Raised This Month: $51 Target: $400
 12% 

NPC pain animation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 12-15-2010 , 09:51   NPC pain animation
Reply With Quote #1

Having a bit of a problem with having my NPC play any animation when it gets damage. It does emit the sound file (and makes the mouth move interestingly).

How can I play an animation then continue to do whatever animation it was doing before it got damaged?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <engine>
#include <hamsandwich>

new const g_NpcClassName[] = "npc_barney";
new const 
g_NpcModel[] = "models/barney.mdl";
new const 
g_NpcSoundPain[] = "barney/ba_pain3.wav";

public 
plugin_init()
{
    
register_plugin("NPC Plugin""1.0""Mazza");
    
register_clcmd("say /npc""clcmd_npc");
    
register_cvar("test""4");
    
}

public 
plugin_precache()
{
    
precache_model(g_NpcModel)
    
precache_sound(g_NpcSoundPain)
}

public 
clcmd_npc(id)
{
    new 
ent create_entity("info_target");
    
    
entity_set_string(entEV_SZ_classnameg_NpcClassName);
    
    new 
Floatorigin[3], Floatangle[3];
    
entity_get_vector(idEV_VEC_originorigin);
    
entity_set_origin(entorigin);
    
origin[2] += 80.0;
    
entity_set_origin(idorigin);

    
entity_get_vector(idEV_VEC_anglesangle);
    
angle[0] = 0.0;
    
entity_set_vector(entEV_VEC_anglesangle);

    
set_pev(entpev_takedamage1.0);
    
set_pev(entpev_health1000.0);

    
entity_set_model(entg_NpcModel);
    
entity_set_int(entEV_INT_movetypeMOVETYPE_PUSHSTEP);
    
entity_set_int(entEV_INT_solidSOLID_BBOX);
    
    new 
Floatmins[3] = { -16.0, -16.00.0 };
    new 
Floatmaxs[3] = { 16.016.054.0    }
    
entity_set_size(entminsmaxs);
    
    
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);

    
entity_set_float(ent,EV_FL_animtime,2.0)
    
entity_set_float(ent,EV_FL_framerate1.0)
    
entity_set_int(ent,EV_INT_sequence4);
    
    
drop_to_floor(ent);
    
    
RegisterHamFromEntity(Ham_TakeDamageent"npc_TakeDamage"1);

    
entity_set_float(entEV_FL_nextthinkget_gametime() + 0.01)
}

public 
npc_TakeDamage(entinflictorattackerFloat:damagebits)
{
    
entity_set_float(ent,EV_FL_animtime,2.0)
    
entity_set_float(ent,EV_FL_framerate1.0)
    
entity_set_int(entEV_INT_sequence17 );

    
emit_sound(entCHAN_VOICEg_NpcSoundPain,  VOL_NORMATTN_NORM0PITCH_NORM)


__________________
It's a mystery.
Mini_Midget is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 12-15-2010 , 11:41   Re: NPC pain animation
Reply With Quote #2

Maybe emit_sound(ent, CHAN_VOICE, g_NpcSoundPain, 1.0, ATTN_NORM, 0, PITCH_NORM)
VOL_NORM to 1.0
emit_sound(id,CHAN_STATIC,"weapons/xbow_hit2.wav",1.0,ATTN_NORM,0,PITCH_NORM)
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 12-15-2010 , 12:03   Re: NPC pain animation
Reply With Quote #3

VOL_NORM = 1.0 lol wtf did you say.

Also, he asked for how to play an animation, not about the sound lol.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 12-15-2010 , 21:36   Re: NPC pain animation
Reply With Quote #4

Quote:
Originally Posted by xakintosh View Post
Maybe emit_sound(ent, CHAN_VOICE, g_NpcSoundPain, 1.0, ATTN_NORM, 0, PITCH_NORM)
VOL_NORM to 1.0
emit_sound(id,CHAN_STATIC,"weapons/xbow_hit2.wav",1.0,ATTN_NORM,0,PITCH_NORM)
... Did you even read my question or the title of this thread?

I'm asking how can I play any animation when my NPC gets damaged then have it play the same animation it was doing before it was hurt.
__________________
It's a mystery.
Mini_Midget is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 12-16-2010 , 03:20   Re: NPC pain animation
Reply With Quote #5

i think it could be done like this , when entity takes damage , play your animation ... you know : entity_set_float(ent,EV_FL_animtime,2.0)
entity_set_float(ent,EV_FL_framerate,1.0)
entity_set_int(ent,EV_INT_sequence,3);

then put a set_task after it and in that make it play your previous animation ...
it sounds like a stupid crazy idea -.-
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 12-16-2010 , 03:24   Re: NPC pain animation
Reply With Quote #6

The problem is that it wouldn't play the animation when it gets damaged at all.
__________________
It's a mystery.
Mini_Midget is offline
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 12-16-2010 , 04:14   Re: NPC pain animation
Reply With Quote #7

I had the same problem
Try that:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <engine>
#include <hamsandwich>

new const g_NpcClassName[] = "npc_barney";
new const 
g_NpcModel[] = "models/barney.mdl";
new const 
g_NpcSoundPain[] = "barney/ba_pain3.wav";

public 
plugin_init()
    {
    
register_plugin("NPC Plugin""1.0""Mazza");
    
register_clcmd("say /npc""clcmd_npc");
    
register_cvar("test""4");
    
}

public 
plugin_precache()
    {
    
precache_model(g_NpcModel)
    
precache_sound(g_NpcSoundPain)
}

public 
clcmd_npc(id)
{
    new 
Float:CurrentTime get_gametime ()
    
    new 
ent create_entity("info_target");
    
    
entity_set_string(entEV_SZ_classnameg_NpcClassName);
    
    new 
Floatorigin[3], Floatangle[3];
    
entity_get_vector(idEV_VEC_originorigin);
    
entity_set_origin(entorigin);
    
origin[2] += 80.0;
    
entity_set_origin(idorigin);
    
    
entity_get_vector(idEV_VEC_anglesangle);
    
angle[0] = 0.0;
    
entity_set_vector(entEV_VEC_anglesangle);
    
    
set_pev(entpev_takedamage1.0);
    
set_pev(entpev_health1000.0);
    
    
entity_set_model(entg_NpcModel);
    
entity_set_int(entEV_INT_movetypeMOVETYPE_PUSHSTEP);
    
entity_set_int(entEV_INT_solidSOLID_BBOX);
    
    new 
Floatmins[3] = { -16.0, -16.00.0 };
    new 
Floatmaxs[3] = { 16.016.054.0    }
    
entity_set_size(entminsmaxs);
    
    
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);
    
    
set_pev(entpev_animtimeCurrentTime);
    
set_pev(entpev_frame0);
    
set_pev(entpev_framerate1.0);
    
set_pev(entpev_sequence4);
    
    
drop_to_floor(ent);
    
    
RegisterHamFromEntity(Ham_TakeDamageent"npc_TakeDamage"1);
    
    
entity_set_float(entEV_FL_nextthinkget_gametime() + 0.01)
}

public 
npc_TakeDamage(entinflictorattackerFloat:damagebits)
{
    new 
Float:CurrentTime get_gametime ();
    
    
set_pev(entpev_animtimeCurrentTime);
    
set_pev(entpev_frame0);
    
set_pev(entpev_framerate1.0);
    
set_pev(entpev_sequence17);
    
    
emit_sound(entCHAN_VOICEg_NpcSoundPain,  VOL_NORMATTN_NORM0PITCH_NORM)
    

__________________
PsYChOPaTiQuE is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 12-16-2010 , 04:52   Re: NPC pain animation
Reply With Quote #8

Exactly what I was trying to do!
Thanks PsYChOPaTiQuE!

Is there any way to catch the duration of the animation so I can perfectly play the next animation?

I want to avoid the use of set_task and possibly have it think next on the length of the duration.
__________________
It's a mystery.
Mini_Midget is offline
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 12-16-2010 , 11:11   Re: NPC pain animation
Reply With Quote #9

I think it's the only way.
__________________
PsYChOPaTiQuE is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:41.


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