• 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.
  • Vote for the theme of Hive's HD Modeling Contest #7! Click here to vote! - Please only vote if you plan on participating❗️

Forbid a unit to attack a Destructible

Status
Not open for further replies.
This seems to work:
  • dsafd
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Wait 0.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Destructible-type of (Target destructible of issued order)) Equal to Barricade
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
If you want to remove the wait, you'll have to play around with pausing/unpausing the unit at some point near the stop command.
 
Level 13
Joined
Feb 5, 2008
Messages
228
Alternately, you could just have the destructible be targeted as something else. Unless this is a destructible that needs to be readily accessed by another type of unit, you can just have it be targeted as a wall or some other sort of destructible and have your hero be unable to target walls. I know this isn't a triggered method, but this way the unit won't even be able to target the destructible, which is what most units will do if they can't attack destructibles, so it looks more consistent with the rest of the game and it won't force the unit to stop its previous orders. Again, it depends on what the destructible is. If it's a tree and you still need it to be harvestable, for instance, I wouldn't risk it, but otherwise it might be worth a shot.

I just did a quick test of this with a Paladin and a couple of random destructibles, and it seems to work.
 
Level 11
Joined
Jan 23, 2015
Messages
788
  • Trigger
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to <YourHero>
      • (Destructible-type of (Target destructible of issued order)) Equal to <Destructible>
    • Actions
      • Set TempPoint = (Position of (Target destructible of issued order))
      • Unit - Order (Ordered unit) to Move To TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
This orders the unit to just walk to the destructible, and will never attack it.. tested and works!
 
Level 10
Joined
Mar 17, 2012
Messages
582
Alternately, you could just have the destructible be targeted as something else. Unless this is a destructible that needs to be readily accessed by another type of unit, you can just have it be targeted as a wall or some other sort of destructible and have your hero be unable to target walls. I know this isn't a triggered method, but this way the unit won't even be able to target the destructible, which is what most units will do if they can't attack destructibles, so it looks more consistent with the rest of the game and it won't force the unit to stop its previous orders. Again, it depends on what the destructible is. If it's a tree and you still need it to be harvestable, for instance, I wouldn't risk it, but otherwise it might be worth a shot.

I just did a quick test of this with a Paladin and a couple of random destructibles, and it seems to work.

This is the way I solved it for now :) but it's not perfect :thumbs_up:
 
Status
Not open for further replies.
Top