• 🏆 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] Need help with "Throw an Axe" spell :)

Status
Not open for further replies.
Level 1
Joined
Aug 16, 2010
Messages
3
I plan a lot of skills like this one on my map but there is a problem.
The axes should strike enemies on way ONCE, but after the first cast they ignore the "DoNotDamageGroup"(just set the MoveLoop to 0.5+ seconds and cast a few times and you'll see).

[TRIGGER=Cast]Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Throw an Axe
Actions
Set Count = (Count + 1)
Set CountCheck = (CountCheck + 1)
Set Caster[Count] = (Casting unit)
Set CastPoint[Count] = (Position of Caster[Count])
Set Angle[Count] = (Angle from CastPoint[Count] to (Target point of ability being cast))
Set TargetPoint[Count] = (CastPoint[Count] offset by 900.00 towards Angle[Count] degrees)
Set Damage[Count] = 10.00
Set Distance = 50.00
Set MissleCreatePoint = (CastPoint[Count] offset by Distance towards Angle[Count] degrees)
Custom script: set udg_DoNotDamageGroup[udg_Count] = CreateGroup()
Unit - Create 1 Footman for (Owner of Caster[Count]) at MissleCreatePoint facing Angle[Count] degrees
Unit - Turn collision for (Last created unit) Off
Unit - Move (Last created unit) instantly to MissleCreatePoint, facing Angle[Count] degrees
Set Missle[Count] = (Last created unit)
Unit - Add Crow Form to (Last created unit)
Animation - Change (Last created unit) flying height to 50.00 at 0.00
Set WorkBoolean[Count] = True
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(MoveLoop <gen> is on) Equal to False
Then - Actions
Trigger - Turn on MoveLoop <gen>
Else - Actions
Custom script: call RemoveLocation (udg_MissleCreatePoint)
[/TRIGGER]

[TRIGGER=MoveLoop]Events
Time - Every 0.03 seconds of game time
Conditions
Actions
For each (Integer LoopInteger) from 1 to Count, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WorkBoolean[LoopInteger] Equal to True
Then - Actions
Set MisslePoint = (Position of Missle[LoopInteger])
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between MisslePoint and TargetPoint[LoopInteger]) Greater than 30.00
Then - Actions
Set MissleMovePoint = (MisslePoint offset by 30.00 towards Angle[LoopInteger] degrees)
Unit - Move Missle[LoopInteger] instantly to MissleMovePoint
Set DamageGroup = (Units within Distance of MissleMovePoint matching ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner o
Unit Group - Pick every unit in DamageGroup and do (Actions)
Loop - Actions
Unit Group - Add (Picked unit) to DoNotDamageGroup[LoopInteger]
Unit - Cause Caster[LoopInteger] to damage (Picked unit), dealing Damage[LoopInteger] damage of attack type Spells and damage type Force
Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Other\Cleave\CleaveDamageTarget.mdl
Special Effect - Destroy (Last created special effect)
Destructible - Pick every destructible within Distance of MissleMovePoint and do (Actions)
Loop - Actions
Destructible - Set life of (Picked destructible) to ((Current life of (Picked destructible)) - Damage[LoopInteger])
Custom script: call RemoveLocation (udg_MissleMovePoint)
Unit Group - Remove all units from DamageGroup
Else - Actions
Unit - Move Missle[LoopInteger] instantly to TargetPoint[LoopInteger]
Unit - Kill Missle[LoopInteger]
Set DamageGroup = (Units within Distance of TargetPoint[LoopInteger] matching ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of
Unit Group - Pick every unit in DamageGroup and do (Actions)
Loop - Actions
Unit Group - Add (Picked unit) to DoNotDamageGroup[LoopInteger]
Unit - Cause Caster[LoopInteger] to damage (Picked unit), dealing Damage[LoopInteger] damage of attack type Spells and damage type Force
Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Other\Cleave\CleaveDamageTarget.mdl
Special Effect - Destroy (Last created special effect)
Destructible - Pick every destructible within Distance of TargetPoint[LoopInteger] and do (Actions)
Loop - Actions
Destructible - Set life of (Picked destructible) to ((Current life of (Picked destructible)) - Damage[LoopInteger])
Set Caster[LoopInteger] = No unit
Set WorkBoolean[LoopInteger] = False
Unit Group - Remove all units from DoNotDamageGroup[LoopInteger]
Custom script: call RemoveLocation (udg_TargetPoint[udg_LoopInteger])
Custom script: call RemoveLocation (udg_CastPoint[udg_LoopInteger])
Unit Group - Remove all units from DamageGroup
Set CountCheck = (CountCheck - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CountCheck Equal to 0
Then - Actions
Set Count = 0
Trigger - Turn off (This trigger)
Else - Actions
Else - Actions
Custom script: call RemoveLocation (udg_MisslePoint)
[/TRIGGER]

The spell is working now thanks to raft_pl!

The map with the skill and triggers is attached.
 

Attachments

  • ThrowAnAxe.w3x
    25.6 KB · Views: 61
Last edited:
Level 9
Joined
May 27, 2006
Messages
498
Thats because you destroy the group. And since in GUI (AFAIK) groups are created only on map initialization, your trigger bugs.
Just replace
  • Custom script: call DestroyGroup(udg_DamageGroup)
with
  • Unit Group - Remove all units from DamageGroup
 
Level 1
Joined
Aug 16, 2010
Messages
3
Thats because you destroy the group. And since in GUI (AFAIK) groups are created only on map initialization, your trigger bugs.
Just replace
  • Custom script: call DestroyGroup(udg_DamageGroup)
with
  • Unit Group - Remove all units from DamageGroup
That did help. Now it works properly with a single axe, but when I cast the spell second time with the same unit before the first axe is destroyed, the second one still bugs.

Updated the trigger and map in the first post.
 
Level 9
Joined
May 27, 2006
Messages
498
Just make the DamageGroup variable an array, just like you did with DoNotDamageGroup.

edit; the above is wrong, brb testing it.

edit2; got it. Strange thing, but apparently only the first group (ie. DoNotDamageGroup[1]) was initiated, and all others had to be created somehow. Just put this where you set up all the variables:
  • Set DoNotDamageGroup[Count] = (Units in (Playable map area))
  • Unit Group - Remove all units from DoNotDamageGroup[Count]
 
Last edited:
Level 1
Joined
Aug 16, 2010
Messages
3
Yes! It works! Thx!

Updated the first post and map once more so it could help anyone with the same problem.
 
Level 9
Joined
May 27, 2006
Messages
498
Since i got reminded about that... You could use
  • Custom script: set udg_DoNotDamageGroup[udg_Count] = CreateGroup()
instead of the two actions i posted above. It achieves the same goal as they do, but without any workarounds and whatnot. It's simply faster and better.
 
Status
Not open for further replies.
Top