Switch object melee weapons graphics midgame 4.1.5 (easy)

mouse spirit

Well-known member
All i used was an input script (b_create_melee_weapon.asm) used with the B Button ,a user variable, and a Game Object (your object melee weapon).
This uses different actions in the same Game Object to be used as different looking weapons.
This is for graphical changes, but could help with other things.

This should work in the platformer module with NESmaker 4.1.5. but assumes that you already have a working object melee weapon, not sprite weapon.

1. Create a user variable in project settings.Name it
whatever you like but make it's value 0.

2. Open your melee object weapon input script.Go to around line 85 (probly). You will see CreateObject temp, blah blah....Erase that line and enter this...

Code:
;changing object melee weapon
LDA (your user variable)
CMP #$00
BEQ ++
JMP weap2

++
;;;weap1:
CreateObject temp, temp1 ,  #OBJECT_PLAYER_MELEE, #$00, temp3
JMP meleeCreated
weap2:
CreateObject temp, temp1 , #OBJECT_PLAYER_MELEE, #$01, temp3

3. Save your script.( That JMP to meleeCreated assumes that it is in your object melee script already.If not, just make sure to JMP to right after the code we just went over.)(Also I assume that you already are using constant OBJECT_PLAYER_MELEE)

4. Go to your first action of you melee object weapon Game Object, that action 0 now essentially represents weapon 1.Action 1 is weapon 2, and so on. Make graphics/animations accordingly and set your end animation/actions n stuff in each action step(like destroy at end step,if thats what you already have goin on with your weapon).
Our code we implimented changes the action state of object melee weapon to whatever your user variable currently equals.

This script is a simple check for 2 weapons.If you understand it,you can add as many weapons as actions for that weapon(8).If you want to change weapons,simply have a tile/collectable/whatever change the user variable you created. I have a collectable change my which_weapon variable (INC which_weapon).

Hope it works for you as it does for me. It should normally unless i made a typo in the code on here
 

mouse spirit

Well-known member
Thanks dale. I have a question though. my variable which_weapon, i'm also using it for the attack damage of each weapon.
Weapon 1 has power of 1, 2 has power of 2. Works fine with HandleHurtMonster , except that i hit before i compare enemys life to #$01,
so when enemy has 1 health left his life then actually goes to -#$01 so it's less than #$01. Dude never dies. So my question is how do i compare
if enemies health is less than #$00 at the same time? Lastly, it works if my variable is certain numbers and enemy health is certain ( like my attack is 1 or 2 and enemies health is 2 or 4 or 6 ...... because the CMP works out) Heres my small edit to HandleHurtMonster_DC.

Code:
skipRecoilBecauseOnEdge:
        LDA Object_health,x
        SEC
        SBC which_weapon ;;;;;my edit is here<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        CMP #$01      ;;;;;i also tried CMP which_weapon
        BCC +
		JMP notMonsterDeath
	+

        DeactivateCurrentObject
        PlaySound #SND_SPLAT
        ;;;;;;;;;;;;;;;;;; ok, so now we also add points to score

Edit: I may have fixed it by just putting the CMP before SBC. Only drawback is that now its like they take one extra hit.Thats fine i will just account for it.

Now the next thing would be to understand if and when the enemy knows it was hit with a melee or projectile, as projectiles will be affected by this
 

mouse spirit

Well-known member
I don't think so. This calls objects. But if you know what you're doing then the script could rewritten to maybe call up sprites.
 
Top Bottom