I store my unit order in a variable with array size 31 (32 orders). So I then change the ownership of the unit to the player's ally. And I recall the variable to issue orders to the unit, so the order queue is not forgotten while changing owner.
But this seems to be not enough, since units still not execute their order. I'm quite sure that the order variable store also the player who ordered, and if the player has no control on the new unit, the unit will not execute the stored orders. I can say this because the order list works when changing to an ally on which I have unit control, while are forgotten when I switch to an ally on which I have no control, or enemy, or neutral.
I basically use this system to remember the rally point, but also on unit morphing order queue.
How can I make the unit to properly execute their orders when ownership is changed?
CODE:
UnitTrainChangeOwnerEventsUnit-AnyUnitcreatesaunitwithabilityBarracks-TrainorbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityFactory-Train(Factory)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityRoboticsFacility-Train(RoboticsFacility)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityLarva-MorphUnit(Larva->Basic)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityNexus-TrainMothershiporbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityGateway-Train(Gateway)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityWarpGate-Train(WarpGate)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityStargate-Train(Stargate)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityStarport-TrainorbehaviorNoGameLinkLocalVariablesOrderCount=0<Integer>Order=NoOrder<Order[31]>
Conditions
(Behavior that created unit) == None
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
((Unit type of (Created unit)) is Worker) == False
Then
Variable - Set Order Count = ((Count of orders on (Created unit)) - 1)
General - Pick each integer from 0 to Order Count, and do (Actions)
Actions
Variable - Set Order[(Pickedinteger)] = ((Created unit) order at index (Picked integer))
Unit - Change ownership of (Created unit) to player 2 and Change Color
General - Pick each integer from 0 to Order Count, and do (Actions)
Actions
Unit - Order (Created unit) to Order[(Pickedinteger)] (After Existing Orders)
Else
Finally solved, basically recreating the order via Triggers; I'll put here the Trigger as public resource:
UnitTrainChangeOwnerEventsUnit-AnyUnitcreatesaunitwithabilityBarracks-TrainorbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityFactory-Train(Factory)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityRoboticsFacility-Train(RoboticsFacility)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityLarva-MorphUnit(Larva->Basic)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityNexus-TrainMothershiporbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityNexusTrainMothershipCore(Unnamed)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityGateway-Train(Gateway)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityWarpGate-Train(WarpGate)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityStargate-Train(Stargate)orbehaviorNoGameLinkUnit-AnyUnitcreatesaunitwithabilityStarport-TrainorbehaviorNoGameLinkLocalVariablesOrderCount=0<Integer>Order=NoOrder<Order[31]>
Conditions
(Behavior that created unit) == None
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
((Unit type of (Created unit)) is Worker) == False
Then
Variable - Set Order Count = ((Count of orders on (Created unit)) - 1)
General - Pick each integer from 0 to Order Count, and do (Actions)
Actions
General - Switch (Actions) depending on (Target type for ((Created unit) order at index (Picked integer)))
Cases
General - If (None)
Actions
Variable - Set Order[(Pickedinteger)] = ((Ability command for ((Created unit) order at index (Picked integer))))
General - If (Item)
Actions
Variable - Set Order[(Pickedinteger)] = ((Ability command for ((Created unit) order at index (Picked integer))) targeting (Target item for ((Created unit) order at index (Picked integer))))
General - If (Point)
Actions
Variable - Set Order[(Pickedinteger)] = ((Ability command for ((Created unit) order at index (Picked integer))) targeting (Target point for ((Created unit) order at index (Picked integer))))
General - If (Unit)
Actions
Variable - Set Order[(Pickedinteger)] = ((Ability command for ((Created unit) order at index (Picked integer))) targeting (Target unit for ((Created unit) order at index (Picked integer))))
Default
Unit - Change ownership of (Created unit) to player 2 and Change Color
General - Pick each integer from 0 to Order Count, and do (Actions)
Actions
Unit - Order (Created unit) to Order[(Pickedinteger)] (After Existing Orders)
Else
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I store my unit order in a variable with array size 31 (32 orders). So I then change the ownership of the unit to the player's ally. And I recall the variable to issue orders to the unit, so the order queue is not forgotten while changing owner. But this seems to be not enough, since units still not execute their order. I'm quite sure that the order variable store also the player who ordered, and if the player has no control on the new unit, the unit will not execute the stored orders. I can say this because the order list works when changing to an ally on which I have unit control, while are forgotten when I switch to an ally on which I have no control, or enemy, or neutral.
I basically use this system to remember the rally point, but also on unit morphing order queue.
How can I make the unit to properly execute their orders when ownership is changed?
CODE:
Also, it can help specifying the ability in the Event, rather on a Triggering Ability Condition to stress CPU less, or it's the same?
@alfx01: Go
Are you sure that int he data editor "Abort on alliance change" is unchecked, because if it isn't, thats why it's not working.
Yes but not every ability has that flag, Rally and Move don't have it, and that's fundamental.
Finally solved, basically recreating the order via Triggers; I'll put here the Trigger as public resource: