Esempio n. 1
0
//-----------------------------------------------------------------------------
// Purpose: Adds a weapon to the known weapon list
// Input  : *pWeapon - weapon to add
//-----------------------------------------------------------------------------
void CTriggerWeaponDissolve::AddWeapon( CBaseCombatWeapon *pWeapon )
{
	if ( HasWeapon( pWeapon ) )
		return;

	m_pWeapons.AddToTail( pWeapon );
}
Esempio n. 2
0
bool CCar::isObjectVisible			(CScriptGameObject* O_)
{
	if(m_memory)
	{
		return m_memory->visual().visible_now(&O_->object());
	}else
	{

		if(!O_)
		{
			Msg("Attempt to call CCar::isObjectVisible method wihth passed NULL parameter");
			return false;
		}
		CObject* O = &O_->object();
		Fvector dir_to_object;
		Fvector to_point;
		O->Center(to_point);
		
		Fvector				from_point;
		Center				(from_point);
	
		if(HasWeapon())
		{
			from_point.y		= XFORM().c.y + m_car_weapon->_height();
		}

		dir_to_object.sub(to_point,from_point).normalize_safe();
		float ray_length = from_point.distance_to(to_point);


		BOOL res = Level().ObjectSpace.RayTest(from_point, dir_to_object, ray_length, collide::rqtStatic, NULL, NULL);
		return (0==res);
	}
}
Esempio n. 3
0
static void RemoveUnavailableWeapons(PlayerData *data, const CArray *weapons)
{
	for (int i = data->weaponCount - 1; i >= 0; i--)
	{
		if (!HasWeapon(weapons, data->weapons[i]))
		{
			for (int j = i + 1; j < data->weaponCount; j++)
			{
				data->weapons[j - 1] = data->weapons[j];
			}
			data->weaponCount--;
		}
	}
}
Esempio n. 4
0
//=========================================================
// CWeaponBox - PackWeapon: Add this weapon to the box
//=========================================================
BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon )
{
	// is one of these weapons already packed in this box?
	if ( HasWeapon( pWeapon ) )
	{
		return FALSE;// box can only hold one of each weapon type
	}

	if ( pWeapon->m_pPlayer )
	{
		if ( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) )
		{
			// failed to unhook the weapon from the player!
			return FALSE;
		}
	}

	int iWeaponSlot = pWeapon->iItemSlot();
	
	if ( m_rgpPlayerItems[ iWeaponSlot ] )
	{
		// there's already one weapon in this slot, so link this into the slot's column
		pWeapon->m_pNext = m_rgpPlayerItems[ iWeaponSlot ];	
		m_rgpPlayerItems[ iWeaponSlot ] = pWeapon;
	}
	else
	{
		// first weapon we have for this slot
		m_rgpPlayerItems[ iWeaponSlot ] = pWeapon;
		pWeapon->m_pNext = NULL;	
	}

	pWeapon->pev->spawnflags |= SF_NORESPAWN;// never respawn
	pWeapon->pev->movetype = MOVETYPE_NONE;
	pWeapon->pev->solid = SOLID_NOT;
	pWeapon->pev->effects = EF_NODRAW;
	//pWeapon->pev->modelindex = 0;
	//pWeapon->pev->model = iStringNull;
	pWeapon->pev->owner = edict();
	pWeapon->SetThink( NULL );// crowbar may be trying to swing again, etc.
	pWeapon->SetTouch( NULL );
	pWeapon->m_pPlayer = NULL;

	SetThink( &CWeaponBox::Kill );
	pev->nextthink = gpGlobals->time + 5;

	//ALERT ( at_console, "packed %s\n", STRING(pWeapon->pev->classname) );
	SET_MODEL(ENT(pev), STRING(pWeapon->pev->model));
	return TRUE;
}
Esempio n. 5
0
static void CleanupPlayerInventory(
	struct PlayerData *data, const CArray *weapons)
{
	for (int i = data->weaponCount - 1; i >= 0; i--)
	{
		if (!HasWeapon(weapons, data->weapons[i]))
		{
			for (int j = i + 1; j < data->weaponCount; j++)
			{
				data->weapons[j - 1] = data->weapons[j];
			}
			data->weaponCount--;
		}
	}
}
Esempio n. 6
0
BOOL CWeaponBox::PackWeapon( CBasePlayerWeapon *pWeapon )
{
	// is one of these weapons already packed in this box?
	if ( HasWeapon( pWeapon ) ) return FALSE;// box can only hold one of each weapon type

	if ( pWeapon->m_pPlayer )
	{
		// failed to unhook the weapon from the player!
		if ( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) ) return FALSE;
	}

	int iWeaponSlot = pWeapon->iItemSlot();
	
	if ( m_rgpPlayerItems[ iWeaponSlot ] )
	{
		// there's already one weapon in this slot, so link this into the slot's column
		pWeapon->m_pNext = m_rgpPlayerItems[ iWeaponSlot ];	
		m_rgpPlayerItems[ iWeaponSlot ] = pWeapon;
	}
	else
	{
		// first weapon we have for this slot
		m_rgpPlayerItems[ iWeaponSlot ] = pWeapon;
		pWeapon->m_pNext = NULL;	
	}

	pWeapon->pev->spawnflags |= SF_NORESPAWN;// never respawn
	pWeapon->pev->movetype = MOVETYPE_NONE;
	pWeapon->pev->solid = SOLID_NOT;
	pWeapon->pev->effects = EF_NODRAW;
	pWeapon->pev->modelindex = 0;
	pWeapon->pev->model = iStringNull;
	pWeapon->pev->owner = edict();
	pWeapon->SetThink( NULL );// crowbar may be trying to swing again, etc.
	pWeapon->SetTouch( NULL );
	pWeapon->m_pPlayer = NULL;

	return TRUE;
}
Esempio n. 7
0
Boolean SpecialEventFormHandleEvent( EventPtr eventP )
{
    Boolean handled = false;
	int i, FirstEmptySlot;

	switch (eventP->eType) 
	{
		case frmOpenEvent:
		case frmUpdateEvent:
			DrawSpecialEventForm();
			handled = true;
			break;

		// Special event
		case ctlSelectEvent:
			if (eventP->data.ctlSelect.controlID != SpecialEventNoButton)
			{
				if (ToSpend() < SpecialEvent[CURSYSTEM.Special].Price)
				{
					FrmAlert( NotEnoughForEventAlert );
					handled = true;
					break;
				}
			
				Credits -= SpecialEvent[CURSYSTEM.Special].Price;
				
				switch (CURSYSTEM.Special)
				{
				
					case GETREACTOR:
						if (FilledCargoBays() > TotalCargoBays() - 15)
						{
							FrmAlert( NotEnoughBaysAlert );
							handled = true;
							break;
						}
						else if (WildStatus == 1)
						{
							if (FrmCustomAlert(WildWontStayOnboardAlert, SolarSystemName[CURSYSTEM.NameIndex],
							    NULL, NULL) == WildWontStayOnboardSayGoodbyetoWild)
							{
								WildStatus = 0;
								FrmCustomAlert( WildLeavesShipAlert,SolarSystemName[CURSYSTEM.NameIndex],
								NULL, NULL);
							}
							else
							{
								handled = true;
								break;
							}
							    
						}
						FrmAlert( ReactorAlert );
						ReactorStatus = 1;
						break;
						
					case REACTORDELIVERED:
						CURSYSTEM.Special = GETSPECIALLASER;
						ReactorStatus = 21;
						handled = true;
						break;	
						
					case MONSTERKILLED:
						break;
						
					case SCARAB:
						ScarabStatus = 1;
						break;

					case SCARABDESTROYED:
						ScarabStatus = 2;
						CURSYSTEM.Special = GETHULLUPGRADED;
						handled = true;
						break;	

					case GETHULLUPGRADED:
						FrmAlert( HullUpgradeAlert );
						Ship.Hull += UPGRADEDHULL;
						ScarabStatus = 3;
						handled = true;
						break;	
						
					case EXPERIMENT:
						ExperimentStatus = 1;
						break;
						
					case EXPERIMENTSTOPPED:
						ExperimentStatus = 13;
						CanSuperWarp = true;
						break;
						
					case EXPERIMENTNOTSTOPPED:
						break;
				
					case ARTIFACTDELIVERY:
						ArtifactOnBoard = false;
						break;
				
					case ALIENARTIFACT:
						ArtifactOnBoard = true;
						break;
				
					case FLYBARATAS:
					case FLYMELINA:
					case FLYREGULAS:
						++DragonflyStatus;
						break;
				
					case DRAGONFLYDESTROYED:
						CURSYSTEM.Special = INSTALLLIGHTNINGSHIELD;
						handled = true;
						break;
				
					case GEMULONRESCUED:
						CURSYSTEM.Special = GETFUELCOMPACTOR;
						InvasionStatus = 0;
						handled = true;
						break;
				
					case MEDICINEDELIVERY:
						JaporiDiseaseStatus = 2;
						IncreaseRandomSkill();
						IncreaseRandomSkill();
						break;

					case MOONFORSALE:
						FrmAlert( BoughtMoonAlert );
						MoonBought = true;
						break;
						
					case MOONBOUGHT:
						EraseRectangle( 0, 0, 160, 160 );
						CurForm = UtopiaForm;
						FrmGotoForm( UtopiaForm );
						return true;
						break;
						
					case SKILLINCREASE:
						FrmAlert( SkillIncreaseAlert );
						IncreaseRandomSkill();
						break;
					
					case TRIBBLE:
						FrmAlert( YouHaveATribbleAlert );						
						Ship.Tribbles = 1;
						break;
					
					case BUYTRIBBLE:
						FrmAlert( BeamOverTribblesAlert );
						Credits += (Ship.Tribbles >> 1);
						Ship.Tribbles = 0;
						break;
					
					case ERASERECORD:
						FrmAlert( CleanRecordAlert );
						PoliceRecordScore = CLEANSCORE;
						RecalculateSellPrices();
						break;

					case SPACEMONSTER:
						MonsterStatus = 1;
						for (i=0; i<MAXSOLARSYSTEM; ++i)
							if (SolarSystem[i].Special == SPACEMONSTER)
								SolarSystem[i].Special = -1;
						break;

					case DRAGONFLY:
						DragonflyStatus = 1;
						for (i=0; i<MAXSOLARSYSTEM; ++i)
							if (SolarSystem[i].Special == DRAGONFLY)
								SolarSystem[i].Special = -1;
						break;
						
					case AMBASSADORJAREK:
						if (Ship.Crew[Shiptype[Ship.Type].CrewQuarters-1] >= 0)
						{
							FrmCustomAlert( NoQuartersAvailableAlert, "Ambassador Jarek", NULL, NULL );
							handled = true;
							break;
						}
						FrmCustomAlert( PassengerTakenOnBoardAlert, "Ambassador Jarek", NULL, NULL );
						JarekStatus = 1;
						break;

					case TRANSPORTWILD:
										
						if (Ship.Crew[Shiptype[Ship.Type].CrewQuarters-1] >= 0)
						{
							FrmCustomAlert( NoQuartersAvailableAlert, "Jonathan Wild", NULL, NULL );
							handled = true;
							break;
						}
						if (!HasWeapon(&Ship, BEAMLASERWEAPON, false))
						{
							FrmAlert (WildWontGetAboardAlert);
							handled = true;
							break;
						}
						if (ReactorStatus > 0 && ReactorStatus < 21)
						{
							FrmAlert( WildAfraidOfReactorAlert );
							handled = true;
							break;
						}
						FrmCustomAlert( PassengerTakenOnBoardAlert, "Jonathan Wild", NULL, NULL );
						WildStatus = 1;
						break;

						
					case ALIENINVASION:
						InvasionStatus = 1;
						break;
						
					case JAREKGETSOUT:
						JarekStatus = 2;
						RecalculateBuyPrices(COMMANDER.CurSystem);
						break;

					case WILDGETSOUT:
						WildStatus = 2;
						Mercenary[MAXCREWMEMBER-1].CurSystem = KRAVATSYSTEM;
						// Zeethibal has a 10 in player's lowest score, an 8
						// in the next lowest score, and 5 elsewhere.
						Mercenary[MAXCREWMEMBER-1].Pilot = 5;
						Mercenary[MAXCREWMEMBER-1].Fighter = 5;
						Mercenary[MAXCREWMEMBER-1].Trader = 5;
						Mercenary[MAXCREWMEMBER-1].Engineer = 5;
						switch (NthLowestSkill(&Ship, 1))
						{
							case PILOTSKILL:
								Mercenary[MAXCREWMEMBER-1].Pilot = 10;
								break;
							case FIGHTERSKILL:
								Mercenary[MAXCREWMEMBER-1].Fighter = 10;
								break;
							case TRADERSKILL:
								Mercenary[MAXCREWMEMBER-1].Trader = 10;
								break;
							case ENGINEERSKILL:
								Mercenary[MAXCREWMEMBER-1].Engineer = 10;
								break;
						}
						switch (NthLowestSkill(&Ship, 2))
						{
							case PILOTSKILL:
								Mercenary[MAXCREWMEMBER-1].Pilot = 8;
								break;
							case FIGHTERSKILL:
								Mercenary[MAXCREWMEMBER-1].Fighter = 8;
								break;
							case TRADERSKILL:
								Mercenary[MAXCREWMEMBER-1].Trader = 8;
								break;
							case ENGINEERSKILL:
								Mercenary[MAXCREWMEMBER-1].Engineer = 8;
								break;
						}

						if (PoliceRecordScore < CLEANSCORE)
							PoliceRecordScore = CLEANSCORE;
						break;

						
					case CARGOFORSALE:
						FrmAlert( SealedCannistersAlert );
						i = GetRandom( MAXTRADEITEM );
						Ship.Cargo[i] += 3;
						BuyingPrice[i] += SpecialEvent[CURSYSTEM.Special].Price;
						break;
						
					case INSTALLLIGHTNINGSHIELD:
						FirstEmptySlot = GetFirstEmptySlot( Shiptype[Ship.Type].ShieldSlots, Ship.Shield );
						if (FirstEmptySlot < 0)
						{
							FrmAlert( NotEnoughSlotsAlert );
							handled = true;
						}
						else
						{
							FrmAlert( LightningShieldAlert );
							Ship.Shield[FirstEmptySlot] = LIGHTNINGSHIELD;
							Ship.ShieldStrength[FirstEmptySlot] = Shieldtype[LIGHTNINGSHIELD].Power;
						}
						break;

					case GETSPECIALLASER:
						FirstEmptySlot = GetFirstEmptySlot( Shiptype[Ship.Type].WeaponSlots, Ship.Weapon );
						if (FirstEmptySlot < 0)
						{
							FrmAlert( NotEnoughSlotsAlert );
							handled = true;
						}
						else
						{
							FrmAlert(MorganLaserAlert );
							Ship.Weapon[FirstEmptySlot] = MORGANLASERWEAPON;
						}
						break;

					case GETFUELCOMPACTOR:
						FirstEmptySlot = GetFirstEmptySlot( Shiptype[Ship.Type].GadgetSlots, Ship.Gadget );
						if (FirstEmptySlot < 0)
						{
							FrmAlert( NotEnoughSlotsAlert );
							handled = true;
						}
						else
						{
							FrmAlert( FuelCompactorAlert );
							Ship.Gadget[FirstEmptySlot] = FUELCOMPACTOR;
							Ship.Fuel = GetFuelTanks();
						}
						break;

					case JAPORIDISEASE:
						if (FilledCargoBays() > TotalCargoBays() - 10)
						{
							FrmAlert( NotEnoughBaysAlert );
							handled = true;
						}
						else
						{
							FrmAlert( AntidoteAlert );
							JaporiDiseaseStatus = 1;
						}
						break;
				}

				if (!handled)				
					CURSYSTEM.Special = -1;
			}
			CurForm = SystemInformationForm;
			FrmGotoForm( CurForm );
			handled = true;
			break;
				
		default:
			break;
	}
	
	return handled;
}