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

[Trigger] Uncontrollable, but attackable?

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
I want to make a spell that summons a unit that automatically attacks the target of the spell, and cant be controlled by the owning player. It has to be selectable and attackable because the enemy should be able to remove it by killing it (like Arachna's ultimate in Heroes of Newerth, or the little bugs that Nerubian Weaver makes in DotA)

So is there a way to do this without like triggering the units to attack the target every 0.03 seconds?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Well you wouldn't really need a timer. Every time the user gives the unit an order it will trigger an event, and when that event is triggered you can re-issue the appropriate order despite any possible user input.
 
Level 8
Joined
Apr 30, 2009
Messages
338
Ok I think I have everything covered with 6 triggers now...


This just summons the unit in melee range of the target when spell is cast and makes it attack the target
  • Living Ember 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to SUM-1 Living Ember
    • Actions
      • Set temp_real = ((Facing of (Triggering unit)) + 180.00)
      • Set temp_point = (Position of (Target unit of ability being cast))
      • Set temp_point2 = (temp_point offset by 50.00 towards temp_real degrees)
      • Unit - Create 1 Living Ember for (Owner of (Triggering unit)) at temp_point2 facing temp_real degrees
      • Custom script: call RemoveLocation(udg_temp_point)
      • Custom script: call RemoveLocation(udg_temp_point2)
      • Unit - Order (Last created unit) to Attack (Target unit of ability being cast)
      • Unit - Add a 8.00 second Generic expiration timer to (Last created unit)
      • Hashtable - Save 4 as (Key attacks) of (Key (Last created unit)) in H_SUM_LivingEmber
      • Hashtable - Save Handle Of(Triggering unit) as (Key caster) of (Key (Last created unit)) in H_SUM_LivingEmber
      • Hashtable - Save Handle Of(Target unit of ability being cast) as (Key target) of (Key (Last created unit)) in H_SUM_LivingEmber
      • Unit Group - Add (Last created unit) to G_SUM_LivingEmber

This makes sure the unit will die after its 4th attack if its expiration timer isn't done yet
  • Living Ember 002
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Living Ember
    • Actions
      • Set temp_integer = (Load (Key attacks) of (Key (Attacking unit)) from H_SUM_LivingEmber)
      • Set temp_unit = (Load (Key target) of (Key (Attacking unit)) in H_SUM_LivingEmber)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to temp_unit
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • temp_integer Greater than 1
            • Then - Actions
              • Hashtable - Save (temp_integer - 1) as (Key attacks) of (Key (Attacking unit)) in H_SUM_LivingEmber
            • Else - Actions
              • Unit - Add a 0.25 second Generic expiration timer to (Attacking unit)
        • Else - Actions
          • Unit - Order (Attacking unit) to Attack temp_unit

These will stop the summon from doing anything except attacking the original target
  • Living Ember 003
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Living Ember
    • Actions
      • Set temp_unit = (Load (Key target) of (Key (Triggering unit)) in H_SUM_LivingEmber)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of issued order) Not equal to temp_unit
        • Then - Actions
          • Unit - Order (Triggering unit) to Attack temp_unit
        • Else - Actions
  • Living Ember 004
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Living Ember
    • Actions
      • Set temp_unit = (Load (Key target) of (Key (Triggering unit)) in H_SUM_LivingEmber)
      • Unit - Order (Triggering unit) to Attack temp_unit

Makes sure the summon will die if its target dies and clears the hashtable when a summon dies, and removes the shared vision buff from the target
  • Living Ember 005
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Living Ember
        • Then - Actions
          • Set temp_integer = 0
          • Set temp_unit = (Load (Key target) of (Key (Triggering unit)) in H_SUM_LivingEmber)
          • Unit Group - Pick every unit in G_SUM_LivingEmber and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • temp_unit Equal to (Load (Key target) of (Key (Picked unit)) in H_SUM_LivingEmber)
                • Then - Actions
                  • Set temp_integer = (temp_integer + 1)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • temp_integer Equal to 0
            • Then - Actions
              • Unit - Remove ~SUM-1 Living Ember (Summoner) buff from temp_unit
            • Else - Actions
          • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in H_SUM_LivingEmber
          • Unit Group - Remove (Triggering unit) from G_SUM_LivingEmber
        • Else - Actions
          • Unit Group - Pick every unit in G_SUM_LivingEmber and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering unit) Equal to (Load (Key target) of (Key (Picked unit)) in H_SUM_LivingEmber)
                • Then - Actions
                  • Unit - Add a 0.25 second Generic expiration timer to (Picked unit)
                • Else - Actions

Makes it so a player cannot select a summon owned by himself
  • Living Ember 006
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
      • Player - Player 4 (Purple) Selects a unit
      • Player - Player 5 (Yellow) Selects a unit
      • Player - Player 6 (Orange) Selects a unit
      • Player - Player 7 (Green) Selects a unit
      • Player - Player 8 (Pink) Selects a unit
      • Player - Player 9 (Gray) Selects a unit
      • Player - Player 10 (Light Blue) Selects a unit
      • Player - Player 11 (Dark Green) Selects a unit
      • Player - Player 12 (Brown) Selects a unit
    • Conditions
    • Actions
      • Set temp_group = (Units currently selected by (Triggering player))
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Living Ember
              • (Owner of (Picked unit)) Equal to (Triggering player)
            • Then - Actions
              • Selection - Remove (Picked unit) from selection for (Triggering player)
            • Else - Actions
          • Unit Group - Remove (Picked unit) from temp_group
      • Custom script: call DestroyGroup(udg_temp_group)
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
It doesn't matter whether the user can select it or not since any time an order is issued it will be over-ridden with an attack on the target of the spell. It doesn't matter what the user orders it to do because it will always re-issue the attack.

By the way, in the trigger, you're going to want to include the other order events as well so that all order input is disabled.
 
Level 8
Joined
Apr 30, 2009
Messages
338
i made cast, backswing, and damage point set to 0 and an instant missle attack so I can trigger an attack countdown without using damage detection. After 4 attacks, I just give the unit a 0.03 second expiration timer
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Cokemonkey11 said:
Actually it does matter. There's something called backswing points which you should look into.

Back-swing point has nothing to do with issued orders. The only time back-swing is factored in is when a unit is actually attacking the unit. When this happens it's order will be "attack". What you're doing with the events is making absolutely sure that the "dummy" unit's order is always an attack on the target.

Cokemonkey11 said:
Issuing an order interrupts its current order, so if you can select a unit and order it to do something only to have it stop, it could have detrimental effects on the system.

That's why you don't order the unit to stop, you order it to attack the target like the thread said.

Christ I shouldn't have to repeat myself several times. If you want my help then take it I don't want to fucking argue with anybody. What I've said is a full-proof solution to the problem, only to be questioned by you on irrelevant terms.
 

Cokemonkey11

Spell Reviewer
Level 29
Joined
May 9, 2006
Messages
3,534
Back-swing point has nothing to do with issued orders. The only time back-swing is factored in is when a unit is actually attacking the unit. When this happens it's order will be "attack". What you're doing with the events is making absolutely sure that the "dummy" unit's order is always an attack on the target.



That's why you don't order the unit to stop, you order it to attack the target like the thread said.

Christ I shouldn't have to repeat myself several times. If you want my help then take it I don't want to fucking argue with anybody. What I've said is a full-proof solution to the problem, only to be questioned by you on irrelevant terms.

You're straight up wrong and it's cute that you think you're so smart. The system works because the unit has a backswing point of 0, but the problem would occur otherwise.

Having a trigger cause a deselect DOES delay slightly, and as such a player could easily click a unit and immediately press s or right click the ground somewhere. At which point the trigger would order it to keep attacking it's target.

I don't know how familiar you are with the warcraft 3 engine, but when you interrupt an order with an attack order, the backswing point must be met first. Think about in AoS type games where a melee hero has to last-hit a unit. You spam stop until you have it timed right, then let the attack order run.

For the sake of not making yourself look dumber than you already have by flaming me, open up the editor, make a unit with an abnormally high backswing point (1 second or so), implement this trigger, then click the unit and order it to stop. Repeat the process. Observe the unit is attacking at a reduced rate.

Edit: If you can click fast enough, you can stop the unit from attacking entirely.
 
Status
Not open for further replies.
Top