• 🏆 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 to improve my trigger

Status
Not open for further replies.
Level 3
Joined
Jul 24, 2010
Messages
54
Charge Trigger

Well, i need someone who can help to improve my spells a little a bit, or could've been said a lot.
The spell was a Charge, based on DotA's Charge of Darkness, except i don't give it a bonus movement speed and attack speed after the charge.
The spell uses following trigger.

  • CoD Hash
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Creating the Hashtable --------
      • Hashtable - Create a hashtable
      • -------- Set the Hashtable --------
      • Set CoD_Hash = (Last created hashtable)
  • CoD Set
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charge
    • Actions
      • -------- Who's the caster --------
      • Set CoD_Caster = (Triggering unit)
      • -------- Who's the target --------
      • Set CoD_Target = (Target unit of ability being cast)
      • -------- Charge speed based on ability's level --------
      • Set CoD_Move_Speed = (10.00 + (15.00 x (Real((Level of Charge for CoD_Caster)))))
      • -------- Duration of the Knockbacked unit --------
      • Set CoD_Dur = 0.80
      • -------- Knockback Speed --------
      • Set CoD_Knockback_Speed = 10.00
      • -------- Saving the handles of the unit and caster to the hashtable --------
      • Hashtable - Save Handle OfCoD_Caster as 1 of (Key (Triggering unit)) in CoD_Hash
      • Hashtable - Save Handle OfCoD_Target as 2 of (Key (Triggering unit)) in CoD_Hash
      • -------- Add the Caster to the group --------
      • Unit Group - Add (Triggering unit) to CoD_Group
  • CoD Charge
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CoD_Group and do (Actions)
        • Loop - Actions
          • -------- Load the caster from the Hashtable --------
          • Set CoD_Caster = (Load 1 of (Key (Picked unit)) in CoD_Hash)
          • -------- Load the target from the Hashtable --------
          • Set CoD_Target = (Load 2 of (Key (Picked unit)) in CoD_Hash)
          • -------- Make the caster to face the target --------
          • Unit - Make CoD_Caster face CoD_Target over 0.00 seconds
          • -------- Set the distance between the caster and the target --------
          • Set CoD_Distance = (Distance between (Position of CoD_Caster) and (Position of CoD_Target))
          • -------- IF THEN ELSE --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CoD_Distance Greater than 135.00
              • ((Picked unit) is Stunned) Equal to False
            • Then - Actions
              • -------- Creates the special effect of the charge --------
              • Set Temp = (Position of CoD_Caster)
              • Special Effect - Create a special effect at Temp using Abilities\Weapons\DemolisherFireMissile\DemolisherFireMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_Temp)
              • -------- Set the angle between the caster and the target --------
              • Set CoD_Angle = (Angle from (Position of CoD_Caster) to (Position of CoD_Target))
              • -------- Turn off the collision of the caster to --------
              • Unit - Turn collision for CoD_Caster Off
              • -------- Charging the caster --------
              • Set Temp = ((Position of CoD_Caster) offset by CoD_Move_Speed towards CoD_Angle degrees)
              • Unit - Move (Picked unit) instantly to Temp
              • Custom script: call RemoveLocation(udg_Temp)
              • -------- Pick every unit nearby the charger --------
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 140.00 of (Position of CoD_Caster)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Picked unit) Not equal to CoD_Caster
                      • ((Picked unit) is alive) Equal to True
                      • ((Picked unit) belongs to an ally of (Owner of CoD_Caster)) Equal to False
                    • Then - Actions
                      • Set CoD_Knockback = (Picked unit)
                      • Hashtable - Save CoD_Dur as 3 of (Key (Picked unit)) in CoD_Hash
                      • Unit Group - Add (Picked unit) to CoD_Knockback_Group
                    • Else - Actions
            • Else - Actions
              • -------- Remove the caster from the group --------
              • Unit Group - Remove (Picked unit) from CoD_Group
              • -------- Turn on the collision for the caster --------
              • Unit - Turn collision for CoD_Caster On
      • Unit Group - Pick every unit in CoD_Knockback_Group and do (Actions)
        • Loop - Actions
          • -------- Load the current time from the hashtable --------
          • Set CoD_Dur = (Load 3 of (Key (Picked unit)) from CoD_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CoD_Dur Greater than 0.00
            • Then - Actions
              • -------- Save the current time to the hashtable --------
              • Hashtable - Save (CoD_Dur - 0.04) as 3 of (Key (Picked unit)) in CoD_Hash
              • -------- Knockback the unit --------
              • Set Temp = ((Position of (Picked unit)) offset by CoD_Knockback_Speed towards (Angle from (Position of CoD_Caster) to (Position of (Picked unit))) degrees)
              • Unit - Move (Picked unit) instantly to Temp
              • Custom script: call RemoveLocation(udg_Temp)
              • -------- Creates a speical effect to the knockacked unit --------
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • -------- Remove the knockbacked unit from the game --------
              • Unit Group - Remove (Picked unit) from CoD_Knockback_Group
However :
- I know there's a leaks somewhere
- The spell's is not efficient
- The special effects are horrible
- I wanna know if this spell will meets the Hive's spell rule?

Note : This is my first spell enhanced trigger....
 
Last edited:
Level 6
Joined
Jul 24, 2008
Messages
180
Actually, I don't see any leaks, but this is the first trigger I've looked at in a year so I wouldn't take my word for it. Also, as far as special effects go, look for the impale dirt effect in the extras section. Thats always a winning for sliding. Can you define efficient for me?
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
Remove this:
  • Do Nothing
Do Nothing literally does nothing. Its a waste of bytes. And in good maps, bytes are important.

Your unit group leaks. Add
  • Custom Script: set bj_wantDestroyGroup = true
This destroys the group automatically when its done being used. Or if you would rather manually destroy it because you want to reuse it, then set it to a trigger:
  • set Variable = Group
  • ....
  • Custom Script: call DestroyGroup(udg_Group)
Will add more, still reading.
 
Level 3
Joined
Jul 24, 2010
Messages
54
LOL, i never thought that Do Nothing was actually making the trigger a bit slower, and thanks for spotting out the leaks...
And for the Impale dust effect, it's really fit perfectly as it should be, +rep for both of you
And for the efficient, it's what makes my trigger really easy to read by other user who want to edit it....
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • The looping trigger should be initially off. Turn it on when you add a unit into the group and turn it off when you remove a unit from it, and the group is empty
  • I'd use 0.03 second loop since it looks smoother than 0.04 second loop
  • Do "Unit is alive" checks in the looping trigger
  • Two leaks
    • Set CoD_Distance = (Distance between (Position of CoD_Caster) and (Position of CoD_Target))
  • Two leaks
    • Set CoD_Angle = (Angle from (Position of CoD_Caster) to (Position of CoD_Target))
  • One leak
    • Set Temp = ((Position of CoD_Caster) offset by CoD_Move_Speed towards CoD_Angle degrees)
  • One leak
    • (the position)Unit Group - Pick every unit in (Units within 140.00 of (Position of CoD_Caster)) and do (Actions)
  • Filter out dead units and structures from being added into the knockback group
  • It looks like you're creating an effect on the caster every 0.04 seconds, you shouldn't create it that often
  • You should turn the collision off for the caster in the cast trigger, not in the looping trigger
  • Three leaks
    • Set Temp = ((Position of (Picked unit)) offset by CoD_Knockback_Speed towards (Angle from (Position of CoD_Caster) to (Position of (Picked unit))) degrees)
 
Status
Not open for further replies.
Top