Figuring that when you pick up a weapon, the decorate code for user variables must transfer their target to the player, I created a new player class that had the same user variables as the weapon definition. However, the weapon still didn't work. In particular, this line was causing me problems:
Code: Select all
SPEL A 0 A_JumpIfInventory("DynamicMana",user_dynamic,"CheckStatic")
After looking at A_JumpIfInventory, I had the hunch that user_dynamic might be considered 0, because if it was, I would need to have my max mana before I made the jump. I tried deleting the line "var int user_dynamic;" from my weapon definition (but left the variable in my player class definition) and sure enough, upon starting Zdoom, it told me, "Script error, "MyWad.pk3:spelcast.txt" line 51: Unknown identifier 'user_dynamic'", where line 51 is the one that calls A_JumpIfInventory.
In short, it appears as though a user variable in a weapon references the variable of the player when writing a variable, but the user variable of the weapon when reading the variable. This is awfully inconvenient, to the point where I figured it was probably a bug. Is this the intended behavior? If so, why? And how do I get around it so I can use variable in my weapons?
I'll replicate the bug in a controlled wad and post it when I get a chance.