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

Self Defense, make the attacking player enemy?

Status
Not open for further replies.
Level 7
Joined
Mar 9, 2016
Messages
226
I tried making this a thing, but for some reason it does not work.
When a player attacks a unit owned by player 11, player 11 makes the triggering player enemy.

  • Self Defense
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Is attacked
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Make (Triggering player) treat Player 11 (Dark Green) as an Enemy
          • Player - Make Player 11 (Dark Green) treat (Triggering player) as an Enemy
 
Level 7
Joined
Mar 10, 2013
Messages
366
I'm seeing that you're having all time trouble with some misconceptions about what the "Triggering Unit" or "Triggering Player" means and endup with alot of triggers that doens't work because you're using the wrong definitions.

Triggering * (Unit, Player...) = Means the exact player or unit that disptached the event (e.g. Event Unit enters Region, there's only a Triggering Unit, which is the Unit that entered the region. Event Player (N) enters chat string "...", there's only a Triggering Player, which is the player that typed the chat string). And by the way, there will be never a Triggering Unit and Player, only one of those, and that depends on the type of Event you're watching (generally if the events regards a player, there will be a Triggering Player, and so forth for the a event regarding a Unit).

Picked * (Unit, Player) = Means each unit in a Pick Units/Players in Group and do Actions. Whenever you want to Pick groups of things (There's a Pick every ... in (Group)) and want to do something with it use Picked Unit/Player.

Matching * (Unit, Player) = It's the same with picked unit, but will be used while checking Conditions (whenever there's a 'macthing' statement).
 
Level 7
Joined
Mar 9, 2016
Messages
226
So,i I replaced triggering player with picked player. Its not working, I really don't get this. Or am just too sleepy to figure it out and its plain obvious.
 
Level 11
Joined
Jun 2, 2004
Messages
849
You'll want to use Owner of Attacked/Attacking unit.

There is no triggering player in this case since you'd need an event triggered directly by a player (like a chat command), not one of their units. A unit event will only have a triggering unit, and no other "triggering" variable.
 
Level 7
Joined
Mar 10, 2013
Messages
366
So,i I replaced triggering player with picked player. Its not working, I really don't get this. Or am just too sleepy to figure it out and its plain obvious.
What is not working? What your trigger does is, whenever any unit attacks a player owned by the Player 11 (DG), it treats everyones as enemy, and everyone treats his as enemy.

Is this incorrect? If you want to do that specifically for the player that attacked. You need to use (out of a pick statement), Owner of Attacking Unit.
 
Level 11
Joined
Jan 2, 2016
Messages
472
EDIT:
  • Events
    • Unit - A unit owned by Player 1 (Red) is attacked
  • Conditions
    • ( Owner of ( Attacking unit ) ) not equal to Player 1 (Red)
  • Actions
    • Unit Group - Pick every unit in ( Units in ( Playable Map Area ) owned by ( Owner of ( Attacking Unit ) ) and do ( Actions )
      • Unit - Change ownership of ( Picked unit ) to Neutral Hostile and Change color
Of course `Unit is attacked` has its own handicap, so you should use a DDS.

EDIT 2: + removing the group leak
 
Last edited:
Level 7
Joined
Mar 10, 2013
Messages
366
  • Events
    • Unit - A unit owned by Player 1 (Red) is attacked
  • Conditions
  • Actions
    • Unit - Change ownership of ( Attacking unit ) to Neutral Hostile and Change color
Of course `Unit is attacked` has its own handicap, so you should use a DDS.
I don't think that will be the result he's expecting.
 
Level 7
Joined
Mar 10, 2013
Messages
366
He probably don't want the unit to change forces, just to control alliances using this method.
 
Level 7
Joined
Mar 10, 2013
Messages
366
For instance, make player 7 enemy of player 4 if player 4 attacks him or viceversa. Not just turning it enemy of everyone.
 
Level 4
Joined
Mar 29, 2017
Messages
78
Maybe you want to do this
  • Self Defense
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Is attacked
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Make (Owner of(Attacking unit) unit treat Player 11 (Dark Green) as an Enemy
          • Player - Make Player 11 (Dark Green) treat (Owner of(Attacking unit) as an Enemy
 
Level 7
Joined
Mar 10, 2013
Messages
366
Maybe you want to do this
  • Self Defense
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Is attacked
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Make (Owner of(Attacking unit) unit treat Player 11 (Dark Green) as an Enemy
          • Player - Make Player 11 (Dark Green) treat (Owner of(Attacking unit) as an Enemy
There's no need for the Player Group loop there.
 
Status
Not open for further replies.
Top