.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   draw beam (http://forums.bots-united.com/showthread.php?t=3315)

Cheeseh 01-01-2005 23:30

draw beam
 
okay I've been making a new bot template from botmans so far, I'm trying to do some waypoint stuff, just trying to wonder how to draw a waypoint.

I can't really include the beam stuff as I need to include lots of files that can't find lots of stuff.

I have:
Code:


void CWaypoint :: draw ( edict_t *pEdict )
{
        CTEBeamPoints *beam = new CTEBeamPoints();

        CEdictRecipient *filter = new CEdictRecipient(pEdict,false);

        engine->UserMessageBegin(filter,TE_BEAMPOINTS); // TE_BEAMPOINTS in here?? what about tempentity...?
        // are these in right order??
        WRITE_COORD(/*???*/) // ??? start and end points???
        WRITE_BYTE( m_nModelIndex ); //???
        WRITE_BYTE( m_nHaloIndex );
        WRITE_BYTE( m_nStartFrame );
        WRITE_BYTE( m_nFrameRate );
        WRITE_FLOAT( m_fLife );
        WRITE_FLOAT( m_fWidth );
        WRITE_FLOAT( m_fEndWidth );
        WRITE_BYTE( m_nFadeLength );
        WRITE_FLOAT( m_fAmplitude );
        WRITE_BYTE( r );
        WRITE_BYTE( g );
        WRITE_BYTE( b );
        WRITE_BYTE( a );
        WRITE_BYTE( m_nSpeed );
        WRITE_BYTE( m_nFlags );
        engine->MessageEnd();       

        delete filter;
}

I had to make a filter:
Code:

class CEdictRecipient : public IRecipientFilter
{
public:
        CEdictRecipient ( edict_t *pEdict, bool bReliable )
        {
                m_pEdict = pEdict;
                m_bReliable = bReliable;
        }

        // require destructor
        ~CEdictRecipient ()
        {
                m_pEdict = NULL;
                m_bReliable = false;
        }

        bool        IsReliable( void ) const { return m_bReliable; }

        bool        IsInitMessage( void ) const { return false; }

        int                GetRecipientCount( void ) const { return 1; }
        int                GetRecipientIndex( int slot ) const { return ENTINDEX(m_pEdict); } // only 1 stored
private:
        edict_t *m_pEdict;
        bool m_bReliable;
};

anyone found anything?

sfx1999 01-01-2005 23:51

Re: draw beam
 
Isn't there a beam entity?

Cheeseh 02-01-2005 00:08

Re: draw beam
 
aye but remember that this is a plugin, no access to lots of stuff, and when you try to include the beam code you get hundreds of errors and external errors because a lot of the stuff is non plugin related.

botman 02-01-2005 00:12

Re: draw beam
 
You might want to consider using NDebugOverlay stuff instead of beams. NDebugOverlay includes...
Code:

void Box(const Vector &origin, const Vector &mins, const Vector &maxs, int r, int g, int b, int a, float flDuration);
 void BoxDirection(const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &forward, int r, int g, int b, int a, float flDuration);
 void BoxAngles(const Vector &origin, const Vector &mins, const Vector &maxs, const QAngle &angles, int r, int g, int b, int a, float flDuration);
 void SweptBox(const Vector& start, const Vector& end, const Vector& mins, const Vector& maxs, const QAngle & angles, int r, int g, int b, int a, float flDuration);
 void EntityBounds( const CBaseEntity *pEntity, int r, int g, int b, int a, float flDuration );
 void Line( const Vector &origin, const Vector &target, int r, int g, int b, bool noDepthTest, float flDuration );
 void Triangle( const Vector &p1, const Vector &p2, const Vector &p3, int r, int g, int b, int a, bool noDepthTest, float duration );
 void EntityText( int entityID, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255);
 void Grid( const Vector &vPosition );
 void Text( const Vector &origin, const char *text, bool bViewCheck, float flDuration );
 void ScreenText( float fXpos, float fYpos, const char *text, int r, int g, int b, int a, float flDuration);
 void Cross3D(const Vector &position, const Vector &mins, const Vector &maxs, int r, int g, int b, bool noDepthTest, float flDuration );
 void Cross3D(const Vector &position, float size, int r, int g, int b, bool noDepthTest, float flDuration );
 void Cross3DOriented( const Vector &position, const QAngle &angles, float size, int r, int g, int b, bool noDepthTest, float flDuration );
 void Cross3DOriented( const matrix3x4_t &m, float size, int c, bool noDepthTest, float flDuration );
 void DrawOverlayLines(void);
 void DrawTickMarkedLine(const Vector &startPos, const Vector &endPos, float tickDist, int tickTextDist, int r, int g, int b, bool noDepthTest, float flDuration );
 void DrawGroundCrossHairOverlay();
 void HorzArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
 void YawArrow( const Vector &startPos, float yaw, float length, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
 void VertArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);

See src\dlls\ndebugoverlay.cpp for details.

I'm not sure if/how NDebugOverlay would work from a plugin, but it seems like a much better system for drawing "debug" lines/boxes/text/etc in the game.

botman

Cheeseh 02-01-2005 00:15

Re: draw beam
 
thanks, yeah I've had a small look at that. There is a small thing though, there was a comment saying that is won't work on HL dedicated server (The interface would be NULL), meaning that clients wanting to make waypoints on a dedicated server might not be able to. I'll have a go at it anyway for now.

edit:

Actually I think the DebugOverlay stuff will ever only work for the local client, there is no input as to what player this should be sent to, even in the Line function it just picks the local player and works with it to determine what the local player can see to clip lines, but is not passed to the engine debugoverlay functions.

sfx1999 02-01-2005 05:08

Re: draw beam
 
Is there a network message you can send to trigger a beam on the client?

Cheeseh 02-01-2005 12:28

Re: draw beam
 
The only thing I know is I need to fire a TempEntity net message, with TE_BEAMPOINTS. But that needs access to a ServerClass() what ever that is, which means you really need the TE_BeamPoints class, but again when you try to include that it's a pian because it includes lots of non plugin stuff.

Cheeseh 02-01-2005 13:07

Re: draw beam
 
Actually I think I#ve got it, I think you've got to get the Server Effects Interface :

IEffects *g_pEffects = NULL;

..

g_pEffects = (IEffects* )interfaceFactory(IEFFECTS_INTERFACE_VERSION,NULL) ;

...

g_pEffects->Beam(..,..);

Haven't tried it yet though but it compiles okay

Edit:

Arrrrgh.. Okay the interfaceFactory returns NULL.. :@

Jerry 02-01-2005 14:04

Re: draw beam
 
Quote:

Originally Posted by Cheeseh
Actually I think I#ve got it, I think you've got to get the Server Effects Interface :

IEffects *g_pEffects = NULL;

..

g_pEffects = (IEffects* )interfaceFactory(IEFFECTS_INTERFACE_VERSION,NULL) ;

...

g_pEffects->Beam(..,..);

Haven't tried it yet though but it compiles okay

Edit:

Arrrrgh.. Okay the interfaceFactory returns NULL.. :@

Don't use interfaceFactory.
Use this instead:

Code:

effects = (IEffects*)gameServerFactory(IEFFECTS_INTERFACE_VERSION, NULL);

Cheeseh 02-01-2005 14:11

Re: draw beam
 
Thanks!


All times are GMT +2. The time now is 08:33.

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