WARNING - Specific unit event BUGGED !!!

Status
Not open for further replies.
Level 12
Joined
Jan 30, 2020
Messages
875
Hello there !

After days trying to figure out what I messed with my Lua functions when switching all my events to per unit events (before switching to OOP), I found out this very serious bug.

The specific unit selected (same issue with deselected) aka "EVENT_UNIT_SELECTED" does return the Owner of the Selected unit instead of the Selecting player, like all other UNIT_SELECTED events.

I tried a quick GUI trigger on a random test map :
  • Select Test
    • Events
      • Unit - Priestess of the Moon 0029 <gen> Is selected
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of (Triggering player))
And here is the result :

EVENT_UNIT_SELECTED_bug.png
 
Level 19
Joined
Jan 1, 2018
Messages
739
constant unitevent EVENT_UNIT_SELECTED = ConvertUnitEvent(57)
It's a unitevent, that's why triggering player simply returns the unit's owner.
Unfortunately, I don't know of a way get the player that did the selection, but technically this is not a bug.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Ok so what you mean is all unitevents return the onwning player of the unit.

Thsi means all selling events would share the same problem ?

So if i add an event for selling units to a neutral shop, the trigger player will always be the neutral player and not the player buying the units ???
 
Last edited:
Level 12
Joined
Jan 30, 2020
Messages
875
Ok than you guys, it seems I definitely got confused with what a unit event was.

I thought it was just an event like the others, but that was only triggered when the unit was concerned.

So in really this event really means that the specific unit is selected but without any way to differentiate the player.
This of course, renders the event useless for most cases where you need to know what players selects the unit (I can think of some situations where the selecting player does not matter, but only a very few cases).

In other words, we can't use this event if we want to add triggers as methods for units in an attempt to use unit-centered tables of properties and methods, or event OOP.

I have decided to go back to generic events for selections...

While I'm at it, I had the feeling that unit specific events were more efficient because the "filter" for the event was handled by the game internally. Is this a misconception ?


@IcemanBo : in the unit selling a unit context, I am doomed because there is no buying unit in my map but only buying players :'(

EDIT : although I realize that event won't be an issue in my map because every player has his own shop :)
But I guess this rules outs Neutral Player shops from this event.
 
Level 12
Joined
Jan 30, 2020
Messages
875
UPDATE

for the record, I have made most of my map events attached to units when related to a unit.
So far, all events I have tested as unit event return the proper expected unit or player, except :

EVENT_UNIT_SELECTED, EVENT_UNIT_DESELECTED and EVENT_UNIT_SUMMONED

As written in original post, the 2 first events DO NOT allow you to access the selecting player.
In the same way, Summoned event for a specific unit has a serious issue with GetSummonedUnit()

The getter returns a unit handle that is bugged : it is indeed a unit handle, but has no id and no name, cannot be removed or manipulated like other units.

I don't think this issue would come from my understanding of what a unit event is this time...
 
Status
Not open for further replies.
Top