Ejemplo n.º 1
0
int DogfightClass::ReadyToStart (void)
{
	int retval = FALSE;
	Unit				unit;
	int teamUsed[MAX_DOGFIGHT_TEAMS] = {0};
	int i, numTeams = 0;
	
	// Check if it's ok to hit the 'Fly' button
	if (!(flags & DF_GAME_OVER))
	{
		VuListIterator		flit(AllRealList);
		unit = (Unit)flit.GetFirst();
		while (unit)
		{
			teamUsed[unit->GetTeam()] ++;
			unit = (Unit)flit.GetNext();
		}
		
		for (i=0; i<MAX_DOGFIGHT_TEAMS; i++)
		{
			if (teamUsed[i])
			{
				numTeams ++;
			}
		}
		
		// Check for more than one team in team play
		if (gameType == dog_Furball || numTeams > 1)
		{
			retval = TRUE;
		}
	}
	
	return retval;
}
int FalconPlayerStatusMessage::Process(uchar autodisp)
{
	FalconSessionEntity		*session = (FalconSessionEntity*) Entity();
	SimMoverClass			*mover = (SimMoverClass*) vuDatabase->Find(dataBlock.playerID);
	SimBaseClass			*theObject;
	if (autodisp)
		return 0;

	if (!session)
		return 0;

	if (!mover)
	{
//		MonoPrint ("No Mover\n");

		FalconPlayerStatusMessage	*msg = new FalconPlayerStatusMessage(session->Id (), FalconLocalSession);
		
		_tcscpy(msg->dataBlock.callsign, dataBlock.callsign);
		msg->dataBlock.playerID         = dataBlock.playerID;
		msg->dataBlock.campID           = dataBlock.campID;
		msg->dataBlock.side             = dataBlock.side;
		msg->dataBlock.pilotID          = dataBlock.pilotID;
		msg->dataBlock.vehicleID		= dataBlock.vehicleID;
		msg->dataBlock.state            = dataBlock.state;

		VuTimerEvent *timer = new VuTimerEvent(0, vuxRealTime + 1000, VU_DELAY_TIMER, msg);
		VuMessageQueue::PostVuMessage(timer);

		return 0;
	}

//	MonoPrint ("Player Status Message\n");
//	MonoPrint ("  session %08x\n", session->Id().creator_);
//	MonoPrint ("  mover %08x\n", mover);
//	MonoPrint ("  pilotID %08x\n", dataBlock.pilotID);

	// Update this player's state and the state of the vehicle they entered/exited
	if (dataBlock.state == PSM_STATE_ENTERED_SIM)
	{
//		MonoPrint ("  State Entered Sim\n");
		// Register this event
		if (TheCampaign.MissionEvaluator)
			TheCampaign.MissionEvaluator->RegisterPlayerJoin(this);
		if (!mover)
			return 0;
		//  Attach the session to this vehicle
		GameManager.AttachPlayerToVehicle (session, mover, dataBlock.pilotID);
		// Wake the vehicle's drawable, if it's a player only vehicle
		if (mover->IsSetFalcFlag(FEC_PLAYERONLY) && !mover->IsAwake() && mover->GetCampaignObject()->IsAwake())
		{
			VuListIterator flit(mover->GetCampaignObject()->GetComponents());
			theObject = (SimBaseClass*) flit.GetFirst();

			mover->Wake();

			while (theObject)
			{
				if ((!theObject->IsAwake ()) && (!theObject->IsSetFalcFlag(FEC_HASPLAYERS)))
				{
					theObject->Wake ();
				}
				theObject = (SimBaseClass*)flit.GetNext();
			}
		}
	}
	else if (dataBlock.state == PSM_STATE_LEFT_SIM)
	{
//		MonoPrint ("  State Left Sim\n");
		// Register the event
		if (TheCampaign.MissionEvaluator){
			TheCampaign.MissionEvaluator->RegisterPlayerJoin(this);
			TheCampaign.MissionEvaluator->ServerFileLog(this);
		}
		if (!mover)
			return 0;
		// Sleep this vehicle if it's a player only vehicle
		if (mover->IsSetFalcFlag(FEC_PLAYERONLY) && mover->IsAwake())
			mover->Sleep();
		// Detach the session from the vehicle
		GameManager.DetachPlayerFromVehicle (session, mover);
		// Sleep the flight if this is the only plane in the flight and it's player only
		if (mover->IsSetFalcFlag(FEC_PLAYERONLY))
		{
			Unit		campObject = (UnitClass*) mover->GetCampaignObject();
			if (campObject->NumberOfComponents() < 2)
			{
				campObject->Sleep();
				campObject->SetFinal(0);
			}
		}
	}
	else if (dataBlock.state == PSM_STATE_TRANSFERED)
	{
//		MonoPrint ("  State Transfered\n");
		if (mover && session)
		{
			SimMoverClass	*oldMover = (SimMoverClass*) vuDatabase->Find(dataBlock.oldID);
			uchar			oldpslot = 255;
//			MonoPrint ("  old %08x\n", oldMover);
			if (oldMover)
				oldpslot = oldMover->pilotSlot; 
			// Reassign player to new vehicle
			GameManager.ReassignPlayerVehicle(session, oldMover, mover);
			// Keep player accountable for the ejected ac
			if (oldMover)
			{
	   			oldMover->pilotSlot = oldpslot;					
			}
		}
	}

	return 0;
}
Ejemplo n.º 3
0
void DogfightClass::ApplySettings (void){
	// This will update all our dogfight flights to mimic the new settings
	Unit				unit;
	int					i;
	
	// KCK: Should this be done on the host only, or should everyone assume we have the same data?
	//	if (!FalconLocalGame || !FalconLocalGame->IsLocal())
	//		return;
	
	if (!TheCampaign.IsLoaded()){
		return;
	}
	
	startY = xRatio * TheCampaign.TheaterSizeX * FEET_PER_KM;
	startX = yRatio * TheCampaign.TheaterSizeY * FEET_PER_KM;
	
	if (startRange < 1){
		startRange = 1;
	}
	
	if (startTime == 0){
		startTime = 1;
	}

	SetTime(startTime);
	
	if (FalconLocalGame && FalconLocalGame->IsLocal()){
		VuListIterator		flit(AllRealList);
		unit = (Unit)flit.GetFirst();
		while (unit){
			if (unit->IsFlight()){
				ApplySettingsToFlight((Flight)unit);
			}
			unit = (Unit)flit.GetNext();
		}
	}
	
	for (i=0; i<MAX_DOGFIGHT_TEAMS; i++){
		if (gameType == dog_Furball){
			if(TeamInfo[i]){
				TeamInfo[i]->stance[i] = War;
			}
		}
		else{
			if(TeamInfo[i]){
				TeamInfo[i]->stance[i] = Allied;
			}
		}
	}
	
	lastUpdateTime = 0;
	
	if (!regenerationQueue){
		ShiAssert (this == &SimDogfight);
		regenerationQueue = new TailInsertList();
		regenerationQueue->Register();
	}
	
	if (rounds < 1){
		rounds = 1;
	}
}
void
mv_1_monster(object *monster, short row, short col)
{
	short i, n;
	boolean tried[6];

	if (monster->m_flags & ASLEEP) {
		if (monster->m_flags & NAPPING) {
			if (--monster->nap_length <= 0) {
				monster->m_flags &= (~(NAPPING | ASLEEP));
			}
			return;
		}
		if ((monster->m_flags & WAKENS) &&
			 rogue_is_around(monster->row, monster->col) &&
			 rand_percent(((stealthy > 0) ?
			 	(WAKE_PERCENT / (STEALTH_FACTOR + stealthy)) :
				WAKE_PERCENT))) {
			wake_up(monster);
		}
		return;
	} else if (monster->m_flags & ALREADY_MOVED) {
		monster->m_flags &= (~ALREADY_MOVED);
		return;
	}
	if ((monster->m_flags & FLITS) && flit(monster)) {
		return;
	}
	if ((monster->m_flags & STATIONARY) &&
		(!mon_can_go(monster, rogue.row, rogue.col))) {
		return;
	}
	if (monster->m_flags & FREEZING_ROGUE) {
		return;
	}
	if ((monster->m_flags & CONFUSES) && m_confuse(monster)) {
		return;
	}
	if (mon_can_go(monster, rogue.row, rogue.col)) {
		mon_hit(monster);
		return;
	}
	if ((monster->m_flags & FLAMES) && flame_broil(monster)) {
		return;
	}
	if ((monster->m_flags & SEEKS_GOLD) && seek_gold(monster)) {
		return;
	}
	if ((monster->trow == monster->row) &&
		   (monster->tcol == monster->col)) {
		monster->trow = NO_ROOM;
	} else if (monster->trow != NO_ROOM) {
		row = monster->trow;
		col = monster->tcol;
	}
	if (monster->row > row) {
		row = monster->row - 1;
	} else if (monster->row < row) {
		row = monster->row + 1;
	}
	if ((dungeon[row][monster->col] & DOOR) &&
		 mtry(monster, row, monster->col)) {
		return;
	}
	if (monster->col > col) {
		col = monster->col - 1;
	} else if (monster->col < col) {
		col = monster->col + 1;
	}
	if ((dungeon[monster->row][col] & DOOR) &&
		 mtry(monster, monster->row, col)) {
		return;
	}
	if (mtry(monster, row, col)) {
		return;
	}

	for (i = 0; i <= 5; i++) tried[i] = 0;

	for (i = 0; i < 6; i++) {
NEXT_TRY:	n = get_rand(0, 5);
		switch(n) {
		case 0:
			if (!tried[n] && mtry(monster, row, monster->col-1)) {
				goto O;
			}
			break;
		case 1:
			if (!tried[n] && mtry(monster, row, monster->col)) {
				goto O;
			}
			break;
		case 2:
			if (!tried[n] && mtry(monster, row, monster->col+1)) {
				goto O;
			}
			break;
		case 3:
			if (!tried[n] && mtry(monster, monster->row-1, col)) {
				goto O;
			}
			break;
		case 4:
			if (!tried[n] && mtry(monster, monster->row, col)) {
				goto O;
			}
			break;
		case 5:
			if (!tried[n] && mtry(monster, monster->row+1, col)) {
				goto O;
			}
			break;
		}
		if (!tried[n]) {
			tried[n] = 1;
		} else {
			goto NEXT_TRY;
		}
	}
O:
	if ((monster->row == monster->o_row) && (monster->col == monster->o_col)) {
		if (++(monster->o) > 4) {
			if ((monster->trow == NO_ROOM) &&
					(!mon_sees(monster, rogue.row, rogue.col))) {
				monster->trow = get_rand(1, (DROWS - 2));
				monster->tcol = get_rand(0, (DCOLS - 1));
			} else {
				monster->trow = NO_ROOM;
				monster->o = 0;
			}
		}
	} else {
		monster->o_row = monster->row;
		monster->o_col = monster->col;
		monster->o = 0;
	}
}