2019-01-16 16:43:50 +00:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
|
|
|
|
*
|
|
|
|
* See the file LICENSE attached with the sources for usage details.
|
|
|
|
*
|
|
|
|
****/
|
2016-12-04 14:04:30 +00:00
|
|
|
|
2017-07-03 11:55:11 +00:00
|
|
|
string sPainSounds[5] = {
|
|
|
|
"player/pl_pain2.wav",
|
|
|
|
"player/pl_pain4.wav",
|
|
|
|
"player/pl_pain5.wav",
|
|
|
|
"player/pl_pain6.wav",
|
|
|
|
"player/pl_pain7.wav"
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Player_SendEntity
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
float Player_SendEntity(entity ePEnt, float fChanged)
|
|
|
|
{
|
2019-03-24 18:37:48 +00:00
|
|
|
/* If dead */
|
2019-02-20 13:30:16 +00:00
|
|
|
if (self.health <= 0 && ePEnt != self) {
|
2017-03-04 20:08:59 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-01-03 01:26:39 +00:00
|
|
|
|
2019-03-24 18:37:48 +00:00
|
|
|
/* Fix CT/VIP team */
|
|
|
|
float t1, t2;
|
|
|
|
t1 = ePEnt.team;
|
|
|
|
t2 = self.team;
|
|
|
|
if (t1 == TEAM_VIP) {
|
|
|
|
t1 = TEAM_CT;
|
|
|
|
} else if (t2 == TEAM_VIP) {
|
|
|
|
t2 = TEAM_CT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Always make team-mates visible */
|
|
|
|
if (t1 != t2 && ePEnt.health > 0) {
|
|
|
|
/* Can we even see them? */
|
|
|
|
if (!checkpvs(ePEnt.origin, self)) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
/* We're in the same PVS, but we might still not be able to see them */
|
|
|
|
traceline(self.origin, ePEnt.origin, FALSE, self);
|
|
|
|
if (trace_ent != ePEnt) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
WriteByte(MSG_ENTITY, ENT_PLAYER);
|
|
|
|
WriteShort(MSG_ENTITY, self.modelindex);
|
2019-03-13 21:03:57 +00:00
|
|
|
WriteCoord(MSG_ENTITY, self.origin[0]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.origin[1]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.origin[2]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.v_angle[0]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.angles[1]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.angles[2]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.velocity[0]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.velocity[1]);
|
|
|
|
WriteCoord(MSG_ENTITY, self.velocity[2]);
|
2019-02-20 13:30:16 +00:00
|
|
|
WriteFloat(MSG_ENTITY, self.flags);
|
|
|
|
WriteFloat(MSG_ENTITY, self.pmove_flags);
|
|
|
|
WriteByte(MSG_ENTITY, self.weapon);
|
|
|
|
WriteByte(MSG_ENTITY, self.health);
|
|
|
|
WriteFloat(MSG_ENTITY, self.movetype);
|
|
|
|
WriteFloat(MSG_ENTITY, self.view_ofs[2]);
|
|
|
|
WriteFloat(MSG_ENTITY, self.viewzoom);
|
2019-03-25 00:49:27 +00:00
|
|
|
WriteFloat(MSG_ENTITY, self.jumptime);
|
|
|
|
WriteFloat(MSG_ENTITY, self.teleport_time);
|
2016-12-13 19:15:09 +00:00
|
|
|
return TRUE;
|
2017-03-04 20:08:59 +00:00
|
|
|
}
|
2016-12-13 19:15:09 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Player_Pain
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Player_Pain(int iHitBody)
|
|
|
|
{
|
2019-01-03 01:26:39 +00:00
|
|
|
/*
|
2019-02-20 13:30:16 +00:00
|
|
|
if (iHitBody == BODY_HEAD) {
|
|
|
|
Animation_PlayerTopTemp(ANIM_HEAD_FLINCH, 0.25f);
|
2017-01-08 14:11:34 +00:00
|
|
|
} else {
|
2019-02-20 13:30:16 +00:00
|
|
|
Animation_PlayerTopTemp(ANIM_GUT_FLINCH, 0.25f);
|
2019-01-03 01:26:39 +00:00
|
|
|
}*/
|
2017-01-08 14:11:34 +00:00
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
sound(self, CHAN_VOICE, sPainSounds[ floor(random() * 5) ], 1, ATTN_IDLE);
|
2017-01-03 18:31:24 +00:00
|
|
|
self.velocity = '0 0 0';
|
2016-12-04 14:04:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Player_Death
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Player_Death(int iHitBody)
|
|
|
|
{
|
|
|
|
if (iHitBody == BODY_HEAD) {
|
|
|
|
sound(self, CHAN_VOICE, sprintf("player/headshot%d.wav", floor((random() * 3) + 1)), 1, ATTN_NORM);
|
2017-01-08 14:11:34 +00:00
|
|
|
} else {
|
2019-02-20 13:30:16 +00:00
|
|
|
sound(self, CHAN_VOICE, sprintf("player/die%d.wav", floor((random() * 3) + 1)), 1, ATTN_NORM);
|
2017-01-08 14:11:34 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
// Drop a corpse
|
|
|
|
entity eCorpse = spawn();
|
2017-01-11 23:31:19 +00:00
|
|
|
eCorpse.classname = "remove_me";
|
2019-02-20 13:30:16 +00:00
|
|
|
setorigin(eCorpse, self.origin);
|
|
|
|
setmodel(eCorpse, self.model);
|
|
|
|
setsize(eCorpse, self.mins, self.maxs);
|
2019-03-13 21:03:57 +00:00
|
|
|
eCorpse.angles = [ 0, self.angles[1], 0 ];
|
2016-12-07 23:50:47 +00:00
|
|
|
eCorpse.movetype = MOVETYPE_BOUNCE;
|
2018-12-07 19:03:07 +00:00
|
|
|
|
2017-06-27 00:04:25 +00:00
|
|
|
// Drop primary weapon as well as the bomb if present
|
2019-02-20 13:30:16 +00:00
|
|
|
if (self.fSlotPrimary) {
|
|
|
|
Weapon_DropWeapon(SLOT_PRIMARY);
|
2017-06-27 00:04:25 +00:00
|
|
|
} else {
|
2019-02-20 13:30:16 +00:00
|
|
|
if (self.fSlotSecondary) {
|
|
|
|
Weapon_DropWeapon(SLOT_SECONDARY);
|
2017-06-27 00:04:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-20 13:30:16 +00:00
|
|
|
if (self.fSlotGrenade) {
|
|
|
|
Weapon_DropWeapon(SLOT_GRENADE);
|
2017-06-27 00:04:25 +00:00
|
|
|
}
|
|
|
|
|
2017-01-14 15:00:31 +00:00
|
|
|
// Make ourselves disappear
|
|
|
|
self.modelindex = 0;
|
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
if (self.flags & FL_CROUCHING) {
|
2017-01-08 14:11:34 +00:00
|
|
|
eCorpse.frame = ANIM_CROUCH_DIE;
|
|
|
|
} else {
|
2019-02-20 13:30:16 +00:00
|
|
|
switch (iHitBody) {
|
2017-01-08 14:11:34 +00:00
|
|
|
case BODY_HEAD:
|
|
|
|
eCorpse.frame = ANIM_DIE_HEAD;
|
|
|
|
break;
|
|
|
|
case BODY_STOMACH:
|
|
|
|
eCorpse.frame = ANIM_DIE_GUT;
|
|
|
|
break;
|
|
|
|
case BODY_LEGLEFT:
|
|
|
|
case BODY_ARMLEFT:
|
|
|
|
eCorpse.frame = ANIM_DIE_LEFT;
|
|
|
|
break;
|
|
|
|
case BODY_LEGRIGHT:
|
|
|
|
case BODY_ARMRIGHT:
|
|
|
|
eCorpse.frame = ANIM_DIE_RIGHT;
|
|
|
|
break;
|
|
|
|
default:
|
2019-02-20 13:30:16 +00:00
|
|
|
eCorpse.frame = ANIM_DEATH1 + floor(random() * 3);
|
2017-01-08 14:11:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-02-12 15:24:08 +00:00
|
|
|
|
2016-12-04 14:04:30 +00:00
|
|
|
Spawn_MakeSpectator();
|
2016-12-07 00:05:06 +00:00
|
|
|
self.classname = "player";
|
|
|
|
self.health = 0;
|
2019-02-20 13:30:16 +00:00
|
|
|
forceinfokey(self, "*dead", "1");
|
|
|
|
forceinfokey(self, "*team", ftos(self.team));
|
2018-12-05 14:05:56 +00:00
|
|
|
|
|
|
|
Rules_CountPlayers();
|
|
|
|
|
2019-03-21 19:14:51 +00:00
|
|
|
/* In Assassination, all Terrorists receive a $2500
|
|
|
|
* reward if they won by killing the VIP. */
|
2019-02-20 13:30:16 +00:00
|
|
|
if (self.team == TEAM_VIP) {
|
|
|
|
Rules_RoundOver(TEAM_T, 2500, FALSE);
|
2017-01-07 16:29:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-12-05 14:05:56 +00:00
|
|
|
|
|
|
|
Rules_DeathCheck();
|
2016-12-04 14:04:30 +00:00
|
|
|
}
|
2016-12-05 00:22:52 +00:00
|
|
|
|
2016-12-11 10:10:03 +00:00
|
|
|
/*
|
|
|
|
====================
|
2019-02-20 13:30:16 +00:00
|
|
|
UseWorkaround
|
2016-12-11 10:10:03 +00:00
|
|
|
====================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void UseWorkaround(entity eTarget)
|
2018-12-31 01:00:38 +00:00
|
|
|
{
|
|
|
|
eActivator = self;
|
|
|
|
entity eOldSelf = self;
|
|
|
|
self = eTarget;
|
|
|
|
self.PlayerUse();
|
|
|
|
self = eOldSelf;
|
|
|
|
}
|
2019-02-20 13:30:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
Player_UseDown
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
void Player_UseDown(void)
|
|
|
|
{
|
|
|
|
if (self.health <= 0) {
|
2016-12-18 09:09:01 +00:00
|
|
|
return;
|
2019-02-20 13:30:16 +00:00
|
|
|
} else if (!(self.flags & FL_USERELEASED)) {
|
2016-12-11 10:10:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector vSource;
|
|
|
|
|
|
|
|
makevectors(self.v_angle);
|
|
|
|
vSource = self.origin + self.view_ofs;
|
2019-02-20 13:30:16 +00:00
|
|
|
traceline (vSource, vSource + (v_forward * 64), FALSE, self);
|
2016-12-11 10:10:03 +00:00
|
|
|
|
2019-01-05 01:02:12 +00:00
|
|
|
if (trace_ent.PlayerUse) {
|
2019-02-20 13:30:16 +00:00
|
|
|
if ((trace_ent.classname != "c4bomb") && (trace_ent.classname != "func_pushable")) {
|
|
|
|
self.flags = (self.flags - FL_USERELEASED);
|
|
|
|
sound(self, CHAN_ITEM, "common/wpn_select.wav", 0.25, ATTN_IDLE);
|
2016-12-11 10:10:03 +00:00
|
|
|
}
|
|
|
|
|
2018-12-31 01:00:38 +00:00
|
|
|
UseWorkaround(trace_ent);
|
2016-12-11 10:10:03 +00:00
|
|
|
} else {
|
2019-02-20 13:30:16 +00:00
|
|
|
sound(self, CHAN_ITEM, "common/wpn_denyselect.wav", 0.25, ATTN_IDLE);
|
|
|
|
self.flags = (self.flags - FL_USERELEASED);
|
2016-12-11 10:10:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
Player_UseUp
|
|
|
|
====================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Player_UseUp(void)
|
|
|
|
{
|
|
|
|
if (!(self.frags & FL_USERELEASED)) {
|
2016-12-11 10:10:03 +00:00
|
|
|
self.flags = self.flags | FL_USERELEASED;
|
|
|
|
self.fProgressBar = 0;
|
|
|
|
}
|
|
|
|
}
|
2017-01-03 01:02:00 +00:00
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
PlayerPreThink
|
|
|
|
|
|
|
|
Run before physics
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_PlayerPreThink(void)
|
|
|
|
{
|
2017-07-03 11:55:11 +00:00
|
|
|
BaseGun_ShotMultiplierUpdate();
|
2017-01-03 01:02:00 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:24:45 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
PlayerPreThink
|
|
|
|
|
|
|
|
Run after physics
|
|
|
|
=================
|
|
|
|
*/
|
2019-02-20 13:30:16 +00:00
|
|
|
void Game_PlayerPostThink(void)
|
|
|
|
{
|
2017-01-03 01:02:00 +00:00
|
|
|
Animation_PlayerUpdate();
|
2017-03-04 20:08:59 +00:00
|
|
|
Footsteps_Update();
|
2017-01-03 01:02:00 +00:00
|
|
|
|
2017-03-04 20:08:59 +00:00
|
|
|
self.SendFlags = 1;
|
2017-01-03 01:02:00 +00:00
|
|
|
}
|