Missing animated sprite cleanup

This commit is contained in:
Marco Cawthorne 2019-01-10 11:14:50 +01:00
parent 79db5ac5fe
commit d244904f84
2 changed files with 43 additions and 29 deletions

View file

@ -8,7 +8,8 @@
.float framerate; .float framerate;
void Sprite_AnimateThink( void ) { void Sprite_AnimateThink(void)
{
if( self.frame >= self.maxframe ) { if( self.frame >= self.maxframe ) {
if (self.health == 1) { if (self.health == 1) {
remove(self); remove(self);
@ -22,34 +23,45 @@ void Sprite_AnimateThink( void ) {
self.nextthink = time + ( 1 / self.framerate ); self.nextthink = time + ( 1 / self.framerate );
} }
void Sprite_Animated( vector vPos, float fIndex, float fFPS, float fScale, float fAlpha, float fEffects ) { void Sprite_Animated(void)
self.modelindex = fIndex; {
setorigin( self, vPos ); self.origin_x = readcoord();
self.scale = fScale; self.origin_y = readcoord();
self.alpha = fAlpha; self.origin_z = readcoord();
self.effects = fEffects; self.modelindex = readfloat();
self.framerate = fFPS; self.framerate = readfloat();
self.scale = readfloat();
self.alpha = readfloat();
self.effects = readfloat();
self.colormod[0] = readfloat();
self.colormod[1] = readfloat();
self.colormod[2] = readfloat();
self.think = Sprite_AnimateThink; self.think = Sprite_AnimateThink;
self.drawmask = MASK_ENGINE; self.drawmask = MASK_ENGINE;
self.nextthink = time + ( 1 / self.framerate ); self.nextthink = time + ( 1 / self.framerate );
self.maxframe = modelframecount( self.modelindex ); self.maxframe = modelframecount( self.modelindex );
self.health = 0; /* repeats */ self.health = 0; /* repeats */
setorigin(self, self.origin);
} }
void Sprite_ParseEvent(void) void Sprite_ParseEvent(void)
{ {
entity sprite = spawn(); entity sprite = spawn();
sprite.origin_x = readcoord(); sprite.origin[0] = readcoord();
sprite.origin_y = readcoord(); sprite.origin[1] = readcoord();
sprite.origin_z = readcoord(); sprite.origin[2] = readcoord();
sprite.modelindex = readfloat(); sprite.modelindex = readfloat();
sprite.framerate = readfloat(); sprite.framerate = readfloat();
sprite.scale = readfloat(); sprite.scale = readfloat();
sprite.alpha = readfloat(); sprite.alpha = readfloat();
sprite.effects = readfloat(); sprite.effects = readfloat();
sprite.colormod[0] = readfloat();
sprite.colormod[1] = readfloat();
sprite.colormod[2] = readfloat();
sprite.think = Sprite_AnimateThink; sprite.think = Sprite_AnimateThink;
sprite.drawmask = MASK_ENGINE; sprite.drawmask = MASK_ENGINE;
sprite.nextthink = time + ( 1 / self.framerate ); sprite.nextthink = time + ( 1 / self.framerate );
sprite.maxframe = modelframecount( self.modelindex ); sprite.maxframe = modelframecount( self.modelindex );
sprite.health = 1; /* does not repeat */ sprite.health = 1; /* does not repeat */
setorigin(sprite, self.origin);
} }

View file

@ -19,7 +19,6 @@ class env_sprite:CBaseTrigger
int m_iToggled; int m_iToggled;
float m_flFramerate; float m_flFramerate;
float m_flScale; float m_flScale;
float m_flAlpha;
float m_flEffects; float m_flEffects;
void() env_sprite; void() env_sprite;
@ -34,29 +33,35 @@ float env_sprite::Network(entity pvsent, float flags)
return FALSE; return FALSE;
} }
WriteByte(MSG_ENTITY, ENT_SPRITE); WriteByte(MSG_ENTITY, ENT_SPRITE);
WriteCoord(MSG_ENTITY, origin_x); WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin_y); WriteCoord(MSG_ENTITY, origin[1]);
WriteCoord(MSG_ENTITY, origin_z); WriteCoord(MSG_ENTITY, origin[2]);
WriteFloat(MSG_ENTITY, modelindex); WriteFloat(MSG_ENTITY, modelindex);
WriteFloat(MSG_ENTITY, m_flFramerate); WriteFloat(MSG_ENTITY, m_flFramerate);
WriteFloat(MSG_ENTITY, m_flScale); WriteFloat(MSG_ENTITY, m_flScale);
WriteFloat(MSG_ENTITY, m_flAlpha); WriteFloat(MSG_ENTITY, alpha);
WriteFloat(MSG_ENTITY, effects); WriteFloat(MSG_ENTITY, effects);
WriteFloat(MSG_ENTITY, colormod[0]);
WriteFloat(MSG_ENTITY, colormod[1]);
WriteFloat(MSG_ENTITY, colormod[2]);
return TRUE; return TRUE;
} }
void env_sprite::NetworkOnce(void) void env_sprite::NetworkOnce(void)
{ {
WriteByte( MSG_MULTICAST, SVC_CGAMEPACKET ); WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET );
WriteByte(MSG_ENTITY, EV_SPRITE); WriteByte(MSG_MULTICAST, EV_SPRITE);
WriteCoord(MSG_ENTITY, origin_x); WriteCoord(MSG_MULTICAST, origin[0]);
WriteCoord(MSG_ENTITY, origin_y); WriteCoord(MSG_MULTICAST, origin[1]);
WriteCoord(MSG_ENTITY, origin_z); WriteCoord(MSG_MULTICAST, origin[2]);
WriteFloat(MSG_ENTITY, modelindex); WriteFloat(MSG_MULTICAST, modelindex);
WriteFloat(MSG_ENTITY, m_flFramerate); WriteFloat(MSG_MULTICAST, m_flFramerate);
WriteFloat(MSG_ENTITY, m_flScale); WriteFloat(MSG_MULTICAST, m_flScale);
WriteFloat(MSG_ENTITY, m_flAlpha); WriteFloat(MSG_MULTICAST, alpha);
WriteFloat(MSG_ENTITY, effects); WriteFloat(MSG_MULTICAST, effects);
WriteFloat(MSG_MULTICAST, colormod[0]);
WriteFloat(MSG_MULTICAST, colormod[1]);
WriteFloat(MSG_MULTICAST, colormod[2]);
msg_entity = this; msg_entity = this;
multicast( origin, MULTICAST_PVS ); multicast( origin, MULTICAST_PVS );
} }
@ -81,9 +86,6 @@ void env_sprite::env_sprite(void)
case "scale": case "scale":
m_flScale = stof(argv(i + 1)); m_flScale = stof(argv(i + 1));
break; break;
case "alpha":
m_flAlpha = stof(argv(i + 1));
break;
default: default:
break; break;
} }