CGameRules: Allow different MaxItemPerSlot limits per slot type.

This commit is contained in:
Marco Cawthorne 2020-04-24 05:37:54 +02:00
parent cc0e7edec0
commit 82d14b46d8
7 changed files with 24 additions and 10 deletions

View File

@ -77,7 +77,7 @@ CSEv_BuyWeapon_f(float fWeapon)
if ((pl.money - g_cstrikeWeaponPrice[iWeapon]) >= 0) {
/* let's check if we've got a limit */
int maxit;
maxit = rules.MaxItemPerSlot();
maxit = rules.MaxItemPerSlot(g_weapons[iWeapon].slot);
if (maxit > 0) {
int wantslot = g_weapons[iWeapon].slot;
int c;

View File

@ -52,7 +52,7 @@ class CSMultiplayerRules:CSGameRules
virtual void(player) PlayerSpawn;
virtual void(player) PlayerPreFrame;
virtual void(player) PlayerDeath;
virtual int(void) MaxItemPerSlot;
virtual int(int) MaxItemPerSlot;
/* CS specific */
virtual void(void) CreateRescueZones;

View File

@ -15,8 +15,12 @@
*/
int
CSMultiplayerRules::MaxItemPerSlot(void)
CSMultiplayerRules::MaxItemPerSlot(int slot)
{
/* grenades */
if (slot == 3) {
return 3;
}
return 1;
}
@ -486,6 +490,9 @@ CSMultiplayerRules::RoundOver(int iTeamWon, int iMoneyReward, int fSilent)
g_cs_hostagesrescued = 0;
g_cs_bombplanted = 0;
g_cs_roundsplayed++;
forceinfokey(world, "teamscore_1", sprintf("%i", g_cs_roundswon_t));
forceinfokey(world, "teamscore_2", sprintf("%i", g_cs_roundswon_ct));
}
/*
@ -547,6 +554,9 @@ CSMultiplayerRules::SwitchTeams(void)
g_cs_alive_ct = iTW;
g_cs_alive_t = iCTW;
forceinfokey(world, "teamscore_1", sprintf("%i", g_cs_roundswon_t));
forceinfokey(world, "teamscore_2", sprintf("%i", g_cs_roundswon_ct));
}
void
@ -796,7 +806,11 @@ CSMultiplayerRules::PlayerSpawn(player pl)
void
CSMultiplayerRules::CSMultiplayerRules(void)
{
forceinfokey(world, "*gamemode", "classic");
forceinfokey(world, "teams", "2");
forceinfokey(world, "team_1", "Terrorist");
forceinfokey(world, "teamscore_1", "0");
forceinfokey(world, "team_2", "Counter-Terrorist");
forceinfokey(world, "teamscore_2", "0");
}
/*
@ -887,7 +901,7 @@ void CSEv_JoinAuto(void)
}
}
if (ct_count > t_count) {
if (ct_count >= t_count) {
CSEv_JoinTeam_f(floor(random(1,5)));
} else {
CSEv_JoinTeam_f(floor(random(5,9)));

View File

@ -105,7 +105,7 @@ CGameRules::SpectatorThink(player pl)
}*/
int
CGameRules::MaxItemPerSlot(void)
CGameRules::MaxItemPerSlot(int slot)
{
return -1;
}
@ -113,7 +113,7 @@ CGameRules::MaxItemPerSlot(void)
void
CGameRules::CGameRules(void)
{
//print("CGameRules!\n");
forceinfokey(world, "teamplay", "0");
}
/* our currently running mode */

View File

@ -38,7 +38,7 @@ class CGameRules
virtual void(void) LevelNewParms;
virtual void(player) LevelChangeParms;
virtual int(void) MaxItemPerSlot;
virtual int(int) MaxItemPerSlot;
/* spectator */
/*virtual void(player) SpectatorConnect;

View File

@ -38,7 +38,7 @@
#define FL_SEMI_TOGGLED (1<<19)
#define FL_FROZEN (1<<20)
#define FL_RESERVED1 (1<<21)
#define FL_RESERVED2 (1<<22)
#define FL_RESERVED2 (1<<22)
#define FL_RESERVED3 (1<<23)
/* game flags */

View File

@ -287,7 +287,7 @@ int Weapons_AddItem(player pl, int w)
/* let's check if we've got a limit */
int maxit;
CGameRules rules = (CGameRules)g_grMode;
maxit = rules.MaxItemPerSlot();
maxit = rules.MaxItemPerSlot(g_weapons[w].slot);
if (maxit > 0) {
int wantslot = g_weapons[w].slot;
int c;