.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Some CS.DLL sources... (http://forums.bots-united.com/showthread.php?t=9124)

Immortal_BLG 08-01-2013 02:55

Some CS.DLL sources...
 
1 Attachment(s)
Something can I already post, but nevertheless...

jeefo 13-01-2013 17:35

Re: Some CS.DLL sources...
 
Still reversing game? )

Immortal_BLG 14-01-2013 04:30

Re: Some CS.DLL sources...
 
Yep! From time to time...

Whistler 14-01-2013 18:41

Re: Some CS.DLL sources...
 
interesting stuff ;)

Code:

                class DefuseBombState : public BotState
                {
/*                        public:
                                virtual      void        OnEnter  (TemplateCSBot *const owner) = 0;
                                virtual      void        OnUpdate (TemplateCSBot *const owner) = 0;
                                virtual      void        OnExit  (TemplateCSBot *const owner) = 0;
                                virtual const char *const GetName  (void) = 0;        // { return "DefuseBomb"; }
*/                };        // sizeof (DefuseBombState) == 4 (1)
                class HideState : public BotState
                {
                        public:
                                enum { MaximumHidingSpotsToPickNumber = 3u };

/*! off=4(1)/2840(710) */                                NavigationArea *m_searchArea;
/*! off=8(2)/2844(711) */                                float          m_searchRange;
/*! off=12(3)/2848(712) */                                Math::Vector3D  m_hiddingSpot;
/*! off=24(6)/2860(715) */                                bool            m_isAtSpot;
/*! off=28(7)/2864(716) */                                float          m_duration;
/*! off=32(8)/2868(717) */                                bool            m_holdPosition;        // Can bot hold position?
/*! off=36(9)/2872(718) */                                float          m_holdPositionTimeAmount;
/*! off=40(10)/2876(719) */                                bool            m_holdPositionAndWaitingEnemy;
/*! off=44(11)/2880(720) */                                float          m_holdPositionStartTimestamp;
/*! off=48(12)/2884(721) */                                unsigned int    m_hidingSpotPickTriesNumber;        // Up to 'MaximumHidingSpotsToPickNumber'.
/*! off=52(13)/2888(722) */                                Math::Vector3D  m_followingTargetPosition;
/*
                        public:
                                virtual      void        OnEnter  (TemplateCSBot *const owner) = 0;
                                virtual      void        OnUpdate (TemplateCSBot *const owner) = 0;
                                virtual      void        OnExit  (TemplateCSBot *const owner) = 0;
                                virtual const char *const GetName  (void) = 0;        // { return "Hide"; }
*/                };        // sizeof (HideState) == 64 (16)
                class EscapeFromBombState : public BotState
                {
/*                        public:
                                virtual      void        OnEnter  (TemplateCSBot *const owner) = 0;
                                virtual      void        OnUpdate (TemplateCSBot *const owner) = 0;
                                virtual      void        OnExit  (TemplateCSBot *const owner) = 0;
                                virtual const char *const GetName  (void) = 0;        // { return "EscapeFromBomb"; }
*/                };        // sizeof (EscapeFromBombState) == 4 (1)
                class FollowState : public BotState
                {
                        public:
/*! off=4(1)/2908(727) */                                EntityHandle              m_leader;
/*! off=12(3)/2916(729) */                                Math::Vector3D            m_UNKNOWN0;
/*! off=24(6)/2928(732) */                                bool                      m_UNKNOWN1;
/*! off=28(7)/2932(733) */                                unsigned int              m_UNKNOWN2;
/*! off=32(8)/2936(734) */                                unsigned int              m_UNKNOWN3_Type;
/*! off=36(9)/2940(735) */                                unsigned int              m_UNKNOWN4_Timestamp;
/*! off=40(10)/2944(736) */                                bool                      m_UNKNOWN5;
/*! off=44(11)/2948(737) */                                float                    m_UNKNOWN6_Timestamp;
/*! off=48(12)/2952(738) */                                Utilities::CountdownTimer m_UNKNOWN7_Timer;
/*! off=56(14)/2960(740) */                                float                    m_UNKNOWN8_Timestamp;
/*! off=60(15)/2964(741) */                                bool                      m_UNKNOWN9;
/*! off=64(16)/2968(742) */                                float                    m_UNKNOWN10_TimeAmount;
/*! off=68(17)/2972(743) */                                Utilities::CountdownTimer m_UNKNOWN11_Timer;
/*
                        public:
                                virtual      void        OnEnter  (TemplateCSBot *const owner) = 0;
                                virtual      void        OnUpdate (TemplateCSBot *const owner) = 0;
                                virtual      void        OnExit  (TemplateCSBot *const owner) = 0;
                                virtual const char *const GetName  (void) = 0;        // { return "Follow"; }
*/                };        // sizeof (FollowState) == 76 (19)
                class UseEntityState : public BotState
                {
                        public:
/*! off=4(1)/2984(746) */                                EntityHandle m_target;
/*
                        public:
                                virtual      void        OnEnter  (TemplateCSBot *const owner) = 0;
                                virtual      void        OnUpdate (TemplateCSBot *const owner) = 0;
                                virtual      void        OnExit  (TemplateCSBot *const owner) = 0;
                                virtual const char *const GetName  (void) = 0;        // { return "UseEntity"; }
*/                };        // sizeof (UseEntityState) == 12 (3)
[...]
        public:
/*! off=2684(671) */                IdleState              m_idleState;
/*! off=2688(672) */                HuntState              m_huntState;
/*! off=2696(674) */                AttackState            m_attackState;                                                                                        // Executed when variable 'm_isAttacking' is true no metter what....
/*! off=2756(689) */                InvestigateNoiseState  m_investigateNoiseState;
/*! off=2772(693) */                BuyState              m_buyState;
/*! off=2800(700) */                MoveToState            m_moveToState;
/*! off=2824(706) */                FetchBombState        m_fetchBombState;
/*! off=2828(707) */                PlantBombState        m_plantBombState;
/*! off=2832(708) */                DefuseBombState        m_defuseBombState;
/*! off=2836(709) */                HideState              m_hideState;
/*! off=2900(725) */                EscapeFromBombState    m_escapeFromBombState;
/*! off=2904(726) */                FollowState            m_followState;
/*! off=2980(745) */                UseEntityState        m_useEntityState;

/*! off=2992(748) */                BotState              *m_currentState;                                                                                        // Executed when variable 'm_isAttacking' is false.

does this mean the official CS bot uses a finite state-machine design with each state wrapped in a class? :)

Whistler 14-01-2013 18:43

Re: Some CS.DLL sources...
 
Code:

void CCSBot::UpdateLookAngles (void)
{
        /// @todo CONTINUE DECOMPILING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        /// @note FROM SOURCE ENGINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        if (*(_DWORD *)(bot_mimic + 48) != 0)
                return;

        if (IsAttacking ())
        {
                v24 = 300.0f;
                v4 = 30.0f;
        }
        else
        {
                v24 = 200.0f;
                v4 = 25.0f;
        }
        v23 = m_lookAngleYaw;
        v26 = m_lookAnglePitch;
        if (m_currentLadder != NULL && !IsLookingAtSpot (PriorityType_High))
                ComputeLadderAngles ((int)&v23, (int)&v26);
        v5 = EyeAngles ();
        LODWORD(v28) = *(_DWORD *)v5;
        LODWORD(v29) = *(_DWORD *)(v5 + 4);
        v30 = *(_DWORD *)(v5 + 8);
        v7 = AngleNormalize (v23 - v29);
        v8 = 3000.0f;
        if (v7 >= 1.0f || v7 <= -1.0f)
        {
                v9 = v7;
                v10 = -3000.0f;
                v11 = v9 * v24 - m_lookAngleYawUNKNOWN * v4;
                if (v11 > 3000.0f || (v8 = v11, v11 >= -3000.0f))
                        v10 = v8;
                v13 = v10 * g_flBotCommandInterval + m_lookAngleYawUNKNOWN;
                m_lookAngleYawUNKNOWN = v13;
                v29 = g_flBotCommandInterval * v13 + v29;
//                if (Math::fabsf (v10) > 1000.0)
//                        *(float *)(this + 14340) = CountdownTimer__Now();
        }
        else
        {
                m_lookAngleYawUNKNOWN = 0.0f;
                v29 = v23;
        }
        v15 = AngleNormalize (v26 - v28);
        v16 = v15 * v24 + v15 * v24 - m_lookAnglePitchUNKNOWN * v4;
        if (v16 <= 3000.0f)
        {
                if (v16 < -3000.0f)
                        v16 = -3000.0f;
        }
        else
                v16 = 3000.0f;
        v18 = v16 * g_flBotCommandInterval + m_lookAnglePitchUNKNOWN;
        m_lookAnglePitchUNKNOWN = v18;
        v19 = g_flBotCommandInterval * v18 + v28;
        v28 = v19;
        v20 = v19;
        v21 = v16;
        v22 = v20;
        if (Math::fabsf (v21) > 1000.0f)
        {
//                *(float *)(this + 14340) = CountdownTimer__Now();
                v22 = v28;
        }
        if (v22 >= -89.0f)
        {
                if (v22 > 89.0f)
                        v28 = 89.0f;
        }
        else
                v28 = -89.0f;
        CBasePlayer__SnapEyeAngles(this, (int)&v28);
//        if (CountdownTimer__Now() <= *(float *)(this + 15580))
//                *(float *)(this + 14340) = CountdownTimer__Now();
}

this looks like how the aiming was done.
IIRC there was a discussion on this one here...
http://forums.bots-united.com/showthread.php?t=3330

jeefo 15-01-2013 18:39

Re: Some CS.DLL sources...
 
if anyone need this now:

Code:

/**
 * Move actual view angles towards desired ones.
 * This is the only place v_angle is altered.
 * @todo Make stiffness and turn rate constants timestep invariant.
 */
void CCSBot::UpdateLookAngles( void )
{
        VPROF_BUDGET( "CCSBot::UpdateLookAngles", VPROF_BUDGETGROUP_NPCS );

        const float deltaT = g_BotUpkeepInterval;
        float maxAccel;
        float stiffness;
        float damping;

        // If mimicing the player, don't modify the view angles.
        if ( bot_mimic.GetInt() )
                return;

        // springs are stiffer when attacking, so we can track and move between targets better
        if (IsAttacking())
        {
                stiffness = 300.0f;
                damping = 30.0f;                        // 20
                maxAccel = 3000.0f;        // 4000
        }
        else
        {
                stiffness = 200.0f;
                damping = 25.0f;
                maxAccel = 3000.0f;
        }

        // these may be overridden by ladder logic
        float useYaw = m_lookYaw;
        float usePitch = m_lookPitch;

        //
        // Ladders require precise movement, therefore we need to look at the
        // ladder as we approach and ascend/descend it.
        // If we are on a ladder, we need to look up or down to traverse it - override pitch in this case.
        //
        // If we're trying to break something, though, we actually need to look at it before we can
        // look at the ladder
        //
        if ( IsUsingLadder() && !(IsLookingAtSpot( PRIORITY_HIGH ) && m_lookAtSpotAttack) )
        {
                ComputeLadderAngles( &useYaw, &usePitch );
        }

        // get current view angles
        QAngle viewAngles = EyeAngles();

        //
        // Yaw
        //
        float angleDiff = AngleNormalize( useYaw - viewAngles.y );

        /*
        * m_forwardAngle is unreliable. Need to simulate mouse sliding & centering
        if (!IsAttacking())
        {
                // do not allow rotation through our reverse facing angle - go the "long" way instead
                float toCurrent = AngleNormalize( pev->v_angle.y - m_forwardAngle );
                float toDesired = AngleNormalize( useYaw - m_forwardAngle );

                // if angle differences are different signs, they cross the forward facing
                if (toCurrent * toDesired < 0.0f)
                {
                        // if the sum of the angles is greater than 180, turn the "long" way around
                        if (abs( toCurrent - toDesired ) >= 180.0f)
                        {
                                if (angleDiff > 0.0f)
                                        angleDiff -= 360.0f;
                                else
                                        angleDiff += 360.0f;
                        }
                }
        }
        */

        // if almost at target angle, snap to it
        const float onTargetTolerance = 1.0f;                // 3
        if (angleDiff < onTargetTolerance && angleDiff > -onTargetTolerance)
        {
                m_lookYawVel = 0.0f;
                viewAngles.y = useYaw;
        }
        else
        {
                // simple angular spring/damper
                float accel = stiffness * angleDiff - damping * m_lookYawVel;

                // limit rate
                if (accel > maxAccel)
                        accel = maxAccel;
                else if (accel < -maxAccel)
                        accel = -maxAccel;

                m_lookYawVel += deltaT * accel;
                viewAngles.y += deltaT * m_lookYawVel;

                // keep track of how long our view remains steady
                const float steadyYaw = 1000.0f;
                if (fabs( accel ) > steadyYaw)
                {
                        m_viewSteadyTimer.Start();
                }
        }

        //
        // Pitch
        // Actually, this is negative pitch.
        //
        angleDiff = usePitch - viewAngles.x;

        angleDiff = AngleNormalize( angleDiff );


        if (false && angleDiff < onTargetTolerance && angleDiff > -onTargetTolerance)
        {
                m_lookPitchVel = 0.0f;
                viewAngles.x = usePitch;
        }
        else
        {
                // simple angular spring/damper
                // double the stiffness since pitch is only +/- 90 and yaw is +/- 180
                float accel = 2.0f * stiffness * angleDiff - damping * m_lookPitchVel;

                // limit rate
                if (accel > maxAccel)
                        accel = maxAccel;
                else if (accel < -maxAccel)
                        accel = -maxAccel;

                m_lookPitchVel += deltaT * accel;
                viewAngles.x += deltaT * m_lookPitchVel;

                // keep track of how long our view remains steady
                const float steadyPitch = 1000.0f;
                if (fabs( accel ) > steadyPitch)
                {
                        m_viewSteadyTimer.Start();
                }
        }

        //PrintIfWatched( "yawVel = %g, pitchVel = %g\n", m_lookYawVel, m_lookPitchVel );

        // limit range - avoid gimbal lock
        if (viewAngles.x < -89.0f)
                viewAngles.x = -89.0f;
        else if (viewAngles.x > 89.0f)
                viewAngles.x = 89.0f;

        // update view angles
        SnapEyeAngles( viewAngles );

        // if our weapon is zooming, our view is not steady
        if (IsWaitingForZoom())
        {
                m_viewSteadyTimer.Start();
        }
}


Immortal_BLG 16-01-2013 04:55

Re: Some CS.DLL sources...
 
Quote:

Originally Posted by Whistler
does this mean the official CS bot uses a finite state-machine design with each state wrapped in a class?

Yes, almost like in your GINABot :)

Quote:

Originally Posted by jeefo
if anyone need this now:

Big thanks!
But where you took this piece? :)
Maybe you will share if you have something else? :{P

jeefo 17-01-2013 16:37

Re: Some CS.DLL sources...
 
Quote:

Originally Posted by Immortal_BLG (Post 64828)
Maybe you will share if you have something else? :{P

What do you need ? :)

Immortal_BLG 18-01-2013 04:31

Re: Some CS.DLL sources...
 
wow!
I need all related to CS/CSS or HL Engine (especially that associated with bots) :P


All times are GMT +2. The time now is 00:47.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.