Add bomb site text hint for T's and add the base for an upcoming, built-in DM gamemode.

This commit is contained in:
Marco Cawthorne 2023-09-29 16:12:44 -07:00
parent 1736b85824
commit 0a283c5282
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
12 changed files with 401 additions and 1 deletions

View File

@ -130,6 +130,7 @@ void CMD_ChooseTeam(void);
void
ClientGame_InitDone(void)
{
if (serverkey("mode") == "Counter-Strike")
if (serverkeyfloat("sv_playerslots") > 1)
VGUI_ShowMOTD();
}

View File

@ -61,5 +61,9 @@ func_bomb_target::Touch(entity eToucher)
return;
}
if (g_csMode.ShowHints() && pl.m_seenBombSite == false) {
env_message_single(pl, "Hint_you_are_in_targetzone");
pl.m_seenBombSite = true;
}
pl.gflags |= GF_BOMBZONE;
}

View File

@ -84,6 +84,7 @@ func_buyzone::Touch(entity eToucher)
if (team == 0 || team == pl.team)
pl.gflags |= GF_BUYZONE;
if (g_csMode.ShowHints() == true)
if (pl.m_buyMessage == false) {
env_message_single(pl, "Hint_press_buy_to_purchase");
pl.m_buyMessage = true;

View File

@ -29,17 +29,44 @@ class CSGameRules:CGameRules
virtual void LevelNewParms(void);
virtual bool BuyingPossible(NSClientPlayer);
virtual bool ShowHints(void);
virtual bool ImpulseCommand(NSClient, float);
};
class CSSingleplayerRules:CSGameRules
{
virtual string Title(void);
/* client */
virtual void PlayerSpawn(NSClientPlayer);
virtual void PlayerDeath(NSClientPlayer);
};
class CSDeathmatchRules:CSGameRules
{
int m_iIntermission;
int m_iIntermissionTime;
string m_strTeamList;
void(void) CSDeathmatchRules;
virtual string Title(void);
virtual void(void) FrameStart;
virtual void(void) CheckRules;
virtual bool(void) MonstersSpawn;
/* client */
virtual void(NSClientPlayer) PlayerSpawn;
virtual void(NSClientPlayer) PlayerDeath;
virtual bool(NSClientPlayer, string) ConsoleCommand;
virtual bool(void) IsMultiplayer;
virtual bool(void) IsTeamplay;
virtual void(void) InitPostEnts;
virtual bool PlayerRequestRespawn(NSClientPlayer);
virtual bool ShowHints(void);
};
class CSMultiplayerRules:CSGameRules
{
entity m_eLastTSpawn;
@ -50,6 +77,7 @@ class CSMultiplayerRules:CSGameRules
void CSMultiplayerRules(void);
virtual string Title(void);
virtual void InitPostEnts(void);
virtual void FrameStart(void);
virtual void PlayerDisconnect(NSClientPlayer);
@ -87,3 +115,5 @@ class CSMultiplayerRules:CSGameRules
};
void CSEv_JoinAuto(void);
CSGameRules g_csMode;

View File

@ -24,6 +24,12 @@ CSGameRules::PlayerPain(NSClientPlayer pl)
{
}
bool
CSGameRules::ShowHints(void)
{
return (true);
}
bool
CSGameRules::BuyingPossible(NSClientPlayer pl)
{

View File

@ -0,0 +1,336 @@
/*
* Copyright (c) 2016-2023 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
const string mp_teamlist_fallback = "robo;hgrunt";
var string autocvar_mp_teamlist = mp_teamlist_fallback;
string
CSDeathmatchRules::Title(void)
{
return "Deathmatch";
}
bool
CSDeathmatchRules::ShowHints(void)
{
return (false);
}
bool
CSDeathmatchRules::IsMultiplayer(void)
{
return (true);
}
bool
CSDeathmatchRules::PlayerRequestRespawn(NSClientPlayer bp)
{
if (bp.TimeSinceDeath() > 0.5f) {
bp.ScheduleThink(PutClientInServer, 0.0f);
return (true);
}
return (false);
}
bool
CSDeathmatchRules::IsTeamplay(void)
{
return cvar("mp_teamplay") == 1 ? true : false;
}
void
CSDeathmatchRules::InitPostEnts(void)
{
MOTD_LoadDefault();
forceinfokey(world, "scorepoints", "0");
if (IsTeamplay() == true) {
int c;
/* get the segments from our cvar */
m_strTeamList = autocvar_mp_teamlist;
c = tokenizebyseparator(m_strTeamList, ";");
/* if we've got less than 2 teams, use the fallback... */
if (c < 2) {
m_strTeamList = mp_teamlist_fallback;
c = tokenizebyseparator(m_strTeamList, ";");
}
forceinfokey(world, "teams", itos(c));
/* initialize all dem teams */
for (int i = 0; i < c; i++) {
forceinfokey(world, sprintf("team_%i", i+1i), argv(i));
forceinfokey(world, sprintf("teamscore_%i", i+1i), "0");
}
} else {
forceinfokey(world, "teams", "0");
}
}
void
CSDeathmatchRules::FrameStart(void)
{
if (cvar("timelimit"))
if (time >= (cvar("timelimit") * 60)) {
IntermissionStart();
}
IntermissionCycle();
}
void
CSDeathmatchRules::CheckRules(void)
{
/* last person who killed somebody has hit the limit */
if (cvar("fraglimit"))
if (g_dmg_eAttacker.frags >= cvar("fraglimit"))
IntermissionStart();
}
void
CSDeathmatchRules::PlayerDeath(NSClientPlayer pl)
{
/* obituary networking */
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_OBITUARY);
WriteString(MSG_MULTICAST, (g_dmg_eAttacker.netname) ? g_dmg_eAttacker.netname : g_dmg_eAttacker.classname);
WriteString(MSG_MULTICAST, pl.netname);
WriteByte(MSG_MULTICAST, g_dmg_iWeapon);
WriteByte(MSG_MULTICAST, 0);
msg_entity = world;
multicast([0,0,0], MULTICAST_ALL);
Plugin_PlayerObituary(g_dmg_eAttacker, g_dmg_eTarget, g_dmg_iWeapon, g_dmg_iHitBody, g_dmg_iDamage);
/* death-counter */
pl.deaths++;
pl.SetInfoKey("*deaths", ftos(pl.deaths));
/* update score-counter */
if (pl.flags & FL_CLIENT || pl.flags & FL_MONSTER)
if (g_dmg_eAttacker.flags & FL_CLIENT) {
if (pl == g_dmg_eAttacker)
g_dmg_eAttacker.frags--;
else
g_dmg_eAttacker.frags++;
}
#if 0
/* explode all satchels */
s_satchel_detonate((entity)pl);
/* drop their posessions into a weaponbox item */
weaponbox_spawn((player)pl);
#endif
/* either gib, or make a corpse */
if (pl.health < -50) {
vector gibDir = vectoangles(pl.origin - g_dmg_eAttacker.origin);
float gibStrength = g_dmg_iDamage * 2.0f;
BreakModel_Entity(pl, gibDir, gibStrength);
} else {
FX_Corpse_Spawn(pl, ANIM_DEATH1);
//FX_Corpse_Spawn((player)pl, ANIM_DIESIMPLE);
}
/* now let's make the real client invisible */
pl.Death();
pl.SetTakedamage(DAMAGE_NO);
pl.gflags &= ~GF_FLASHLIGHT;
Sound_Play(pl, CHAN_AUTO, "player.die");
/* force respawn */
pl.ScheduleThink(PutClientInServer, 4.0f);
/* have we gone over the fraglimit? */
CheckRules();
}
void
CSDeathmatchRules::PlayerSpawn(NSClientPlayer pp)
{
player pl = (player)pp;
string playerModel;
/* this is where the mods want to deviate */
entity spot;
pl.classname = "player";
pl.SetMaxHealth(100);
pl.SetHealth(100);
pl.SetArmor(100);
pl.SetTakedamage(DAMAGE_YES);
pl.SetSolid(SOLID_SLIDEBOX);
pl.SetMovetype(MOVETYPE_WALK);
pl.AddFlags(FL_CLIENT);
pl.viewzoom = 1.0;
/* player model selection */
if (IsTeamplay() == true) {
int teamCount = tokenizebyseparator(m_strTeamList, ";");
int playerTeam = (int)pl.GetTeam();
/* not part of a team? pick one of the ones we have */
/* TODO: this should sort us into the lowest team */
if (playerTeam == 0) {
playerTeam = 1i + (int)floor(random(0, (float)teamCount)); /* teams start at 1 after all */
pl.SetTeam(playerTeam);
}
/* assign our player model */
playerModel = sprintf("models/player/%s/%s.mdl", argv(playerTeam - 1i), argv(playerTeam - 1i));
} else {
pl.charmodel = rint(random(1,9));
}
switch (pl.charmodel) {
case 1:
pl.model = "models/player/terror/terror.mdl";
break;
case 2:
pl.model = "models/player/leet/leet.mdl";
break;
case 3:
pl.model = "models/player/arctic/arctic.mdl";
break;
case 4:
pl.model = "models/player/guerilla/guerilla.mdl";
break;
case 5:
pl.model = "models/player/urban/urban.mdl";
break;
case 6:
pl.model = "models/player/gsg9/gsg9.mdl";
break;
case 7:
pl.model = "models/player/sas/sas.mdl";
break;
case 8:
pl.model = "models/player/gign/gign.mdl";
break;
default:
pl.model = "models/player/vip/vip.mdl";
}
/* fallback is always models/player.mdl for Half-Life */
if not (whichpack(playerModel)) {
playerModel = "models/player.mdl";
}
pl.SetModel(playerModel);
pl.SetSize(VEC_HULL_MIN, VEC_HULL_MAX);
pl.ClearVelocity();
pl.gravity = __NULL__;
pl.SetFrame(1);
pl.SendFlags = UPDATE_ALL;
pl.SetInfoKey("*spec", "0");
pl.SetInfoKey("*dead", "0");
pl.SetInfoKey("*deaths", ftos(pl.deaths));
pl.SetPropData("actor_human");
pl.SetCanBleed(true);
LevelNewParms();
LevelDecodeParms(pl);
pl.g_items = ITEM_KNIFE | ITEM_SUIT;
pl.activeweapon = WEAPON_KNIFE;
int randomGun = (int)rint(random(WEAPON_USP45, WEAPON_FIVESEVEN));
Weapons_AddItem(pl, randomGun, -1);
randomGun = (int)rint(random(WEAPON_M3, WEAPON_PARA));
Weapons_AddItem(pl, randomGun, -1);
pl.activeweapon = randomGun;
Ammo_BuyPrimary(pl, TRUE);
Ammo_BuySecondary(pl, TRUE);
spot = Spawn_SelectRandom("info_player_deathmatch");
pl.Transport(spot.origin, spot.angles);
Weapons_RefreshAmmo(pl);
Client_FixAngle(pl, pl.angles);
}
bool
CSDeathmatchRules::ConsoleCommand(NSClientPlayer pp, string cmd)
{
tokenize(cmd);
switch (argv(0)) {
case "bot_add":
bot pete = (bot)Bot_AddQuick();
Bot_RandomColormap(pete);
searchhandle pm = search_begin("models/player/*/*.mdl", TRUE, TRUE);
int r = floor(random(0, search_getsize(pm)));
string mdl = substring(search_getfilename(pm, r), 0, -5);
tokenizebyseparator(mdl, "/");
pete.SetInfoKey("model", argv(2));
search_end(pm);
break;
case "jumptest":
makevectors(pp.v_angle);
traceline(pp.origin + pp.view_ofs, pp.origin + pp.view_ofs + v_forward * 1024, FALSE, pp);
pp.velocity = Route_GetJumpVelocity(pp.origin, trace_endpos, pp.gravity);
break;
default:
return (false);
}
return (true);
}
bool
CSDeathmatchRules::MonstersSpawn(void)
{
return (autocvar(mp_allowmonsters, 0)) ? true : false;
}
void
CSDeathmatchRules::CSDeathmatchRules(void)
{
/* these lines do nothing but tell the server to register those cvars */
autocvar(timelimit, 15, "Timelimit for multiplayer rounds");
autocvar(fraglimit, 15, "Points limit for multiplayer rounds");
}
void
CSEv_HLDM_Chooseteam_s(string teamName)
{
CSGameRules rules = (CSGameRules)g_grMode;
player pl = (player)self;
if (!teamName)
return;
if (rules.IsMultiplayer() == false)
return;
if (rules.IsTeamplay() == false)
return;
if (pl.IsDead() == true)
return;
CSDeathmatchRules mprules = (CSDeathmatchRules)rules;
int c = tokenizebyseparator(mprules.m_strTeamList, ";");
for (int i = 0; i < c; i++) {
if (argv(i) == teamName) {
pl.SetTeam((float)i + 1);
Damage_Apply(pl, pl, 100, 0, DMG_SKIP_ARMOR);
return;
}
}
}

View File

@ -14,6 +14,12 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
string
CSMultiplayerRules::Title(void)
{
return "Counter-Strike";
}
int
CSMultiplayerRules::MaxItemPerSlot(int slot)
{

View File

@ -14,6 +14,12 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
string
CSSingleplayerRules::Title(void)
{
return "Singleplayer";
}
void
CSSingleplayerRules::PlayerDeath(NSClientPlayer pl)
{

View File

@ -126,6 +126,8 @@ hostage_entity::OnPlayerUse(void)
{
if (eActivator.team == TEAM_T) {
player pl = (player)eActivator;
if (g_csMode.ShowHints() == true)
if (pl.m_hostMessageT == false) {
env_message_single(pl, "Only_CT_Can_Move_Hostages");
pl.m_hostMessageT = true;

View File

@ -42,6 +42,7 @@ bot.qc
game_money.qc
gamerules.qc
gamerules_singleplayer.qc
gamerules_deathmatch.qc
gamerules_multiplayer.qc
radio.qc

View File

@ -20,8 +20,14 @@ Game_InitRules(void)
if (cvar("sv_playerslots") == 1 || cvar("coop") == 1) {
g_grMode = spawn(CSSingleplayerRules);
} else {
g_grMode = spawn(CSMultiplayerRules);
if (cvar("fcs_deathmatch") == 1) {
g_grMode = spawn(CSDeathmatchRules);
} else {
g_grMode = spawn(CSMultiplayerRules);
}
}
g_csMode = (CSGameRules)g_grMode;
}
void

View File

@ -199,6 +199,7 @@ class player:NSClientPlayer
bool m_seenFriend;
bool m_seenEnemy;
bool m_seenHostage;
bool m_seenBombSite;
#endif
};