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

[Trigger] Facing a rare collision issue with a Trigger

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Greetings, Hive.

For a long time I've been using a custom spell from Hive called "Inevitable Doom" from this pack. It's essentially a 'leap' spell towards a targeted enemy. The spell has worked flawlessly for me for years, but recently I decided to give a "copy" of the spell to another hero, in a way where 2 heroes would be able to cast the spell together in the same game.

In the triggers I am about to post below, you will see conditions that differentiate between 3 spells and 3 heroes. The 'Heroic Leap' spell belongs to 'Hero_Warrior', the 'Tiger Palm' belongs to 'Hero_Monk' and 'Fel Rush' belongs to 'Hero_DemonHunter'. All 3 spells essentially use the same trigger. The Warrior and Monk are both strength heroes and therefore can never be in the same game together. It's possible, however, for either of them to be in the same game with the Demon Hunter.

Which leads me to the actual issue. Very quickly after including the Demon Hunter and his Fel Rush spell into the trigger, I noticed a bug that I've never seen before. While having the Monk (using the Tiger Palm ability) and the Demon Hunter (using Fel Rush), at one point in the game the Monk hero lost his collision, resulting in him walking over walls, water, you name it. Recasting his Tiger Palm ability did restore his collision.

Here is what I think happened: Somehow the Leap A trigger got activated when casting the Tiger Palm ability, it disabled the collision of the Monk (as intended), but it did not give it back to him in Leap B (or maybe, Leap B did not run at all). I know that the spell is MUI, but I have strong suspicions that the inclusion of the Demon Hunter in the trigger and by opening up the possibility of 2 heroes using the spell code, it resulted in this bug, since I've never encountered before. Obviously I cannot be 100% certain that's the issue.

The bug happened only once in the game which at that point had been going on for 1-2 hours, which makes it kinda rare. I do want to note that neither of the mentioned heroes have other spells or effects that disable their collision.

Here are the triggers:
[trigger=""]
Leap A
Events
Unit - A unit Starts the effect of an ability
Conditions
Or - Any (Conditions) are true
Conditions
(Ability being cast) Equal to Heroic Leap
(Ability being cast) Equal to Tiger Palm
(Ability being cast) Equal to Fel Rush
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ID_Switch Equal to 0
Then - Actions
Trigger - Turn on Leap B <gen>
Else - Actions
-------- -------- --------
Set ID_CastNumber = (ID_CastNumber + 1)
Set ID_Switch = (ID_Switch + 1)
Set ID_Off[ID_CastNumber] = True
-------- -------- --------
Set ID_Caster[ID_CastNumber] = (Triggering unit)
Set ID_Target[ID_CastNumber] = (Target unit of ability being cast)
-------- -------- --------
Set ID_Speed[ID_CastNumber] = 20.00
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Heroic Leap
Then - Actions
Set ID_Damage[ID_CastNumber] = ((20.00 + (80.00 x (Real((Level of Heroic Leap for (Triggering unit)))))) + (1.80 x (Real((Strength of Hero_Warrior (Include bonuses))))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Talents_Unit[2] has an item of type Warpath) Equal to True
Then - Actions
Set Generic_Point = (Position of (Triggering unit))
Unit - Create 1 Dummy (Generic Uses) for (Owner of (Triggering unit)) at Generic_Point facing Default building facing degrees
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
Unit - Add Warpath (Dummy) to (Last created unit)
Unit - Set level of Warpath (Dummy) for (Last created unit) to (Level of Heroic Leap for (Triggering unit))
Unit - Order (Last created unit) to Orc Shaman - Bloodlust (Triggering unit)
Custom script: call RemoveLocation(udg_Generic_Point)
Else - Actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Tiger Palm
Then - Actions
Set ID_Damage[ID_CastNumber] = ((100.00 x (Real((Level of Tiger Palm for Hero_Monk)))) + (2.25 x (Real((Strength of Hero_Monk (Include bonuses))))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Talents_Unit[2] has an item of type Wrath of Xuen) Equal to True
Then - Actions
Set ID_Damage[ID_CastNumber] = (ID_Damage[ID_CastNumber] x (1.00 + (0.02 x (Real((Agility of Hero_Monk (Include bonuses)))))))
Else - Actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Fel Rush
Then - Actions
Set ID_Damage[ID_CastNumber] = (50.00 + (2.50 x (Real((Agility of Hero_DemonHunter (Include bonuses))))))
Else - Actions
-------- -------- --------
Set ID_Point[0] = (Position of ID_Caster[ID_CastNumber])
Set ID_Point[1] = (Position of ID_Target[ID_CastNumber])
-------- -------- --------
Set ID_Distance[ID_CastNumber] = (Distance between ID_Point[0] and ID_Point[1])
Set ID_Angle[ID_CastNumber] = (Angle from ID_Point[0] to ID_Point[1])
Set ID_Angle[ID_CastNumber] = (ID_Angle[ID_CastNumber] + 180.00)
-------- -------- --------
Unit - Turn collision for ID_Caster[ID_CastNumber] Off
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Heroic Leap
Then - Actions
Animation - Play ID_Caster[ID_CastNumber]'s attack slam animation
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Tiger Palm
Then - Actions
Animation - Play ID_Caster[ID_CastNumber]'s attack -2 animation
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Fel Rush
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of ID_Caster[ID_CastNumber]) Equal to |c00a330c9Demon Hunter|r
Then - Actions
Animation - Play ID_Caster[ID_CastNumber]'s attack animation
Else - Actions
Animation - Play ID_Caster[ID_CastNumber]'s attack alternate animation
Else - Actions
-------- -------- --------
Custom script: call RemoveLocation (udg_ID_Point[0])
Custom script: call RemoveLocation (udg_ID_Point[1])
[/trigger]


[trigger=""]
Leap B
Events
Time - Every 0.02 seconds of game time
Conditions
Actions
For each (Integer ID_HL) from 1 to ID_CastNumber, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ID_Off[ID_HL] Equal to True
Then - Actions
Set ID_Point[4] = (Position of ID_Target[ID_HL])
Set ID_Distance[ID_HL] = (ID_Distance[ID_HL] - ID_Speed[ID_HL])
Set ID_Point[2] = (ID_Point[4] offset by ID_Distance[ID_HL] towards ID_Angle[ID_HL] degrees)
Unit - Move ID_Caster[ID_HL] instantly to ID_Point[2], facing (Facing of ID_Caster[ID_HL]) degrees
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ID_Caster[ID_CastNumber] Equal to Hero_Warrior
Then - Actions
Special Effect - Create a special effect attached to the weapon of ID_Caster[ID_HL] using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
Special Effect - Destroy (Last created special effect)
Else - Actions
Special Effect - Create a special effect attached to the weapon of ID_Caster[ID_HL] using war3mapImported\FelSplash.mdx
Special Effect - Destroy (Last created special effect)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ID_Distance[ID_HL] Less than or equal to 100.00
Then - Actions
Set ID_Off[ID_HL] = False
Set ID_Switch = (ID_Switch - 1)
Set ID_Point[3] = (Position of ID_Target[ID_HL])
Unit - Turn collision for ID_Caster[ID_CastNumber] On
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of ID_Caster[ID_HL]) Equal to |c00c79c6eWarrior|r
Then - Actions
Unit - Order ID_Target[ID_HL] to Attack ID_Caster[ID_HL]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DefensiveStance Equal to True
Then - Actions
Set NextDamageType = 5
Unit - Cause ID_Caster[ID_HL] to damage ID_Target[ID_HL], dealing ID_Damage[ID_HL] damage of attack type Spells and damage type Normal
Trigger - Run ClearDamageEvent (checking conditions)
Set Generic_Point = (Position of ID_Caster[ID_HL])
Unit - Create 1 Dummy (Generic Uses) for (Owner of ID_Caster[ID_HL]) at Generic_Point facing Default building facing degrees
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
Unit - Add Generic Stun to (Last created unit)
Unit - Set level of Generic Stun for (Last created unit) to 5
Unit - Order (Last created unit) to Human Mountain King - Storm Bolt ID_Target[ID_HL]
Custom script: call RemoveLocation(udg_Generic_Point)
Else - Actions
Unit - Cause ID_Caster[ID_HL] to damage ID_Target[ID_HL], dealing ID_Damage[ID_HL] damage of attack type Normal and damage type Normal
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of ID_Caster[ID_HL]) Equal to |c0000ff96Monk|r
Then - Actions
Unit - Order ID_Target[ID_HL] to Attack ID_Caster[ID_HL]
Set NextDamageType = 5
Unit - Cause ID_Caster[ID_HL] to damage ID_Target[ID_HL], dealing ID_Damage[ID_HL] damage of attack type Spells and damage type Normal
Trigger - Run ClearDamageEvent (checking conditions)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of ID_Caster[ID_HL]) Equal to |c00a330c9Demon Hunter|r
(Unit-type of ID_Caster[ID_HL]) Equal to |c009900ccDemon Hunter|r (Metamorphosis)
Then - Actions
Set Generic_Point = (Position of ID_Target[ID_HL])
Special Effect - Create a special effect at Generic_Point using Objects\Spawnmodels\Undead\UDeathSmall\UDeathSmall.mdl
Special Effect - Destroy (Last created special effect)
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within 250.00 of Generic_Point) and do (Actions)
Loop - Actions
-------- Standard AoE Damage Conditions --------
Set DeathCheck_Unit = (Picked unit)
Custom script: if GetUnitTypeId(udg_DeathCheck_Unit) == 0 or IsUnitType(udg_DeathCheck_Unit, UNIT_TYPE_DEAD) then
Custom script: set udg_DeathCheck_Alive = false
Custom script: else
Custom script: set udg_DeathCheck_Alive = true
Custom script: endif
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) belongs to an enemy of (Owner of ID_Caster[ID_HL])) Equal to True
((Picked unit) is A structure) Equal to False
((Picked unit) is A flying unit) Equal to False
((Picked unit) is Magic Immune) Equal to False
DeathCheck_Alive Equal to True
Then - Actions
Set NextDamageType = 5
Unit - Cause ID_Caster[ID_HL] to damage (Picked unit), dealing ID_Damage[ID_HL] damage of attack type Spells and damage type Normal
Trigger - Run ClearDamageEvent (checking conditions)
Else - Actions
Custom script: call RemoveLocation (udg_Generic_Point)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ID_Caster[ID_CastNumber] Equal to Hero_Warrior
Then - Actions
Special Effect - Create a special effect at ID_Point[3] using Abilities\Weapons\PhoenixMissile\Phoenix_Missile.mdl
Special Effect - Destroy (Last created special effect)
Special Effect - Create a special effect at ID_Point[3] using Abilities\Weapons\SteamTank\SteamTankImpact.mdl
Special Effect - Destroy (Last created special effect)
Else - Actions
Special Effect - Create a special effect at ID_Point[3] using Abilities\Weapons\GargoyleMissile\GargoyleMissile.mdl
Special Effect - Destroy (Last created special effect)
Special Effect - Create a special effect at ID_Point[3] using Abilities\Spells\Human\ManaFlare\ManaFlareBoltImpact.mdl
Special Effect - Destroy (Last created special effect)
Animation - Reset ID_Caster[ID_HL]'s animation
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ID_Switch Equal to 0
Then - Actions
Set ID_CastNumber = 0
Trigger - Turn off Leap B <gen>
Else - Actions
Custom script: call RemoveLocation (udg_ID_Point[3])
Else - Actions
Custom script: call RemoveLocation (udg_ID_Point[2])
Custom script: call RemoveLocation (udg_ID_Point[4])
Else - Actions
[/trigger]


So the question is: Can anyone identify the reason why the Hero_Monk lost his collision?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Inside the loop one has to use the loop index and not the cast count.

Problem...
Unit - Turn collision for ID_Caster[ID_CastNumber] On

Solution...
Unit - Turn collision for ID_Caster[ID_HL] On

If one searches your trigger one can also see this same problem multiple times...

ID_Caster[ID_CastNumber] Equal to Hero_Warrior
Should be...
ID_Caster[ID_HL] Equal to Hero_Warrior

And repeated again...
ID_Caster[ID_CastNumber] Equal to Hero_Warrior
Should be...
ID_Caster[ID_HL] Equal to Hero_Warrior
 
Status
Not open for further replies.
Top