2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
/*
|
|
|
|
* ScriptCB.c
|
|
|
|
*
|
|
|
|
* functions to deal with parameterised script callback triggers.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-11-06 06:40:07 -08:00
|
|
|
#include <string.h>
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/framework/frame.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "objects.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/script/script.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "scripttabs.h"
|
|
|
|
#include "scriptcb.h"
|
|
|
|
#include "projectile.h"
|
|
|
|
#include "hci.h"
|
|
|
|
#include "group.h"
|
|
|
|
#include "transporter.h"
|
|
|
|
#include "mission.h"
|
|
|
|
#include "research.h"
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
static INTERP_VAL scrFunctionResult; //function return value to be pushed to stack
|
2006-11-16 06:30:29 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
// unit taken over..
|
|
|
|
DROID *psScrCBDroidTaken;
|
|
|
|
|
2006-09-30 16:09:12 -07:00
|
|
|
DROID *psScrCBOrderDroid = NULL; //Callback droid that have received an order
|
|
|
|
SDWORD psScrCBOrder = DORDER_NONE; //Order of the droid
|
|
|
|
|
2006-11-01 05:56:23 -08:00
|
|
|
//Script key event callback
|
|
|
|
SDWORD cbPressedMetaKey;
|
|
|
|
SDWORD cbPressedKey;
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
// The pointer to the droid that was just built for a CALL_NEWDROID
|
|
|
|
DROID *psScrCBNewDroid;
|
|
|
|
STRUCTURE *psScrCBNewDroidFact; // id of factory that built it.
|
|
|
|
|
|
|
|
// the attacker and target for a CALL_ATTACKED
|
|
|
|
BASE_OBJECT *psScrCBAttacker, *psScrCBTarget;
|
|
|
|
|
|
|
|
|
|
|
|
// alliance details
|
|
|
|
UDWORD CBallFrom,CBallTo;
|
|
|
|
|
2008-03-24 11:42:49 -07:00
|
|
|
// player number that left the game
|
|
|
|
UDWORD CBPlayerLeft;
|
|
|
|
|
2006-08-20 07:48:14 -07:00
|
|
|
//console callback stuff
|
|
|
|
//---------------------------
|
|
|
|
SDWORD ConsolePlayer = -2;
|
|
|
|
SDWORD MultiMsgPlayerTo = -2;
|
|
|
|
SDWORD beaconX = -1, beaconY = -1;
|
|
|
|
SDWORD MultiMsgPlayerFrom = -2;
|
|
|
|
char ConsoleMsg[MAXSTRLEN]="ERROR!!!\0"; //Last console message
|
|
|
|
char MultiplayMsg[MAXSTRLEN]; //Last multiplayer message
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
BOOL scrCBDroidTaken(void)
|
|
|
|
{
|
|
|
|
DROID **ppsDroid;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(1, VAL_REF|ST_DROID, &ppsDroid))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBDroidTaken == NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsDroid = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsDroid = psScrCBDroidTaken;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Deal with a CALL_NEWDROID
|
|
|
|
BOOL scrCBNewDroid(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
DROID **ppsDroid;
|
|
|
|
STRUCTURE **ppsStructure;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid, VAL_REF|ST_STRUCTURE, &ppsStructure))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBNewDroid == NULL)
|
|
|
|
{
|
|
|
|
// eh? got called without setting the new droid
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBNewUnit: no unit has been set" );
|
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsDroid = NULL;
|
|
|
|
*ppsStructure = NULL;
|
|
|
|
}
|
|
|
|
else if (psScrCBNewDroid->player == (UDWORD)player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsDroid = psScrCBNewDroid;
|
|
|
|
*ppsStructure = psScrCBNewDroidFact;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Deal with a CALL_STRUCT_ATTACKED
|
|
|
|
BOOL scrCBStructAttacked(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
STRUCTURE **ppsTarget;
|
|
|
|
BASE_OBJECT **ppsAttacker;//, **ppsTarget;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(3, VAL_INT, &player,
|
|
|
|
VAL_REF|ST_STRUCTURE, &ppsTarget,
|
|
|
|
VAL_REF|ST_BASEOBJECT, &ppsAttacker))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psLastStructHit == NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBStructAttacked: no target has been set" );
|
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = NULL;
|
|
|
|
*ppsTarget = NULL;
|
|
|
|
}
|
|
|
|
else if (psLastStructHit->player == (UDWORD)player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = g_pProjLastAttacker;
|
|
|
|
*ppsTarget = psLastStructHit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = NULL;
|
|
|
|
*ppsTarget = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Deal with a CALL_DROID_ATTACKED
|
|
|
|
BOOL scrCBDroidAttacked(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
DROID **ppsTarget;
|
|
|
|
BASE_OBJECT **ppsAttacker;//, **ppsTarget;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(3, VAL_INT, &player,
|
|
|
|
VAL_REF|ST_DROID, &ppsTarget,
|
|
|
|
VAL_REF|ST_BASEOBJECT, &ppsAttacker))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psLastDroidHit == NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBUnitAttacked: no target has been set" );
|
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = NULL;
|
|
|
|
*ppsTarget = NULL;
|
|
|
|
}
|
|
|
|
else if (psLastDroidHit->player == (UDWORD)player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = g_pProjLastAttacker;
|
|
|
|
*ppsTarget = psLastDroidHit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = NULL;
|
|
|
|
*ppsTarget = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Deal with a CALL_ATTACKED
|
|
|
|
BOOL scrCBAttacked(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
BASE_OBJECT **ppsTarget;
|
|
|
|
BASE_OBJECT **ppsAttacker;//, **ppsTarget;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(3, VAL_INT, &player,
|
|
|
|
VAL_REF|ST_BASEOBJECT, &ppsTarget,
|
|
|
|
VAL_REF|ST_BASEOBJECT, &ppsAttacker))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBTarget == NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBAttacked: no target has been set" );
|
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = NULL;
|
|
|
|
*ppsTarget = NULL;
|
|
|
|
}
|
|
|
|
else if (psScrCBTarget->player == (UDWORD)player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = g_pProjLastAttacker;
|
|
|
|
*ppsTarget = psScrCBTarget;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsAttacker = NULL;
|
|
|
|
*ppsTarget = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// The button id
|
|
|
|
|
|
|
|
// deal with CALL_BUTTON_PRESSED
|
|
|
|
BOOL scrCBButtonPressed(void)
|
|
|
|
{
|
|
|
|
UDWORD button;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(1, VAL_INT, &button))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (button == intLastWidget)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// the Droid that was selected for a CALL_DROID_SELECTED
|
|
|
|
DROID *psCBSelectedDroid;
|
|
|
|
|
|
|
|
// deal with CALL_DROID_SELECTED
|
|
|
|
BOOL scrCBDroidSelected(void)
|
|
|
|
{
|
|
|
|
DROID **ppsDroid;
|
|
|
|
|
|
|
|
if (!stackPopParams(1, VAL_REF|ST_DROID, &ppsDroid))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2007-04-03 06:20:41 -07:00
|
|
|
ASSERT( psCBSelectedDroid != NULL,
|
2006-08-23 05:58:48 -07:00
|
|
|
"scrSCUnitSelected: invalid unit pointer" );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
*ppsDroid = psCBSelectedDroid;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// the object that was last killed for a CALL_OBJ_DESTROYED
|
|
|
|
BASE_OBJECT *psCBObjDestroyed;
|
|
|
|
|
|
|
|
// deal with a CALL_OBJ_DESTROYED
|
|
|
|
BOOL scrCBObjDestroyed(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
BASE_OBJECT **ppsObj;
|
|
|
|
BOOL retval;
|
|
|
|
|
|
|
|
if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_BASEOBJECT, &ppsObj))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( (psCBObjDestroyed != NULL) &&
|
|
|
|
(psCBObjDestroyed->player == (UDWORD)player) &&
|
|
|
|
(psCBObjDestroyed->type != OBJ_FEATURE) )
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = psCBObjDestroyed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deal with a CALL_STRUCT_DESTROYED
|
|
|
|
BOOL scrCBStructDestroyed(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
BASE_OBJECT **ppsObj;
|
|
|
|
BOOL retval;
|
|
|
|
|
|
|
|
if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_STRUCTURE, &ppsObj))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( (psCBObjDestroyed != NULL) &&
|
|
|
|
(psCBObjDestroyed->player == (UDWORD)player) &&
|
|
|
|
(psCBObjDestroyed->type == OBJ_STRUCTURE) )
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = psCBObjDestroyed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deal with a CALL_DROID_DESTROYED
|
|
|
|
BOOL scrCBDroidDestroyed(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
BASE_OBJECT **ppsObj;
|
|
|
|
BOOL retval;
|
|
|
|
|
|
|
|
if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_DROID, &ppsObj))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( (psCBObjDestroyed != NULL) &&
|
|
|
|
(psCBObjDestroyed->player == (UDWORD)player) &&
|
|
|
|
(psCBObjDestroyed->type == OBJ_DROID) )
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = psCBObjDestroyed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deal with a CALL_FEATURE_DESTROYED
|
|
|
|
BOOL scrCBFeatureDestroyed(void)
|
|
|
|
{
|
|
|
|
BASE_OBJECT **ppsObj;
|
|
|
|
BOOL retval;
|
|
|
|
|
|
|
|
if (!stackPopParams(1, VAL_REF|ST_FEATURE, &ppsObj))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psCBObjDestroyed != NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = psCBObjDestroyed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// the last object to be seen for a CALL_OBJ_SEEN
|
|
|
|
BASE_OBJECT *psScrCBObjSeen;
|
|
|
|
// the object that saw psScrCBObjSeen for a CALL_OBJ_SEEN
|
|
|
|
BASE_OBJECT *psScrCBObjViewer;
|
|
|
|
|
|
|
|
// deal with all the object seen functions
|
2006-09-19 18:12:13 -07:00
|
|
|
static BOOL scrCBObjectSeen(SDWORD callback)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
BASE_OBJECT **ppsObj;
|
|
|
|
BASE_OBJECT **ppsViewer;
|
|
|
|
SDWORD player;
|
|
|
|
BOOL retval;
|
|
|
|
|
|
|
|
if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_BASEOBJECT, &ppsObj, VAL_REF|ST_BASEOBJECT, &ppsViewer))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBObjSeen == NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false,"scrCBObjectSeen: no object set" );
|
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppsObj = NULL;
|
|
|
|
if (((psScrCBObjViewer != NULL) &&
|
|
|
|
(psScrCBObjViewer->player != player)) ||
|
|
|
|
!psScrCBObjSeen->visible[player])
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2006-05-27 09:37:17 -07:00
|
|
|
else if ((callback == CALL_DROID_SEEN) &&
|
2007-06-28 10:47:08 -07:00
|
|
|
(psScrCBObjSeen->type != OBJ_DROID))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2006-05-27 09:37:17 -07:00
|
|
|
else if ((callback == CALL_STRUCT_SEEN) &&
|
2007-06-28 10:47:08 -07:00
|
|
|
(psScrCBObjSeen->type != OBJ_STRUCTURE))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2006-05-27 09:37:17 -07:00
|
|
|
else if ((callback == CALL_FEATURE_SEEN) &&
|
2007-06-28 10:47:08 -07:00
|
|
|
(psScrCBObjSeen->type != OBJ_FEATURE))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsObj = psScrCBObjSeen;
|
|
|
|
*ppsViewer = psScrCBObjViewer;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// deal with a CALL_OBJ_SEEN
|
|
|
|
BOOL scrCBObjSeen(void)
|
|
|
|
{
|
|
|
|
return scrCBObjectSeen(CALL_OBJ_SEEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
// deal with a CALL_DROID_SEEN
|
|
|
|
BOOL scrCBDroidSeen(void)
|
|
|
|
{
|
|
|
|
return scrCBObjectSeen(CALL_DROID_SEEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
// deal with a CALL_STRUCT_SEEN
|
|
|
|
BOOL scrCBStructSeen(void)
|
|
|
|
{
|
|
|
|
return scrCBObjectSeen(CALL_STRUCT_SEEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
// deal with a CALL_FEATURE_SEEN
|
|
|
|
BOOL scrCBFeatureSeen(void)
|
|
|
|
{
|
|
|
|
return scrCBObjectSeen(CALL_FEATURE_SEEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL scrCBTransporterOffMap( void )
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
BOOL retval;
|
|
|
|
DROID *psTransporter;
|
|
|
|
|
|
|
|
if (!stackPopParams(1, VAL_INT, &player) )
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
psTransporter = transporterGetScriptCurrent();
|
|
|
|
|
|
|
|
if ( (psTransporter != NULL) &&
|
|
|
|
(psTransporter->player == (UDWORD)player) )
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL scrCBTransporterLanded( void )
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
DROID_GROUP *psGroup;
|
|
|
|
DROID *psTransporter, *psDroid, *psNext;
|
|
|
|
BOOL retval;
|
|
|
|
|
|
|
|
if (!stackPopParams(2, ST_GROUP, &psGroup, VAL_INT, &player))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
psTransporter = transporterGetScriptCurrent();
|
|
|
|
|
|
|
|
if ( (psTransporter == NULL) ||
|
|
|
|
(psTransporter->player != (UDWORD)player) )
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if not selectedPlayer unload droids */
|
|
|
|
if ( (UDWORD)player != selectedPlayer )
|
|
|
|
{
|
|
|
|
/* transfer droids from transporter group to current group */
|
|
|
|
for(psDroid=psTransporter->psGroup->psList; psDroid; psDroid=psNext)
|
|
|
|
{
|
|
|
|
psNext = psDroid->psGrpNext;
|
|
|
|
if ( psDroid != psTransporter )
|
|
|
|
{
|
|
|
|
grpLeave( psTransporter->psGroup, psDroid );
|
|
|
|
grpJoin(psGroup, psDroid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2006-08-20 07:48:14 -07:00
|
|
|
BOOL scrCBTransporterLandedB( void )
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
DROID_GROUP *psGroup;
|
|
|
|
DROID *psTransporter, *psDroid, *psNext;
|
|
|
|
BOOL retval;
|
|
|
|
DROID **ppsTransp;
|
|
|
|
|
|
|
|
if (!stackPopParams(3, ST_GROUP, &psGroup, VAL_INT, &player,
|
|
|
|
VAL_REF|ST_DROID, &ppsTransp))
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBTransporterLandedB(): stack failed");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
psTransporter = transporterGetScriptCurrent();
|
|
|
|
|
|
|
|
if ( (psTransporter == NULL) ||
|
|
|
|
(psTransporter->player != (UDWORD)player) )
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppsTransp = psTransporter; //return landed transporter
|
|
|
|
|
|
|
|
/* if not selectedPlayer unload droids */
|
|
|
|
//if ( (UDWORD)player != selectedPlayer )
|
|
|
|
//{
|
|
|
|
/* transfer droids from transporter group to current group */
|
|
|
|
for(psDroid=psTransporter->psGroup->psList; psDroid; psDroid=psNext)
|
|
|
|
{
|
|
|
|
psNext = psDroid->psGrpNext;
|
|
|
|
if ( psDroid != psTransporter )
|
|
|
|
{
|
|
|
|
grpLeave( psTransporter->psGroup, psDroid );
|
|
|
|
grpJoin(psGroup, psDroid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBTransporterLandedB: push landed");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// tell the scripts when a cluster is no longer valid
|
|
|
|
SDWORD scrCBEmptyClusterID;
|
|
|
|
BOOL scrCBClusterEmpty( void )
|
|
|
|
{
|
|
|
|
SDWORD *pClusterID;
|
|
|
|
|
|
|
|
if (!stackPopParams(1, VAL_REF|VAL_INT, &pClusterID))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
*pClusterID = scrCBEmptyClusterID;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// note when a vtol has finished returning to base - used to vanish
|
|
|
|
// vtols when they are attacking from off map
|
|
|
|
DROID *psScrCBVtolOffMap;
|
|
|
|
BOOL scrCBVtolOffMap(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
DROID **ppsVtol;
|
|
|
|
BOOL retval;
|
|
|
|
|
|
|
|
if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_DROID, &ppsVtol))
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBVtolOffMap == NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBVtolAtBase: NULL vtol pointer" );
|
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = false;
|
2007-06-28 10:47:08 -07:00
|
|
|
if (psScrCBVtolOffMap->player == player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retval = true;
|
2007-06-28 10:47:08 -07:00
|
|
|
*ppsVtol = psScrCBVtolOffMap;
|
|
|
|
}
|
|
|
|
psScrCBVtolOffMap = NULL;
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retval;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*called when selectedPlayer completes some research*/
|
|
|
|
BOOL scrCBResCompleted(void)
|
|
|
|
{
|
|
|
|
RESEARCH **ppsResearch;
|
2007-09-29 08:04:25 -07:00
|
|
|
STRUCTURE **ppsResFac;
|
2007-06-28 10:47:08 -07:00
|
|
|
BOOL retVal;
|
2007-09-29 08:04:25 -07:00
|
|
|
SDWORD resFacOwner;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-09-29 08:04:25 -07:00
|
|
|
if (!stackPopParams(3, VAL_REF|ST_RESEARCH, &ppsResearch,
|
|
|
|
VAL_REF|ST_STRUCTURE, &ppsResFac ,VAL_INT, &resFacOwner))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
retVal = false;
|
2007-09-29 08:04:25 -07:00
|
|
|
*ppsResearch = NULL;
|
|
|
|
*ppsResFac = NULL;
|
|
|
|
|
|
|
|
if(resFacOwner == -1 || resFacOwner == CBResFacilityOwner)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-09-29 08:04:25 -07:00
|
|
|
if (psCBLastResearch != NULL)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
retVal = true;
|
2007-09-29 08:04:25 -07:00
|
|
|
*ppsResearch = psCBLastResearch;
|
|
|
|
*ppsResFac = psCBLastResStructure;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBResCompleted: no research has been set" );
|
2007-09-29 08:04:25 -07:00
|
|
|
}
|
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = retVal;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* when a humna player leaves a game*/
|
|
|
|
BOOL scrCBPlayerLeft(void)
|
|
|
|
{
|
2008-03-24 11:42:49 -07:00
|
|
|
SDWORD *player;
|
2008-03-24 11:50:48 -07:00
|
|
|
if (!stackPopParams(1, VAL_REF | VAL_INT, &player) )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 11:42:49 -07:00
|
|
|
*player = CBallFrom;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// alliance has been offered.
|
|
|
|
BOOL scrCBAllianceOffer(void)
|
|
|
|
{
|
|
|
|
SDWORD *from,*to;
|
2006-05-27 09:37:17 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(2, VAL_REF | VAL_INT, &from, VAL_REF | VAL_INT,&to) )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
*from = CBallFrom;
|
|
|
|
*to = CBallTo;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2006-08-20 07:48:14 -07:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------
|
|
|
|
/* New callbacks */
|
|
|
|
|
|
|
|
|
|
|
|
//console callback
|
|
|
|
//---------------------------
|
|
|
|
BOOL scrCallConsole(void)
|
|
|
|
{
|
|
|
|
SDWORD *player;
|
2006-11-03 13:35:50 -08:00
|
|
|
char **ConsoleText = NULL;
|
2006-08-20 07:48:14 -07:00
|
|
|
|
2008-03-29 06:27:54 -07:00
|
|
|
if (!stackPopParams(2, VAL_REF | VAL_INT, &player, VAL_REF | VAL_STRING, &ConsoleText) )
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallConsole(): stack failed");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ConsoleText == NULL)
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallConsole(): passed string was not initialized");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(*ConsoleText,ConsoleMsg);
|
|
|
|
|
|
|
|
*player = ConsolePlayer;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallConsole(): stackPushResult failed");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//multiplayer beacon
|
|
|
|
//---------------------------
|
|
|
|
BOOL scrCallBeacon(void)
|
|
|
|
{
|
|
|
|
SDWORD *playerFrom, playerTo;
|
2006-11-03 13:35:50 -08:00
|
|
|
char **BeaconText = NULL;
|
2006-08-20 07:48:14 -07:00
|
|
|
SDWORD *locX,*locY;
|
|
|
|
|
|
|
|
if (!stackPopParams(5, VAL_INT, &playerTo, VAL_REF | VAL_INT, &playerFrom,
|
|
|
|
VAL_REF | VAL_INT, &locX, VAL_REF | VAL_INT, &locY,
|
2008-03-29 06:27:54 -07:00
|
|
|
VAL_REF | VAL_STRING, &BeaconText))
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
2006-08-26 08:50:47 -07:00
|
|
|
debug(LOG_ERROR, "scrCallBeacon() - failed to pop parameters.");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-28 09:47:43 -07:00
|
|
|
debug(LOG_SCRIPT, "scrCallBeacon: to: %d (%d), text: %s ",
|
|
|
|
playerTo, MultiMsgPlayerTo, *BeaconText);
|
|
|
|
|
2006-08-20 07:48:14 -07:00
|
|
|
if(*BeaconText == NULL)
|
|
|
|
{
|
2006-08-26 08:50:47 -07:00
|
|
|
debug(LOG_ERROR, "scrCallBeacon(): passed string was not initialized");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(MultiMsgPlayerTo >= 0 && MultiMsgPlayerFrom >= 0 && MultiMsgPlayerTo < MAX_PLAYERS && MultiMsgPlayerFrom < MAX_PLAYERS)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(MultiMsgPlayerTo == playerTo)
|
|
|
|
{
|
|
|
|
strcpy(*BeaconText,MultiplayMsg);
|
2008-03-29 06:27:54 -07:00
|
|
|
|
2006-08-20 07:48:14 -07:00
|
|
|
*playerFrom = MultiMsgPlayerFrom;
|
|
|
|
*locX = beaconX;
|
|
|
|
*locY = beaconY;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult)) //triggered
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
2006-11-16 06:30:29 -08:00
|
|
|
debug(LOG_ERROR, "scrCallBeacon - failed to push");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-26 08:50:47 -07:00
|
|
|
debug(LOG_ERROR, "scrCallBeacon() - player indexes failed: %d - %d", MultiMsgPlayerFrom, MultiMsgPlayerTo);
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = false;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult)) //not triggered
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//return "not triggered"
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = false;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
2008-03-29 06:27:54 -07:00
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//multiplayer message callback
|
|
|
|
//----------------------------
|
|
|
|
BOOL scrCallMultiMsg(void)
|
|
|
|
{
|
|
|
|
SDWORD *player, playerTo;
|
2006-11-03 13:35:50 -08:00
|
|
|
char **ConsoleText = NULL;
|
2006-08-20 07:48:14 -07:00
|
|
|
|
2008-03-29 06:27:54 -07:00
|
|
|
if (!stackPopParams(3, VAL_INT, &playerTo, VAL_REF | VAL_INT, &player, VAL_REF | VAL_STRING, &ConsoleText) )
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallMultiMsg() failed to pop parameters.");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ConsoleText == NULL)
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallMultiMsg(): passed string was not initialized");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(MultiMsgPlayerTo >= 0 && MultiMsgPlayerFrom >= 0 && MultiMsgPlayerTo < MAX_PLAYERS && MultiMsgPlayerFrom < MAX_PLAYERS)
|
|
|
|
{
|
|
|
|
if(MultiMsgPlayerTo == playerTo)
|
|
|
|
{
|
|
|
|
strcpy(*ConsoleText,MultiplayMsg);
|
2008-03-29 06:27:54 -07:00
|
|
|
|
2006-08-20 07:48:14 -07:00
|
|
|
*player = MultiMsgPlayerFrom;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult)) //triggered
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallMultiMsg(): stackPushResult failed");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallMultiMsg() - player indexes failed: %d - %d", MultiMsgPlayerFrom, MultiMsgPlayerTo);
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = false;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult)) //not triggered
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//return "not triggered"
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = false;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCallMultiMsg: stackPushResult failed");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
2008-03-29 06:27:54 -07:00
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
STRUCTURE *psScrCBNewStruct = NULL; //for scrCBStructBuilt callback
|
|
|
|
DROID *psScrCBNewStructTruck = NULL;
|
|
|
|
//structure built callback
|
|
|
|
//------------------------------
|
|
|
|
BOOL scrCBStructBuilt(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
STRUCTURE **ppsStructure;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2006-08-20 07:48:14 -07:00
|
|
|
DROID **ppsDroid;
|
|
|
|
|
2008-03-29 06:27:54 -07:00
|
|
|
if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid, VAL_REF|ST_STRUCTURE, &ppsStructure) )
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBStructBuilt() failed to pop parameters.");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBNewStruct == NULL)
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBStructBuilt: no structure has been set");
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBStructBuilt: no structure has been set" );
|
|
|
|
triggered = false;
|
2006-08-20 07:48:14 -07:00
|
|
|
*ppsStructure = NULL;
|
|
|
|
*ppsDroid = NULL;
|
|
|
|
}
|
|
|
|
else if(psScrCBNewStructTruck == NULL)
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBStructBuilt: no builder has been set");
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBStructBuilt: no builder has been set" );
|
|
|
|
triggered = false;
|
2006-08-20 07:48:14 -07:00
|
|
|
*ppsStructure = NULL;
|
|
|
|
*ppsDroid = NULL;
|
|
|
|
}
|
|
|
|
else if (psScrCBNewStruct->player == (UDWORD)player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2006-08-20 07:48:14 -07:00
|
|
|
*ppsStructure = psScrCBNewStruct; //pass to script
|
|
|
|
*ppsDroid = psScrCBNewStructTruck;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2006-08-20 07:48:14 -07:00
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBStructBuilt: push failed");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-08-20 07:48:14 -07:00
|
|
|
}
|
2006-09-30 16:09:12 -07:00
|
|
|
|
|
|
|
/* Droid received stop order */
|
|
|
|
BOOL scrCBDorderStop(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
DROID **ppsDroid;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2006-09-30 16:09:12 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid))
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBDorderStop: failed to pop");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-09-30 16:09:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBOrderDroid == NULL) //if droid that received stop order was destroyed
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBDorderStop: psScrCBOrderDroid is NULL" );
|
|
|
|
triggered = false;
|
2006-09-30 16:09:12 -07:00
|
|
|
*ppsDroid = NULL;
|
|
|
|
}
|
|
|
|
else if (psScrCBOrderDroid->player == (UDWORD)player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2006-09-30 16:09:12 -07:00
|
|
|
*ppsDroid = psScrCBOrderDroid;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2006-09-30 16:09:12 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-09-30 16:09:12 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-09-30 16:09:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Droid reached destination point and stopped on its own */
|
|
|
|
BOOL scrCBDorderReachedLocation(void)
|
|
|
|
{
|
|
|
|
SDWORD player;
|
|
|
|
SDWORD *Order = NULL;
|
|
|
|
DROID **ppsDroid;
|
2008-03-24 09:51:17 -07:00
|
|
|
BOOL triggered = false;
|
2006-09-30 16:09:12 -07:00
|
|
|
|
|
|
|
if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid
|
|
|
|
,VAL_REF | VAL_INT, &Order))
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBDorderReachedLocation: failed to pop");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-09-30 16:09:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psScrCBOrderDroid == NULL) //if droid was destroyed
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
ASSERT( false, "scrCBDorderReachedLocation: psScrCBOrderDroid is NULL" );
|
|
|
|
triggered = false;
|
2006-09-30 16:09:12 -07:00
|
|
|
*ppsDroid = NULL;
|
|
|
|
}
|
|
|
|
else if (psScrCBOrderDroid->player == (UDWORD)player)
|
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
triggered = true;
|
2006-09-30 16:09:12 -07:00
|
|
|
*ppsDroid = psScrCBOrderDroid;
|
|
|
|
*Order = psScrCBOrder;
|
|
|
|
}
|
|
|
|
|
2006-11-19 12:50:02 -08:00
|
|
|
scrFunctionResult.v.bval = triggered;
|
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
2006-09-30 16:09:12 -07:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-09-30 16:09:12 -07:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-09-30 16:09:12 -07:00
|
|
|
}
|
|
|
|
|
2006-11-01 05:56:23 -08:00
|
|
|
/* Process key-combo */
|
|
|
|
BOOL scrCBProcessKeyPress(void)
|
|
|
|
{
|
|
|
|
SDWORD *key = NULL, *metaKey = NULL;
|
|
|
|
|
|
|
|
if (!stackPopParams(2,VAL_REF | VAL_INT, &key, VAL_REF | VAL_INT, &metaKey))
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "scrCBProcessKeyPress: failed to pop");
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-11-01 05:56:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
*key = cbPressedKey;
|
|
|
|
*metaKey = cbPressedMetaKey;
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
scrFunctionResult.v.bval = true;
|
2006-11-19 12:50:02 -08:00
|
|
|
if (!stackPushResult(VAL_BOOL, &scrFunctionResult)) //triggered
|
2006-11-01 05:56:23 -08:00
|
|
|
{
|
2008-03-24 09:51:17 -07:00
|
|
|
return false;
|
2006-11-01 05:56:23 -08:00
|
|
|
}
|
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2006-11-01 05:56:23 -08:00
|
|
|
}
|