Raised This Month: $32 Target: $400
 8% 

[SOLVED] ACT_RANGE_ATTACK1 Activity - Playing Animation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fearAR
Veteran Member
Join Date: Oct 2010
Old 01-14-2013 , 17:25   [SOLVED] ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #1

Hi, I've a problem with a plugin. I'm making a new knife, for that reason I block the primary and secondary attack by setting m_flNextPrimaryAttack and others, to get_gametime() + 999.0, so the player can't attack, and then I hook cmdstart for improve the next attack when IN_ATTACK button is pressed.

All things are ok, the attack, the tracelines, the takedamage, but now, I am trying to play player animation because the player stays like he isn't attacking.

I tried with this code, in the code when user pressed IN_ATTACK button:

Like Arkshine said:
PHP Code:
const ACT_RANGE_ATTACK1 28;
const 
m_Activity 73;

set_pdata_intidm_ActivityACT_RANGE_ATTACK1 );
set_pevidpev_sequenceYOUR_SEQUENCE )
set_pevidpev_animtimeget_gametime() );
set_pevidpev_frame);
set_pevidpev_framerate1.0 ); 
But, when I walk, the animation doesn't play, I think it is because the WALK activity replace this activity in the next frame.

I thought implementing Orpheu ( CBasePlayer::SetAnimation() ), I tried but I can't achieve this. Maybe anyone can help me?

Greetings.
__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]

Last edited by fearAR; 01-14-2013 at 17:26.
fearAR is offline
Send a message via MSN to fearAR
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-14-2013 , 17:34   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #2

SetAnimation is called all the time. Most of time ACT_WALK, but next animation should not be overwritten if m_Activity is set on ACT_RANGE_ATTACK1.
Technically the code should work. Maybe you will need to set m_fSequenceFinished to 0, because animation is overwritten if either not set on ACT_RANGE_ATTACK1 or either m_fSequenceFinished is on 1. It might be handled differently in CS, I've don't have fully decompiled the code yet.

Though, It would be really easier, faster and reliable to call SetAnimation(). It think it has already been posted somewhere.
__________________

Last edited by Arkshine; 01-14-2013 at 17:53.
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 01-14-2013 , 17:37   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #3

Quote:
Originally Posted by hornet View Post
Could look into Arkshine's prone plugin:

http://forums.alliedmods.net/showpos...6&postcount=27
__________________

Last edited by Bos93; 01-14-2013 at 17:38.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
fearAR
Veteran Member
Join Date: Oct 2010
Old 01-14-2013 , 17:41   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #4

I saw that, but It blocks all sequences when the player is in prone position, I want to play the ref_shoot_knife or crouch_shoot_knife while it is walking, crouching, or whatever he is doing, without blocking these sequences, for that reason I couldn't achieve this.
__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]

Last edited by fearAR; 01-14-2013 at 17:42.
fearAR is offline
Send a message via MSN to fearAR
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-14-2013 , 18:07   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #5

You should have just to call SetAnimation() when you want, and make sure m_szAnimationExt is set to "knife".
__________________

Last edited by Arkshine; 01-14-2013 at 18:08.
Arkshine is offline
fearAR
Veteran Member
Join Date: Oct 2010
Old 01-14-2013 , 18:21   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #6

So, If i do this:

PHP Code:
const m_szAnimExtention 1968;

new 
OrpheuFunction:SetAnimationHook;

// plugin_init
SetAnimationHook OrpheuGetFunction"SetAnimation""CBasePlayer" );
// end plugin_init

// FM_CmdStart Hook

// Player pressed IN_ATTACK button ->
set_pdata_stringidm_szAnimExtention"knife"120 );
OrpheuCallSetAnimationHookidPLAYER_ATTACK1 );

// End 
Is it correct?

Edit: It worked! Thank you.

Is it possible to play other animation ( not CS default animations ), like to do emotes for CS, and block attack, reload animations but not crouch, and walk, or swim, and at the same time play the new animation attached to the model file?
__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]

Last edited by fearAR; 01-14-2013 at 18:50.
fearAR is offline
Send a message via MSN to fearAR
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-14-2013 , 18:34   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #7

m_szAnimExtention is used inside SetAnimation to format string like ref_shoot_knife, so it doesn't make to set it after.
set_pdata_string is char based, meaning the offset should be the full 1968 (492*4).
__________________
Arkshine is offline
fearAR
Veteran Member
Join Date: Oct 2010
Old 01-14-2013 , 18:49   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #8

Ok, I fixed these errores. Now I have a doubt, I was thinking on set player animation to a new sequence, like he is in defensive position, with knife pointing to his side, and to do that, I need to set this sequence and at the same time, don't block the walk, crouch, etc sequences, or that these animations doesn't replace the new sequence, therefore..., that the walk, crouch, swimming animations, would be mixed with the new sequence ( defensive position ).
__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]
fearAR is offline
Send a message via MSN to fearAR
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 01-14-2013 , 20:00   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #9

Quote:
Originally Posted by fearAR View Post
So, If i do this:

PHP Code:
const m_szAnimExtention 1968;

new 
OrpheuFunction:SetAnimationHook;

// plugin_init
SetAnimationHook OrpheuGetFunction"SetAnimation""CBasePlayer" );
// end plugin_init

// FM_CmdStart Hook

// Player pressed IN_ATTACK button ->
set_pdata_stringidm_szAnimExtention"knife"120 );
OrpheuCallSetAnimationHookidPLAYER_ATTACK1 );

// End 
Is it correct?

Edit: It worked! Thank you.

Is it possible to play other animation ( not CS default animations ), like to do emotes for CS, and block attack, reload animations but not crouch, and walk, or swim, and at the same time play the new animation attached to the model file?
The m_szAnimExtention offset is updated on DefaultDeploy which is called by Deploy, that means that on every weapon deploy the value is updated so you don't need to overwrite it on every fire event
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
fearAR
Veteran Member
Join Date: Oct 2010
Old 01-14-2013 , 20:05   Re: ACT_RANGE_ATTACK1 Activity - Playing Animation
Reply With Quote #10

Thanks meTaLiCroSS.

Any solution for my doubt?
__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]
fearAR is offline
Send a message via MSN to fearAR
Reply


Thread Tools
Display Modes

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:22.


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