1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Help with fixing a spell

Discussion in 'Triggers & Scripts' started by MatiS, Jul 5, 2015.

  1. MatiS

    MatiS

    Joined:
    Feb 23, 2015
    Messages:
    208
    Resources:
    29
    Models:
    27
    Packs:
    2
    Resources:
    29
    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.
     
  2. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,190
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    The owner and caster are not set.

    Don't use a wait in a short periodic loop.
     
  3. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    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/
     
  4. MatiS

    MatiS

    Joined:
    Feb 23, 2015
    Messages:
    208
    Resources:
    29
    Models:
    27
    Packs:
    2
    Resources:
    29
    '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
    . 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
     
  5. venger07

    venger07

    Joined:
    Dec 21, 2010
    Messages:
    429
    Resources:
    5
    Icons:
    4
    Maps:
    1
    Resources:
    5
    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: Jul 9, 2015
  6. MatiS

    MatiS

    Joined:
    Feb 23, 2015
    Messages:
    208
    Resources:
    29
    Models:
    27
    Packs:
    2
    Resources:
    29
    Ok, thanks, I'm gonna try it when I have time :D

    EDIT:Well, I tried everything, it just doesn't work. Triggers look ok, but nothing happens. Here's the map, maybe problem's there: View attachment ShadowImageTest.w3x
     
    Last edited: Jul 17, 2015