Пример #1
0
/*
===============
G_SetStats
===============
*/
void G_SetStats (edict_t *ent)
{
	gitem_t		*item;
#if defined (__APPLE__) || defined (MACOSX)
	int			index, cells = 0;
#else
	int			index, cells;
#endif /* __APPLE__ || MACOSX */
	int			power_armor_type;

	//
	// health
	//
	ent->client->ps.stats[STAT_HEALTH_ICON] = level.pic_health;
	ent->client->ps.stats[STAT_HEALTH] = ent->health;

	//
	// ammo
	//
	if (!ent->client->ammo_index /* || !ent->client->pers.inventory[ent->client->ammo_index] */)
	{
		ent->client->ps.stats[STAT_AMMO_ICON] = 0;
		ent->client->ps.stats[STAT_AMMO] = 0;
	}
	else
	{
		item = &itemlist[ent->client->ammo_index];
		ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex (item->icon);
		ent->client->ps.stats[STAT_AMMO] = ent->client->pers.inventory[ent->client->ammo_index];
	}
	
	//
	// armor
	//
	power_armor_type = PowerArmorType (ent);
	if (power_armor_type)
	{
		cells = ent->client->pers.inventory[ITEM_INDEX(FindItem ("cells"))];
		if (cells == 0)
		{	// ran out of cells for power armor
			ent->flags &= ~FL_POWER_ARMOR;
			gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/power2.wav"), 1, ATTN_NORM, 0);
			power_armor_type = 0;;
		}
	}

	index = ArmorIndex (ent);
	if (power_armor_type && (!index || (level.framenum & 8) ) )
	{	// flash between power armor and other armor icon
		ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex ("i_powershield");
		ent->client->ps.stats[STAT_ARMOR] = cells;
	}
	else if (index)
	{
		item = GetItemByIndex (index);
		ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex (item->icon);
		ent->client->ps.stats[STAT_ARMOR] = ent->client->pers.inventory[index];
	}
	else
	{
		ent->client->ps.stats[STAT_ARMOR_ICON] = 0;
		ent->client->ps.stats[STAT_ARMOR] = 0;
	}

	//
	// pickup message
	//
	if (level.time > ent->client->pickup_msg_time)
	{
		ent->client->ps.stats[STAT_PICKUP_ICON] = 0;
		ent->client->ps.stats[STAT_PICKUP_STRING] = 0;
	}

	//
	// timers
	//
	if (ent->client->quad_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_quad");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->quad_framenum - level.framenum)/10;
	}
	else if (ent->client->invincible_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_invulnerability");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->invincible_framenum - level.framenum)/10;
	}
	else if (ent->client->enviro_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_envirosuit");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->enviro_framenum - level.framenum)/10;
	}
	else if (ent->client->breather_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_rebreather");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->breather_framenum - level.framenum)/10;
	}
	else
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = 0;
		ent->client->ps.stats[STAT_TIMER] = 0;
	}

	//
	// selected item
	//
	if (ent->client->pers.selected_item == -1)
		ent->client->ps.stats[STAT_SELECTED_ICON] = 0;
	else
		ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex (itemlist[ent->client->pers.selected_item].icon);

	ent->client->ps.stats[STAT_SELECTED_ITEM] = ent->client->pers.selected_item;

	//
	// layouts
	//
	ent->client->ps.stats[STAT_LAYOUTS] = 0;

	if (deathmatch->value)
	{
		if (ent->client->pers.health <= 0 || level.intermissiontime
			|| ent->client->showscores)
			ent->client->ps.stats[STAT_LAYOUTS] |= 1;
		if (ent->client->showinventory && ent->client->pers.health > 0)
			ent->client->ps.stats[STAT_LAYOUTS] |= 2;
	}
	else
	{
		if (ent->client->showscores || ent->client->showhelp)
			ent->client->ps.stats[STAT_LAYOUTS] |= 1;
		if (ent->client->showinventory && ent->client->pers.health > 0)
			ent->client->ps.stats[STAT_LAYOUTS] |= 2;
	}

	//
	// frags
	//
	ent->client->ps.stats[STAT_FRAGS] = ent->client->resp.score;

	//
	// help icon / current weapon if not shown
	//
	if (ent->client->resp.helpchanged && (level.framenum&8) )
		ent->client->ps.stats[STAT_HELPICON] = gi.imageindex ("i_help");
	else if ( (ent->client->pers.hand == CENTER_HANDED || ent->client->ps.fov > 91)
		&& ent->client->pers.weapon)
		ent->client->ps.stats[STAT_HELPICON] = gi.imageindex (ent->client->pers.weapon->icon);
	else
		ent->client->ps.stats[STAT_HELPICON] = 0;

//ZOID
	SetCTFStats(ent);
//ZOID
}
Пример #2
0
void Drop_PowerArmor (edict_t *ent, gitem_t *item)
{
	if ((ent->flags & FL_POWER_ARMOR) && (ent->client->pers.inventory[ITEM_INDEX(item)] == 1))
		Use_PowerArmor (ent, item);
	Drop_General (ent, item);
}
Пример #3
0
/*
===============
Touch_Item
===============
*/
void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
{
	qboolean	taken;
	float		vol;

	if (!other->client)
	{
		if (!ent->playedsound && ent->groundentity)
		{
			//gi.dprintf(DEVELOPER_MSG_GAME, "Plonk!  %s\n",other->classname);
			if (ent->item)
			{
				//velocity goes from around -250 for normal drop to ~1000 from top of dday2 church stairs
				//knife ~1 lb  50cal ~50 lbs
				vol = ((1000+(-1 * ent->velocity[2]))/2000) * ( (ent->item->weight+100)/150 );
				if (vol > .9)
					vol = .9;


//				gi.dprintf(DEVELOPER_MSG_GAME, "%f %f   %f\n", ent->velocity[2], ent->item->weight, vol);
//				gi.dprintf(DEVELOPER_MSG_GAME, "%f %f   %f\n", ((1000+(-1 * ent->velocity[2]))/2000), (ent->item->weight+100)/150, vol);
				
				if (ent->item->flags & IT_AMMO || ent->item->position == LOC_GRENADES || ent->item->position == LOC_KNIFE)
					gi.sound (ent, CHAN_WEAPON, gi.soundindex("weapons/ammodrop.wav"), vol, ATTN_NORM, 0);
					//gi.positioned_sound (ent->s.origin, g_edicts, CHAN_AUTO, gi.soundindex("weapons/ammodrop.wav"), vol, ATTN_NORM, 0);			
				else if (ent->item->flags & IT_WEAPON)
					gi.sound (ent, CHAN_WEAPON, gi.soundindex("weapons/gundrop.wav"), vol, ATTN_NORM, 0);
					//gi.positioned_sound (ent->s.origin, g_edicts, CHAN_AUTO, gi.soundindex("weapons/gundrop.wav"), vol, ATTN_NORM, 0);			
			}
			ent->playedsound = true;
		}
		return;
	}
	if (other->health < 1)
		return;		// dead people can't pickup
	if (!ent->item->pickup)
		return;		// not a grabbable item?
	if (other->client->resp.autopickup == false && ent->item->classnameb != HGRENADE)
		return;


	if (other->client && other->client->resp.mos == MEDIC)
	{
		if (!( 
				(ent->item->tag && ent->item->tag == AMMO_TYPE_PISTOL) ||
				(ent->item->position && ent->item->position == LOC_PISTOL) ||
				(ent->item->pickup_name && !Q_stricmp(ent->item->pickup_name,"Knife")) ||
				(ent->item->pickup_name && !Q_stricmp(ent->item->pickup_name,"Helmet")) 
			))
			return;
	}

	//pbowens: you can only have 1 helmet
	if (ent->item->pickup_name && !Q_stricmp(ent->item->pickup_name, "Helmet") )
	{
		if (other->client->pers.inventory[ITEM_INDEX(ent->item)])
		{
//			safe_cprintf(other, PRINT_HIGH, "You already have a helmet!\n");
			return;
		}
	}

	// you cannot pickup more than 1 team weapon
	if (ent->item->guninfo && other->client->pers.inventory[ITEM_INDEX(ent->item)])
		return;

//faf	if (ent->item->position != LOC_GRENADES && ent->count > 1 &&
//faf		other->client->pers.inventory[ITEM_INDEX(ent->item)] ) // dont pick up if ammo already
//faf		return;

	taken = ent->item->pickup(ent, other);

	if (taken)
	{
		// flash the screen
		//other->client->bonus_alpha = 0.25;	

		// show icon and name on status bar
		other->client->ps.stats[STAT_PICKUP_ICON] = gi.imageindex(ent->item->icon);
		other->client->ps.stats[STAT_PICKUP_STRING] = CS_ITEMS+ITEM_INDEX(ent->item);

		other->client->pickup_msg_time = level.time + 3.0;

		// change selected item
		//if (ent->item->use)
		//	other->client->pers.selected_item = other->client->ps.stats[STAT_SELECTED_ITEM] = ITEM_INDEX(ent->item);

		gi.sound(other, CHAN_ITEM, gi.soundindex(ent->item->pickup_sound), 1, ATTN_NORM, 0);
	}

	if (!(ent->spawnflags & ITEM_TARGETS_USED))
	{
		G_UseTargets (ent, other);
		ent->spawnflags |= ITEM_TARGETS_USED;
	}

	if (!taken)
		return;

	if (!((coop->value) &&  (ent->item->flags & IT_STAY_COOP)) || (ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)))
	{
		if (ent->flags & FL_RESPAWN)
			ent->flags &= ~FL_RESPAWN;
		else
			G_FreeEdict (ent);
	}

}
Пример #4
0
qboolean Pickup_Pack (edict_t *ent, edict_t *other)
{
	gitem_t	*item;
	int		index;

	if (other->client->pers.max_bullets < 300)
		other->client->pers.max_bullets = 300;
	if (other->client->pers.max_shells < 200)
		other->client->pers.max_shells = 200;
	if (other->client->pers.max_rockets < 100)
		other->client->pers.max_rockets = 100;
	if (other->client->pers.max_grenades < 2)
		other->client->pers.max_grenades = 2;
//bcass start - TNT
	if (other->client->pers.max_tnt < 1)
		other->client->pers.max_tnt = 1;
//bcass end
	if (other->client->pers.max_30cal < 300)
		other->client->pers.max_30cal = 300;
	if (other->client->pers.max_slugs < 100)
		other->client->pers.max_slugs = 100;

	item = FindItem("Bullets");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_bullets)
			other->client->pers.inventory[index] = other->client->pers.max_bullets;
	}

	item = FindItem("Shells");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_shells)
			other->client->pers.inventory[index] = other->client->pers.max_shells;
	}

	item = FindItem("Cells");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_30cal)
			other->client->pers.inventory[index] = other->client->pers.max_30cal;
	}

	item = FindItem("Grenades");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_grenades)
			other->client->pers.inventory[index] = other->client->pers.max_grenades;
	}

	item = FindItem("Mk 2 Grenade");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_grenades)
			other->client->pers.inventory[index] = other->client->pers.max_grenades;

	}

	item = FindItem("M24 Grenade");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_grenades)
			other->client->pers.inventory[index] = other->client->pers.max_grenades;
	}

	item = FindItem("Rockets");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_rockets)
			other->client->pers.inventory[index] = other->client->pers.max_rockets;
	}

	item = FindItem("Slugs");
	if (item)
	{
		index = ITEM_INDEX(item);
		other->client->pers.inventory[index] += item->quantity;
		if (other->client->pers.inventory[index] > other->client->pers.max_slugs)
			other->client->pers.inventory[index] = other->client->pers.max_slugs;
	}


	if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
		SetRespawn (ent, ent->item->quantity);

	return true;
}
Пример #5
0
qboolean Pickup_Armor (edict_t *ent, edict_t *other)
{
			// change armor to new item with computed value
			other->client->pers.inventory[ITEM_INDEX(ent->item)] = 1;
			return true;
}
Пример #6
0
void G_SetStats (edict_t *ent)
{
	gitem_t		*item;
//	int			num;
	int			index, cells;
	int			power_armor_type = 0;

//	int			time_left;//K03

	//
	// health
	//


	ent->client->ps.stats[STAT_HEALTH_ICON] = level.pic_health;

	if (ent->health <= 32767)
		ent->client->ps.stats[STAT_HEALTH] = ent->health;
	else
		ent->client->ps.stats[STAT_HEALTH] = 666;

//GHz START
	// 3.5 show percent ability is charged
	if (ent->client->charge_index)
		ent->client->ps.stats[STAT_CHARGE_LEVEL] = ent->myskills.abilities[ent->client->charge_index-1].charge;
	else
		ent->client->ps.stats[STAT_CHARGE_LEVEL] = 0;

	if (G_EntExists(ent->supplystation) /*&& (ent->supplystation->wait >= level.time)*/)
	{
		ent->client->ps.stats[STAT_STATION_ICON] = gi.imageindex("i_tele");
		//if (ent->supplystation->wait < 100)
			ent->client->ps.stats[STAT_STATION_TIME] = (int)ent->supplystation->wait;//-level.time;
		//else
		//	ent->client->ps.stats[STAT_STATION_TIME] = 0;
	}
	else
	{
		ent->client->ps.stats[STAT_STATION_ICON] = 0;
		ent->client->ps.stats[STAT_STATION_TIME] = 0;
	}

	if (ptr->value || domination->value)
	{
		//if (G_EntExists(ent))
		if (ent->inuse && ent->teamnum)
		{
			index = 0;
			if (ent->teamnum == 1)
			{
				if (DEFENSE_TEAM == ent->teamnum)
					index =  gi.imageindex("i_ctf1"); // show team color pic
				else
					index = gi.imageindex("i_ctf1d"); // not in control
			}
			else if (ent->teamnum == 2)
			{
				if (DEFENSE_TEAM == ent->teamnum)
					index = gi.imageindex("i_ctf2");
				else
					index = gi.imageindex("i_ctf2d");
			}
			ent->client->ps.stats[STAT_TEAM_ICON] = index;
		}
		else
		{
			ent->client->ps.stats[STAT_TEAM_ICON] = 0;
		}

	}

	if (ctf->value)
	{
		if (ent->inuse && ent->teamnum)
		{
			edict_t *base;
			index = 0;

			if ((base = CTF_GetFlagBaseEnt(ent->teamnum)) != NULL)
			{
				if (ent->teamnum == RED_TEAM)
				{
					if (base->count == BASE_FLAG_SECURE)
						index =  gi.imageindex("i_ctf1"); // show team color pic
					else
					{
						if (level.framenum&8)
							index = gi.imageindex("i_ctf1d"); // flag taken
						else
							index = gi.imageindex("i_ctf1");
					}
				}
				else if (ent->teamnum == BLUE_TEAM)
				{
					if (base->count == BASE_FLAG_SECURE)
						index = gi.imageindex("i_ctf2");
					else
					{
						if (level.framenum&8)
							index = gi.imageindex("i_ctf2d");
						else
							index = gi.imageindex("i_ctf2");
					}
				}
			}
			ent->client->ps.stats[STAT_TEAM_ICON] = index;
		}
		else
		{
			ent->client->ps.stats[STAT_TEAM_ICON] = 0;
		}
	}
//GHz END

	// player boss
	if (G_EntExists(ent->owner))
		ent->client->ps.stats[STAT_HEALTH] = ent->owner->health;

	//
	// ammo
	//
	if (!ent->client->ammo_index /* || !ent->client->pers.inventory[ent->client->ammo_index] */)
	{
		ent->client->ps.stats[STAT_AMMO_ICON] = 0;
		ent->client->ps.stats[STAT_AMMO] = 0;
	}
	else
	{
		item = &itemlist[ent->client->ammo_index];
		ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex (item->icon);
		ent->client->ps.stats[STAT_AMMO] = ent->client->pers.inventory[ent->client->ammo_index];
	}
//GHz START
	// blaster weapon ammo
	if (ent->client->pers.weapon == Fdi_BLASTER)
	{
		ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex("a_cells");
		ent->client->ps.stats[STAT_AMMO] = ent->monsterinfo.lefty;
	}
//GHz END

	//
	// armor
	//

	power_armor_type = PowerArmorType (ent);

	if (power_armor_type)
	{
		cells = ent->client->pers.inventory[ITEM_INDEX(Fdi_CELLS)];

		if (cells == 0)
		{	// ran out of cells for power armor
			ent->flags &= ~FL_POWER_ARMOR;
			gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/power2.wav"), 1, ATTN_NORM, 0);
			power_armor_type = 0;
		}
	}

	index = ArmorIndex (ent);
	if (power_armor_type && (!index || ent->mtype || (level.framenum & 8) ) )//4.2 morphed players only have powered armor
	{	// flash between power armor and other armor icon
		ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex ("i_powershield");
		ent->client->ps.stats[STAT_ARMOR] = cells;
	}
	else if (index && !ent->mtype)
	{
		item = GetItemByIndex (index);
		ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex (item->icon);
		ent->client->ps.stats[STAT_ARMOR] = ent->client->pers.inventory[index];
	}
	else
	{
		ent->client->ps.stats[STAT_ARMOR_ICON] = 0;
		ent->client->ps.stats[STAT_ARMOR] = 0;
	}

	// morphed players
	if (ent->mtype)
	{
		if ((ent->mtype == MORPH_MEDIC) && (ent->client->weapon_mode == 0 || ent->client->weapon_mode == 2))
		{
			ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex("a_cells");
			ent->client->ps.stats[STAT_AMMO] = ent->myskills.abilities[MEDIC].ammo;
		}
		else if (ent->mtype == MORPH_FLYER)
		{
			ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex("a_cells");
			ent->client->ps.stats[STAT_AMMO] = ent->myskills.abilities[FLYER].ammo;
		}
		else if (ent->mtype == MORPH_CACODEMON)
		{
			ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex("a_rockets");
			ent->client->ps.stats[STAT_AMMO] = ent->myskills.abilities[CACODEMON].ammo;
		}
		else
		{
			ent->client->ps.stats[STAT_AMMO_ICON] = 0;
			ent->client->ps.stats[STAT_AMMO] = 0;
		}

	}
	
	// player-monsters
	if (PM_PlayerHasMonster(ent))
	{
		if (ent->owner->mtype == P_TANK)
		{
			if (ent->client->weapon_mode == 0)
			{
				ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex("a_rockets");
				ent->client->ps.stats[STAT_AMMO] = ent->owner->monsterinfo.jumpup;
			}
			else if (ent->client->weapon_mode == 2)
			{
				ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex("a_bullets");
				ent->client->ps.stats[STAT_AMMO] = ent->owner->monsterinfo.lefty;
			}
			else if (ent->client->weapon_mode == 3)
			{
				ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex("a_cells");
				ent->client->ps.stats[STAT_AMMO] = ent->owner->monsterinfo.radius;
			}
			else
			{
				ent->client->ps.stats[STAT_AMMO_ICON] = 0;
				ent->client->ps.stats[STAT_AMMO] = 0;
			}
			
			if (power_armor_type)
			{
				ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex ("i_powershield");
				ent->client->ps.stats[STAT_ARMOR] = cells;
			}
			else
			{
				ent->client->ps.stats[STAT_ARMOR_ICON] = 0;
				ent->client->ps.stats[STAT_ARMOR] = 0;
			}
			
		}
		else
		{
			ent->client->ps.stats[STAT_AMMO_ICON] = 0;
			ent->client->ps.stats[STAT_AMMO] = 0;
		}
	}

	//
	// pickup message
	//
	if (level.time > ent->client->pickup_msg_time)
	{
		ent->client->ps.stats[STAT_PICKUP_ICON] = 0;
		ent->client->ps.stats[STAT_PICKUP_STRING] = 0;
	}

	//
	// timers
	//
	if (ent->client->quad_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_quad");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->quad_framenum - level.framenum)/10;
	}
	// RAFAEL
	else if (ent->client->quadfire_framenum > level.framenum)
	{
		// note to self
		// need to change imageindex
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_quadfire");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->quadfire_framenum - level.framenum)/10;
	}
	else if (ent->client->invincible_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_invulnerability");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->invincible_framenum - level.framenum)/10;
	}
	else if (ent->client->enviro_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_envirosuit");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->enviro_framenum - level.framenum)/10;
	}
	else if (ent->client->breather_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_rebreather");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->breather_framenum - level.framenum)/10;
	}
	//K03 Begin
	else if (ent->client->thrusting == 1 ||
		ent->client->cloakable ||
		ent->client->hook_state)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("k_powercube");
		ent->client->ps.stats[STAT_TIMER] = ent->client->pers.inventory[power_cube_index];
	}
	//K03 End
	else
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = 0;
		ent->client->ps.stats[STAT_TIMER] = 0;
	}

	//
	// selected item
	//
	if (ent->client->pers.selected_item == -1)
		ent->client->ps.stats[STAT_SELECTED_ICON] = 0;
	else
		ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex (itemlist[ent->client->pers.selected_item].icon);

	ent->client->ps.stats[STAT_SELECTED_ITEM] = ent->client->pers.selected_item;

	//
	// layouts
	//
	ent->client->ps.stats[STAT_LAYOUTS] = 0;

	if (deathmatch->value)
	{
		if (ent->client->pers.health <= 0 || level.intermissiontime
			|| ent->client->showscores || ent->client->pers.scanner_active)
			ent->client->ps.stats[STAT_LAYOUTS] |= 1;
		if (ent->client->showinventory && ent->client->pers.health > 0)
			ent->client->ps.stats[STAT_LAYOUTS] |= 2;
	}
	else
	{
		if (ent->client->showscores || ent->client->showhelp)
			ent->client->ps.stats[STAT_LAYOUTS] |= 1;
		if (ent->client->showinventory && ent->client->pers.health > 0)
			ent->client->ps.stats[STAT_LAYOUTS] |= 2;
	}

	//
	// frags
	//
	ent->client->ps.stats[STAT_FRAGS] = ent->client->resp.score;

	//
	// help icon / current weapon if not shown
	//
	if (ent->client->resp.helpchanged && (level.framenum&8) )
		ent->client->ps.stats[STAT_HELPICON] = gi.imageindex ("i_help");
	else if ( (ent->client->pers.hand == CENTER_HANDED || ent->client->ps.fov > 91)
		&& ent->client->pers.weapon)
		ent->client->ps.stats[STAT_HELPICON] = gi.imageindex (ent->client->pers.weapon->icon);
	else
		ent->client->ps.stats[STAT_HELPICON] = 0;

//ponpoko
	/*K03 if(ent->client->zc.aiming == 1)
	{
		ent->client->ps.stats[STAT_SIGHT_PIC] = gi.imageindex ("zsight");
	}
	else if(ent->client->zc.aiming == 3)
	{
		if(ent->client->zc.lockon) ent->client->ps.stats[STAT_SIGHT_PIC] = gi.imageindex ("zsight_l1");
		else ent->client->ps.stats[STAT_SIGHT_PIC] = gi.imageindex ("zsight_l0");
	}
	else ent->client->ps.stats[STAT_SIGHT_PIC] = 0;*/
//ponpoko

	//K03 Begin
	//ent->client->ps.stats[STAT_LEVEL] = ent->myskills.level;
	ent->client->ps.stats[STAT_STREAK] = ent->myskills.streak;

	/*if (timelimit->value)
		time_left = (timelimit->value*60 - level.time);
	else
		time_left = 60*99;

	ent->client->ps.stats[STAT_TIMEMIN] = (int)(time_left/60);*/
	ent->client->ps.stats[STAT_TIMEMIN] = ent->client->pers.inventory[power_cube_index];
	if (ent->client->ps.stats[STAT_TIMEMIN] < 0)
		ent->client->ps.stats[STAT_TIMEMIN] = 0;
	
	

	if (ent->client->pers.selected_item == -1)
		ent->client->ps.stats[STAT_SELECTED_NUM] = 0;
	else
		ent->client->ps.stats[STAT_SELECTED_NUM] = ent->client->pers.inventory[ent->client->pers.selected_item];
	//K03 End

	//GHz Begin
	V_PlayerID(ent, NULL);
	// id code
	//GHz End
//GHz START
	if ((ent->myskills.abilities[ID].disable) || (!ent->myskills.abilities[ID].current_level) || (level.time > ent->lastdmg+2))
		ent->client->ps.stats[STAT_ID_DAMAGE] = 0;
//GHz END

}
Пример #7
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;
}
Пример #8
0
qboolean dom_pickupflag (edict_t *ent, edict_t *other)
{
	int		i;
	edict_t *cl_ent;

	//if (!G_EntExists(other))
	//	return false;
	if (!other || !other->inuse || !other->client || G_IsSpectator(other))
		return false;

	//if ((other->myskills.class_num == CLASS_POLTERGEIST) || other->mtype)
	//	return false; // poltergeist and morphed players can't pick up flag

	// unmorph morphed players
	if (other->mtype)
	{
		other->mtype = 0;
		other->s.modelindex = 255;
		other->s.skinnum = ent-g_edicts-1;
		ShowGun(other);
	}
	
	// if this is a player-monster, remove the monster and restore the player
	if (PM_PlayerHasMonster(other))
		PM_RemoveMonster(other);

	// disable movement abilities
	//jetpack
	other->client->thrusting = 0;
	//grapple hook
	other->client->hook_state = HOOK_READY;
	// super speed
	other->superspeed = false;

	// disable scanner
	if (other->client->pers.scanner_active & 1)
		other->client->pers.scanner_active = 0;

	// reset their velocity
	VectorClear(other->velocity);

	// alert everyone
	gi.bprintf(PRINT_HIGH, "%s got the flag!\n", other->client->pers.netname);
	gi.bprintf(PRINT_HIGH, "The %s team is now in control.\n", TeamName(other));

	// alert teammates
	for (i=0 ; i<game.maxclients ; i++) {
		cl_ent = g_edicts+1+i;
		if (G_EntExists(cl_ent) && (cl_ent->teamnum == other->teamnum) && (cl_ent != other))
			gi.centerprintf(cl_ent, "Protect the flag carrier!\n");
	}

	DEFENSE_TEAM = other->teamnum;

	// if a new team takes control of the flag, then reset the counter
	if (PREV_DEFENSE_TEAM != DEFENSE_TEAM)
		FLAG_FRAMES = 0;

	PREV_DEFENSE_TEAM = DEFENSE_TEAM;

	gi.sound(other, CHAN_ITEM, gi.soundindex("world/xianbeats.wav"), 1, ATTN_NORM, 0);
	other->client->pers.inventory[ITEM_INDEX(ent->item)] = 1;
	return true;
}
Пример #9
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (edict_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			index;
	int			i;
	qboolean	give_all;
	edict_t		*it_ent;

	if (deathmatch->value && !sv_cheats->value)
	{
		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	name = gi.args();

	if (Q_stricmp(name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3)
			ent->health = atoi(gi.argv(2));
		else
			ent->health = ent->max_health;
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		gitem_armor_t	*info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Power Shield") == 0)
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	}

	it = FindItem (name);
	if (!it)
	{
		name = gi.argv(1);
		it = FindItem (name);
		if (!it)
		{
			gi.dprintf ("unknown item\n");
			return;
		}
	}

	if (!it->pickup)
	{
		gi.dprintf ("non-pickup item\n");
		return;
	}

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (gi.argc() == 3)
			ent->client->pers.inventory[index] = atoi(gi.argv(2));
		else
			ent->client->pers.inventory[index] += it->quantity;
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);
	}
}
Пример #10
0
/*
===============
ChangeWeapon

The old weapon has been dropped all the way, so make the new one
current
===============
*/
void ChangeWeapon (edict_t *ent)
{
	int i;

	//WF
	if(Lithium_IsObserver(ent)) {
		ent->client->ps.gunindex = 0;
		return;
	}
	//WF

	if (ent->client->grenade_time)
	{
		ent->client->grenade_time = level.time;
		ent->client->weapon_sound = 0;
		weapon_grenade_fire (ent, false);
		ent->client->grenade_time = 0;
	}

	ent->client->pers.lastweapon = ent->client->pers.weapon;
	ent->client->pers.weapon = ent->client->newweapon;
	ent->client->newweapon = NULL;
	ent->client->machinegun_shots = 0;

	// set visible model
	if (ent->s.modelindex == 255) {
		if (ent->client->pers.weapon)
			i = ((ent->client->pers.weapon->weapmodel & 0xff) << 8);
		else
			i = 0;
		ent->s.skinnum = (ent - g_edicts - 1) | i;
	}

	if (ent->client->pers.weapon && ent->client->pers.weapon->ammo)
		ent->client->ammo_index = ITEM_INDEX(FindItem(ent->client->pers.weapon->ammo));
	else
		ent->client->ammo_index = 0;

	if (!ent->client->pers.weapon)
	{	// dead
		ent->client->ps.gunindex = 0;
		return;
	}

	ent->client->weaponstate = WEAPON_ACTIVATING;
	ent->client->ps.gunframe = 0;
	ent->client->ps.gunindex = gi.modelindex(ent->client->pers.weapon->view_model);

	ent->client->anim_priority = ANIM_PAIN;
	if(ent->client->ps.pmove.pm_flags & PMF_DUCKED)
	{
			ent->s.frame = FRAME_crpain1;
			ent->client->anim_end = FRAME_crpain4;
	}
	else
	{
			ent->s.frame = FRAME_pain301;
			ent->client->anim_end = FRAME_pain304;
			
	}
}
Пример #11
0
/*
=================
NoAmmoWeaponChange
=================
*/
void NoAmmoWeaponChange (edict_t *ent)
{
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("slugs"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("railgun"))] )
	{
		ent->client->newweapon = FindItem ("railgun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("cells"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("hyperblaster"))] )
	{
		ent->client->newweapon = FindItem ("hyperblaster");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("chaingun"))] )
	{
		ent->client->newweapon = FindItem ("chaingun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("machinegun"))] )
	{
		ent->client->newweapon = FindItem ("machinegun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))] > 1
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("super shotgun"))] )
	{
		ent->client->newweapon = FindItem ("super shotgun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("shotgun"))] )
	{
		ent->client->newweapon = FindItem ("shotgun");
		return;
	}
	ent->client->newweapon = FindItem ("blaster");
}
Пример #12
0
/*QUAKED trigger_key (.5 .5 .5) (-8 -8 -8) (8 8 8)
A relay trigger that only fires it's targets if player has the proper key.
Use "item" to specify the required key, for example "key_data_cd"
*/
void trigger_key_use (edict_t *self, edict_t *other, edict_t *activator)
{
    int			index;

    if (!self->item)
        return;
    if (!activator->client)
        return;

    index = ITEM_INDEX(self->item);
    if (!activator->client->pers.inventory[index])
    {
        if (level.time < self->touch_debounce_time)
            return;
        self->touch_debounce_time = level.time + 5.0;
        gi.centerprintf (activator, "You need the %s", self->item->pickup_name);
        gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/keytry.wav"), 1, ATTN_NORM, 0);
        return;
    }

    gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/keyuse.wav"), 1, ATTN_NORM, 0);
    if (coop->value)
    {
        int		player;
        edict_t	*ent;

        if (strcmp(self->item->classname, "key_power_cube") == 0)
        {
            int	cube;

            for (cube = 0; cube < 8; cube++)
                if (activator->client->pers.power_cubes & (1 << cube))
                    break;
            for (player = 1; player <= game.maxclients; player++)
            {
                ent = &g_edicts[player];
                if (!ent->inuse)
                    continue;
                if (!ent->client)
                    continue;
                if (ent->client->pers.power_cubes & (1 << cube))
                {
                    ent->client->pers.inventory[index]--;
                    ent->client->pers.power_cubes &= ~(1 << cube);
                }
            }
        }
        else
        {
            for (player = 1; player <= game.maxclients; player++)
            {
                ent = &g_edicts[player];
                if (!ent->inuse)
                    continue;
                if (!ent->client)
                    continue;
                ent->client->pers.inventory[index] = 0;
            }
        }
    }
    else
    {
        activator->client->pers.inventory[index]--;
    }

    G_UseTargets (self, activator);

    self->use = NULL;
}
Пример #13
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
static void Cmd_Give_f(edict_t *ent)
{
    char        *name;
    gitem_t     *it;
    int         index;
    int         i;
    bool        give_all;
    edict_t     *it_ent;

    if (!CheckCheats(ent)) {
        return;
    }

    name = gi.args();

    if (Q_stricmp(name, "all") == 0)
        give_all = true;
    else
        give_all = false;

    if (give_all || Q_stricmp(gi.argv(1), "health") == 0) {
        if (gi.argc() == 3)
            ent->health = atoi(gi.argv(2));
        else
            ent->health = ent->max_health;
        if (!give_all)
            return;
    }

    if (give_all || Q_stricmp(name, "weapons") == 0) {
        for (i = 0; i < ITEM_TOTAL; i++) {
            it = INDEX_ITEM(i);
            if (!it->pickup)
                continue;
            if (!(it->flags & IT_WEAPON))
                continue;
            ent->client->inventory[i] += 1;
        }
        if (!give_all)
            return;
    }

    if (give_all || Q_stricmp(name, "ammo") == 0) {
        for (i = 0; i < ITEM_TOTAL; i++) {
            it = INDEX_ITEM(i);
            if (!it->pickup)
                continue;
            if (!(it->flags & IT_AMMO))
                continue;
            Add_Ammo(ent, it, 1000);
        }
        if (!give_all)
            return;
    }

    if (give_all || Q_stricmp(name, "armor") == 0) {
        gitem_armor_t   *info;

        ent->client->inventory[ITEM_ARMOR_JACKET] = 0;

        ent->client->inventory[ITEM_ARMOR_COMBAT] = 0;

        it = INDEX_ITEM(ITEM_ARMOR_BODY);
        info = (gitem_armor_t *)it->info;
        ent->client->inventory[ITEM_ARMOR_BODY] = info->max_count;

        if (!give_all)
            return;
    }

    if (give_all || Q_stricmp(name, "Power Shield") == 0) {
        it = INDEX_ITEM(ITEM_POWER_SHIELD);
        it_ent = G_Spawn();
        it_ent->classname = it->classname;
        SpawnItem(it_ent, it);
        if (it_ent->inuse) {
            Touch_Item(it_ent, ent, NULL, NULL);
            if (it_ent->inuse)
                G_FreeEdict(it_ent);
        }

        if (!give_all)
            return;
    }

    if (give_all) {
        for (i = 0; i < ITEM_TOTAL; i++) {
            it = INDEX_ITEM(i);
            if (!it->pickup)
                continue;
            if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO))
                continue;
            ent->client->inventory[i] = 1;
        }
        return;
    }

    it = FindItem(name);
    if (!it) {
        name = gi.argv(1);
        it = FindItem(name);
        if (!it) {
            gi.cprintf(ent, PRINT_HIGH, "unknown item\n");
            return;
        }
    }

    if (!it->pickup) {
        gi.cprintf(ent, PRINT_HIGH, "non-pickup item\n");
        return;
    }

    index = ITEM_INDEX(it);

    if (it->flags & IT_AMMO) {
        if (gi.argc() == 3)
            ent->client->inventory[index] = atoi(gi.argv(2));
        else
            ent->client->inventory[index] += it->quantity;
    } else {
        it_ent = G_Spawn();
        it_ent->classname = it->classname;
        SpawnItem(it_ent, it);
        if (it_ent->inuse) {
            Touch_Item(it_ent, ent, NULL, NULL);
            if (it_ent->inuse)
                G_FreeEdict(it_ent);
        }
    }
}
Пример #14
0
/*
==============
TDM_SetInitialItems
==============
Give a client an initial weapon/item loadout depending on match mode
*/
void TDM_SetInitialItems (edict_t *ent)
{
    gclient_t		*client;
    const gitem_t	*item;
    int				i;

    client = ent->client;


    client->max_bullets		= 200;
    client->max_shells		= 100;
    client->max_rockets		= 50;
    client->max_grenades	= 50;
    client->max_cells		= 200;
    client->max_slugs		= 50;

    switch (tdm_match_status)
    {
    case MM_WARMUP:
        //wision: spawn with rail in insta
        if (g_gamemode->value == GAMEMODE_ITDM)
        {
            item = GETITEM (ITEM_WEAPON_RAILGUN);
            Add_Ammo (ent, GETITEM(item->ammoindex), 1000);
            client->weapon = item;
            client->selected_item = ITEM_INDEX(item);
            client->inventory[client->selected_item] = 1;
        }
        else
        {
            for (i = 1; i < game.num_items; i++)
            {
                item = GETITEM (i);
                //wision: BFG sucks in warmup :X
                if ((item->flags & IT_WEAPON) && i != ITEM_WEAPON_BFG)
                {
                    client->inventory[i] = 1;
                    if (item->ammoindex)
                        Add_Ammo (ent, GETITEM(item->ammoindex), 1000);
                }
            }

            //spawn with RL up
            if (!client->pers.last_weapon || client->inventory[ITEM_INDEX (client->pers.last_weapon)] == 0)
            {
                client->selected_item = ITEM_WEAPON_ROCKETLAUNCHER;
                client->weapon = GETITEM (ITEM_WEAPON_ROCKETLAUNCHER);
            }
            else
            {
                client->weapon = client->pers.last_weapon;
                client->selected_item = ITEM_INDEX (client->pers.last_weapon);
            }
        }
        client->inventory[ITEM_ITEM_ARMOR_BODY] = 100;
        break;

    default:
        //wision: spawn with rail in insta
        if (g_gamemode->value == GAMEMODE_ITDM)
        {
            item = GETITEM (ITEM_WEAPON_RAILGUN);
            Add_Ammo (ent, GETITEM(item->ammoindex), 1000);
        }
        else
            item = GETITEM (ITEM_WEAPON_BLASTER);
        client->weapon = item;
        client->selected_item = ITEM_INDEX(item);
        client->inventory[client->selected_item] = 1;
        break;
    }
}
Пример #15
0
static int CheckArmor (edict_t *ent, edict_t *attacker, vec3_t point, vec3_t normal, int damage, int te_sparks, int dflags, int mod, qboolean mod_magic) {
	gclient_t	*client;
	float armor_save = 0;
	float pierce = 0;
	float breaker = 1.0;
	int			save;
	float		armoraff;
	int			armoraffsave;
	int			index;
	iteminfo_t *ainfo = NULL;

	if (!damage)
		return 0;

	client = ent->client;

	if (!client)
		return 0;
	ainfo = getWornItemInfo(ent, 1);

	if (dflags & DAMAGE_NO_ARMOR)
		return 0;

	if (ent->health <= 0)
		return 0;

	index = ITEM_INDEX(FindItem("Body Armor"));
	if (!index)
		return 0;

	if (attacker->client && attacker->client->pers.skill[2] > 0) { // Armor piercing
		int item = getWornItem(attacker, GIEX_ITEM_WEAPON);
		if (mod == MOD_BLASTER) {
			iteminfo_t *winfo = getWornItemInfo(attacker, GIEX_ITEM_WEAPON);
			pierce = getBlasterPierce(attacker, item, winfo);//winfo->arg4 + winfo->arg5 * attacker->client->pers.skill[2];
		} else if (!mod_magic) {
			pierce = getWeaponPierce(attacker, item);
		}
	}
	if (attacker->client && (attacker->client->pers.skill[71] > 0) && (!mod_magic)) { // Armor breaker (extra damage to armor)
		breaker += 0.05 * attacker->client->pers.skill[71];
	}

	if (dflags & DAMAGE_25_PIERCE) {
		pierce += 0.25;
	} else if (dflags & DAMAGE_50_PIERCE) {
		pierce += 0.5;
	} else if (dflags & DAMAGE_75_PIERCE) {
		pierce += 0.75;
	} else if (dflags & DAMAGE_100_PIERCE) {
		pierce += 1.0;
	}

	if ((attacker->svflags & SVF_MONSTER) && (attacker->monsterinfo.ability & GIEX_MABILITY_ARMORPIERCE)) {
		pierce += 0.5;
	}

	armor_save = ainfo->arg3 + ainfo->arg4 * client->pers.skill[23]/* + 0.002 * pow(ent->client->pers.skills.classLevel[1], 1.2)*/ - pierce;
	if (armor_save > 1)
		armor_save = 1;
	if (armor_save <= 0)
		return 0;

	save = ceil(armor_save * damage * breaker);
	if (save < 1) {
		return 0;
	}

	armoraff = 0.015 * client->pers.skill[44];
	if (armoraff > 0.8)
		armoraff = 0.8;
	armoraffsave = (int) ceil(save * armoraff);
	if (armoraffsave > 0) {
		if (armoraff > 0.5) {
			if ((client->silencer_shots > 0) && (client->pers.skill[58] > 5)) {
				client->silencer_shots -= 1;
			} else {
				gi.sound(ent, CHAN_ITEM, gi.soundindex("giex/magarm2.wav"), 1, ATTN_NORM, 0);
			}
		} else if (armoraff > 0.25) {
			if ((client->silencer_shots > 0) && (client->pers.skill[58] > 5)) {
				client->silencer_shots -= 1;
			} else {
				gi.sound(ent, CHAN_ITEM, gi.soundindex("giex/magarm1.wav"), 1, ATTN_NORM, 0);
			}
		}
	}

	save -= armoraffsave;
	if (save >= client->pers.inventory[index])
		save = client->pers.inventory[index];

	if (!save) {
		if (armoraffsave > 0)
			return 1;
		return 0;
	}
	client->pers.inventory[index] -= save;
	SpawnDamage (te_sparks, point, normal, save);

	return (int) ((save + armoraffsave) / breaker);
}
Пример #16
0
/*
============
T_Damage
 
targ		entity that is being damaged
inflictor	entity that is causing the damage
attacker	entity that caused the inflictor to damage targ
	example: targ=monster, inflictor=rocket, attacker=player
 
dir			direction of the attack
point		point at which the damage is being inflicted
normal		normal vector from that point
damage		amount of damage being inflicted
knockback	force to be applied against targ as a result of the damage
 
dflags		these flags are used to control how T_Damage works
	DAMAGE_RADIUS			damage was indirect(from a nearby explosion)
	DAMAGE_NO_ARMOR			armor does not protect from this damage
	DAMAGE_ENERGY			damage is from an energy based weapon
	DAMAGE_NO_KNOCKBACK		do not affect velocity, just view angles
	DAMAGE_BULLET			damage is from a bullet(used for ricochets)
	DAMAGE_NO_PROTECTION	kills godmode, armor, everything
============
*/
static int CheckPowerArmor(edict_t *ent, vec3_t point, vec3_t normal, int damage, int dflags){
	gclient_t	*client;
	int	save;
	int	power_armor_type;
	int	index = -1;
	int	damagePerCell;
	int	pa_te_type;
	int	power = 0;
	int	power_used;
	
	if(!damage)
		return 0;
		
	client = ent->client;
	
	if(dflags & DAMAGE_NO_ARMOR)
		return 0;
		
	if(client){
		power_armor_type = PowerArmorType(ent);
		if(power_armor_type != POWER_ARMOR_NONE){
			index = ITEM_INDEX(FindItem("Cells"));
			power = client->pers.inventory[index];
		}
	} else if(ent->svflags & SVF_MONSTER){
		power_armor_type = ent->monsterinfo.power_armor_type;
		power = ent->monsterinfo.power_armor_power;
	} else
		return 0;
		
	if(power_armor_type == POWER_ARMOR_NONE)
		return 0;
	if(!power)
		return 0;
		
	if(power_armor_type == POWER_ARMOR_SCREEN){
		vec3_t	vec;
		float	dot;
		vec3_t	forward;
		
		// only works if damage point is in front
		AngleVectors(ent->s.angles, forward, NULL, NULL);
		VectorSubtract(point, ent->s.origin, vec);
		VectorNormalize(vec);
		dot = DotProduct(vec, forward);
		if(dot <= 0.3)
			return 0;
			
		damagePerCell = 1;
		pa_te_type = TE_SCREEN_SPARKS;
		damage = damage / 3;
	} else {
		damagePerCell = 1; // power armor is weaker in CTF
		pa_te_type = TE_SHIELD_SPARKS;
		damage =(2 * damage) / 3;
	}
	
	save = power * damagePerCell;
	if(!save)
		return 0;
	if(save > damage)
		save = damage;
		
	SpawnDamage(pa_te_type, point, normal, save);
	ent->powerarmor_time = level.time + 0.2;
	
	power_used = save / damagePerCell;
	
	if(client)
		client->pers.inventory[index] -= power_used;
	else
		ent->monsterinfo.power_armor_power -= power_used;
	return save;
}
Пример #17
0
qboolean Pickup_Weapon (edict_t *ent, edict_t *other)
{
	int			index;
	gitem_t		*ammo;
	gclient_t	*client;

	// Make sure ent exists!
  if (!G_EntExists(other)) return false;


	if (other->client)
		client = other->client;
	else
		return false;


	index = ITEM_INDEX(ent->item);

	if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) 
		&& other->client->pers.inventory[index])
	{
		if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) )
			return false;	// leave the weapon for others to pickup
	}

	if ((ent->spawnflags & DROPPED_PLAYER_ITEM) && (ent->item->flags & IT_WEAPON))
	{
		if (!(dmflag & DF_WEAPONS_STAY))
			client->pers.inventory[index]++;
	}
	else
		client->pers.inventory[index]++;

	if (!(ent->spawnflags & DROPPED_ITEM) )
	{
		// give them some ammo with it
		ammo = FindItem (ent->item->ammo);
		if (! ( dmflag & DF_INFINITE_AMMO ) )
		{
			Add_Ammo (other, ammo, ammo->quantity);
		}
		else
		{
			Add_Ammo (other, ammo, 1000);
		}

		if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) )
		{
			if (deathmatch->value)
			{
				if ((int)(dmflags->value) & DF_WEAPONS_STAY)
					ent->flags |= FL_RESPAWN;
				else
					SetRespawn (ent, spawn_time->value);//RAV
			}
			if (coop->value)
				ent->flags |= FL_RESPAWN;
		}
	}

	if (client->pers.weapon != ent->item && 
		(other->client->pers.inventory[index] == 1) &&
		( !deathmatch->value || client->pers.weapon == FindItem("blaster") ) )
		client->newweapon = ent->item;

	return true;
}
Пример #18
0
/*
 * Give items to a client
 */
void
Cmd_Give_f(edict_t *ent)
{
	char *name;
	gitem_t *it;
	int index;
	int i;
	qboolean give_all;
	edict_t *it_ent;

	if (!ent)
	{
		return;
	}

	if ((deathmatch->value || coop->value) && !sv_cheats->value)
	{
		gi.cprintf( ent, PRINT_HIGH,
				"Cheats are disabled on this server.\n");
//				"You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	name = gi.args();

	if (Q_stricmp(name, "all") == 0)
	{
		give_all = true;
	}
	else
	{
		give_all = false;
	}

	if (give_all || (Q_stricmp(gi.argv(1), "health") == 0))
	{
		if (gi.argc() == 3)
		{
			ent->health = (int)strtol(gi.argv(2), (char **)NULL, 10);
		}
		else
		{
			ent->health = ent->max_health;
		}

		if (!give_all)
		{
			return;
		}
	}

	if (give_all || (Q_stricmp(name, "weapons") == 0))
	{
		for (i = 0; i < game.num_items; i++)
		{
			it = itemlist + i;

			if (!it->pickup)
			{
				continue;
			}

			if (!(it->flags & IT_WEAPON))
			{
				continue;
			}

			ent->client->pers.inventory[i] += 1;
		}

		if (!give_all)
		{
			return;
		}
	}

	if (give_all || (Q_stricmp(name, "ammo") == 0))
	{
		for (i = 0; i < game.num_items; i++)
		{
			it = itemlist + i;

			if (!it->pickup)
			{
				continue;
			}

			if (!(it->flags & IT_AMMO))
			{
				continue;
			}

			Add_Ammo(ent, it, 1000);
		}

		if (!give_all)
		{
			return;
		}
	}

	// ace - added "give techs" cheat to simultaniously give all techs (normally ungivable)
	if (give_all || (Q_stricmp(name, "techs") == 0))
	{
		it = FindItem("Disruptor Shield");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 1;

		it = FindItem("Power Amplifier");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 1;

		it = FindItem("Time Accel");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 1;

		it = FindItem("AutoDoc");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 1;

		if (!give_all)
		{
			gi.cprintf( ent, PRINT_HIGH,
				"All tech abilities are active (Disruptor Shield, Power Amplifier, Time Accel and AutoDoc).\n");
			return;
		}
	}

	if (give_all || (Q_stricmp(name, "armor") == 0))
	{
		gitem_armor_t *info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
		{
			return;
		}
	}

	if (give_all || (Q_stricmp(name, "Power Shield") == 0))
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem(it_ent, it);
		Touch_Item(it_ent, ent, NULL, NULL);

		if (it_ent->inuse)
		{
			G_FreeEdict(it_ent);
		}

		if (!give_all)
		{
			return;
		}
	}

	if (give_all)
	{
		for (i = 0; i < game.num_items; i++)
		{
			it = itemlist + i;

			if (!it->pickup)
			{
				continue;
			}

			if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO))
			{
				continue;
			}

			// ace - allow entering a specific ammount when giving "all", otherwise give 1 of everything as usual.
//			ent->client->pers.inventory[i] = 1;
			if (gi.argc() == 3)
			{
				ent->client->pers.inventory[i] = (int)strtol(gi.argv(2), (char **)NULL, 10);
			}
			else
			{
				ent->client->pers.inventory[i] = 1;
			}

		}

		return;
	}

	it = FindItem(name);

	if (!it)
	{
		name = gi.argv(1);
		it = FindItem(name);

		if (!it)
		{
			gi.cprintf(ent, PRINT_HIGH, "unknown item\n");
			return;
		}
	}

	if (!it->pickup)
	{
//		gi.cprintf(ent, PRINT_HIGH, "non-pickup item\n");
		gi.cprintf(ent, PRINT_HIGH, "can't touch this.\n");
		return;
	}

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (gi.argc() == 3)
		{
			ent->client->pers.inventory[index] = (int)strtol(gi.argv(2), (char **)NULL, 10);
		}
		else
		{
			ent->client->pers.inventory[index] += it->quantity;
		}
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem(it_ent, it);
		Touch_Item(it_ent, ent, NULL, NULL);

		if (it_ent->inuse)
		{
			G_FreeEdict(it_ent);
		}
	}
}