Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
I need some help with something that is seemingly very simple, but I can't get it to work.
I read a lot of wiki documentation and tried to figure out some examples, but I don't understand why my "regular integer" variable doesn't work.
So I converted a DECORATE actor from flametraps.pk3 (realm667) to ZScript and everything works fine, but the modification here is to no longer use the ACS Args[] to reset one of the integers (user_shotdelay) back to its initial value, but a custom defined user int variable with a value set by the editor in UDMB in the map.
The ZScript class works fine if I don't add that regular int (shotcountdelay), but then I can't reset user_shotdelay to its initial value, and thus it will only shoot once.
So basically when I add the regular int, seemingly nothing happens anymore and I can't tell where exactly it's "hanging" or why nothing happens.
Can anyone explain how to deal with this?
Thanks in advance.
ZScript Actor Class:
Spoiler:
//Based on flametraps.pk3 DECORATE
Class Model_FireballSpitter : SwitchableDecoration {
Default {
+SOLID
+INVULNERABLE
+NODAMAGE
+SHOOTABLE
+NOTAUTOAIMED
+NEVERTARGET
+DONTTHRUST
+NOCLIP
+NOGRAVITY
Radius 1;
Height 40;
}
int user_shotdelay;
int user_shotspeed;
int shotcountdelay;
Override Void PostBeginPlay() // to set a default value if values are zero
{
Super.PostBeginPlay();
If (user_shotdelay <= 0) {
user_shotdelay=3;
}//Args[0]; // 3 seconds delay -> Args[0] is the arguments tab though !! don't use it
If (user_shotspeed <= 0) {
user_shotspeed=25;
}//Args[1]; // 25 velocity for projectile
}
States
{
Active:
//Goto Spawn;
Spawn:
MODL A 0 {shotcountdelay=user_shotdelay;} // reset to initial value (set in UDMB (or taken from default PostBeginPlay))
SpitDelay:
MODL A 35 {shotcountdelay=shotcountdelay-1;}
MODL A 0 A_JumpIf(shotcountdelay==0,"SpitFireball");
Loop;
SpitFireball:
MODL A 8 Bright
{
A_SpawnItemEx ("SpitterShot", 5, 0, 5, user_shotspeed, 0, 0, 0, 0, 0, 0);
}
Goto Spawn;
Inactive:
MODL A 0;
Stop;
}
}