• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

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.
 
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.
 
  • 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!
 
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.
Back
Top