• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Help with fixing a spell

Status
Not open for further replies.
Level 20
Joined
Feb 23, 2015
Messages
243
Hi
I made spell for my map. It's similar to teleportation that's used by Adepts in Starcraft. Unit creates immortal image of himself that cannot attack and cast abilities. After some time caster teleports to image's location. Problem is, that when caster casts spell nothing happens. Here are triggers (I hope I translated them correctly):
  • SIConfiguration
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Spell Variable: --------
      • Set SI_Spell = Shadow Image
      • -------- Time to teleportation --------
      • Set SI_Time = 7.00
      • -------- Shadow Image speed multiplier --------
      • Set SI_UnitSpeedMultiplier = 1.25
      • -------- Shadow Image's colouring and transparency (%) --------
      • Set SI_Blue = 100.00
      • Set SI_Green = 50.00
      • Set SI_Red = 30.00
      • Set SI_Transparency = 30.00
      • -------- If Shadow Image is invisible (0=no;1=yes) --------
      • Set IfInvisible = 0
      • -------- If Shadow Image is immortal (0=no;1=yes) --------
      • Set IfImmortal = 1
  • SICast
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to SI_Spell
    • Actions
      • Set SI_Index = (SI_Index + 1)
      • Set SI_Caster[SI_Index] = (Casting unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SI_Index R Equal to 1
        • Then - Akcje
          • Trigger - Turn on SILoop <gen>
        • Else - Actions
  • SILoop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SI_Loop) from 1 to SI_Index, do (Actions)
        • Loop - Actions
          • Set SI_CasterLocation[SI_Loop] = (Position of SI_Caster[SI_Loop])
          • Unit - Create 1 (Unit-type of SI_Caster[SI_Loop]) for (Owner of SI_Caster[SI_Loop]) at SI_CasterLocation[SI_Loop] facing Default building facing degrees
          • Set SI_Unit[SI_Loop] = (Last created unit)
          • Custom script: call RemoveLocation(udg_SI_CasterLocation[udg_SI_Loop])
          • Unit - Turn off supply usage for SI_Unit[SI_Loop]
          • Unit - Set SI_Unit[SI_Loop] movement speed to ((Default movement speed of SI_Unit[SI_Loop]) x SI_UnitSpeedMultiplier)
          • -------- Removes Attack --------
          • Unit - Add NoAttack(SI) to SI_Unit[SI_Loop]
          • -------- Custom Value for turning off abilities --------
          • Unit - Set the custom value of SI_Unit[SI_Loop] to 2
          • Animation - Change SI_Unit[SI_Loop]'s vertex coloring to (SI_Red%, SI_Green%, SI_Blue%) with SI_Transparency% transparency
          • Unit - Turn collision for SI_Unit[SI_Loop] WyĹ‚.
          • Unit - Remove SI_Spell from SI_Unit[SI_Loop]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IfInvisible Equal to 1
            • Then - Actions
              • Unit - Add Ghost to SI_Unit[SI_Loop]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IfImmortal Equal to 1
            • Then - Actions
              • Unit - Make SI_Unit[SI_Loop] Indestructible
            • Else - Actions
          • Wait SI_Time seconds
          • Set SI_Location[SI_Loop] = (Position of SI_Unit[SI_Loop])
          • Unit - Remove SI_Unit[SI_Loop] from the game
          • Unit - Move SI_Caster[SI_Loop] instantly to SI_Location[SI_Index]
          • Custom script: call RemoveLocation(udg_SI_Location[udg_SI_Loop])
          • Set SI_Index = (SI_Index - 1)
          • Set SI_Loop = (SI_Loop - 1)
  • SITurnOffAbilities
    • Events
      • Unit - A unit begins casting an ability
    • Conditions
      • (Custom value of (Triggering unit)) Equal to 2
    • Actions
      • Unit - Pause (Triggering unit)
      • Unit - Order (Triggering unit) to Stop
      • Unit - Unpause (Triggering unit)
I would be grateful for help :D.
 
What is this line?
  • SI_Index R Equal to 1
Maybe it was a typo. But the "R" shouldn't be there. Add a game message within SILoop and make sure that the trigger is being ran.

But your spell probably won't work for other reasons, such as the wait. I don't think you need a periodic trigger if you just need to create a unit, wait 7 seconds, and then remove it. Also, the way the loop is setup makes it so that all concurrent spell instances will have a 7 second delay before they do anything. You should either use a different method, or use a counter variable to track how much time has elapsed for an instance:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/mui-triggers-waits-218354/
http://www.hiveworkshop.com/forums/...279/mui-spells-using-artificial-waits-223315/
 
Level 20
Joined
Feb 23, 2015
Messages
243
'R' was just my mistake during translation, it's not in code :D. I changed trigger to use loop and counter instead of wait. Problem is, that
The owner and caster are not set.
. Even after I put triggers that summon unit outside the loop nothing happens. Something is wrong with:
  • Set SI_Caster[SI_Index] = (Triggering unit)
, but I have no idea what. Probably somethin' really easy...

PS: I checked loop, it doesn't even run
 
Level 13
Joined
Dec 21, 2010
Messages
541
your problem is that you use WAIT inside the loop in every 0.10 seconds.. that would be super leak.. xD


Rework your Cast and Loop Trigger

  • SICast
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to SI_Spell
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • SI_Mui[0] Equal to 0
      • Then - Actions
        • Trigger - Turn on SILoop <gen>
      • Else - Actions
    • Set SI_Mui[0] = (SI_Mui[0] + 1)
    • Set SI_Mui[1] = (SI_Mui[1] + 1)
    • Set SI_Caster[SI_Mui[1]] = (Casting unit)
    • -------- REAL ARRAY --------
    • Set SI_Duration[SI_Mui[1]] = SI_Time
    • -------- Caster Point --------
    • Set SI_CasterLocation = (Position of SI_Caster[SI_Mui[1]])
    • -------- Dummy --------
    • Unit - Create 1 (Unit-type of SI_Caster[SI_Mui[1]]) for (Owner of SI_Caster[SI_Mui[1]]) at SI_CasterLocation facing Default building facing degrees
    • Set SI_Dummy[SI_Mui[1]] = (Last created unit)
    • Unit - Turn off supply usage for SI_Dummy[SI_Mui[1]]
    • Unit - Set SI_Dummy[SI_Mui[1]] movement speed to ((Default movement speed of SI_Dummy[SI_Mui[1]]) x SI_UnitSpeedMultiplier)
    • -------- Removes Attack --------
    • Unit - Add NoAttack(SI) to SI_Dummy[SI_Mui[1]]
    • -------- Custom Value for turning off abilities --------
    • Unit - Set the custom value of SI_Dummy[SI_Mui[1]] to 2
    • Animation - Change SI_Dummy[SI_Mui[1]]'s vertex coloring to (SI_Red%, SI_Green%, SI_Blue%) with SI_Transparency% transparency
    • Unit - Turn collision for SI_Dummy[SI_Mui[1]]
    • Unit - Remove SI_Spell from SI_Dummy[SI_Mui[1]]
    • -------- The dummy is invisible??? --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • IfInvisible Equal to 1
      • Then - Actions
        • Unit - Add Ghost to SI_Dummy[SI_Mui[2]]
      • Else - Actions
        • -------- The dummy is invulnerable??? --------
        • Unit - Make SI_Dummy[SI_Mui[2]] Indestructible
    • Custom script: call RemoveLocation(udg_SI_CasterLocation)


  • SILoop
  • Events
    • Time - Every 0.10 seconds of game time
  • Conditions
  • Actions
    • For each (Integer SI_Mui[2]) from 1 to SI_Mui[1], do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • SI_Duration[SI_Mui[2]] Greater than 0.00
          • Then - Actions
            • Set SI_Duration[SI_Mui[2]] = SI_Duration[SI_Mui[2]] - 0.10
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • SI_Duration[SI_Mui[2]] Less than or Equal to 0.00
              • Then - Actions
                • Set SI_Location[SI_Mui[2]] = (Position of SI_Dummy[SI_Mui[2]])
                • Unit - Remove SI_Dummy[SI_Mui[2]] from the game
                • Unit - Move SI_Caster[SI_Mui[2]] instantly to SI_Location[SI_Mui[2]]
                • Custom script: call RemoveLocation(udg_SI_Location[SI_Mui[2]])
                • Set SI_Duration[SI_Mui[2]] = 0.00
                • Set SI_Caster[SI_Mui[2]] = No Unit
                • Set SI_Dummy[SI_Mui[2]] = No Unit
                • Set SI_Mui[0] = (SI_Mui[0] - 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • SI_Mui[0] Equal to 0
                  • Then - Actions
                    • Trigger - Turn off this trigger
                    • Set SI_Mui[0] = 0
                    • Set SI_Mui[1] = 0
                  • Else - Actions
                • Else - Actions
        • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top