Code: Select all
actor TurnWeapon: PlasmaRifle
{
var int user_angle; // Must also be declared in the player class for this to work!
States
{
Ready:
PLSG A 1 A_WeaponReady
TNT1 A 0 A_Log("Angle:")
TNT1 A 0 A_LogInt(angle)
TNT1 A 0 A_Log("UserVar:")
TNT1 A 40 A_LogInt(user_angle)
TNT1 A 0 A_JumpIf(angle>user_angle,"Ready1")
TNT1 A 0 A_JumpIf(angle<user_angle,"Ready2")
SHT2 A 3
Loop
Ready1:
TNT1 A 0 A_SetUserVar("user_angle",angle)
PLSF A 20 Bright A_Print("READY1")
Goto Ready
Ready2:
TNT1 A 0 A_SetUserVar("user_angle",angle)
PLSF A 20 Bright A_Print("READY2")
Goto Ready
Select:
TNT1 A 0 A_SetUserVar("user_angle",0)
Select2:
PLSG A 1 A_Raise
Loop
}
}
As-is now, the code always enters state Ready2. If however I edit the code with hard values (i.e. A_JumpIf(angle>10)), the code works as it should.
The problem here is probably related to the scope of the var int user_angle:
- I placed var int user_angle; in the weapon actor.
- I placed var int user_angle in the playerclass too (otherwise the code would generate warnings)
- I'm setting the value of user_angle in the weapon's code, yet the next A_JumpIf statement seems to fail.
*edit*
DECORATE code updated. The uservar is reported as 65536, which I assume is the maximum 16-bit integer value. Or is this because something is casted improperly to the LogInt call?