Moved Player_Death into the Gamerule logic.

Counter-Strike's zones have been shoved into .flags, where we desperately
need some more bits.
Counter-Strike's WEAPON_C4BOMB now only works in a func_bomb_target zone.
This commit is contained in:
Marco Cawthorne 2020-04-20 19:25:15 +02:00
parent 1eda0ab5d4
commit a3ff75a4da
39 changed files with 526 additions and 271 deletions

View File

@ -197,10 +197,10 @@ HUD_DrawMoney(void)
/* dollar sign */
drawsubpic(
money_pos,
[18,25],
[18,26],
HUD_NUMS,
[NUMSIZE_X * 8, NUMSIZE_Y * 1],
[NUMSIZE_X * 0.75, NUMSIZE_Y],
[192/256, 24/256],
[18/256, 26/256],
g_hud_color,
HUD_ALPHA - endalpha,
DRAWFLAG_ADDITIVE
@ -210,7 +210,16 @@ HUD_DrawMoney(void)
* varying alphas/colors */
if (pSeat->m_flMoneyAlpha > 0) {
/* red/green dollar sign */
drawsubpic(money_pos, [18,25], HUD_NUMS, [NUMSIZE_X * 8, NUMSIZE_Y * 1], [NUMSIZE_X * 0.75, NUMSIZE_Y], pSeat->m_vecMoneyColor, endalpha, DRAWFLAG_ADDITIVE);
drawsubpic(
money_pos,
[18,26],
HUD_NUMS,
[192/256, 24/256],
[18/256, 26/256],
pSeat->m_vecMoneyColor,
endalpha,
DRAWFLAG_ADDITIVE
);
/* draw the +/- symbols depending on whether
* or not we made or lost money */
@ -310,29 +319,56 @@ HUD_DrawArmor(void)
pSeat->m_flArmorAlpha = HUD_ALPHA;
}
drawsubpic(
pos + [-80,1],
[24,24],
HUD_NUMS,
[spr_suit2[0], spr_suit2[1]],
[spr_suit2[2], spr_suit2[3]],
g_hud_color,
pSeat->m_flArmorAlpha,
DRAWFLAG_ADDITIVE
);
if (pl.armor > 0) {
if (pl.g_items & ITEM_HELMET) {
drawsubpic(
pos + [-80,1],
[24, 24 * (pl.armor / 100)],
[24,24],
HUD_NUMS,
[spr_suit1[0],
spr_suit1[1]],
[spr_suit1[2], spr_suit1[3] * (pl.armor / 100)],
[spr_suit4[0], spr_suit4[1]],
[spr_suit4[2], spr_suit4[3]],
g_hud_color,
pSeat->m_flArmorAlpha,
DRAWFLAG_ADDITIVE
);
} else {
drawsubpic(
pos + [-80,1],
[24,24],
HUD_NUMS,
[spr_suit2[0], spr_suit2[1]],
[spr_suit2[2], spr_suit2[3]],
g_hud_color,
pSeat->m_flArmorAlpha,
DRAWFLAG_ADDITIVE
);
}
if (pl.armor > 0) {
if (pl.g_items & ITEM_HELMET) {
drawsubpic(
pos + [-80,1],
[24, 24 * (pl.armor / 100)],
HUD_NUMS,
[spr_suit3[0],
spr_suit3[1]],
[spr_suit3[2], spr_suit3[3] * (pl.armor / 100)],
g_hud_color,
pSeat->m_flArmorAlpha,
DRAWFLAG_ADDITIVE
);
} else {
drawsubpic(
pos + [-80,1],
[24, 24 * (pl.armor / 100)],
HUD_NUMS,
[spr_suit1[0],
spr_suit1[1]],
[spr_suit1[2], spr_suit1[3] * (pl.armor / 100)],
g_hud_color,
pSeat->m_flArmorAlpha,
DRAWFLAG_ADDITIVE
);
}
}
HUD_DrawNums(pl.armor, pos, pSeat->m_flArmorAlpha, g_hud_color);
@ -451,35 +487,79 @@ HUD_DrawFlashlight(void)
}
}
/* logo animation used during e3 1998 */
void
HUD_DrawLogo(void)
HUD_DrawZones(void)
{
vector pos;
static int f;
static float frame_timer;
int zc = 0;
vector pos = [0,0,0];
player pl = (player)pSeat->m_ePlayer;
frame_timer -= clframetime;
pos = [g_hudres[0] - 262, 48];
drawpic(
pos,
sprintf("sprites/640_logo.spr_%i.tga", f),
[256, 48],
[1,1,1],
1.0f,
DRAWFLAG_ADDITIVE
);
if (frame_timer > 0) {
return;
if (pl.flags & FL_BUYZONE) {
zc++;
}
if (pl.flags & FL_BOMBZONE) {
zc++;
}
if (pl.flags & FL_RESCUEZONE) {
zc++;
}
if (pl.g_items & ITEM_DEFUSAL) {
zc++;
}
frame_timer = 0.1f;
pos = g_hudmins + [16, (g_hudres[1] / 2) - (zc * 16)];
f++;
if (f == 31) {
f = 0;
if (pl.flags & FL_BUYZONE) {
drawsubpic(
pos,
[32,32],
HUD_NUMS,
[96/256,148/256],
[32/256,32/256],
[0,1,0],
1.0f,
DRAWFLAG_ADDITIVE
);
pos[1] += 32;
}
if (pl.flags & FL_BOMBZONE) {
drawsubpic(
pos,
[32,32],
HUD_NUMS,
[0/256,148/256],
[32/256,32/256],
[0,1,0],
1.0f,
DRAWFLAG_ADDITIVE
);
pos[1] += 32;
}
if (pl.flags & FL_RESCUEZONE) {
drawsubpic(
pos,
[32,32],
HUD_NUMS,
[64/256,148/256],
[32/256,32/256],
[0,1,0],
1.0f,
DRAWFLAG_ADDITIVE
);
pos[1] += 32;
}
if (pl.g_items & ITEM_DEFUSAL) {
drawsubpic(
pos,
[32,32],
HUD_NUMS,
[48/256,148/256],
[32/256,32/256],
[0,1,0],
1.0f,
DRAWFLAG_ADDITIVE
);
pos[1] += 32;
}
}
@ -529,10 +609,9 @@ HUD_Draw(void)
HUD_DrawNotify();
HUD_DrawHealth();
HUD_DrawArmor();
HUD_DrawZones();
HUD_DrawFlashlight();
Damage_Draw();
//drawpic([128,128], HUD_NUMS, [256,256], [1,1,1], 1.0f);
}
/* specatator main entry */

View File

@ -36,6 +36,20 @@ float spr_suit2[4] = {
24 / 256 // size y
};
float spr_suit3[4] = {
0 / 256, // pos x
124 / 256, // pos u
24 / 256, // size x
24 / 256 // size y
};
float spr_suit4[4] = {
24 / 256, // pos x
124 / 256, // pos u
24 / 256, // size x
24 / 256 // size y
};
float spr_flash1[4] = {
160 / 256, // pos x
24 / 256, // pos u

View File

@ -77,7 +77,7 @@ CSEv_BuyWeapon_f(float fWeapon)
if ((pl.money - g_cstrikeWeaponPrice[iWeapon]) >= 0) {
Weapons_AddItem(pl, iWeapon);
Money_AddMoney(pl, -g_cstrikeWeaponPrice[iWeapon]);
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.weapon");
} else {
//centerprint(pl, "You have insufficient funds!");
}
@ -115,32 +115,32 @@ CSEv_BuyEquipment_f(float fUtil)
switch (iUtil) {
case 0:
pl.armor = 100;
sound(pl, CHAN_ITEM, "items/tr_kevlar.wav", 1.0f, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.kevlar");
break;
case 1:
pl.armor = 100;
pl.g_items |= ITEM_HELMET;
sound(pl, CHAN_ITEM, "items/tr_kevlar.wav", 1.0f, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.kevlar");
break;
case 2:
Weapons_AddItem(pl, WEAPON_FLASHBANG);
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1.0f, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.weapon");
break;
case 3:
Weapons_AddItem(pl, WEAPON_HEGRENADE);
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1.0f, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.weapon");
break;
case 4:
Weapons_AddItem(pl, WEAPON_SMOKEGRENADE);
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1.0f, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.weapon");
break;
case 5:
pl.g_items |= ITEM_DEFUSAL;
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1.0f, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.weapon");
break;
case 6:
pl.g_items |= ITEM_NIGHTVISION;
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1.0f, ATTN_IDLE);
Sound_Play(pl, CHAN_ITEM, "buy.weapon");
break;
}
Money_AddMoney(pl, -g_cstrikeUtilPrice[iUtil]);

View File

@ -18,7 +18,10 @@ void
Game_RunClientCommand(void)
{
player pl = (player)self;
pl.buyzone = FALSE;
pl.flags &= ~FL_BUYZONE;
pl.flags &= ~FL_RESCUEZONE;
pl.flags &= ~FL_BOMBZONE;
Footsteps_Update();
PMove_Run();

View File

@ -29,9 +29,27 @@ Once the bomb explodes inside this volume, it'll trigger its targets.
class func_bomb_target:CBaseTrigger
{
void(void) func_bomb_target;
virtual void(void) Respawn;
virtual void(void) touch;
};
void
func_bomb_target::touch(void)
{
player pl = (player)other;
if (!(other.flags & FL_CLIENT)) {
return;
}
if (pl.team != TEAM_T) {
return;
}
pl.flags |= FL_BOMBZONE;
}
void
func_bomb_target::Respawn(void)
{

View File

@ -52,11 +52,11 @@ void
func_buyzone::touch(void)
{
player pl = (player)other;
if (!(other.flags & FL_CLIENT)) {
if (!(other.flags & FL_CLIENT))
return;
}
pl.buyzone = TRUE;
if (team == 0 || team == pl.team)
pl.flags |= FL_BUYZONE;
}
void

View File

@ -39,6 +39,12 @@ class func_hostage_rescue:CBaseTrigger
void
func_hostage_rescue::touch(void)
{
if (other.flags & FL_CLIENT) {
player pl = (player)other;
pl.flags |= FL_RESCUEZONE;
return;
}
if (other.classname != "hostage_entity") {
return;
}
@ -52,7 +58,7 @@ func_hostage_rescue::touch(void)
Radio_BroadcastMessage(RADIO_RESCUED);
g_cs_hostagesrescued++;
Money_AddMoney(hosty.m_eFollowing, 1000);
Money_AddMoney((player)hosty.m_eFollowing, 1000);
/* In Hostage Rescue, all Counter-Terrorists receive an $850
* bonus for every hostage they rescue, even if they lose the round. */

View File

@ -16,6 +16,16 @@
var int autocvar_sv_playerkeepalive = TRUE;
void
CSGameRules::PlayerDeath(player pl)
{
}
void
CSGameRules::PlayerPain(player pl)
{
}
int
CSGameRules::BuyingPossible(player pl)
{

View File

@ -22,6 +22,8 @@ class CSGameRules:CGameRules
virtual void(entity) PlayerDisconnect;
virtual void(player) PlayerKill;
virtual void(player) PlayerPostFrame;
virtual void(player) PlayerDeath;
virtual void(player) PlayerPain;
/* level transitions */
virtual void(player) LevelChangeParms;
@ -35,6 +37,7 @@ class CSSingleplayerRules:CSGameRules
{
/* client */
virtual void(player) PlayerSpawn;
virtual void(player) PlayerDeath;
};
class CSMultiplayerRules:CSGameRules
@ -48,6 +51,7 @@ class CSMultiplayerRules:CSGameRules
virtual void(void) FrameStart;
virtual void(player) PlayerSpawn;
virtual void(player) PlayerPreFrame;
virtual void(player) PlayerDeath;
/* CS specific */
virtual void(void) CreateRescueZones;

View File

@ -14,6 +14,44 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
CSMultiplayerRules::PlayerDeath(player pl)
{
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
pl.health = 0;
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
/* gamerule stuff */
PlayerMakeSpectator(pl);
pl.classname = "player";
pl.health = 0;
forceinfokey(pl, "*dead", "1");
forceinfokey(pl, "*team", ftos(pl.team));
CountPlayers();
/* In Assassination, all Terrorists receive a $2500
* reward if they won by killing the VIP. */
if (self.team == TEAM_VIP) {
RoundOver(TEAM_T, 2500, FALSE);
return;
}
DeathCheck(pl);
}
void
CSMultiplayerRules::PlayerPreFrame(player pl)
{
@ -294,7 +332,7 @@ CSMultiplayerRules::BuyingPossible(player pl)
}
}
if (pl.buyzone == FALSE) {
if (!(pl.flags & FL_BUYZONE)) {
centerprint(pl, "Sorry, you aren't in a buyzone.\n");
return FALSE;
}
@ -828,5 +866,3 @@ void CSEv_JoinTeam_f(float flChar)
rules.RoundOver(FALSE, 0, FALSE);
}
}
void weaponbox_spawn(player pl) {}

View File

@ -14,6 +14,24 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
CSSingleplayerRules::PlayerDeath(player pl)
{
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
if (pl.health < -50) {
pl.health = 0;
Effect_GibHuman(pl.origin);
return;
}
pl.health = 0;
}
void
CSSingleplayerRules::PlayerSpawn(player pl)
{

View File

@ -35,11 +35,11 @@ void
info_buyzone::touch(void)
{
player pl = (player)other;
if (!(other.flags & FL_CLIENT)) {
if (!(other.flags & FL_CLIENT))
return;
}
pl.buyzone = TRUE;
if (team == 0 || team == pl.team)
pl.flags |= FL_BUYZONE;
}
void

View File

@ -38,6 +38,12 @@ class info_hostage_rescue
void
info_hostage_rescue::touch(void)
{
if (other.flags & FL_CLIENT) {
player pl = (player)other;
pl.flags |= FL_RESCUEZONE;
return;
}
if (other.classname != "hostage_entity") {
return;
}
@ -51,7 +57,7 @@ info_hostage_rescue::touch(void)
Radio_BroadcastMessage(RADIO_RESCUED);
g_cs_hostagesrescued++;
Money_AddMoney(hosty.m_eFollowing, 1000);
Money_AddMoney((player)hosty.m_eFollowing, 1000);
/* In Hostage Rescue, all Counter-Terrorists receive an $850
* bonus for every hostage they rescue, even if they lose the round. */

View File

@ -14,63 +14,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void Player_Pain(int hit)
{
}
void Player_Death(int hit)
{
player pl = (player)self;
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
if (pl.health < -50) {
pl.health = 0;
Effect_GibHuman(pl.origin);
return;
}
pl.health = 0;
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
/* gamerule stuff */
// PlayerMakeSpectator();
self.classname = "player";
self.health = 0;
forceinfokey(self, "*dead", "1");
forceinfokey(self, "*team", ftos(self.team));
//Rules_CountPlayers();
/* In Assassination, all Terrorists receive a $2500
* reward if they won by killing the VIP. */
if (self.team == TEAM_VIP) {
// Rules_RoundOver(TEAM_T, 2500, FALSE);
return;
}
//
//Rules_DeathCheck();
}
/*
====================
UseWorkaround

View File

@ -37,10 +37,15 @@ void Game_Worldspawn(void)
precache_model("models/player/urban/urban.mdl");
precache_model("models/player/vip/vip.mdl");
precache_sound("weapons/ric_metal-2.wav");
precache_sound("player/pl_pain2.wav");
precache_sound("player/pl_pain4.wav");
Sound_Precache("buy.kevlar");
Sound_Precache("buy.weapon");
Weapons_Init();
clientstat(STAT_MONEY, EV_INTEGER, player::money);
pointerstat(STAT_GAMETIME, EV_FLOAT, &g_cs_gametime);
pointerstat(STAT_GAMESTATE, EV_INTEGER, &g_cs_gamestate);
}

View File

@ -46,6 +46,16 @@ CGameRules::PlayerDisconnect(entity pl)
}
void
CGameRules::PlayerKill(player pl)
{
//print("PlayerKill!\n");
}
void
CGameRules::PlayerDeath(player pl)
{
//print("PlayerDeath!\n");
}
void
CGameRules::PlayerPain(player pl)
{
//print("ClientKill!\n");
}

View File

@ -31,6 +31,8 @@ class CGameRules
virtual void(player) PlayerSpawn;
virtual void(player) PlayerPreFrame;
virtual void(player) PlayerPostFrame;
virtual void(player) PlayerDeath;
virtual void(player) PlayerPain;
/* level transitions */
virtual void(void) LevelNewParms;

View File

@ -15,9 +15,36 @@
*/
void
HLMultiplayerRules::LevelDecodeParms(player pl)
HLMultiplayerRules::PlayerDeath(player pl)
{
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
if (pl.health < -50) {
pl.health = 0;
Effect_GibHuman(pl.origin);
return;
}
pl.health = 0;
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
}
void
@ -65,7 +92,3 @@ HLMultiplayerRules::PlayerSpawn(player pl)
Client_FixAngle(pl, pl.angles);
}
void weaponbox_spawn(player pl)
{
}

View File

@ -14,11 +14,39 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class HLMultiplayerRules:HLGameRules
void
HLMultiplayerRules::PlayerDeath(player pl)
{
/* client */
virtual void(player) PlayerSpawn;
};
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
sound(pl, CHAN_AUTO, "fvox/flatline.wav", 1.0, ATTN_NORM);
if (pl.health < -50) {
pl.health = 0;
Effect_GibHuman(pl.origin);
return;
}
pl.health = 0;
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
}
void
HLMultiplayerRules::PlayerSpawn(player pl)
@ -71,7 +99,3 @@ HLMultiplayerRules::PlayerSpawn(player pl)
Client_FixAngle(pl, pl.angles);
}
void weaponbox_spawn(player pl)
{
}

View File

@ -16,6 +16,42 @@
var int autocvar_sv_playerkeepalive = TRUE;
void
SHMultiplayerRules::PlayerDeath(player pl)
{
weaponbox_spawn(pl);
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
sound(pl, CHAN_AUTO, "fvox/flatline.wav", 1.0, ATTN_NORM);
if (pl.health < -50) {
pl.health = 0;
Effect_GibHuman(pl.origin);
return;
}
pl.health = 0;
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
}
void
SHMultiplayerRules::PlayerSpawn(player pl)
{

View File

@ -23,6 +23,7 @@ class SHMultiplayerRules:CGameRules
virtual void(entity) PlayerConnect;
virtual void(entity) PlayerDisconnect;
virtual void(player) PlayerKill;
virtual void(player) PlayerDeath;
virtual void(player) PlayerPostFrame;
virtual void(player) LevelDecodeParms;

View File

@ -36,6 +36,7 @@ Damage_Obituary(entity c, entity t, float weapon, float flags)
void
Damage_Apply(entity t, entity c, float dmg, int w, int type)
{
CGameRules rules = (CGameRules)g_grMode;
if (t.flags & FL_GODMODE) {
return;
}
@ -99,9 +100,17 @@ Damage_Apply(entity t, entity c, float dmg, int w, int type)
if (t.flags & FL_MONSTER || t.flags & FL_CLIENT) {
Damage_Obituary(c, t, w, 0);
}
s.Death(trace_surface_id);
if (s.flags & FL_CLIENT) {
rules.PlayerDeath((player)s);
} else {
s.Death(trace_surface_id);
}
} else {
s.Pain(trace_surface_id);
if (s.flags & FL_CLIENT) {
rules.PlayerPain((player)s);
} else {
s.Pain(trace_surface_id);
}
}
}

View File

@ -32,10 +32,12 @@ class HLSingleplayerRules:HLGameRules
{
/* client */
virtual void(player) PlayerSpawn;
virtual void(player) PlayerDeath;
};
class HLMultiplayerRules:HLGameRules
{
/* client */
virtual void(player) PlayerSpawn;
virtual void(player) PlayerDeath;
};

View File

@ -14,6 +14,41 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
HLMultiplayerRules::PlayerDeath(player pl)
{
weaponbox_spawn(pl);
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
sound(pl, CHAN_AUTO, "fvox/flatline.wav", 1.0, ATTN_NORM);
if (pl.health < -50) {
pl.health = 0;
Effect_GibHuman(pl.origin);
return;
}
pl.health = 0;
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
}
void
HLMultiplayerRules::PlayerSpawn(player pl)
{

View File

@ -14,6 +14,25 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
HLSingleplayerRules::PlayerDeath(player pl)
{
pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
sound(pl, CHAN_AUTO, "fvox/flatline.wav", 1.0, ATTN_NORM);
if (pl.health < -50) {
pl.health = 0;
Effect_GibHuman(pl.origin);
return;
}
pl.health = 0;
}
void
HLSingleplayerRules::PlayerSpawn(player pl)
{

View File

@ -14,47 +14,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void weaponbox_spawn(player);
void player::Pain(int hit)
{
}
void player::Death(int hit)
{
weaponbox_spawn(this);
movetype = MOVETYPE_NONE;
solid = SOLID_NOT;
takedamage = DAMAGE_NO;
flags &= ~FL_FLASHLIGHT;
armor = activeweapon = g_items = 0;
think = PutClientInServer;
nextthink = time + 4.0f;
sound(this, CHAN_AUTO, "fvox/flatline.wav", 1.0, ATTN_NORM);
if (health < -50) {
health = 0;
Effect_GibHuman(origin);
return;
}
health = 0;
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, origin + [0,0,32]);
setmodel(corpse, model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = angles;
corpse.velocity = velocity;
}
/*
====================
UseWorkaround

View File

@ -56,7 +56,8 @@ Vote_Reset(void)
forceinfokey(world, "vote_cmd", "");
for (entity e = world; (e = find(e, ::classname, "player"));) {
e.flags &= ~FL_VOTED;
player pl = (player)e;
pl.voted = 0;
}
}
@ -127,6 +128,8 @@ CSEv_VoteY
void
CSEv_VoteY(void)
{
player pl = (player)self;
/* No vote is in progress */
if (g_iVoteState != VOTE_INPROGRESS) {
return;
@ -136,12 +139,12 @@ CSEv_VoteY(void)
return;
}
if (self.flags & FL_VOTED) {
if (pl.voted) {
return;
}
forceinfokey(world, "votes_y", ftos(serverkeyfloat("votes_y")+1));
self.flags |= FL_VOTED;
pl.voted = 1;
/* HACK: Is there a better way to do this? */
float playernums = 0;
@ -170,6 +173,8 @@ CSEv_VoteN
void
CSEv_VoteN(void)
{
player pl = (player)self;
/* No vote is in progress */
if (g_iVoteState != VOTE_INPROGRESS) {
return;
@ -179,12 +184,12 @@ CSEv_VoteN(void)
return;
}
if (self.flags & FL_VOTED) {
if (pl.voted) {
return;
}
forceinfokey(world, "votes_n", ftos(serverkeyfloat("votes_n")+1));
self.flags |= FL_VOTED;
pl.voted = 1;
/* HACK: Is there a better way to do this? */
float playernums = 0;

View File

@ -18,21 +18,17 @@
#include "weapons.h"
#include "items.h"
enum
{
STAT_BUYZONE = 34,
STAT_ESCAPEZONE,
STAT_VIPZONE,
STAT_HOSTAGEZONE,
STAT_BOMBZONE,
STAT_MONEY,
STAT_TEAM,
STAT_GAMETIME,
STAT_GAMESTATE,
STAT_WON_T,
STAT_WON_CT
};
#define TEAM_T 1
#define TEAM_CT 2
#define TEAM_VIP 3
#define FL_BUYZONE (1<<21)
#define FL_RESCUEZONE (1<<22)
#define FL_BOMBZONE (1<<23)
enum
{
STAT_MONEY = 34,
STAT_GAMETIME,
STAT_GAMESTATE
};

View File

@ -85,7 +85,6 @@ class player:CBaseEntity
virtual float() predraw;
virtual void(void) postdraw;
#else
int buyzone;
int charmodel;
int money;
int ammo_50ae;
@ -148,6 +147,8 @@ class player:CBaseEntity
int old_a_ammo2;
int old_a_ammo3;
int voted;
int old_cs_shotmultiplier;
float old_cs_shottime;
#endif

View File

@ -225,7 +225,11 @@ void
w_c4bomb_primary(void)
{
player pl = (player)self;
if (!(pl.flags & FL_BOMBZONE)) {
return;
}
pl.flags |= FL_FROZEN;
switch (pl.a_ammo1) {

View File

@ -34,12 +34,12 @@
/* nuclide */
#define FL_ONLADDER (1<<13)
#define FL_FLASHLIGHT (1<<17)
#define FL_REMOVEME (1<<18)
#define FL_CROUCHING (1<<19)
#define FL_SEMI_TOGGLED (1<<20)
#define FL_FROZEN (1<<21)
#define FL_VOTED (1<<22)
#define FL_RESERVED (1<<23)
#define FL_CROUCHING (1<<18)
#define FL_SEMI_TOGGLED (1<<19)
#define FL_FROZEN (1<<20)
#define FL_RESERVED1 (1<<21)
#define FL_RESERVED2 (1<<22)
#define FL_RESERVED3 (1<<23)
/* game flags */
#define GF_UNUSED1 (1<<0)

View File

@ -125,8 +125,7 @@ class player:CBaseEntity
int old_a_ammo2;
int old_a_ammo3;
virtual void(int) Pain;
virtual void(int) Death;
int voted;
#endif
};

View File

@ -123,9 +123,7 @@ class player:CBaseEntity
int old_a_ammo1;
int old_a_ammo2;
int old_a_ammo3;
virtual void(int) Pain;
virtual void(int) Death;
int voted;
#endif
};

View File

@ -106,9 +106,7 @@ class player:CBaseEntity
int old_a_ammo1;
int old_a_ammo2;
int old_a_ammo3;
virtual void(int) Pain;
virtual void(int) Death;
int voted;
#endif
};

View File

@ -122,8 +122,7 @@ class player:CBaseEntity
int old_a_ammo2;
int old_a_ammo3;
virtual void(int) Pain;
virtual void(int) Death;
int voted;
#endif
};

View File

@ -115,8 +115,6 @@ class player:CBaseEntity
int old_a_ammo1;
int old_a_ammo2;
int old_a_ammo3;
virtual void(int) Pain;
virtual void(int) Death;
int voted;
#endif
};

View File

@ -115,8 +115,7 @@ class player:CBaseEntity
int old_a_ammo2;
int old_a_ammo3;
virtual void(int) Pain;
virtual void(int) Death;
int voted;
#endif
};

View File

@ -1,7 +1,3 @@
#ifndef WASTES
#define CLASSIC_VGUI
#endif
#includelist
../vgui/font.cpp
../vgui/ui.cpp

View File

@ -69,15 +69,15 @@ void CUIScrollbar::Draw(void)
drawfill(m_parent.m_vecOrigin + m_vecOrigin, vecSize, m_vecColor, m_flAlpha);
if (m_iFlags & BUTTON_DOWN) {
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, vecSize[1] - 1], [vecSize[0], 1], '1 1 1', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin, [vecSize[0], 1], '0 0 0', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, 1], [1, vecSize[1] - 2], '0 0 0', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [vecSize[0] - 1, 1], [1, vecSize[1] - 2], '1 1 1', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, vecSize[1] - 1], [vecSize[0], 1], [1,1,1], 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin, [vecSize[0], 1], [0,0,0], 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, 1], [1, vecSize[1] - 2], [0,0,0], 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [vecSize[0] - 1, 1], [1, vecSize[1] - 2], [1,1,1], 0.5f);
} else {
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, vecSize[1] - 1], [vecSize[0], 1], '0 0 0', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin, [vecSize[0], 1], '1 1 1', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, 1], [1, vecSize[1] - 2], '1 1 1', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [vecSize[0] - 1, 1], [1, vecSize[1] - 2], '0 0 0', 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, vecSize[1] - 1], [vecSize[0], 1], [0,0,0], 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin, [vecSize[0], 1], [1,1,1], 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, 1], [1, vecSize[1] - 2], [1,1,1], 0.5f);
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [vecSize[0] - 1, 1], [1, vecSize[1] - 2], [0,0,0], 0.5f);
}
#else
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, vecSize[1] - 1], [vecSize[0], 1], m_vecColor, 1.0f);
@ -93,67 +93,67 @@ void CUIScrollbar::Draw(void)
vecSliderPos[1] += (m_iLength - 60) * (m_flValue / m_flMax);
// Slider Button
drawfill(vecSliderPos, '20 20', m_vecColor, m_flAlpha);
drawfill(vecSliderPos, [20,20], m_vecColor, m_flAlpha);
if (m_iFlags & SCROLLBAR_SLIDER_DOWN) {
drawfill(vecSliderPos, [20, 1], '0 0 0', 0.5f);
drawfill(vecSliderPos + [0, 19], [20, 1], '1 1 1', 0.5f);
drawfill(vecSliderPos + [0, 1], [1, 18], '0 0 0', 0.5f);
drawfill(vecSliderPos + [19, 1], [1, 18], '1 1 1', 0.5f);
drawfill(vecSliderPos, [20, 1], [0,0,0], 0.5f);
drawfill(vecSliderPos + [0, 19], [20, 1], [1,1,1], 0.5f);
drawfill(vecSliderPos + [0, 1], [1, 18], [0,0,0], 0.5f);
drawfill(vecSliderPos + [19, 1], [1, 18], [1,1,1], 0.5f);
} else {
drawfill(vecSliderPos, [20, 1], '1 1 1', 0.5f);
drawfill(vecSliderPos + [0, 19], [20, 1], '0 0 0', 0.5f);
drawfill(vecSliderPos + [0, 1], [1, 18], '1 1 1', 0.5f);
drawfill(vecSliderPos + [19, 1], [1, 18], '0 0 0', 0.5f);
drawfill(vecSliderPos, [20, 1], [1,1,1], 0.5f);
drawfill(vecSliderPos + [0, 19], [20, 1], [0,0,0], 0.5f);
drawfill(vecSliderPos + [0, 1], [1, 18], [1,1,1], 0.5f);
drawfill(vecSliderPos + [19, 1], [1, 18], [0,0,0], 0.5f);
}
// Button UP
#ifndef CLASSIC_VGUI
drawfill(vecUpPos, '20 20', m_vecColor, m_flAlpha);
drawfill(vecUpPos, [20,20], m_vecColor, m_flAlpha);
if (m_iFlags & SCROLLBAR_UP_DOWN) {
drawfill(vecUpPos, [20, 1], '0 0 0', 0.5f);
drawfill(vecUpPos + [0, 19], [20, 1], '1 1 1', 0.5f);
drawfill(vecUpPos + [0, 1], [1, 18], '0 0 0', 0.5f);
drawfill(vecUpPos + [19, 1], [1, 18], '1 1 1', 0.5f);
drawfill(vecUpPos, [20, 1], [0,0,0], 0.5f);
drawfill(vecUpPos + [0, 19], [20, 1], [1,1,1], 0.5f);
drawfill(vecUpPos + [0, 1], [1, 18], [0,0,0], 0.5f);
drawfill(vecUpPos + [19, 1], [1, 18], [1,1,1], 0.5f);
} else {
drawfill(vecUpPos, [20, 1], '1 1 1', 0.5f);
drawfill(vecUpPos + [0, 19], [20, 1], '0 0 0', 0.5f);
drawfill(vecUpPos + [0, 1], [1, 18], '1 1 1', 0.5f);
drawfill(vecUpPos + [19, 1], [1, 18], '0 0 0', 0.5f);
drawfill(vecUpPos, [20, 1], [1,1,1], 0.5f);
drawfill(vecUpPos + [0, 19], [20, 1], [0,0,0], 0.5f);
drawfill(vecUpPos + [0, 1], [1, 18], [1,1,1], 0.5f);
drawfill(vecUpPos + [19, 1], [1, 18], [0,0,0], 0.5f);
}
drawpic(vecUpPos + '2 2', "textures/ui/steam/icon_up", '16 16', '1 1 1', 1.0f, 0);
drawpic(vecUpPos + [2,2], "textures/ui/steam/icon_up", [16,16], [1,1,1], 1.0f, 0);
#else
if (m_iFlags & SCROLLBAR_UP_DOWN) {
drawfill(vecUpPos, '20 20', m_vecColor, 0.25f);
drawfill(vecUpPos, [20,20], m_vecColor, 0.25f);
drawfill(vecUpPos, [20, 1], m_vecColor, 1.0f);
drawfill(vecUpPos + [0, 19], [20, 1], m_vecColor, 1.0f);
drawfill(vecUpPos + [0, 1], [1, 18], m_vecColor, 1.0f);
drawfill(vecUpPos + [19, 1], [1, 18], m_vecColor, 1.0f);
} else {
drawfill(vecUpPos, [20, 1], '1 1 1', 0.5f);
drawfill(vecUpPos, [20, 1], [1,1,1], 0.5f);
drawfill(vecUpPos + [0, 19], [20, 1], m_vecColor, 1.0f);
drawfill(vecUpPos + [0, 1], [1, 18], m_vecColor, 1.0f);
drawfill(vecUpPos + [19, 1], [1, 18], m_vecColor, 1.0f);
}
drawpic(vecUpPos + '2 2', "textures/ui/steam/icon_up", '16 16', m_vecColor, 1.0f, 0);
drawpic(vecUpPos + [2,2], "textures/ui/steam/icon_up", [16,16], m_vecColor, 1.0f, 0);
#endif
// Button DOWN
#ifndef CLASSIC_VGUI
drawfill(vecDownPos, '20 20', m_vecColor, m_flAlpha);
drawfill(vecDownPos, [20,20], m_vecColor, m_flAlpha);
if (m_iFlags & SCROLLBAR_DN_DOWN) {
drawfill(vecDownPos, [20, 1], '0 0 0', 0.5f);
drawfill(vecDownPos + [0, 19], [20, 1], '1 1 1', 0.5f);
drawfill(vecDownPos + [0, 1], [1, 18], '0 0 0', 0.5f);
drawfill(vecDownPos + [19, 1], [1, 18], '1 1 1', 0.5f);
drawfill(vecDownPos, [20, 1], [0,0,0], 0.5f);
drawfill(vecDownPos + [0, 19], [20, 1], [1,1,1], 0.5f);
drawfill(vecDownPos + [0, 1], [1, 18], [0,0,0], 0.5f);
drawfill(vecDownPos + [19, 1], [1, 18], [1,1,1], 0.5f);
} else {
drawfill(vecDownPos, [20, 1], '1 1 1', 0.5f);
drawfill(vecDownPos+ [0, 19], [20, 1], '0 0 0', 0.5f);
drawfill(vecDownPos + [0, 1], [1, 18], '1 1 1', 0.5f);
drawfill(vecDownPos + [19, 1], [1, 18], '0 0 0', 0.5f);
drawfill(vecDownPos, [20, 1], [1,1,1], 0.5f);
drawfill(vecDownPos+ [0, 19], [20, 1], [0,0,0], 0.5f);
drawfill(vecDownPos + [0, 1], [1, 18], [1,1,1], 0.5f);
drawfill(vecDownPos + [19, 1], [1, 18], [0,0,0], 0.5f);
}
drawpic(vecDownPos + '2 2', "textures/ui/steam/icon_down", '16 16', '1 1 1', 1.0f, 0);
drawpic(vecDownPos + [2,2], "textures/ui/steam/icon_down", [16,16], [1,1,1], 1.0f, 0);
#else
if (m_iFlags & SCROLLBAR_DN_DOWN) {
drawfill(vecDownPos, '20 20', m_vecColor, 0.25f);
drawfill(vecDownPos, [20,20], m_vecColor, 0.25f);
drawfill(vecDownPos, [20, 1], m_vecColor, 1.0f);
drawfill(vecDownPos + [0, 19], [20, 1], m_vecColor, 1.0f);
drawfill(vecDownPos + [0, 1], [1, 18], m_vecColor, 1.0f);
@ -164,7 +164,7 @@ void CUIScrollbar::Draw(void)
drawfill(vecDownPos + [0, 1], [1, 18], m_vecColor, 1.0f);
drawfill(vecDownPos + [19, 1], [1, 18], m_vecColor, 1.0f);
}
drawpic(vecDownPos + '2 2', "textures/ui/steam/icon_down", '16 16', m_vecColor, 1.0f, 0);
drawpic(vecDownPos + [2,2], "textures/ui/steam/icon_down", [16,16], m_vecColor, 1.0f, 0);
#endif
}
@ -175,17 +175,17 @@ void CUIScrollbar::Input (float flEVType, float flKey, float flChar, float flDev
if (flEVType == IE_KEYDOWN) {
if (flKey == K_MOUSE1) {
if (Util_MouseAbove(getmousepos(), vecUpPos, '20 20')) {
if (Util_MouseAbove(getmousepos(), vecUpPos, [20,20])) {
m_iFlags |= SCROLLBAR_UP_DOWN;
} else if (Util_MouseAbove(getmousepos(), vecDownPos, '20 20')) {
} else if (Util_MouseAbove(getmousepos(), vecDownPos, [20,20])) {
m_iFlags |= SCROLLBAR_DN_DOWN;
}
}
} else if (flEVType == IE_KEYUP) {
if (flKey == K_MOUSE1) {
if (m_iFlags & SCROLLBAR_UP_DOWN && Util_MouseAbove(getmousepos(), vecUpPos, '20 20')) {
if (m_iFlags & SCROLLBAR_UP_DOWN && Util_MouseAbove(getmousepos(), vecUpPos, [20,20])) {
SetValue(GetValue() - GetStep(), TRUE);
} else if (m_iFlags & SCROLLBAR_DN_DOWN && Util_MouseAbove(getmousepos(), vecDownPos, '20 20')) {
} else if (m_iFlags & SCROLLBAR_DN_DOWN && Util_MouseAbove(getmousepos(), vecDownPos, [20,20])) {
SetValue(GetValue() + GetStep(), TRUE);
}
m_iFlags -= (m_iFlags & SCROLLBAR_UP_DOWN);