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

[Solved] Simulate 'Attack Ground' with triggers

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

In the RPG i'm making there are some magics items that replace the natural attack of the Hero. But I want to simulate the same that happens with an 'Attack Ground' orden (or something like that). If the unit casts on the ground, the mana is consumed, thats what i want to avoid.

I want something like:

If the number of units around the (Point where the ability was casted) is greater than 0, pick random unit from (Units around Point) and Order (Triggering Unit) to Attack (Picked Unit). Else, Right click Point.


  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Mindstaff
    • Actions
      • Set Temp_Point = (Target point of ability being cast)
      • Set Temp_Group = (Units within 400.00 of Temp_Point matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group) Greater than 0
        • Then - Actions
          • Unit - Order (Triggering unit) to Attack (Random unit from Temp_Group)
        • Else - Actions
          • Unit - Order (Triggering unit) to Right-Click Temp_Point
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • Custom script: call RemoveLocation(udg_Temp_Point)


BUT, doesn't work. The unit casts the spell on the ground, spending mana and doing nothing.

The BaseorderID of the Skill is 'attack', same as the Text Order String.

EDIT: Managed to get it work... but warcraft crashes often when dealing with this order.


  • Avoid Casting on Ground
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(attack))
      • Or - Any (Conditions) are true
        • Conditions
          • (Level of Mindstaff for (Triggering unit)) Greater than 0
    • Actions
      • Unit - Order (Triggering unit) to Stop
      • Set Temp_Point = (Target point of issued order)
      • Set Temp_Group = (Units within 400.00 of Temp_Point matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group) Greater than 0
        • Then - Actions
          • Unit - Order (Triggering unit) to Attack (Random unit from Temp_Group)
        • Else - Actions
          • Unit - Order (Triggering unit) to Right-Click Temp_Point
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • Custom script: call RemoveLocation(udg_Temp_Point)


EDIT: The only way I managed it to work without crashing (so far xD) was removing the attack to the random target if there was any. When the unit gets two different orders with triggers, the game crashes, and somehow it was.

This trigger just avoids the cast on ground, ordering the unit to move to the point, instead of casting there.

  • Avoid Casting on Ground
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(attack))
      • Or - Any (Conditions) are true
        • Conditions
          • (Level of Mindstaff for (Triggering unit)) Greater than 0
    • Actions
      • Set Temp_Point = (Target point of issued order)
      • Unit - Order (Triggering unit) to Right-Click Temp_Point
      • Custom script: call RemoveLocation(udg_Temp_Point)
 
Last edited:
Status
Not open for further replies.
Top