From f041ce6282b9980b2d44dd9d6b026cd4e86fb9ff Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sat, 11 Nov 2006 15:57:23 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@586 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/bot/ac_bot.cpp | 83 +---------- source/src/bot/ac_bot.h | 1 - source/src/bot/bot.cpp | 56 +------- source/src/bot/bot.h | 3 - source/src/bot/bot_ai.cpp | 17 ++- source/src/bot/bot_util.cpp | 7 +- source/src/bot/botmanager.cpp | 110 +-------------- source/src/clientextras.cpp | 5 - source/src/clientgame.cpp | 163 ++++++++++----------- source/src/clients2c.cpp | 238 +------------------------------ source/src/physics.cpp | 33 +---- source/src/protos.h | 5 +- source/src/rendergl.cpp | 2 - source/src/savegamedemo.cpp | 9 -- source/src/server.cpp | 259 +--------------------------------- source/src/sound.cpp | 7 - source/src/weapon.cpp | 105 ++------------ 17 files changed, 129 insertions(+), 974 deletions(-) diff --git a/source/src/bot/ac_bot.cpp b/source/src/bot/ac_bot.cpp index e55b5da3..e3d8e905 100644 --- a/source/src/bot/ac_bot.cpp +++ b/source/src/bot/ac_bot.cpp @@ -123,85 +123,6 @@ void CACBot::Spawn() ResetWaypointVars(); } -void CACBot::BotPain(int damage, playerent *d, bool gib) -{ - if(m_pMyEnt->state!=CS_ALIVE || editmode || intermission) return; -//fixmebot - int ad = damage*30/100; - if(ad>m_pMyEnt->armour) ad = m_pMyEnt->armour; - m_pMyEnt->armour -= ad; - damage -= ad; - float droll = damage/0.5f; - m_pMyEnt->roll += m_pMyEnt->roll>0 ? droll : (m_pMyEnt->roll<0 ? -droll : (rnd(2) ? droll : -droll)); // give player a kick depending on amount of damage - if((m_pMyEnt->health -= damage)<=0) - { - if (player1 == d) - { - int frags; - if(isteam(player1->team, m_pMyEnt->team)) - { - frags = -1; - conoutf("you fragged a teammate (%s)", m_pMyEnt->name); - } - else - { - frags = 1; - conoutf("you fragged %s", m_pMyEnt->name); - } - addmsg(SV_FRAGS, "ri", player1->frags += frags); - addmsg(SV_BOTDIED, "ri3", BotManager.GetBotIndex(m_pMyEnt), -1, false); - if(gib) addgib(m_pMyEnt); - } - else - { - int KillerIndex = -1; - - if (d == m_pMyEnt) - { - conoutf("%s suicided", d->name); - KillerIndex = BotManager.GetBotIndex(m_pMyEnt); - addmsg(SV_BOTFRAGS, "rii", KillerIndex, --d->frags); - } - else - { - if (d->type==ENT_BOT) - { - KillerIndex = BotManager.GetBotIndex((botent *)d); - addmsg(SV_BOTFRAGS, "rii", KillerIndex, ++d->frags); - } - else - loopv(players){ if (players[i] == d) { KillerIndex = i; break;} } - - if(isteam(m_pMyEnt->team, d->team)) - { - conoutf("%s fragged his teammate (%s)", d->name, - m_pMyEnt->name); - } - else - { - conoutf("%s fragged %s", d->name, m_pMyEnt->name); - } - } - addmsg(SV_BOTDIED, "ri3", BotManager.GetBotIndex(m_pMyEnt), KillerIndex, - d->type==ENT_BOT); - if(d->gunselect==GUN_KNIFE) addgib(m_pMyEnt); - } - - m_pMyEnt->lifesequence++; - m_pMyEnt->attacking = false; - m_pMyEnt->state = CS_DEAD; - m_pMyEnt->pitch = 0; - m_pMyEnt->roll = 60; - playsound(S_DIE1+rnd(2), &m_pMyEnt->o); - spawnstate(m_pMyEnt); - m_pMyEnt->lastaction = lastmillis; - } - else - { - playsound(S_PAIN6, &m_pMyEnt->o); - } -} - void CACBot::CheckItemPickup() { if(editmode) return; @@ -284,12 +205,10 @@ void CACBot::AddItem(int i, int &v, int spawnsec, int t) ents[i].spawned = false; v += is.add; if(v>is.max) v = is.max; - botplaysound(is.sound, m_pMyEnt); + playsound(is.sound, &m_pMyEnt->o); sents[i].spawned = false; sents[i].spawnsecs = spawnsec; - addmsg(SV_BOTITEMPICKUP, "rii", i, m_classicsp ? 100000 : spawnsec); - // HACK: Reset ent goal if bot was looking for for this ent if (m_pTargetEnt == &ents[i]) { diff --git a/source/src/bot/ac_bot.h b/source/src/bot/ac_bot.h index 8cce7149..cbf83421 100644 --- a/source/src/bot/ac_bot.h +++ b/source/src/bot/ac_bot.h @@ -36,7 +36,6 @@ public: virtual bool DoSPStuff(void); virtual void Spawn(void); - virtual void BotPain(int damage, playerent *d, bool gib=false); }; inline void AddScreenText(char *t, ...) {}; // UNDONE diff --git a/source/src/bot/bot.cpp b/source/src/bot/bot.cpp index 95203080..80c26623 100644 --- a/source/src/bot/bot.cpp +++ b/source/src/bot/bot.cpp @@ -283,60 +283,6 @@ void CBot::SendBotInfo() { if(lastmillis-m_iLastBotUpdate<40) return; // don't update faster than 25fps m_iLastBotUpdate = lastmillis; - - int x = (int)(m_pMyEnt->o.x*DMF); - int y = (int)(m_pMyEnt->o.y*DMF); - int z = (int)(m_pMyEnt->o.z*DMF); - int yaw = (int)(m_pMyEnt->yaw*DAF); - int pitch = (int)(m_pMyEnt->pitch*DAF); - int roll = (int)(m_pMyEnt->roll*DAF); - int velx = (int)(m_pMyEnt->vel.x*DVF); - int vely = (int)(m_pMyEnt->vel.y*DVF); - int velz = (int)(m_pMyEnt->vel.z*DVF); - // pack rest in 1 byte: strafe:2, move:2, onfloor:1, state:3 - int moveflags = (m_pMyEnt->strafe&3) | ((m_pMyEnt->move&3)<<2) | - (((int)m_pMyEnt->onfloor)<<4) | - ((editmode ? CS_EDITING : - m_pMyEnt->state)<<5); - - ENetPacket *packet = enet_packet_create(NULL, 100, 0); - ucharbuf p(packet->data, packet->dataLength); - - putint(p, SV_BOTUPDATE); - putint(p, BotManager.GetBotIndex(m_pMyEnt)); - putint(p, x); // quantize coordinates to 1/16th of a cube, between 1 and 3 bytes - putint(p, y); - putint(p, z); - putint(p, yaw); - putint(p, pitch); - putint(p, roll); - putint(p, velx); // quantize to 1/100, almost always 1 byte - putint(p, vely); - putint(p, velz); - // pack rest in 1 byte: strafe:2, move:2, onfloor:1, state:3 - putint(p, moveflags); - - enet_packet_resize(packet, p.length()); - incomingdemodata(0, p.buf, p.length(), true); - sendpackettoserv(0, packet); - - if(!m_bSendC2SInit) // tell other clients who I am - { - ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, 0); - ucharbuf p(packet->data, packet->dataLength); - - packet->flags = ENET_PACKET_FLAG_RELIABLE; - m_bSendC2SInit = true; - putint(p, SV_ADDBOT); - putint(p, BotManager.GetBotIndex(m_pMyEnt)); - sendstring(m_pMyEnt->name, p); - sendstring(m_pMyEnt->team, p); - putint(p, m_pMyEnt->lifesequence); - - enet_packet_resize(packet, p.length()); - incomingdemodata(1, p.buf, p.length(), true); - sendpackettoserv(1, packet); - } } float CBot::GetDistance(const vec &o) @@ -358,7 +304,7 @@ float CBot::GetDistance(entity *e) bool CBot::SelectGun(int Gun) { if(m_pMyEnt->reloading) return false; - if (m_pMyEnt->gunselect != Gun) botplaysound(S_GUNCHANGE, m_pMyEnt); + if (m_pMyEnt->gunselect != Gun) playsound(S_GUNCHANGE, &m_pMyEnt->o); m_pMyEnt->gunselect = Gun; return true; } diff --git a/source/src/bot/bot.h b/source/src/bot/bot.h index 1084b3c4..5b029464 100644 --- a/source/src/bot/bot.h +++ b/source/src/bot/bot.h @@ -240,7 +240,6 @@ public: virtual void CheckItemPickup(void) = 0; virtual void PickUp(int n) = 0; virtual void AddItem(int i, int &v, int spawnsec, int t) = 0; - virtual void BotPain(int damage, playerent *d, bool gib=false) = 0; void SendBotInfo(void); float GetDistance(const vec &o); float GetDistance(const vec &v1, const vec &v2); @@ -373,8 +372,6 @@ public: void Init(void); void Think(void); void RenderBots(void); - void RenderBotScore(void) { loopv(bots) if(bots[i]) renderscore(bots[i]); } - void AddBotTeamScore(void) { loopv(bots) addteamscore(bots[i]); }; void RespawnBots(void) { loopv(bots) if (bots[i] && bots[i]->pBot) bots[i]->pBot->Spawn(); }; void EndMap(void); void BeginMap(char *szMapName); diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp index ee1d189b..e11a437d 100644 --- a/source/src/bot/bot_ai.cpp +++ b/source/src/bot/bot_ai.cpp @@ -203,7 +203,8 @@ bool CBot::FindEnemy(void) BestEnemyVal = EnemyVal; } } - + +#if 0 // Then loop through all bots loopv(bots) { @@ -234,7 +235,7 @@ bool CBot::FindEnemy(void) BestEnemyVal = EnemyVal; } } - +#endif // Then examine the local player if (player1 && !isteam(player1->team, m_pMyEnt->team) && (player1->state == CS_ALIVE)) @@ -475,7 +476,8 @@ bool CBot::CheckHunt(void) BestOldPos = bestfrombot; } //} - + +#if 0 // Then loop through all bots loopv(bots) { @@ -555,7 +557,8 @@ bool CBot::CheckHunt(void) BestOldPos = bestfrombot; } } - +#endif + // Then examine the local player if (player1 && !isteam(player1->team, m_pMyEnt->team) && (player1->state == CS_ALIVE) && ((flDist = GetDistance(player1->o)) <= 250.0f)) @@ -2246,7 +2249,8 @@ void CBot::HearSound(int n, vec *o) flNearestDist = flDist; } } - + +#if 0 // Check all bots loopv(bots) { @@ -2261,7 +2265,8 @@ void CBot::HearSound(int n, vec *o) flNearestDist = flDist; } } - +#endif + // Check local player if (player1 && (player1->state == CS_ALIVE) && !isteam(m_pMyEnt->team, player1->team)) diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp index ea76c39b..49634666 100644 --- a/source/src/bot/bot_util.cpp +++ b/source/src/bot/bot_util.cpp @@ -233,7 +233,8 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult tr->collided = true; } } - + +#if 0 // Check if the 'line' collides with bots loopv(bots) { @@ -248,8 +249,8 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult tr->collided = true; } } +#endif - // Check if the 'line' collides with the local player(player1) dynent *d = player1; // Shortcut if (d && (d!=pTracer) && !BotManager.m_pBotToView && (d->state == CS_ALIVE)) @@ -509,7 +510,7 @@ bool IsInGame(dynent *d) { #ifdef VANILLA_CUBE if (!players[i] || (players[i]->state == CS_DEDHOST)) continue; -#elif defined AC_CUBE +#elif defined(AC_CUBE) if (!players[i]) continue; #endif if (players[i] == d) diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index ddb1a4e3..df80c0bb 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -352,7 +352,7 @@ void CBotManager::EndMap() } bots[i]->pBot = NULL; - DELETEP(bots[i]); + freebotent(bots[i]); } bots.setsize(0); condebug("Cleared all bots"); @@ -1002,35 +1002,6 @@ void addbot(char *arg1, char *arg2, char *arg3) return; } } - else if (clienthost) - { - char team[32], name[32]; - int skill = -1; - - team[0] = name[0] = 0; - - if (arg1 && arg1[0]) strcpy(team, arg1); - if (arg3 && arg3[0]) strcpy(name, arg3); - if (arg2 && arg2[0]) - { - if (!strcasecmp(arg2, "best")) skill = 0; - else if (!strcasecmp(arg2, "good")) skill = 1; - else if (!strcasecmp(arg2, "medium")) skill = 2; - else if (!strcasecmp(arg2, "worse")) skill = 3; - else if (!strcasecmp(arg2, "bad")) skill = 4; - } - - ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); - ucharbuf p(packet->data, packet->dataLength); - putint(p, SV_BOTCOMMAND); - putint(p, int(COMMAND_ADDBOT)); // Bot command type - putint(p, 1); // Bot count - putint(p, skill); // Bot skill - sendstring(team, p); // Bot team - sendstring(name, p); // Bot name - enet_packet_resize(packet, p.length()); - sendpackettoserv(1, packet); - } } COMMAND(addbot, ARG_3STR); @@ -1050,35 +1021,6 @@ void addnbot(char *arg1, char *arg2, char *arg3) i--; } } - else if (clienthost) - { - char team[32], name[32]; - int skill = -1; - - team[0] = name[0] = 0; - - if (arg2 && arg2[0]) strcpy(team, arg2); -// if (arg4 && arg4[0]) strcpy(name, arg4); - if (arg3 && arg3[0]) - { - if (!strcasecmp(arg2, "best")) skill = 0; - else if (!strcasecmp(arg2, "good")) skill = 1; - else if (!strcasecmp(arg2, "medium")) skill = 2; - else if (!strcasecmp(arg2, "worse")) skill = 3; - else if (!strcasecmp(arg2, "bad")) skill = 4; - } - - ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); - ucharbuf p(packet->data, packet->dataLength); - putint(p, SV_BOTCOMMAND); - putint(p, int(COMMAND_ADDBOT)); // Bot command type - putint(p, i); // Bot count - putint(p, skill); // Bot skill - sendstring(team, p); // Bot team - sendstring(name, p); // Bot name - enet_packet_resize(packet, p.length()); - sendpackettoserv(1, packet); - } } COMMAND(addnbot, ARG_3STR); @@ -1151,26 +1093,12 @@ void kickbot(const char *szName) { if (ishost()) { - addmsg(SV_BOTDIS, "ri", iBotInd); - - if(bots[iBotInd]->name[0]) conoutf("bot %s disconnected", bots[iBotInd]->name); - delete bots[iBotInd]->pBot; - DELETEP(bots[iBotInd]); + botent *d = bots[iBotInd]; + if(d->name[0]) conoutf("bot %s disconnected", d->name); + delete d->pBot; bots.remove(iBotInd); + freebotent(d); } - else if (clienthost) // Ask server to destroy bot(with voting) - { - ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); - ucharbuf p(packet->data, packet->dataLength); - putint(p, SV_BOTCOMMAND); - putint(p, int(COMMAND_KICKBOT)); // Bot command type - putint(p, 1); // 0==kick all bots, 1==kick one specific bot - char tmp[20]; - strcpy(tmp, szName); - sendstring(tmp, p); // Bot name - enet_packet_resize(packet, p.length()); - sendpackettoserv(1, packet); - } } } @@ -1184,24 +1112,10 @@ void kickallbots(void) { if (ishost()) { - addmsg(SV_BOTDIS, "ri", i); - - conoutf("bot %s disconnected",(bots[i]->name[0] ? - bots[i]->name : "[incompatible client]")); + if(bots[i]->name[0]) conoutf("bot %s disconnected", bots[i]->name); delete bots[i]->pBot; - DELETEP(bots[i]); + freebotent(bots[i]); } - else if (clienthost) // Ask the server to destroy all bots - { - ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, - ENET_PACKET_FLAG_RELIABLE); - ucharbuf p(packet->data, packet->dataLength); - putint(p, SV_BOTCOMMAND); - putint(p, int(COMMAND_KICKBOT)); // Bot command type - putint(p, 0); // 0==kick all bots, 1==kick one specific bot - enet_packet_resize(packet, p.length()); - sendpackettoserv(1, packet); - } } } @@ -1282,16 +1196,6 @@ void botskill(char *bot, char *skill) else BotManager.ChangeBotSkill(SkillNr); } - else if (clienthost) // ask server to change botskill - { - ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); - ucharbuf p(packet->data, packet->dataLength); - putint(p, SV_BOTCOMMAND); - putint(p, int(COMMAND_BOTSKILL)); // Bot command type - putint(p, SkillNr); - enet_packet_resize(packet, p.length()); - sendpackettoserv(1, packet); - } } COMMAND(botskill, ARG_2STR); diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp index 63a2dbe8..d47cf55e 100644 --- a/source/src/clientextras.cpp +++ b/source/src/clientextras.cpp @@ -125,16 +125,11 @@ void renderscores() if(!demoplayback) renderscore(player1); loopv(players) if(players[i]) renderscore(players[i]); - // Added by Rick: Render Score for bots - BotManager.RenderBotScore(); - sortmenu(menu, 0, scorelines.length()); if(m_teammode) { teamsused = 0; loopv(players) addteamscore(players[i]); - // Added by Rick: Add team scores for bots - BotManager.AddBotTeamScore(); if(!demoplayback) addteamscore(player1); teamscores[0] = 0; loopj(teamsused) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index f18664f0..9da86bb3 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -67,9 +67,24 @@ botent *newbotent() // create a new blank player d->lastupdate = lastmillis; d->skin = rnd(1 + rb_team_int(d->team) == TEAM_CLA ? 3 : 5); spawnstate(d); + loopv(players) if(i!=getclientnum() && !players[i]) + { + players[i] = d; + return d; + }; + if(players.length()==getclientnum()) players.add(NULL); + players.add(d); return d; }; +void freebotent(botent *d) +{ + loopv(players) if(players[i]==d) + { + DELETEP(players[i]); + }; +}; + void ctf_death() // EDIT: AH { int flag = rb_opposite(rb_team_int(player1->team)); @@ -143,8 +158,6 @@ void arenarespawn() char *lastname = NULL; bool oneteam = true; loopv(players) if(players[i]) arenacount(players[i], alive, dead, lastteam, lastname, oneteam); - // Added by Rick: Count bot stuff - loopv(bots) if(bots[i]) arenacount(bots[i], alive, dead, lastteam, lastname, oneteam); arenacount(player1, alive, dead, lastteam, lastname, oneteam); if(dead>0 && (alive<=1 || (m_teammode && oneteam))) { @@ -186,26 +199,17 @@ extern int democlientnum; void otherplayers() { - loopv(players) if(players[i]) + loopv(players) if(players[i] && players[i]->type==ENT_PLAYER && players[i]->state==CS_ALIVE) { const int lagtime = lastmillis-players[i]->lastupdate; - if(lagtime>1000 && players[i]->state==CS_ALIVE) + if(lagtime>1000) { players[i]->state = CS_LAGGED; continue; - }; - if(lagtime && players[i]->state != CS_DEAD && (!demoplayback || i!=democlientnum)) moveplayer(players[i], 2, false); // use physics to extrapolate player position + } + else if(!lagtime) continue; + if(!demoplayback || i!=democlientnum) moveplayer(players[i], 2, false); // use physics to extrapolate player position }; - // Added by Rick - if (!ishost()) - { - loopv(bots) - { - if(bots[i] && bots[i]->state != CS_DEAD && (!demoplayback)) - moveplayer(bots[i], 2, false); // use physics to extrapolate bot position - } - } - // End add }; struct scriptsleep { int wait; char *cmd; }; @@ -398,21 +402,42 @@ void mousemove(int dx, int dy) // damage arriving from the network, monsters, yourself, all ends up here. -void selfdamage(int damage, int actor, playerent *act, bool gib) +void selfdamage(int damage, int actor, playerent *act, bool gib, playerent *pl) { if(!act) return; - if(player1->state!=CS_ALIVE || editmode || intermission) return; - damageblend(damage); - demoblend(damage); + if(pl->state!=CS_ALIVE || editmode || intermission) return; + if(pl==player1) + { + damageblend(damage); + demoblend(damage); + }; int ad = damage*30/100; // let armour absorb when possible - if(ad>player1->armour) ad = player1->armour; - player1->armour -= ad; + if(ad>pl->armour) ad = player1->armour; + pl->armour -= ad; damage -= ad; float droll = damage/0.5f; - player1->roll += player1->roll>0 ? droll : (player1->roll<0 ? -droll : (rnd(2) ? droll : -droll)); // give player a kick depending on amount of damage - if((player1->health -= damage)<=0) + pl->roll += pl->roll>0 ? droll : (pl->roll<0 ? -droll : (rnd(2) ? droll : -droll)); // give player a kick depending on amount of damage + if((pl->health -= damage)<=0) { - if(actor==-2) + if(pl->type==ENT_BOT) + { + if(pl==act) + { + --pl->frags; + conoutf("%s suicided", pl->name); + } + else if(isteam(pl->team, act->team)) + { + --act->frags; + conoutf("%s fragged %s teammate (%s)", act==player1 ? "you" : act->name, act==player1 ? "a" : "his", pl->name); + } + else + { + ++act->frags; + conoutf("%s fragged %s", act==player1 ? "you" : act->name, pl->name); + }; + } + else if(actor==-2) { conoutf("you got killed by %s!", &act->name); } @@ -420,51 +445,41 @@ void selfdamage(int damage, int actor, playerent *act, bool gib) { actor = getclientnum(); conoutf("you suicided!"); - addmsg(SV_FRAGS, "ri", --player1->frags); + addmsg(SV_FRAGS, "ri", --pl->frags); } - else + else if(act) { - // Modified by Rick - //dynent *a = getclient(actor); - playerent *a; - if(act->type==ENT_BOT) a = act; - else a = getclient(actor); - // End mod - - if(a) + if(isteam(act->team, player1->team)) { - if(isteam(a->team, player1->team)) - { - conoutf("you got fragged by a teammate (%s)", a->name); - } - else - { - conoutf("you got fragged by %s", a->name); - }; + conoutf("you got fragged by a teammate (%s)", act->name); + } + else + { + conoutf("you got fragged by %s", act->name); }; }; - // EDIT: AH - if(m_ctf) ctf_death(); - showscores(true); - setscope(false); - if(act->type==ENT_BOT) addmsg(SV_DIEDBYBOT, "ri", actor); - else addmsg(gib ? SV_GIBDIED : SV_DIED, "ri", actor); - player1->lifesequence++; - player1->attacking = false; - player1->state = CS_DEAD; - player1->oldpitch = player1->pitch; - player1->pitch = 0; - player1->roll = 60; - playsound(S_DIE1+rnd(2)); - if(gib) addgib(player1); - spawnstate(player1); - //player1->lastaction = lastmillis; - //fixme - if (act->type==ENT_BOT) addmsg(SV_BOTFRAGS, "rii", BotManager.GetBotIndex((botent *)act), ++act->frags); + if(pl==player1) + { + if(m_ctf) ctf_death(); + showscores(true); + setscope(false); + addmsg(gib ? SV_GIBDIED : SV_DIED, "ri", actor); + }; + pl->lifesequence++; + pl->attacking = false; + pl->state = CS_DEAD; + pl->oldpitch = pl->pitch; + pl->pitch = 0; + pl->roll = 60; + playsound(S_DIE1+rnd(2), pl!=player1 ? &pl->o : NULL); + if(gib) addgib(pl); + spawnstate(pl); + pl->lastaction = lastmillis; + if (pl!=player1 || act->type==ENT_BOT) act->frags++; } else { - playsound(S_PAIN6); + playsound(S_PAIN6, pl!=player1 ? &pl->o : NULL); }; }; @@ -496,30 +511,6 @@ playerent *getclient(int cn) // ensure valid entity return players[cn] ? players[cn] : (players[cn] = newplayerent()); }; -// Added by Rick -botent *getbot(int cn) // ensure valid entity -{ - if(cn<0 || cn>=MAXCLIENTS) - { - neterr("botnum"); - return NULL; - }; - - while(cn>=bots.length()) bots.add(NULL); - if (!bots[cn]) - { - bots[cn] = newbotent(); - if (bots[cn]) - { - bots[cn]->pBot = NULL; - bots[cn]->type = ENT_BOT; - } - } - - return bots[cn]; -}; -// End add by Rick - void initclient() { clientmap[0] = 0; diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index e4cf7192..8f824157 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -23,30 +23,6 @@ void changemap(char *name) // request map change, server ma addmsg(SV_MAPCHANGE, "rsi", name, nextmode); }; -// Added by Rick -void botcommand(ucharbuf &p, char *text) -{ - int type = getint(p); - switch(EBotCommands(type)) - { - case COMMAND_ADDBOT: - getint(p); - getint(p); - getstring(text, p); - getstring(text, p); - break; - case COMMAND_KICKBOT: - if (getint(p)==1) // Kick a specific bot - getstring(text, p); - break; - case COMMAND_BOTSKILL: - getint(p); - break; - } -} -// End add - - // update the position of other clients in the game in our world // don't care if he's in the scenery or other players, // just don't overlap with our client @@ -109,35 +85,6 @@ void parsepositions(ucharbuf &p) break; }; - case SV_BOTUPDATE: - { - int n = getint(p); - botent *b = getbot(n); - if(!b) return; - b->o.x = getint(p)/DMF; - b->o.y = getint(p)/DMF; - b->o.z = getint(p)/DMF; - b->yaw = getint(p)/DAF; - b->pitch = getint(p)/DAF; - b->roll = getint(p)/DAF; - b->vel.x = getint(p)/DVF; - b->vel.y = getint(p)/DVF; - b->vel.z = getint(p)/DVF; - int f = getint(p); - b->strafe = (f&3)==3 ? -1 : f&3; - f >>= 2; - b->move = (f&3)==3 ? -1 : f&3; - b->onfloor = (f>>2)&1; - int state = f>>3; - if(state==CS_DEAD && b->state!=CS_DEAD) b->lastaction = lastmillis; - b->state = state; - - if (!b->type!=ENT_BOT) b->type = ENT_BOT; - - if(!demoplayback) updatepos(b); - break; - }; - default: neterr("type"); return; @@ -149,7 +96,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) static char text[MAXTRANS]; int type; bool mapchanged = false; - bool c2si = false, killedbybot=false; + bool c2si = false; bool gib=false; while(p.remaining()) switch(type = getint(p)) @@ -277,38 +224,17 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } - case SV_BOT2CLIENTDMG: - { - - int target = getint(p); - int damage = getint(p); - int ls = getint(p); - int damager = getint(p); - - if(target==clientnum) - { - botent *a = getbot(damager); - if(ls==player1->lifesequence) - selfdamage(damage, cn, a); - } - else playsound(S_PAIN1+rnd(5), &getclient(target)->o); - break; - } - - - case SV_DIEDBYBOT: - killedbybot = true; case SV_GIBDIED: - if(type!=SV_DIEDBYBOT) gib = true; // uargl.. fixme + gib = true; case SV_DIED: { int actor = getint(p); - if(actor==cn && !killedbybot) + if(actor==cn) { conoutf("%s suicided", d->name); } - else if(actor==clientnum && !killedbybot) + else if(actor==clientnum) { int frags; if(isteam(player1->team, d->team)) @@ -326,7 +252,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) } else { - playerent *a = killedbybot ? getbot(actor) : getclient(actor); + playerent *a = getclient(actor); if(a) { if(isteam(a->team, d->name)) @@ -342,7 +268,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) }; playsound(S_DIE1+rnd(2), &d->o); if(!c2si) d->lifesequence++; - killedbybot = gib = false; + gib = false; break; }; @@ -366,7 +292,6 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) }; case SV_ITEMPICKUP: - case SV_BOTITEMPICKUP: setspawn(getint(p), false); getint(p); break; @@ -526,157 +451,6 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; }; - // Added by Rick: Bot specific messages - case SV_BOTSOUND: - { - int Sound = getint(p); - botent *pBot = getbot(getint(p)); - - if (pBot) - playsound(Sound, &pBot->o); - - break; - } - - case SV_ADDBOT: // Bot joined the game - { - botent *b = getbot(getint(p)); - if (!b) break; - - getstring(text, p); - if(b->name[0]) // already connected - { - if(strcmp(b->name, text)) - conoutf("%s is now known as %s", b->name, &text); - } - else // new client - { - //c2sinit = false; // send new players my info again - conoutf("connected: %s", &text); - }; - s_strcpy(b->name, text); - getstring(text, p); - s_strcpy(b->team, text); - b->lifesequence = getint(p); - b->type = ENT_BOT; - b->pBot = NULL; - break; - }; - - case SV_BOTDIS: - { - int n = getint(p); - botent *b = getbot(n); - - if (!b) - break; - - if(b->name[0]) conoutf("bot %s disconnected", b->name); - delete b->pBot; - DELETEP(bots[n]); - bots.remove(n); - break; - } - - case SV_CLIENT2BOTDMG: - case SV_BOT2BOTDMG: - { - int target = getint(p); - int damage = getint(p); - int damager = getint(p); - botent *b = getbot(target); - - playerent *a; - if (damager == -1) - { - // HACK! if the local client who sended the message is the damager, its -1 - a = d; - } - else if (type == SV_CLIENT2BOTDMG) - { - if (damager == clientnum) a = player1; - else a = getclient(damager); - } - else - a = getbot(damager); - - if (b && a) - { - // Do we know the bot info? if so we are the host... - if (b->pBot) b->pBot->BotPain(damage, a); - playsound(S_PAIN1+rnd(5), &b->o); - } - break; - } - - case SV_BOTDIED: - { - int b = getint(p); - int killer = getint(p); - bool KilledByABot = getint(p) > 0; //fixmebot - botent *bot = getbot(b); - - if((b==killer) && KilledByABot) - { - conoutf("%s suicided", bot->name); - } - else if((killer==clientnum) && !KilledByABot) - { - int frags; - if(isteam(player1->team, bot->team)) - { - frags = -1; - conoutf("you fragged a teammate (%s)", bot->name); - } - else - { - frags = 1; - conoutf("you fragged %s", bot->name); - }; - addmsg(SV_FRAGS, "ri", player1->frags += frags); - if(player1->gunselect==GUN_KNIFE) - addgib(bot); - } - else - { - playerent *k; - if (KilledByABot) - k = getbot(killer); - else if (killer == -1) - // if killer = -1, 'a player1' sended the message(hack) - k = d; - else - k = getclient(killer); - - if(bot && k) - { - if(isteam(bot->team, k->name)) - { - conoutf("%s fragged his teammate (%s)", bot->name, k->name); - } - else - { - conoutf("%s fragged %s", bot->name, k->name); - } - if(k->gunselect==GUN_KNIFE) addgib(bot); - } - } - playsound(S_DIE1+rnd(2), &bot->o); - bot->lifesequence++; - break; - }; - - case SV_BOTFRAGS: - { - botent *b = getbot(getint(p)); - if (b) b->frags = getint(p); - break; - }; - - case SV_BOTCOMMAND: - botcommand(p, text); - break; - case SV_NOP: { getint(p); break; diff --git a/source/src/physics.cpp b/source/src/physics.cpp index a0ebb13c..9894186d 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -5,21 +5,6 @@ #include "cube.h" -/* Modified by Rick: Fix, so we can jump on players aswell -bool plcollide(dynent *d, dynent *o, float &headspace) // collide with player or monster -{ - if(o->state!=CS_ALIVE) return true; - const float r = o->radius+d->radius; - if(fabs(o->o.x-d->o.x)o.y-d->o.y)o.z-d->o.z)aboveeye+d->eyeheight) return false; - headspace = d->o.z-o->o.z-o->aboveeye-d->eyeheight; - if(headspace<0) headspace = 10; - }; - return true; -}; -*/ - bool plcollide(physent *d, physent *o, float &headspace, float &hi, float &lo) // collide with player or monster { if(o->state!=CS_ALIVE) return true; @@ -133,12 +118,6 @@ bool collide(physent *d, bool spawn, float drop, float rise) if(!o || o==d) continue; if(!plcollide(d, o, headspace, hi, lo)) return false; }; - loopv(bots) // Added by Rick: collide with other bots - { - botent *o = bots[i]; - if(!o || o==d) continue; - if(!plcollide(d, o, headspace, hi, lo)) return false; - }; if(d!=player1/*&& d->mtype!=M_NADE*/) if(!plcollide(d, player1, headspace, hi, lo)) return false; headspace -= 0.01f; @@ -182,16 +161,6 @@ bool collide(physent *d, bool spawn, float drop, float rise) VAR(maxroll, 0, 3, 20); -void selfdamage(playerent *d, int dm) -{ - if(d==player1) selfdamage(dm, -1, d); - else { addmsg(SV_DAMAGE, "ri3", d, dm, d->lifesequence); }; - //playsound(S_FALL1+rnd(5), &d->o); }; // fixme sound - particle_splash(3, dm, 1000, d->o); //edit out? - demodamage(dm, d->o); -}; - - // main physics routine, moves a player/monster for a curtime step // moveres indicated the physics precision (which is lower for monsters and multiplayer prediction) // local is false for multiplayer prediction @@ -266,7 +235,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) pl->vel.z = 2.0f; //1.7f; // physics impulse upwards if(water) { pl->vel.x /= 8; pl->vel.y /= 8; }; // dampen velocity change even harder, gives correct water feel if(local) playsoundc(S_JUMP); - else if(pl->type==ENT_BOT) botplaysound(S_JUMP, (botent *)pl); // Added by Rick + else if(pl->type==ENT_BOT) playsound(S_JUMP, &pl->o); // Added by Rick } pl->timeinair = 0; if(pl->type==ENT_BOUNCE) pl->vel.z *= 0.7f; diff --git a/source/src/protos.h b/source/src/protos.h index ab6b40d3..cd25c1ec 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -93,10 +93,11 @@ extern void updateworld(int curtime, int lastmillis); extern void startmap(char *name); extern void changemap(char *name); extern void initclient(); -extern void spawnplayer(playerent *d, bool secure=false); -extern void selfdamage(int damage, int actor, playerent *act, bool gib=false); +extern void spawnplayer(playerent *d, bool secure = false); +extern void selfdamage(int damage, int actor, playerent *act, bool gib = false, playerent *pl = player1); extern playerent *newplayerent(); extern botent *newbotent(); +extern void freebotent(botent *d); extern char *getclientmap(); extern const char *modestr(int n); extern void zapplayer(playerent *&d); diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 06ecac20..30ecf114 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -399,8 +399,6 @@ void gl_drawframe(int w, int h, float changelod, float curfps) readdepth(w, h); renderclients(); - //monsterrender(); - BotManager.RenderBots(); // Added by Rick renderspheres(curtime); renderents(); diff --git a/source/src/savegamedemo.cpp b/source/src/savegamedemo.cpp index cbc71a37..1fe2cb36 100644 --- a/source/src/savegamedemo.cpp +++ b/source/src/savegamedemo.cpp @@ -35,15 +35,6 @@ void stop() demoloading = false; loopv(playerhistory) zapplayer(playerhistory[i]); playerhistory.setsize(0); - // Added by Rick: Remove bots - loopv(bots) - { - if (!bots[i]) continue; - delete bots[i]->pBot; - bots[i]->pBot = NULL; - DELETEP(bots[i]); - } - bots.setsize(0); }; void stopifrecording() { if(demorecording) stop(); }; diff --git a/source/src/server.cpp b/source/src/server.cpp index 0e3bca2e..65f3a3f5 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -40,15 +40,6 @@ struct client // server side version of "dynent" type int modevote; uint pos[3]; clientscore score; - // Added by Rick: For bot voting -#ifndef STANDALONE - bool addbot, kickbot, changebotskill; - short botcount; - string botteam, botname; - short botskill; - bool kickallbots; -#endif - // End add bool ismaster; bool isauthed; // for passworded servers vector position, messages; @@ -233,13 +224,6 @@ vector sents; bool notgotitems = true; // true when map has changed and waiting for clients to send item int mode = 0; -// Added by Rick -#ifndef STANDALONE -extern void kickbot(const char *szName); -extern void kickallbots(void); -#endif -// End add - void restoreserverstate(vector &ents) // hack: called from savegame code, only works in SP { @@ -309,7 +293,7 @@ void sendflaginfo(int flag, int action, int cn = -1) enet_packet_resize(packet, p.length()); if(cn<0) multicast(packet, -1, 1); else sendpacket(cn, 1, packet); - printf("flaginfo sent %i %i\n", cn, p.length()); //fixme + if(packet->referenceCount==0) enet_packet_destroy(packet); }; void ctfreset() @@ -422,7 +406,7 @@ void resetvotes() loopv(clients) clients[i]->mapvote[0] = 0; }; -void changemap(const char *newname, int newmode, int newtime, bool notify = true) +void resetmap(const char *newname, int newmode, int newtime, bool notify = true) { mode = newmode; minremain = newtime; @@ -433,10 +417,6 @@ void changemap(const char *newname, int newmode, int newtime, bool notify = true interm = 0; laststatus = lastsec-61; resetvotes(); -#ifndef STANDALONE - extern void resetbotvotes(); - resetbotvotes(); // Added by Rick -#endif resetitems(); resetscores(); ctfreset(); @@ -449,7 +429,7 @@ void nextcfgset(bool notify = true) // load next maprotation set if(curcfgset>=configsets.length() || curcfgset<0) curcfgset=0; configset &c = configsets[curcfgset]; - changemap(c.mapname, c.mode, c.time, notify); + resetmap(c.mapname, c.mode, c.time, notify); }; bool vote(char *map, int reqmode, int sender) @@ -480,210 +460,6 @@ bool vote(char *map, int reqmode, int sender) return true; }; -//fixmebot -// Added by Rick: Vote for bot commands - -#ifndef STANDALONE -void resetbotvotes() -{ - loopv(clients) - { - clients[i]->addbot = false; - clients[i]->kickbot = false; - clients[i]->changebotskill = false; - clients[i]->kickallbots = false; - clients[i]->botcount = 0; - clients[i]->botteam[0] = 0; - clients[i]->botname[0] = 0; - clients[i]->botskill = -1; - }; -}; - -bool addbotvote(int count, char *team, int skill, char *name, int sender) -{ - clients[sender]->addbot = true; - clients[sender]->kickbot = false; - clients[sender]->changebotskill = false; - clients[sender]->botcount = (count>=0) ? count : 0; - if (team && team[0]) s_strcpy(clients[sender]->botteam, team); - else clients[sender]->botteam[0] = 0; - clients[sender]->botskill = skill; - if (name && name[0]) s_strcpy(clients[sender]->botname, name); - else clients[sender]->botname[0] = 0; - int yes = 0, no = 0; - loopv(clients) if(clients[i]->type!=ST_EMPTY) - { - if (clients[i]->addbot) - { - if (!strcmp(clients[i]->botteam, team) && !strcmp(clients[i]->botname, name) && - (clients[i]->botskill == skill) && - (clients[i]->botcount == clients[sender]->botcount)) - yes++; - else - no++; - } - else no++; - }; - if(yes==1 && no==0) return true; // single player - s_sprintfd(msg)("%s suggests to add a bot", clients[sender]->name); - if(team && team[0]) - { - strcat(msg, " on team "); - strcat(msg, team); - }; - - if(skill!=-1) - { - strcat(msg, ", with skill "); - strcat(msg, SkillNrToSkillName(skill)); - }; - - if(name && name[0]) - { - strcat(msg, " named "); - strcat(msg, name); - } - - sendservmsg(msg); - if(yes/(float)(yes+no) <= 0.5f) return false; - sendservmsg("vote passed"); - resetbotvotes(); - - return true; -}; - - -bool kickbotvote(int specific, char *name, int sender) -{ - clients[sender]->addbot = false; - clients[sender]->kickbot = true; - clients[sender]->changebotskill = false; - clients[sender]->kickallbots = !specific; - if(name && name[0]) s_strcpy(clients[sender]->botname, name); - else clients[sender]->botname[0] = 0; - int yes = 0, no = 0; - loopv(clients) if(clients[i]->type!=ST_EMPTY) - { - if(clients[i]->kickbot) - { - if(clients[sender]->kickallbots) - { - if(clients[i]->kickallbots) yes++; - else no++; - } - else - { - if(!clients[i]->kickallbots && !strcmp(clients[i]->botname, name)) - yes++; - else - no++; - } - } - else no++; - } - if(yes==1 && no==0) return true; // single player - - char msg[256]; - if(clients[sender]->kickallbots) - sprintf(msg, "%s suggests to kick all bots", clients[sender]->name); - else - sprintf(msg, "%s suggests to kick bot %s", clients[sender]->name, - clients[sender]->botname); - - sendservmsg(msg); - if(yes/(float)(yes+no) <= 0.5f) return false; - sendservmsg("vote passed"); - resetbotvotes(); - return true; -}; - -bool botskillvote(int skill, int sender) -{ - clients[sender]->addbot = false; - clients[sender]->kickbot = false; - clients[sender]->changebotskill = true; - clients[sender]->botskill = skill; - int yes = 0, no = 0; - loopv(clients) if(clients[i]->type!=ST_EMPTY) - { - if(clients[i]->changebotskill) - { - if(clients[sender]->botskill == clients[i]->botskill) yes++; - else no++; - } - else no++; - } - if(yes==1 && no==0) return true; // single player - - s_sprintfd(msg)("%s suggests to change the skill of all bots to: %s", clients[sender]->name, - SkillNrToSkillName(clients[sender]->botskill)); - sendservmsg(msg); - if(yes/(float)(yes+no) <= 0.5f) return false; - sendservmsg("vote passed"); - resetbotvotes(); - return true; -}; - -void botcommand(ucharbuf &p, char *text, int sender) -{ - if(!valid_client(sender)) return; - int type = getint(p); - switch(EBotCommands(type)) - { - case COMMAND_ADDBOT: - { - string name, team; - int count = getint(p); - int skill = getint(p); - getstring(text, p); - strcpy(team, text); - getstring(text, p); - strcpy(name, text); - if (addbotvote(count, team, skill, name, sender)) - { - while(count>0) - { - BotManager.CreateBot(team, SkillNrToSkillName(skill), name); - count--; - } - } - break; - } - case COMMAND_KICKBOT: - { - int specific = getint(p); - - if (specific) - getstring(text, p); - - if (kickbotvote(specific, text, sender)) - { - if (specific) - kickbot(text); - else - kickallbots(); - } - } - case COMMAND_BOTSKILL: - { - int skill = getint(p); - if (botskillvote(skill, sender)) - { - BotManager.ChangeBotSkill(skill, NULL); - } - } - } -} -#endif -// End add - - -// force map change, EDIT: AH -void changemap() -{ - sendf(-1, 1, "risi", SV_MAPCHANGE, smapname, mode); -}; - struct ban { ENetAddress address; @@ -848,7 +624,7 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 int reqmode = getint(p); if(reqmode<0) reqmode = 0; if(smapname[0] && !mapreload && !vote(text, reqmode, sender)) return; - changemap(text, reqmode, m_ctf_s ? 10 : (m_teammode_s ? 15 : 10)); + resetmap(text, reqmode, m_ctf_s ? 10 : (m_teammode_s ? 15 : 10)); break; }; @@ -875,13 +651,6 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 break; }; - case SV_BOTITEMPICKUP: - { - loopi(2) getint(p); - QUEUE_MSG; - break; - }; - case SV_PING: CN_CHECK; sendf(cn, 1, "ii", SV_PONG, getint(p)); @@ -919,24 +688,6 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 sendpacket(sender, 3, recvmap(sender)); break; - // Added by Rick: Bot specifc messages -#ifndef STANDALONE - case SV_ADDBOT: - getint(p); - getstring(text, p); - //s_strcpy(clients[cn]->name, text); - getstring(text, p); - getint(p); - QUEUE_MSG; - break; - case SV_BOTCOMMAND: // Client asked server for a bot command - botcommand(p, text, sender); - QUEUE_MSG; - break; -#endif - // End add by Rick - - // EDIT: AH case SV_FLAGPICKUP: { @@ -1130,7 +881,7 @@ void resetserverifempty() { loopv(clients) if(clients[i]->type!=ST_EMPTY) return; //clients.setsize(0); - changemap("", 0, 10, false); + resetmap("", 0, 10, false); }; int nonlocalclients = 0; diff --git a/source/src/sound.cpp b/source/src/sound.cpp index 9ad27ffa..17c25723 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -206,13 +206,6 @@ void updatevol() void playsoundc(int n) { addmsg(SV_SOUND, "i", n); playsound(n); }; -// Added by Rick: For bots -void botplaysound(int n, botent *b) -{ - addmsg(SV_BOTSOUND, "rii", n, BotManager.GetBotIndex(b)); playsound(n, &b->o); -} -// End add by Rick - int soundsatonce = 0, lastsoundmillis = 0; void playsound(int n, vec *loc) diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 08110fa5..29b172db 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -205,10 +205,11 @@ playerent *intersectclosest(vec &from, vec &to, int &n, playerent *at) { playerent *best = NULL; float bestdist = 1e16f; - if(at!=player1) + if(at!=player1 && player1->state==CS_ALIVE && intersect(player1, from, to)) { best = player1; bestdist = at->o.dist(player1->o); + n = getclientnum(); }; loopv(players) { @@ -223,18 +224,6 @@ playerent *intersectclosest(vec &from, vec &to, int &n, playerent *at) n = i; }; }; - loopv(bots) - { - botent *o = bots[i]; - if(!o || o==at || o->state!=CS_ALIVE) continue; - if(!intersect(o, from, to)) continue; - float dist = at->o.dist(o->o); - if(distlastpain = lastmillis; - if(d==player1) selfdamage(damage, at==player1 ? -1 : -2, at, gib); - // Added by Rick: Let bots take damage - else if(d->type==ENT_BOT) - { - if(((botent *)d)->pBot) ((botent *)d)->pBot->BotPain(damage, at, gib); - else - { - int PlayerIndex = -1; - if (at->type==ENT_BOT) PlayerIndex = BotManager.GetBotIndex((botent *)at); - else - { - loopv(players) - { - if (!players[i]) continue; - - if (players[i] == at) - { - PlayerIndex = i; - break; - } - } - } - - int msgtype = (at->type==ENT_BOT) ? SV_BOT2BOTDMG : SV_CLIENT2BOTDMG; - addmsg(msgtype, "ri3", BotManager.GetBotIndex((botent *)d), damage, PlayerIndex); - playsound(S_PAIN1+rnd(5), &d->o); - }; - } - // End add by Rick - //else { addmsg(SV_DAMAGE, "ri3", target, damage, d->lifesequence); playsound(S_PAIN1+rnd(5), &d->o); }; Modified by Rick: Added IsBot and PlayerIndex to message + if(d==player1 || d->type==ENT_BOT) selfdamage(damage, at==d ? -1 : -2, at, gib, d); else { - // Modified by Rick: Added IsBot and PlayerIndex to message - int PlayerIndex = -1; - if (at->type==ENT_BOT) - PlayerIndex = BotManager.GetBotIndex((botent *)at); - else - { - loopv(players) - { - if (!players[i]) - continue; - - if (players[i] == at) - { - PlayerIndex = i; - break; - } - } - } - if(at->type==ENT_BOT) addmsg(SV_BOT2CLIENTDMG, "ri4", target, damage, d->lifesequence, PlayerIndex); - else addmsg(gib ? SV_GIBDAMAGE : SV_DAMAGE, "ri3", target, damage, d->lifesequence); + addmsg(gib ? SV_GIBDAMAGE : SV_DAMAGE, "ri3", target, damage, d->lifesequence); playsound(S_PAIN1+rnd(5), &d->o); }; @@ -348,8 +289,7 @@ void radialeffect(playerent *o, vec &v, int cn, int qdam, playerent *at) }; }; -// Modified by Rick: Added notthisbot -void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthisbot, int qdam) +void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int qdam) { particle_splash(0, 50, 300, v); p->inuse = false; @@ -372,26 +312,15 @@ void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthisbot, if(!o) continue; radialeffect(o, v, i, qdam, p->owner); }; - // Added by Rick - loopv(bots) - { - if(i==notthisbot) continue; - botent *o = bots[i]; - if(!o) continue; - radialeffect(o, v, i, qdam, p->owner); - } }; }; -// Modified by Rick -// inline void projdamage(dynent *o, projectile *p, vec &v, int i, int im, int qdam) -inline void projdamage(playerent *o, projectile *p, vec &v, int i, int ib, int qdam) +inline void projdamage(playerent *o, projectile *p, vec &v, int i, int qdam) { if(o->state!=CS_ALIVE) return; if(intersect(o, p->o, v)) { - // splash(p, v, p->o, i, im, qdam); Modified by Rick - splash(p, v, p->o, i, ib, qdam); + splash(p, v, p->o, i, qdam); hit(i, qdam, o, p->owner, true); //fixme }; }; @@ -415,21 +344,13 @@ void moveprojectiles(float time) { playerent *o = players[i]; if(!o) continue; - projdamage(o, p, v, i, -1, qdam); + projdamage(o, p, v, i, qdam); }; - // Added by Rick: Damage bots aswell - loopv(bots) - { - botent *o = bots[i]; - if(!o || (o == p->owner)) continue; - projdamage(o, p, v, -1, i, qdam); - }; - // End add by Rick - if(p->owner!=player1) projdamage(player1, p, v, -1, -1, qdam); + if(p->owner!=player1) projdamage(player1, p, v, -1, qdam); }; if(p->inuse) { - if(time==dtime) splash(p, v, p->o, -1, -1, qdam); + if(time==dtime) splash(p, v, p->o, -1, qdam); else { if(p->gun==GUN_GRENADE) { dodynlight(p->o, v, 0, 255, p->owner); particle_splash(5, 2, 200, v); } @@ -437,7 +358,7 @@ void moveprojectiles(float time) // Added by Rick traceresult_s tr; TraceLine(p->o, v, p->owner, true, &tr); - if (tr.collided) splash(p, v, p->o, -1, -1, qdam); + if (tr.collided) splash(p, v, p->o, -1, qdam); // End add }; }; @@ -641,7 +562,7 @@ bool hasammo(playerent *d) // bot mod { if(!d->mag[d->gunselect]) { - if (d->type==ENT_BOT) botplaysound(S_NOAMMO, (botent *)d); + if (d->type==ENT_BOT) playsound(S_NOAMMO, &d->o); else playsoundc(S_NOAMMO); d->gunwait = 250; d->lastattackgun = -1; @@ -733,7 +654,7 @@ void shoot(playerent *d, vec &targ) else d->gunwait = guns[d->gunselect].attackdelay; shootv(d->gunselect, from, to, d, 0); - addmsg(SV_SHOT, "ri8", d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), 0 ); + if(d->type==ENT_PLAYER) addmsg(SV_SHOT, "ri8", d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), 0 ); if(guns[d->gunselect].projspeed || d->gunselect==GUN_GRENADE) return; raydamage(from, to, d);