X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_client.qc;h=0f22be6d85c053bdb590b6170697b1e178eb4439;hb=e228cc51205348e013470f2b70b16f87812a3f0e;hp=b3d326264e0a2a702843ae0b874714d6eb11f0cf;hpb=bd9b670cca7d94ed61720b5d5231bef96f00ef52;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index b3d326264..0f22be6d8 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -112,7 +112,7 @@ void spawnfunc_info_player_deathmatch (void) void spawnpoint_use() { - if(teams_matter) + if(teamplay) if(have_team_spawns > 0) { self.team = activator.team; @@ -333,7 +333,7 @@ entity SelectSpawnPoint (float anypoint) { // we request a spawn for a team, and we have team // spawns, but that team has no spawns? - if(have_team_spawns[0]) + if(have_team_spawns_forteam[0]) // try noteam spawns teamcheck = 0; else @@ -343,7 +343,7 @@ entity SelectSpawnPoint (float anypoint) else teamcheck = self.team; // MUST be team } - else if(have_team_spawns == 0 && have_team_spawns[0]) + else if(have_team_spawns == 0 && have_team_spawns_forteam[0]) teamcheck = 0; // MUST be noteam else teamcheck = -1; @@ -614,6 +614,9 @@ void PutObserverInServer (void) DropAllRunes(self); MUTATOR_CALLHOOK(MakePlayerObserver); + if (g_minstagib) + minstagib_stop_countdown(); + Portal_ClearAll(self); if(self.alivetime) @@ -748,7 +751,7 @@ void FixPlayermodel() if(autocvar_sv_defaultcharacter == 1) { defaultskin = 0; - if(teams_matter) + if(teamplay) { string s; s = Team_ColorNameLowerCase(self.team); @@ -804,7 +807,7 @@ void FixPlayermodel() if(chmdl || oldskin != self.skinindex) self.species = player_getspecies(); // model or skin has changed - if(!teams_matter) + if(!teamplay) if(strlen(autocvar_sv_defaultplayercolors)) if(self.clientcolors != stof(autocvar_sv_defaultplayercolors)) setcolor(self, stof(autocvar_sv_defaultplayercolors)); @@ -1079,11 +1082,16 @@ void PutClientInServer (void) if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars self.weapon_load[j] = cvar(strcat("g_balance_", e.netname, "_reload_ammo")); } + self.weapon_forbidchange = FALSE; oldself = self; self = spot; activator = oldself; + string s; + s = self.target; + self.target = string_null; SUB_UseTargets(); + self.target = s; activator = world; self = oldself; @@ -1133,9 +1141,10 @@ float ClientInit_SendEntity(entity to, float sf) WriteCoord(MSG_ENTITY, self.ebouncefactor); // g_balance_grenadelauncher_bouncefactor WriteCoord(MSG_ENTITY, self.ebouncestop); // g_balance_grenadelauncher_bouncestop WriteByte(MSG_ENTITY, autocvar_g_balance_nex_secondary); // client has to know if it should zoom or not - WriteByte(MSG_ENTITY, autocvar_g_balance_sniperrifle_secondary); // client has to know if it should zoom or not + WriteByte(MSG_ENTITY, autocvar_g_balance_rifle_secondary); // client has to know if it should zoom or not WriteByte(MSG_ENTITY, serverflags); // client has to know if it should zoom or not WriteByte(MSG_ENTITY, autocvar_g_balance_minelayer_limit); // minelayer max mines + WriteByte(MSG_ENTITY, autocvar_g_balance_hagar_secondary_load_max); // hagar max loadable rockets WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange); return TRUE; } @@ -1297,17 +1306,18 @@ void KillIndicator_Think() { if(self.cnt <= 10) AnnounceTo(self.owner, strcat(ftos(self.cnt), "")); + // TODO: Send_CSQC_Centerprint_Generic only once if(self.owner.killindicator_teamchange) { if(self.owner.killindicator_teamchange == -1) - centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_TEAMCHANGE, "Changing team in %d seconds", 1, self.cnt); else if(self.owner.killindicator_teamchange == -2) - centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_TEAMCHANGE, "Spectating in %d seconds", 1, self.cnt); else - centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_TEAMCHANGE, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in %d seconds"), 1, self.cnt); } else - centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_KILL, "^1Suicide in %d seconds", 1, self.cnt); } self.nextthink = time + 1; self.cnt -= 1; @@ -1416,7 +1426,7 @@ void CTS_ClientKill (entity e) // silent version of ClientKill, used when player void DoTeamChange(float destteam) { float t, c0; - if(!teams_matter) + if(!teamplay) { if(destteam >= 0) SetPlayerColors(self, destteam); @@ -1523,6 +1533,7 @@ Called when a client connects to the server string ColoredTeamName(float t); void DecodeLevelParms (void); //void dom_player_join_team(entity pl); +void set_dom_state(entity e); void ClientConnect (void) { float t; @@ -1606,7 +1617,7 @@ void ClientConnect (void) else self.team_forced = 0; - if(!teams_matter) + if(!teamplay) if(self.team_forced > 0) self.team_forced = 0; @@ -1615,7 +1626,7 @@ void ClientConnect (void) if((autocvar_sv_spectate == 1 && !g_lms) || autocvar_g_campaign || self.team_forced < 0) { self.classname = "observer"; } else { - if(teams_matter) + if(teamplay) { if(autocvar_g_balance_teams || autocvar_g_balance_teams_force) { @@ -1636,6 +1647,9 @@ void ClientConnect (void) self.playerid = (playerid_last = playerid_last + 1); + if(clienttype(self) == CLIENTTYPE_BOT) + PlayerStats_AddPlayer(self); + if(autocvar_sv_eventlog) GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", ((clienttype(self) == CLIENTTYPE_REAL) ? self.netaddress : "bot"), ":", self.netname)); @@ -1652,8 +1666,6 @@ void ClientConnect (void) bprint("\n"); - self.welcomemessage_time = 0; - stuffcmd(self, strcat(clientstuff, "\n")); stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n")); stuffcmd(self, "cl_particles_reloadeffects\n"); @@ -1676,7 +1688,7 @@ void ClientConnect (void) GetCvars(0); // notify about available teams - if(teams_matter) + if(teamplay) { CheckAllowedTeams(self); t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8; @@ -1698,8 +1710,7 @@ void ClientConnect (void) ctf_clientconnect(); }*/ - if(teams_matter || radar_showennemies) - attach_entcs(); + attach_entcs(); bot_relinkplayerlist(); @@ -1764,9 +1775,13 @@ void ClientConnect (void) else if(autocvar_sv_teamnagger && !(autocvar_bot_vs_human && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca send_CSQC_teamnagger(); + if (g_domination) + set_dom_state(self); + CheatInitClient(); - PlayerStats_AddPlayer(self); + if(!autocvar_g_campaign) + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), autocvar_welcome_message_time, 0); } /* @@ -1777,7 +1792,6 @@ Called when a client disconnects from the server ============= */ .entity chatbubbleentity; -.entity teambubbleentity; void ReadyCount(); void ClientDisconnect (void) { @@ -1831,9 +1845,6 @@ void ClientDisconnect (void) if (self.chatbubbleentity) remove (self.chatbubbleentity); - if (self.teambubbleentity) - remove (self.teambubbleentity); - if (self.killindicator) remove (self.killindicator); @@ -1914,52 +1925,6 @@ void UpdateChatBubble() } -void TeamBubbleThink() -{ - self.nextthink = time; - if (!self.owner.modelindex || self.owner.teambubbleentity != self) - { - if(self.owner) // but why can that ever be world? - self.owner.teambubbleentity = world; - remove(self); - return; - } -// setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1'); // bandwidth hog. setattachment does this now - if (self.owner.BUTTON_CHAT || self.owner.deadflag || self.owner.killindicator) - self.model = ""; - else - self.model = self.mdl; - -}; - -float TeamBubble_customizeentityforclient() -{ - return (self.owner != other && self.owner.team == other.team && other.killcount > -666); -} - -void UpdateTeamBubble() -{ - if (!self.modelindex || !teams_matter) - return; - // spawn a teambubble entity if needed - if (!self.teambubbleentity && teams_matter) - { - self.teambubbleentity = spawn(); - self.teambubbleentity.owner = self; - self.teambubbleentity.exteriormodeltoclient = self; - self.teambubbleentity.think = TeamBubbleThink; - self.teambubbleentity.nextthink = time; - setmodel(self.teambubbleentity, "models/misc/teambubble.spr"); // precision set below -// setorigin(self.teambubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1'); - setorigin(self.teambubbleentity, '0 0 15' + self.maxs_z * '0 0 1'); - setattachment(self.teambubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth - self.teambubbleentity.mdl = self.teambubbleentity.model; - self.teambubbleentity.model = self.teambubbleentity.mdl; - self.teambubbleentity.customizeentityforclient = TeamBubble_customizeentityforclient; - self.teambubbleentity.effects = EF_LOWPRECISION; - } -} - // LordHavoc: this hack will be removed when proper _pants/_shirt layers are // added to the model skins /*void UpdateColorModHack() @@ -1967,7 +1932,7 @@ void UpdateTeamBubble() local float c; c = self.clientcolors & 15; // LordHavoc: only bothering to support white, green, red, yellow, blue - if (!teams_matter) self.colormod = '0 0 0'; + if (!teamplay) self.colormod = '0 0 0'; else if (c == 0) self.colormod = '1.00 1.00 1.00'; else if (c == 3) self.colormod = '0.10 1.73 0.10'; else if (c == 4) self.colormod = '1.73 0.10 0.10'; @@ -2044,7 +2009,7 @@ string getTimeoutText(float addOneSecond) { else { retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n"); //don't show messages like "Timeout ends in 0 seconds"... - if (remainingTimeoutTime > 0) + if ((remainingTimeoutTime) > 0) return retStr; else return ""; @@ -2384,6 +2349,7 @@ void SpectateCopy(entity spectatee) { self.weapon = spectatee.weapon; self.nex_charge = spectatee.nex_charge; self.nex_chargepool_ammo = spectatee.nex_chargepool_ammo; + self.hagar_load = spectatee.hagar_load; self.minelayer_mines = spectatee.minelayer_mines; self.punchangle = spectatee.punchangle; self.view_ofs = spectatee.view_ofs; @@ -2471,7 +2437,7 @@ void ShowRespawnCountdown() void LeaveSpectatorMode() { if(nJoinAllowed(1)) { - if(!teams_matter || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) { + if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) { self.classname = "player"; if(autocvar_g_campaign || autocvar_g_balance_teams || autocvar_g_balance_teams_force) @@ -2486,7 +2452,7 @@ void LeaveSpectatorMode() bprint ("^4", self.netname, "^4 is playing now\n"); if(!autocvar_g_campaign) - centerprint(self,""); // clear MOTD + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, "", 1, 0); // clear MOTD return; } else { @@ -2499,7 +2465,7 @@ void LeaveSpectatorMode() } else { //player may not join because of g_maxplayers is set - centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT); + centerprint(self, PREVENT_JOIN_TEXT); } } @@ -2571,7 +2537,6 @@ void ObserverThink() } } } - PrintWelcomeMessage(self); } void SpectatorThink() @@ -2611,10 +2576,22 @@ void SpectatorThink() } } - PrintWelcomeMessage(self); self.flags |= FL_CLIENT | FL_NOTARGET; } +float ctf_usekey(); +void PlayerUseKey() +{ + if(self.classname != "player") + return; + + // a use key was pressed; call handlers + if(ctf_usekey()) + return; + + MUTATOR_CALLHOOK(PlayerUseKey); +} + .float touchexplode_time; /* @@ -2624,9 +2601,11 @@ PlayerPreThink Called every frame for each client before the physics are run ============= */ +.float usekeypressed; void() ctf_setstatus; void() nexball_setstatus; .float items_added; +.float motd_actived_time; // used for both motd and campaign_message void PlayerPreThink (void) { WarpZone_PlayerPhysics_FixVAngle(); @@ -2701,25 +2680,59 @@ void PlayerPreThink (void) MUTATOR_CALLHOOK(PlayerPreThink); + if(self.BUTTON_USE && !self.usekeypressed) + PlayerUseKey(); + self.usekeypressed = self.BUTTON_USE; + + if (self.motd_actived_time == 0) { + if (autocvar_g_campaign) { + if (self.classname == "player" && self.BUTTON_INFO) { + self.motd_actived_time = time; + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, campaign_message, 999, 0); + } + } else { + if ((self.classname == "player" || time - self.jointime > autocvar_welcome_message_time) && self.BUTTON_INFO) { + self.motd_actived_time = time; + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), 999, 0); + } + } + } else { // showing MOTD or campaign message + if (autocvar_g_campaign) { + if (self.classname == "player") { + if (self.BUTTON_INFO) + self.motd_actived_time = time; + else if (time - self.motd_actived_time > 2) { // hide it some seconds after BUTTON_INFO has been released + self.motd_actived_time = 0; + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, "", 1, 0); + } + } + } else { + if (self.classname == "player" || (time - self.jointime) > autocvar_welcome_message_time) { + if (self.BUTTON_INFO) + self.motd_actived_time = time; + else if (time - self.motd_actived_time > 2) { // hide it some seconds after BUTTON_INFO has been released + self.motd_actived_time = 0; + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, "", 1, 0); + } + } + } + } + if(self.classname == "player") { // if(self.netname == "Wazat") // bprint(self.classname, "\n"); CheckRules_Player(); - PrintWelcomeMessage(self); - if (intermission_running) { IntermissionThink (); // otherwise a button could be missed between return; // the think tics } - if(frametime > 0) // don't do this in cl_movement frames, just in server ticks - UpdateSelectedPlayer(); - //don't allow the player to turn around while game is paused! if(timeoutStatus == 2) { + // FIXME turn this into CSQC stuff self.v_angle = self.lastV_angle; self.angles = self.lastV_angle; self.fixangle = TRUE; @@ -2743,10 +2756,32 @@ void PlayerPreThink (void) self.glowmod_z = -1; } else + { + // set weapon and player glowmod self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2; + + if(self.weapon == WEP_NEX && autocvar_g_balance_nex_charge) + { + self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit); + self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit); + self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit); + + if(self.nex_charge > autocvar_g_balance_nex_charge_animlimit) + { + self.weaponentity_glowmod_x = self.weaponentity_glowmod_x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit); + self.weaponentity_glowmod_y = self.weaponentity_glowmod_y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit); + self.weaponentity_glowmod_z = self.weaponentity_glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit); + } + } + else + self.weaponentity_glowmod = self.glowmod; + } player_powerups(); } + if (g_minstagib) + minstagib_ammocheck(); + if (self.deadflag != DEAD_NO) { float button_pressed, force_respawn; @@ -2794,6 +2829,8 @@ void PlayerPreThink (void) } return; } + // FIXME from now on self.deadflag is always 0 (and self.health is never < 1) + // so (self.deadflag == DEAD_NO) is always true in the code below if(g_touchexplode) if(time > self.touchexplode_time) @@ -2905,9 +2942,6 @@ void PlayerPreThink (void) if(frametime) player_anim(); - if (g_minstagib) - minstagib_ammocheck(); - if(g_ctf) ctf_setstatus(); @@ -2928,7 +2962,7 @@ void PlayerPreThink (void) } if(!zoomstate_set) - SetZoomState(self.BUTTON_ZOOM || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_SNIPERRIFLE && autocvar_g_balance_sniperrifle_secondary == 0)); + SetZoomState(self.BUTTON_ZOOM || self.BUTTON_ZOOMSCRIPT || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_RIFLE && autocvar_g_balance_rifle_secondary == 0)); float oldspectatee_status; oldspectatee_status = self.spectatee_status; @@ -3046,13 +3080,14 @@ void PlayerPostThink (void) { if(timeleft != self.idlekick_lasttimeleft) { - centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "...")); + // TODO: send this msg only once + Send_CSQC_Centerprint_Generic(self, CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in %d seconds...", 1, timeleft); AnnounceTo(self, strcat(ftos(timeleft), "")); } } else { - centerprint_expire(self, CENTERPRIO_IDLEKICK); + Send_CSQC_Centerprint_Generic(self, CPID_DISCONNECT_IDLING, "", 1, timeleft); } self.idlekick_lasttimeleft = timeleft; } @@ -3069,7 +3104,6 @@ void PlayerPostThink (void) if(self.classname == "player") { CheckRules_Player(); UpdateChatBubble(); - UpdateTeamBubble(); if (self.impulse) ImpulseCommands(); if (intermission_running)