|
Senior Member
Join Date: Oct 2009
Location: Budapest, Hungary
|

10-21-2010
, 00:06
Model animating confusion
|
#1
|
Hi there!
I often find myself in the following situation while writing a plugin:
I load a model and place it in the map, then I need to set it's animation phases, so that the movement is smooth.
Try the code below:
PHP Code:
#define light_hiding_time 5.0 new const Float:light_collision_radius = 15.0;
#define TASK_LIGHT 750
//models of the light new const light_models[][] = { "models/light.mdl","models/lightt.mdl" } new const alien_gibs[] = "models/agibs.mdl"
#include <amxmodx> #include <fakemeta> #include <engine> #include <hamsandwich>
public plugin_init(){ register_plugin("Creatures","1.0","Lulu the hero"); register_clcmd("say light","test"); //precache the... new modelnum; //light models for(modelnum=0;modelnum<sizeof light_models;modelnum++) engfunc(EngFunc_PrecacheModel,light_models[modelnum]); engfunc(EngFunc_PrecacheModel,alien_gibs); RegisterHam(Ham_Touch,"info_target","touched_light"); }
public plugin_precache(){ precache_model( "models/fleshgibs.mdl" );
precache_sound( "debris/bustflesh1.wav" ); precache_sound( "debris/bustflesh2.wav" );
precache_sound( "debris/flesh1.wav" ); precache_sound( "debris/flesh2.wav" ); precache_sound( "debris/flesh3.wav" ); precache_sound( "debris/flesh5.wav" ); precache_sound( "debris/flesh6.wav" ); precache_sound( "debris/flesh7.wav" ); }
public test(id){ new team = get_user_team(id); if(is_user_alive(id)&&is_user_connected(id)&&((team==1)||(team==2))){ new origin[3],Float:f_origin[3]; new tempid,Float:size1[3],Float:size2[3]; get_user_origin(id,origin,3); f_origin[0] = float(origin[0]); f_origin[1] = float(origin[1]); f_origin[2] = float(origin[2]); tempid = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target")); if(pev_valid(tempid)){ set_pev(tempid,pev_classname,"creature_light"); engfunc(EngFunc_SetModel,tempid,light_models[0]); size1[0] = 0.0-light_collision_radius; size1[1] = 0.0-light_collision_radius; size1[2] = 0.0; size2[0] = light_collision_radius; size2[1] = light_collision_radius; size2[2] = light_collision_radius; set_pev(tempid,pev_solid,SOLID_BBOX); engfunc(EngFunc_SetSize,tempid,size1,size2); set_pev(tempid,pev_movetype,MOVETYPE_NONE); set_pev(tempid,pev_sequence,0); set_pev(tempid,pev_gaitsequence,0); set_pev(tempid,pev_frame,0); set_pev(tempid,pev_framerate,1.0); set_pev(tempid,pev_euser1,3); //lighting(f_origin,200,200,100,1); //DispatchKeyValue(tempid,"material","3"); //DispatchKeyValue(tempid,"health","100"); //set_pev(tempid,pev_health,100.0); engfunc(EngFunc_SetOrigin,tempid,f_origin); DispatchSpawn(tempid); } } return PLUGIN_HANDLED; }
public touched_light(ent,other){ new classname[32]; pev(ent,pev_classname,classname,31); if(!equal(classname,"creature_light")) return HAM_IGNORED;
new team = get_user_team(other); if(is_user_alive(other)&&is_user_connected(other)&&((team==1)||(team==2))){ new st = pev(ent,pev_euser1); new params[1]; params[0] = ent; if(st>=2){ withdraw_light(params); }else if(st==0){ remove_task(TASK_LIGHT+ent); set_task(light_hiding_time,"deploy_light",TASK_LIGHT+ent,params,1); } } return HAM_HANDLED; }
public withdraw_light(params[]){ new ent = params[0]; set_pev(ent,pev_euser1,1); set_pev(ent,pev_sequence,1); set_pev(ent,pev_frame,0); set_pev(ent,pev_framerate,1.0); set_pev(ent,pev_gaitsequence,1); set_pev(ent,pev_animtime,0.3); remove_task(TASK_LIGHT+ent); set_task(0.3,"hidden_light",TASK_LIGHT+ent,params,1); }
public deploy_light(params[]){ new ent = params[0]; set_pev(ent,pev_euser1,2); set_pev(ent,pev_sequence,2); set_pev(ent,pev_frame,0); set_pev(ent,pev_framerate,1.0); set_pev(ent,pev_gaitsequence,2); set_pev(ent,pev_animtime,1.3); remove_task(TASK_LIGHT+ent); set_task(1.3,"normal_light",TASK_LIGHT+ent,params,1); }
public normal_light(params[]){ new ent = params[0]; set_pev(ent,pev_euser1,3); set_pev(ent,pev_sequence,0); set_pev(ent,pev_frame,0); set_pev(ent,pev_framerate,1.0); set_pev(ent,pev_gaitsequence,0); }
public hidden_light(params[]){ new ent = params[0]; set_pev(ent,pev_euser1,0); set_pev(ent,pev_sequence,3); set_pev(ent,pev_frame,0); set_pev(ent,pev_framerate,1.0); set_pev(ent,pev_gaitsequence,3); remove_task(TASK_LIGHT+ent); set_task(light_hiding_time,"deploy_light",TASK_LIGHT+ent,params,1); }
Then when I load the game and actually put a "light" creature in the game, there are animation problems. To be honest, I really don't know what gaitsequence is, or are the other animation settings work properly, so I would need a small tutorial or alike on how to play an animation for a model.
Eg. rewind animation to the beginning frame, loop animation, play it only once, or generally how does this work in HL?
Or more simply, why are the animation troubles on withdraw and deploy states?
Thank you very much for all the ideas, helps in advance, I would really like to know what do I need to take care of while animating, because I would need these much.
|
|