X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fanimdecide.qh;h=16feb948c35d5c2264b9bdc21329c531c47ae2d9;hb=3cc1e9c4a52d70b4d7097a0a584cbb391570c6e2;hp=3f6815fe1f523ac902c257a3dd7460a6ecd135f5;hpb=ba0988ca930f50286f8cf3b6c114ebc6584964af;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/animdecide.qh b/qcsrc/common/animdecide.qh index 3f6815fe1..16feb948c 100644 --- a/qcsrc/common/animdecide.qh +++ b/qcsrc/common/animdecide.qh @@ -1,60 +1,4 @@ -#ifndef ANIMDECIDE_H -#define ANIMDECIDE_H - -#if defined(CSQC) - #include "util-pre.qh" - #include "../client/sys-pre.qh" - #include "../dpdefs/csprogsdefs.qc" - #include "../client/sys-post.qh" - #include "../client/Defs.qc" - #include "../dpdefs/keycodes.qc" - #include "constants.qh" - #include "stats.qh" - #include "../warpzonelib/anglestransform.qh" - #include "../warpzonelib/mathlib.qh" - #include "../warpzonelib/common.qh" - #include "../warpzonelib/client.qh" - #include "playerstats.qh" - #include "teams.qh" - #include "util.qh" - #include "nades.qh" - #include "buffs.qh" - #include "test.qh" - #include "counting.qh" - #include "weapons/weapons.qh" - #include "mapinfo.qh" - #include "command/markup.qh" - #include "command/rpn.qh" - #include "command/generic.qh" - #include "command/shared_defs.qh" - #include "urllib.qh" -#elif defined(MENUQC) -#elif defined(SVQC) - #include "util-pre.qh" - #include "../server/sys-pre.qh" - #include "../dpdefs/progsdefs.qc" - #include "../dpdefs/dpextensions.qc" - #include "../server/sys-post.qh" - #include "../warpzonelib/anglestransform.qh" - #include "../warpzonelib/mathlib.qh" - #include "../warpzonelib/common.qh" - #include "../warpzonelib/util_server.qh" - #include "../warpzonelib/server.qh" - #include "constants.qh" - #include "stats.qh" - #include "teams.qh" - #include "util.qh" - #include "nades.qh" - #include "buffs.qh" - #include "test.qh" - #include "counting.qh" - #include "urllib.qh" - #include "command/markup.qh" - #include "command/rpn.qh" - #include "command/generic.qh" - #include "command/shared_defs.qh" - #include "net_notice.qh" -#endif +#pragma once // must be called at least once to initialize, or when modelindex is changed void animdecide_load_if_needed(entity e); @@ -63,6 +7,102 @@ void animdecide_load_if_needed(entity e); void animdecide_setimplicitstate(entity e, float onground); void animdecide_setframes(entity e, bool support_blending, .int fld_frame, .int fld_frame1time, .int fld_frame2, .int fld_frame2time); +CLASS(Animation, Object) + ATTRIB(Animation, m_framenames, string); + STATIC_METHOD(Animation, getframe, int(Animation this, int mdlidx)) + { + FOREACH_WORD(this.m_framenames, true, { + int f = frameforname(mdlidx, it); + if (f != -1) return f; + }); +#ifdef CSQC + LOG_DEBUGF("Missing animation for %s: %s", modelnameforindex(mdlidx), this.registered_id); +#endif + return -1; + } +ENDCLASS(Animation) + +REGISTRY(Animations, BITS(8)) +REGISTER_REGISTRY(Animations) +#define Animations_from(id) _Animations_from(id, NULL) +#define WriteAnimation(to, it) WriteRegistered(Animations, to, it) +#define ReadAnimation() ReadRegistered(Animations) +#define REGISTER_ANIMATION(id, framenames) \ + .vector anim_##id; \ + REGISTER(Animations, ANIM_##id, m_id, NEW(Animation)) { \ + this.m_framenames = framenames; \ + } + +vector anim_vec(Animation anim, int mdlidx, int numframes, float framerate) +{ + vector v; + v.x = Animation_getframe(anim, mdlidx); + v.y = numframes; + v.z = framerate; + return v; +} + +// player animation data for this model +// each vector is as follows: +// _x = startframe +// _y = numframes +// _z = framerate +/** player dies */ +REGISTER_ANIMATION(die1, "dieone groupified_0_anim"); +/** player dies differently */ +REGISTER_ANIMATION(die2, "dietwo groupified_1_anim"); +/** player pulls out a weapon */ +REGISTER_ANIMATION(draw, "draw groupified_2_anim"); +REGISTER_ANIMATION(duck, "duck groupified_3_anim"); +/** player walking while crouching */ +REGISTER_ANIMATION(duckwalk, "duckwalk groupified_4_anim"); +/** player jumping from a crouch */ +REGISTER_ANIMATION(duckjump, "duckjump groupified_5_anim"); +/** player idling while crouching */ +REGISTER_ANIMATION(duckidle, "duckidle groupified_6_anim"); +/** player standing */ +REGISTER_ANIMATION(idle, "idle groupified_7_anim"); +/** player jump */ +REGISTER_ANIMATION(jump, "jump groupified_8_anim"); +/** player flinches from pain */ +REGISTER_ANIMATION(pain1, "painone groupified_9_anim"); +/** player flinches from pain, differently */ +REGISTER_ANIMATION(pain2, "paintwo groupified_10_anim"); +/** player shoots */ +REGISTER_ANIMATION(shoot, "shoot groupified_11_anim"); +/** player taunts others (FIXME: no code references this) */ +REGISTER_ANIMATION(taunt, "taunt groupified_12_anim"); +/** player running forward */ +REGISTER_ANIMATION(run, "run groupified_13_anim"); +/** player running backward */ +REGISTER_ANIMATION(runbackwards, "runbackwards groupified_14_anim"); +/** player shuffling left quickly */ +REGISTER_ANIMATION(strafeleft, "strafeleft groupified_15_anim"); +/** player shuffling right quickly */ +REGISTER_ANIMATION(straferight, "straferight groupified_16_anim"); +/** */ +REGISTER_ANIMATION(dead1, "deadone groupified_17_anim"); +/** */ +REGISTER_ANIMATION(dead2, "deadtwo groupified_18_anim"); +/** player running forward and right */ +REGISTER_ANIMATION(forwardright, "forwardright groupified_19_anim"); +/** player running forward and left */ +REGISTER_ANIMATION(forwardleft, "forwardleft groupified_20_anim"); +/** player running backward and right */ +REGISTER_ANIMATION(backright, "backright groupified_21_anim"); +/** player running back and left */ +REGISTER_ANIMATION(backleft, "backleft groupified_22_anim"); +/** player doing the melee action */ +REGISTER_ANIMATION(melee, "melee groupified_23_anim"); +REGISTER_ANIMATION(duckwalkbackwards, "duckwalkbackwards groupified_24_anim"); +REGISTER_ANIMATION(duckwalkstrafeleft, "duckwalkstrafeleft duckstrafeleft groupified_25_anim"); +REGISTER_ANIMATION(duckwalkstraferight, "duckwalkstraferight duckstraferight groupified_26_anim"); +REGISTER_ANIMATION(duckwalkforwardright, "duckwalkforwardright duckforwardright groupified_27_anim"); +REGISTER_ANIMATION(duckwalkforwardleft, "duckwalkforwardleft groupified_28_anim"); +REGISTER_ANIMATION(duckwalkbackright, "duckwalkbackright duckbackwardright groupified_29_anim"); +REGISTER_ANIMATION(duckwalkbackleft, "duckwalkbackleft duckbackwardleft groupified_30_anim"); +.float animdecide_modelindex; + // please network this one .int anim_state; .float anim_time; @@ -80,19 +120,20 @@ void animdecide_setframes(entity e, bool support_blending, .int fld_frame, .int .float anim_upper_implicit_time; // explicit anim states (networked) -void animdecide_setstate(entity e, float newstate, float restart); -const int ANIMSTATE_DEAD1 = 1; // base frames: die1 -const int ANIMSTATE_DEAD2 = 2; // base frames: die2 -const int ANIMSTATE_DUCK = 4; // turns walk into duckwalk, jump into duckjump, etc. -const int ANIMSTATE_FROZEN = 8; // force idle +void animdecide_setstate(entity e, int newstate, float restart); +const int ANIMSTATE_DEAD1 = BIT(0); // base frames: die1 +const int ANIMSTATE_DEAD2 = BIT(1); // base frames: die2 +const int ANIMSTATE_DUCK = BIT(2); // turns walk into duckwalk, jump into duckjump, etc. +const int ANIMSTATE_FROZEN = BIT(3); // force idle +const int ANIMSTATE_FOLLOW = BIT(4); // also force idle // implicit anim states (inferred from velocity, etc.) -const int ANIMIMPLICITSTATE_INAIR = 1; -const int ANIMIMPLICITSTATE_FORWARD = 2; -const int ANIMIMPLICITSTATE_BACKWARDS = 4; -const int ANIMIMPLICITSTATE_LEFT = 8; -const int ANIMIMPLICITSTATE_RIGHT = 16; -const int ANIMIMPLICITSTATE_JUMPRELEASED = 32; +const int ANIMIMPLICITSTATE_INAIR = BIT(0); +const int ANIMIMPLICITSTATE_FORWARD = BIT(1); +const int ANIMIMPLICITSTATE_BACKWARDS = BIT(2); +const int ANIMIMPLICITSTATE_LEFT = BIT(3); +const int ANIMIMPLICITSTATE_RIGHT = BIT(4); +const int ANIMIMPLICITSTATE_JUMPRELEASED = BIT(5); // explicit actions (networked); negative values are for lower body void animdecide_setaction(entity e, float action, float restart); @@ -103,4 +144,3 @@ const int ANIMACTION_PAIN2 = 3; // pain const int ANIMACTION_SHOOT = 4; // shoot const int ANIMACTION_TAUNT = 5; // taunt const int ANIMACTION_MELEE = 6; // melee -#endif \ No newline at end of file