MCPcopy Create free account
hub / github.com/assaultcube/AC / spectatemode

Function spectatemode

source/src/clientgame.cpp:1758–1814  ·  view source on GitHub ↗

set new spect mode

Source from the content-addressed store, hash-verified

1756
1757// set new spect mode
1758void spectatemode(int mode)
1759{
1760 if((player1->state != CS_DEAD && player1->state != CS_SPECTATE && !team_isspect(player1->team)) || (!m_teammode && !team_isspect(player1->team) && servstate.mastermode == MM_MATCH)) return; // during ffa matches only SPECTATORS can spectate
1761 if(mode == player1->spectatemode) return;
1762 if((mode == SM_OVERVIEW || mode == SM_FLY) && smoverviewflyforbidden()) return;
1763 showscores(false);
1764 switch(mode)
1765 {
1766 case SM_DEATHCAM:
1767 case SM_FOLLOW1ST:
1768 case SM_FOLLOW3RD:
1769 case SM_FOLLOW3RD_TRANSPARENT:
1770 {
1771 if(players.length() && updatefollowplayer()) break;
1772 else if (smoverviewflyforbidden()) mode = SM_DEATHCAM;
1773 else mode = SM_FLY;
1774 }
1775 case SM_FLY:
1776 {
1777 if(player1->spectatemode != SM_FLY)
1778 {
1779 playerent *f = getclient(player1->followplayercn);
1780 if(f)
1781 {
1782 player1->o = f->o;
1783 player1->yaw = f->yaw;
1784 player1->pitch = 0.0f;
1785 player1->resetinterp();
1786 physent d = *player1;
1787 d.radius = d.eyeheight = d.maxeyeheight = d.aboveeye = 0.1;
1788 if(collide(&d, false)) // need air around
1789 {
1790 int x = findentity(PLAYERSTART,rnd(ents.length()));
1791 if(x>=0)
1792 {
1793 gotoplayerstart(player1, &ents[x]);
1794 player1->o.z = S((int)player1->o.x, (int)player1->o.y)->floor + player1->maxeyeheight;
1795 entinmap(player1);
1796 }
1797 else
1798 {
1799 spectatemode(SM_OVERVIEW); // fail-safe
1800 }
1801 }
1802 }
1803 else entinmap(player1); // or drop 'em at a random place
1804 addmsg(SV_SPECTCN, "ri", (player1->followplayercn = FPCN_FLY));
1805 }
1806 break;
1807 }
1808 case SM_OVERVIEW:
1809 addmsg(SV_SPECTCN, "ri", (player1->followplayercn = FPCN_OVERVIEW));
1810 break;
1811 default: break;
1812 }
1813 player1->spectatemode = mode;
1814}
1815COMMANDF(spectatemode, "i", (int *mode) { spectatemode(*mode); });

Callers 6

~playerentMethod · 0.85
parsemessagesFunction · 0.85
toggleeditFunction · 0.85
deathstateFunction · 0.85
clientgame.cppFile · 0.85
togglespectFunction · 0.85

Calls 11

smoverviewflyforbiddenFunction · 0.85
showscoresFunction · 0.85
updatefollowplayerFunction · 0.85
getclientFunction · 0.85
collideFunction · 0.85
findentityFunction · 0.85
gotoplayerstartFunction · 0.85
entinmapFunction · 0.85
addmsgFunction · 0.85
resetinterpMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected