How can i detect player number of owner of triggering unit?

Status
Not open for further replies.
Level 18
Joined
Jun 2, 2009
Messages
1,233
Hello. Is there a way to detect this one?

  • Untitled Trigger 001 Copy
    • Events
      • 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 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
I want to set TempUnit = Owner of Triggering Unit but somehow i cannot do that.

How can i detect? I have a variable names Hero [number]
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
owner of triggering unit == triggering player.

it's a preset option. but that wouldn't be tempUnit which I assume is a "unit" variable but rather a "player" variable.


maybe I misunderstood you...
Uhmmm let me tell you.

  • Events
    • 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 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
    • (Unit-type of (Triggering unit)) Equal to Carrion Beetle (Level 1)
  • Actions
    • Unit Group - Pick every unit in (Units within 500.00 of (Position of Carrion Beetle (Level 1) 0003 <gen>) matching ((((Matching unit) is in HerolarALL) Equal to True) and (((Matching unit) belongs to an ally of (Owner of Carrion Beetle (Level 1) 0003 <gen>)) Equal to True))) and do (Actions)
      • Loop - Actions
        • Unit - Move BirimNumarasi instantly to (Position of Crypt Lord 0001 <gen>)
I want to move only Hero [player number of owner of selected player bla bla]

When your ally clicks on your unit, it's hero teleports near of your hero.
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
here you go:

  • setup
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet heroes[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
the variable "heroes" is a unit array. TempPoint is a point.

  • tp
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • ((Triggering player) is an ally of (Owner of (Triggering unit)).) Equal to True
    • Actions
      • Set VariableSet TempPoint = (Position of heroes[(Player number of (Owner of (Triggering unit)))])
      • Unit - Move heroes[(Player number of (Triggering player))] instantly to TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
good luck!

(this will work assuming there is only one hero per player, and they are added to the map after initialization. otherwise you will need to change some things.)
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
Edit: Here is the situation. My hero able to teleport but my friend doesn't (player 3)

  • Events
    • Time - Elapsed game time is 1.00 seconds
  • Conditions
  • Actions
    • Unit - Create 1 Paladin for Player 2 (Blue) at (Center of Region 000 <gen>) facing Default building facing degrees
    • Unit Group - Add (Last created unit) to HerolarALL
    • Set FenerBirim_u[(Player number of (Owner of (Last created unit)))] = (Last created unit)
    • Unit - Create 1 Archmage for Player 3 (Teal) at (Center of Region 000 <gen>) facing Default building facing degrees
    • Unit Group - Add (Last created unit) to HerolarALL
    • Set FenerBirim_u[(Player number of (Owner of (Last created unit)))] = (Last created unit)
  • Events
    • 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 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
    • (Unit-type of (Triggering unit)) Equal to Carrion Beetle (Level 1)
  • Actions
    • Set TempPoint = (Position of (Triggering unit))
    • Unit Group - Pick every unit in (Units within 500.00 of (Position of Carrion Beetle (Level 1) 0003 <gen>) matching ((((Matching unit) is in HerolarALL) Equal to True) and (((Matching unit) belongs to an ally of (Owner of Carrion Beetle (Level 1) 0003 <gen>)) Equal to True))) and do (Actions)
      • Loop - Actions
        • Unit - Move FenerBirim_u[(Player number of (Triggering player))] instantly to (Position of Crypt Lord 0001 <gen>)
    • Custom script: call RemoveLocation(udg_TempPoint)
 
Last edited:
Level 25
Joined
Mar 29, 2020
Messages
1,466
you seem to be overcomplicating things.

for instance - , if you created a paladin for player 2 - then you don't need to try to detect who the owner of the last created unit is with "(Player number of (Owner of (Last created unit)))", you can just use the number 2 like this => Set FenerBirim_u[2] = (last created unit).

however if you want to be able to work dynamically and not have to hard code triggers for every specific player, I suggest you start from what I posted and just add the conditions you need.
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
you seem to be overcomplicating things.

for instance - , if you created a paladin for player 2 - then you don't need to try to detect who the owner of the last created unit is with "(Player number of (Owner of (Last created unit)))", you can just use the number 2 like this => Set FenerBirim_u[2] = (last created unit).

however if you want to be able to work dynamically and not have to hard code triggers for every specific player, I suggest you start from what I posted and just add the conditions you need.
This is my test map for the test and prepare things before implement it into my map. You can ignore my method in this trigger. I just need to learn why Player 3 cannot use this teleport thing?
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
if you both are allies of (Owner of Carrion Beetle (Level 1) 0003 <gen>), and he is selecting the beetle, It should move him too when he selects it. (if the beetle belongs to him, than that is the reason since he is not his own ally). the way it is currently set up it will only move the units that belong to the player that clicked on the beetle.

if you want it to also move player 3's units when you are the one who clicks - then you need to change the inside of the loop. currently it just moves the same unit (FenerBirim_u[(Player number of (Triggering player))]) again for each loop, since the triggering player is still the same player. so it's just moving the same unit to the same place again and again.

also, you you aren't using the point variable you created and instead you are leaking both points you actually use (Position of Carrion Beetle, Position of Crypt Lord ).
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
if you both are allies of (Owner of Carrion Beetle (Level 1) 0003 <gen>), and he is selecting the beetle, It should move him too when he selects it. (if the beetle belongs to him, than that is the reason since he is not his own ally). the way it is currently set up it will only move the units that belong to the player that clicked on the beetle.

if you want it to also move player 3's units when you are the one who clicks - then you need to change the inside of the loop. currently it just moves the same unit (FenerBirim_u[(Player number of (Triggering player))]) again for each loop, since the triggering player is still the same player. so it's just moving the same unit to the same place again and again.

also, you you aren't using the point variable you created and instead you are leaking both points you actually use (Position of Carrion Beetle, Position of Crypt Lord ).
Wow. Yes it is working. Why my friend lied to me i don't know. I was testing with him. Then now i have tested it with someone else and it is working. I haven't changed anything.

Ok i think it is ok now.

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Avatar
  • Actions
    • Set UnitToBeTeleported = (Casting unit)
This is the unit. I will make it non-moving structure looking unit. When player casts the skills, it willl create this unit and set it as FenerKendi

Then this is the trigger as you want i think. Right? Just let me know if you see the problem.

  • Events
    • 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 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
    • (Unit-type of (Triggering unit)) Equal to Carrion Beetle (Level 1)
  • Actions
    • Set TempPoint = (Position of (Triggering unit))
    • Unit Group - Pick every unit in (Units within 500.00 of TempPoint matching ((((Matching unit) is in HerolarALL) Equal to True) and (((Matching unit) belongs to an ally of (Owner of Carrion Beetle (Level 1) 0003 <gen>)) Equal to True))) and do (Actions)
      • Loop - Actions
        • Unit - Move FenerBirim_u[(Player number of (Triggering player))] instantly to (Position of UnitToBeTeleported)
    • Custom script: call RemoveLocation(udg_TempPoint)
 

Attachments

  • fener yetenek.w3x
    18.1 KB · Views: 6
Level 25
Joined
Mar 29, 2020
Messages
1,466
from a quick glance it seems like it should work.

it doesn't seem so optimal though. you should read about what memory leaks are and how to avoid them. you are currently leaking a unit group (Unit Group - Pick every unit in .... ->this action creates a unit group) and a point (Position of UnitToBeTeleported).



in addition, looping through a unit group to move a single unit over and over again seems like a strange way to move a unit, but if that isn't causing problems than whatever I guess... just not so efficient.
 
Status
Not open for further replies.
Top