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

Charge Ability help

Status
Not open for further replies.
Level 5
Joined
Jun 21, 2013
Messages
116
I need an ability that would target a unit, then the caster would get 522 movement speed and charge into the target. Upon impact, all enemies surrounding the caster would get a debuff that makes them miss attacks.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Try this I made it very fast , but it isn't MUI MPI
  • Charge
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set Caster = (Triggering unit)
      • Set Point_Of_Caster = (Position of Caster)
      • Set Target = (Target unit of ability being cast)
      • Set Point_Of_Target = (Position of Target)
      • Animation - Change Caster's animation speed to 150.00% of its original speed
      • Unit - Set Caster movement speed to 522.00
      • Unit - Pause Caster
      • Animation - Play Caster's Walk Defend ( Or Whatever ) animation
      • Trigger - Turn on Charge Loop <gen>
      • Wait until ((Distance between Point_Of_Caster and Point_Of_Target) Less than or equal to 100.00), checking every 0.10 seconds
      • Trigger - Turn off Charge Loop <gen>
      • Animation - Change Caster's animation speed to 100.00% of its original speed
      • Unit - Set Caster movement speed to (Default movement speed of Caster)
      • Unit - Unpause Caster
      • Set Caster = No unit
      • Set Target = No unit
      • Custom script: call RemoveLocation(udg_Point_Of_Caster)
      • Custom script: call RemoveLocation(udg_Point_Of_Target)
      • Custom script: call RemoveLocation(udg_Next_Charge_Point)
      • Custom script: call DestroyGroup(udg_Surrounded_Units)
  • Charge Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Point_Of_Caster = (Position of Caster)
      • Set Point_Of_Target = (Position of Target)
      • Set Next_Charge_Point = (Point_Of_Caster offset by 40.00 towards (Facing of Caster) degrees)
      • Unit - Move Caster instantly to Next_Charge_Point, facing (Facing of Caster) degrees
      • Set Surrounded_Units = (Units within 300.00 of Point_Of_Caster matching (((Matching unit) belongs to an enemy of (Owner of Caster)) Equal to True))
      • Unit Group - Pick every unit in Surrounded_Units and do (Actions)
        • Loop - Actions
          • -------- Your debuff --------
      • Custom script: call RemoveLocation(udg_Point_Of_Caster)
      • Custom script: call RemoveLocation(udg_Point_Of_Target)
      • Custom script: call RemoveLocation(udg_Next_Charge_Point)
      • Custom script: call DestroyGroup(udg_Surrounded_Units)
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
I created my own charge spell, though it doesn't place the debuff on nearby enemies and is not MUI. But it should be easy enough to add those effects there yourself

  • Charge Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Your_Ability
    • Actions
      • -------- set up variables --------
      • Set Caster = Blademaster 0002 <gen>
      • Set TargetPoint = (Target point of ability being cast)
      • -------- ------------------------------------------------------- --------
      • Unit - Make Caster face TargetPoint over 0.00 seconds
      • Unit - Pause Caster
      • Animation - Change Caster's animation speed to 150.00% of its original speed
      • -------- ------------------------------------------------------- --------
      • -------- a custom script, the number there is the index number of "walk" animation (this differs per unit) --------
      • Custom script: call SetUnitAnimationByIndex(udg_Caster, 6)
      • -------- ------------------------------------------------------- --------
      • Trigger - Turn on Charge Loop <gen>
"Caster" is a unit variable
"TargetPoint" is point variable

A very important part is the "call SetUnitAnimationByIndex(udg_Caster, 6)" custom script. Through this script I play "walk" animation, so the caster runs when he charges. The number 6 is index number of "walk" animation, however that is for Blademaster unit... walk animation of other units may have different index number. If more than 1 model uses this spell, then you will need an If/Then/Else.


And this other trigger which periodically moves the Caster unit.
  • Charge Loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set p1 = (Position of Caster)
      • -------- Checks distance between TargetPoint and caster's current location p1 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between TargetPoint and p1) Greater than 10.44
        • Then - Actions
          • -------- It is not close enough, so we offset caster a little bit towards TargetPoint --------
          • Set p2 = (p1 offset by 10.44 towards (Angle from p1 to TargetPoint) degrees)
          • -------- ------------------------------------------------------- --------
          • -------- ------------------------------------------------------- --------
          • -------- We find X and Y coordiantes of p2 --------
          • Set x = (X of p2)
          • Set y = (Y of p2)
          • -------- ------------------------------------------------------- --------
          • -------- ------------------------------------------------------- --------
          • -------- This moves the caster, it moves Caster through any pathing, so you will "run" up/down cliffs, over deep water, etc. but you will also not be blocked by other units --------
          • -------- It moves caster by moving him to X and Y coordinates which we set up a few lines above --------
          • Custom script: call SetUnitX( udg_Caster, udg_x)
          • Custom script: call SetUnitY( udg_Caster, udg_y)
          • -------- ------------------------------------------------------- --------
          • -------- ------------------------------------------------------- --------
          • -------- This removes memory leaks. --------
          • Custom script: call RemoveLocation(udg_p1)
          • Custom script: call RemoveLocation(udg_p2)
        • Else - Actions
          • -------- Caster is close enough to TargetPoint, we move Caster one last time and end charge spell --------
          • Trigger - Turn off (This trigger)
          • -------- ------------------------------------------------------- --------
          • -------- We find X and Y coordinates of TargetPoint and move Caster there --------
          • Set x = (X of TargetPoint)
          • Set y = (Y of TargetPoint)
          • Custom script: call SetUnitX( udg_Caster, udg_x)
          • Custom script: call SetUnitY( udg_Caster, udg_y)
          • -------- ------------------------------------------------------- --------
          • -------- ------------------------------------------------------- --------
          • -------- Resets Caster's animation speed and current animation to defaults and create special effect --------
          • Animation - Reset Caster's animation
          • Animation - Change Caster's animation speed to 100.00% of its original speed
          • Special Effect - Create a special effect at TargetPoint using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • -------- ------------------------------------------------------- --------
          • -------- ------------------------------------------------------- --------
          • -------- Stops Caster to null his current order and unpauses him --------
          • Unit - Order Caster to Stop
          • Unit - Unpause Caster
          • Set Caster = No unit
          • -------- ------------------------------------------------------- --------
          • -------- ------------------------------------------------------- --------
          • -------- Removes leaks --------
          • Custom script: call RemoveLocation(udg_TargetPoint)
          • Custom script: call RemoveLocation(udg_p1)
          • Set Caster = No unit
We move Caster by 11.44 every 0,02 second, which is effectively 522 every second, so the movement speed should be correct.

x and y are real variables, p1 and p2 are point variables.
 
Status
Not open for further replies.
Top