New script function bool getPlayerStartPosition(index, ref x, ref y) that finds the start position of any player.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9464 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
cb3c9bcf88
commit
daceec3fd9
|
@ -339,18 +339,7 @@ event initialisedEvent(CALL_GAMEINIT)
|
|||
groupAddArea(buildGroup, me, 0, 0, (mapWidth*128), (mapHeight*128));
|
||||
|
||||
// note where our base is.
|
||||
initIterateGroup(buildGroup); // find idle droids in build group.
|
||||
droid = iterateGroup(buildGroup);
|
||||
if(droid != NULLOBJECT)
|
||||
{
|
||||
baseX = droid.x;
|
||||
baseY = droid.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseX = (128*mapWidth)/2;
|
||||
baseY = (128*mapHeight)/2;
|
||||
}
|
||||
getPlayerStartPosition(me, ref baseX, ref baseY);
|
||||
|
||||
// defence.
|
||||
defendbusy = FALSE;
|
||||
|
|
15
src/game.c
15
src/game.c
|
@ -7031,6 +7031,11 @@ BOOL loadSaveStructureV7(char *pFileData, UDWORD filesize, UDWORD numStructures)
|
|||
buildingComplete(psStructure);
|
||||
}
|
||||
|
||||
if (psStructure->pStructureType->type == REF_HQ)
|
||||
{
|
||||
scriptSetStartPos(psSaveStructure->player, psStructure->pos.x, psStructure->pos.y);
|
||||
}
|
||||
|
||||
//if not a save game, don't want to overwrite any of the stats so continue
|
||||
if (gameType != GTYPE_SAVE_START)
|
||||
{
|
||||
|
@ -7318,6 +7323,11 @@ BOOL loadSaveStructureV19(char *pFileData, UDWORD filesize, UDWORD numStructures
|
|||
buildingComplete(psStructure);
|
||||
}
|
||||
|
||||
if (psStructure->pStructureType->type == REF_HQ)
|
||||
{
|
||||
scriptSetStartPos(psSaveStructure->player, psStructure->pos.x, psStructure->pos.y);
|
||||
}
|
||||
|
||||
//if not a save game, don't want to overwrite any of the stats so continue
|
||||
if ((gameType != GTYPE_SAVE_START) &&
|
||||
(gameType != GTYPE_SAVE_MIDMISSION))
|
||||
|
@ -7751,6 +7761,11 @@ BOOL loadSaveStructureV(char *pFileData, UDWORD filesize, UDWORD numStructures,
|
|||
buildingComplete(psStructure);
|
||||
}
|
||||
|
||||
if (psStructure->pStructureType->type == REF_HQ)
|
||||
{
|
||||
scriptSetStartPos(psSaveStructure->player, psStructure->pos.x, psStructure->pos.y);
|
||||
}
|
||||
|
||||
//if not a save game, don't want to overwrite any of the stats so continue
|
||||
if ((gameType != GTYPE_SAVE_START) &&
|
||||
(gameType != GTYPE_SAVE_MIDMISSION))
|
||||
|
|
|
@ -113,6 +113,14 @@ extern UDWORD objID; // unique ID creation thing..
|
|||
|
||||
/// Hold the previously assigned player
|
||||
static int nextPlayer = 0;
|
||||
static Vector2i positions[MAX_PLAYERS];
|
||||
|
||||
void scriptSetStartPos(int position, int x, int y)
|
||||
{
|
||||
debug(LOG_ERROR, "Setting start position %d to (%d, %d)", position, x, y);
|
||||
positions[position].x = x;
|
||||
positions[position].y = y;
|
||||
}
|
||||
|
||||
BOOL scriptInit()
|
||||
{
|
||||
|
@ -142,6 +150,35 @@ BOOL scrGetPlayer()
|
|||
return true;
|
||||
}
|
||||
|
||||
BOOL scrGetPlayerStartPosition(void)
|
||||
{
|
||||
SDWORD *x, *y, player;
|
||||
|
||||
if (!stackPopParams(3, VAL_INT, &player, VAL_REF|VAL_INT, &x, VAL_REF|VAL_INT, &y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ASSERT_OR_RETURN(false, player < MAX_PLAYERS, "Invalid player %d", player);
|
||||
if (player < NetPlay.maxPlayers)
|
||||
{
|
||||
*x = positions[player].x;
|
||||
*y = positions[player].y;
|
||||
scrFunctionResult.v.bval = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
scrFunctionResult.v.bval = false;
|
||||
}
|
||||
|
||||
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************************/
|
||||
/* Check for objects in areas */
|
||||
|
||||
|
|
|
@ -40,8 +40,10 @@ struct BASE_OBJECT;
|
|||
struct DROID;
|
||||
|
||||
extern BOOL scriptInit(void);
|
||||
extern void scriptSetStartPos(int position, int x, int y);
|
||||
extern BOOL scrGetPlayer(void);
|
||||
extern BOOL scrScavengersActive(void);
|
||||
extern BOOL scrGetPlayerStartPosition(void);
|
||||
|
||||
// not used in scripts, but used in code.
|
||||
extern BOOL objectInRange(struct BASE_OBJECT *psList, SDWORD x, SDWORD y, SDWORD range);
|
||||
|
|
|
@ -1488,6 +1488,10 @@ FUNC_SYMBOL asFuncTable[] =
|
|||
0, { VAL_VOID },
|
||||
false, 0, NULL, 0, 0, NULL, NULL },
|
||||
|
||||
{ "getPlayerStartPosition", scrGetPlayerStartPosition, VAL_BOOL,
|
||||
3, { VAL_INT, VAL_INT|VAL_REF, VAL_INT|VAL_REF },
|
||||
false, 0, NULL, 0, 0, NULL, NULL },
|
||||
|
||||
{ "scavengersActive", scrScavengersActive, VAL_BOOL,
|
||||
0, { VAL_VOID },
|
||||
false, 0, NULL, 0, 0, NULL, NULL },
|
||||
|
|
Loading…
Reference in New Issue