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

[HELP] Damage Units for once?

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
After you successfully damaged the unit, add it to a Unit Group
The next time it hits the unit, check whether the unit is in the Unit Group or not
If the unit is not, damage that unit first and later add that unit to Unit Group
If he's in the Unit Group, just leave it blank
Use the IF/THEN/ELSE Multiple Function Action
 
Level 4
Joined
Aug 3, 2008
Messages
58
I have the same problem and I can't figure it out, can you help me please.
  • Meteor
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Meteor
    • Actions
      • Set Meteor_Counts = (Meteor_Counts + 1)
      • Set Meteor_Caster[Meteor_Counts] = (Casting unit)
      • Set Meteor_CasterLoc = ((Position of Meteor_Caster[Meteor_Counts]) offset by -20.00 towards Meteor_Angle degrees)
      • Set Meteor_TargetPoint = (Target point of ability being cast)
      • Set Meteor_Angle = (Angle from Meteor_CasterLoc to Meteor_TargetPoint)
      • Unit - Create 1 Meteorr for (Owner of Meteor_Caster[Meteor_Counts]) at Meteor_CasterLoc facing Meteor_Angle degrees
      • Unit - Set the custom value of (Last created unit) to Meteor_Counts
      • Unit Group - Add (Last created unit) to Meteor_StartGroup
      • Set Meteor_Distance[1] = 500.00
      • Set Meteor_Distance[2] = 700.00
      • Set Meteor_Distance[3] = 900.00
      • Set Meteor_Distance[4] = 1100.00
      • Set Meteor_DistanceTravel[Meteor_Counts] = 0.00
      • Set Meteor_DistanceCount[Meteor_Counts] = 0.00
      • Set Meteor_Level = (Level of Meteor for Meteor_Caster[Meteor_Counts])
      • Set Meteor_Dmg[1] = 75
      • Set Meteor_Dmg[2] = 150
      • Set Meteor_Dmg[3] = 225
      • Set Meteor_Dmg[4] = 330
      • Trigger - Turn on Meteor Move <gen>
      • Custom script: call RemoveLocation (udg_Meteor_CasterLoc)
      • Custom script: call RemoveLocation (udg_Meteor_TargetPoint)
  • Meteor Move
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Meteor_StartGroup and do (Actions)
        • Loop - Actions
          • Set Meteor_CustomValue = (Custom value of (Picked unit))
          • Set Meteor_DummyLoc = (Position of (Picked unit))
          • Set Meteor_Movement = (Meteor_DummyLoc offset by 20.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Move (Picked unit) instantly to Meteor_Movement
          • Set Meteor_DistanceTravel[Meteor_CustomValue] = (Meteor_DistanceTravel[Meteor_CustomValue] + 18.00)
          • Set Meteor_DistanceCount[Meteor_CustomValue] = (Meteor_DistanceCount[Meteor_CustomValue] + 18.00)
          • Set Meteor_UnitGroup = (Units within 100.00 of Meteor_Movement matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)) and ((((Unit-type of (Matching unit)) Equal to Dog) and (((Matching unit) is in DamagedUnits) Equal to False))
          • Unit Group - Pick every unit in Meteor_UnitGroup and do (Actions)
            • Loop - Actions
              • Unit - Cause Meteor_Caster[Meteor_CustomValue] to damage (Picked unit), dealing (Real(Meteor_Dmg[Meteor_Level])) damage of attack type Spells and damage type Normal
              • Unit Group - Add (Picked unit) to DamagedUnits
          • Unit Group - Remove (Attacked unit) from Meteor_UnitGroup
          • Unit Group - Add (Attacked unit) to Meteor_RandomUnit
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Meteor_DistanceTravel[Meteor_CustomValue] Greater than or equal to Meteor_Distance[Meteor_Level]
            • Then - Actions
              • Unit - Kill (Picked unit)
              • Unit Group - Remove (Picked unit) from Meteor_StartGroup
              • Unit Group - Pick every unit in DamagedUnits and do (Unit Group - Remove (Picked unit) from DamagedUnits)
              • Custom script: call DestroyGroup (udg_DamagedUnits)
            • Else - Actions
          • Custom script: call RemoveLocation (udg_Meteor_DummyLoc)
          • Custom script: call RemoveLocation (udg_Meteor_Movement)
          • Custom script: call DestroyGroup (udg_Meteor_UnitGroup)
          • Custom script: call DestroyGroup (udg_Meteor_RandomUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Meteor_StartGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Firstly, move constants to an initialization function. There is no need to reload them upon each cast.

Secondly, you refer to "Attacked unit" in a perodic event run function which is total nonsense (there is no attacked unit...).

What you want to do for your damage routein is...
1. check if the unit is in the already damaged group and if so, skip the unit and move onto the next unit (repeaiting this).
2. damage the unit
3. add the unit to the already damaged group

After the spell ends, you can discard the cotense of the already damaged group.

Be aware that the already damaged group must be unique to each instance of the spell otherwise a unit could become immune to another instance of the spell while the first instance still has not ended.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
constant native IsUnitInGroup takes unit whichUnit,group whichGroup returns boolean
This function tests if a unit is in a group and returns the result.
whichUnit is the unit you want to test.
whichGroup is the group you want to check he is in.
It returns a boolean value of true if the unit is in the provided group and false otherwise.

A group is a set of units. A set is an unorder collection where every element is unique.

As you damage a unit, you are after adding it to the group.
However, before you damage a unit (and thus add it to the group) you are after checking if it is already in the group.

If the unit already is in the group, it must have been damaged already by the ability as that is the only way units get added to the group.
If it is not in the group, the unit has not been damaged thus you can damage it but you then have to add it to the group to prevent it from being damaged again.

The group must be unique for every instance of the spell. After the spell finishes the whole group can be discarded (Destroyed or Recycled).
 
Level 9
Joined
Dec 26, 2010
Messages
475
Like This?
  • Set CrocGroup[0] = (Units within 200.00 of CrocL[0] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of Croc[1])) Equal to True))))
  • Unit Group - Pick every unit in CrocGroup[0] and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) is in CrocGroup[1]) Equal to False
        • Then - Actions
          • Set CrocL[1] = (Position of (Picked unit))
          • Unit - Cause Croc[0] to damage (Picked unit), dealing CrocReal[0] damage of attack type Normal and damage type Normal
          • Special Effect - Create a special effect at CrocL[1] using war3mapImported\SandWaveDamage.mdx
          • Special Effect - Destroy (Last created special effect)
          • Unit Group - Add (Picked unit) to CrocGroup[1]
        • Else - Actions
  • Custom script: call DestroyGroup (udg_CrocGroup[0])
 
Last edited:
Status
Not open for further replies.
Top