Topic: Need help with server-side dummies
Hi!
I implemented Pikotee's dummies in my server, but still have no clue how to make them move and aim.
I just started learing c++, so i'm asking for your help.
Here's some code:
Character.cpp
void CCharacter::DummyMovement()
{
// testing
if(m_pPlayer->m_IsDummy)
{
m_Input.m_Direction = 1;
}
}
/*
void CCharacter::DummyAim()
{
if(ClientState(m_pPlayer->GetCID()) == CServer::CClient::STATE_DUMMY)
{
for(int i=0; i<MAX_CLIENTS;i++)
{
if(!GameServer()->GetPlayerChar(i) || ClientState(i) == CServer::CClient::STATE_DUMMY || (m_DummyLockChar != -1 && m_DummyLockChar != i))
continue;
if(distance(m_Pos, GameServer()->GetPlayerChar(i)->Core()->m_Pos) < 300)// maybe he moved
{
m_DummyLockChar = i;
CCharacter *pChar = GameServer()->GetPlayerChar(m_DummyLockChar);
m_LatestInput.m_TargetX = pChar->Core()->m_Pos.x - m_Pos.x;
m_LatestInput.m_TargetY = pChar->Core()->m_Pos.y - m_Pos.y;
}
else
m_DummyLockChar = -1;
}
}
}*/
player.h
bool m_IsDummy;
engine/server/server.h
void DummyJoin(int DummyID, const char *pDummyName, const char *pDummyClan, int Country);
void DummyLeave(int DummyID, const char *pReason = "No reason given");
engine/server/server.cpp
void CServer::DummyJoin(int DummyID, const char *pDummyName, const char *pDummyClan, int Country)
{
m_NetServer.DummyInit(DummyID);
m_aClients[DummyID].m_State = CClient::STATE_DUMMY;
str_copy(m_aClients[DummyID].m_aName, pDummyName, MAX_NAME_LENGTH);
str_copy(m_aClients[DummyID].m_aClan, pDummyClan, MAX_CLAN_LENGTH);
m_aClients[DummyID].m_Country = Country;
}
// Dummy
void CServer::DummyLeave(int DummyID, const char *pReason)
{
GameServer()->OnClientDrop(DummyID, pReason);
m_aClients[DummyID].m_State = CClient::STATE_EMPTY;
m_aClients[DummyID].m_aName[0] = 0;
m_aClients[DummyID].m_aClan[0] = 0;
m_aClients[DummyID].m_Country = -1;
m_aClients[DummyID].m_Authed = AUTHED_NO;
m_aClients[DummyID].m_AuthTries = 0;
m_aClients[DummyID].m_pRconCmdToSend = 0;
m_aClients[DummyID].m_Snapshots.PurgeAll();
m_NetServer.DummyDelete(DummyID);
}
engine/server.h
virtual void DummyJoin(int DummyID, const char *pDummyName, const char *pDummyClan, int Country) = 0;
virtual void DummyLeave(int DummyID, const char *pReason = "No reason given") = 0;