Exemplo n.º 1
0
void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther )
{
	if ( !pOther->IsPlayer() )
	{
		return;
	}

	if (!UTIL_IsMasterTriggered(m_sMaster, m_pPlayer))	//
		return ;										// AJH allows for locked weapons

	if (AddAmmo( pOther ))
	{
		if ( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES )
		{
			Respawn();
		}
		else
		{
			SetTouch( NULL );
			SetThink(&CBasePlayerAmmo ::SUB_Remove);
			SetNextThink( 0.1 );
		}
		SUB_UseTargets( pOther, USE_TOGGLE, 0 );	//AJH now ammo can trigger stuff too
	}
	else if (gEvilImpulse101)
	{
		// evil impulse 101 hack, kill always
		SetTouch( NULL );
		SetThink(&CBasePlayerAmmo ::SUB_Remove);
		SetNextThink( 0.1 );
	}
}
Exemplo n.º 2
0
void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther )
{
	if ( !pOther->IsPlayer() )
	{
		return;
	}

	if (AddAmmo( pOther ))
	{
		if ( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES )
		{
			Respawn();
		}
		else
		{
			SetTouch( NULL );
			SetThink(SUB_Remove);
			pev->nextthink = gpGlobals->time + .1;
		}
	}
	else if (gEvilImpulse101)
	{
		// evil impulse 101 hack, kill always
		SetTouch( NULL );
		SetThink(SUB_Remove);
		pev->nextthink = gpGlobals->time + .1;
	}
}
Exemplo n.º 3
0
bool AWeapon::TryPickupRestricted (AActor *&toucher)
{
	// Wrong class, but try to pick up for ammo
	if (ShouldStay())
	{ // Can't pick up weapons for other classes in coop netplay
		return false;
	}

	bool gaveSome = (NULL != AddAmmo (toucher, AmmoType1, AmmoGive1));
	gaveSome |= (NULL != AddAmmo (toucher, AmmoType2, AmmoGive2));
	if (gaveSome)
	{
		GoAwayAndDie ();
	}
	return gaveSome;
}
//-----------------------------------------------------------------------------
// Button click handlers
//-----------------------------------------------------------------------------
void CSentrygunControlPanel::OnCommand( const char *command )
{
	if (!Q_strnicmp(command, "AddAmmo", 7))
	{
		AddAmmo();
		return;
	}

	BaseClass::OnCommand(command);
}
Exemplo n.º 5
0
void AWeapon::AttachToOwner (AActor *other)
{
	Super::AttachToOwner (other);

	Ammo1 = AddAmmo (Owner, AmmoType1, AmmoGive1);
	Ammo2 = AddAmmo (Owner, AmmoType2, AmmoGive2);
	SisterWeapon = AddWeapon (SisterWeaponType);
	if (Owner->player != NULL)
	{
		if (!Owner->player->userinfo.GetNeverSwitch() && !(WeaponFlags & WIF_NO_AUTO_SWITCH))
		{
			Owner->player->PendingWeapon = this;
		}
		if (Owner->player->mo == players[consoleplayer].camera)
		{
			StatusBar->ReceivedWeapon (this);
		}
	}
	GivenAsMorphWeapon = false; // will be set explicitly by morphing code
}
Exemplo n.º 6
0
int Pickup_Ammo( gentity_t *ent, gentity_t *other ) {
	int quantity;

	if ( ent->count ) {
		quantity = ent->count;
	} else {
		quantity = ent->item->quantity;
	}

	AddAmmo( other, ent->item->giTag, quantity );

	return RESPAWN_AMMO;
}
void CMissionData::ReadFromMessage(ILTCSBase *pInterface, HMESSAGEREAD hMessage)
{
	if (!hMessage) return;

	// Clear our data...

	Clear();

	// Read in the new data...

    m_nMission = (int) pInterface->ReadFromMessageFloat(hMessage);
    m_nLevel   = (int) pInterface->ReadFromMessageFloat(hMessage);

    int nSize = (int) pInterface->ReadFromMessageDWord(hMessage);

    int i;
	CWeaponData Weapon;
    for (i = 0; i < nSize; i++)
	{
        Weapon.ReadFromMessage(pInterface, hMessage);
		AddWeapon(Weapon.m_nID);
	}

    nSize = (int) pInterface->ReadFromMessageDWord(hMessage);

	CAmmoData Ammo;
	for (i = 0; i < nSize; i++)
	{
        Ammo.ReadFromMessage(pInterface, hMessage);
		AddAmmo(Ammo.m_nID, Ammo.m_nCount);
	}

    nSize = (int) pInterface->ReadFromMessageDWord(hMessage);

	CModData Mod;
	for (i = 0; i < nSize; i++)
	{
        Mod.ReadFromMessage(pInterface, hMessage);
		AddMod(Mod.m_nID);
	}

    nSize = (int) pInterface->ReadFromMessageDWord(hMessage);

	CGearData Gear;
	for (i = 0; i < nSize; i++)
	{
        Gear.ReadFromMessage(pInterface, hMessage);
		AddGear(Gear.m_nID);
	}
}
Exemplo n.º 8
0
END_DEFAULTS

bool AFighterWeapon::TryPickup (AActor *toucher)
{
	// The Doom and Hexen players are not excluded from pickup in case
	// somebody wants to use these weapons with either of those games.
	if (toucher->IsKindOf (RUNTIME_CLASS(AClericPlayer)) ||
		toucher->IsKindOf (RUNTIME_CLASS(AMagePlayer)))
	{ // Wrong class, but try to pick up for mana
		if (ShouldStay())
		{ // Can't pick up weapons for other classes in coop netplay
			return false;
		}

		bool gaveSome = (NULL != AddAmmo (toucher, AmmoType1, AmmoGive1));
		gaveSome |= (NULL != AddAmmo (toucher, AmmoType2, AmmoGive2));
		if (gaveSome)
		{
			GoAwayAndDie ();
		}
		return gaveSome;
	}
	return Super::TryPickup (toucher);
}
Exemplo n.º 9
0
// AM+ command.
// adds "ammo" ammo to the specified weapons ammo and maxammo,
// and if you don't have it already, gives it to you.
void GetWeapon(int wpn, int ammo)
{
	if (!player->weapons[wpn].hasWeapon)
	{
		player->weapons[wpn].ammo = 0;	// will be filled to full by AddAmmo below
		player->weapons[wpn].maxammo = ammo;
		player->weapons[wpn].level = 0;
		player->weapons[wpn].xp = 0;
		player->weapons[wpn].hasWeapon = true;
		player->curWeapon = wpn;
	}
	else
	{	// missile capacity powerups
		player->weapons[wpn].maxammo += ammo;
	}
	
	AddAmmo(wpn, ammo);
	sound(SND_GET_ITEM);
}
Exemplo n.º 10
0
void isdf07Mission::CommandShab() {
	char tempstr[128];
	switch (shabState) {
		case 0: //setup the first batch of enemies
			shabEnemy1 = BuildObject("fvsent", comp_team, spawn1);
			shabEnemy2 = BuildObject("fvsent", comp_team, spawn2);
			Attack(shabEnemy1, shabayev, 1);
			Attack(shabEnemy2, shabayev, 1);
			Attack(shabayev, shabEnemy1, 1);
			shabState++;
			break;
		case 1: //do nothing until the first enemy gets killed
			if (!IsAlive(shabEnemy1)) {
				if (IsAlive(shabEnemy2)) {
					Attack(shabayev, shabEnemy2, 1);
					shabState++;
				}
				else {
					shabState++;
				}
			}

			if (gunTowBuilt) { //If shab can't kill anybody do it for her
				Damage(shabEnemy1, 3000);
				if (IsAlive(shabEnemy2)) {
					Damage(shabEnemy2, 3000);
				}
				ClearObjectives();
				AddObjective("isdf0707.otf", WHITE);
				Goto(shabayev, "tree_point", 1);
				AudioMessage("isdf0728.wav");
				shabState = 3;
				BugFix=GetTime()+60.0f;
			}

			break;
		case 2: //go NEAR the ruin when all of the enemies are killed
			if ((missionState>8) && (IsAlive(shabEnemy2))) { //If shab can't kill anybody do it for her
				Damage(shabEnemy2, 3000);
			}
			if ((!IsAlive(shabEnemy1)) && (!IsAlive(shabEnemy2)) && (!gunTowBuilt)) {
				shabEnemy2 = BuildObject("fvsent", 2, spawn1);
				Attack(shabayev, shabEnemy2, 1);
				Attack(shabEnemy2, shabayev, 1);

			}
			if ((!IsAlive(shabEnemy1)) && (!IsAlive(shabEnemy2)) && (gunTowBuilt)) {
				ClearObjectives();
				AddObjective("isdf0710.otf", WHITE);
				AudioMessage("isdf0728.wav");
				Goto(shabayev, "tree_point", 1);
				BugFix=GetTime()+20.0f;
				shabState++;
			}
			break;
		case 3: //hop out of the vehicle when near the ruin
			if (GetTime()>BugFix)
			{
				Goto(shabayev,"tree_point");
				BugFix=GetTime()+10.0f;	
			}
			if (((GetDistance(shabayev, "tree_point") < 25.0)) && ((!IsAlive(enemy1)) || (!IsAlive(enemy2))))
			{
				ClearObjectives();
				AudioMessage("isdf0725.wav");

				AddObjective("isdf0707.otf", WHITE);
				justHoped = true;
				HopOut(shabayev);
//				SetObjectiveOn(shabOnFoot);
				hunter=	BuildObject("fvsent",comp_team,"hunter");
	//			Patrol(temp,"hunter_path");
				Attack(hunter,shabayev); // blow up shabs craft
				CameraReady();
				reminderTimer=GetTime()+60.0f;
				shabState++;
			}
			break;
		case 4:
			oldPlayer=HoppedOutOf(shabOnFoot);	// because shab becomes 0
			{
				Vector pos;
				pos = GetPosition(oldPlayer);
				CameraObject(oldPlayer,2,5,-7,oldPlayer);		
				LookAt(shabOnFoot, ruins, 1);
				RemoveObject(oldPlayer);
				oldPlayer=BuildObject("petank",1,pos);
			}
			shabState++;
			break;
		case 5:
			if (movie_counter<70)
			{
				CameraObject(oldPlayer,2,2,-7,oldPlayer);
				movie_counter++;
			}
			else
			{
				RemoveObject(oldPlayer);
				Handle temp=BuildObject("ibnav",1,"tree_point");
				TranslateString2(tempstr, sizeof(tempstr), "Mission0701");  // Rescue
				SetObjectiveName(temp,tempstr);
				SetObjectiveOn(temp);
				CameraFinish();
				shabState++;
			}
			break;
		case 6: //order the player to get out of his vehicle once he gets close
			if ((!IsAround(shabayev)) && (!ship_blown_up))
			{
				Patrol(hunter,"hunter_path");
				SetIndependence(hunter,0);
				ship_blown_up=true;

			}

			if ((!IsAlive(shabOnFoot) && (!shab_dead)))	
			{
				AudioMessage("isdf0732.wav");
				ClearObjectives();
				AddObjective("isdf05l1.otf",RED,15.0f);
				FailMission(GetTime()+5.0f,"isdf05l1.otf");
				shab_dead=true;
			}

			if (GetTime()>reminderTimer) {
				AudioMessage("isdf0725.wav");
				reminderTimer=GetTime()+60.0f;
			}
			
			if ((GetDistance(shabOnFoot, player) < 50.0)) {

				//RemoveObject(shabayev);
				Attack(shabEnemy1,shabayev);
				Attack(shabEnemy2,shabayev);
				ClearObjectives();
				AudioMessage("isdf0729.wav");
				AddObjective("isdf0708.otf", WHITE);
				shabState++;
			}
			break;

		case 7: //send shab to get the relic
			if ((!IsAlive(shabOnFoot) && (!shab_dead)))	
			{
				AudioMessage("isdf0732.wav");
				ClearObjectives();
				AddObjective("isdf05l1.otf",RED,15.0f);
				FailMission(GetTime()+5.0f,"isdf05l1.otf");
				shab_dead=true;
			}
			if (playerOnFoot) {
				Attack(shabEnemy1,oldPlayer);
				Attack(shabEnemy2,oldPlayer);
				Goto(shabOnFoot, ruins, 1);
				//we should start the patrols here
				shabState++;
			}
			break;
		case 8: //get shab hurt
			if ((!IsAlive(shabOnFoot) && (!shab_dead)))	
			{
				AudioMessage("isdf0732.wav");
				ClearObjectives();
				AddObjective("isdf05l1.otf",RED,15.0f);
				FailMission(GetTime()+5.0f,"isdf05l1.otf");
				shab_dead=true;
			}

			if ((GetDistance(shabOnFoot, ruins) < 20.0f) || (GetDistance(player,ruins)<10.0f))
			{
				if (winMission == false) {
					AudioMessage("isdf0731.wav"); // wrong file name
					SucceedMission(GetTime()+5.0f,"isdf07w1.txt");
					winMission = true;
				}
			}
			break;
		case 9: //hide shab
			
			break;
		case 10: //play closing cineractive
		// The following is an example of how to play a movie in a script.
			moviePlaying = PlayMovie("temp");
			if (!moviePlaying) {
				missionState++;
				moviePlaying = true;
				//IFace_SetInteger("script.mission.state", 1);
			}
			break;
	}

	if (GetHealth(shabayev) < 0.7f) { //keep shab alive
		AddHealth(shabayev, 100);
	}

	if ((GetAmmo(shabayev)) < 0.5f) {
		AddAmmo(shabayev, 500);
	}
	if ((justHoped) && (!IsAlive(shabOnFoot)))
	{
		int i;
		i=1;
		// Houston we have a problem
	}

}
Exemplo n.º 11
0
/**\brief Parse one player out of an xml node
 */
bool Player::FromXMLNode( xmlDocPtr doc, xmlNodePtr node ) {
	xmlNodePtr  attr;
	string value;
	Coordinate pos;

	if( (attr = FirstChildNamed(node,"name")) ){
		SetName(NodeToString(doc,attr));
	}

	if( (attr = FirstChildNamed(node, "planet"))){
		string temp;
		xmlNodePtr name = FirstChildNamed(attr,"name");
		lastPlanet = NodeToString(doc,name);
		Planet* p = Planets::Instance()->GetPlanet( lastPlanet );
		if( p != NULL ) {
			SetWorldPosition( p->GetWorldPosition() );
		}
	}else return false;

	if( (attr = FirstChildNamed(node,"model")) ){
		value = NodeToString(doc,attr);
		Model* model = Models::Instance()->GetModel( value );
		if( NULL!=model) {
			SetModel( model );
		} else {
			LogMsg(ERR,"No such model as '%s'", value.c_str());
			return false;
		}
	} else return false;
	
	if( (attr = FirstChildNamed(node,"engine")) ){
		value = NodeToString(doc,attr);
		Engine* engine = Engines::Instance()->GetEngine( value );
		if( NULL!=engine) {
			SetEngine( engine );
		} else {
			LogMsg(ERR,"No such engine as '%s'", value.c_str());
			return false;
		}
	} else return false;


	if( (attr = FirstChildNamed(node,"credits")) ){
		value = NodeToString(doc,attr);
		SetCredits( atoi(value.c_str()) );
	} else return false;

	for( attr = FirstChildNamed(node,"weapon"); attr!=NULL; attr = NextSiblingNamed(attr,"weapon") ){
		AddShipWeapon( NodeToString(doc,attr) );
	}

	for( attr = FirstChildNamed(node,"outfit"); attr!=NULL; attr = NextSiblingNamed(attr,"outfit") ){
		AddOutfit( NodeToString(doc,attr) );
	}

	for( attr = FirstChildNamed(node,"cargo"); attr!=NULL; attr = NextSiblingNamed(attr,"cargo") ){
		xmlNodePtr type = FirstChildNamed(attr,"type");
		xmlNodePtr ammt = FirstChildNamed(attr,"amount");
		if(!type || !ammt)
			return false;
		if( NodeToInt(doc,ammt) > 0 )
		{
			StoreCommodities( NodeToString(doc,type), NodeToInt(doc,ammt) );
		}
	}

	for( attr = FirstChildNamed(node,"ammo"); attr!=NULL; attr = NextSiblingNamed(attr,"ammo") ){
		xmlNodePtr type = FirstChildNamed(attr,"type");
		xmlNodePtr ammt = FirstChildNamed(attr,"amount");
		if(!type || !ammt)
			return false;
		AmmoType ammoType = Weapon::AmmoNameToType( NodeToString(doc,type) );
		int ammoCount = NodeToInt(doc,ammt);
		if( ammoType < max_ammo ) {
			AddAmmo( ammoType, ammoCount );
		} else return false;
	}

	for( attr = FirstChildNamed(node,"Mission"); attr!=NULL; attr = NextSiblingNamed(attr,"Mission") ){
		Mission *mission = Mission::FromXMLNode(doc,attr);
		if( mission != NULL ) {
			LogMsg(INFO, "Successfully loaded the %s mission of player '%s'", mission->GetName().c_str(), this->GetName().c_str() );
			missions.push_back( mission );
		} else {
			LogMsg(INFO, "Aborted loading mission of player '%s'", this->GetName().c_str() );
		}
	}

	for( attr = FirstChildNamed(node,"favor"); attr!=NULL; attr = NextSiblingNamed(attr,"favor") ){
		xmlNodePtr alliance = FirstChildNamed(attr,"alliance");
		xmlNodePtr value = FirstChildNamed(attr,"value");
		if(!alliance || !value)
			return false;
		if( NodeToInt(doc,value) > 0 )
		{
			UpdateFavor( NodeToString(doc,alliance), NodeToInt(doc,value) );
		}
	}

	for( attr = FirstChildNamed(node,"hiredEscort"); attr!=NULL; attr = NextSiblingNamed(attr,"hiredEscort") ){
		xmlNodePtr typePtr = FirstChildNamed(attr, "type");
		xmlNodePtr payPtr = FirstChildNamed(attr, "pay");
		assert(typePtr && payPtr);
		if(!typePtr || !payPtr) return false;
		string type = NodeToString(doc, typePtr);
		int pay = atoi( NodeToString(doc, payPtr).c_str() );
		// Adding it with sprite ID -1 means it's up to player.lua to go ahead and create the correct sprite.
		this->AddHiredEscort(type, pay, -1);
	}

	if(this->ConfigureWeaponSlots(doc, node)){
		// great - it worked
		LogMsg( INFO, "Successfully loaded weapon slots");
	}
	else {
		LogMsg( ERR, "Weapon slot XML helper failed to configure weapon slots");
	}

	if( (attr = FirstChildNamed(node,"lastLoadTime")) ){
		lastLoadTime = NodeToInt(doc,attr);
	} else {
		lastLoadTime = (time_t)0;
	}

	RemoveLuaControlFunc();

	return true;
}