1 #include "csqcmodel_hooks.qh"
3 #include <client/mutators/_mod.qh>
4 #include <client/player_skeleton.qh>
5 #include <client/weapons/projectile.qh>
6 #include <common/animdecide.qh>
7 #include <common/effects/all.inc>
8 #include <common/effects/all.qh>
9 #include <common/ent_cs.qh>
10 #include <common/gamemodes/_mod.qh>
11 #include <common/mapinfo.qh>
12 #include <common/physics/movetypes/movetypes.qh>
13 #include <common/physics/player.qh>
14 #include <common/viewloc.qh>
15 #include <lib/csqcmodel/cl_model.qh>
16 #include <lib/csqcmodel/cl_player.qh>
17 #include <lib/csqcmodel/interpolate.qh>
26 void CSQCPlayer_LOD_Apply(entity this)
29 if(this.lodmodelindex0 != this.modelindex)
31 string modelname = this.model;
34 vector mi = this.mins;
35 vector ma = this.maxs;
38 this.lodmodelindex0 = this.modelindex;
39 this.lodmodelindex1 = this.modelindex;
40 this.lodmodelindex2 = this.modelindex;
42 // FIXME: this only supports 3-letter extensions
43 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
49 this.lodmodelindex1 = this.modelindex;
52 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
58 this.lodmodelindex2 = this.modelindex;
61 _setmodel(this, modelname); // make everything normal again
62 setsize(this, mi, ma);
66 if(autocvar_cl_playerdetailreduction <= 0)
68 if(autocvar_cl_playerdetailreduction <= -2)
69 this.modelindex = this.lodmodelindex2;
70 else if(autocvar_cl_playerdetailreduction <= -1)
71 this.modelindex = this.lodmodelindex1;
73 this.modelindex = this.lodmodelindex0;
77 float distance = vlen(this.origin - view_origin);
78 float f = (distance * current_viewzoom + 100.0) * autocvar_cl_playerdetailreduction;
79 f *= 1.0 / bound(0.01, view_quality, 1);
80 if(f > autocvar_cl_loddistance2)
81 this.modelindex = this.lodmodelindex2;
82 else if(f > autocvar_cl_loddistance1)
83 this.modelindex = this.lodmodelindex1;
85 this.modelindex = this.lodmodelindex0;
89 // FEATURE: forcemodel and model color selection (MUST be called BEFORE LOD!)
90 string forceplayermodels_model;
91 bool forceplayermodels_modelisgoodmodel;
92 int forceplayermodels_modelindex;
93 int forceplayermodels_skin;
95 string forceplayermodels_mymodel;
96 bool forceplayermodels_myisgoodmodel;
97 int forceplayermodels_mymodelindex;
99 bool forceplayermodels_attempted;
101 .string forceplayermodels_savemodel;
102 .int forceplayermodels_savemodelindex;
103 .int forceplayermodels_saveskin;
104 .int forceplayermodels_savecolormap;
106 .string forceplayermodels_isgoodmodel_mdl;
107 .bool forceplayermodels_isgoodmodel;
109 string forceplayermodels_goodmodel;
110 int forceplayermodels_goodmodelindex;
114 void CSQCPlayer_ModelAppearance_PreUpdate(entity this)
116 this.model = this.forceplayermodels_savemodel;
117 this.modelindex = this.forceplayermodels_savemodelindex;
118 this.skin = this.forceplayermodels_saveskin;
119 this.colormap = this.forceplayermodels_savecolormap;
121 void CSQCPlayer_ModelAppearance_PostUpdate(entity this)
123 this.forceplayermodels_savemodel = this.model;
124 this.forceplayermodels_savemodelindex = this.modelindex;
125 this.forceplayermodels_saveskin = this.skin;
126 this.forceplayermodels_savecolormap = this.colormap;
128 if(this.forceplayermodels_savemodel != this.forceplayermodels_isgoodmodel_mdl)
130 this.forceplayermodels_isgoodmodel = fexists(this.forceplayermodels_savemodel);
131 this.forceplayermodels_isgoodmodel_mdl = this.forceplayermodels_savemodel;
132 if(!this.forceplayermodels_isgoodmodel)
133 LOG_INFOF("Warning: missing model %s has been used", this.forceplayermodels_savemodel);
136 void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
138 int cm = this.forceplayermodels_savecolormap;
139 cm = (cm >= 1024) ? cm : (entcs_GetClientColors(cm - 1) + 1024);
141 if(MUTATOR_CALLHOOK(ForcePlayermodels_Skip, this, islocalplayer))
142 goto skipforcemodels;
145 // which one is ALWAYS good?
146 if (!forceplayermodels_goodmodel)
149 precache_model(cvar_defstring("_cl_playermodel"));
150 _setmodel(e, cvar_defstring("_cl_playermodel"));
151 forceplayermodels_goodmodel = e.model;
152 forceplayermodels_goodmodelindex = e.modelindex;
156 // first, try finding it from the server
157 if(this.forceplayermodels_savemodelindex && this.forceplayermodels_savemodel != "null")
161 if(!isdemo()) // this is mainly cheat protection; not needed for demos
163 // trust server's idea of "own player model"
164 forceplayermodels_modelisgoodmodel = this.forceplayermodels_isgoodmodel;
165 forceplayermodels_model = this.forceplayermodels_savemodel;
166 forceplayermodels_modelindex = this.forceplayermodels_savemodelindex;
167 forceplayermodels_skin = this.forceplayermodels_saveskin;
168 forceplayermodels_attempted = 1;
173 // forcemodel finding
174 if(!forceplayermodels_attempted)
176 forceplayermodels_attempted = 1;
178 // only if this failed, find it out on our own
180 precache_model(autocvar__cl_playermodel);
181 _setmodel(e, autocvar__cl_playermodel); // this is harmless, see below
182 forceplayermodels_modelisgoodmodel = fexists(e.model);
183 forceplayermodels_model = e.model;
184 forceplayermodels_modelindex = e.modelindex;
185 forceplayermodels_skin = autocvar__cl_playerskin;
189 if(autocvar_cl_forcemyplayermodel != "" && autocvar_cl_forcemyplayermodel != forceplayermodels_mymodel)
192 _setmodel(e, autocvar_cl_forcemyplayermodel); // this is harmless, see below
193 forceplayermodels_myisgoodmodel = fexists(e.model);
194 forceplayermodels_mymodel = e.model;
195 forceplayermodels_mymodelindex = e.modelindex;
203 isfriend = (cm == 1024 + 17 * myteam);
205 isfriend = islocalplayer;
207 if(autocvar_cl_forcemyplayermodel != "" && forceplayermodels_myisgoodmodel && isfriend)
209 this.model = forceplayermodels_mymodel;
210 this.modelindex = forceplayermodels_mymodelindex;
211 this.skin = autocvar_cl_forcemyplayerskin;
213 else if(autocvar_cl_forceplayermodels && forceplayermodels_modelisgoodmodel)
215 this.model = forceplayermodels_model;
216 this.modelindex = forceplayermodels_modelindex;
217 this.skin = forceplayermodels_skin;
219 else if(this.forceplayermodels_isgoodmodel)
221 this.model = this.forceplayermodels_savemodel;
222 this.modelindex = this.forceplayermodels_savemodelindex;
223 this.skin = this.forceplayermodels_saveskin;
227 this.model = forceplayermodels_goodmodel;
228 this.modelindex = forceplayermodels_goodmodelindex;
229 this.skin = this.forceplayermodels_saveskin;
232 LABEL(skipforcemodels)
234 if(MUTATOR_CALLHOOK(ForcePlayercolors_Skip, this, islocalplayer))
235 goto skipforcecolors;
237 // forceplayercolors too
240 // own team's color is never forced
241 int forcecolor_friend = 0;
242 int forcecolor_enemy = 0;
245 if(autocvar_cl_forcemyplayercolors)
246 forcecolor_friend = 1024 + autocvar_cl_forcemyplayercolors;
247 if((autocvar_cl_forceplayercolors == 2 && team_count == 2)
248 || (autocvar_cl_forceplayercolors == 3 && IS_GAMETYPE(DUEL)))
249 forcecolor_enemy = 1024 + autocvar__cl_color;
251 if(forcecolor_enemy && !forcecolor_friend)
253 // only enemy color is forced?
254 // verify it is not equal to the friend color
255 if(forcecolor_enemy == 1024 + 17 * myteam)
256 forcecolor_enemy = 0;
259 if(forcecolor_friend && !forcecolor_enemy)
261 // only friend color is forced?
262 // verify it is not equal to the enemy color
263 for(tm = teams.sort_next; tm; tm = tm.sort_next)
264 // note: we even compare against our own team.
265 // if we rejected because we matched our OWN team color,
266 // this is not bad; we then simply keep our color as is
268 if(forcecolor_friend == 1024 + 17 * tm.team)
269 forcecolor_friend = 0;
272 if(cm == 1024 + 17 * myteam)
274 if(forcecolor_friend)
275 this.colormap = forcecolor_friend;
280 this.colormap = forcecolor_enemy;
285 if(autocvar_cl_forcemyplayercolors && islocalplayer)
286 this.colormap = 1024 + autocvar_cl_forcemyplayercolors;
287 else if(autocvar_cl_forceplayercolors)
288 this.colormap = player_localnum + 1;
291 LABEL(skipforcecolors)
293 if((this.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST) && !autocvar_cl_respawn_ghosts_keepcolors)
295 this.glowmod = '0 0 0';
300 // GLOWMOD AND DEATH FADING
301 if(this.colormap > 0)
302 this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : entcs_GetClientColors(this.colormap - 1)) & 0x0F, true) * 2;
304 this.glowmod = '1 1 1';
306 if(autocvar_cl_deathglow > 0)
308 if(this.csqcmodel_isdead)
310 float min_factor = bound(0, autocvar_cl_deathglow_min, 1);
311 if(this.colormap > 0)
313 float glow_fade = bound(0, 1 - (time - this.death_time) / autocvar_cl_deathglow, 1);
314 this.glowmod *= (min_factor + glow_fade * (1 - min_factor));
315 if (this.glowmod == '0 0 0')
316 this.glowmod.x = 0.000001;
320 //printf("CSQCPlayer_ModelAppearance_Apply(): state = %s, colormap = %f, glowmod = %s\n", (this.csqcmodel_isdead ? "DEAD" : "ALIVE"), this.colormap, vtos(this.glowmod));
323 // FEATURE: fallback frames
324 .int csqcmodel_saveframe;
325 .int csqcmodel_saveframe2;
326 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
327 .int csqcmodel_saveframe3;
328 .int csqcmodel_saveframe4;
330 .int csqcmodel_framecount;
332 #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1)
333 void CSQCPlayer_FallbackFrame_PreUpdate(entity this)
335 this.frame = this.csqcmodel_saveframe;
336 this.frame2 = this.csqcmodel_saveframe2;
337 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
338 this.frame3 = this.csqcmodel_saveframe3;
339 this.frame4 = this.csqcmodel_saveframe4;
342 void CSQCPlayer_FallbackFrame_PostUpdate(entity this, bool isnew)
344 this.csqcmodel_saveframe = this.frame;
345 this.csqcmodel_saveframe2 = this.frame2;
346 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
347 this.csqcmodel_saveframe3 = this.frame3;
348 this.csqcmodel_saveframe4 = this.frame4;
351 // hack for death animations: set their frametime to zero in case a
355 #define FIX_FRAMETIME(f,ft) MACRO_BEGIN \
356 if(IS_DEAD_FRAME(this.f) && this.ft != 0 && this.death_time != 0) \
357 this.ft = this.death_time; \
359 FIX_FRAMETIME(frame, frame1time);
360 FIX_FRAMETIME(frame2, frame2time);
361 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
362 FIX_FRAMETIME(frame3, frame3time);
363 FIX_FRAMETIME(frame4, frame4time);
366 this.csqcmodel_isdead = IS_DEAD_FRAME(this.frame);
368 void CSQCPlayer_AnimDecide_PostUpdate(entity this, bool isnew)
370 this.csqcmodel_isdead = boolean(this.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
372 int CSQCPlayer_FallbackFrame(entity this, int f)
375 if(frameduration(this.modelindex, f) > 0)
376 return f; // goooooood
377 if(frameduration(this.modelindex, 1) <= 0)
378 return f; // this is a static model. We can't fix it if we wanted to
381 case 23: return 11; // anim_melee -> anim_shoot
382 case 24: return 4; // anim_duckwalkbackwards -> anim_duckwalk
383 case 25: return 4; // anim_duckwalkstrafeleft -> anim_duckwalk
384 case 26: return 4; // anim_duckwalkstraferight -> anim_duckwalk
385 case 27: return 4; // anim_duckwalkforwardright -> anim_duckwalk
386 case 28: return 4; // anim_duckwalkforwardleft -> anim_duckwalk
387 case 29: return 4; // anim_duckwalkbackright -> anim_duckwalk
388 case 30: return 4; // anim_duckwalkbackleft -> anim_duckwalk
390 LOG_DEBUGF("Frame %d missing in model %s, and we have no fallback - FAIL!", f, this.model);
393 void CSQCPlayer_FallbackFrame_Apply(entity this)
395 this.frame = CSQCPlayer_FallbackFrame(this, this.frame);
396 this.frame2 = CSQCPlayer_FallbackFrame(this, this.frame2);
397 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
398 this.frame3 = CSQCPlayer_FallbackFrame(this, this.frame3);
399 this.frame4 = CSQCPlayer_FallbackFrame(this, this.frame4);
403 // FEATURE: auto tag_index
405 .int tag_entity_lastmodelindex;
407 void CSQCModel_AutoTagIndex_Apply(entity this)
409 if(this.tag_entity && wasfreed(this.tag_entity))
410 this.tag_entity = NULL;
412 MUTATOR_CALLHOOK(TagIndex_Update, this);
414 if(this.tag_networkentity)
418 if(this.tag_entity.entnum != this.tag_networkentity)
420 this.tag_entity = findfloat(NULL, entnum, this.tag_networkentity);
424 // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch
425 if(this.tag_entity.classname == "ENT_CLIENT_MODEL")
427 CSQCModel_Hook_PreDraw(this.tag_entity, (this.tag_entity.isplayermodel & ISPLAYER_CLIENT));
430 if(this.tag_entity.modelindex != this.tag_entity_lastmodelindex)
432 this.tag_entity_lastmodelindex = this.tag_entity.modelindex;
439 // the best part is: IT EXISTS
440 if(substring(this.model, 0, 14) == "models/weapons")
442 if(substring(this.tag_entity.model, 0, 14) == "models/weapons")
444 this.tag_index = gettagindex(this.tag_entity, "weapon");
446 this.tag_index = gettagindex(this.tag_entity, "tag_weapon");
449 // we need to prevent this from 'appening
450 this.tag_entity = NULL;
452 LOG_TRACE("h_ model lacks weapon attachment, but v_ model is attached to it");
455 else if((this.tag_entity.isplayermodel & ISPLAYER_MODEL))
457 skeleton_loadinfo(this.tag_entity);
458 this.tag_index = this.tag_entity.bone_weapon;
462 if(substring(this.tag_entity.model, 0, 14) == "models/weapons")
464 this.tag_index = gettagindex(this.tag_entity, "shot");
466 this.tag_index = gettagindex(this.tag_entity, "tag_shot");
469 MUTATOR_CALLHOOK(TagIndex_Apply, this);
473 // damn, see you next frame
480 void CSQCModel_Effects_PreUpdate(entity this)
482 this.effects = this.csqcmodel_effects;
483 this.modelflags = this.csqcmodel_modelflags;
484 this.traileffect = this.csqcmodel_traileffect;
486 void Reset_ArcBeam();
487 void CSQCModel_Effects_PostUpdate(entity this)
489 if (this == csqcplayer) {
490 if (this.csqcmodel_teleported) {
494 this.csqcmodel_effects = this.effects;
495 this.csqcmodel_modelflags = this.modelflags;
496 this.csqcmodel_traileffect = this.traileffect;
499 if(this.csqcmodel_teleported)
500 Projectile_ResetTrail(this, this.origin);
503 void CSQCModel_Effects_Apply(entity this)
505 int eff = this.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
506 int tref = this.csqcmodel_traileffect;
508 this.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
510 this.traileffect = 0;
512 if(eff & EF_BRIGHTFIELD)
513 tref = EFFECT_TR_NEXUIZPLASMA.m_id;
514 // ignoring EF_MUZZLEFLASH
515 if(eff & EF_BRIGHTLIGHT)
516 adddynamiclight(this.origin, 400, '3 3 3');
517 if(eff & EF_DIMLIGHT)
518 adddynamiclight(this.origin, 200, '1.5 1.5 1.5');
519 if((eff & EF_NODRAW) || (this.alpha < 0))
521 if(eff & EF_ADDITIVE)
522 this.renderflags |= RF_ADDITIVE;
524 adddynamiclight(this.origin, 200, '0.15 0.15 1.5');
526 adddynamiclight(this.origin, 200, '1.5 0.15 0.15');
527 // ignoring EF_NOGUNBOB
528 if(eff & EF_FULLBRIGHT)
529 this.renderflags |= RF_FULLBRIGHT;
532 boxparticles(particleeffectnum(EFFECT_EF_FLAME), this, this.absmin, this.absmax, this.velocity, this.velocity, bound(0, frametime, 0.1), 0);
533 //pointparticles(EFFECT_EF_FLAME, this.origin, '0 0 0', bound(0, frametime, 0.1));
535 if(eff & EF_STARDUST)
537 boxparticles(particleeffectnum(EFFECT_EF_STARDUST), this, this.absmin, this.absmax, this.velocity, this.velocity, bound(0, frametime, 0.1), 0);
538 //pointparticles(EFFECT_EF_STARDUST, this.origin, '0 0 0', bound(0, frametime, 0.1));
540 if(eff & EF_NOSHADOW)
541 this.renderflags |= RF_NOSHADOW;
542 if(eff & EF_NODEPTHTEST)
543 this.renderflags |= RF_DEPTHHACK;
544 // ignoring EF_SELECTABLE
545 if(eff & EF_DOUBLESIDED)
546 this.effects |= EF_DOUBLESIDED;
547 if(eff & EF_NOSELFSHADOW)
548 this.effects |= EF_NOSELFSHADOW;
549 if(eff & EF_DYNAMICMODELLIGHT)
550 this.renderflags |= RF_DYNAMICMODELLIGHT;
551 // ignoring EF_UNUSED18, EF_UNUSED19, EF_RESTARTANIM_BIT, EF_TELEPORT_BIT, EF_LOWPRECISION
552 if(this.csqcmodel_modelflags & MF_ROCKET)
553 tref = EFFECT_TR_ROCKET.m_id;
554 if(this.csqcmodel_modelflags & MF_GRENADE)
555 tref = EFFECT_TR_GRENADE.m_id;
556 if(this.csqcmodel_modelflags & MF_GIB)
557 tref = EFFECT_TR_BLOOD.m_id;
558 if(this.csqcmodel_modelflags & MF_ROTATE)
560 // This will be hard to replace with MAKE_VECTORS because it's called as part of the predraw function
561 // as documented in csprogs.h in the engine. The globals can then be read in many places in the engine.
562 // However MF_ROTATE is currently only used in one place - might be possible to get rid of it entirely.
563 this.renderflags |= RF_USEAXIS;
564 makevectors(this.angles + '0 100 0' * fmod(time, 3.6));
566 if(this.csqcmodel_modelflags & MF_TRACER)
567 tref = EFFECT_TR_WIZSPIKE.m_id;
568 if(this.csqcmodel_modelflags & MF_ZOMGIB)
569 tref = EFFECT_TR_SLIGHTBLOOD.m_id;
570 if(this.csqcmodel_modelflags & MF_TRACER2)
571 tref = EFFECT_TR_KNIGHTSPIKE.m_id;
572 if(this.csqcmodel_modelflags & MF_TRACER3)
573 tref = EFFECT_TR_VORESPIKE.m_id;
575 this.traileffect = tref;
578 Projectile_DrawTrail(this, this.origin);
580 Projectile_ResetTrail(this, this.origin);
582 if(this.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST)
583 this.renderflags |= RF_ADDITIVE;
584 // also special in CSQCPlayer_GlowMod_Apply
586 if(this.csqcmodel_modelflags & MF_ROCKET)
588 if(!this.snd_looping)
590 sound(this, CH_TRIGGER_SINGLE, SND_JETPACK_FLY, VOL_BASE, autocvar_cl_jetpack_attenuation);
591 this.snd_looping = CH_TRIGGER_SINGLE;
598 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_cl_jetpack_attenuation);
599 this.snd_looping = 0;
605 .int csqcmodel_predraw_run;
607 .int anim_frame1time;
609 .int anim_frame2time;
611 .int anim_saveframe1time;
612 .int anim_saveframe2;
613 .int anim_saveframe2time;
614 .int anim_prev_pmove_flags;
615 void CSQCModel_Hook_PreDraw(entity this, bool isplayer)
617 if(this.csqcmodel_predraw_run == framecount)
619 this.csqcmodel_predraw_run = framecount;
621 if(!this.modelindex || this.model == "null")
624 if(this.snd_looping > 0)
626 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_cl_jetpack_attenuation);
627 this.snd_looping = 0;
632 this.drawmask = MASK_NORMAL;
634 if((this.isplayermodel & ISPLAYER_MODEL) && this.drawmask) // this checks if it's a player MODEL!
636 CSQCPlayer_ModelAppearance_Apply(this, (this.isplayermodel & ISPLAYER_LOCAL));
637 CSQCPlayer_LOD_Apply(this);
641 skeleton_loadinfo(this);
642 bool doblend = (this.bone_upperbody >= 0);
643 CSQCPlayer_FallbackFrame_Apply(this);
646 skeleton_from_frames(this, this.csqcmodel_isdead);
650 free_skeleton_from_frames(this);
651 // just in case, clear these (we're animating in frame and frame3)
658 // we know that frame3 and frame4 fields, used by InterpolateAnimation, are left alone - but that is all we know!
659 skeleton_loadinfo(this);
660 bool doblend = (this.bone_upperbody >= 0);
662 if(this == csqcplayer)
664 if(IS_ONGROUND(this))
666 this.anim_prev_pmove_flags = this.flags;
667 if(this.flags & FL_DUCKED)
668 animdecide_setstate(this, this.anim_state | ANIMSTATE_DUCK, false);
669 else if(this.anim_state & ANIMSTATE_DUCK)
670 animdecide_setstate(this, this.anim_state - ANIMSTATE_DUCK, false);
674 tracebox(this.origin + '0 0 1', this.mins, this.maxs, this.origin - '0 0 4', MOVE_NORMAL, this);
675 if(trace_startsolid || trace_fraction < 1)
677 // predicted clients handle smoothing in the prediction code
678 this.origin = CSQCModel_ApplyStairSmoothing(this, onground, this.origin);
680 animdecide_load_if_needed(this);
681 animdecide_setimplicitstate(this, onground);
682 animdecide_setframes(this, doblend, anim_frame, anim_frame1time, anim_frame2, anim_frame2time);
684 if(this.anim_saveframe != this.anim_frame || this.anim_saveframe1time != this.anim_frame1time)
685 sf |= CSQCMODEL_PROPERTY_FRAME;
686 if(this.anim_saveframe2 != this.anim_frame2 || this.anim_saveframe2time != this.anim_frame2time)
687 sf |= CSQCMODEL_PROPERTY_FRAME2;
688 this.anim_saveframe = this.anim_frame;
689 this.anim_saveframe1time = this.anim_frame1time;
690 this.anim_saveframe2 = this.anim_frame2;
691 this.anim_saveframe2time = this.anim_frame2time;
692 // Note: we always consider lerpfrac "changed", as it uses fixed values every time anyway.
693 // This ensures that .frame etc. are always written.
694 CSQCModel_InterpolateAnimation_2To4_PreNote(this, sf | CSQCMODEL_PROPERTY_LERPFRAC);
695 this.lerpfrac = (doblend ? 0.5 : 0);
696 this.frame = this.anim_frame;
697 this.frame1time = this.anim_frame1time;
698 this.frame2 = this.anim_frame2;
699 this.frame2time = this.anim_frame2time;
700 CSQCModel_InterpolateAnimation_2To4_Note(this, sf | CSQCMODEL_PROPERTY_LERPFRAC, false);
701 CSQCModel_InterpolateAnimation_2To4_Do(this);
704 skeleton_from_frames(this, this.csqcmodel_isdead);
708 free_skeleton_from_frames(this);
709 // just in case, clear these (we're animating in frame and frame3)
716 CSQCModel_AutoTagIndex_Apply(this);
718 CSQCModel_Effects_Apply(this);
721 void CSQCModel_Hook_PreUpdate(entity this, bool isnew, bool isplayer, bool islocalplayer)
723 // interpolate v_angle
724 this.iflags |= IFLAG_V_ANGLE_X;
725 // revert to values from server
726 CSQCModel_Effects_PreUpdate(this);
727 if((this.isplayermodel & ISPLAYER_MODEL))
730 CSQCPlayer_FallbackFrame_PreUpdate(this);
731 CSQCPlayer_ModelAppearance_PreUpdate(this);
735 void CSQCModel_Hook_PostUpdate(entity this, bool isnew, bool isplayer, bool islocalplayer)
737 // is it a player model? (shared state)
738 bool is_playermodel = (substring(this.model, 0, 14) == "models/player/" || substring(this.model, 0, 17) == "models/ok_player/" ||
739 (substring(this.model, 0, 16) == "models/monsters/" && (this.isplayermodel & BIT(1))));
740 this.isplayermodel = BITSET(this.isplayermodel, ISPLAYER_MODEL, is_playermodel);
741 this.csqcmodel_isdead = false; // workaround for dead players who become a spectator
743 // save values set by server
744 if((this.isplayermodel & ISPLAYER_MODEL))
746 CSQCPlayer_ModelAppearance_PostUpdate(this);
748 CSQCPlayer_AnimDecide_PostUpdate(this, isnew);
750 CSQCPlayer_FallbackFrame_PostUpdate(this, isnew);
752 CSQCModel_Effects_PostUpdate(this);