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

  if (!ent) {
    return;
  }

  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 = SV_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;
  }
}
Exemple #2
0
/*
===============
ChangeWeapon

The old weapon has been dropped all the way, so make the new one
current
===============
*/
void ChangeWeapon (edict_t *ent)
{
	//a grenade action is happening
	if (ent->client->grenade_framenum)
	{
		//but it blew up in their hand or they threw it, allow bug to double explode
		if ((ent->client->grenade_state == GRENADE_BLEW_UP && g_bugs->value >= 2) ||
			(ent->client->grenade_state == GRENADE_THROWN && g_bugs->value >= 1) ||
			ent->client->grenade_state == GRENADE_NONE)
		{
			ent->client->grenade_framenum = level.framenum;
			weapon_grenade_fire (ent, false);
			ent->client->grenade_framenum = 0;
			ent->client->grenade_state = GRENADE_NONE;
		}
	}

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

	SetVWepInfo (ent);

	if (ent->client->weapon && ent->client->weapon->ammoindex)
		ent->client->ammo_index = ent->client->weapon->ammoindex;
	else
		ent->client->ammo_index = 0;

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

	ent->client->ps.gunindex = gi.modelindex(ent->client->weapon->view_model);

	ent->client->weaponstate = WEAPON_ACTIVATING;
	ent->client->ps.gunframe = 0;

	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;	
	}
}
Exemple #3
0
/*
===============
ChangeWeapon

The old weapon has been dropped all the way, so make the new one
current
===============
*/
void ChangeWeapon (edict_t *ent)
{
	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;
	}

	if (ent->client->pers.weapon &&
		(ent->client->pers.weapon->hideFlags & HIDE_DONT_KEEP))
	{
		ent->client->pers.lastweapon = ent->client->pers.lastweapon2;
		ent->client->pers.lastweapon2 = NULL;
		ent->client->pers.weapon = ent->client->newweapon;
	}
	else
	{
		ent->client->pers.lastweapon2 = ent->client->pers.lastweapon;
		ent->client->pers.lastweapon = ent->client->pers.weapon;
		ent->client->pers.weapon = ent->client->newweapon;
	}
	ent->client->newweapon = NULL;
	ent->client->machinegun_shots = 0;

	if (ent->client->pers.weapon && ent->client->pers.weapon->ammo)
	{
		gitem_t *item = FindItem(ent->client->pers.weapon->ammo);
		ent->client->ammo_index = ITEM_INDEX(item);
	}
	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);
}
Exemple #4
0
/*
===============
ChangeWeapon

The old weapon has been dropped all the way, so make the new one
current
===============
*/
void ChangeWeapon (edict_t *ent)
{
  // Make sure ent exists!
  if (!G_EntExists(ent)) return;

 
	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;

	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);

	// ### Hentai ### BEGIN	
	ShowGun(ent);		
	// ### Hentai ### END
}
Exemple #5
0
void Weapon_Grenade (edict_t *ent)
{
	if ((ent->client->newweapon) && (ent->client->weaponstate == WEAPON_READY))
	{
		ChangeWeapon (ent);
		return;
	}

	if (ent->client->weaponstate == WEAPON_ACTIVATING)
	{
		ent->client->weaponstate = WEAPON_READY;
		ent->client->ps.gunframe = 16;
		return;
	}

	if (ent->client->weaponstate == WEAPON_READY)
	{
		if ( ((ent->client->latched_buttons|ent->client->buttons) & BUTTON_ATTACK) )
		{
			ent->client->latched_buttons &= ~BUTTON_ATTACK;
			if (ent->client->pers.inventory[ent->client->ammo_index])
			{
				ent->client->ps.gunframe = 1;
				ent->client->weaponstate = WEAPON_FIRING;
				ent->client->grenade_time = 0;
			}
			else
			{
				if (level.time >= ent->pain_debounce_time)
				{
					gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0);
					ent->pain_debounce_time = level.time + 1;
				}
				NoAmmoWeaponChange (ent);
			}
			return;
		}

		if ((ent->client->ps.gunframe == 29) || (ent->client->ps.gunframe == 34) || (ent->client->ps.gunframe == 39) || (ent->client->ps.gunframe == 48))
		{
			if (rand()&15)
				return;
		}

		if (++ent->client->ps.gunframe > 48)
			ent->client->ps.gunframe = 16;
		return;
	}

	if (ent->client->weaponstate == WEAPON_FIRING)
	{
		if (ent->client->ps.gunframe == 5)
			gi.sound(ent, CHAN_WEAPON, gi.soundindex("weapons/hgrena1b.wav"), 1, ATTN_NORM, 0);

		if (ent->client->ps.gunframe == 11)
		{
			if (!ent->client->grenade_time)
			{
				ent->client->grenade_time = level.time + GRENADE_TIMER + 0.2;
				ent->client->weapon_sound = gi.soundindex("weapons/hgrenc1b.wav");
			}

			// they waited too long, detonate it in their hand
			if (!ent->client->grenade_blew_up && level.time >= ent->client->grenade_time)
			{
				ent->client->weapon_sound = 0;
				weapon_grenade_fire (ent, true);
				ent->client->grenade_blew_up = true;
			}

			if (ent->client->buttons & BUTTON_ATTACK)
				return;

			if (ent->client->grenade_blew_up)
			{
				if (level.time >= ent->client->grenade_time)
				{
					ent->client->ps.gunframe = 15;
					ent->client->grenade_blew_up = false;
				}
				else
				{
					return;
				}
			}
		}

		if (ent->client->ps.gunframe == 12)
		{
			ent->client->weapon_sound = 0;
			weapon_grenade_fire (ent, false);
		}

		if ((ent->client->ps.gunframe == 15) && (level.time < ent->client->grenade_time))
			return;

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

		if (ent->client->ps.gunframe == 16)
		{
			ent->client->grenade_time = 0;
			ent->client->weaponstate = WEAPON_READY;
		}
	}
}
Exemple #6
0
void Weapon_Grenade (edict_t *ent)
{
	if ((ent->client->newweapon) && (ent->client->weaponstate == WEAPON_READY))
	{
		ChangeWeapon (ent);
		return;
	}

	if (ent->client->weaponstate == WEAPON_ACTIVATING)
	{
		ent->client->weaponstate = WEAPON_READY;
		ent->client->ps.gunframe = 16;
		return;
	}

	if (ent->client->weaponstate == WEAPON_READY)
	{
		if ( ((ent->client->latched_buttons|ent->client->buttons) & BUTTON_ATTACK) )
		{
			ent->client->latched_buttons &= ~BUTTON_ATTACK;
			if (ent->client->inventory[ent->client->ammo_index])
			{
				ent->client->ps.gunframe = 1;
				ent->client->weaponstate = WEAPON_FIRING;
				ent->client->grenade_framenum = 0;
			}
			else
			{
				if (level.framenum >= ent->pain_debounce_framenum)
				{
					gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0);
					ent->pain_debounce_framenum = level.framenum + SECS_TO_FRAMES(1);
				}
				NoAmmoWeaponChange (ent);
			}
			return;
		}

		if ((ent->client->ps.gunframe == 29) || (ent->client->ps.gunframe == 34) || (ent->client->ps.gunframe == 39) || (ent->client->ps.gunframe == 48))
		{
			if (genrand_int32()&15)
				return;
		}

		if (++ent->client->ps.gunframe > 48)
			ent->client->ps.gunframe = 16;
		return;
	}

	if (ent->client->weaponstate == WEAPON_FIRING)
	{
		if (ent->client->ps.gunframe == 5)
			gi.sound(ent, CHAN_WEAPON, gi.soundindex("weapons/hgrena1b.wav"), 1, ATTN_NORM, 0);

		if (ent->client->ps.gunframe == 11)
		{
			if (!ent->client->grenade_framenum)
			{
				ent->client->grenade_framenum = level.framenum + SECS_TO_FRAMES(GRENADE_TIMER + 0.2f);
				ent->client->weapon_sound = gi.soundindex("weapons/hgrenc1b.wav");
			}

			// they waited too long, detonate it in their hand
			if (ent->client->grenade_state != GRENADE_BLEW_UP && level.framenum >= ent->client->grenade_framenum)
			{
				ent->client->weapon_sound = 0;
				weapon_grenade_fire (ent, true);
				ent->client->grenade_state = GRENADE_BLEW_UP;
			}

			if (ent->client->buttons & BUTTON_ATTACK)
				return;

			if (ent->client->grenade_state == GRENADE_BLEW_UP)
			{
				if (level.framenum >= ent->client->grenade_framenum)
				{
					ent->client->ps.gunframe = 15;
					ent->client->grenade_state = GRENADE_NONE;
				}
				else
				{
					return;
				}
			}
		}

		if (ent->client->ps.gunframe == 12)
		{
			ent->client->weapon_sound = 0;
			weapon_grenade_fire (ent, false);
			ent->client->grenade_state = GRENADE_THROWN;
		}

		if ((ent->client->ps.gunframe == 15) && (level.framenum < ent->client->grenade_framenum))
			return;

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

		if (ent->client->ps.gunframe == 16)
		{
			ent->client->grenade_framenum = 0;
			ent->client->grenade_state = GRENADE_NONE;
			ent->client->weaponstate = WEAPON_READY;
		}
	}
}