Add new trigger CALL_VTOL_RETARGET that is fired off whenever a VTOL detects that its
designated target no longer exists. This allows an AI script to give it a new target while in-flight instead of waiting for it to return to base, saving precious time. git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@10841 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
6c633359f1
commit
59b5478d83
13
src/order.c
13
src/order.c
|
@ -767,14 +767,21 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
{
|
||||
if (!orderDroidList(psDroid))
|
||||
{
|
||||
psDroid->order = DORDER_NONE;
|
||||
psDroid->order = DORDER_NONE;
|
||||
moveToRearm(psDroid);
|
||||
if (!vtolEmpty(psDroid))
|
||||
{
|
||||
// VTOL droid can do more work, let scripts handle it
|
||||
psScrVtolRetarget = psDroid;
|
||||
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_VTOL_RETARGET);
|
||||
psScrVtolRetarget = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
psDroid->order = DORDER_NONE;
|
||||
actionDroid(psDroid, DACTION_NONE);
|
||||
psDroid->order = DORDER_NONE;
|
||||
actionDroid(psDroid, DACTION_NONE);
|
||||
}
|
||||
}
|
||||
else if ( ((psDroid->action == DACTION_MOVE) ||
|
||||
|
|
|
@ -57,6 +57,8 @@ STRUCTURE *psScrCBNewDroidFact; // id of factory that built it.
|
|||
// the attacker and target for a CALL_ATTACKED
|
||||
BASE_OBJECT *psScrCBAttacker, *psScrCBTarget;
|
||||
|
||||
// vtol target
|
||||
DROID *psScrVtolRetarget = NULL;
|
||||
|
||||
// alliance details
|
||||
UDWORD CBallFrom,CBallTo;
|
||||
|
@ -184,6 +186,35 @@ BOOL scrCBStructAttacked(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
BOOL scrCBVTOLRetarget(void)
|
||||
{
|
||||
SDWORD player;
|
||||
DROID **ppsDroid;
|
||||
|
||||
if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ASSERT_OR_RETURN(false, player < MAX_PLAYERS && player >= 0, "Invalid player %d", player);
|
||||
|
||||
if (player == psScrVtolRetarget->player)
|
||||
{
|
||||
*ppsDroid = psScrVtolRetarget;
|
||||
scrFunctionResult.v.bval = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppsDroid = NULL;
|
||||
scrFunctionResult.v.bval = false;
|
||||
}
|
||||
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Deal with a CALL_DROID_ATTACKED
|
||||
BOOL scrCBDroidAttacked(void)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ extern DROID *psScrCBNewDroid;
|
|||
extern STRUCTURE *psScrCBNewDroidFact;
|
||||
extern DROID *psScrCBOrderDroid;
|
||||
extern SDWORD psScrCBOrder;
|
||||
extern DROID *psScrVtolRetarget;
|
||||
|
||||
//Script key event callback
|
||||
extern SDWORD cbPressedMetaKey;
|
||||
|
@ -138,6 +139,9 @@ extern BOOL scrCBResCompleted(void);
|
|||
/* when a player leaves the game*/
|
||||
extern BOOL scrCBPlayerLeft(void);
|
||||
|
||||
/* when a VTOL runs out of things to do while mid-air */
|
||||
extern BOOL scrCBVTOLRetarget(void);
|
||||
|
||||
// alliance offered.
|
||||
extern BOOL scrCBAllianceOffer(void);
|
||||
extern UDWORD CBallFrom,CBallTo;
|
||||
|
|
|
@ -2257,8 +2257,11 @@ CALLBACK_SYMBOL asCallbackTable[] =
|
|||
{ "CALL_DROID_REACH_LOCATION",(TRIGGER_TYPE)CALL_DROID_REACH_LOCATION,
|
||||
scrCBDorderReachedLocation,3, { VAL_INT, VAL_REF|(INTERP_TYPE)ST_DROID, VAL_REF | VAL_INT } },
|
||||
|
||||
{ "CALL_KEY_PRESSED", (TRIGGER_TYPE)CALL_KEY_PRESSED,
|
||||
scrCBProcessKeyPress,2, { VAL_REF | VAL_INT, VAL_REF| VAL_INT} },
|
||||
{ "CALL_KEY_PRESSED", (TRIGGER_TYPE)CALL_KEY_PRESSED,
|
||||
scrCBProcessKeyPress, 2, { VAL_REF | VAL_INT, VAL_REF| VAL_INT} },
|
||||
|
||||
{ "CALL_VTOL_RETARGET", (TRIGGER_TYPE)CALL_VTOL_RETARGET,
|
||||
scrCBVTOLRetarget, 2, { VAL_INT, VAL_REF| (INTERP_TYPE)ST_DROID } },
|
||||
|
||||
/* This entry marks the end of the callback list */
|
||||
{ "CALLBACK LIST END", 0, NULL, 0, {VAL_VOID} }
|
||||
|
|
|
@ -102,6 +102,7 @@ typedef enum _scr_callback_types
|
|||
CALL_DORDER_STOP, // Fired when droid is forced to stop via user interface
|
||||
CALL_DROID_REACH_LOCATION, // Fired when droid reached the destination and stopped on its own
|
||||
CALL_KEY_PRESSED, // Allows to process key presses, mainly for debug purposes
|
||||
CALL_VTOL_RETARGET, // VTOL is out of targets
|
||||
} SCR_CALLBACK_TYPES;
|
||||
|
||||
// The table of user types for the compiler
|
||||
|
|
Loading…
Reference in New Issue