Hi. My name is Sami, and I decided introducing in the world of ACS and Decorate when Zdoom version 2.6.0 was out and so I begin to make a simple mod to try out the features of both languages, but I reached the problem that we all have, the use and access of user_vars in weapons. So googling i was took here and, after reading the replies in the topic, i contemplate the only way to make this to work, and i achieved it!
Before i explain what i did (which is not very difficult, but like the programmer i am i hate it) i will tell you the context of the problem: the playerclass i was doing, a rogue, has a stealth attack in the same weapon (Fire state) he usually uses so it needed a new "stealth state" (entered by the AltFire) in order to attack differently when the player controlling it wanted to. It was obvius that needed a "state" variable so i tried it with no result. Declaring the variable (its name is user_stealth) in the weapon and tried to use "A_SetUserVar" prints a warning error in game "no user_stealth var in the rogue actor". So, understanding the error i declared the variable in the playerclass actor and the error was gone, but when i tried to get variable's value the code didn't compile like yours. It's strange that you can set a variable but you can't get its value. The line that didn't work was this:
Code: Select all
A_JumpIf(user_stealth==1),"StealthFire")
Well, the solution is to access to variable's value via ACS. Its dirty but it's the only way. When you want to get variable's value, like this line:
Code: Select all
A_JumpIf((ACS_ExecuteWithResult(2)==1),"StealthFire")
You have to call the script (in this example, the script 2) that returns variable's value. The script 2 is like this:
Code: Select all
script 2 (void) {
SetResultValue(GetUserVariable(0,"user_stealth"));
}
It gets the variable "user_stealth" of the TID 0 (the first parameter of GetUserVariable) which is the player. In this case is good to have the variable declared in the player actor, because i dont know how to get the TID of a weapon you have never picked up and i didn't have curiosity of how to get it. The dirty thing is that you need to put that script 2 in all map that may be needed or rather you will have that rogue trying to make a stealthy stab. I hope this helps a little.
And sorry for my english, i'm spanish.
PS: Soon i will post a WIP thread with all what i have done of my mod.
Hi. My name is Sami, and I decided introducing in the world of ACS and Decorate when Zdoom version 2.6.0 was out and so I begin to make a simple mod to try out the features of both languages, but I reached the problem that we all have, the use and access of user_vars in weapons. So googling i was took here and, after reading the replies in the topic, i contemplate the only way to make this to work, and i achieved it!
Before i explain what i did (which is not very difficult, but like the programmer i am i hate it) i will tell you the context of the problem: the playerclass i was doing, a rogue, has a stealth attack in the same weapon (Fire state) he usually uses so it needed a new "stealth state" (entered by the AltFire) in order to attack differently when the player controlling it wanted to. It was obvius that needed a "state" variable so i tried it with no result. Declaring the variable (its name is user_stealth) in the weapon and tried to use "A_SetUserVar" prints a warning error in game "no user_stealth var in the rogue actor". So, understanding the error i declared the variable in the playerclass actor and the error was gone, but when i tried to get variable's value the code didn't compile like yours. It's strange that you can set a variable but you can't get its value. The line that didn't work was this:
[code]A_JumpIf(user_stealth==1),"StealthFire")[/code]
Well, the solution is to access to variable's value via ACS. Its dirty but it's the only way. When you want to get variable's value, like this line:
[code]A_JumpIf((ACS_ExecuteWithResult(2)==1),"StealthFire")[/code]
You have to call the script (in this example, the script 2) that returns variable's value. The script 2 is like this:
[code]script 2 (void) {
SetResultValue(GetUserVariable(0,"user_stealth"));
}[/code]
It gets the variable "user_stealth" of the TID 0 (the first parameter of GetUserVariable) which is the player. In this case is good to have the variable declared in the player actor, because i dont know how to get the TID of a weapon you have never picked up and i didn't have curiosity of how to get it. The dirty thing is that you need to put that script 2 in all map that may be needed or rather you will have that rogue trying to make a stealthy stab. I hope this helps a little.
And sorry for my english, i'm spanish.
PS: Soon i will post a WIP thread with all what i have done of my mod.