Change 'impulse 240' for adding bots to 'sv bot_add', which is game-mode
oriented and more flexible to mod authors.
This commit is contained in:
parent
3e0f62127c
commit
c0f97524ce
20 changed files with 101 additions and 37 deletions
|
@ -26,3 +26,5 @@ class bot:player
|
|||
void(void) bot;
|
||||
virtual void(void) PickName;
|
||||
};
|
||||
|
||||
entity Bot_AddQuick(void);
|
||||
|
|
|
@ -108,7 +108,7 @@ ammoinfo_t cs_ammoinfo[11] = {
|
|||
};
|
||||
|
||||
int
|
||||
Ammo_BuyCaliber(player pl, int cal)
|
||||
Ammo_BuyCaliber(player pl, int cal, int free)
|
||||
{
|
||||
int *ptr_ammo;
|
||||
int rv = 0;
|
||||
|
@ -151,7 +151,10 @@ Ammo_BuyCaliber(player pl, int cal)
|
|||
break;
|
||||
|
||||
*ptr_ammo += cs_ammoinfo[cal].a_size;
|
||||
Money_AddMoney(pl, -cs_ammoinfo[cal].price);
|
||||
|
||||
if (!free)
|
||||
Money_AddMoney(pl, -cs_ammoinfo[cal].price);
|
||||
|
||||
rv = 1;
|
||||
}
|
||||
|
||||
|
@ -160,7 +163,6 @@ Ammo_BuyCaliber(player pl, int cal)
|
|||
|
||||
/* We want to loop through all the possible weapons in case the server
|
||||
* enabled the ability to pick up more than one primary/secondary weapon */
|
||||
|
||||
void
|
||||
CSEv_AmmoBuySecondary(void)
|
||||
{
|
||||
|
@ -196,7 +198,7 @@ CSEv_AmmoBuySecondary(void)
|
|||
break;
|
||||
}
|
||||
|
||||
if (Ammo_BuyCaliber(pl, cal) == 1) {
|
||||
if (Ammo_BuyCaliber(pl, cal, FALSE) == 1) {
|
||||
ps = 1;
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +275,7 @@ CSEv_AmmoBuyPrimary(void)
|
|||
break;
|
||||
}
|
||||
|
||||
if (Ammo_BuyCaliber(pl, cal) == 1) {
|
||||
if (Ammo_BuyCaliber(pl, cal, FALSE) == 1) {
|
||||
ps = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ CSEv_BuyWeapon_f(float fWeapon)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Weapons_AddItem(pl, iWeapon, -1);
|
||||
Money_AddMoney(pl, -g_cstrikeWeaponPrice[iWeapon]);
|
||||
Sound_Play(pl, CHAN_ITEM, "buy.weapon");
|
||||
|
|
|
@ -53,6 +53,7 @@ class CSMultiplayerRules:CSGameRules
|
|||
virtual void(base_player) PlayerPreFrame;
|
||||
virtual void(base_player) PlayerDeath;
|
||||
virtual int(int) MaxItemPerSlot;
|
||||
virtual float(base_player, string) ConsoleCommand;
|
||||
|
||||
/* CS specific */
|
||||
virtual void(void) CreateRescueZones;
|
||||
|
|
|
@ -892,6 +892,26 @@ CSMultiplayerRules::PlayerSpawn(base_player pl)
|
|||
forceinfokey(pl, "*team", "0");
|
||||
}
|
||||
|
||||
float
|
||||
CSMultiplayerRules::ConsoleCommand(base_player pp, string cmd)
|
||||
{
|
||||
tokenize(cmd);
|
||||
|
||||
switch (argv(0)) {
|
||||
case "bot_add":
|
||||
entity bot_ent = Bot_AddQuick();
|
||||
if (bot_ent) {
|
||||
bot_ent.think = CSEv_JoinAuto;
|
||||
bot_ent.nextthink = time;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
CSMultiplayerRules::CSMultiplayerRules(void)
|
||||
{
|
||||
|
|
|
@ -43,16 +43,6 @@ Game_Input(void)
|
|||
if (self.impulse == 100) {
|
||||
Flashlight_Toggle();
|
||||
}
|
||||
|
||||
if (self.impulse == 240) {
|
||||
entity bot = Bot_AddQuick();
|
||||
if (bot) {
|
||||
entity oself = self;
|
||||
self = bot;
|
||||
CSEv_JoinAuto();
|
||||
self = oself;
|
||||
}
|
||||
}
|
||||
|
||||
if (cvar("sv_cheats") == 1) {
|
||||
player pl = (player)self;
|
||||
|
|
|
@ -21,7 +21,7 @@ void Money_AddMoney(base_player, int);
|
|||
void Money_QueTeamReward(int, int);
|
||||
void Money_GiveTeamReward(base_player);
|
||||
void Money_ResetTeamReward(void);
|
||||
int Money_GetLosses(int);
|
||||
int Money_HasBonus(int);
|
||||
void Money_HandleRoundReward(int)
|
||||
void Money_ResetRoundReward(void);
|
||||
int Money_GetLosses(int);
|
||||
int Money_HasBonus(int);
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
../cstrike/item_c4bomb.cpp
|
||||
../valve/items.cpp
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../cstrike/game_money.c
|
||||
../cstrike/gamerules.cpp
|
||||
../cstrike/gamerules_singleplayer.cpp
|
||||
|
@ -50,8 +52,6 @@
|
|||
../valve/damage.c
|
||||
../valve/rules.c
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../cstrike/input.c
|
||||
../cstrike/spawn.c
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ entity g_eAttacker;
|
|||
.float material;
|
||||
.float deaths;
|
||||
.float fStepTime;
|
||||
.float gflags;
|
||||
|
||||
/* in idTech the .owner field causes collisions to fail against set entity,
|
||||
* we don't want this all of the time. so use this as a fallback */
|
||||
|
@ -66,8 +67,6 @@ string startspot;
|
|||
string __fullspawndata;
|
||||
hashtable hashMaterials;
|
||||
|
||||
.float gflags;
|
||||
|
||||
enumflags
|
||||
{
|
||||
GF_CANRESPAWN,
|
||||
|
|
|
@ -133,10 +133,11 @@ void initents(void)
|
|||
{
|
||||
iprint("Initializing Entities");
|
||||
|
||||
/* sound shader init */
|
||||
Sound_Init();
|
||||
|
||||
if (serverkeyfloat("*bspversion") != 30) {
|
||||
// Let's load materials.txt because someone thought this was the best idea
|
||||
/* load materials.txt because someone thought this was the best idea */
|
||||
filestream fileMaterial = fopen("sound/materials.txt", FILE_READ);
|
||||
hashMaterials = __NULL__;
|
||||
hashMaterials = hash_createtab(2, HASH_ADD);
|
||||
|
@ -144,7 +145,7 @@ void initents(void)
|
|||
if (fileMaterial >= 0) {
|
||||
string sTemp;
|
||||
while ((sTemp = fgets(fileMaterial))) {
|
||||
// Tokenize and just parse this stuff in
|
||||
/* tokenize and just parse this stuff in */
|
||||
if (tokenize_console(sTemp) == 2) {
|
||||
hash_add(hashMaterials, strtolower(argv(1)), str2chr(argv(0), 0));
|
||||
}
|
||||
|
@ -157,6 +158,7 @@ void initents(void)
|
|||
|
||||
PMove_Init();
|
||||
|
||||
/* TODO: turn these effects into sound shaders */
|
||||
precache_sound("weapons/explode3.wav");
|
||||
precache_sound("weapons/explode4.wav");
|
||||
precache_sound("weapons/explode5.wav");
|
||||
|
@ -228,6 +230,8 @@ void initents(void)
|
|||
Decals_Init();
|
||||
Sentences_Init();
|
||||
|
||||
/* TODO: Make sure every entity calls Respawn inside the constructor, then
|
||||
* remove this */
|
||||
entity respawntimer = spawn();
|
||||
respawntimer.think = init_respawn;
|
||||
respawntimer.nextthink = time + 0.1f;
|
||||
|
|
|
@ -73,6 +73,8 @@
|
|||
../valve/ammo.cpp
|
||||
../gearbox/ammo_op4.cpp
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../gearbox/gamerules.cpp
|
||||
../valve/gamerules_singleplayer.cpp
|
||||
../valve/gamerules_multiplayer.cpp
|
||||
|
@ -82,8 +84,6 @@
|
|||
../valve/damage.c
|
||||
../valve/rules.c
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../valve/input.c
|
||||
../valve/spawn.c
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@
|
|||
../valve/ammo.cpp
|
||||
../hunger/ammo_th.cpp
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../valve/gamerules.cpp
|
||||
../valve/gamerules_singleplayer.cpp
|
||||
../valve/gamerules_multiplayer.cpp
|
||||
|
@ -79,8 +81,6 @@
|
|||
../valve/damage.c
|
||||
../valve/rules.c
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../hunger/input.c
|
||||
../valve/spawn.c
|
||||
|
||||
|
|
|
@ -103,3 +103,19 @@ HLMultiplayerRules::PlayerSpawn(base_player pp)
|
|||
|
||||
Client_FixAngle(pl, pl.angles);
|
||||
}
|
||||
|
||||
float
|
||||
HLMultiplayerRules::ConsoleCommand(base_player pp, string cmd)
|
||||
{
|
||||
tokenize(cmd);
|
||||
|
||||
switch (argv(0)) {
|
||||
case "bot_add":
|
||||
Bot_AddQuick();
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@
|
|||
../valve/xen_plantlight.cpp
|
||||
../poke646/ammo_p646.cpp
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../poke646/gamerules.cpp
|
||||
../valve/gamerules_singleplayer.cpp
|
||||
../poke646/gamerules_multiplayer.cpp
|
||||
|
@ -77,8 +79,6 @@
|
|||
../valve/damage.c
|
||||
../valve/rules.c
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../poke646/input.c
|
||||
../valve/spawn.c
|
||||
|
||||
|
|
|
@ -109,3 +109,19 @@ HLMultiplayerRules::PlayerSpawn(base_player pp)
|
|||
|
||||
Client_FixAngle(pl, pl.angles);
|
||||
}
|
||||
|
||||
float
|
||||
HLMultiplayerRules::ConsoleCommand(base_player pp, string cmd)
|
||||
{
|
||||
tokenize(cmd);
|
||||
|
||||
switch (argv(0)) {
|
||||
case "bot_add":
|
||||
Bot_AddQuick();
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
../valve/items.cpp
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../rewolf/gamerules.cpp
|
||||
../valve/gamerules_singleplayer.cpp
|
||||
../rewolf/gamerules_multiplayer.cpp
|
||||
|
@ -33,8 +35,6 @@
|
|||
../valve/damage.c
|
||||
../valve/rules.c
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../rewolf/input.c
|
||||
../valve/spawn.c
|
||||
|
||||
|
|
|
@ -43,4 +43,5 @@ class HLMultiplayerRules:HLGameRules
|
|||
/* client */
|
||||
virtual void(base_player) PlayerSpawn;
|
||||
virtual void(base_player) PlayerDeath;
|
||||
virtual float(base_player, string) ConsoleCommand;
|
||||
};
|
||||
|
|
|
@ -141,3 +141,19 @@ HLMultiplayerRules::PlayerSpawn(base_player pp)
|
|||
|
||||
Client_FixAngle(pl, pl.angles);
|
||||
}
|
||||
|
||||
float
|
||||
HLMultiplayerRules::ConsoleCommand(base_player pp, string cmd)
|
||||
{
|
||||
tokenize(cmd);
|
||||
|
||||
switch (argv(0)) {
|
||||
case "bot_add":
|
||||
Bot_AddQuick();
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -49,9 +49,6 @@ void Game_Input(void)
|
|||
if (self.impulse == 100) {
|
||||
Flashlight_Toggle();
|
||||
}
|
||||
|
||||
if (self.impulse == 240)
|
||||
Bot_AddQuick();
|
||||
|
||||
if (cvar("sv_cheats") == 1) {
|
||||
player pl = (player)self;
|
||||
|
|
|
@ -69,6 +69,8 @@
|
|||
../valve/xen_plantlight.cpp
|
||||
../valve/ammo.cpp
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../valve/gamerules.cpp
|
||||
../valve/gamerules_singleplayer.cpp
|
||||
../valve/gamerules_multiplayer.cpp
|
||||
|
@ -77,8 +79,6 @@
|
|||
../valve/damage.c
|
||||
../valve/rules.c
|
||||
|
||||
../../botlib/include.src
|
||||
|
||||
../valve/input.c
|
||||
../valve/spawn.c
|
||||
|
||||
|
|
Loading…
Reference in a new issue