AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NPC animation (https://forums.alliedmods.net/showthread.php?t=76341)

Sam Tsuki 08-22-2008 17:38

NPC animation
 
I'm trying to make an NPC flinch if it detected a decrease in health
What happens is when I shoot it the animation stops
What could be wrong???

PHP Code:

#include <amxmodx>
#include <engine>

new Float:npc_health[3000]

public 
plugin_init()
{
    
register_clcmd("barney""barney")
    
register_think("npc_barney""npc_think"); 

public 
plugin_precache() 
{
    
precache_model("models/barney.mdl")
    
precache_model("models/p_gauss.mdl"

public 
barney(id
{
    new 
Float:origin[3]
    
entity_get_vector(id,EV_VEC_origin,origin)
    new 
ent create_entity("info_target")
    
entity_set_origin(ent,origin);
    
origin[2] += 100.0
    entity_set_origin
(id,origin)
    
entity_set_float(ent,EV_FL_takedamage,1.0)
    
entity_set_float(ent,EV_FL_health,100.0)
    
entity_set_string(ent,EV_SZ_classname,"npc_barney");
    
entity_set_model(ent,"models/barney.mdl");
    
entity_set_int(ent,EV_INT_solid2)
    
entity_set_byte(ent,EV_BYTE_controller1,125);
    
entity_set_byte(ent,EV_BYTE_controller2,125);
    
entity_set_byte(ent,EV_BYTE_controller3,125);
    
entity_set_byte(ent,EV_BYTE_controller4,125);
    new 
Float:maxs[3] = {16.0,16.0,72.0}
    new 
Float:mins[3] = {-16.0,-16.0,0.0}
    
entity_set_size(ent,mins,maxs)
    
entity_set_int(ent,EV_INT_sequence,0)
    
entity_set_int(ent,EV_INT_gaitsequence,0)
    
entity_set_float(ent,EV_FL_framerate,1.0)
    
entity_set_float(ent,EV_FL_nextthink,halflife_time() + 0.01)
    
drop_to_floor(ent)
    
npc_health[ent] = entity_get_float(entEV_FL_health)
    return 
1

public 
give_weapon(ent
{
    new 
entWeapon create_entity("info_target")
    
entity_set_string(entWeaponEV_SZ_classname"npc_weapon")
    
entity_set_int(entWeaponEV_INT_movetypeMOVETYPE_FOLLOW)
    
entity_set_int(entWeaponEV_INT_solidSOLID_NOT)
    
entity_set_edict(entWeaponEV_ENT_aimentent)
    
entity_set_model(entWeapon"models/p_gauss.mdl"

public 
npc_think(id
{
    
// Put your think stuff here.
    
if(entity_get_float(idEV_FL_health) < npc_health[id]) {
        
npc_health[id] = entity_get_float(idEV_FL_health)
        new 
flinch random_num(1317)
        
entity_set_int(id,EV_INT_sequence,flinch)
        
entity_set_int(id,EV_INT_gaitsequence,flinch)
        
entity_set_float(id,EV_FL_framerate,1.0)
    }
    
entity_set_float(id,EV_FL_nextthink,halflife_time() + 0.01



Vet 08-23-2008 01:39

Re: NPC animation
 
You may have to track and set EV_FL_frame to the desired animation frame. I'm not familiar with the engine module method, but I had to do it that way in FakeMeta once I changed the model's sequence.

Sam Tsuki 08-23-2008 01:57

Re: NPC animation
 
Quote:

Originally Posted by Vet (Post 674089)
You may have to track and set EV_FL_frame to the desired animation frame. I'm not familiar with the engine module method, but I had to do it that way in FakeMeta once I changed the model's sequence.

K I'll try that out


All times are GMT -4. The time now is 03:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.