*** empty log message ***
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@586 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -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])
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-55
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user