• 🏆 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] How to make a charge?

Status
Not open for further replies.
Hi, I'm trying to make a change, and here it is. I know there is charge and slash in spells section, but the warrior and the target are ALREADY in variables here, so they can't be in other variables, that's why I have to put the target in unit group. Don't think that the warrior is MUI just because it is in an array, just makes it easier for me :D. the spell is not MUI, and cannot be cast multiple times before the cooldown refresh.

The problem is that when i castt charge it charges but continues to run against the target. can someone lighten me up why? :D

  • Charge cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charge (Warrior)
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to Warrior_Charge_Group
  • Charge finish
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Charge (Warrior)
    • Actions
      • Trigger - Turn on Charge loop <gen>
  • Charge loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Warrior_Charge_Group and do (Actions)
        • Loop - Actions
          • Set Warrior_Charge_TargetPos = (Position of (Picked unit))
          • Set Warrior_Charge_points[1] = (Position of Hero_units[2])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Warrior_Charge_points[1] and Warrior_Charge_TargetPos) Greater than 30.00
            • Then - Actions
              • Unit - Make Hero_units[2] face (Picked unit) over 0.00 seconds
              • Set Warrior_Charge_points[2] = (Warrior_Charge_points[1] offset by 10.00 towards (Facing of Hero_units[2]) degrees)
              • Unit - Move Hero_units[2] instantly to Warrior_Charge_points[2]
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[1])
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[2])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Warrior_Charge_points[1] and Warrior_Charge_TargetPos) Less than or equal to 30.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Warrior_Charge_Group
              • Unit - Order Hero_units[2] to Stop
              • Trigger - Turn off (This trigger)
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[1])
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[2])
            • Else - Actions
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
I don't understand your problem fully (didn't understand the sentence).

Anyway, charge spells are imo the hardest spells to code efficiently in WCIII, because:
1) You cannot calculate efficiently a good pathable way from starting point to target point. There are ways to find out if point is pathable, but there's no easy way to find out if a whole way is pathable AND joint together.

2) If you use the action you used - "Unit - Move unit to point", then you interrupt its current order, but that's not the only problem - unit is affected by pathable points. In actual game, that would mean that the unit will be moved to the next pathable point - then the actual path your triggering unit ran doesn't even look like path (more so if big groups of units are clustered together and your unit is supposed to run through them).

3) More used approach is using the SetUnitX and SetUnitY commands, as they ignore pathing and using an item trick to find out if point is pathable or not (this check does not include units - they are considered pathable, which works to our favor), but your unit would be able to run through cliffs of different high etc. and once again, there is no way to easily find out joint pathable way from point X to point Y, so your unit can either run in direct line and stops at first unpathable point, or it runs through them...


Side note:
Your point variables don't seem to save any data for longer than 1 trigger run. You should opt to using temp variables for such cases, so you don't end up with hunderds of variables when they all can be replaced by 1 temp variable.
 
I reviewed the trigger and here is what I made. But still, after the distance between them becomes 40, the warrior becomes to SHAKE in place.
  • Charge cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charge (Warrior)
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to Warrior_Charge_Group
  • Charge finish
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Charge (Warrior)
    • Actions
      • Trigger - Turn on Charge loop <gen>
  • Charge loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Warrior_Charge_Group and do (Actions)
        • Loop - Actions
          • Set Warrior_Charge_TargetPos = (Position of (Picked unit))
          • Set Warrior_Charge_points[1] = (Position of Hero_units[2])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Warrior_Charge_points[1] and Warrior_Charge_TargetPos) Less than or equal to 40.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Warrior_Charge_Group
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[1])
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[2])
              • Custom script: call RemoveLocation(udg_Warrior_Charge_TargetPos)
              • Trigger - Turn off (This trigger)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Warrior_Charge_points[1] and Warrior_Charge_TargetPos) Greater than 40.00
            • Then - Actions
              • Unit - Make Hero_units[2] face (Picked unit) over 0.00 seconds
              • Set Warrior_Charge_points[2] = (Warrior_Charge_points[1] offset by 10.00 towards (Facing of Hero_units[2]) degrees)
              • Unit - Move Hero_units[2] instantly to Warrior_Charge_points[2]
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[1])
              • Custom script: call RemoveLocation(udg_Warrior_Charge_points[2])
              • Custom script: call RemoveLocation(udg_Warrior_Charge_TargetPos)
            • Else - Actions
Instead of 30 range try use something like 70 or 100 range.
Distance of 30 is fine as well as 40, there is enough space between them.
 
I don't understand your problem fully (didn't understand the sentence).

Anyway, charge spells are imo the hardest spells to code efficiently in WCIII, because:
1) You cannot calculate efficiently a good pathable way from starting point to target point. There are ways to find out if point is pathable, but there's no easy way to find out if a whole way is pathable AND joint together.

2) If you use the action you used - "Unit - Move unit to point", then you interrupt its current order, but that's not the only problem - unit is affected by pathable points. In actual game, that would mean that the unit will be moved to the next pathable point - then the actual path your triggering unit ran doesn't even look like path (more so if big groups of units are clustered together and your unit is supposed to run through them).

3) More used approach is using the SetUnitX and SetUnitY commands, as they ignore pathing and using an item trick to find out if point is pathable or not (this check does not include units - they are considered pathable, which works to our favor), but your unit would be able to run through cliffs of different high etc. and once again, there is no way to easily find out joint pathable way from point X to point Y, so your unit can either run in direct line and stops at first unpathable point, or it runs through them...


Side note:
Your point variables don't seem to save any data for longer than 1 trigger run. You should opt to using temp variables for such cases, so you don't end up with hunderds of variables when they all can be replaced by 1 temp variable.

http://www.hiveworkshop.com/forums/...-0-a-207607/?prev=search=movement&d=list&r=20 + unit-groups = Done.

Do you still need help stan0033?
 
Status
Not open for further replies.
Top