1 (edited by Jimmy 2018-01-18 13:50:19)

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;

2

Re: Need help with server-side dummies

I can't help you with coding, but consider checking DDNet source code as it has dummy working just fine. (https://ddnet.tw)

Arch Linux users, see packages for some Teeworlds mod here! wink

3

Re: Need help with server-side dummies

rafael.f.f1 wrote:

I can't help you with coding, but consider checking DDNet source code as it has dummy working just fine. (https://ddnet.tw)


DDNet dummy is clientsided and has no serverside dummys. But ddnet++ has it.
https://github.com/ChillerDragon/DDNetPP

Sorry for the Bad english ._.        www.ChillerDragon.weebly.com (teeworlds page)

4 (edited by Deepfinder 2018-02-06 19:04:40)

Re: Need help with server-side dummies

Jimmy wrote:

I implemented Pikotee's dummies in my server, but still have no clue how to make them move and aim.

dummies != bots
Look here for server-side bots: https://github.com/nheir/teeworlds/tree/bMod

I will be banned if I troll again ...

5

Re: Need help with server-side dummies

Well, we did it 5 (!) Years ago, so I could forget something..
Dummy may move when it's alive, so all changes are to be done in character.cpp
If you know mod iDDRace and commands /dh and /dhf, you can look at it's implementation and learn from there: https://github.com/Shahan/teeworlds/blo … racter.cpp