These functions are something I created to help ease the pain of maintaining loops, and loops inside of loops because whenever something goes wrong (and it ALWAYS has that possibility), debugging complex loops can be a total bitch when there's multiple A_SetUserVar/Arrays involved. This takes care of automatic jumping back to specified states while the actor still needs to loop, and jumping into the appropriate state or not jumping at all when it reaches the quota.
In short, one could think of this as a for loop (or make it into a while loop if you want! Just set the increment to 0.)
This could also be thought of as an if/else statement when used properly, just no "else ifs" and it only works with user vars/arrays.
This function is capable of incrementing and decrementing.
Parameters:
- State Progress - If the repeating is still "in progress", this is where the function will jump to.
- user(var/array) - The name of the user variable/array goes here. For an array, it works just like how A_SetUserArray is worked, i.e. A_SetUserArray(user_t,0,1).
- Position (Array Only) - The position of the array to modify its contents.
- Increment - How much to increment (or decrement if going down) whenever pushing the "varray" closer to the limit.
- Limit - The goal for the function to reach, in terms of incrementing a user var.
- Flags - See below. Optional.
- Final Value - If the limit is reached, the function will set the user var to this value once completed. Optional.
- State Finished - This is the state the function will jump to instead of the progress state if the function completes setting the increment to the limit. Optional
- RPF_OVERCOUNT - If the function exceeds above/below the limit based upon which direction it's going, it would set it directly to the limit/final var and discard anything else. This flag makes it keep the leftovers and apply them to whatever the variable is set to, after it's set.
- RPF_KEEPVAR - If final var is 0, instead of setting the var to 0 as well, keep it at the limit (and overcount if specified).
This cybie will only fire one rocket when he attacks for the very first time, and only the first time. Every other time, he will fire 3 rockets as usual, featuring the (in/de)crement abilities, unless he is interrupted by pain. In which case, he must finish his volley before being able to fire another full 3 rounds at his foe.
Code: Select all
Actor MCD : CyberDemon
{
var int user_t[1];
+BUDDHA
+DONTRIP
+REFLECTIVE
States
{
See:
CYBR A 3 A_Hoof
CYBR A 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
CYBR A 3 A_Chase
CYBR A 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
CYBR B 3 A_Chase
CYBR B 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
CYBR B 3 A_Chase
CYBR B 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
CYBR C 3 A_Chase
CYBR C 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
CYBR C 3 A_Chase
CYBR C 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
CYBR D 3 A_Metal
CYBR D 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
CYBR D 3 A_Chase
CYBR D 0 A_SpawnItemEx("MCDShadow",0,0,0,0,0,0,0,32|SXF_TRANSFERSPRITEFRAME)
Loop
Missile:
Missile2: //Fires only ONE rocket, on its VERY FIRST EVER attack. After that, fires 3 like normal.
CYBR E 12 A_FaceTarget
CYBR E 0 A_LogInt(user_t[0])
CYBR F 12 A_CyberAttack
"####" "#" 0 A_RepeatArray("Missile2",user_t,0,1,0,0,3,"See")
"####" "#" 0 A_LogInt(user_t[0]) //This frame will never be reached.
Goto See
}
}
Actor MCDShadow
{
+NOINTERACTION
Alpha 0.75
States
{
Spawn:
"####" "#" 1 A_FadeOut(0.05)
Wait
}
}
