Help with animating sprite (.spr) in Pawn language

New Member
Joined
Jan 30, 2003
Messages
135
Best answers
0
Hi everyone,

This past weekend, I've been trying to code my first plugin in pawn. I have not been able to animate my sprite explode02.spr (from half-life sdk) no matter what I do and I'd like some help from those that know how.

here's a code snippet:

Code:
        //Called whenever the PS hud appears

        //Good for entering water by beam block or swoop



        new origin[3], Float:Orig[3];

	get_user_origin(id, origin, 0);

	Orig[0] = float(origin[0]);

	Orig[1] = float(origin[1]);

	Orig[2] = float(origin[2]);



        //Draw sprite here

        new ent = create_entity("env_sprite");

        entity_set_string(ent, EV_SZ_model, "sprites/explode02.spr");   //additional info on the entity can be used to match entities



        //From Harsens' EFFECTS.CPP & edited to AMX Functions

        set_pev(ent, pev_spawnflags, SF_SPRITE_STARTON);      //env_sprite

        set_pev(ent, pev_solid, SOLID_NOT);

	set_pev(ent, pev_movetype, MOVETYPE_NONE);

	set_pev(ent, pev_effects, 0);           //Produces glaring sprite on EF_LIGHT

	set_pev(ent, pev_frame, 0);



        engfunc(EngFunc_SetModel, ent, "sprites/explode02.spr");

        entity_set_origin(ent, Orig);



        //entity_set_float(ent,EV_FL_animtime,1.0);

      	//set_pev(ent,pev_animtime,10.0);

        //entity_set_float(ent,EV_FL_framerate,10.0);

       	set_pev(ent,pev_framerate,10.0);



        //Animate

        new maxframes = engfunc(EngFunc_ModelFrames,engfunc(EngFunc_ModelIndex,"sprites/explode02.spr"));

        new lasttime = global_get(glb_time);



        for(new Float:frame = 0.0; pev(ent,pev_frame) < maxframes; frame += pev(ent,pev_framerate) * (global_get(glb_time)- lasttime))

        {

                set_pev(ent, pev_frame, frame);

        }

        //EF_AnimationAutomove(ent, 1.0);

        //set_rendering(ent);

        //call_think(ent);

        //remove_entity(ent);
Thanks
 
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
dispatch spawn...
 
New Member
Joined
Jan 30, 2003
Messages
135
Best answers
0
I've seen dispatchkeyvalue and dispatchspawn but I don't really know what they do or how to use them.

The sprite is rendered/drawn to screen but stuck on first frame and fairly small. So will dispathspawn animate the sprite? And if so, where/when should I call the function?

Thanks
 
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
try this:
Code:
//Called whenever the PS hud appears
//Good for entering water by beam block or swoop

//Draw sprite here
new Entity = create_entity( "env_sprite" );

entity_set_string	( Entity, EV_SZ_classname, "SpriteEntity" );
entity_set_model	( Entity, "sprites/explode02.spr" );
entity_set_float	( Entity, EV_FL_scale, 1.0 );

//if u like:
/*
entity_set_int( Entity, EV_INT_renderfx, kRenderFxNone );
entity_set_int( Entity, EV_INT_rendermode, kRenderTransAdd );
entity_set_float( Entity, EV_FL_renderamt, 255.0 );
*/


// Spawn Sprite at Clients Origin Coords
new Float:CoreOrigin[ 3 ];
entity_get_vector( Client, EV_VEC_origin, CoreOrigin );
entity_set_origin( Entity, CoreOrigin );

//Framerate if u like...
entity_set_float( Entity, EV_FL_framerate, 10.0 );

DispatchSpawn( Entity );



//EF_AnimationAutomove(ent, 1.0);

//set_rendering(ent);

//call_think(ent);

//remove_entity(ent);
 
New Member
Joined
Jan 30, 2003
Messages
135
Best answers
0
Thx, I'll give it a try tonight for flexibility.

I did get the animation to work using set_task with a delay of 0.1 and changing pev_frame. The weird thing is I've tried changing it before in a for loop with no success. (fps must of been too high for me to notice a change in frame or there might not be an intermediate frame like 1.1 and instead it has to be a whole number/interger).

Thanks
 
New Member
✔️ HL Verified
Joined
Apr 23, 2005
Messages
416
Best answers
0
lol trying to reproduce flameeffect arent you
 
New Member
Joined
Jul 27, 2008
Messages
5
Best answers
0
I do not see anything wrong in your approach...let me check the source carefully and get back to you.
 

Users who are viewing this thread

Top Bottom