I'm trying to make a dialogue window that pops up when a unit is loaded into another unit with specific information about the cargo unit. I'm doing this through a trigger that fires when a unit uses the load command, then sets the loaded unit in a variable and goes through a switch statement with cases for each unit type to decide what to show.
I'm having trouble getting around a particular bug, though: despite the trigger firing on a "unit uses ability (Load) at the Generic6 - Complete stage" even the game refuses to acknowledge that the loading unit has a cargo unit, and has instead decided to gurgle Array Index Out Of Bounds errors at me. Here's the trigger in question:
EventsUnit-AnyUnitusesLoad(CommandCenter)atGeneric6-Completestage(Ignoresharedabilities)LocalVariablesp=0<Integer>cargounit=NoUnit<Unit>ConditionsActionsUI-Display"[show window] running..."for(Allplayers)toSubtitleareaVariable-Setp=((Ownerof(Triggeringunit))-1)Variable-Setcargounit=(Cargounitin(Triggeringunit)atslot1)General-Switch(Actions)dependingon(Unittypeofcargounit)CasesGeneral-If(Infantry)ActionsUI-Display"[show window] in Infantry switch case..."for(Allplayers)toSubtitleareaDialog-ShowunitCarriedDialog[p]for(Playergroup((Ownerof(Triggeringunit))))
This error leads me to believe the trigger doesn't believe the unit has cargo at the moment, as the parameter requirements for the UnitCargo call are impossible to satisfy. I don't really know how to get around this! I've tried changing the line to get the unit from a conversion from unit to unit group of from the Triggering Unit's Cargo unit group, which doesn't throw errors but also doesn't work as the found unit only triggers the default switch block. Is there any other way to deal with this?
However I've been watching the variable in the debug window and it never changes in value from null. This leads me to believe that the trigger executes after the ability finishes but before the unit is actually placed into cargo. I've tried changing the event ability stage around but I get the same results or worse with other options.
Wow, cool! The wait thing worked. I'd tried something similar earlier but had no results, which probably means I screwed it up somewhere that time. Oh well!
Thanks for the help!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm trying to make a dialogue window that pops up when a unit is loaded into another unit with specific information about the cargo unit. I'm doing this through a trigger that fires when a unit uses the load command, then sets the loaded unit in a variable and goes through a switch statement with cases for each unit type to decide what to show.
I'm having trouble getting around a particular bug, though: despite the trigger firing on a "unit uses ability (Load) at the Generic6 - Complete stage" even the game refuses to acknowledge that the loading unit has a cargo unit, and has instead decided to gurgle Array Index Out Of Bounds errors at me. Here's the trigger in question:
the line that's giving me the problems is
it returns the following error whenever the trigger fires:
This error leads me to believe the trigger doesn't believe the unit has cargo at the moment, as the parameter requirements for the UnitCargo call are impossible to satisfy. I don't really know how to get around this! I've tried changing the line to get the unit from a conversion from unit to unit group of from the Triggering Unit's Cargo unit group, which doesn't throw errors but also doesn't work as the found unit only triggers the default switch block. Is there any other way to deal with this?
I've done a bit more testing and I've managed to avoid getting an error by replacing the problem line with this line:
However I've been watching the variable in the debug window and it never changes in value from null. This leads me to believe that the trigger executes after the ability finishes but before the unit is actually placed into cargo. I've tried changing the event ability stage around but I get the same results or worse with other options.
try some wait 0-0.1 then
also isn't cargo unit the target of Load ability? even when it comes from the actual unit
Wow, cool! The wait thing worked. I'd tried something similar earlier but had no results, which probably means I screwed it up somewhere that time. Oh well!
Thanks for the help!