1 #include "csqcmodel_hooks.qh"
5 #include "player_skeleton.qh"
7 #include "weapons/projectile.qh"
9 #include "../common/animdecide.qh"
10 #include "../common/csqcmodel_settings.qh"
11 #include "../common/effects/effects.qh"
12 #include "../common/teams.qh"
13 #include "../common/triggers/trigger/viewloc.qh"
15 #include "mutators/events.qh"
17 #include "../csqcmodellib/cl_model.qh"
18 #include "../csqcmodellib/cl_player.qh"
19 #include "../csqcmodellib/interpolate.qh"
25 void CSQCModel_Hook_PreDraw(bool isplayer);
33 void CSQCPlayer_LOD_Apply(void)
36 if(self.lodmodelindex0 != self.modelindex)
38 string modelname = self.model;
41 vector mi = self.mins;
42 vector ma = self.maxs;
45 self.lodmodelindex0 = self.modelindex;
46 self.lodmodelindex1 = self.modelindex;
47 self.lodmodelindex2 = self.modelindex;
49 // FIXME: this only supports 3-letter extensions
50 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
56 self.lodmodelindex1 = self.modelindex;
59 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
65 self.lodmodelindex2 = self.modelindex;
68 _setmodel(self, modelname); // make everything normal again
69 setsize(self, mi, ma);
73 if(autocvar_cl_playerdetailreduction <= 0)
75 if(autocvar_cl_playerdetailreduction <= -2)
76 self.modelindex = self.lodmodelindex2;
77 else if(autocvar_cl_playerdetailreduction <= -1)
78 self.modelindex = self.lodmodelindex1;
80 self.modelindex = self.lodmodelindex0;
84 float distance = vlen(self.origin - view_origin);
85 float f = (distance * current_viewzoom + 100.0) * autocvar_cl_playerdetailreduction;
86 f *= 1.0 / bound(0.01, view_quality, 1);
87 if(f > autocvar_cl_loddistance2)
88 self.modelindex = self.lodmodelindex2;
89 else if(f > autocvar_cl_loddistance1)
90 self.modelindex = self.lodmodelindex1;
92 self.modelindex = self.lodmodelindex0;
96 // FEATURE: forcemodel and model color selection (MUST be called BEFORE LOD!)
97 string forceplayermodels_model;
98 bool forceplayermodels_modelisgoodmodel;
99 int forceplayermodels_modelindex;
100 int forceplayermodels_skin;
102 string forceplayermodels_mymodel;
103 bool forceplayermodels_myisgoodmodel;
104 int forceplayermodels_mymodelindex;
106 bool forceplayermodels_attempted;
108 .string forceplayermodels_savemodel;
109 .int forceplayermodels_savemodelindex;
110 .int forceplayermodels_saveskin;
111 .int forceplayermodels_savecolormap;
113 .string forceplayermodels_isgoodmodel_mdl;
114 .bool forceplayermodels_isgoodmodel;
116 string forceplayermodels_goodmodel;
117 int forceplayermodels_goodmodelindex;
122 void CSQCPlayer_ModelAppearance_PreUpdate(void)
124 self.model = self.forceplayermodels_savemodel;
125 self.modelindex = self.forceplayermodels_savemodelindex;
126 self.skin = self.forceplayermodels_saveskin;
127 self.colormap = self.forceplayermodels_savecolormap;
129 void CSQCPlayer_ModelAppearance_PostUpdate(void)
131 self.forceplayermodels_savemodel = self.model;
132 self.forceplayermodels_savemodelindex = self.modelindex;
133 self.forceplayermodels_saveskin = self.skin;
134 self.forceplayermodels_savecolormap = self.colormap;
136 if(self.forceplayermodels_savemodel != self.forceplayermodels_isgoodmodel_mdl)
138 self.forceplayermodels_isgoodmodel = fexists(self.forceplayermodels_savemodel);
139 self.forceplayermodels_isgoodmodel_mdl = self.forceplayermodels_savemodel;
140 if(!self.forceplayermodels_isgoodmodel)
141 LOG_INFOF("Warning: missing model %s has been used\n", self.forceplayermodels_savemodel);
144 void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
147 // which one is ALWAYS good?
148 if (!forceplayermodels_goodmodel)
152 precache_model(cvar_defstring("_cl_playermodel"));
153 _setmodel(e, cvar_defstring("_cl_playermodel"));
154 forceplayermodels_goodmodel = e.model;
155 forceplayermodels_goodmodelindex = e.modelindex;
159 // first, try finding it from the server
160 if(self.forceplayermodels_savemodelindex && self.forceplayermodels_savemodel != "null")
164 if(!isdemo()) // this is mainly cheat protection; not needed for demos
166 // trust server's idea of "own player model"
167 forceplayermodels_modelisgoodmodel = self.forceplayermodels_isgoodmodel;
168 forceplayermodels_model = self.forceplayermodels_savemodel;
169 forceplayermodels_modelindex = self.forceplayermodels_savemodelindex;
170 forceplayermodels_skin = self.forceplayermodels_saveskin;
171 forceplayermodels_attempted = 1;
176 // forcemodel finding
177 if(!forceplayermodels_attempted)
179 forceplayermodels_attempted = 1;
181 // only if this failed, find it out on our own
184 _setmodel(e, autocvar__cl_playermodel); // this is harmless, see below
185 forceplayermodels_modelisgoodmodel = fexists(e.model);
186 forceplayermodels_model = e.model;
187 forceplayermodels_modelindex = e.modelindex;
188 forceplayermodels_skin = autocvar__cl_playerskin;
192 if(autocvar_cl_forcemyplayermodel != "" && autocvar_cl_forcemyplayermodel != forceplayermodels_mymodel)
196 _setmodel(e, autocvar_cl_forcemyplayermodel); // this is harmless, see below
197 forceplayermodels_myisgoodmodel = fexists(e.model);
198 forceplayermodels_mymodel = e.model;
199 forceplayermodels_mymodelindex = e.modelindex;
206 cm = self.forceplayermodels_savecolormap;
207 cm = (cm >= 1024) ? cm : (stof(getplayerkeyvalue(cm - 1, "colors")) + 1024);
210 isfriend = (cm == 1024 + 17 * myteam);
212 isfriend = islocalplayer;
214 if(autocvar_cl_forcemyplayermodel != "" && forceplayermodels_myisgoodmodel && isfriend)
216 self.model = forceplayermodels_mymodel;
217 self.modelindex = forceplayermodels_mymodelindex;
218 self.skin = autocvar_cl_forcemyplayerskin;
220 else if(autocvar_cl_forceplayermodels && forceplayermodels_modelisgoodmodel)
222 self.model = forceplayermodels_model;
223 self.modelindex = forceplayermodels_modelindex;
224 self.skin = forceplayermodels_skin;
226 else if(self.forceplayermodels_isgoodmodel)
228 self.model = self.forceplayermodels_savemodel;
229 self.modelindex = self.forceplayermodels_savemodelindex;
230 self.skin = self.forceplayermodels_saveskin;
234 self.model = forceplayermodels_goodmodel;
235 self.modelindex = forceplayermodels_goodmodelindex;
236 self.skin = self.forceplayermodels_saveskin;
239 // forceplayercolors too
242 // own team's color is never forced
243 int forcecolor_friend = 0;
244 int forcecolor_enemy = 0;
247 if(autocvar_cl_forcemyplayercolors)
248 forcecolor_friend = 1024 + autocvar_cl_forcemyplayercolors;
249 if(autocvar_cl_forceplayercolors && team_count == 2)
250 forcecolor_enemy = 1024 + autocvar__cl_color;
252 if(forcecolor_enemy && !forcecolor_friend)
254 // only enemy color is forced?
255 // verify it is not equal to the friend color
256 if(forcecolor_enemy == 1024 + 17 * myteam)
257 forcecolor_enemy = 0;
260 if(forcecolor_friend && !forcecolor_enemy)
262 // only friend color is forced?
263 // verify it is not equal to the enemy color
264 for(tm = teams.sort_next; tm; tm = tm.sort_next)
265 // note: we even compare against our own team.
266 // if we rejected because we matched our OWN team color,
267 // this is not bad; we then simply keep our color as is
269 if(forcecolor_friend == 1024 + 17 * tm.team)
270 forcecolor_friend = 0;
273 if(cm == 1024 + 17 * myteam)
275 if(forcecolor_friend)
276 self.colormap = forcecolor_friend;
281 self.colormap = forcecolor_enemy;
286 if(autocvar_cl_forcemyplayercolors && islocalplayer)
287 self.colormap = 1024 + autocvar_cl_forcemyplayercolors;
288 else if(autocvar_cl_forceplayercolors)
289 self.colormap = player_localnum + 1;
292 // GLOWMOD AND DEATH FADING
293 if(self.colormap > 0)
294 self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? self.colormap : stof(getplayerkeyvalue(self.colormap - 1, "colors"))) & 0x0F, true) * 2;
296 self.glowmod = '1 1 1';
298 if(autocvar_cl_deathglow > 0)
300 if(self.csqcmodel_isdead)
302 // Fade out to black now...
303 if(self.old_glowmod == '0 0 0') { self.old_glowmod = self.glowmod; }
306 self.glowmod = self.old_glowmod * bound(0, 1 - (time - self.death_time) / autocvar_cl_deathglow, 1);
307 self.glowmod_x = max(self.glowmod.x, 0.0001);
308 self.glowmod_y = max(self.glowmod.y, 0.0001);
309 self.glowmod_z = max(self.glowmod.z, 0.0001);
311 else if(self.old_glowmod != '0 0 0') { self.old_glowmod = '0 0 0'; }
314 //printf("CSQCPlayer_ModelAppearance_Apply(): state = %s, colormap = %f, glowmod = %s\n", (self.csqcmodel_isdead ? "DEAD" : "ALIVE"), self.colormap, vtos(self.glowmod));
317 // FEATURE: fallback frames
318 .int csqcmodel_saveframe;
319 .int csqcmodel_saveframe2;
320 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
321 .int csqcmodel_saveframe3;
322 .int csqcmodel_saveframe4;
324 .int csqcmodel_framecount;
326 #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1)
327 void CSQCPlayer_FallbackFrame_PreUpdate(void)
329 self.frame = self.csqcmodel_saveframe;
330 self.frame2 = self.csqcmodel_saveframe2;
331 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
332 self.frame3 = self.csqcmodel_saveframe3;
333 self.frame4 = self.csqcmodel_saveframe4;
336 void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
338 self.csqcmodel_saveframe = self.frame;
339 self.csqcmodel_saveframe2 = self.frame2;
340 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
341 self.csqcmodel_saveframe3 = self.frame3;
342 self.csqcmodel_saveframe4 = self.frame4;
345 // hack for death animations: set their frametime to zero in case a
349 #define FIX_FRAMETIME(f,ft) do { \
350 if(IS_DEAD_FRAME(self.f) && self.ft != 0 && self.death_time != 0) \
351 self.ft = self.death_time; \
353 FIX_FRAMETIME(frame, frame1time);
354 FIX_FRAMETIME(frame2, frame2time);
355 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
356 FIX_FRAMETIME(frame3, frame3time);
357 FIX_FRAMETIME(frame4, frame4time);
360 self.csqcmodel_isdead = IS_DEAD_FRAME(self.frame);
362 void CSQCPlayer_AnimDecide_PostUpdate(bool isnew)
364 self.csqcmodel_isdead = !!(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
366 int CSQCPlayer_FallbackFrame(int f)
368 if(frameduration(self.modelindex, f) > 0)
369 return f; // goooooood
370 if(frameduration(self.modelindex, 1) <= 0)
371 return f; // this is a static model. We can't fix it if we wanted to
374 case 23: return 11; // anim_melee -> anim_shoot
375 case 24: return 4; // anim_duckwalkbackwards -> anim_duckwalk
376 case 25: return 4; // anim_duckwalkstrafeleft -> anim_duckwalk
377 case 26: return 4; // anim_duckwalkstraferight -> anim_duckwalk
378 case 27: return 4; // anim_duckwalkforwardright -> anim_duckwalk
379 case 28: return 4; // anim_duckwalkforwardleft -> anim_duckwalk
380 case 29: return 4; // anim_duckwalkbackright -> anim_duckwalk
381 case 30: return 4; // anim_duckwalkbackleft -> anim_duckwalk
383 LOG_INFOF("Frame %d missing in model %s, and we have no fallback - FAIL!\n", f, self.model);
386 void CSQCPlayer_FallbackFrame_Apply(void)
388 self.frame = CSQCPlayer_FallbackFrame(self.frame);
389 self.frame2 = CSQCPlayer_FallbackFrame(self.frame2);
390 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
391 self.frame3 = CSQCPlayer_FallbackFrame(self.frame3);
392 self.frame4 = CSQCPlayer_FallbackFrame(self.frame4);
396 // FEATURE: auto tag_index
398 .int tag_entity_lastmodelindex;
400 void CSQCModel_AutoTagIndex_Apply(void)
402 if(self.tag_entity && wasfreed(self.tag_entity))
403 self.tag_entity = world;
405 if(self.viewloc && wasfreed(self.viewloc))
406 self.viewloc = world;
408 if(self.viewloc.entnum != self.tag_networkviewloc)
409 self.viewloc = findfloat(world, entnum, self.tag_networkviewloc);
411 MUTATOR_CALLHOOK(TagIndex_Update, self);
413 if(self.tag_networkentity)
417 if(self.tag_entity.entnum != self.tag_networkentity)
419 self.tag_entity = findfloat(world, entnum, self.tag_networkentity);
423 // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch
424 if(self.tag_entity.classname == "csqcmodel")
426 WITH(entity, self, self.tag_entity, CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients)));
429 if(self.tag_entity.modelindex != self.tag_entity_lastmodelindex)
431 self.tag_entity_lastmodelindex = self.tag_entity.modelindex;
438 // the best part is: IT EXISTS
439 if(substring(self.model, 0, 14) == "models/weapons")
441 if(substring(self.tag_entity.model, 0, 14) == "models/weapons")
443 self.tag_index = gettagindex(self.tag_entity, "weapon");
445 self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
448 // we need to prevent this from 'appening
449 self.tag_entity = world;
451 LOG_TRACE("h_ model lacks weapon attachment, but v_ model is attached to it\n");
454 else if(self.tag_entity.isplayermodel)
456 skeleton_loadinfo(self.tag_entity);
457 self.tag_index = self.tag_entity.bone_weapon;
461 if(substring(self.tag_entity.model, 0, 14) == "models/weapons")
463 self.tag_index = gettagindex(self.tag_entity, "shot");
465 self.tag_index = gettagindex(self.tag_entity, "tag_shot");
468 MUTATOR_CALLHOOK(TagIndex_Apply, self);
472 // damn, see you next frame
479 // FEATURE: EF_NODRAW workalike
480 const int EF_BRIGHTFIELD = 1;
481 const int EF_BRIGHTLIGHT = 4;
482 const int EF_DIMLIGHT = 8;
483 const int EF_DOUBLESIDED = 32768;
484 const int EF_NOSELFSHADOW = 65536;
485 const int EF_DYNAMICMODELLIGHT = 131072;
486 const int EF_RESTARTANIM_BIT = 1048576;
487 const int EF_TELEPORT_BIT = 2097152;
488 const int MF_ROCKET = 1; // leave a trail
489 const int MF_GRENADE = 2; // leave a trail
490 const int MF_GIB = 4; // leave a trail
491 const int MF_ROTATE = 8; // rotate (bonus items)
492 const int MF_TRACER = 16; // green split trail
493 const int MF_ZOMGIB = 32; // small blood trail
494 const int MF_TRACER2 = 64; // orange split trail
495 const int MF_TRACER3 = 128; // purple trail
496 .int csqcmodel_effects;
497 .int csqcmodel_modelflags;
498 void CSQCModel_Effects_PreUpdate(void)
500 self.effects = self.csqcmodel_effects;
501 self.modelflags = self.csqcmodel_modelflags;
503 void Reset_ArcBeam(void);
504 void CSQCModel_Effects_PostUpdate(void)
506 if (self == csqcplayer) {
507 if (self.csqcmodel_teleported) {
511 self.csqcmodel_effects = self.effects;
512 self.csqcmodel_modelflags = self.modelflags;
515 if(self.csqcmodel_teleported)
516 Projectile_ResetTrail(self.origin);
519 void CSQCModel_Effects_Apply(void)
521 int eff = self.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
523 self.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
525 self.traileffect = 0;
527 if(eff & EF_BRIGHTFIELD)
528 self.traileffect = particleeffectnum(EFFECT_TR_NEXUIZPLASMA);
529 // ignoring EF_MUZZLEFLASH
530 if(eff & EF_BRIGHTLIGHT)
531 adddynamiclight(self.origin, 400, '3 3 3');
532 if(eff & EF_DIMLIGHT)
533 adddynamiclight(self.origin, 200, '1.5 1.5 1.5');
534 if((eff & EF_NODRAW) || (self.alpha < 0))
536 if(eff & EF_ADDITIVE)
537 self.renderflags |= RF_ADDITIVE;
539 adddynamiclight(self.origin, 200, '0.15 0.15 1.5');
541 adddynamiclight(self.origin, 200, '1.5 0.15 0.15');
542 // ignoring EF_NOGUNBOB
543 if(eff & EF_FULLBRIGHT)
544 self.renderflags |= RF_FULLBRIGHT;
546 pointparticles(particleeffectnum(EFFECT_EF_FLAME), self.origin, '0 0 0', bound(0, frametime, 0.1));
547 if(eff & EF_STARDUST)
548 pointparticles(particleeffectnum(EFFECT_EF_STARDUST), self.origin, '0 0 0', bound(0, frametime, 0.1));
549 if(eff & EF_NOSHADOW)
550 self.renderflags |= RF_NOSHADOW;
551 if(eff & EF_NODEPTHTEST)
552 self.renderflags |= RF_DEPTHHACK;
553 // ignoring EF_SELECTABLE
554 if(eff & EF_DOUBLESIDED)
555 self.effects |= EF_DOUBLESIDED;
556 if(eff & EF_NOSELFSHADOW)
557 self.effects |= EF_NOSELFSHADOW;
558 if(eff & EF_DYNAMICMODELLIGHT)
559 self.renderflags |= RF_DYNAMICMODELLIGHT;
560 // ignoring EF_UNUSED18, EF_UNUSED19, EF_RESTARTANIM_BIT, EF_TELEPORT_BIT, EF_LOWPRECISION
561 if(self.csqcmodel_modelflags & MF_ROCKET)
562 self.traileffect = particleeffectnum(EFFECT_TR_ROCKET);
563 if(self.csqcmodel_modelflags & MF_GRENADE)
564 self.traileffect = particleeffectnum(EFFECT_TR_GRENADE);
565 if(self.csqcmodel_modelflags & MF_GIB)
566 self.traileffect = particleeffectnum(EFFECT_TR_BLOOD);
567 if(self.csqcmodel_modelflags & MF_ROTATE)
569 self.renderflags |= RF_USEAXIS;
570 makevectors(self.angles + '0 100 0' * fmod(time, 3.6));
572 if(self.csqcmodel_modelflags & MF_TRACER)
573 self.traileffect = particleeffectnum(EFFECT_TR_WIZSPIKE);
574 if(self.csqcmodel_modelflags & MF_ZOMGIB)
575 self.traileffect = particleeffectnum(EFFECT_TR_SLIGHTBLOOD);
576 if(self.csqcmodel_modelflags & MF_TRACER2)
577 self.traileffect = particleeffectnum(EFFECT_TR_KNIGHTSPIKE);
578 if(self.csqcmodel_modelflags & MF_TRACER3)
579 self.traileffect = particleeffectnum(EFFECT_TR_VORESPIKE);
582 Projectile_DrawTrail(self.origin);
584 Projectile_ResetTrail(self.origin);
586 if(self.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST)
587 self.renderflags |= RF_ADDITIVE;
588 // also special in CSQCPlayer_GlowMod_Apply
590 if(self.csqcmodel_modelflags & MF_ROCKET)
592 if(!self.snd_looping)
594 sound(self, CH_TRIGGER_SINGLE, "misc/jetpack_fly.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
595 self.snd_looping = CH_TRIGGER_SINGLE;
602 sound(self, self.snd_looping, "misc/null.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
603 self.snd_looping = 0;
608 void CSQCPlayer_Precache()
610 precache_sound("misc/jetpack_fly.wav");
614 .int csqcmodel_predraw_run;
616 .int anim_frame1time;
618 .int anim_frame2time;
620 .int anim_saveframe1time;
621 .int anim_saveframe2;
622 .int anim_saveframe2time;
623 .int anim_prev_pmove_flags;
624 void CSQCModel_Hook_PreDraw(bool isplayer)
626 if(self.csqcmodel_predraw_run == framecount)
628 self.csqcmodel_predraw_run = framecount;
630 if(!self.modelindex || self.model == "null")
636 self.drawmask = MASK_NORMAL;
638 if(self.isplayermodel) // this checks if it's a player MODEL!
640 CSQCPlayer_ModelAppearance_Apply(self.entnum == player_localnum + 1);
641 CSQCPlayer_LOD_Apply();
645 skeleton_loadinfo(self);
646 bool doblend = (self.bone_upperbody >= 0);
647 CSQCPlayer_FallbackFrame_Apply();
650 skeleton_from_frames(self, self.csqcmodel_isdead);
654 free_skeleton_from_frames(self);
655 // just in case, clear these (we're animating in frame and frame3)
662 // we know that frame3 and frame4 fields, used by InterpolateAnimation, are left alone - but that is all we know!
663 skeleton_loadinfo(self);
664 bool doblend = (self.bone_upperbody >= 0);
666 if(self == csqcplayer)
668 if(self.flags & FL_ONGROUND)
670 self.anim_prev_pmove_flags = self.flags;
671 if(self.flags & FL_DUCKED)
672 animdecide_setstate(self, self.anim_state | ANIMSTATE_DUCK, false);
673 else if(self.anim_state & ANIMSTATE_DUCK)
674 animdecide_setstate(self, self.anim_state - ANIMSTATE_DUCK, false);
678 tracebox(self.origin + '0 0 1', self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
679 if(trace_startsolid || trace_fraction < 1)
682 animdecide_load_if_needed(self);
683 animdecide_setimplicitstate(self, onground);
684 animdecide_setframes(self, doblend, anim_frame, anim_frame1time, anim_frame2, anim_frame2time);
686 if(self.anim_saveframe != self.anim_frame || self.anim_saveframe1time != self.anim_frame1time)
687 sf |= CSQCMODEL_PROPERTY_FRAME;
688 if(self.anim_saveframe2 != self.anim_frame2 || self.anim_saveframe2time != self.anim_frame2time)
689 sf |= CSQCMODEL_PROPERTY_FRAME2;
690 self.anim_saveframe = self.anim_frame;
691 self.anim_saveframe1time = self.anim_frame1time;
692 self.anim_saveframe2 = self.anim_frame2;
693 self.anim_saveframe2time = self.anim_frame2time;
694 // Note: we always consider lerpfrac "changed", as it uses fixed values every time anyway.
695 // This ensures that .frame etc. are always written.
696 CSQCModel_InterpolateAnimation_2To4_PreNote(sf | CSQCMODEL_PROPERTY_LERPFRAC);
697 self.lerpfrac = (doblend ? 0.5 : 0);
698 self.frame = self.anim_frame;
699 self.frame1time = self.anim_frame1time;
700 self.frame2 = self.anim_frame2;
701 self.frame2time = self.anim_frame2time;
702 CSQCModel_InterpolateAnimation_2To4_Note(sf | CSQCMODEL_PROPERTY_LERPFRAC, false);
703 CSQCModel_InterpolateAnimation_2To4_Do();
706 skeleton_from_frames(self, self.csqcmodel_isdead);
710 free_skeleton_from_frames(self);
711 // just in case, clear these (we're animating in frame and frame3)
718 CSQCModel_AutoTagIndex_Apply();
720 CSQCModel_Effects_Apply();
723 void CSQCModel_Hook_PreUpdate(bool isnew, bool isplayer, bool islocalplayer)
725 // interpolate v_angle
726 self.iflags |= IFLAG_V_ANGLE_X;
727 // revert to values from server
728 CSQCModel_Effects_PreUpdate();
729 if(self.isplayermodel)
732 CSQCPlayer_FallbackFrame_PreUpdate();
733 CSQCPlayer_ModelAppearance_PreUpdate();
737 void CSQCModel_Hook_PostUpdate(bool isnew, bool isplayer, bool islocalplayer)
739 // is it a player model? (shared state)
740 self.isplayermodel = (substring(self.model, 0, 14) == "models/player/" || substring(self.model, 0, 17) == "models/ok_player/" || (substring(self.model, 0, 16) == "models/monsters/" && (self.entnum >= 1 && self.entnum <= maxclients)));
742 // save values set by server
743 if(self.isplayermodel)
745 CSQCPlayer_ModelAppearance_PostUpdate();
747 CSQCPlayer_AnimDecide_PostUpdate(isnew);
749 CSQCPlayer_FallbackFrame_PostUpdate(isnew);
751 CSQCModel_Effects_PostUpdate();