Skill Trigger Help (Index)

Bankde

Member
Reaction score
20
The problem occur rarely with this trigger (About 1 in 40-60) Not sure what happen. The Bullet should be moved periodically but sometimes it stop moving, not damage, and appear as it isn't there at all. (Max bullet is 3 but if there is one bullet stop moving, the bullet in the map will be 4)

Trigger:
  • Shot Moving
    • Events
      • Time - BulletTimer expires
    • Conditions
    • Actions
      • For each (Integer ShotLoopIndex) from 1 to ShotIndex, do (Actions)
        • Loop - Actions
          • Set BulletPoint = (Position of Shot[ShotLoopIndex])
          • Set BulletPoint_Move = (BulletPoint offset by (Real((BulletSpeed / 25))) towards 90.00 degrees)
          • Unit - Move Shot[ShotLoopIndex] instantly to BulletPoint_Move, facing 90.00 degrees
          • Unit Group - Pick every unit in UndeadGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between (Position of Shot[ShotLoopIndex]) and (Position of (Picked unit))) Less than or equal to 90.00
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • Unit - Remove Shot[ShotLoopIndex] from the game
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (Real(BulletDamage)))
                  • Set Bullet = (Bullet + 1)
                  • Special Effect - Create a special effect at BulletPoint_Move using Abilities\Weapons\SteamTank\SteamTankImpact.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
                  • Set ShotIndex = (ShotIndex - 1)
                  • Set ShotLoopIndex = (ShotLoopIndex - 1)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Spawn Region <gen> contains Shot[ShotLoopIndex]) Equal to True
            • Then - Actions
              • Set Bullet = (Bullet + 1)
              • Unit - Remove Shot[ShotLoopIndex] from the game
              • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
              • Set ShotIndex = (ShotIndex - 1)
              • Set ShotLoopIndex = (ShotLoopIndex - 1)
            • Else - Actions


Trigger:
  • Shot
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Bullet Greater than or equal to 1
        • Then - Actions
          • Set Bullet = (Bullet - 1)
          • Animation - Play Surviving Sniper 0000 <gen>'s attack animation
          • Set PointofSniper = (Position of Surviving Sniper 0000 <gen>)
          • Set ShotIndex = (ShotIndex + 1)
          • Unit - Order Surviving Sniper 0000 <gen> to Stop
          • Unit - Make Surviving Sniper 0000 <gen> face 90.00 over 0.10 seconds
          • Unit - Create 1 Dummy for Player 1 (Red) at PointofSniper facing 90.00 degrees
          • Set Shot[ShotIndex] = (Last created unit)
          • If (ShotIndex Equal to 1) then do (Countdown Timer - Start BulletTimer as a Repeating timer that will expire in 0.04 seconds) else do (Do nothing)
        • Else - Actions

Trigger:
  • Sniper Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set BulletSpeed = 150
      • Set BulletDamage = 1
      • Set Bullet = 3
      • Set PointofSniper = (Position of Surviving Sniper 0000 <gen>)


Thank in advance (I can't solve it myself because the problem doesn't always occur)
 

Gummi_Bears

New Member
Reaction score
5
I can see leaks with the Bullet point and BulletPoint_Move. Also what's this for?
Trigger:
  • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
    • Set ShotIndex = (ShotIndex - 1)
    • Set ShotLoopIndex = (ShotLoopIndex - 1)


Also in your map init you set PointofSniper. There's no point of this if you reset that point in your Shot trigger.

Maybe you could remake the timer. Use the 0.04 periodic event which turns on whenever you press up. If you can't be stuffed or think my trigger sucks all I can suggest if fix those leaks! Cause I dont know :(
(Free-hand) Hope you understand!

Trigger:
  • Shot Init
    • Events
      • Player - Player 1 (Red) Presses Up Arrow Key
    • Conditions
    • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Bullet Equal to 3
      • Then - Actions
        • Turn on Shot Moving
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Bullet is Greater than or Equal to 1
      • Then - Actions
        • Set Bullet = (Bullet - 1)
        • Set ShotIndex = (ShotIndex + 1)
        • Set BulletComplete[ShotIndex] = False
        • Animation - Play Surviving Sniper 0000 <gen>'s attack animation
        • Set PointofSniper = (Position of Surviving Sniper 0000 <gen>)
        • Unit - Order Surviving Sniper 0000 <gen> to Stop
        • Unit - Make Surviving Sniper 0000 <gen> face 90.00 over 0.10 seconds
        • Unit - Create 1 Dummy for Player 1 (Red) at PointofSniper facing 90.00 degrees
        • Set Shot[ShotIndex] = (Last created unit)
        • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
        • customScript: call RemoveLocation PointofSniper
      • Else - Actions



Trigger:
  • Shot Moving
    • Events
      • Every 0.04 seconds of the game
    • Conditions
    • Actions
      • For each (Integer ShotLoopIndex) from 1 to ShotIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions BulletComplete[ShotLoopIndex] = False
            • Then - Actions
              • Set BulletPoint = (Position of Shot[ShotLoopIndex])
              • Set BulletPoint_Move = (BulletPoint offset by (Real((BulletSpeed / 25))) towards 90.00 degrees)
              • Unit - Move Shot[ShotLoopIndex] instantly to BulletPoint_Move, facing 90.00 degrees
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Spawn Region <gen> contains Shot[ShotLoopIndex]) Equal to True
                • Then - Actions
                  • Set BulletComplete[ShotLoopIndex] = True
                • Else - Actions
              • Unit Group - Pick every unit in UndeadGroup and do (Actions)
              • Loop - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Distance between (Position of Shot[ShotLoopIndex]) and (Position of (Picked unit))) Less than or equal to 90.00
                    • ((Picked unit) is alive) Equal to True
                  • Then - Actions
                    • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (Real(BulletDamage)))
                    • Set BulletComplete[ShotLoopIndex] = True
                  • Else - Actions
            • Else
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Bullet is Equal to 3
                • Then - Actions
                  • Turn off (This trigger)
                  • Set ShotIndex = 0
                • Else - Actions
              • Set Bullet = Bullet + 1
              • Unit - Remove Shot[ShotLoopIndex] from the game
              • Special Effect - Create a special effect at BulletPoint_Move using Abilities\Weapons\SteamTank\SteamTankImpact.mdl
              • Special Effect - Destroy (Last created special effect)
            • customscript: call RemoveLocation (udg_BulletPoint[udg_ShotLoopIndex])
            • customscript: call RemoveLocation (udg_BulletPoint_Move[udg_ShotLoopIndex])


Changed your triggers slightly. Variables added:
BulletComplete - Boolean, Array
 

Bankde

Member
Reaction score
20
I can see leaks with the Bullet point and BulletPoint_Move. Also what's this for?
Trigger:
  • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
    • Set ShotIndex = (ShotIndex - 1)
    • Set ShotLoopIndex = (ShotLoopIndex - 1)

It isn't leak because if you don't have it, index will be changed and turn wrong.

PS: This trigger works very well. But for no reason, sometimes (1%) when bullet is damaging, this trigger work wrong leaving that bullet on the map while other variable is correct. Only problem is "There is 1% when the bullet damage not to remove unit out". I don't know what's reason and I've never seen sth like this before.

Thank for replying +rep
 

Gummi_Bears

New Member
Reaction score
5
Relook at my post...I edited it but you replied five minutes before :p. Just made it easier to see and fixed some stuff in the beginning triggers so it doesn't fail.

It isn't leak because if you don't have it, index will be changed and turn wrong.
. I still don't get it. I copied that from inside your loop within every 0.04 sec. And I still don't get the problem fully. 1% when the bullet damage what? Also why is everything at 90 degrees :O

Edit: Btw my trigger as well as yours, would make the bullet keep flying until it reaches an undead or that region. Added expiration timer! I got a cool fading system by Paladon, want me to implement it in the trigger?
 

hgkjfhfdsj

Active Member
Reaction score
55
maybe a clash with your other triggers? for example, changes to UndeadGroup.. (which in this trigger deals the damage and removes the bullet from the index)?

otherwise the only thing i can think of is that both the conditions of the 2 if then else returns true.. ie
Trigger:
  • (Spawn Region <gen> contains Shot[ShotLoopIndex]) Equal to True

which means the loop index is freed twice, removing the same unit that was moved to the recently removed index. so realistically, the top indexed unit that is moved to the current loop index is in Spawn Region<gen>, and so this unit is freed, despite the unit for the current index being already freed. not sure if im clear :p to fix this add the conditions with "or" then nest an if/then/else for condition
Trigger:
  • (Distance between (Position of Shot[ShotLoopIndex]) and (Position of (Picked unit))) Less than or equal to 90.00
    • ((Picked unit) is alive) Equal to True

for the effects, and so only doing the
Trigger:
  • Set Bullet = (Bullet + 1)
    • Unit - Remove Shot[ShotLoopIndex] from the game
    • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
    • Set ShotIndex = (ShotIndex - 1)
    • Set ShotLoopIndex = (ShotLoopIndex - 1)

once in the entire trigger.
 

Gummi_Bears

New Member
Reaction score
5
How can you effeciently imply the 'or' in the trigger if it its within a unit group function? Also his original unit group trigger had the damage part, and the spawn region did not. How can you use nested if statments to fix? :eek:
 

Bankde

Member
Reaction score
20
Still having problem (More problem with Gummi_Bears trigger) -*-

I don't think my trigger is leak because everything is variable and although I don't remove it, it will leak ONLY 4 bytes. And when the variable is rewritten, the old information will be replaced by new one which nothing is leak. (Also no need to use custom script to remove leak)

Your trigger are fully leak because
Trigger:
  • Set ShotIndex = (ShotIndex + 1)


You set Index+1 each times which will create 1 more array leaving old information leaking. That's why I need to -1 to index when it was finished.

When I test my map more, I observe more mysterious of this problem. "The bullet stop moving" will occur rarely and it will occur only once. I try to make it occur once then refresh all unit in map. Then it occur again leaving 1 bullet on the map. There is always 1 "non-moving bullet" on the map everytimes and never become 2. I think the problem is about indexing as hgkjhfdsj said. But I don't know how can I put "or" in the trigger (As Gummi_Bears said) ??

PS: +rep to hgkjfhfdsj for helping me a lot (Also teaching me about index)
 

sentrywiz

New Member
Reaction score
25
The problem occur rarely with this trigger (About 1 in 40-60) Not sure what happen. The Bullet should be moved periodically but sometimes it stop moving, not damage, and appear as it isn't there at all. (Max bullet is 3 but if there is one bullet stop moving, the bullet in the map will be 4)

Trigger:
  • Shot Moving
    • Events
      • Time - BulletTimer expires
    • Conditions
    • Actions
      • For each (Integer ShotLoopIndex) from 1 to ShotIndex, do (Actions)
        • Loop - Actions
          • Set BulletPoint = (Position of Shot[ShotLoopIndex])
          • Set BulletPoint_Move = (BulletPoint offset by (Real((BulletSpeed / 25))) towards 90.00 degrees)
          • Unit - Move Shot[ShotLoopIndex] instantly to BulletPoint_Move, facing 90.00 degrees
          • Unit Group - Pick every unit in UndeadGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between (Position of Shot[ShotLoopIndex]) and (Position of (Picked unit))) Less than or equal to 90.00
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • Unit - Remove Shot[ShotLoopIndex] from the game
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (Real(BulletDamage)))
                  • Set Bullet = (Bullet + 1)
                  • Special Effect - Create a special effect at BulletPoint_Move using Abilities\Weapons\SteamTank\SteamTankImpact.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
                  • Set ShotIndex = (ShotIndex - 1)
                  • Set ShotLoopIndex = (ShotLoopIndex - 1)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Spawn Region &lt;gen&gt; contains Shot[ShotLoopIndex]) Equal to True
            • Then - Actions
              • Set Bullet = (Bullet + 1)
              • Unit - Remove Shot[ShotLoopIndex] from the game
              • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
              • Set ShotIndex = (ShotIndex - 1)
              • Set ShotLoopIndex = (ShotLoopIndex - 1)
            • Else - Actions


Trigger:
  • Shot
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Bullet Greater than or equal to 1
        • Then - Actions
          • Set Bullet = (Bullet - 1)
          • Animation - Play Surviving Sniper 0000 &lt;gen&gt;&#039;s attack animation
          • Set PointofSniper = (Position of Surviving Sniper 0000 &lt;gen&gt;)
          • Set ShotIndex = (ShotIndex + 1)
          • Unit - Order Surviving Sniper 0000 &lt;gen&gt; to Stop
          • Unit - Make Surviving Sniper 0000 &lt;gen&gt; face 90.00 over 0.10 seconds
          • Unit - Create 1 Dummy for Player 1 (Red) at PointofSniper facing 90.00 degrees
          • Set Shot[ShotIndex] = (Last created unit)
          • If (ShotIndex Equal to 1) then do (Countdown Timer - Start BulletTimer as a Repeating timer that will expire in 0.04 seconds) else do (Do nothing)
        • Else - Actions

Trigger:
  • Sniper Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set BulletSpeed = 150
      • Set BulletDamage = 1
      • Set Bullet = 3
      • Set PointofSniper = (Position of Surviving Sniper 0000 &lt;gen&gt;)


Thank in advance (I can't solve it myself because the problem doesn't always occur)



I have to agree with hgkjfhfdsj but this trigger is kinda, a mess. It works for you, but reading and jumping up and down is hard. Especially since the first trigger you posted in tags isn't the activation trigger.

I see large indexing problem. While it may work, I am puzzled by these things:

Trigger:
  • Set BulletPoint = (Position of Shot[ShotLoopIndex])


The very first time this trigger fires, ShotLoopIndex isn't set to anything, so I can only assume because I don't know for sure that variable automatically is given a null value, or a zero. So Shot becomes Last Created Unit[0].

Trigger:
  • Set ShotIndex = (ShotIndex + 1)
    • Set Shot[ShotIndex] = (Last created unit)


These in the first trigger, ShotIndex is probably given a null value as well, so 0+1=1. So Last Created Unit[1].

Now in the above thing, BulletPoint probably wants Last Created Unit to be [1] but in the very first case it is [0]. I think this might be a reason why your stuck bullet doesn't get removed from map.

And these:

Trigger:
  • # Set Shot[ShotLoopIndex] = Shot[ShotIndex]
    • # Set ShotIndex = (ShotIndex - 1)
    • # Set ShotLoopIndex = (ShotLoopIndex - 1)


I don't even wanna bother with these. Ok I will...

So Last Created Unit[0] = Last Created Unit[1]?
Then [1] = 1-1=0?
Finally [0] has becomed [1] but because [1] has becomed [0] so [0] = 0-1=-1?

Is it me or indexing is out of sense and array might get negative value?
I hope my math and logic suck as hell and what I wrote isn't true, because 1% chance of bullet stuck is actually a good thing with these indexes, and indexes in your triggers actually do the good part of the job.
 

Bankde

Member
Reaction score
20
There is no need to set LoopIndex because it work like integer A or integer B like this

While {Loopindex<5} // Do action until Loopindex=5 //
Action
Loopindex++
end function

So there is no need to set it.
Anyway, Thank for the last point, I will think of it. But the best point should be the action of trigger. As hgkjfhfdsj said but I still don't know how to combine 2 conditions into 1.
 

hgkjfhfdsj

Active Member
Reaction score
55
try a skip remaining action in the first if/then/else. that way, if it returns true for the first trigger, the rest is skipped, while if the first is not true, the 2nd will be regardlessly evaluated.

EDIT
actually ignore what i wrote above (forgot this was in a loop)

freehand sketch (very messy when nesting if/then/else in another in GUI..)
Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or (Any conditions true)
        • And (all conditions true)
          • (Distance between (Position of Shot[ShotLoopIndex]) and (Position of (Picked unit))) Less than or equal to 90.00
          • ((Picked unit) is alive) Equal to True
        • (Spawn Region &lt;gen&gt; contains Shot[ShotLoopIndex]) Equal to True
    • Then - Actions
      • ------------------------- damage/effect first before removing --------------------------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between (Position of Shot[ShotLoopIndex]) and (Position of (Picked unit))) Less than or equal to 90.00
        • Then - Actions
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (Real(BulletDamage)))
          • Special Effect - Create a special effect at BulletPoint_Move using Abilities\Weapons\SteamTank\SteamTankImpact.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
    • Else - Actions
    • ------------------------- the rest not in else actions --------------------------
    • Set Bullet = (Bullet + 1)
    • Unit - Remove Shot[ShotLoopIndex] from the game
    • Set Shot[ShotLoopIndex] = Shot[ShotIndex]
    • Set ShotIndex = (ShotIndex - 1)
    • Set ShotLoopIndex = (ShotLoopIndex - 1)
 

sentrywiz

New Member
Reaction score
25
No prob, I hope I was able to help.


I can't think otherwise than there must be an easier way to index these and change the triggers. I may look at it again when I have time, right now I'm not home. Can you pm me with the specifics of what this spell does?
 

Bankde

Member
Reaction score
20
Here the map: View attachment Sniper Arcade Need help.w3x

This problem will occur only once in game. I've tried to put "Break" or "Skip remaining action" but it still happen
(So I've remove "Skip remaining action out because it does nothing).

PS: Don't tell me I'm promoting map because it is just a started map for me and it isn't finished. I just want to solve this problem before continue working on this map.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top