• 🏆 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!

Triggered Shockwave damage once

Status
Not open for further replies.
Level 10
Joined
Mar 17, 2012
Messages
579
Hi everyone! I have a little problem.
I got a spell that acts like a Shockwave, but damage is triggered. But for some reason it damages units several time despite the fact that I add units in "Damaged_Group" and check if they are in that group not to damage them again... :ogre_rage:
  • Retribution
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Retribution of Overlord
    • Actions
      • Set Retribution_Counts = (Retribution_Counts + 1)
      • Set Retribution_Caster[Retribution_Counts] = (Triggering unit)
      • Set Retribution_Caster_Point = (Position of Retribution_Caster[Retribution_Counts])
      • Set Retribution_Target_Point = (Target point of ability being cast)
      • Set Retribution_Angle = (Angle from Retribution_Caster_Point to Retribution_Target_Point)
      • Unit - Create 1 Retribution Dummy for (Owner of Retribution_Caster[Retribution_Counts]) at Retribution_Caster_Point facing Retribution_Angle degrees
      • Unit - Set the custom value of (Last created unit) to Retribution_Counts
      • Unit Group - Add (Last created unit) to Retribution_StartGroup
      • Set Retribution_Distance[Retribution_Counts] = 1000.00
      • Set Retribution_DistanceTravel[Retribution_Counts] = 0.00
      • Trigger - Turn on Retribution Move <gen>
      • Custom script: call RemoveLocation (udg_Retribution_Caster_Point)
      • Custom script: call RemoveLocation (udg_Retribution_Target_Point)
  • Retribution Move
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Retribution_StartGroup and do (Actions)
        • Loop - Actions
          • Set Retribution_CustomValue = (Custom value of (Picked unit))
          • Set Retribution_DummyLoc = (Position of (Picked unit))
          • Set Retribution_Movement = (Retribution_DummyLoc offset by 30.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Move (Picked unit) instantly to Retribution_Movement
          • Set Retribution_DistanceTravel[Retribution_CustomValue] = (Retribution_DistanceTravel[Retribution_CustomValue] + 30.00)
          • Set Retribution_UnitGroup = (Units within 200.00 of Retribution_Movement matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of Retribution_Caster[Retribution_CustomValue])) E
          • Unit Group - Pick every unit in Retribution_UnitGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in Retribution_Damaged_Units) Equal to True
                • Then - Actions
                  • Do nothing
                • Else - Actions
                  • Unit - Cause Retribution_Caster[Retribution_CustomValue] to damage (Picked unit), dealing ((((Real((Intelligence of Retribution_Caster[Retribution_CustomValue] (Include bonuses)))) x 1.75) + (((Real((Level of Retribution of Overlord for Retribution_Caster[Retribution_CustomValue]))) x 120.00) + 250.00)) + (((Real((Level of Elune's Arrow for Elun damage of attack type Spells and damage type Fire
                  • Unit Group - Add (Picked unit) to Retribution_Damaged_Units
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Retribution_DistanceTravel[Retribution_CustomValue] Greater than or equal to Retribution_Distance[Retribution_CustomValue]
            • Then - Actions
              • Unit - Kill (Picked unit)
              • Unit Group - Remove (Picked unit) from Retribution_StartGroup
            • Else - Actions
          • Custom script: call RemoveLocation (udg_Retribution_DummyLoc)
          • Custom script: call RemoveLocation (udg_Retribution_Movement)
          • Custom script: call DestroyGroup (udg_Retribution_UnitGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Retribution_StartGroup) Equal to 0
        • Then - Actions
          • Custom script: call DestroyGroup (udg_Retribution_Damaged_Units)
          • Trigger - Turn off (This trigger)
        • Else - Actions
Help me please
 
Last edited:
Level 12
Joined
Mar 21, 2008
Messages
358
At a quick glance, it's probably not working because you're destroying the "Retribution_Damaged_Units" variable instead of clearing the units from that unit group. This is at the bottom of the second trigger, by the way.

Also, it seems to me that you haven't even initialized "Retribution_Damaged_Units" anywhere. Although you might have done so in another trigger not shown
 
Level 8
Joined
Oct 12, 2011
Messages
483
Don't think this is directly related to your problem, but it seems like you're trying to make the spell MUI. However, it seems that if your code worked as intended, if the spell is cast on the same target units twice at the same time, the units would only get damaged once, as the damaged units unit group persists for all Retribution dummy units.
 
Level 10
Joined
Mar 17, 2012
Messages
579
Don't think this is directly related to your problem, but it seems like you're trying to make the spell MUI. However, it seems that if your code worked as intended, if the spell is cast on the same target units twice at the same time, the units would only get damaged once, as the damaged units unit group persists for all Retribution dummy units.

Nope, I don't need it to be mui

At a quick glance, it's probably not working because you're destroying the "Retribution_Damaged_Units" variable instead of clearing the units from that unit group.

That's realy helped! Thanks))
 
Don't use Group, use Hashtable :)

  • Hashtable - Create a hashtable
  • Set myHashtable = (Last created hashtable)
  • Melee Initialization
    • Events
    • Conditions
    • Actions
      • -------- ------------------------- --------
      • -------- Just an example --------
      • -------- ------------------------- --------
      • Set myIndex = (myIndex + 1)
      • Set myCaster[myIndex] = (Triggering unit)
      • -------- Remember: Use dummy handle ID, not the caster --------
      • Unit - Create 1 Footman for Neutral Passive at (Center of (Playable map area)) facing Default building facing degrees
      • Set myDummy[myIndex] = (Last created unit)
      • -------- ------------------------- --------
      • -------- Get dummy's handle Id --------
      • Custom script: set udg_myHandleId[udg_myIndex]=GetHandleId(udg_myDummy[udg_myIndex])
      • -------- ------------------------- --------
      • -------- Dmg enemy --------
      • Set myGroup[myIndex] = (Units in (Playable map area))
      • Unit Group - Pick every unit in myGroup[myIndex] and do (Actions)
        • Loop - Actions
          • Set myEnemy = (Picked unit)
          • -------- Get enemy's Handle Id --------
          • Custom script: set udg_myEnemyId=GetHandleId(udg_myEnemy)
          • -------- Check if the enemy is stored to this Hashtable with key myHandleId[myIndex] or not --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (myHandleId[myIndex] is stored as a Handle of myEnemyId in myHashtable) Equal to False
            • Then - Actions
              • -------- Your code --------
              • -------- Save them to this Hashtable with key myHandleId[myIndex] so they can't not be damaged twice --------
              • Hashtable - Save Handle OfmyEnemy as myHandleId[myIndex] of myEnemyId in myHashtable
            • Else - Actions
          • -------- ------------------------- --------
      • -------- Destroy leak --------
      • Custom script: call DestroyGroup(.....................
      • Hashtable - Clear all child hashtables of child myHandleId[myIndex] in myHashtable
 
Status
Not open for further replies.
Top