IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> TF2 improvements
JRob
post Sep 18 2015, 12:28 AM
Post #1


Advanced Member
***

Group: Members
Posts: 52
Joined: 30-April 11
Member No.: 1,970



The bot seems to spam joinclass and jointeam because they don't execute immediately.

I solved this by setting the netprop value directly instead of using a command.

This will require you to add the netprop and the ability to change them.

CODE

void CBotFortress :: selectTeam ()
{
    int reds = 0;
    int blues = 0;

    for ( int i=1; i <= gpGlobals->maxClients; i++ )
    {
        edict_t* p = INDEXENT(i);

        if ( p == m_pEdict )
            continue;

        if ( CBotGlobals::entityIsValid(p) )
        {
            int team = CTeamFortress2Mod::getTeam(p);
            if(team == 2)
                reds++;
            else if(team == 3)
                blues++;
        }
    }

    if(reds < blues)
        m_pPlayerInfo->ChangeTeam(2);
    else if(blues > reds)
        m_pPlayerInfo->ChangeTeam(3);
    else
        m_pPlayerInfo->ChangeTeam(randomInt(2,3));
}

void CBotFortress :: selectClass ()
{
    TF_Class _class;

    if ( m_iDesiredClass == 0 )
        _class = (TF_Class)randomInt(1,9);
    else
        _class = (TF_Class)m_iDesiredClass;

    m_iClass = _class;

    #define CHANGE_CLASS(cls) \
    case cls: \
        CClassInterface::setTF2Class(m_pEdict, cls); \
        break;

    switch(_class) {
        CHANGE_CLASS(TF_CLASS_SCOUT)
        CHANGE_CLASS(TF_CLASS_SNIPER)
        CHANGE_CLASS(TF_CLASS_SOLDIER)
        CHANGE_CLASS(TF_CLASS_DEMOMAN)
        CHANGE_CLASS(TF_CLASS_MEDIC)
        CHANGE_CLASS(TF_CLASS_HWGUY)
        CHANGE_CLASS(TF_CLASS_PYRO)
        CHANGE_CLASS(TF_CLASS_SPY)
        CHANGE_CLASS(TF_CLASS_ENGINEER)
        default:
            break;
    }
    m_fChangeClassTime = engine->Time() + randomFloat(bot_min_cc_time.GetFloat(),bot_max_cc_time.GetFloat());
}



CODE

    inline int *getIntPointerFromEdict ( edict_t *edict )
    {
        getData(edict, true);

        return (int*)m_data;
    }    

....

    inline static int getTF2DesiredClass ( edict_t *edict ) { return g_GetProps[GETPROP_TF2DESIREDCLASS].getInt(edict,0); }
    inline static void setTF2Class (edict_t *edict, int value)
    {
        int* p = g_GetProps[GETPROP_TF2DESIREDCLASS].getIntPointerFromEdict(edict);
        if(p != NULL) *p = value;
    }
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 10:15 PM