Exemple #1
0
/*
* G_UseItem
*/
void G_UseItem( edict_t *ent, gsitem_t *it )
{
	if( !it || !( it->flags & ITFLAG_USABLE ) )
		return;

	if( it->type & IT_WEAPON )
		Use_Weapon( ent, it );
}
Exemple #2
0
/*
* Drop_Weapon
*/
void Drop_Weapon( edict_t *ent, const gsitem_t *item )
{
	int otherweapon;
	edict_t *drop;
	int ammodrop = 0;

	if( item->tag < 1 || item->tag >= WEAP_TOTAL )
	{
		G_PrintMsg( ent, "Can't drop unknown weapon\n" );
		return;
	}

	// find out the amount of ammo to drop
	if( ent->r.client->ps.inventory[item->tag] > 1 && ent->r.client->ps.inventory[item->ammo_tag] > 5 )
	{
		ammodrop = ent->r.client->ps.inventory[item->ammo_tag] / 2;
	}
	else // drop all
	{
		ammodrop = ent->r.client->ps.inventory[item->ammo_tag];
	}

	drop = Drop_Item( ent, item );
	if( drop )
	{
		ent->r.client->ps.inventory[item->ammo_tag] -= ammodrop;
		drop->count = ammodrop;
		drop->spawnflags |= DROPPED_PLAYER_ITEM;
		ent->r.client->ps.inventory[item->tag]--;

		if( !ent->r.client->ps.inventory[item->tag] )
		{
			otherweapon = GS_SelectBestWeapon( &ent->r.client->ps );
			Use_Weapon( ent, GS_FindItemByTag( otherweapon ) );
		}
	}
}
Exemple #3
0
void Weapon_Sandbag_Fire (edict_t *ent)

{
	edict_t	*sandbag;

    
	ent->client->ps.gunframe++;

	if (ent->client->resp.team_on->index == 0)
	{
		if (allied_sandbags >= sandbaglimit->value)
		{
			safe_centerprintf(ent, "Your team is at the sandbag limit!\n");
			return;
		}
	}
	else if (ent->client->resp.team_on->index == 1)
	{
		if (axis_sandbags >= sandbaglimit->value)
		{
			safe_centerprintf(ent, "Your team is at the sandbag limit!\n");
			return;
		}
	}

	if (VectorCompare (ent->client->sandbag_pos , vec3_origin))
	{
		safe_centerprintf(ent, "There's no space for sandbags there!\n");
		return;
	}

	ent->client->pers.inventory[ITEM_INDEX(FindItem("Sandbags"))]--;





	sandbag = G_Spawn();

	VectorCopy (ent->client->sandbag_preview->mins, sandbag->mins);
	VectorCopy (ent->client->sandbag_preview->maxs, sandbag->maxs);
	VectorCopy (ent->client->sandbag_preview->s.angles, sandbag->s.angles);

	sandbag->classnameb = SANDBAGS;

	sandbag->movetype = MOVETYPE_TOSS;
	sandbag->solid = SOLID_BBOX;
	sandbag->s.modelindex = gi.modelindex ("models/objects/sandbag/tris.md2");
	sandbag->think = sandbag_think;
	sandbag->nextthink = level.time +.1;
//	ent->s.frame = rand() % 16;
//	ent->s.frame = 1;

	sandbag->mass = 300;

	sandbag->touch = sandbag_touch;

	sandbag->health = 2000;
	sandbag->takedamage      = DAMAGE_YES;
	sandbag->die = sandbag_die;
		sandbag->s.skinnum = 0;


		sandbag->s.frame = 0;
//		VectorSet (sandbag->mins, -19, -9, -10);
//		VectorSet (sandbag->maxs, 19, 9, 8);

	VectorCopy (ent->client->sandbag_pos, sandbag->s.origin);
	
	sandbag->clipmask = MASK_SHOT;


	sandbag->spawnflags = 1;
	if (ent->client->resp.team_on)
		sandbag->obj_owner = ent->client->resp.team_on->index;

	if (ent->client->resp.team_on->index == 0)
		allied_sandbags++;
	else if (ent->client->resp.team_on->index == 1)
		axis_sandbags++;

	sandbag->obj_time = level.time;


	gi.linkentity (sandbag);






	if (ent->client->pers.inventory[ITEM_INDEX(FindItem("Sandbags"))] ==0)
	{
		ent->client->weaponstate=WEAPON_LOWER;
		ent->client->ps.gunframe = 20;
		Use_Weapon (ent, FindItem("fists"));
		return;
	}

	G_FreeEdict (ent->client->sandbag_preview);
	ent->client->sandbag_preview = NULL;
}
Exemple #4
0
/*
=================
Cmd_Arty_f
CCH: new function to call in airstrikes
=================
*/
void Cmd_Arty_f (edict_t *ent)
{
/*	vec3_t	start;
	vec3_t	forward;
	vec3_t	end;
	vec3_t world_up;

	edict_t *airstrike;//faf
	trace_t	tr;*/

	//int randnum;	
	vec3_t v;
	edict_t *check;
	int e;

	edict_t *t;
	vec3_t  vdist;
	float tdist;

	int i;

	if (!ent->client)
		return;

	if (!IsValidPlayer(ent))
		return;

	if (ent->deadflag)
		return;

	if (!ent->client->resp.team_on)
		return;

	for (i=0 ; i<game.maxentities ; i++)
	{
		vec3_t neworg;

		t = &g_edicts[i];

		if (!t->inuse)
			continue;
		if (!t->classnameb)
			continue;
		if (t->classnameb != TNT)
			continue;

		VectorCopy (ent->s.origin, neworg);
		neworg[2]+= ent->viewheight;

		VectorSubtract (t->s.origin, neworg, vdist);

		tdist = VectorLength (vdist);
		
		if (tdist > 40) 
			continue;

		if (infront (ent, t))
		{
			t->think = G_FreeEdict;
			t->nextthink = level.time + 2;
			t->s.sound = 0;
			t->s.effects = 0;
			safe_centerprintf (ent, "You defused the TNT!\n");
		}
	}

	Spawn_Chute_Special (ent);

	//faf:  turret stuff
	if (!ent->client->turret &&
		!ent->client->grenade)
	{
		if	(CheckForTurret(ent))
		{
			Use_Weapon (ent, FindItem("Fists"));
			CheckForTurret(ent);
			return;
		}
	}
	else
	{
		turret_off(ent);
		return;
	}
	if (ent->client &&
		ent->client->pers.weapon &&
		ent->client->pers.weapon->classnameb == WEAPON_ARISAKA)
	{
		if (ent->client->weaponstate == WEAPON_READY &&
			ent->client->ps.gunframe < 99 &&
			!ent->client->aim)
		{
			ent->client->ps.gunframe = 99;
			Weapon_Bayonet_Fire1 (ent);
			return;
		}
		return;
	}

	if (ent->client &&
		ent->client->pers.weapon &&
		ent->client->pers.weapon->classnameb == WEAPON_CARCANO)
	{
		if (ent->client->weaponstate == WEAPON_READY &&
			ent->client->ps.gunframe < 104 &&
			!ent->client->aim)
		{
			ent->client->ps.gunframe = 104;
			Weapon_Bayonet_Fire1 (ent);
			return;
		}
		return;
	}

	if (ent->client &&
		ent->client->pers.weapon &&
		ent->client->pers.weapon->classnameb == WEAPON_ENFIELD)
	{
		if (ent->client->weaponstate == WEAPON_READY &&
			ent->client->ps.gunframe < 107 //&&
			)//!ent->client->aim)
		{
			ent->client->aim = false;
			ent->client->ps.gunframe = 107;
			Weapon_Bayonet_Fire1 (ent);
			return;
		}
		return;
	}

	if (ent->client &&
		ent->client->pers.weapon &&
		ent->client->pers.weapon->classnameb == WEAPON_SVT)
	{
		if (ent->client->weaponstate == WEAPON_READY &&
			ent->client->ps.gunframe < 89 &&
			!ent->client->aim)
		{
			ent->client->ps.gunframe = 89;
			Weapon_Bayonet_Fire1 (ent);
			return;
		}
		return;
	}

	if (ent->client->airstrike)
	{
		safe_cprintf(ent, PRINT_HIGH, "Airstrike cancelled sir!\n");

		G_FreeEdict(ent->client->airstrike);
		ent->client->airstrike = NULL;
		return;
	}
	else if ((ent->client->pers.weapon &&
		ent->client->pers.weapon->classnameb) &&
		ent->client->pers.weapon->classnameb == WEAPON_BINOCULARS)
	{
		if (ent->client->aim)
			safe_cprintf(ent, PRINT_HIGH, "Press fire to call an airstrike!\n");
		else
			safe_cprintf(ent, PRINT_HIGH, "Aim and then press fire to call an airstrike!\n");
	}

//	if (ent->client->resp.mos != OFFICER) {
//		safe_cprintf(ent, PRINT_HIGH, "You're not an officer, soldier!\n");
//		return;
//	}

	if (ent->deadflag || ent->client->limbo_mode ) {
		safe_cprintf(ent, PRINT_HIGH, "You are dead!\n");
		return;
	}

	//faf:  moving this up so you dont have to look through binocs to cancel arty
	// make sure artillary hasn't already been called

	check = g_edicts+1;
	for (e = 1; e < globals.num_edicts; e++, check++)
	{
		if (!check->inuse)
			continue;
		if (check->health < 1)
			continue;
		if (strcmp(check->classname, "misc_civilian"))
			continue;

		VectorSubtract (ent->s.origin, check->s.origin, v);

		if (VectorLength (v)< 100)
		{
			//gi.dprintf(DEVELOPER_MSG_GAME, "CIV FOUND\n");
			if (check->master == ent)
			{
				check->master = NULL;
				//gi.dprintf(DEVELOPER_MSG_GAME, "STAY\n");
				gi.sound (ent, CHAN_AUTO, gi.soundindex("misc/trigger1.wav"), .5, ATTN_STATIC, 0);
				check->goalentity = NULL;
				check->movetarget = NULL;
				check->enemy = NULL;
				check->monsterinfo.currentmove = &civilian_move_stand;
			}
			else
			{
				if (check->master && check->obj_owner == ent->client->resp.team_on->index)
					return; // can't steal civilian from teammate

				gi.sound (ent, CHAN_AUTO, gi.soundindex("misc/trigger1.wav"), .5, ATTN_STATIC, 0);

				check->master = ent;
				//gi.dprintf(DEVELOPER_MSG_GAME, "FOLLOW\n");
				if (check->obj_owner != ent->client->resp.team_on->index)
				{	
					level.obj_team = ent->client->resp.team_on->index;
					check->obj_owner = ent->client->resp.team_on->index;
					check->wait =level.time;
					//if (!check->wait) check->wait =level.time;
				}
			}
			check->obj_owner = ent->client->resp.team_on->index; 
		}
	}
}