1 #include "csqcmodel_hooks.qh"
2 #include "autocvars.qh"
3 #include "csqcmodel_hooks.qh"
4 #include "miscfunctions.qh"
5 #include "mutators/events.qh"
6 #include "player_skeleton.qh"
7 #include "weapons/projectile.qh"
8 #include <common/animdecide.qh>
9 #include <common/ent_cs.qh>
10 #include <common/physics/movetypes/movetypes.qh>
11 #include <common/viewloc.qh>
12 #include <common/effects/all.qh>
13 #include <common/effects/all.inc>
14 #include <lib/csqcmodel/cl_model.qh>
15 #include <lib/csqcmodel/cl_player.qh>
16 #include <lib/csqcmodel/interpolate.qh>
21 void CSQCModel_Hook_PreDraw(entity this, bool isplayer);
29 void CSQCPlayer_LOD_Apply(entity this, bool isplayer)
31 int detailreduction = ((isplayer) ? autocvar_cl_playerdetailreduction : autocvar_cl_modeldetailreduction);
34 if(this.lodmodelindex0 != this.modelindex)
36 string modelname = this.model;
39 vector mi = this.mins;
40 vector ma = this.maxs;
43 this.lodmodelindex0 = this.modelindex;
44 this.lodmodelindex1 = this.modelindex;
45 this.lodmodelindex2 = this.modelindex;
47 // FIXME: this only supports 3-letter extensions
48 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
54 this.lodmodelindex1 = this.modelindex;
57 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
63 this.lodmodelindex2 = this.modelindex;
66 _setmodel(this, modelname); // make everything normal again
67 setsize(this, mi, ma);
71 if(detailreduction <= 0)
73 if(detailreduction <= -2)
74 this.modelindex = this.lodmodelindex2;
75 else if(detailreduction <= -1)
76 this.modelindex = this.lodmodelindex1;
78 this.modelindex = this.lodmodelindex0;
82 float distance = vlen(((isplayer) ? this.origin : NearestPointOnBox(this, view_origin)) - view_origin); // TODO: perhaps it should just use NearestPointOnBox all the time, player hitbox can potentially be huge
83 float f = (distance * current_viewzoom + 100.0) * detailreduction;
84 f *= 1.0 / bound(0.01, view_quality, 1);
85 if(f > autocvar_cl_loddistance2)
86 this.modelindex = this.lodmodelindex2;
87 else if(f > autocvar_cl_loddistance1)
88 this.modelindex = this.lodmodelindex1;
90 this.modelindex = this.lodmodelindex0;
94 // FEATURE: forcemodel and model color selection (MUST be called BEFORE LOD!)
95 string forceplayermodels_model;
96 bool forceplayermodels_modelisgoodmodel;
97 int forceplayermodels_modelindex;
98 int forceplayermodels_skin;
100 string forceplayermodels_mymodel;
101 bool forceplayermodels_myisgoodmodel;
102 int forceplayermodels_mymodelindex;
104 bool forceplayermodels_attempted;
106 .string forceplayermodels_savemodel;
107 .int forceplayermodels_savemodelindex;
108 .int forceplayermodels_saveskin;
109 .int forceplayermodels_savecolormap;
111 .string forceplayermodels_isgoodmodel_mdl;
112 .bool forceplayermodels_isgoodmodel;
114 string forceplayermodels_goodmodel;
115 int forceplayermodels_goodmodelindex;
120 void CSQCPlayer_ModelAppearance_PreUpdate(entity this)
122 this.model = this.forceplayermodels_savemodel;
123 this.modelindex = this.forceplayermodels_savemodelindex;
124 this.skin = this.forceplayermodels_saveskin;
125 this.colormap = this.forceplayermodels_savecolormap;
127 void CSQCPlayer_ModelAppearance_PostUpdate(entity this)
129 this.forceplayermodels_savemodel = this.model;
130 this.forceplayermodels_savemodelindex = this.modelindex;
131 this.forceplayermodels_saveskin = this.skin;
132 this.forceplayermodels_savecolormap = this.colormap;
134 if(this.forceplayermodels_savemodel != this.forceplayermodels_isgoodmodel_mdl)
136 this.forceplayermodels_isgoodmodel = fexists(this.forceplayermodels_savemodel);
137 this.forceplayermodels_isgoodmodel_mdl = this.forceplayermodels_savemodel;
138 if(!this.forceplayermodels_isgoodmodel)
139 LOG_INFOF("Warning: missing model %s has been used", this.forceplayermodels_savemodel);
142 void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
144 if(MUTATOR_CALLHOOK(ForcePlayermodels_Skip, this, islocalplayer))
145 goto skipforcemodels;
148 // which one is ALWAYS good?
149 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(this.forceplayermodels_savemodelindex && this.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 = this.forceplayermodels_isgoodmodel;
168 forceplayermodels_model = this.forceplayermodels_savemodel;
169 forceplayermodels_modelindex = this.forceplayermodels_savemodelindex;
170 forceplayermodels_skin = this.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
183 precache_model(autocvar__cl_playermodel);
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)
195 _setmodel(e, autocvar_cl_forcemyplayermodel); // this is harmless, see below
196 forceplayermodels_myisgoodmodel = fexists(e.model);
197 forceplayermodels_mymodel = e.model;
198 forceplayermodels_mymodelindex = e.modelindex;
205 cm = this.forceplayermodels_savecolormap;
206 cm = (cm >= 1024) ? cm : (entcs_GetClientColors(cm - 1) + 1024);
209 isfriend = (cm == 1024 + 17 * myteam);
211 isfriend = islocalplayer;
213 if(autocvar_cl_forcemyplayermodel != "" && forceplayermodels_myisgoodmodel && isfriend)
215 this.model = forceplayermodels_mymodel;
216 this.modelindex = forceplayermodels_mymodelindex;
217 this.skin = autocvar_cl_forcemyplayerskin;
219 else if(autocvar_cl_forceplayermodels && forceplayermodels_modelisgoodmodel)
221 this.model = forceplayermodels_model;
222 this.modelindex = forceplayermodels_modelindex;
223 this.skin = forceplayermodels_skin;
225 else if(this.forceplayermodels_isgoodmodel)
227 this.model = this.forceplayermodels_savemodel;
228 this.modelindex = this.forceplayermodels_savemodelindex;
229 this.skin = this.forceplayermodels_saveskin;
233 this.model = forceplayermodels_goodmodel;
234 this.modelindex = forceplayermodels_goodmodelindex;
235 this.skin = this.forceplayermodels_saveskin;
238 // forceplayercolors too
241 // own team's color is never forced
242 int forcecolor_friend = 0;
243 int forcecolor_enemy = 0;
246 if(autocvar_cl_forcemyplayercolors)
247 forcecolor_friend = 1024 + autocvar_cl_forcemyplayercolors;
248 if(autocvar_cl_forceplayercolors == 2 && team_count == 2)
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(skipforcemodels)
293 // GLOWMOD AND DEATH FADING
294 if(this.colormap > 0)
295 this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : entcs_GetClientColors(this.colormap - 1)) & 0x0F, true) * 2;
297 this.glowmod = '1 1 1';
299 if(autocvar_cl_deathglow > 0)
301 if(this.csqcmodel_isdead)
303 // Fade out to black now...
304 if(this.old_glowmod == '0 0 0') { this.old_glowmod = this.glowmod; }
307 this.glowmod = this.old_glowmod * bound(0, 1 - (time - this.death_time) / autocvar_cl_deathglow, 1);
308 this.glowmod_x = max(this.glowmod.x, 0.0001);
309 this.glowmod_y = max(this.glowmod.y, 0.0001);
310 this.glowmod_z = max(this.glowmod.z, 0.0001);
312 else if(this.old_glowmod != '0 0 0') { this.old_glowmod = '0 0 0'; }
315 //printf("CSQCPlayer_ModelAppearance_Apply(): state = %s, colormap = %f, glowmod = %s\n", (this.csqcmodel_isdead ? "DEAD" : "ALIVE"), this.colormap, vtos(this.glowmod));
318 // FEATURE: fallback frames
319 .int csqcmodel_saveframe;
320 .int csqcmodel_saveframe2;
321 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
322 .int csqcmodel_saveframe3;
323 .int csqcmodel_saveframe4;
325 .int csqcmodel_framecount;
327 #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1)
328 void CSQCPlayer_FallbackFrame_PreUpdate(entity this)
330 this.frame = this.csqcmodel_saveframe;
331 this.frame2 = this.csqcmodel_saveframe2;
332 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
333 this.frame3 = this.csqcmodel_saveframe3;
334 this.frame4 = this.csqcmodel_saveframe4;
337 void CSQCPlayer_FallbackFrame_PostUpdate(entity this, bool isnew)
339 this.csqcmodel_saveframe = this.frame;
340 this.csqcmodel_saveframe2 = this.frame2;
341 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
342 this.csqcmodel_saveframe3 = this.frame3;
343 this.csqcmodel_saveframe4 = this.frame4;
346 // hack for death animations: set their frametime to zero in case a
350 #define FIX_FRAMETIME(f,ft) MACRO_BEGIN { \
351 if(IS_DEAD_FRAME(this.f) && this.ft != 0 && this.death_time != 0) \
352 this.ft = this.death_time; \
354 FIX_FRAMETIME(frame, frame1time);
355 FIX_FRAMETIME(frame2, frame2time);
356 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
357 FIX_FRAMETIME(frame3, frame3time);
358 FIX_FRAMETIME(frame4, frame4time);
361 this.csqcmodel_isdead = IS_DEAD_FRAME(this.frame);
363 void CSQCPlayer_AnimDecide_PostUpdate(entity this, bool isnew)
365 this.csqcmodel_isdead = boolean(this.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
367 int CSQCPlayer_FallbackFrame(entity this, int f)
370 if(frameduration(this.modelindex, f) > 0)
371 return f; // goooooood
372 if(frameduration(this.modelindex, 1) <= 0)
373 return f; // this is a static model. We can't fix it if we wanted to
376 case 23: return 11; // anim_melee -> anim_shoot
377 case 24: return 4; // anim_duckwalkbackwards -> anim_duckwalk
378 case 25: return 4; // anim_duckwalkstrafeleft -> anim_duckwalk
379 case 26: return 4; // anim_duckwalkstraferight -> anim_duckwalk
380 case 27: return 4; // anim_duckwalkforwardright -> anim_duckwalk
381 case 28: return 4; // anim_duckwalkforwardleft -> anim_duckwalk
382 case 29: return 4; // anim_duckwalkbackright -> anim_duckwalk
383 case 30: return 4; // anim_duckwalkbackleft -> anim_duckwalk
385 LOG_DEBUGF("Frame %d missing in model %s, and we have no fallback - FAIL!", f, this.model);
388 void CSQCPlayer_FallbackFrame_Apply(entity this)
390 this.frame = CSQCPlayer_FallbackFrame(this, this.frame);
391 this.frame2 = CSQCPlayer_FallbackFrame(this, this.frame2);
392 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
393 this.frame3 = CSQCPlayer_FallbackFrame(this, this.frame3);
394 this.frame4 = CSQCPlayer_FallbackFrame(this, this.frame4);
398 // FEATURE: auto tag_index
400 .int tag_entity_lastmodelindex;
402 void CSQCModel_AutoTagIndex_Apply(entity this)
404 if(this.tag_entity && wasfreed(this.tag_entity))
405 this.tag_entity = NULL;
407 MUTATOR_CALLHOOK(TagIndex_Update, this);
409 if(this.tag_networkentity)
413 if(this.tag_entity.entnum != this.tag_networkentity)
415 this.tag_entity = findfloat(NULL, entnum, this.tag_networkentity);
419 // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch
420 if(this.tag_entity.classname == "csqcmodel")
422 CSQCModel_Hook_PreDraw(this.tag_entity, (this.tag_entity.entnum >= 1 && this.tag_entity.entnum <= maxclients));
425 if(this.tag_entity.modelindex != this.tag_entity_lastmodelindex)
427 this.tag_entity_lastmodelindex = this.tag_entity.modelindex;
434 // the best part is: IT EXISTS
435 if(substring(this.model, 0, 14) == "models/weapons")
437 if(substring(this.tag_entity.model, 0, 14) == "models/weapons")
439 this.tag_index = gettagindex(this.tag_entity, "weapon");
441 this.tag_index = gettagindex(this.tag_entity, "tag_weapon");
444 // we need to prevent this from 'appening
445 this.tag_entity = NULL;
447 LOG_TRACE("h_ model lacks weapon attachment, but v_ model is attached to it");
450 else if(this.tag_entity.isplayermodel)
452 skeleton_loadinfo(this.tag_entity);
453 this.tag_index = this.tag_entity.bone_weapon;
457 if(substring(this.tag_entity.model, 0, 14) == "models/weapons")
459 this.tag_index = gettagindex(this.tag_entity, "shot");
461 this.tag_index = gettagindex(this.tag_entity, "tag_shot");
464 MUTATOR_CALLHOOK(TagIndex_Apply, this);
468 // damn, see you next frame
475 void CSQCModel_Effects_PreUpdate(entity this)
477 this.effects = this.csqcmodel_effects;
478 this.modelflags = this.csqcmodel_modelflags;
479 this.traileffect = this.csqcmodel_traileffect;
481 void Reset_ArcBeam();
482 void CSQCModel_Effects_PostUpdate(entity this)
484 if (this == csqcplayer) {
485 if (this.csqcmodel_teleported) {
489 this.csqcmodel_effects = this.effects;
490 this.csqcmodel_modelflags = this.modelflags;
491 this.csqcmodel_traileffect = this.traileffect;
494 if(this.csqcmodel_teleported)
495 Projectile_ResetTrail(this, this.origin);
498 void CSQCModel_Effects_Apply(entity this)
500 int eff = this.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
501 int tref = this.csqcmodel_traileffect;
503 this.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
505 this.traileffect = 0;
507 if(eff & EF_BRIGHTFIELD)
508 tref = EFFECT_TR_NEXUIZPLASMA.m_id;
509 // ignoring EF_MUZZLEFLASH
510 if(eff & EF_BRIGHTLIGHT)
511 adddynamiclight(this.origin, 400, '3 3 3');
512 if(eff & EF_DIMLIGHT)
513 adddynamiclight(this.origin, 200, '1.5 1.5 1.5');
514 if((eff & EF_NODRAW) || (this.alpha < 0))
516 if(eff & EF_ADDITIVE)
517 this.renderflags |= RF_ADDITIVE;
519 adddynamiclight(this.origin, 200, '0.15 0.15 1.5');
521 adddynamiclight(this.origin, 200, '1.5 0.15 0.15');
522 // ignoring EF_NOGUNBOB
523 if(eff & EF_FULLBRIGHT)
524 this.renderflags |= RF_FULLBRIGHT;
526 pointparticles(EFFECT_EF_FLAME, this.origin, '0 0 0', bound(0, frametime, 0.1));
527 if(eff & EF_STARDUST)
528 pointparticles(EFFECT_EF_STARDUST, this.origin, '0 0 0', bound(0, frametime, 0.1));
529 if(eff & EF_NOSHADOW)
530 this.renderflags |= RF_NOSHADOW;
531 if(eff & EF_NODEPTHTEST)
532 this.renderflags |= RF_DEPTHHACK;
533 // ignoring EF_SELECTABLE
534 if(eff & EF_DOUBLESIDED)
535 this.effects |= EF_DOUBLESIDED;
536 if(eff & EF_NOSELFSHADOW)
537 this.effects |= EF_NOSELFSHADOW;
538 if(eff & EF_DYNAMICMODELLIGHT)
539 this.renderflags |= RF_DYNAMICMODELLIGHT;
540 // ignoring EF_UNUSED18, EF_UNUSED19, EF_RESTARTANIM_BIT, EF_TELEPORT_BIT, EF_LOWPRECISION
541 if(this.csqcmodel_modelflags & MF_ROCKET)
542 tref = EFFECT_TR_ROCKET.m_id;
543 if(this.csqcmodel_modelflags & MF_GRENADE)
544 tref = EFFECT_TR_GRENADE.m_id;
545 if(this.csqcmodel_modelflags & MF_GIB)
546 tref = EFFECT_TR_BLOOD.m_id;
547 if(this.csqcmodel_modelflags & MF_ROTATE)
549 this.renderflags |= RF_USEAXIS;
550 makevectors(this.angles + '0 100 0' * fmod(time, 3.6));
552 if(this.csqcmodel_modelflags & MF_TRACER)
553 tref = EFFECT_TR_WIZSPIKE.m_id;
554 if(this.csqcmodel_modelflags & MF_ZOMGIB)
555 tref = EFFECT_TR_SLIGHTBLOOD.m_id;
556 if(this.csqcmodel_modelflags & MF_TRACER2)
557 tref = EFFECT_TR_KNIGHTSPIKE.m_id;
558 if(this.csqcmodel_modelflags & MF_TRACER3)
559 tref = EFFECT_TR_VORESPIKE.m_id;
561 this.traileffect = tref;
564 Projectile_DrawTrail(this, this.origin);
566 Projectile_ResetTrail(this, this.origin);
568 if(this.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST)
569 this.renderflags |= RF_ADDITIVE;
570 // also special in CSQCPlayer_GlowMod_Apply
572 if(this.csqcmodel_modelflags & MF_ROCKET)
574 if(!this.snd_looping)
576 sound(this, CH_TRIGGER_SINGLE, SND_JETPACK_FLY, VOL_BASE, autocvar_cl_jetpack_attenuation);
577 this.snd_looping = CH_TRIGGER_SINGLE;
584 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_cl_jetpack_attenuation);
585 this.snd_looping = 0;
591 .int csqcmodel_predraw_run;
593 .int anim_frame1time;
595 .int anim_frame2time;
597 .int anim_saveframe1time;
598 .int anim_saveframe2;
599 .int anim_saveframe2time;
600 .int anim_prev_pmove_flags;
601 void CSQCModel_Hook_PreDraw(entity this, bool isplayer)
603 if(this.csqcmodel_predraw_run == framecount)
605 this.csqcmodel_predraw_run = framecount;
607 if(!this.modelindex || this.model == "null")
613 this.drawmask = MASK_NORMAL;
615 if(this.isplayermodel) // this checks if it's a player MODEL!
617 CSQCPlayer_ModelAppearance_Apply(this, this.entnum == player_localnum + 1);
618 CSQCPlayer_LOD_Apply(this, true);
622 skeleton_loadinfo(this);
623 bool doblend = (this.bone_upperbody >= 0);
624 CSQCPlayer_FallbackFrame_Apply(this);
627 skeleton_from_frames(this, this.csqcmodel_isdead);
631 free_skeleton_from_frames(this);
632 // just in case, clear these (we're animating in frame and frame3)
639 // we know that frame3 and frame4 fields, used by InterpolateAnimation, are left alone - but that is all we know!
640 skeleton_loadinfo(this);
641 bool doblend = (this.bone_upperbody >= 0);
643 if(this == csqcplayer)
645 if(IS_ONGROUND(this))
647 this.anim_prev_pmove_flags = this.flags;
648 if(this.flags & FL_DUCKED)
649 animdecide_setstate(this, this.anim_state | ANIMSTATE_DUCK, false);
650 else if(this.anim_state & ANIMSTATE_DUCK)
651 animdecide_setstate(this, this.anim_state - ANIMSTATE_DUCK, false);
655 tracebox(this.origin + '0 0 1', this.mins, this.maxs, this.origin - '0 0 4', MOVE_NORMAL, this);
656 if(trace_startsolid || trace_fraction < 1)
659 animdecide_load_if_needed(this);
660 animdecide_setimplicitstate(this, onground);
661 animdecide_setframes(this, doblend, anim_frame, anim_frame1time, anim_frame2, anim_frame2time);
663 if(this.anim_saveframe != this.anim_frame || this.anim_saveframe1time != this.anim_frame1time)
664 sf |= CSQCMODEL_PROPERTY_FRAME;
665 if(this.anim_saveframe2 != this.anim_frame2 || this.anim_saveframe2time != this.anim_frame2time)
666 sf |= CSQCMODEL_PROPERTY_FRAME2;
667 this.anim_saveframe = this.anim_frame;
668 this.anim_saveframe1time = this.anim_frame1time;
669 this.anim_saveframe2 = this.anim_frame2;
670 this.anim_saveframe2time = this.anim_frame2time;
671 // Note: we always consider lerpfrac "changed", as it uses fixed values every time anyway.
672 // This ensures that .frame etc. are always written.
673 CSQCModel_InterpolateAnimation_2To4_PreNote(this, sf | CSQCMODEL_PROPERTY_LERPFRAC);
674 this.lerpfrac = (doblend ? 0.5 : 0);
675 this.frame = this.anim_frame;
676 this.frame1time = this.anim_frame1time;
677 this.frame2 = this.anim_frame2;
678 this.frame2time = this.anim_frame2time;
679 CSQCModel_InterpolateAnimation_2To4_Note(this, sf | CSQCMODEL_PROPERTY_LERPFRAC, false);
680 CSQCModel_InterpolateAnimation_2To4_Do(this);
683 skeleton_from_frames(this, this.csqcmodel_isdead);
687 free_skeleton_from_frames(this);
688 // just in case, clear these (we're animating in frame and frame3)
695 CSQCPlayer_LOD_Apply(this, false);
697 CSQCModel_AutoTagIndex_Apply(this);
699 CSQCModel_Effects_Apply(this);
702 void CSQCModel_Hook_PreUpdate(entity this, bool isnew, bool isplayer, bool islocalplayer)
704 // interpolate v_angle
705 this.iflags |= IFLAG_V_ANGLE_X;
706 // revert to values from server
707 CSQCModel_Effects_PreUpdate(this);
708 if(this.isplayermodel)
711 CSQCPlayer_FallbackFrame_PreUpdate(this);
712 CSQCPlayer_ModelAppearance_PreUpdate(this);
716 void CSQCModel_Hook_PostUpdate(entity this, bool isnew, bool isplayer, bool islocalplayer)
718 // is it a player model? (shared state)
719 this.isplayermodel = (substring(this.model, 0, 14) == "models/player/" || substring(this.model, 0, 17) == "models/ok_player/" || (substring(this.model, 0, 16) == "models/monsters/" && (this.entnum >= 1 && this.entnum <= maxclients)));
721 // save values set by server
722 if(this.isplayermodel)
724 CSQCPlayer_ModelAppearance_PostUpdate(this);
726 CSQCPlayer_AnimDecide_PostUpdate(this, isnew);
728 CSQCPlayer_FallbackFrame_PostUpdate(this, isnew);
730 CSQCModel_Effects_PostUpdate(this);