git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@300 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2006-06-01 22:01:32 +00:00
parent c40015be6c
commit e9159704ba
27 changed files with 2957 additions and 2086 deletions
+246 -12
View File
@@ -24,6 +24,29 @@ void changemap(char *name) // request map change, server ma
strcpy_s(toservermap, name);
};
// Added by Rick
void botcommand(uchar *&p, char *text)
{
int type = getint(p);
switch(EBotCommands(type))
{
case COMMAND_ADDBOT:
getint(p);
getint(p);
sgetstr();
sgetstr();
break;
case COMMAND_KICKBOT:
if (getint(p)==1) // Kick a specific bot
sgetstr();
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
@@ -60,6 +83,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th
int cn = -1, type;
dynent *d = NULL;
bool mapchanged = false;
bool c2si = false, killedbybot=false;
while(p<end) switch(type = getint(p))
{
@@ -95,6 +119,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th
cn = getint(p);
d = getclient(cn);
if(!d) return;
c2si = false;
d->o.x = getint(p)/DMF;
d->o.y = getint(p)/DMF;
d->o.z = getint(p)/DMF;
@@ -161,13 +186,19 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th
c2sinit = false; // send new players my info again
conoutf("connected: %s", (int)&text);
gun_changed = true;
// Added by Rick: If we are the host("the bot owner"), tell the bots
// to update their stats
if (ishost())
BotManager.LetBotsUpdateStats();
// End add by Rick
};
strcpy_s(d->name, text);
sgetstr();
strcpy_s(d->team, text);
strcpy_s(d->team, text);
d->skin = getint(p);
d->lifesequence = getint(p);
printf("SV_INIT2C\tskin:%i\tlifes:%i\n", d->skin, d->lifesequence);
d->lifesequence = getint(p);
c2si = true;
printf("SV_INITC2S\n");
break;
};
@@ -203,16 +234,36 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th
if(target==clientnum) { if(ls==player1->lifesequence) selfdamage(damage, cn, d); else printf("wrong lifesequence\n"); }
else playsound(S_PAIN1+rnd(5), &getclient(target)->o);
break;
};
};
case SV_BOT2CLIENTDMG:
{
int target = getint(p);
int damage = getint(p);
int ls = getint(p);
int damager = getint(p);
if(target==clientnum)
{
dynent *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_DIED:
{
int actor = getint(p);
if(actor==cn)
if(actor==cn && !killedbybot)
{
conoutf("%s suicided", (int)d->name);
}
else if(actor==clientnum)
else if(actor==clientnum && !killedbybot)
{
int frags;
if(isteam(player1->team, d->team))
@@ -229,7 +280,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th
}
else
{
dynent *a = getclient(actor);
dynent *a = killedbybot ? getbot(actor) : getclient(actor);
if(a)
{
if(isteam(a->team, d->name))
@@ -243,15 +294,19 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th
};
};
playsound(S_DIE1+rnd(2), &d->o);
d->lifesequence++; printf("SV_DIED\n");
if(!c2si) d->lifesequence++;
killedbybot = false;
break;
};
};
case SV_FRAGS:
players[cn]->frags = getint(p);
break;
case SV_ITEMPICKUP:
case SV_ITEMPICKUP:
case SV_BOTITEMPICKUP:
setspawn(getint(p), false);
getint(p);
break;
@@ -430,7 +485,186 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th
for(int n = getint(p); n; n--) getint(p);
break;
};
*/
*/
// Added by Rick: Bot specific messages
case SV_BOTSOUND:
{
int Sound = getint(p);
dynent *pBot = getbot(getint(p));
if (pBot)
playsound(Sound, &pBot->o);
break;
}
case SV_ADDBOT: // Bot joined the game
{
dynent *b = getbot(getint(p));
if (!b) break;
sgetstr();
if(b->name[0]) // already connected
{
if(strcmp(b->name, text))
conoutf("%s is now known as %s", (int)b->name, (int)&text);
}
else // new client
{
//c2sinit = false; // send new players my info again
conoutf("connected: %s", (int)&text);
};
strcpy_s(b->name, text);
sgetstr();
strcpy_s(b->team, text);
b->lifesequence = getint(p);
b->bIsBot = true;
b->pBot = NULL;
break;
};
case SV_BOTDIS:
{
int n = getint(p);
dynent *b = getbot(n);
if (!b)
break;
conoutf("bot %s disconnected", (int)(b->name[0] ? b->name : "[incompatible client]"));
delete b->pBot;
zapdynent(bots[n]);
bots.remove(n);
break;
}
case SV_CLIENT2BOTDMG:
case SV_BOT2BOTDMG:
{
int target = getint(p);
int damage = getint(p);
int damager = getint(p);
dynent *b = getbot(target);
dynent *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);
dynent *bot = getbot(b);
if((b==killer) && KilledByABot)
{
conoutf("%s suicided", (int)bot->name);
}
else if((killer==clientnum) && !KilledByABot)
{
int frags;
if(isteam(player1->team, bot->team))
{
frags = -1;
conoutf("you fragged a teammate (%s)", (int)bot->name);
}
else
{
frags = 1;
conoutf("you fragged %s", (int)bot->name);
};
addmsg(1, 2, SV_FRAGS, player1->frags += frags);
}
else
{
dynent *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)", (int)bot->name, (int)k->name);
}
else
{
conoutf("%s fragged %s", (int)bot->name, (int)k->name);
}
}
}
playsound(S_DIE1+rnd(2), &bot->o);
bot->lifesequence++;
break;
};
case SV_BOTFRAGS:
{
dynent *b = getbot(getint(p));
if (b) b->frags = getint(p);
break;
}
case SV_BOTUPDATE:
{
int n = getint(p);
dynent *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->bIsBot)
b->bIsBot = true;
if(!demoplayback) updatepos(b);
break;
}
case SV_BOTCOMMAND:
botcommand(p, text);
break;
// End add
default:
neterr("type");