Raised This Month: $ Target: $400
 0% 

Player Animations


Post New Thread Reply   
 
Thread Tools Display Modes
sgtbane
Member
Join Date: Feb 2006
Old 05-25-2010 , 00:27   Re: Player Animations
Reply With Quote #61

I connected to the Insane server just before posting that and tried it out and it worked properly.

edit - Just realized I had it set to admin only :S. should work now. Sorry for saying you had mental issues o.0

and Direktor, it does have bugs, as to why I haven't released it as a working plugin, however not Unpossible...
__________________
[Add|Community]

~SgtBane
sgtbane is offline
Send a message via MSN to sgtbane
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-25-2010 , 07:52   Re: Player Animations
Reply With Quote #62

Still you can post there the current work to see how you do, I'm sure people would like to know your method even if not perfect.
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-01-2010 , 09:16   Re: Player Animations
Reply With Quote #63

Code:
#include < amxmodx > #include < engine > #include < fakemeta > public plugin_init( ) {     register_clcmd( "say /a", "Cmd" ); } public plugin_precache( ) {     precache_model( "models/Anim/playeranimha.mdl" );     precache_model( "models/player/gign/gign.mdl" ); } public Cmd( const id ) {     new Float:vOrigin[ 3 ];     pev( id, pev_origin, vOrigin );         new iEntity = create_entity( "info_target" );     entity_set_model( iEntity, "models/Anim/playeranimha.mdl" );     entity_set_origin( iEntity, vOrigin );         new iEntity2 = create_entity( "info_target" );     entity_set_model( iEntity2, "models/player/gign/gign.mdl" );     entity_set_origin( iEntity2, vOrigin );     set_pev( iEntity2, pev_movetype, MOVETYPE_FOLLOW );     set_pev( iEntity2, pev_aiment, iEntity );         set_pev( iEntity, pev_sequence, 1 );         set_controller( iEntity, 0, 0.5 );     set_controller( iEntity, 1, 0.5 ); }
There it is. I was lazy to make controllers copy player movements
The way it works is interesting, it creates 2 entities, 1 is normal player model attached to 2nd entity wich is set to his anim model and with sequence of it. The anim model has the sequences he wants to play.
__________________
xPaw is offline
Nathan2
BANNED
Join Date: Apr 2010
Old 07-07-2010 , 10:14   Re: Player Animations
Reply With Quote #64

its done?
Nathan2 is offline
Brreaker
Senior Member
Join Date: Oct 2009
Location: Constanta, Romania
Old 07-07-2010 , 12:22   Re: Player Animations
Reply With Quote #65

Quote:
Originally Posted by xPaw View Post
Code:
#include < amxmodx > #include < engine > #include < fakemeta > public plugin_init( ) {     register_clcmd( "say /a", "Cmd" ); } public plugin_precache( ) {     precache_model( "models/Anim/playeranimha.mdl" );     precache_model( "models/player/gign/gign.mdl" ); } public Cmd( const id ) {     new Float:vOrigin[ 3 ];     pev( id, pev_origin, vOrigin );         new iEntity = create_entity( "info_target" );     entity_set_model( iEntity, "models/Anim/playeranimha.mdl" );     entity_set_origin( iEntity, vOrigin );         new iEntity2 = create_entity( "info_target" );     entity_set_model( iEntity2, "models/player/gign/gign.mdl" );     entity_set_origin( iEntity2, vOrigin );     set_pev( iEntity2, pev_movetype, MOVETYPE_FOLLOW );     set_pev( iEntity2, pev_aiment, iEntity );         set_pev( iEntity, pev_sequence, 1 );         set_controller( iEntity, 0, 0.5 );     set_controller( iEntity, 1, 0.5 ); }
There it is. I was lazy to make controllers copy player movements
The way it works is interesting, it creates 2 entities, 1 is normal player model attached to 2nd entity wich is set to his anim model and with sequence of it. The anim model has the sequences he wants to play.
So for every animation you must create a .mdl file containing the proper sequences?
__________________
There are 10 kinds of people.Those who understand binary, and those who don't.
Also, for those who understand binary, there is a donation tab too!
No steam || PM support!
Brreaker is offline
Send a message via MSN to Brreaker Send a message via Yahoo to Brreaker
DaxProxy
Senior Member
Join Date: Sep 2007
Old 07-07-2010 , 16:58   Re: Player Animations
Reply With Quote #66

I guess there is no other possible way to make such moves.
You must animate models manually before adding them to the game.
DaxProxy is offline
m*stylez
BANNED
Join Date: May 2010
Old 07-07-2010 , 23:22   Re: Player Animations
Reply With Quote #67

nice
m*stylez is offline
snowyledge
BANNED
Join Date: Dec 2009
Old 07-08-2010 , 15:57   Re: Player Animations
Reply With Quote #68

Amazing.
snowyledge is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 09-04-2010 , 07:33   Re: Player Animations
Reply With Quote #69

Can you upload some .mdl file to that script @xPaw
EDIT: Can anyone show some tutorials to get start with animations

Last edited by xakintosh; 09-04-2010 at 07:42.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
sgtbane
Member
Join Date: Feb 2006
Old 09-12-2010 , 22:06   Re: Player Animations
Reply With Quote #70

Plugin Source / .sma
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>

#define PLUG_NAME     "PlrAnims"
#define PLUG_AUTH     "SgtBane"
#define PLUG_VERS     "0.5"
#define PLUG_TAG     "PlrAnims"

#define offset_nextanim        1000
#define menusize     220

#define PLUG_ACCESS        ADMIN_CHAT

//stock fm_set_entity_visibility(index, invisible = 0) set_pev(index, pev_effects, invisible == 0 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)

new AnimFile[41]
new 
AnimConfig[64]

new 
g_Animed[33]
new 
g_Avatar[33]
new 
g_Anim[33]


new 
p_MoveHeadp_LockRotp_adminonly

#define anim_None    -1

#define MaxAnims    32
new AnimCnt
new saycmds[MaxAnims][31]
new 
saysentence[MaxAnims][31]
new 
Float:playlength[MaxAnims]
new 
Float:playframerate[MaxAnims]
new 
nextsequencenumb[MaxAnims]

public 
plugin_init() {
    
register_plugin(PLUG_NAME,    PLUG_VERS,    PLUG_AUTH)
    
RegisterHam(Ham_Spawn,        "player",    "fwd_playerspawn"1)
    
RegisterHam(Ham_TakeDamage"player",     "fwd_TakeDamage")
    
register_forward(FM_CmdStart,            "fwd_cmdstart")
    
register_event("CurWeapon",                "fwd_curweapon",         "be""1=1")
    
register_clcmd("say",                     "hook_say")
    
register_concmd("amx_anim_reloadini",    "func_reloadini",        ADMIN_RCON,    "ReLoads the .ini file")
    
    
p_MoveHead        =        register_cvar("amx_anim_movehead",        "1")
    
p_LockRot        =        register_cvar("amx_anim_lockrot",        "1")
    
p_adminonly        =        register_cvar("amx_anim_admin",            "1")
}
public 
func_reloadini(id,level,cid) { 
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    command_load
()
    return 
PLUGIN_HANDLED
}
public 
hook_say(id) {
    new 
said[21], match[22]
    
read_args(said20)
    
remove_quotes(said)
    if (
get_pcvar_num(p_adminonly) == && !(get_user_flags(id) & PLUG_ACCESS)) return PLUGIN_CONTINUE
    
if (!is_user_alive(id)) return PLUGIN_CONTINUE
    
for (new i=0i<AnimCnti++) {
        
format(match21"/%s"saycmds[i])
        if (
equali(saidmatch)) {
            
g_Animed[id] = i
            ToggleAnim
(idtrue)
            
//client_print(id, print_center, "You are now %s", saysentence[i])
            
return PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
fwd_curweapon(id) {
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if (g_Animed[id] == anim_None) return PLUGIN_CONTINUE
    
if (read_data(2) != CSW_KNIFE) {
    
//If they try to change to a weapon other than the knife, stop the animation.
        
g_Animed[id] = anim_None
        ToggleAnim
(idfalse)
    }
    return 
PLUGIN_CONTINUE
}
public 
fwd_TakeDamage(VictimUselessAttackerFloat:damagedamagebits) {
    if (!
is_user_connected(Victim)) return HAM_IGNORED
    
if (g_Animed[Victim] == anim_None) return FMRES_IGNORED
    
//If they are currently using an animation and get hurt, stop the animation.
    
g_Animed[Victim] = anim_None
    ToggleAnim
(Victimfalse)
    return 
FMRES_IGNORED
}
public 
fwd_cmdstart(id, const uc_handlerandom_seed) {
    if (!
is_user_alive(id)) return FMRES_IGNORED
    
if (g_Animed[id] == anim_None) return FMRES_IGNORED
    
static buttons
    buttons 
get_uc(uc_handleUC_Buttons)

    if (
buttons IN_FORWARD ||
        
buttons IN_MOVELEFT ||
        
buttons IN_MOVERIGHT ||
        
buttons IN_BACK ||
        
buttons IN_ATTACK ||
        
buttons IN_ATTACK2 ||
        
buttons IN_DUCK ||
        
buttons IN_JUMP ||
        
buttons IN_USE) {
        
g_Animed[id] = anim_None
        ToggleAnim
(idfalse)
        return 
FMRES_IGNORED
    
}
    
    new 
Float:fTest
    get_uc
(uc_handleUC_SideMovefTest)
    if (
fTest != 0.0) {
        
g_Animed[id] = anim_None
        ToggleAnim
(idfalse)
        return 
FMRES_IGNORED
    
}
    
get_uc(uc_handleUC_ForwardMovefTest)
    if (
fTest != 0.0) {
        
g_Animed[id] = anim_None
        ToggleAnim
(idfalse)
        return 
FMRES_IGNORED
    
}
    
get_uc(uc_handleUC_UpMovefTest)
    if (
fTest != 0.0) {
        
g_Animed[id] = anim_None
        ToggleAnim
(idfalse)
        return 
FMRES_IGNORED
    
}
    
    if (
get_pcvar_num(p_MoveHead) != 0) {
        static 
Float:fAngA[3], Float:fAngB[3]
        
pev(g_Anim[id], pev_anglesfAngA)
        
pev(idpev_v_anglefAngB)
        
        
fAngA[0] = (fAngB[0] - fAngA[0])
        
fAngA[0] + ((fAngA[0]) / 90.0 255.0)
        
fAngA[0] += 90.0
        
        fAngA
[1] = (fAngB[1] - fAngA[1]) + 180
        
if(fAngA[1]>=360.0fAngA[1] -= 360.0
        
if(fAngA[1]<0.0fAngA[1] += 360.0

        fAngA
[1] = ((fAngA[1]) / 360.0 255.0)
        if (
get_pcvar_num(p_LockRot) != 0) {
            if (
fAngA[1] > 191.25 && fAngA[1] < 255.0fAngA[1] = 191.25
            
if (fAngA[1] < 63.75 && fAngA[1] >= 0fAngA[1] = 63.75
        
}
        
//client_print(id, print_center, "Pitch:%i Yaw:%i", floatround(fAngA[0]), floatround(fAngA[1]))
        
set_pev(g_Anim[id], pev_controller_1floatround(fAngA[0]))
        
set_pev(g_Anim[id], pev_controller_0floatround(fAngA[1]))
    }
    return 
FMRES_IGNORED
}

public 
fwd_playerspawn(id) {
    if (!
is_user_alive(id)) return
    if (
get_user_team(id) != && get_user_team(id) != 2) return
    if (!
pev_valid(g_Avatar[id])) {
        
g_Avatar[id] = fm_find_ent_by_owner(0"Anim_Avatar"id)
        if (
pev_valid(g_Avatar[id])) {
            
server_print("[%s]Recycling Avatar:%i for %i"PLUG_TAGg_Avatar[id], id)
        } else {
            
g_Avatar[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
            
server_print("[%s]Created Avatar:%i for %i"PLUG_TAGg_Avatar[id], id)
        }
        if (
pev_valid(g_Avatar[id])) {
            
set_pev(g_Avatar[id],    pev_classname,        "Anim_Avatar")
            
set_pev(g_Avatar[id],        pev_owner,            id)
            
set_pev(g_Avatar[id],    pev_movetype,        MOVETYPE_FOLLOW)
            
set_pev(g_Avatar[id],     pev_solid,            0)
            
MakeInvisible(g_Avatar[id], 1)
        }
    }
    if (!
pev_valid(g_Anim[id])) {
        
g_Anim[id] = fm_find_ent_by_owner(0"Anim_Struct"id)
        if (
pev_valid(g_Anim[id])) {
            
server_print("[%s]Recycling Anim Structure:%i for %i"PLUG_TAGg_Anim[id], id)
        } else {
            
g_Anim[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
            
server_print("[%s]Created Anim Structure:%i for %i"PLUG_TAGg_Anim[id], id)
        }
        if (
pev_valid(g_Anim[id])) {
            
set_pev(g_Anim[id],        pev_classname,        "Anim_Struct")
            
set_pev(g_Anim[id],        pev_owner,            id)
            
set_pev(g_Anim[id],     pev_movetype,        MOVETYPE_TOSS)

            
engfunc(EngFunc_SetModel,    g_Anim[id],        AnimFile)
            
engfunc(EngFunc_SetSizeg_Anim[id], {-16.0, -16.00.0}, {16.016.072.0})
            
set_pev(g_Anim[id],     pev_solid,            SOLID_BBOX)
            
MakeInvisible(g_Anim[id], 1)
        }
    }
    
    if (
pev_valid(g_Avatar[id]) && is_user_alive(id)) {
        if (
task_exists(id)) remove_task(id)
        
set_task(1.0"delayedmdlset"id)
    }
    
    
g_Animed[id] = anim_None
    ToggleAnim
(idfalse)
}
public 
delayedmdlset(id) {        // Delaying because custom models don't get set till shortly after spawn.
    
if (!is_user_alive(id)) return
    if (!
pev_valid(g_Avatar[id])) return
    new 
modelname[41]
    
cs_get_user_model (idmodelname40)
    
format(modelname40"models/player/%s/%s.mdl"modelnamemodelname)
    
engfunc(EngFunc_SetModel,    g_Avatar[id],    modelname)
    return
}
public 
plugin_precache() {
    new 
cfgDir[32]
    
get_configsdir(cfgDir,31)
    
formatex(AnimConfig,63,"%s/AnimConfig.ini",cfgDir)
    
command_load()
    
precache_model(AnimFile)
}
public 
ToggleAnim(idbool:TogAnim) {
    if (
pev_valid(g_Avatar[id]) && pev_valid(g_Anim[id])) {
        if (
TogAnim && is_user_alive(id)) {
            
MakeInvisible(g_Anim[id], 0)
            
MakeInvisible(g_Avatar[id], 0)
            
MakeInvisible(id1)
            
            new 
Float:fOrigin[3], Float:fAngles[3], Float:fVelocity[3]
            
pev(idpev_origin,     fOrigin)
            
fOrigin[2] -= 36.0
            set_pev
(g_Anim[id],     pev_origin,            fOrigin)
            
pev(idpev_angles,        fAngles)
            
fAngles[0] = 0.0
            fAngles
[2] = 0.0
            set_pev
(g_Anim[id],        pev_angles,            fAngles)
            
pev(idpev_velocityfVelocity)
            
set_pev(g_Anim[id],        pev_velocity,        fVelocity)
            
            
//falltofloor(g_Anim[id])
            
set_pev(g_Avatar[id],    pev_aiment,            g_Anim[id])
            
set_pev(g_Anim[id],        pev_framerate,        playframerate[g_Animed[id]])
            
set_pev(g_Anim[id],        pev_sequence,        g_Animed[id])
            
set_pev(g_Anim[id],        pev_frame,            0)
            
set_pev(g_Anim[id],        pev_animtime,        get_gametime())
            
engclient_cmd(id"weapon_knife"
            
            if (
nextsequencenumb[g_Animed[id]] > anim_None && playlength[g_Animed[id]] > anim_None) {
                if (
task_exists(offset_nextanim id)) remove_task(offset_nextanim id)
                
set_task(playlength[g_Animed[id]], "task_nextanim"offset_nextanim id)
            }
            
            
//client_print(id, print_chat, "%i %s %s %i %i", g_Animed[id], saycmds[g_Animed[id]], saysentence[g_Animed[id]], floatround(playlength[g_Animed[id]]), str_to_num(nextsequencenumb[g_Animed[id]]))
        
} else {
            
MakeInvisible(g_Anim[id], 1)
            
MakeInvisible(g_Avatar[id], 1)
            
MakeInvisible(id0)
            
            
set_pev(g_Avatar[id],    pev_aiment,            id)
            
set_pev(g_Anim[id],        pev_sequence,        0)
            if (
task_exists(offset_nextanim id)) remove_task(offset_nextanim id)
        }
    } else {
        new 
name[32]
        
get_user_name(idname31)
        
server_print("[%s]Error: %i%s Tried to run an animation with Avatar:%s Anim:%s"PLUG_TAGidnamepev_valid(g_Avatar[id])?"Valid":"Invalid"pev_valid(g_Anim[id])?"Valid":"Invalid")
    }
}
public 
task_nextanim(id) {
    
id -= offset_nextanim
    g_Animed
[id] = nextsequencenumb[g_Animed[id]]
    if (
g_Animed[id] >= 0) {
        
ToggleAnim(idtrue)
    }
}

//24.200.185.50:27015
stock MakeInvisible(idinvisible 1) {
    
set_pev(idpev_effectsinvisible == pev(idpev_effects) & ~EF_NODRAW pev(idpev_effects) | EF_NODRAW)
}
stock falltofloor(ent) {
    new 
Float:fOriginA[3], Float:fOriginB[3], Float:fHit[3]
    
pev(entpev_originfOriginA)
    
pev(entpev_originfOriginB)
    
fOriginB[2] -= 64
    fm_trace_line
(entfOriginAfOriginBfHit)
    
set_pev(ent,    pev_velocity,    {0.00.010.0})    //Force the game to update its position
    
set_pev(ent,    pev_origin,        fHit)
}
stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
    
engfunc(EngFunc_TraceLinestartendignoreent == -0ignoreent0)
    
get_tr2(0TR_vecEndPosret)
}
stock fm_find_ent_by_owner(index, const classname[], owner) {
    new 
ent index
    
while ((ent engfunc(EngFunc_FindEntityByStringent"classname"classname)) && pev(entpev_owner) != owner) {}
    return 
ent
}

public 
command_load() {
    new 
tmpCmd[31], tmpSent[31], tmpLen[5], tmpNext[4], tmpRate[7]
    if(
file_exists(AnimConfig)) {
        
AnimCnt 0
        
new sfLineData[128]
        new 
file fopen(AnimConfig,"rt")
        while(
file && !feof(file)) {
            
fgets(file,sfLineData,127)
            
            
// Skip Comment ; // and Empty Lines 
            
if (sfLineData[0] == ';' || strlen(sfLineData) < || (sfLineData[0] == '/')) continue
            
            if (
containi(sfLineData"Model=") > -1) {
                new 
strGarb[26]
                
parse(sfLineDatastrGarb25AnimFile40
            } else {
                
// BREAK IT UP!
                
parse(sfLineDatatmpCmd30tmpSent30tmpRate6tmpLen4tmpNext3)
                
                
saycmds[AnimCnt] = tmpCmd
                saysentence
[AnimCnt] = tmpSent
                playlength
[AnimCnt] = str_to_float(tmpLen)
                
playframerate[AnimCnt] = str_to_float(tmpRate)
                if (
tmpNext[0] == '-') {
                    
nextsequencenumb[AnimCnt] = -1
                
} else {
                    
nextsequencenumb[AnimCnt] = str_to_num(tmpNext)
                }
                
AnimCnt += 1
                
if(AnimCnt >= MaxAnims) {
                    
server_print("[%s] Reached animation limit",PLUG_TAG)
                    break
                }
            }
        }
        if(
filefclose(file)
    }

Create file named "AnimConfig.ini" and place in your configs folder. Put the following text in it.
Code:
model=		"models/Anim/playeranimha.mdl"
/Command	Sentence		FrameRate	Length		Next
"Stand"		"Stand"			1.0		0.0		-0
"Sit"		"Sitting"		1.0		0.0		-0
"Sit2"		"Sitting"		1.0		0.0		-0
"Wave"		"Waving"		1.5		0.0		-0
"Float"		"Floating"		1.0		0.0		-0
"Finger"	"Giving the Finger"	1.0		1.0		0
"Scratch"	"Scratching"		0.8		1.0		0
"Pump"		"Fist Pumping"		1.0		0.0		-0
"Flip"		"Flipping"		1.0		1.0		0
"Lay"		"Laying"		1.0		0.0		-0
"Pushup"	"Doing Pushups"		1.0		0.0		-0
"Pound"		"Chest Pounding"	0.75		0.0		-0
"Y"		"The Y"			1.0		0.0		-0
"M"		"The M"			1.0		0.0		-0
"C"		"The C"			1.0		0.0		-0
"A"		"The A"			1.0		0.0		-0
"DanceA"	"Dancing"		0.5		0.0		-0
"DanceB"	"Dancing"		1.0		0.0		-0
"Beatit"	"MJ Beat It"		1.8		0.0		-1
Add the attached model:
"models/Anim/playeranimha.mdl"

Sorry, I haven't checked these forums in a while, Always dipping in and out of playing CS. That is as far as I got with this, feel free to do whatever you want with it. If I missed something let me know.

Above code has the head movement part, and stops the animation when shot, or the player tries to move.
Still defiantly not something ready to just release on a server yet, but I tried to make it user friendly

say /"command" to use an animation.
Example say /sit, /sit2, /wave

If you make any changes to the .ini and you want the plugin to reload it without changing maps, use:
amx_anim_reloadini

Cvar, Default - Description
amx_anim_movehead, 1 - Allow heads to move where the player is looking when 'animating'
amx_anim_lockrot, 1 - Lock head movement to 180 degrees. (if set to 0, it looks kinda creepy)
amx_anim_admin, 1 - Only allow admins to use the animations

and to clear something up, some people don't seem to get it exactly..
There is one custom model needed to be downloaded from the server. It needed to have vertexes attached to it or the compiler would ignores the bones, but it is a very low poly model, and it ends up makes it a little easier to work with when animating. Besides that, all of the sequences are inside the single model. Its a very small download (76kb, less than the size of most Hat models)
Attached Files
File Type: zip playeranimha.zip (33.5 KB, 704 views)
__________________
[Add|Community]

~SgtBane

Last edited by sgtbane; 02-04-2011 at 00:19.
sgtbane is offline
Send a message via MSN to sgtbane
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 08:27.


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