Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot customization and bugfix #16

Open
wants to merge 10 commits into
base: bInfection
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/game/server/bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@
#include "entities/flag.h"
#include "entities/pickup.h"

//default skins for bots. (added per-bot skin changing, works with non-vanilla skins too) -skay
char g_BotSkin[MAX_CLIENTS][16] = {
"default",
"cammo",
"warpaint",
"cammostripes",
"redbopp",
"redstripe",
"twinbop",
"saddo",
"limmekitty",
"brownbear",
"bluestripe",
"coala",
"twintri",
"pinky",
"bluekitty",
"toptri"

};


CBot::CBot(CBotEngine *pBotEngine, CPlayer *pPlayer) : m_Genetics(CTarget::NUM_TARGETS,10)
{
m_pBotEngine = pBotEngine;
Expand Down Expand Up @@ -801,6 +823,15 @@ const char *CBot::GetName() {
return g_BotName[m_pPlayer->GetCID()];
}

const char *CBot::GetSkin() {
char *temp = strtok (g_Config.m_SvBotSkin, " ");
for (size_t i = 0; i < MAX_CLIENTS && temp; ++i){
strcpy (g_BotSkin[i], temp);
temp = strtok (NULL, " ");
}
return g_BotSkin[m_pPlayer->GetCID()];
}

const char *CBot::GetRepartee() {
if(!m_pPlayer->Infected())
return "Shut up and kill !";
Expand Down
5 changes: 4 additions & 1 deletion src/game/server/bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
#define GAME_SERVER_BOT_H

#include <base/vmath.h>
#include <engine/shared/config.h>

#include "gamecontext.h"
#include "botengine.h"

#include "ai/genetics.h"

const char g_BotClan[12] = "Love";
const char g_BotClan[12] = {*g_Config.m_SvBotClan};
const char g_BotName[MAX_CLIENTS][16] = {
"Anna",
"Bob",
Expand All @@ -27,6 +28,7 @@ const char g_BotName[MAX_CLIENTS][16] = {
"Ondine",
"Platon"
};
extern char g_BotSkin[MAX_CLIENTS][16]; //made this one extern to avoid a segmentation fault and weird compilation -skay

#define BOT_HOOK_DIRS 32

Expand Down Expand Up @@ -127,6 +129,7 @@ class CBot
int m_GenomeTick;

const char *GetName();
const char *GetSkin();
const char *GetClan() { return g_BotClan; }

int GetID() { return m_SnapID; }
Expand Down
19 changes: 12 additions & 7 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,11 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon, int Firew
if (GameServer()->m_apPlayers[From] && GameServer()->m_apPlayers[From]->Infected() && !m_pPlayer->Infected())
m_pPlayer->Infect(From, Weapon);

// m_pPlayer only inflicts half damage on self
if(From == m_pPlayer->GetCID())
// m_pPlayer only inflicts half damage on self, if selfdamage is off: damage is 0 -skay
if(From == m_pPlayer->GetCID() && g_Config.m_SvSelfdamage == 1)
Dmg = max(1, Dmg/2);
else if(From == m_pPlayer->GetCID() && g_Config.m_SvSelfdamage == 0)
Dmg = 0;

m_DamageTaken++;

Expand All @@ -850,7 +852,8 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon, int Firew
GameServer()->CreateDamageInd(m_Pos, 0, Dmg);
}

if(m_pPlayer->m_Zombie && GameServer()->m_apPlayers[From]->m_Zombie && Weapon == WEAPON_HAMMER)
//bug: player only deals selfdamage if has armor (no selfdamage if no armor) fix: changed "zombie" to "infected" -skay
if(m_pPlayer->Infected() && GameServer()->m_apPlayers[From]->m_Zombie && Weapon == WEAPON_HAMMER)
{
//Lets be nice to our zombie mates
if(Dmg)
Expand Down Expand Up @@ -903,10 +906,12 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon, int Firew
}
}

if (From == m_pPlayer->GetCID() && Firework)
{
Dmg = 0;
}
// m_pPlayer only inflicts half damage on self, if selfdamage is off: damage is 0. this one is for fireworks -skay
if(From == m_pPlayer->GetCID() && g_Config.m_SvSelfdamage == 1 && Firework)
Dmg = max(1, Dmg/2);
else if(From == m_pPlayer->GetCID() && g_Config.m_SvSelfdamage == 0 && Firework)
Dmg = 0;

m_Health -= Dmg;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/game/server/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ void CPlayer::Snap(int SnappingClient)
StrToInts(&pClientInfo->m_Name0, 4, Server()->ClientName(m_ClientID));
StrToInts(&pClientInfo->m_Clan0, 3, (m_Zombie != HUMAN)? (m_Zombie == ZOMBIE)? "Zombie" : "iZombie" : Server()->ClientClan(m_ClientID));
pClientInfo->m_Country = Server()->ClientCountry(m_ClientID);
StrToInts(&pClientInfo->m_Skin0, 6, m_Zombie ? "cammo" : m_TeeInfos.m_SkinName);
StrToInts(&pClientInfo->m_Skin0, 6, m_Zombie ? g_Config.m_SvZombSkin : m_TeeInfos.m_SkinName);
}
else {
StrToInts(&pClientInfo->m_Name0, 4, m_pBot->GetName());
StrToInts(&pClientInfo->m_Clan0, 3, (m_Zombie != HUMAN)? (m_Zombie == ZOMBIE)? "Zombie" : "iZombie" : m_pBot->GetClan());
StrToInts(&pClientInfo->m_Clan0, 3, (m_Zombie != HUMAN)? (m_Zombie == ZOMBIE)? "Zombie" : "iZombie" : g_Config.m_SvBotClan); //bot clan changing added -skay
pClientInfo->m_Country = 0;
StrToInts(&pClientInfo->m_Skin0, 6, m_Zombie ? "cammo" : g_Config.m_SvBotSkin);
StrToInts(&pClientInfo->m_Skin0, 6, m_Zombie ? g_Config.m_SvZombSkin : m_pBot->GetSkin()); //per bot skin changing -skay
}

pClientInfo->m_UseCustomColor = m_Zombie ? true : false;
Expand Down
5 changes: 4 additions & 1 deletion src/game/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ MACRO_CONFIG_INT(GfxNoclip, gfx_noclip, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "D
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, 0, 0, CFGFLAG_SERVER, "Number of seconds to do warmup before round starts")
MACRO_CONFIG_STR(SvMotd, sv_motd, 900, "", CFGFLAG_SERVER, "Message of the day to display for the clients")
MACRO_CONFIG_INT(SvTeamdamage, sv_teamdamage, 0, 0, 1, CFGFLAG_SERVER, "Team damage")
MACRO_CONFIG_INT(SvSelfdamage, sv_selfdamage, 1, 0, 1, CFGFLAG_SERVER, "whether players can hurt themselves with grenade or not, default is 1")
MACRO_CONFIG_STR(SvMaprotation, sv_maprotation, 768, "", CFGFLAG_SERVER, "Maps to rotate between")
MACRO_CONFIG_INT(SvRoundsPerMap, sv_rounds_per_map, 1, 1, 100, CFGFLAG_SERVER, "Number of rounds on each map before rotating")
MACRO_CONFIG_INT(SvRoundSwap, sv_round_swap, 1, 0, 1, CFGFLAG_SERVER, "Swap teams between rounds")
Expand Down Expand Up @@ -106,7 +107,9 @@ MACRO_CONFIG_INT(InfRandomIZombiePicking, inf_random_izombie_picking, 1, 0, 1, C

//Server Bots
MACRO_CONFIG_INT(SvBotSlots, sv_bot_slots, 2, 0, MAX_CLIENTS, CFGFLAG_SERVER, "Number of slots to reserve for bots")
MACRO_CONFIG_STR(SvBotSkin, sv_bot_skin, 24, "default", CFGFLAG_SERVER, "Bot skin")
MACRO_CONFIG_STR(SvBotSkin, sv_bot_skin, 800, "default cammo warpaint cammostripes redbopp redstripe twinbop saddo limekitty brownbear bluestripe coala twintri pinky toptri bluekitty", CFGFLAG_SERVER, "Bot skin, separated by spaces, up to 16 skins")
MACRO_CONFIG_STR(SvZombSkin, sv_zombie_skin, 24, "cammo", CFGFLAG_SERVER, "Zombie skin, default is cammo")
MACRO_CONFIG_STR(SvBotClan, sv_bot_clan, 12, "Love", CFGFLAG_SERVER, "Bot clan")
MACRO_CONFIG_INT(SvBotAllowHook, sv_bot_allow_hook, 1, 0, 1, CFGFLAG_SERVER, "Bots are allowed to hook")
MACRO_CONFIG_INT(SvBotAllowMove, sv_bot_allow_move, 1, 0, 1, CFGFLAG_SERVER, "Bots are allowed to move")
MACRO_CONFIG_INT(SvBotAllowFire, sv_bot_allow_fire, 1, 0, 1, CFGFLAG_SERVER, "Bots fire")
Expand Down