• 🏆 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] make unit only attacked by direct command

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
hey all,

I want to create an ability that when activated makes all units that were previously attacking it stop, and as long as it is active the user can only be attacked via direct command and not through auto attack or attack move. is that possible?

thanks!
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
change her owner.

I tried playing around with this concept but I don't think it will work in my map BC I want this to be an ability for a tavern hero on an altered melee map. so even when I gave the unit to neutral passive (a different one then critters and buildings so as not to give free scouting) and shared control with the original owner, If multiple players had this hero and used this ability at the same time it would cause chaos....
 
Level 16
Joined
May 2, 2011
Messages
1,345
Level 21
Joined
Mar 29, 2020
Messages
1,237
How can i turn off auto attack?
they suggested 2 solutions:
Reduce aquisition range (this will probably also disable attack move and only enable manual attacks)
Classify as worker (this will change how unit behaves in many ways, including disabling auto attack; and will also make icon apear)

thanks, but both of these options will make the units stop targeting all enemies in the area equally and not only the casting hero, no?
 
Level 16
Joined
May 2, 2011
Messages
1,345
aha i missread you title for attack instead of attacked sry

anyway what about this:

Event01
Unit is issued order targetting another unit
conditions:
target is EnderWiggins
Or - any condition is true
issued order is right click
issued order is attack command
Actions
Add trigger unit to PermitAttackUnitGroup

Event02
unit is attacked
Conditions
attacked unit is EnderWiggins
triggering unit is not within PermitAttackUnitGroup
Actions:
order triggering unit to stop!

Event03
unit is issued an order targeting a point
unit is issued an order targeting a unit
unit is issued an order with no target
unit is issued any other order
Conditions
Unit is wihtin PermitAttackUnitGroup
Target is not equal to EnderWiggins
Actions
Remove triggering unit from Units within PermitAttackUnitGroup



but that wouldnt be MUI afaik
also im not sure the condition "Target is not equal to EnderWiggins" works if the event has no target.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
I have been trying to play around with this but it seems that auto attack activates attack command. so by allowing or blocking one, I am doing the same to the other one.

I did this:

  • Events
    • Unit - A unit Is attacked
  • Conditions
    • ((Attacked unit) has buff leavemebe) Equal to True
    • (Issued order) Not equal to (Order(attack command))
    • (Issued order) Not equal to (Order(right click))
  • Actions
    • Unit - Order (Attacking unit) to Stop
and this way it had no effect. when i moved the unit close to the hero who was using the ability, they auto attacked him - so I guess auto attack works via attack command. and when i set the conditions the opposite way (order equal to attack ground) it couldn't attack him at all. so this looked promising, but not sure if possible this way.

There should be a way to do it by manipulating mechanical critter (the only unit with exactly the desired "attackability"), but th only way I found to manipulate it is by setting the desired unit as the only type of critter - which I don't want to do as this is for an altered melee, and I don't want to give a free hero to whoever uses a mechanical critter.... :hohum:
 
Level 16
Joined
May 2, 2011
Messages
1,345
wierd. I checked the item ability, and it does not have a summoned unit type field.

though I have Q, what about if you the unit race - critter, like all other critters (sheep chicken frog etc).

I checked all creature true false fields and there doesnt seem to be anything special about them.


as for the item summoned problem, you can solve that by trigger easily

event
unit uses mechanical critter
action
create random unit for trigger player (frog sheep or dear)
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
I may have thought of a way around this: make unit invisible & with no (is that possible?) or nearly invisible model file. than create a neutral passive dummy with the model you want that is always where the unit is. when your unit looses whatever status this is, make the dummy die and your unit return to its previous form.

would this work?
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
Here's a trick : Create a dummy unit which is the same type as the unit you don't want to be auto-attacked and change its Combat - Targeted as to something which cannot be targeted, after that make the normal unit morph into this dummy unit when shes casts the spell.
Now if you want to attack command the unit in question, simply morph the dummy unit back to its normal form.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
Here's a trick : Create a dummy unit which is the same type as the unit you don't want to be auto-attacked and change its Combat - Targeted as to something which cannot be targeted, after that make the normal unit morph into this dummy unit when shes casts the spell.
Now if you want to attack command the unit in question, simply morph the dummy unit back to its normal form.

but how can you issue an order to attack command something that can't be targeted?
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
but how can you issue an order to attack command something that can't be targeted?
  • Trigger 1
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • (Target unit of issued order) Equal Footman 0000 <gen>
    • Actions
      • Game - Display to (All players) the text: Test
  • Trigger 2
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(attack))
    • Actions
      • Set Point = (Target point of issued order)
      • Set Region = (Region centered at Point with size (200.00, 200.00))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Region contains Footman 0000 <gen>) Equal to TRUE
        • Then - Actions
          • Game - Display to (All players) the text: Test
        • Else - Actions
      • Custom script: call RemoveLocation (udg_Point)
      • Custom script: call RemoveRect (udg_Region)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,552
You could so something like this, although it's not perfect:
  • Direct Attack
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LeaveMeBe[(Custom value of (Target unit of issued order))] Equal to True
          • Or - Any (Conditions) are true
            • Conditions
              • (Issued order) Equal to (Order(attack))
              • (Issued order) Equal to (Order(smart))
        • Then - Actions
          • Set VariableSet AttackTarget[(Custom value of (Ordered unit))] = (Target unit of issued order)
        • Else - Actions
          • Set VariableSet AttackTarget[(Custom value of (Ordered unit))] = No unit
  • Cancel Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • LeaveMeBe[(Custom value of (Attacked unit))] Equal to True
      • AttackTarget[(Custom value of (Attacking unit))] Not equal to (Attacked unit)
    • Actions
      • Unit - Order (Attacking unit) to Stop.
  • Turn On Leave Me Be
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence <--- This runs when you press ESCAPE
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LeaveMeBe[(Custom value of Paladin 0000 <gen>)] Equal to False
        • Then - Actions
          • Set VariableSet LeaveMeBe[(Custom value of Paladin 0000 <gen>)] = True
          • Game - Display to (All players) for 30.00 seconds the text: Leave Me Be = ON
          • Special Effect - Create a special effect attached to the origin of Paladin 0000 <gen> using Abilities\Spells\Human\DivineShield\DivineShieldTarget.mdl
        • Else - Actions
          • Set VariableSet LeaveMeBe[(Custom value of Paladin 0000 <gen>)] = False
          • Game - Display to (All players) for 30.00 seconds the text: Leave Me Be = OFF
          • Special Effect - Destroy (Last created special effect)
It takes advantage of that Unit Indexer system I used in your other spell.

How it works:
1) When a unit is attacked, if LeaveMeBe = True for the attacked unit, then order the attacker to "stop".
2) When you order a unit to directly attack a target, this target is saved as the AttackTarget for the ordered unit.
3) If LeaveMeBe = True BUT the attacked unit happens to be the attacking unit's AttackTarget, then allow the attack to go through.
4) When a unit issues any order other than a Direct Attack (aka any order other than "smart" targeting a unit or "attack") then set it's AttackTarget to No Unit.

"smart" = right click
 

Attachments

  • Attack Cancel Example.w3m
    22.3 KB · Views: 32
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
I finally got this set up and it works perfectly, thanks!!!:grin:

just wanted to check - if I used the wrong types of variable arrays does that matter? (/if it works maybe that means I did it right...)


If - Conditions
  • empty.gif
    empty.gif
    line.gif
    join.gif
    if.gif
    LeaveMeBe[(Custom value of (Target unit of issued order))] Equal to True

-boolean array?


Set VariableSet AttackTarget[(Custom value of (Ordered unit))] = (Target unit of issued order)

- unit array?


besides that - I triggered the activation basically exactly as you wrote (but appropriately and minimally altered to fit the ability and not a test) but being as its an ability based on immolation just wanted to show you the deactivation and ask if everything looks right- anything missing? :

  • turn off leavemebe
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(unimmolation))
      • (Unit-type of (Triggering unit)) Equal to Master of Illusions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LeaveMeBe[(Custom value of (Triggering unit))] Equal to True
        • Then - Actions
          • Set LeaveMeBe[(Custom value of (Triggering unit))] = False
        • Else - Actions
          • Set LeaveMeBe[(Custom value of (Triggering unit))] = False
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,552
Yes, those are the correct variable types.
Boolean = True/False, Unit = Some specific pre-placed unit like Paladin 001 or a unit from an Event response like (Triggering/Casting/Dying unit).

You can always figure out a Variable type by it's value.

Anyway, since you're toggling LeaveMeBe with Immolation, you know for certain that "unimmolation" is ALWAYS turning OFF LeaveMeBe, and you know that "immolation" is ALWAYS turning it ON.

What you should do to simplify these triggers:

Delete the If Then Else, and keep only the single Set LeaveMeBe[custom value] = False in the Actions.

And do the same thing for your Turn On Immolation trigger, but set LeaveMeBe[custom value] = True instead.

So your 2 LeaveMeBe triggers will look something like:

A unit is issued an order, order = immolation, set LeaveMeBe = True.

A unit is issued an order, order = unimmolation, set LeaveMeBe = False.

Also, the Else in your current If Then Else works but it doesn't make any sense.
  • If LeaveMeBe = True
  • Set LeaveMeBe = False
  • ELSE (So if LeaveMeBe = False)
  • Set LeaveMeBe = False
^Your Else is only running if LeaveMeBe is already False, so it's redundant. You're setting LeaveMeBe = False if it's already False... lol.

But I point this out only to help you understand better as in this case the If Then Else isn't even needed in the first place.
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
I just found two small bugs -
1. when the hero gets stunned while using the ability - if I disable it while stunned - the ability itself stays active, while the "leavemebe" status ends.
2. while in leavemebe - the hero using the ability inconsistantly also doesn't auto attack or ground attack some enemies. this did not happen against enemy units(even a magic immune one) or against low level creeps, only against a granite golem. don't know what that's about.

3 - not a bug, but a setback - this ability stops creeps from attacking the user. what is the best way around that? specifically triggering creeps to focus the caster?


haven't changed according to your last post yet though...
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,552
1) Not sure about the stun thing, I'd have to test it myself. You may have to base the ability off of something else that isn't a Toggle ability.

2) Maybe the creeps are getting the LeaveMeBe status accidentally.

3) Filter out creeps in the conditions for the Cancel Attack trigger. Owner of Attacking unit not equal to Neutral Hostile.
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
Filter out creeps in the conditions for the Cancel Attack trigger.

so much simpler than this weird thing that I did lol:
  • creeps attack
    • Events
      • Unit - A unit owned by Neutral Hostile Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Master of Illusions
    • Actions
      • Set Temp_Group = (Units within 500.00 of (Position of (Attacking unit)) matching ((Owner of (Matching unit)) Equal to Neutral Hostile))
      • Unit Group - Order Temp_Group to Attack (Attacking unit)
      • Custom script: call DestroyGroup (udg_Temp_Group)
the stun thing

pretty sure that all went away now that the immolation directly toggles the leavemebe.

once again, awesome solve, thanks!!!
 
Status
Not open for further replies.
Top