mercredi 26 mars 2014

[Help] NoSpread topic




Hey,
as i see that not many saw my new posts here: http://www.unknowncheats.me/forum/co...in_attack.html

I decided to make a new thread.

I have one more question but concerning NoSpread. I am using the NoSpread from NK2.
But somehow it doesn't work propaly.

In the HUD_PostRunCmd(), if i only use the PostRunCmd from gNoSpread then i have no animations and so on, if i use both then there is no NoSpread effect

Code:


void HUD_PostRunCmd ( struct local_state_s *from, struct local_state_s  *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int  random_seed )
{
    gClient.HUD_PostRunCmd(from, to, cmd, runfuncs, time, random_seed);
    gNoSpread.HUD_PostRunCmd(from,to,cmd,runfuncs,time,random_seed);
}


My CL_CreateMove looks like this

Code:


void CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active )
{
    gClient.CL_CreateMove(frametime, cmd, active);

    ApplyNoRecoil(frametime, me.punchangle, cmd->viewangles);
   

    //nospread
    if (cvars.nospread && me.alive)
    {
        float offset[3];
        gNoSpread.GetSpreadOffset(me.spread.random_seed, 1, cmd->viewangles, me.pmVelocity, offset);
        cmd->viewangles[0] += offset[0];
        cmd->viewangles[1] += offset[1];
        cmd->viewangles[2] += offset[2];
    }

    if(cvars.bunnyhop)
    {
        me.DoBunnyHop(cmd);
    }
}


the struct from players.h for me and nospread is this:

Code:


struct spread_info
{
    unsigned int random_seed;
    int recoil;
    float gtime;
    float prevtime;
    float brokentime; // This is only supposed to be set to zero when you buy the sg550 or the g3sg1
                        // not when you reload, switch weapons or pick up a weapon, this is do to the
                        // cs bugs for these guns (valve fix your code please)
    float spreadvar;
    float recoiltime;
    bool firing;
    int WeaponState;
    int prcflags;
};

struct sMe
{
    int iClip;
    int iHealth;
    int iArmor;
    int iKills;
    int iDeaths;
    int iHs;
    int iMoney;

    int iFOV;
    float pmVelocity[3];
    float punchangle[3];
    float pmEyePos[3];
    int pmFlags;
    float viewAngles[3];
    float sin_yaw, minus_cos_yaw;
    bool inZoomMode;
    int pmMoveType;
    int team;
    struct cl_entity_s * ent;
    int entindex;
    bool alive;
    spread_info spread;
    void DoBunnyHop(struct usercmd_s *usercmd);
};


What am i doing wrong? As i said, using it from NK2 (from the ETK sources)

the

Code:


gClient.HUD_PostRunCmd(from, to, cmd, runfuncs, time, random_seed);

is normally the client function.

the one from NoSpread here:

Code:


void cNoSpread::HUD_PostRunCmd(struct local_state_s *from, struct  local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time,  unsigned int random_seed)
{
    static int prevammo = 0, curammo;
    int i, index, Id;

    if (runfuncs)
    {
        me.spread.random_seed = random_seed;

        me.spread.gtime = time;

        me.spread.prcflags = to->client.flags;

        if (cmd->buttons & IN_ATTACK &&  CanCurWeaponAttack()) // catch case when pistol and IN_ATTACK is always  on and not firing
        {
            PrimaryAttack();
        }
        else if (!(cmd->buttons & (IN_ATTACK | IN_ATTACK2)))
        {
            if (me.spread.firing)
            {
                me.spread.firing = false;

                if (me.spread.recoil > 15)
                    me.spread.recoil = 15;

                me.spread.recoiltime = time + 0.4;
            }

            if (IsCurWeaponSec())
            {
                me.spread.recoil = 0;
            }
            else if (me.spread.recoil > 0)
            {
                if (me.spread.recoiltime <= time)
                {
                    me.spread.recoiltime = me.spread.recoiltime + 0.0225;
                    me.spread.recoil--;
                }
            }
        }

        for (i=0;i<WeaponList.size();i++)
        {
            if (WeaponList[i].Id == to->client.m_iId)
            {
                if (!WeaponList[i].CurWeapon) // FIX: This doesn't catch when you have a weapon and you buy the same weapon
                {
                    prevammo = 0;

                    me.spread.recoil = 0;
                    me.spread.prevtime = 0;
                    DefaultSpreadVar(WeaponList[i].Id);
                    me.spread.recoiltime = time;
                    me.spread.firing = true;
                }

                WeaponList[i].CurWeapon = true;
            }
            else
                WeaponList[i].CurWeapon = false;
        }

        for (i=0;i<MAX_WEAPONS;i++)
        {
            // this assumes (i == wd[i].m_iId)
            index = GetWeaponIndexByID(i);
            if (index == -1)
                continue;

            if (to->weapondata[i].m_iId)
                memcpy(&WeaponList[index].weapondata, &to->weapondata[i], sizeof(weapon_data_t));
            else
                memset(&WeaponList[index].weapondata, 0, sizeof(weapon_data_t));
        }

        if (IsReloading())
        {
            Id = GetCurWeaponId();

            me.spread.recoil = 0;
            me.spread.prevtime = 0;
            DefaultSpreadVar(Id);
            me.spread.recoiltime = time;
            me.spread.firing = false;
        }

        curammo = GetCurWeaponAmmo();
        prevammo = curammo;
    }
}



Code:


void HUD_PostRunCmd ( struct local_state_s *from, struct local_state_s  *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int  random_seed );

and here from nospread:

Code:


class cNoSpread
{
    public:
        void GetSpreadOffset(unsigned int seed, int future, float *inangles, float *velocity, float *outangles);
        void HUD_PostRunCmd(struct local_state_s *from, struct  local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time,  unsigned int random_seed);

    private:
        unsigned int U_Random( void );
        float GetVecSpread(float speed);
        void DefaultSpreadVar(int weaponid);
        void PrimaryAttack(void);
        void VectorAngles(const float *forward, float *angles);
        void U_Srand( unsigned int seed );
        void GetSpreadXY(unsigned int seed, int future, float *velocity, float *vec);
        int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
        float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
};
extern cNoSpread gNoSpread;







Aucun commentaire:

Enregistrer un commentaire