Ejemplo n.º 1
0
// Add a droid to a group
BOOL scrGroupAddDroid(void)
{
	DROID_GROUP		*psGroup;
	DROID			*psDroid;

	if (!stackPopParams(2, ST_GROUP, &psGroup, ST_DROID, &psDroid))
	{
		return FALSE;
	}

	ASSERT((PTRVALID(psGroup, sizeof(DROID_GROUP)),
		"scrGroupAdd: Invalid group pointer"));
	ASSERT((PTRVALID(psDroid, sizeof(DROID)),
		"scrGroupAdd: Invalid droid pointer"));
	if (psDroid == NULL)
	{
		return FALSE;
	}
	if (psDroid->droidType == DROID_COMMAND)
	{
		ASSERT((FALSE,
			"scrGroupAdd: cannot add a command droid to a group"));
		return FALSE;
	}
	if (psDroid->droidType == DROID_TRANSPORTER)
	{
		ASSERT((FALSE,
			"scrGroupAdd: cannot add a transporter to a group"));
		return FALSE;
	}

	grpJoin(psGroup, psDroid);

	return TRUE;
}
Ejemplo n.º 2
0
// Add a droid to a group
bool scrGroupAddDroid(void)
{
	DROID_GROUP		*psGroup;
	DROID			*psDroid;

	if (!stackPopParams(2, ST_GROUP, &psGroup, ST_DROID, &psDroid))
	{
		return false;
	}

	ASSERT(psGroup != NULL,
	       "scrGroupAdd: Invalid group pointer");
	ASSERT(psDroid != NULL,
	       "scrGroupAdd: Invalid droid pointer");
	if (psDroid == NULL)
	{
		return false;
	}
	if (psDroid->droidType == DROID_COMMAND)
	{
		debug(LOG_ERROR,
		      "scrGroupAdd: cannot add a command droid to a group");
		return false;
	}
	if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
	{
		debug(LOG_ERROR,
		      "scrGroupAdd: cannot add a transporter to a group");
		return false;
	}

	psGroup->add(psDroid);

	return true;
}
Ejemplo n.º 3
0
// set droid target ignore types
bool scrSetDroidTarIgnore(void)
{
	UDWORD	pref;

	if (!stackPopParams(1, VAL_INT, &pref))
	{
		return false;
	}

	ASSERT((SCR_DT_COMMAND		== pref) ||
	       (SCR_DT_SENSOR			== pref) ||
	       (SCR_DT_CONSTRUCT		== pref) ||
	       (SCR_DT_REPAIR			== pref) ||
	       (SCR_DT_WEAP_GROUND	== pref) ||
	       (SCR_DT_WEAP_AIR		== pref) ||
	       (SCR_DT_WEAP_IDF		== pref) ||
	       (SCR_DT_WEAP_ALL		== pref) ||
	       (SCR_DT_LIGHT			== pref) ||
	       (SCR_DT_MEDIUM			== pref) ||
	       (SCR_DT_HEAVY			== pref) ||
	       (SCR_DT_SUPER_HEAVY	== pref) ||
	       (SCR_DT_TRACK			== pref) ||
	       (SCR_DT_HTRACK			== pref) ||
	       (SCR_DT_WHEEL			== pref) ||
	       (SCR_DT_LEGS			== pref) ||
	       (SCR_DT_GROUND			== pref) ||
	       (SCR_DT_VTOL			== pref) ||
	       (SCR_DT_HOVER			== pref) ,
	       "scrSetUnitTarIgnore: unknown ignore target");

	scrDroidIgnore |= pref;

	return true;
}
Ejemplo n.º 4
0
// returns number of idle droids in a group.
bool scrIdleGroup(void)
{
	DROID_GROUP *psGroup;
	DROID		*psDroid;
	UDWORD		count = 0;

	if (!stackPopParams(1, ST_GROUP, &psGroup))
	{
		return false;
	}
	ASSERT_OR_RETURN(false, psGroup != NULL, "Invalid group pointer");

	for (psDroid = psGroup->psList; psDroid; psDroid = psDroid->psGrpNext)
	{
		if (psDroid->order.type == DORDER_NONE || (psDroid->order.type == DORDER_GUARD && psDroid->order.psObj == NULL))
		{
			count++;
		}
	}

	scrFunctionResult.v.ival = (SDWORD)count;
	if (!stackPushResult(VAL_INT, &scrFunctionResult))
	{
		return false;
	}
	return true;
}
Ejemplo n.º 5
0
// Give a group an order
bool scrOrderGroup(void)
{
	DROID_GROUP		*psGroup;
	DROID_ORDER		order;

	if (!stackPopParams(2, ST_GROUP, &psGroup, VAL_INT, &order))
	{
		return false;
	}

	ASSERT(psGroup != NULL,
	       "scrOrderGroup: Invalid group pointer");

	if (order != DORDER_STOP &&
	    order != DORDER_RETREAT &&
	    order != DORDER_DESTRUCT &&
	    order != DORDER_RTR &&
	    order != DORDER_RTB &&
	    order != DORDER_RUN)
	{
		ASSERT(false,
		       "scrOrderGroup: Invalid order");
		return false;
	}

	debug(LOG_NEVER, "group %p (%u) order %d", psGroup, psGroup->getNumMembers(), order);
	psGroup->orderGroup(order);

	return true;
}
Ejemplo n.º 6
0
// Give a Droid an order with a stat
bool scrOrderDroidStatsLoc(void)
{
	DROID			*psDroid;
	DROID_ORDER		order;
	SDWORD			x,y, statIndex;
	BASE_STATS		*psStats;

	if (!stackPopParams(5, ST_DROID, &psDroid, VAL_INT, &order, ST_STRUCTURESTAT, &statIndex,
						   VAL_INT, &x, VAL_INT, &y))
	{
		return false;
	}

	if (statIndex < 0 || statIndex >= (SDWORD)numStructureStats)
	{
		ASSERT( false, "Invalid structure stat" );
		return false;
	}

	ASSERT_OR_RETURN( false, statIndex < numStructureStats, "Invalid range referenced for numStructureStats, %d > %d", statIndex, numStructureStats);
	psStats = (asStructureStats + statIndex);

	ASSERT_OR_RETURN( false, psDroid != NULL, "Invalid Unit pointer" );
	ASSERT_OR_RETURN( false, psStats != NULL, "Invalid object pointer" );
	if (psDroid == NULL)
	{
		return false;
	}

	if ((x < 0) || (x > (SDWORD)mapWidth*TILE_UNITS) ||
		(y < 0) || (y > (SDWORD)mapHeight*TILE_UNITS))
	{
		ASSERT( false, "Invalid location" );
		return false;
	}

	if (order != DORDER_BUILD)
	{
		ASSERT( false, "Invalid order" );
		return false;
	}

	// Don't allow scripts to order structure builds if players structure
	// limit has been reached.
	if (!IsPlayerStructureLimitReached(psDroid->player))
	{
		// HACK: FIXME: Looks like a script error in the player*.slo files
		// buildOnExactLocation() which references previously destroyed buildings from
		// _stat = rebuildStructStat[_count]  causes this.
		if (strcmp(psStats->pName, "A0ADemolishStructure") == 0)
		{
			// I don't feel like spamming a ASSERT here, we *know* it is a issue. 
			return true;
		}

		orderDroidStatsLocDir(psDroid, order, psStats, x, y, 0, ModeQueue);
	}

	return true;
}
Ejemplo n.º 7
0
//-----------------------
// New functions
//-----------------------
bool scrActionDroidObj(void)
{
	DROID			*psDroid;
	DROID_ACTION		action;
	BASE_OBJECT		*psObj;

	if (!stackPopParams(3, ST_DROID, &psDroid, VAL_INT, &action, ST_BASEOBJECT, &psObj))
	{
		debug(LOG_ERROR, "scrActionDroidObj: failed to pop");
		return false;
	}

	ASSERT(psDroid != NULL,
	       "scrOrderUnitObj: Invalid unit pointer");
	ASSERT(psObj != NULL,
	       "scrOrderUnitObj: Invalid object pointer");

	if (psDroid == NULL || psObj == NULL)
	{
		return false;
	}

	if (action != DACTION_DROIDREPAIR)
	{
		debug(LOG_ERROR, "scrActionDroidObj: this action is not supported");
		return false;
	}

	syncDebug("TODO: Synchronise this!");
	actionDroid(psDroid, action, psObj);

	return true;
}
Ejemplo n.º 8
0
// set prefered droid target types
BOOL scrSetDroidTarPref(void)
{
	UDWORD	pref;

	if (!stackPopParams(1, VAL_INT, &pref))
	{
		return FALSE;
	}

	ASSERT(( (SCR_DT_COMMAND		== pref) ||
			 (SCR_DT_SENSOR			== pref) ||
			 (SCR_DT_CONSTRUCT		== pref) ||
			 (SCR_DT_REPAIR			== pref) ||
			 (SCR_DT_WEAP_GROUND	== pref) ||
			 (SCR_DT_WEAP_AIR		== pref) ||
			 (SCR_DT_WEAP_IDF		== pref) ||
			 (SCR_DT_WEAP_ALL		== pref) ||
			 (SCR_DT_LIGHT			== pref) ||
			 (SCR_DT_MEDIUM			== pref) ||
			 (SCR_DT_HEAVY			== pref) ||
			 (SCR_DT_SUPER_HEAVY	== pref) ||
			 (SCR_DT_TRACK			== pref) ||
			 (SCR_DT_HTRACK			== pref) ||
			 (SCR_DT_WHEEL			== pref) ||
			 (SCR_DT_LEGS			== pref) ||
			 (SCR_DT_GROUND			== pref) ||
			 (SCR_DT_VTOL			== pref) ||
			 (SCR_DT_HOVER			== pref) ,
		"scrSetUnitTarPref: unknown target preference"));

	
	scrDroidPref |= pref;

	return TRUE;
}
Ejemplo n.º 9
0
// Deal with a CALL_NEWDROID
BOOL scrCBNewDroid(void)
{
	SDWORD		player;
	DROID		**ppsDroid;
	STRUCTURE	**ppsStructure;
	BOOL	triggered = false;

	if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid, VAL_REF|ST_STRUCTURE, &ppsStructure))
	{
		return false;
	}

	if (psScrCBNewDroid == NULL)
	{
		// eh? got called without setting the new droid
		ASSERT( false, "scrCBNewUnit: no unit has been set" );
		triggered = false;
		*ppsDroid = NULL;
		*ppsStructure  = NULL;
	}
	else if (psScrCBNewDroid->player == (UDWORD)player)
	{
		triggered = true;
		*ppsDroid = psScrCBNewDroid;
		*ppsStructure  = psScrCBNewDroidFact;
	}

	scrFunctionResult.v.bval = triggered;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 10
0
// Give a droid an order
BOOL scrOrderDroid(void)
{
	DROID			*psDroid;
	SDWORD			order;

	if (!stackPopParams(2, ST_DROID, &psDroid, VAL_INT, &order))
	{
		return FALSE;
	}

	ASSERT((PTRVALID(psDroid, sizeof(DROID)),
		"scrOrderUnit: Invalid unit pointer"));
	if (psDroid == NULL)
	{
		return FALSE;
	}

	if (order != DORDER_STOP &&
		order != DORDER_RETREAT &&
		order != DORDER_DESTRUCT &&
		order != DORDER_RTR &&
		order != DORDER_RTB &&
		order != DORDER_RUN)
	{
		ASSERT((FALSE,
			"scrOrderUnit: Invalid order"));
		return FALSE;
	}

	orderDroid(psDroid, order);

	return TRUE;
}
Ejemplo n.º 11
0
// set prefered structure target types
BOOL scrSetStructTarPref(void)
{
	UDWORD	pref;

	if (!stackPopParams(1, VAL_INT, &pref))
	{
		return FALSE;
	}

	ASSERT(( (SCR_ST_HQ					== pref) ||
			 (SCR_ST_FACTORY			== pref) ||
			 (SCR_ST_POWER_GEN			== pref) ||
			 (SCR_ST_RESOURCE_EXTRACTOR	== pref) ||
			 (SCR_ST_WALL				== pref) ||
			 (SCR_ST_RESEARCH			== pref) ||
			 (SCR_ST_REPAIR_FACILITY	== pref) ||
			 (SCR_ST_COMMAND_CONTROL	== pref) ||
			 (SCR_ST_CYBORG_FACTORY		== pref) ||
			 (SCR_ST_VTOL_FACTORY		== pref) ||
			 (SCR_ST_REARM_PAD			== pref) ||
			 (SCR_ST_SENSOR				== pref) ||
			 (SCR_ST_DEF_GROUND			== pref) ||
			 (SCR_ST_DEF_AIR			== pref) ||
			 (SCR_ST_DEF_IDF			== pref) ||
			 (SCR_ST_DEF_ALL			== pref) ,
		"scrSetStructTarPref: unknown target preference"));

	scrStructPref |= pref;

	return TRUE;
}
Ejemplo n.º 12
0
// Give a group an order to an object
BOOL scrOrderGroupObj(void)
{
	DROID_GROUP		*psGroup;
	SDWORD			order;
	BASE_OBJECT		*psObj;

	if (!stackPopParams(3, ST_GROUP, &psGroup, VAL_INT, &order, ST_BASEOBJECT, &psObj))
	{
		return FALSE;
	}

	ASSERT((PTRVALID(psGroup, sizeof(DROID_GROUP)),
		"scrOrderGroupObj: Invalid group pointer"));
	ASSERT((PTRVALID(psObj, sizeof(BASE_OBJECT)),
		"scrOrderGroupObj: Invalid object pointer"));

	if (order != DORDER_ATTACK &&
		order != DORDER_HELPBUILD &&
		order != DORDER_DEMOLISH &&
		order != DORDER_REPAIR &&
		order != DORDER_OBSERVE &&
		order != DORDER_EMBARK &&
		order != DORDER_FIRESUPPORT)
	{
		ASSERT((FALSE,
			"scrOrderGroupObj: Invalid order"));
		return FALSE;
	}

	DBP1(("scrOrderGroupObj: group %p (%d) order %d,  obj type %d player %d id %d\n",
		psGroup, grpNumMembers(psGroup), order, psObj->type, psObj->player, psObj->id));
	orderGroupObj(psGroup, order, psObj);

	return TRUE;
}
Ejemplo n.º 13
0
// Give a group an order to a location
BOOL scrOrderGroupLoc(void)
{
	DROID_GROUP		*psGroup;
	SDWORD			order, x,y;

	if (!stackPopParams(4, ST_GROUP, &psGroup, VAL_INT, &order, VAL_INT, &x, VAL_INT, &y))
	{
		return FALSE;
	}

	ASSERT((PTRVALID(psGroup, sizeof(DROID_GROUP)),
		"scrOrderGroupLoc: Invalid group pointer"));

	if (order != DORDER_MOVE &&
		order != DORDER_SCOUT)
	{
		ASSERT((FALSE,
			"scrOrderGroupLoc: Invalid order"));
		return FALSE;
	}
	if (x < 0 || x > (SDWORD)(mapWidth << TILE_SHIFT) ||
		y < 0 || y > (SDWORD)(mapHeight << TILE_SHIFT))
	{
		ASSERT((FALSE,
			"scrOrderGroupLoc: Invalid location"));
		return FALSE;
	}

	DBP1(("scrOrderGroupLoc: group %p (%d) order %d (%d,%d)\n",
		psGroup, grpNumMembers(psGroup), order, x,y));
	orderGroupLoc(psGroup, order, (UDWORD)x,(UDWORD)y);

	return TRUE;
}
Ejemplo n.º 14
0
// Give a group an order
BOOL scrOrderGroup(void)
{
	DROID_GROUP		*psGroup;
	SDWORD			order;

	if (!stackPopParams(2, ST_GROUP, &psGroup, VAL_INT, &order))
	{
		return FALSE;
	}

	ASSERT((PTRVALID(psGroup, sizeof(DROID_GROUP)),
		"scrOrderGroup: Invalid group pointer"));

	if (order != DORDER_STOP &&
		order != DORDER_RETREAT &&
		order != DORDER_DESTRUCT &&
		order != DORDER_RTR &&
		order != DORDER_RTB &&
		order != DORDER_RUN)
	{
		ASSERT((FALSE,
			"scrOrderGroup: Invalid order"));
		return FALSE;
	}

	DBP1(("scrOrderGroup: group %p (%d) order %d\n", psGroup, grpNumMembers(psGroup), order));
	orderGroup(psGroup, order);

	return TRUE;
}
Ejemplo n.º 15
0
BOOL scrCBDroidTaken(void)
{
	DROID		**ppsDroid;
	BOOL	triggered = false;

	if (!stackPopParams(1, VAL_REF|ST_DROID, &ppsDroid))
	{
		return false;
	}

	if (psScrCBDroidTaken == NULL)
	{
		triggered = false;
		*ppsDroid = NULL;
	}
	else
	{
		triggered = true;
		*ppsDroid = psScrCBDroidTaken;
	}

	scrFunctionResult.v.bval = triggered;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 16
0
/* Droid received stop order */
BOOL scrCBDorderStop(void)
{
	SDWORD		player;
	DROID		**ppsDroid;
	BOOL	triggered = false;

	if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid))
	{
		debug(LOG_ERROR, "scrCBDorderStop: failed to pop");
		return false;
	}

	if (psScrCBOrderDroid == NULL)	//if droid that received stop order was destroyed
	{
		ASSERT( false, "scrCBDorderStop: psScrCBOrderDroid is NULL" );
		triggered = false;
		*ppsDroid = NULL;
	}
	else if (psScrCBOrderDroid->player == (UDWORD)player)
	{
		triggered = true;
		*ppsDroid = psScrCBOrderDroid;
	}

	scrFunctionResult.v.bval = triggered;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 17
0
//console callback
//---------------------------
BOOL scrCallConsole(void)
{
	SDWORD	*player;
	char	**ConsoleText = NULL;

	if (!stackPopParams(2, VAL_REF | VAL_INT, &player, VAL_REF | VAL_STRING, &ConsoleText) )
	{
		debug(LOG_ERROR, "scrCallConsole(): stack failed");
		return false;
	}

	if(*ConsoleText == NULL)
	{
		debug(LOG_ERROR, "scrCallConsole(): passed string was not initialized");
		return false;
	}

	strcpy(*ConsoleText,ConsoleMsg);

	*player = ConsolePlayer;

	scrFunctionResult.v.bval = true;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		debug(LOG_ERROR, "scrCallConsole(): stackPushResult failed");
		return false;
	}

	return true;
}
Ejemplo n.º 18
0
/* Droid reached destination point and stopped on its own */
BOOL scrCBDorderReachedLocation(void)
{
	SDWORD		player;
	SDWORD		*Order = NULL;
	DROID		**ppsDroid;
	BOOL	triggered = false;

	if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid
		,VAL_REF | VAL_INT, &Order))
	{
		debug(LOG_ERROR, "scrCBDorderReachedLocation: failed to pop");
		return false;
	}

	if (psScrCBOrderDroid == NULL)	//if droid was destroyed
	{
		ASSERT( false, "scrCBDorderReachedLocation: psScrCBOrderDroid is NULL" );
		triggered = false;
		*ppsDroid = NULL;
	}
	else if (psScrCBOrderDroid->player == (UDWORD)player)
	{
		triggered = true;
		*ppsDroid = psScrCBOrderDroid;
		*Order = psScrCBOrder;
	}

	scrFunctionResult.v.bval = triggered;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 19
0
// get a target from a cluster using the preferences
bool scrTargetInCluster(void)
{
	SDWORD		tarPlayer, tarType, visPlayer, clusterID, cluster;
	BASE_OBJECT	*psTarget;

	if (!stackPopParams(2, VAL_INT, &clusterID, VAL_INT, &visPlayer))
	{
		return false;
	}

	if (clusterID < 0 || clusterID >= CLUSTER_MAX)
	{
		ASSERT(false, "scrTargetInCluster: invalid clusterID");
		return false;
	}

	cluster = aClusterMap[clusterID];
	tarPlayer = aClusterInfo[cluster] & CLUSTER_PLAYER_MASK;
	tarType = (aClusterInfo[cluster] & CLUSTER_DROID) ? SCR_TAR_DROID : SCR_TAR_STRUCT;

	psTarget = scrTargetInArea(tarPlayer, visPlayer, tarType, cluster,
	        scrollMinX * TILE_UNITS, scrollMinY * TILE_UNITS,
	        scrollMaxX * TILE_UNITS, scrollMaxY * TILE_UNITS);

	scrFunctionResult.v.oval = psTarget;
	if (!stackPushResult((INTERP_TYPE)ST_BASEOBJECT, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 20
0
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;
}
Ejemplo n.º 21
0
bool scrDroidCanReach(void)
{
	DROID			*psDroid;
	int			x, y;

	if (!stackPopParams(3, ST_DROID, &psDroid, VAL_INT, &x, VAL_INT, &y))
	{
		debug(LOG_ERROR, "Failed to pop parameters");
		return false;
	}
	if (psDroid)
	{
		const PROPULSION_STATS *psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION];
		const Vector3i rPos(x, y, 0);

		scrFunctionResult.v.bval = fpathCheck(psDroid->pos, rPos, psPropStats->propulsionType);
		if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
		{
			debug(LOG_ERROR, "stackPushResult failed");
			return false;
		}
		return true;
	}
	return false;
}
Ejemplo n.º 22
0
// 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))
	{
		return false;
	}

	if ( (psCBObjDestroyed != NULL) &&
		 (psCBObjDestroyed->player == (UDWORD)player) &&
		 (psCBObjDestroyed->type == OBJ_DROID) )
	{
		retval = true;
		*ppsObj = psCBObjDestroyed;
	}
	else
	{
		retval = false;
		*ppsObj = NULL;
	}

	scrFunctionResult.v.bval = retval;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 23
0
// iterate through a groups members
bool scrIterateGroup(void)
{
	DROID_GROUP	*psGroup;
	DROID		*psDroid;

	if (!stackPopParams(1, ST_GROUP, &psGroup))
	{
		return false;
	}

	if (psGroup != psScrIterateGroup)
	{
		debug(LOG_ERROR, "scrIterateGroup: invalid group, InitGroupIterate not called?");
		return false;
	}

	if (psScrIterateGroupDroid != NULL)
	{
		psDroid = psScrIterateGroupDroid;
		psScrIterateGroupDroid = psScrIterateGroupDroid->psGrpNext;
	}
	else
	{
		psDroid = NULL;
	}

	scrFunctionResult.v.oval = psDroid;
	if (!stackPushResult((INTERP_TYPE)ST_DROID, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 24
0
// deal with a CALL_FEATURE_DESTROYED
BOOL scrCBFeatureDestroyed(void)
{
	BASE_OBJECT		**ppsObj;
	BOOL			retval;

	if (!stackPopParams(1, VAL_REF|ST_FEATURE, &ppsObj))
	{
		return false;
	}

	if (psCBObjDestroyed != NULL)
	{
		retval = true;
		*ppsObj = psCBObjDestroyed;
	}
	else
	{
		retval = false;
		*ppsObj = NULL;
	}

	scrFunctionResult.v.bval = retval;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 25
0
// Give a droid an order
bool scrOrderDroid(void)
{
	DROID			*psDroid;
	DROID_ORDER		order;

	if (!stackPopParams(2, ST_DROID, &psDroid, VAL_INT, &order))
	{
		return false;
	}

	ASSERT(psDroid != NULL,
	       "scrOrderUnit: Invalid unit pointer");
	if (psDroid == NULL)
	{
		return false;
	}

	if (order != DORDER_STOP &&
	    order != DORDER_RETREAT &&
	    order != DORDER_DESTRUCT &&
	    order != DORDER_RTR &&
	    order != DORDER_RTB &&
	    order != DORDER_RUN &&
	    order != DORDER_NONE)
	{
		ASSERT(false,
		       "scrOrderUnit: Invalid order %d", order);
		return false;
	}

	orderDroid(psDroid, order, ModeQueue);

	return true;
}
Ejemplo n.º 26
0
BOOL scrCBTransporterOffMap( void )
{
	SDWORD	player;
	BOOL	retval;
	DROID	*psTransporter;

	if (!stackPopParams(1, VAL_INT, &player) )
	{
		return false;
	}

	psTransporter = transporterGetScriptCurrent();

	if ( (psTransporter != NULL) &&
		 (psTransporter->player == (UDWORD)player) )
	{
		retval = true;
	}
	else
	{
		retval = false;
	}

	scrFunctionResult.v.bval = retval;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 27
0
// set structure target ignore types
bool scrSetStructTarIgnore(void)
{
	UDWORD	pref;

	if (!stackPopParams(1, VAL_INT, &pref))
	{
		return false;
	}

	ASSERT((SCR_ST_HQ					== pref) ||
	       (SCR_ST_FACTORY			== pref) ||
	       (SCR_ST_POWER_GEN			== pref) ||
	       (SCR_ST_RESOURCE_EXTRACTOR	== pref) ||
	       (SCR_ST_WALL				== pref) ||
	       (SCR_ST_RESEARCH			== pref) ||
	       (SCR_ST_REPAIR_FACILITY	== pref) ||
	       (SCR_ST_COMMAND_CONTROL	== pref) ||
	       (SCR_ST_CYBORG_FACTORY		== pref) ||
	       (SCR_ST_VTOL_FACTORY		== pref) ||
	       (SCR_ST_REARM_PAD			== pref) ||
	       (SCR_ST_SENSOR				== pref) ||
	       (SCR_ST_DEF_GROUND			== pref) ||
	       (SCR_ST_DEF_AIR			== pref) ||
	       (SCR_ST_DEF_IDF			== pref) ||
	       (SCR_ST_DEF_ALL			== pref) ,
	       "scrSetStructTarIgnore: unknown ignore target");

	scrStructIgnore |= pref;

	return true;
}
Ejemplo n.º 28
0
BOOL scrCBVtolOffMap(void)
{
	SDWORD	player;
	DROID	**ppsVtol;
	BOOL	retval;

	if (!stackPopParams(2, VAL_INT, &player, VAL_REF|ST_DROID, &ppsVtol))
	{
		return false;
	}

	if (psScrCBVtolOffMap == NULL)
	{
		ASSERT( false, "scrCBVtolAtBase: NULL vtol pointer" );
		return false;
	}

	retval = false;
	if (psScrCBVtolOffMap->player == player)
	{
		retval = true;
		*ppsVtol = psScrCBVtolOffMap;
	}
	psScrCBVtolOffMap = NULL;

	scrFunctionResult.v.bval = retval;
	if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
	{
		return false;
	}

	return true;
}
Ejemplo n.º 29
0
// Add droids in an area to a group
bool scrGroupAddArea(void)
{
	DROID_GROUP		*psGroup;
	DROID			*psDroid;
	SDWORD			x1, y1, x2, y2, player;

	if (!stackPopParams(6, ST_GROUP, &psGroup, VAL_INT, &player,
	        VAL_INT, &x1, VAL_INT, &y1, VAL_INT, &x2, VAL_INT, &y2))
	{
		return false;
	}

	ASSERT(psGroup != NULL,
	       "scrGroupAdd: Invalid group pointer");

	if (player < 0 || player >= MAX_PLAYERS)
	{
		ASSERT(false, "scrGroupAddArea: invalid player");
		return false;
	}

	for (psDroid = apsDroidLists[player]; psDroid; psDroid = psDroid->psNext)
	{
		if (((SDWORD)psDroid->pos.x >= x1) && ((SDWORD)psDroid->pos.x <= x2) &&
		    ((SDWORD)psDroid->pos.y >= y1) && ((SDWORD)psDroid->pos.y <= y2) &&
		    psDroid->droidType != DROID_COMMAND &&
		    (psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER))

		{
			psGroup->add(psDroid);
		}
	}

	return true;
}
Ejemplo n.º 30
0
// iterate through a groups members
BOOL scrIterateGroup(void)
{
	DROID_GROUP	*psGroup;
	DROID		*psDroid;

	if (!stackPopParams(1, ST_GROUP, &psGroup))
	{
		return FALSE;
	}

	if (psGroup != psScrIterateGroup)
	{
		ASSERT((FALSE, "scrIterateGroup: invalid group, InitGroupIterate not called?"));
		return FALSE;
	}

	if (psScrIterateGroupDroid != NULL)
	{
		psDroid = psScrIterateGroupDroid;
		psScrIterateGroupDroid = psScrIterateGroupDroid->psGrpNext;
	}
	else
	{
		psDroid = NULL;
	}

	if (!stackPushResult(ST_DROID, (SDWORD)psDroid))
	{
		return FALSE;
	}

	return TRUE;
}