baardbi
Well-known member
The script I had was not so great. This method is better. It's actually what you suggested yourself. Destroy the sword when the player is hurt. However, this is not straight forward. The sword object can have a different object ID every time it is created. So we need to make sure we have a way of addressing the sword object. So do this:
1. Make a new User Variable called swordObject
2. In the input script ChangeToAttack_AdventureBase.asm you need to add something below these lines:
CreateObject tempA, tempB, tempC, #WEAPON_DOWN_STATE, currentNametable
CreateObject tempA, tempB, tempC, #WEAPON_RIGHT_STATE, currentNametable
CreateObject tempA, tempB, tempC, #WEAPON_UP_STATE, currentNametable
CreateObject tempA, tempB, tempC, #WEAPON_LEFT_STATE, currentNametable
So it should look like this:
CreateObject tempA, tempB, tempC, #WEAPON_DOWN_STATE, currentNametable
STX swordObject
CreateObject tempA, tempB, tempC, #WEAPON_RIGHT_STATE, currentNametable
STX swordObject
CreateObject tempA, tempB, tempC, #WEAPON_UP_STATE, currentNametable
STX swordObject
CreateObject tempA, tempB, tempC, #WEAPON_LEFT_STATE, currentNametable
STX swordObject
You need to hunt through the file to find those lines and add STX swordObject below. Don't add STX swordObject for the last CreateObject line. That's the projectile weapon.
3. Then finally in the playerHurt file add this just before +notAlreadyInHurtState :
Now the sword object should be destroyed when the player is hurt.
1. Make a new User Variable called swordObject
2. In the input script ChangeToAttack_AdventureBase.asm you need to add something below these lines:
CreateObject tempA, tempB, tempC, #WEAPON_DOWN_STATE, currentNametable
CreateObject tempA, tempB, tempC, #WEAPON_RIGHT_STATE, currentNametable
CreateObject tempA, tempB, tempC, #WEAPON_UP_STATE, currentNametable
CreateObject tempA, tempB, tempC, #WEAPON_LEFT_STATE, currentNametable
So it should look like this:
CreateObject tempA, tempB, tempC, #WEAPON_DOWN_STATE, currentNametable
STX swordObject
CreateObject tempA, tempB, tempC, #WEAPON_RIGHT_STATE, currentNametable
STX swordObject
CreateObject tempA, tempB, tempC, #WEAPON_UP_STATE, currentNametable
STX swordObject
CreateObject tempA, tempB, tempC, #WEAPON_LEFT_STATE, currentNametable
STX swordObject
You need to hunt through the file to find those lines and add STX swordObject below. Don't add STX swordObject for the last CreateObject line. That's the projectile weapon.
3. Then finally in the playerHurt file add this just before +notAlreadyInHurtState :
TXA
PHA
LDX swordObject
DestroyObject
PLA
TAX
Now the sword object should be destroyed when the player is hurt.