• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Another MUI Spell Problemo

Status
Not open for further replies.
Level 6
Joined
Jan 2, 2007
Messages
189
ok so i came back from the dark age and started using hashtables. obviously im no master at so i ran into a problem ive been at all day. im completely stumped! heres the simple bullet system again, all the dummy units move as they should but as soon as one either A. reaches its final distance or B. hits a target, ALL the dummy bullets stop. I based my triggering heavily on the example i recieved earlier and the hashtable tuturial here at the hive.

  • Events
    • Unit - A unit Is attacked
  • Conditions
    • (Unit-type of (Attacking unit)) Equal to Stalker
  • Actions
    • Set Temp_Unit[1] = (Attacking unit)
    • Set Temp_Unit[2] = (Attacked unit)
    • Set TempPoint[1] = (Position of Temp_Unit[1])
    • Set TempPoint[2] = (Position of Temp_Unit[2])
    • Unit - Create 1 Arrow for (Owner of (Attacking unit)) at TempPoint[1] facing TempPoint[2]
    • Set Archer_Distance = (400.00 x 0.04)
    • Set Archer_Time = 2.00
    • Hashtable - Save Archer_Distance as 0 of (Key (Last created unit)) in Hashtables[1]
    • Hashtable - Save Archer_Time as 1 of (Key (Last created unit)) in Hashtables[1]
    • Unit Group - Add (Last created unit) to Archer_Group[1]
    • Custom script: call RemoveLocation (udg_TempPoint[1])
    • Custom script: call RemoveLocation (udg_TempPoint[2])
  • Archers Move
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Archer_Group[1] and do (Actions)
        • Loop - Actions
          • Set Archer_Distance = (Load 0 of (Key (Picked unit)) from Hashtables[1])
          • Set Archer_Time = (Load 1 of (Key (Picked unit)) from Hashtables[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Archer_Time Greater than 0.00
            • Then - Actions
              • Set TempPoint[1] = (Position of (Picked unit))
              • Unit - Move (Picked unit) instantly to (TempPoint[1] offset by Archer_Distance towards (Facing of (Picked unit)) degrees)
              • Set Temp_Unit[1] = (Picked unit)
              • Set Archer_Group[2] = (Units within 45.00 of TempPoint[1] matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
              • Unit Group - Pick every unit in Archer_Group[2] and do (Actions)
                • Loop - Actions
                  • Unit - Cause Temp_Unit[1] to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Normal
                  • Trigger - Run Archers End <gen> (ignoring conditions)
              • Hashtable - Save (Archer_Time - 0.04) as 1 of (Key (Picked unit)) in Hashtables[1]
              • Custom script: call RemoveLocation (udg_TempPoint[1])
            • Else - Actions
              • Trigger - Run Archers End <gen> (ignoring conditions)
  • Archers End
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Archer_Group[1] and do (Actions)
        • Loop - Actions
          • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hashtables[1]
          • Unit Group - Remove (Picked unit) from Archer_Group[1]
          • Unit - Kill (Picked unit)
 
coz archer_end kills all units in archer group[1] so when one missile finishes then all other missiles will die... here try this

  • Archers Move
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Archer_Group[1] and do (Actions)
        • Loop - Actions
          • Set Temp_Unit[1] = (Picked unit)
          • Set Archer_Distance = (Load 0 of (Key (Temp_Unit[1])) from Hashtables[1])
          • Set Archer_Time = (Load 1 of (Key (Temp_Unit[1])) from Hashtables[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Archer_Time Greater than 0.00
            • Then - Actions
              • Set TempPoint[1] = (Position of (Temp_Unit[1]))
              • Unit - Move (Temp_Unit[1]) instantly to (TempPoint[1] offset by Archer_Distance towards (Facing of (Temp_Unit[1])) degrees)
              • Set Archer_Group[2] = (Units within 45.00 of TempPoint[1] matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
              • Unit Group - Pick every unit in Archer_Group[2] and do (Actions)
                • Loop - Actions
                  • Unit - Cause Temp_Unit[1] to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Normal
                  • Hashtable - Clear all child hashtables of child (Key (Temp_Unit[1])) in Hashtables[1]
                  • Unit Group - Remove (Temp_Unit[1]) from Archer_Group[1]
                  • Unit - Kill (Temp_Unit[1])
                • Hashtable - Save (Archer_Time - 0.04) as 1 of (Key (Picked unit)) in Hashtables[1]
                • Custom script: call RemoveLocation (udg_TempPoint[1])
            • Else - Actions
            • Hashtable - Clear all child hashtables of child (Key (Temp_Unit[1])) in Hashtables[1]
            • Unit Group - Remove (Temp_Unit[1]) from Archer_Group[1]
            • Unit - Kill (Temp_Unit[1])
 
Level 9
Joined
Sep 28, 2004
Messages
365
Use this. Because when you run the Archer end trigger, there is no condition to check if Archer_Time has ended for that particular dummy, so it loop for all dummy and kills it. Also, clear the group, i added inside the code.


  • Archers Move
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Archer_Group[1] and do (Actions)
        • Loop - Actions
          • Set Archer_Distance = (Load 0 of (Key (Picked unit)) from Hashtables[1])
          • Set Archer_Time = (Load 1 of (Key (Picked unit)) from Hashtables[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Archer_Time Greater than 0.00
            • Then - Actions
              • Set TempPoint[1] = (Position of (Picked unit))
              • Unit - Move (Picked unit) instantly to (TempPoint[1] offset by Archer_Distance towards (Facing of (Picked unit)) degrees)
              • Set Temp_Unit[1] = (Picked unit)
              • Set Archer_Group[2] = (Units within 45.00 of TempPoint[1] matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
              • Unit Group - Pick every unit in Archer_Group[2] and do (Actions)
                • Loop - Actions
                  • Unit - Cause Temp_Unit[1] to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Normal
                  • Hashtable - Clear all child hashtables of child (Key Temp_Unit[1]) in Hashtables[1]
                  • Unit Group - Remove Temp_Unit[1] from Archer_Group[1]
                  • Unit - Kill (Temp_Unit[1])
              • Hashtable - Save (Archer_Time - 0.04) as 1 of (Key (Picked unit)) in Hashtables[1]
              • Custom script: call RemoveLocation (udg_TempPoint[1])
              • Custom script: call DestroyGroup (udg_Archer_Group[2])
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hashtables[1]
              • Unit Group - Remove (Picked unit) from Archer_Group[1]
              • Unit - Kill (Picked unit)
EDIT: Adiktuz beat me to it [: Remember to destroy the group though [:
 

Use this. Because when you run the Archer end trigger, there is no condition to check if Archer_Time has ended for that particular dummy, so it loop for all dummy and kills it. Also, clear the group, i added inside the code.


  • Archers Move
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Archer_Group[1] and do (Actions)
        • Loop - Actions
          • Set Archer_Distance = (Load 0 of (Key (Picked unit)) from Hashtables[1])
          • Set Archer_Time = (Load 1 of (Key (Picked unit)) from Hashtables[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Archer_Time Greater than 0.00
            • Then - Actions
              • Set TempPoint[1] = (Position of (Picked unit))
              • Unit - Move (Picked unit) instantly to (TempPoint[1] offset by Archer_Distance towards (Facing of (Picked unit)) degrees)
              • Set Temp_Unit[1] = (Picked unit)
              • Set Archer_Group[2] = (Units within 45.00 of TempPoint[1] matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
              • Unit Group - Pick every unit in Archer_Group[2] and do (Actions)
                • Loop - Actions
                  • Unit - Cause Temp_Unit[1] to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Normal
                  • Trigger - Run Archers End <gen> (ignoring conditions)
              • Hashtable - Save (Archer_Time - 0.04) as 1 of (Key (Picked unit)) in Hashtables[1]
              • Custom script: call RemoveLocation (udg_TempPoint[1])
              • Custom script: call DestroyGroup (udg_Archer_Group[2])
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hashtables[1]
              • Unit Group - Remove (Picked unit) from Archer_Group[1]
              • Unit - Kill (Picked unit)
EDIT: Adiktuz beat me to it [: Remember to destroy the group though [:


I haven't seen the group... I was focused about the fact that they all stop when one missile stops...

Also: Dont run archer's end coz that trigger loops all missiles and kills them...

anyway, here's a new code:


  • Archers Move
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Archer_Group[1] and do (Actions)
        • Loop - Actions
          • Set Temp_Unit[1] = (Picked unit)
          • Set Archer_Distance = (Load 0 of (Key (Temp_Unit[1])) from Hashtables[1])
          • Set Archer_Time = (Load 1 of (Key (Temp_Unit[1])) from Hashtables[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Archer_Time Greater than 0.00
            • Then - Actions
              • Set TempPoint[1] = (Position of (Temp_Unit[1]))
              • Unit - Move (Temp_Unit[1]) instantly to (TempPoint[1] offset by Archer_Distance towards (Facing of (Temp_Unit[1])) degrees)
              • Set Archer_Group[2] = (Units within 45.00 of TempPoint[1] matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
              • Unit Group - Pick every unit in Archer_Group[2] and do (Actions)
                • Loop - Actions
                  • Unit - Cause Temp_Unit[1] to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Normal
                  • Hashtable - Clear all child hashtables of child (Key (Temp_Unit[1])) in Hashtables[1]
                  • Unit Group - Remove (Temp_Unit[1]) from Archer_Group[1]
                  • Unit - Kill (Temp_Unit[1])
                • Hashtable - Save (Archer_Time - 0.04) as 1 of (Key (Picked unit)) in Hashtables[1]
                • Custom script: call RemoveLocation (udg_TempPoint[1])
                • Custom script: call DestroyGroup(udg_Archer_Group[2])
            • Else - Actions
            • Hashtable - Clear all child hashtables of child (Key (Temp_Unit[1])) in Hashtables[1]
            • Unit Group - Remove (Temp_Unit[1]) from Archer_Group[1]
            • Unit - Kill (Temp_Unit[1])
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
The offset location leaks, you need to set Temp_Loc_2 = Temp_Loc_1 offset by... and then move the unit to Temp_Loc_2.

Also there's some redundant code, clear hashtables, remove from unit group and kill unit. Either remove last three lines, or replace the ones in the unit group loop with "save -1 as 1 of Key(Picked Unit)".
 
Level 6
Joined
Jan 2, 2007
Messages
189
you guys are good haha! thank you so much for all your help. not only does it work but i learned how hashtables work and knowing is half the battle haha +rep for all yay!
 
Status
Not open for further replies.
Top