Initial sauer
[SauerbratenRemote.git] / src / fpsgame / fpsrender.h
blob6953dcec196f6233a43d356a12e8917c7794169e
2 struct fpsrender
3 {
4 fpsclient &cl;
6 fpsrender(fpsclient &_cl) : cl(_cl) {}
8 vector<fpsent *> bestplayers;
9 vector<const char *> bestteams;
11 IVARP(ogro, 0, 0, 1);
13 void renderplayer(fpsent *d, const char *mdlname)
15 int lastaction = d->lastaction, attack = d->gunselect==GUN_FIST ? ANIM_PUNCH : ANIM_SHOOT, delay = ogro() ? 300 : cl.ws.reloadtime(d->gunselect)+50;
16 if(cl.intermission && d->state!=CS_DEAD)
18 lastaction = cl.lastmillis;
19 attack = ANIM_LOSE|ANIM_LOOP;
20 delay = 1000;
21 int gamemode = cl.gamemode;
22 if(m_teammode) loopv(bestteams) { if(!strcmp(bestteams[i], d->team)) { attack = ANIM_WIN|ANIM_LOOP; break; } }
23 else if(bestplayers.find(d)>=0) attack = ANIM_WIN|ANIM_LOOP;
25 else if(d->state==CS_ALIVE && d->lasttaunt && cl.lastmillis-d->lasttaunt<1000 && cl.lastmillis-d->lastaction>delay)
27 lastaction = d->lasttaunt;
28 attack = ANIM_TAUNT;
29 delay = 1000;
31 modelattach a[4] = { { NULL }, { NULL }, { NULL }, { NULL } };
32 static const char *vweps[] = {"vwep/fist", "vwep/shotg", "vwep/chaing", "vwep/rocket", "vwep/rifle", "vwep/gl", "vwep/pistol"};
33 int ai = 0;
34 if((!ogro() || d->gunselect!=GUN_FIST) && d->gunselect<=GUN_PISTOL)
36 a[ai].name = ogro() ? "monster/ogro/vwep" : vweps[d->gunselect];
37 a[ai].type = MDL_ATTACH_VWEP;
38 a[ai].anim = ANIM_VWEP|ANIM_LOOP;
39 a[ai].basetime = 0;
40 ai++;
42 if(!ogro() && d->state==CS_ALIVE)
44 if(d->quadmillis)
46 a[ai].name = "quadspheres";
47 a[ai].type = MDL_ATTACH_POWERUP;
48 a[ai].anim = ANIM_POWERUP|ANIM_LOOP;
49 a[ai].basetime = 0;
50 ai++;
52 if(d->armour)
54 a[ai].name = d->armourtype==A_GREEN ? "shield/green" : (d->armourtype==A_YELLOW ? "shield/yellow" : NULL);
55 a[ai].type = MDL_ATTACH_SHIELD;
56 a[ai].anim = ANIM_SHIELD|ANIM_LOOP;
57 a[ai].basetime = 0;
58 ai++;
61 renderclient(d, mdlname, a[0].name ? a : NULL, attack, delay, lastaction, cl.intermission ? 0 : d->lastpain);
62 #if 0
63 if(d->state!=CS_DEAD && d->quadmillis)
65 vec color(1, 1, 1), dir(0, 0, 1);
66 rendermodel(color, dir, "quadrings", ANIM_MAPMODEL|ANIM_LOOP, 0, 0, vec(d->o).sub(vec(0, 0, d->eyeheight/2)), 360*cl.lastmillis/1000.0f, 0, 0, 0, NULL, MDL_DYNSHADOW | MDL_CULL_VFC | MDL_CULL_DIST);
68 #endif
71 IVARP(teamskins, 0, 0, 1);
73 void rendergame(int gamemode)
75 if(cl.intermission)
77 if(m_teammode) { bestteams.setsize(0); cl.sb.bestteams(bestteams); }
78 else { bestplayers.setsize(0); cl.sb.bestplayers(bestplayers); }
81 startmodelbatches();
83 const char *mdlnames[3] =
85 ogro() ? "monster/ogro" : "ironsnout",
86 ogro() ? "monster/ogro/blue" : "ironsnout/blue",
87 ogro() ? "monster/ogro/red" : "ironsnout/red"
90 fpsent *d;
91 loopv(cl.players) if((d = cl.players[i]) && d->state!=CS_SPECTATOR && d->state!=CS_SPAWNING)
93 int mdl = 0;
94 if(m_assassin) mdl = cl.asc.targets.find(d)>=0 ? 2 : (cl.asc.hunters.find(d)>=0 ? 0 : 1);
95 else if(teamskins() || m_teammode) mdl = isteam(cl.player1->team, d->team) ? 1 : 2;
96 if(d->state!=CS_DEAD || d->superdamage<50) renderplayer(d, mdlnames[mdl]);
97 s_strcpy(d->info, cl.colorname(d, NULL, "@"));
98 if(d->maxhealth>100) { s_sprintfd(sn)(" +%d", d->maxhealth-100); s_strcat(d->info, sn); }
99 if(d->state!=CS_DEAD) particle_text(d->abovehead(), d->info, mdl ? (mdl==1 ? 16 : 13) : 11, 1);
101 if(isthirdperson()) renderplayer(cl.player1, teamskins() || m_teamskins ? mdlnames[1] : mdlnames[0]);
103 cl.ms.monsterrender();
104 cl.mo.render();
105 cl.et.renderentities();
106 cl.ws.renderprojectiles();
107 if(m_capture) cl.cpc.renderbases();
109 endmodelbatches();