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

Changing owner

Status
Not open for further replies.
Level 3
Joined
Dec 27, 2014
Messages
23
Hi i have a problem on my map and i don't know how to solve.

I placed a hero and a player will select (all work perfect). But when the hero is changed to another owner the trigger will detect the last owner when i want to trigger this

New_Bitmap_Image.png


The trigger detect the last owner and not the current and i want to detect the current owner not the last because i want to add -GOLD for the current owner

I wand a trigger or condition or action something but the trigger to no detect the last owner for that hero .

I hope you understand my problem if you do not understand something please post.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You have to understand what happens when you create triggers.
When you load the map, the game will run a function called the "main".
All your trigger events are placed inside that main function.

So in your main function, you create a new trigger and add the event to it:
<player>'s <variable> becomes <operator> <value>. (You don't have to understand it completely already :D)

Your event: "Player - (Owner of Blood Mage 0243 <gen>)'s Current gold becomes Greater than or equal to 1000.00"
Is the visualisation of the implementation of that weird stuff I just wrote.

First of all, who is the player that this event will work for?
<player> = (Owner of Blood Mage 0243 <gen>)
So the <player> will be the owner of that Blood Mage unit at the moment that the map loads.
That player (probably neutral passive) will now be linked to this event.

<variable> will be the thing that we want to track (the gold)
<operator> will be the operator that we use on this event (Greater than or equal to)
<value> will be the value that the gold has to be greater than or equal to.
However these are irrelevant to your problem.

What happens is that now, we have the trigger all set up and ready to use.
When Neutral Passive's gold will be greater than or equal to 1000, we run this trigger.

You can see that the Blood Mage is of no concern of the trigger itself.
The trigger doesn't care if the Blood Mage exists.
The trigger doesn't care who the owner of the Blood Mage is.
The trigger only cares about Neutral Passive's gold.

So to fix your problem, there are two solutions:
1, we create a new event when the blood mage changes owner (the original event will then be useless so you can remove it).
This means that instead of creating the event when the map loads, we create the event when you select the Blood Mage.
There seems to be a GUI action that adds an event to a trigger during runtime.

2, we create a generic event (much more recommended and better for personal triggering/scripting/coding experience).
In this case, we create an event that will work for every single player, but adds a condition that you have to be the owner of the Blood Mage.
Because you use a preplaced unit, you can use that one, however I ussually use a global array variable to store the hero of each player in.
Then you can check if the unit type of the player's hero is equal to Blood Mage.
Then this trigger would work for all players that would have the Blood Mage as their hero.

In any case, it would work properly.
The first one is slightly easier to create but the second one is much more recommended.
Anyway, it is your choice.
 
Level 3
Joined
Dec 27, 2014
Messages
23
Thanks for that i will have a much more to work because that trigger do not detect the current owner (why!!) only the initial owner :(. However i have 20 heroes to manage,make a select trigger for every hero , run (Advanced) AI for it and 10 player who can select the hero.

Let's get started :)

Problem Solved
 
Status
Not open for further replies.
Top