2004-07-22 12:46:35 +00:00
|
|
|
#include "ns.h"
|
|
|
|
|
|
|
|
void CPlayer::PreThink()
|
|
|
|
{
|
|
|
|
if (!connected)
|
|
|
|
{
|
|
|
|
// This usually means it's a bot...
|
|
|
|
// So just emulate connections
|
|
|
|
Connect();
|
|
|
|
bot=true;
|
|
|
|
}
|
2004-09-10 13:57:10 +00:00
|
|
|
if (olddeadflag && pev->deadflag == 0 && SpawnForward != -1)
|
2004-09-10 18:43:37 +00:00
|
|
|
MF_ExecuteForward(SpawnForward,index());
|
2004-09-10 13:57:10 +00:00
|
|
|
|
|
|
|
if (oldteam != pev->team && TeamForward != -1)
|
2004-09-10 18:43:37 +00:00
|
|
|
MF_ExecuteForward(TeamForward,index(),pev->team,oldteam);
|
2004-09-10 13:57:10 +00:00
|
|
|
|
2004-07-22 12:46:35 +00:00
|
|
|
int tClass = GetClass();
|
|
|
|
if (tClass != iclass)
|
|
|
|
ChangeClass(tClass);
|
|
|
|
oldimpulse=pev->impulse;
|
2004-09-10 13:57:10 +00:00
|
|
|
olddeadflag = pev->deadflag;
|
|
|
|
oldteam = pev->team;
|
2004-07-22 12:46:35 +00:00
|
|
|
}
|
|
|
|
void CPlayer::PreThink_Post()
|
|
|
|
{
|
|
|
|
// Trying to incorperate this into PostThink_Post led to really *weird* results (i don't think it was propagated to the client properly).
|
|
|
|
// Change the users speed here
|
|
|
|
maxspeed=(int)pev->maxspeed;
|
|
|
|
pev->maxspeed+=speedchange;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayer::PostThink_Post()
|
|
|
|
{
|
|
|
|
// Change the player's models...
|
|
|
|
if (custommodel)
|
|
|
|
SET_MODEL(edict,model);
|
|
|
|
if (customskin)
|
|
|
|
pev->skin=skin;
|
|
|
|
if (custombody)
|
|
|
|
pev->body=body;
|
|
|
|
}
|
|
|
|
void CPlayer::ChangeClass(int newclass)
|
|
|
|
{
|
2004-09-10 13:57:10 +00:00
|
|
|
if (ChangeclassForward != -1)
|
2004-09-10 18:43:37 +00:00
|
|
|
MF_ExecuteForward(ChangeclassForward, index(), newclass, iclass, oldimpulse);
|
2004-07-22 12:46:35 +00:00
|
|
|
iclass=newclass;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CPlayer::GetClass()
|
|
|
|
{
|
|
|
|
if (pev->deadflag)
|
|
|
|
return CLASS_DEAD;
|
|
|
|
if (!pev->team)
|
|
|
|
return CLASS_NOTEAM;
|
|
|
|
switch (pev->iuser3)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
// Light armor marine..
|
|
|
|
if (pev->iuser4 & MASK_HEAVYARMOR)
|
|
|
|
return CLASS_HEAVY;
|
|
|
|
if (pev->iuser4 & MASK_JETPACK)
|
|
|
|
return CLASS_JETPACK;
|
|
|
|
return CLASS_MARINE;
|
|
|
|
case 2:
|
|
|
|
return CLASS_COMMANDER;
|
|
|
|
case 3:
|
|
|
|
return CLASS_SKULK;
|
|
|
|
case 4:
|
|
|
|
return CLASS_GORGE;
|
|
|
|
case 5:
|
|
|
|
return CLASS_LERK;
|
|
|
|
case 6:
|
|
|
|
return CLASS_FADE;
|
|
|
|
case 7:
|
|
|
|
return CLASS_ONOS;
|
|
|
|
case 8:
|
|
|
|
return CLASS_GESTATE;
|
|
|
|
}
|
|
|
|
return CLASS_UNKNOWN;
|
|
|
|
|
|
|
|
}
|
|
|
|
void CPlayer::Connect()
|
|
|
|
{
|
|
|
|
connected=true;
|
|
|
|
bot=false;
|
2004-09-10 13:57:10 +00:00
|
|
|
|
2004-07-22 12:46:35 +00:00
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
void CPlayer::Disconnect()
|
|
|
|
{
|
|
|
|
connected=false;
|
|
|
|
bot=false;
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
void CPlayer::Reset()
|
|
|
|
{
|
|
|
|
this->custombody=false;
|
|
|
|
this->custommodel=false;
|
|
|
|
this->customskin=false;
|
|
|
|
this->maxspeed=0;
|
|
|
|
this->speedchange=0;
|
|
|
|
this->model[0]='\0';
|
|
|
|
this->skin=0;
|
|
|
|
this->body=0;
|
2004-07-27 01:15:10 +00:00
|
|
|
this->fov=0.0;
|
|
|
|
this->foved=false;
|
2004-09-10 13:57:10 +00:00
|
|
|
olddeadflag=0;
|
|
|
|
oldteam=0;
|
|
|
|
|
2004-07-22 12:46:35 +00:00
|
|
|
}
|