• 🏆 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] Unit Handle Problem

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
This spell is supposed to be a channeled invulnerability. The casting paladin channels for up to 10 seconds, making himself and the target invulnerable.

Problem is, the first time it is cast on a particular unit, the lightning effect moves between the caster and the middle of the map instead of the caster and the target. Any casts after this first time on a target work as intended.

The problem seems to happen in the "THEN" section of the second trigger.

  • Sanctified Bond 01
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to PAL-4 Sanctified Bond
    • Actions
      • Set temp_point = (Position of (Triggering unit))
      • Unit - Create 1 D.PAL-2 Sanctified Bond for (Owner of (Triggering unit)) at temp_point facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Priest - Inner Fire (Triggering unit)
      • Set temp_point2 = (Position of (Target unit of ability being cast))
      • Unit - Create 1 D.PAL-2 Sanctified Bond for (Owner of (Triggering unit)) at temp_point2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Priest - Inner Fire (Target unit of ability being cast)
      • Lightning - Create a Spirit Link lightning effect from source temp_point to target temp_point2
      • Custom script: call RemoveLocation(udg_temp_point)
      • Custom script: call RemoveLocation(udg_temp_point2)
      • Hashtable - Save Handle Of(Target unit of ability being cast) as (Key target) of (Key (Triggering unit)) in H_SanctifiedBond
      • Hashtable - Save Handle Of(Last created lightning effect) as (Key light) of (Key (Triggering unit)) in H_SanctifiedBond
      • Unit Group - Add (Triggering unit) to G_SanctifiedBond
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Sanctified Bond 02 <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Sanctified Bond 02 <gen>
        • Else - Actions
  • Sanctified Bond 02
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in G_SanctifiedBond) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in G_SanctifiedBond and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current order of (Picked unit)) Equal to (Order(divineshield))
                • Then - Actions
                  • Set temp_point = (Position of (Picked unit))
                  • Set temp_point2 = (Position of (Load (Key target) of (Key (Picked unit)) in H_SanctifiedBond))
                  • Lightning - Move (Load (Key light) of (Key (Picked unit)) in H_SanctifiedBond) to source temp_point and target temp_point2
                  • Custom script: call RemoveLocation(udg_temp_point)
                  • Custom script: call RemoveLocation(udg_temp_point2)
                • Else - Actions
                  • Unit - Remove ~Sanctified Bond (Paladin) buff from (Picked unit)
                  • Unit - Remove ~Sanctified Bond (Paladin) buff from (Load (Key target) of (Key (Picked unit)) in H_SanctifiedBond)
                  • Lightning - Destroy (Load (Key light) of (Key (Picked unit)) in H_SanctifiedBond)
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in H_SanctifiedBond
                  • Unit Group - Remove (Picked unit) from G_SanctifiedBond
        • Else - Actions
          • Trigger - Turn off (This trigger)
 
I can't read this now I am tired and i need to sleep but if you said that: problem is, the first time it is cast on a particular unit, the lightning effect moves between the caster and the middle of the map instead of the caster and the target. Any casts after this first time on a target work as intended.

Then just create 2 dummy units on map start and order with triggers to one to cast spell on another! Quickly destroy them and spell will be fine!
 
Level 8
Joined
Apr 30, 2009
Messages
338
no it only works the second time on any unit, like every unit on the map would have to have it cast on them once for your idea to work. there has to be something wrong with my trigger where it is losing the target unit and I can;t figure it out
 
Level 8
Joined
Apr 30, 2009
Messages
338
Wow I just tried a dumb idea and it worked. I moved the temp_point assignment outside the if/then tree and it seems to work now:

  • Sanctified Bond 02
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in G_SanctifiedBond) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in G_SanctifiedBond and do (Actions)
            • Loop - Actions
              • Set temp_unit = (Load (Key target) of (Key (Picked unit)) in H_SanctifiedBond)
              • Set temp_point = (Position of (Picked unit))
              • Set temp_point2 = (Position of temp_unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current order of (Picked unit)) Equal to (Order(divineshield))
                • Then - Actions
                  • Lightning - Move (Load (Key light) of (Key (Picked unit)) in H_SanctifiedBond) to source temp_point and target temp_point2
                • Else - Actions
                  • Unit - Remove ~Sanctified Bond (Paladin) buff from (Picked unit)
                  • Unit - Remove ~Sanctified Bond (Paladin) buff from (Load (Key target) of (Key (Picked unit)) in H_SanctifiedBond)
                  • Lightning - Destroy (Load (Key light) of (Key (Picked unit)) in H_SanctifiedBond)
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in H_SanctifiedBond
                  • Unit Group - Remove (Picked unit) from G_SanctifiedBond
              • Custom script: set udg_temp_unit = null
              • Custom script: call RemoveLocation(udg_temp_point)
              • Custom script: call RemoveLocation(udg_temp_point2)
        • Else - Actions
          • Trigger - Turn off (This trigger)
Can anyone tell me why this works and my first one doesn't?
 
Level 8
Joined
Apr 30, 2009
Messages
338
  • Custom script: set udg_temp_unit = null
you don't need that.

Lightning works weird for me, too. I had my lightning saved in hash tables, just like you, and they often had weird glitches that made absolutely no sense. There's a problem with lightning.

I would think that, but the dummy casting the inner fire buff on the target would also malfunction on the first cast (or maybe it was cast but got instantly removed because trigger 2 is screwy).
 
Status
Not open for further replies.
Top