Beam Bullettracers

Забаненный
Статус
Оффлайн
Регистрация
4 Мар 2018
Сообщения
25
Реакции[?]
12
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Looked into some sources having tried to implement this recently,and i saw a lot of people failing on something this easy,so here you go:

1. Create an Interface for >>IViewRenderBeams<< (client.dll,B9 ?? ?? ?? ?? A1 ?? ?? ?? ?? FF 10 A1 ?? ?? ?? ?? B9 + 1)

Code for the class:
Код:
class IViewRenderBeams
{
public:
    // Construction
public:
    IViewRenderBeams(void);
    virtual                ~IViewRenderBeams(void);
 
    // Implement IViewRenderBeams
public:
    virtual    void        InitBeams(void);
    virtual    void        ShutdownBeams(void);
    virtual    void        ClearBeams(void);
 
    // Updates the state of the temp ent beams
    virtual void        UpdateTempEntBeams();
 
    virtual void        DrawBeam(Beam_t *pbeam);
    virtual void        DrawBeam(C_Beam* pbeam, ITraceFilter *pEntityBeamTraceFilter = NULL);
 
    virtual    void        KillDeadBeams(IClientEntity *pDeadEntity);
 
    virtual    void        CreateBeamEnts(int startEnt, int endEnt, int modelIndex, int haloIndex, float haloScale,
        float life, float width, float endWidth, float fadeLength, float amplitude,
        float brightness, float speed, int startFrame,
        float framerate, float r, float g, float b, int type = -1);
    virtual Beam_t        *CreateBeamEnts(BeamInfo_t &beamInfo);
 
    virtual    void        CreateBeamEntPoint(int    nStartEntity, const Vector *pStart, int nEndEntity, const Vector* pEnd,
        int modelIndex, int haloIndex, float haloScale,
        float life, float width, float endWidth, float fadeLength, float amplitude,
        float brightness, float speed, int startFrame,
        float framerate, float r, float g, float b);
    virtual Beam_t        *CreateBeamEntPoint(BeamInfo_t &beamInfo);
 
    virtual    void        CreateBeamPoints(Vector& start, Vector& end, int modelIndex, int haloIndex, float haloScale,
        float life, float width, float endWidth, float fadeLength, float amplitude,
        float brightness, float speed, int startFrame,
        float framerate, float r, float g, float b);
    virtual    Beam_t        *CreateBeamPoints(BeamInfo_t &beamInfo);
 
    virtual    void        CreateBeamRing(int startEnt, int endEnt, int modelIndex, int haloIndex, float haloScale,
        float life, float width, float endWidth, float fadeLength, float amplitude,
        float brightness, float speed, int startFrame,
        float framerate, float r, float g, float b, int flags);
    virtual Beam_t        *CreateBeamRing(BeamInfo_t &beamInfo);
 
    virtual void        CreateBeamRingPoint(const Vector& center, float start_radius, float end_radius, int modelIndex, int haloIndex, float haloScale,
        float life, float width, float m_nEndWidth, float m_nFadeLength, float amplitude,
        float brightness, float speed, int startFrame,
        float framerate, float r, float g, float b, int flags);
    virtual Beam_t        *CreateBeamRingPoint(BeamInfo_t &beamInfo);
 
    virtual    void        CreateBeamCirclePoints(int type, Vector& start, Vector& end,
        int modelIndex, int haloIndex, float haloScale, float life, float width,
        float endWidth, float fadeLength, float amplitude, float brightness, float speed,
        int startFrame, float framerate, float r, float g, float b);
    virtual Beam_t        *CreateBeamCirclePoints(BeamInfo_t &beamInfo);
 
    virtual    void        CreateBeamFollow(int startEnt, int modelIndex, int haloIndex, float haloScale,
        float life, float width, float endWidth, float fadeLength, float r, float g, float b,
        float brightness);
    virtual Beam_t        *CreateBeamFollow(BeamInfo_t &beamInfo);
 
};
Then we are gonna log the data of every bullet fired using fireeventclientside or your own logger.We will use a struct to store the userID,the position from where the bullet was fired from,where it impacted,and the impacttime all in once.
Код:
struct bullet
{
    bullet(int userID, Vector FirePos, Vector i, float itime)
    {
        this->userid= userid;
        this->firepos= FirePos;
        this->impactpos= i;
        this->impacttime= itime;
    }
    Vector impactpos;
    float impacttime;
    Vector firepos;
    int userid;
 
 
 
};
Create a std::vector to store
Код:
std::vector<bullet> bulletdata;

Before we can start storing our bulletdata and actually drawing the beams,we need to define the Beam itself and its info:

Код:
struct BeamInfo_t
{
    int            m_nType;
 
    // Entities
    IClientEntity* m_pStartEnt;
    int            m_nStartAttachment;
    IClientEntity* m_pEndEnt;
    int            m_nEndAttachment;
 
    // Points
    Vector        m_vecStart;
    Vector        m_vecEnd;
 
    int            m_nModelIndex;
    const char    *m_pszModelName;
 
    int            m_nHaloIndex;
    const char    *m_pszHaloName;
    float        m_flHaloScale;
 
    float        m_flLife;
    float        m_flWidth;
    float        m_flEndWidth;
    float        m_flFadeLength;
    float        m_flAmplitude;
 
    float        m_flBrightness;
    float        m_flSpeed;
 
    int            m_nStartFrame;
    float        m_flFrameRate;
 
    float        m_flRed;
    float        m_flGreen;
    float        m_flBlue;
 
    bool        m_bRenderable;
 
    int            m_nSegments;
 
    int            m_nFlags;
 
    // Rings
    Vector        m_vecCenter;
    float        m_flStartRadius;
    float        m_flEndRadius;
 
    BeamInfo_t()
    {
        m_nType = 0;
        m_nSegments = -1;
        m_pszModelName = NULL;
        m_pszHaloName = NULL;
        m_nModelIndex = -1;
        m_nHaloIndex = -1;
        m_bRenderable = true;
        m_nFlags = 0;
    }
};

Now we can store where the bullet has hit,the userid... and everything what we need,using the bullet_impact event

Код:
Vector position(event->GetInt("x"), event->GetInt("y"), event->GetInt("z"));
 
        BulletLogs.push_back(BulletImpactLog(event->GetInt("userid"), firingentity->GetEyePos(), position, pGlobals->curtime));

Since we have everything good to go when it comes to data,we can now start drawing the actual beams:

Код:
BeamInfo_t beamInfo;
    beamInfo.m_nType = 0;
    beamInfo.m_pszModelName = "sprites/physbeam.vmt";
    beamInfo.m_nModelIndex = 1;
    beamInfo.m_flHaloScale = 0.0f;
    beamInfo.m_vecStart = (Vector) startPos;
    beamInfo.m_vecEnd = (Vector) endPos;
    beamInfo.m_flLife = 2.f;
 
    beamInfo.m_flFadeLength = 0.1f;
    beamInfo.m_flAmplitude = 2.3f;
    beamInfo.m_nSegments = 2;
    beamInfo.m_bRenderable = true;
    beamInfo.m_flBrightness = 255.f;
    beamInfo.m_flSpeed = 0.2f;
    beamInfo.m_nStartFrame = 0;
    beamInfo.m_flFrameRate = 0.f;
    beamInfo.m_flWidth = 3.5f;
    beamInfo.m_flEndWidth = 1.1f;
 
    beamInfo.m_nFlags = 0;
 
 
 
    Beam_t* myBeam = m_pViewRenderBeams->CreateBeamPoints(beamInfo);
 
    if (myBeam)
        m_pViewRenderBeams->DrawBeam(myBeam); //renderBeam func

Now we just need to find the perfect place to draw them,i personally do it in FSN,if you have better ideas,let me know:

Код:
renderbeam(bullet[i].firepos, bullet[i].impactpos); //colors can easily be applied with beamInfo.m_flRed,flGreen etc..
 
Последнее редактирование:
Похожие темы
Сверху Снизу