Event Response Unit lost by Trigger

XeRo13g

New Member
Reaction score
3
I've done some testing but I cannot conclude to a result 100%. Maybe someone can help...

Code:
Event
Unit - A unit Sells a unit

Conditions
(Unit-type of (Sold unit)) Equal to UnitX

Actions

Do something for (Owner of (Sold unit)) ....
Wait 5 seconds
Do something else for (Owner of (Sold unit)) ....

In these 5 seconds delay:
-What happens if another player buys ANY other unit?
-What happens if another player buys a UnitX?

Does the already running trigger loses focus on the first (Owner of (Sold unit))?

Thanks in advance.
 

evilwolf

Member
Reaction score
11
Wait action is unstable if rum multiple times.
Use a countdown timer that will run and fire only for the owner of sold unit.
 

DioD

New Member
Reaction score
57
every event variable expect GetTriggerX is LOST after wait.

sold unit in your trigger will be lost after wait in ANY case (ever if you sell no other units), you must use global or local variables to save reference.
 

XeRo13g

New Member
Reaction score
3
Yet, for some unknown reason it still works. I surely don't feel safe using such trigger and I will need some way to stabilize it.

Edit.-
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
basically if you are not using variables just event responses and owner of unit, etc the trigger will run fine as long as the owner of the unit isnt changing, variables would not work with the wait function because they can be changed before the wait function ends... by a different trigger or the same one, but once the trigger is in the que if the owner of the unit does not change then the trigger should work

if you wish to use variables and still want to use a wait function, you need to use a pick every player/unit function like this:
pick every unit in playable map area matching condition: unit comparision - matching unit = saved variable then do every action for the picked unit, because then the unit is picked for the trigger already and does not change for that trigger while it is in the que...
 

XeRo13g

New Member
Reaction score
3
basically if you are not using variables just event responses and owner of unit, etc the trigger will run fine as long as the owner of the unit isnt changing.

So, if the same trigger runs multiple times for multiple users at the same time, the (Owner of (Sold unit)) will be kept for each one of the users for as long as the sold unit (of each player) isn't modified in any way?

-I'm not very comfortable using "queue", because even though I've read a fair share about it's use, it's mechanics and placement remain unclear to me and also caused a crash that kinda scared me.

-I could use a unit variable array to store the (Owner of (Sold unit)) for each player and re-use it over and over again. Though, I haven't seen that a lot in other people coding and even though Temp_Unit variable is not supposed to leak, I don't quite trust it.

Only if i could clear those things in my mind...Ohh well..
 

hopy

Active Member
Reaction score
64
So, if the same trigger runs multiple times for multiple users at the same time, the (Owner of (Sold unit)) will be kept for each one of the users for as long as the sold unit (of each player) isn't modified in any way?
The '(Owner of (Sold unit))' shouldn't cause problems because of multiple players using it, but more because the data stored in '(Owner of (Sold unit))' gets cleared afther the wait. So no, it wouldn't work.

-I could use a unit variable array to store the (Owner of (Sold unit)) for each player and re-use it over and over again. Though, I haven't seen that a lot in other people coding and even though Temp_Unit variable is not supposed to leak, I don't quite trust it.
If every player can only use this once, or once every 5 seconds, yes.
If yes, should I show you how?
 

XeRo13g

New Member
Reaction score
3
If every player can only use this once, or once every 5 seconds, yes.
If yes, should I show you how?

I didn't quite understand what do you mean by that and yes please show me!!

PS. After looking into it a bit more, I don't see how (Owner of (Sold unit) can be stored in something that will be reused and remain unchanged even if the trigger re-runs. Let alone creating 1 trigger for each player, which I'm sure is not optimal.

EDIT: spelling
 

tommerbob

Minecraft. :D
Reaction score
110
PS. After looking into it a bit more, I don't see how (Owner of (Sold unit) can be stored in something that will be reused and remain unchanged even if the trigger re-runs. Let alone creating 1 trigger for each player, which I'm sure is not optimal.

You use variables to keep track of specific data. So in your trigger above, you would change it to this:

Trigger:
  • Events
    • Unit - A unit sells a unit
    • Conditions
      • (sold unit) equal to [Your Unit]
    • Actions
      • Set UNIT = (sold unit)
      • Wait 5.00 seconds
      • Unit - Make UNIT jump around


You would need to add a condition check if you want this for only 1 player, or instead of using a variable you could add the (sold unit) to a unit group (like GFreak45 suggested), and then after the wait, do actions for every unit in that unit group and then remove the unit from the unit group. Example:

Trigger:
  • Events
    • Unit - A unit sells a unit
    • Conditions
      • (sold unit) equal to [Your Unit]
    • Actions
      • Unit group - Add (sold unit) to UNITS
      • Wait 5.00 seconds
      • Unit group - Pick every unit in UNITS and do Actions
        • Loop - Actions
          • Unit - Make (picked unit) jump around
          • Unit group - Remove (picked unit) from UNITS
 

XeRo13g

New Member
Reaction score
3
To my understanding that would work just fine if the event runs at the same time for all players.
If a second player trigger the event after x seconds though, the sequence of actions for each player should be different (since the first is x seconds ahead).

Am I missing something?
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top