I have a problem where an entity works during the first run, but loses a pointer upon loading a saved game.
This is my "Power Spore" entity, based on on xen_spore_large. It creates and saves its own sprite (adapted directly from the xen_plantlight entity code). Relevant portion of the class definition --
class CXenSporePower : public CXenSpore
{
static TYPEDESCRIPTION m_SaveData[]; // so we can save our
pointer
private :
CSprite *m_pGlow;
}There's a typedescription for the saved data -- again, based directly on what xen_plantlight does ...
TYPEDESCRIPTION CXenSporePower::m_SaveData[] =
{
DEFINE_FIELD( CXenSporePower, m_pGlow, FIELD_CLASSPTR ),
};Then in Spawn(), the sprite gets created ...
m_pGlow = CSprite::SpriteCreate( POWER_SPORE_SPRITE, pev->origin +
Vector(0,0,(pev->mins.z+pev->maxs.z)*0.5 + 50 ), TRUE );
m_pGlow->SetTransparency( kRenderTransAdd, 0, 255, 0, 196,
pev->renderfx );
// m_pGlow->SetAttachment( edict(), 1 ); // don't use this -- let
SpriteCreate define the location
m_pGlow->pev->scale = 5.0 ;
if ( m_pGlow )
{
m_pGlow->pev->effects &= ~EF_NODRAW;
}All of the above works, on the initial run -- the sprite makes a nice corona effect around the spore pod. There's also some code in Think() which changes the sprite color to indicate the team power level status, which works fine on first run.
Upon loading a saved game, the sprite still visually appears in the correct place. But m_pGlow is null, dammit.
SetAttachment is commented out because the SpriteCreate has to set the position. But the same problem occurs when I used SetAttachment.
It's simple code, adapted with minimal change from good old xen_plantlight. But so far I haven't figured out what I'm doing wrong ....
Anyone got the answer?
Thanks - - Karl Jones ... the Handy Vandal
_______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

