• 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.

[General] Help me to Fix my Code for my Spear Trigger

Level 8
Joined
Oct 6, 2022
Messages
188
Hello, i'm making a spear skill, the base ability is the Stampede. what i would like to do is to make this spear is when an enemy got hit by it while the spear is moving, the enemy will get stun & knockback by the spear. but i don't know how would i do it here, can you guys able to help me with this one?


Hero's object editor:
1748216955800.png

Skill time channel cast:
1748217814147.png

Spear Trigger:

>>Initially On
  • Remilia_SEN
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to []Remilia[] Impaling Spear
    • Actions
      • Set Remilia_Cast_Unit[6] = (Triggering unit)
      • Set Remilia_SEN_IsCasted[1] = False
      • Set Remilia_SEN_IsCasted[2] = True
      • Set Remilia_SEN_Countdown = 2.90
      • Set Remilia_SEN_Point[2] = (Target point of ability being cast)
      • Set Remilia_SEN_angle = (Angle from (Position of Remilia_Cast_Unit[6]) to Remilia_SEN_Point[2])
      • Set Remilia_SEN_Speed = 100.00
      • Set Remilia_SEN_Distance = 0.00
      • Set Remilia_SEN_MaxDistance = 900.00
      • Set Remilia_KnockDuration = 0.00
      • Wait 0.01 seconds
      • Unit - Add (Fujiwara) DMG block to Remilia_Cast_Unit[6]
      • Unit - For Remilia_Cast_Unit[6], Ability (Fujiwara) DMG block , Disable ability: False, Hide UI: True
      • Animation - Play Remilia_Cast_Unit[6]'s attack animation
      • Animation - Queue Remilia_Cast_Unit[6]'s stand animation
      • Trigger - Turn on Remilia_SENCountdown <gen>
  • Remilia_SEN Cancel
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to []Remilia[] Impaling Spear
    • Actions
      • Set Remilia_SEN_IsCasted[1] = False
      • Set Remilia_SEN_IsCasted[2] = False

>>Initially off
  • Remilia_SENCountdown
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Remilia_SEN_IsCasted[1] Equal to False
          • Remilia_SEN_IsCasted[2] Equal to True
        • Then - Actions
          • Set Remilia_SEN_Countdown = (Remilia_SEN_Countdown - 0.10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Remilia_SEN_Countdown Equal to 0.00
            • Then - Actions
              • Set Remilia_SEN_IsCasted[1] = True
              • Set Remilia_SEN_IsCasted[2] = True
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Remilia_SEN_IsCasted[1] Equal to True
                  • Remilia_SEN_IsCasted[2] Equal to True
                • Then - Actions
                  • Unit - Remove (Fujiwara) DMG block from Remilia_Cast_Unit[6]
                  • Unit - Remove [][]Fuji[][] DMGblock buff from Remilia_Cast_Unit[6]
                  • Set Remilia_SEN_OriginPoint = ((Position of Remilia_Cast_Unit[6]) offset by 50.00 towards ((Facing of Remilia_Cast_Unit[6]) + 0.00) degrees)
                  • Unit - Create 1 Remilia Spear Dummy for (Owner of Remilia_Cast_Unit[6]) at Remilia_SEN_OriginPoint facing (Facing of Remilia_Cast_Unit[6]) degrees
                  • Animation - Play (Last created unit)'s death animation
                  • Set Remilia_SEN_Dummy2[2] = (Last created unit)
                  • Trigger - Turn on Remilia_SENReleased Loop <gen>
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Remilia_SEN_IsCasted[1] Equal to False
              • Remilia_SEN_IsCasted[2] Equal to False
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
  • Remilia_SENReleased Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Remilia_SEN_Distance Less than or equal to Remilia_SEN_MaxDistance
        • Then - Actions
          • For each (Integer A) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Move Remilia_SEN_Dummy2[(Integer A)] instantly to ((Position of Remilia_SEN_Dummy2[(Integer A)]) offset by Remilia_SEN_Speed towards Remilia_SEN_angle degrees), facing Remilia_SEN_angle degrees
              • Animation - Play Remilia_SEN_Dummy2[(Integer A)]'s stand animation
              • Unit Group - Pick every unit in (Units within 200.00 of (Position of Remilia_SEN_Dummy2[(Integer A)]) matching ((((Matching unit) belongs to an enemy of (Owner of Remilia_Cast_Unit[6])) Equal to True) and (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Eq and do (Actions)
                • Loop - Actions
                  • Unit - Cause Remilia_SEN_Dummy2[(Integer A)] to damage (Picked unit), dealing (100.00 x (Real((Level of []Remilia[] Impaling Spear for Remilia_Cast_Unit[6])))) damage of attack type Spells and damage type Normal
                  • Unit - Order (Picked unit) to Stop
                  • Special Effect - Create a special effect at (Position of (Picked unit)) using war3mapImported\Dota_Effect_lina_longpozhan.mdx
                  • Special Effect - Set Scale of (Last created special effect) to 0.50
                  • Special Effect - Destroy (Last created special effect)
                  • Trigger - Turn on Remilia_SEN Knock Loop <gen>
          • Set Remilia_SEN_Distance = (Remilia_SEN_Distance + Remilia_SEN_Speed)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • For each (Integer A) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Remove Remilia_SEN_Dummy2[(Integer A)] from the game
              • Special Effect - Create a special effect at (Position of Remilia_SEN_Dummy2[(Integer A)]) using war3mapImported\Dota_Effect_lina_longpozhan.mdx
              • Special Effect - Set Scale of (Last created special effect) to 0.50
              • Special Effect - Destroy (Last created special effect)
              • Set Remilia_SEN_Dummy2[(Integer A)] = No unit
  • Remilia_SEN Knock Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • Remilia_KnockDuration Less than or equal to 1.00
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Other\Doom\DoomTarget.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
          • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 10.00 towards (Distance between (Position of Remilia_SEN_Dummy2[(Integer A)]) and (Position of (Picked unit))) degrees)
          • Set Remilia_KnockDuration = (Remilia_KnockDuration + 0.05)
        • Else - Actions
          • Unit - Remove Remilia_SEN_Dummy2[(Integer A)] from the game
          • Trigger - Turn off (This trigger)
 
Level 13
Joined
Nov 13, 2010
Messages
281
in your trigger Loop you are already picking up enemy units when the spear moves and hits something so to make sure you (stunned and knockback) correctly then try add the unit to a unit group
try something like Unit Group - Add (Picked unit) to Remilia_Hit_UnitGroup

for the stun you need a dummy to stun so try something like
Unit - Create 1 Dummy Caster for (Owner of Remilia_Cast_Unit[6]) at (Position of (Picked unit)) facing any angle
Unit - Add Storm Bolt to (Last created unit)
Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
Unit - Add a 1.00 second expiration timer to (Last created unit)

and then we come to Knockback i can see in your trigger you are trying to move (Picked unit)
but outside the picking loop (Picked unit) it becomes invalid so
instead you should store hit units in a list or array so you can reference the unit
you can do something like
Set TempPoint = (Position of Remilia_KnockTarget[what you use])
Set Knock_Angle = (Angle from (Position of Remilia_SEN_Dummy2[1]) to tempPoint)
Set New_Position = TempPoint offset by 25.00 towards Knock_Angle degrees
Unit - Move Remilia_KnockTarget[what you use] to New_Position
You can run this over a duration that is controlled by Remilia_KnockDuration
and you can increase the offset per tick for smoother knockback if you like
 
Top