X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fcl_client.qc;h=eca3ad9fd69755e9f50e240400ea232a973df46b;hb=2bf749f4895306259c9090c5219027264da91220;hp=c0b7a5f8306e9097d18d31ac4ae59338f138e510;hpb=8adb3c12036016d9e14faccb35236c09e47d69d8;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index c0b7a5f8..eca3ad9f 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -406,6 +406,7 @@ string CheckPlayerModel(string plyermodel) { { if(substring(plyermodel,-4,4) != ".zym") if(substring(plyermodel,-4,4) != ".dpm") + if(substring(plyermodel,-4,4) != ".iqm") if(substring(plyermodel,-4,4) != ".md3") if(substring(plyermodel,-4,4) != ".psk") return FallbackPlayerModel; @@ -417,11 +418,12 @@ string CheckPlayerModel(string plyermodel) { return plyermodel; } -void setmodel_apply(string modelname) +void setmodel_apply(string modelname, float reset_anims) { precache_model(modelname); setmodel(self, modelname); // players have high precision - player_setupanimsformodel(); + if(reset_anims) + player_setupanimsformodel(); } string setmodel_state() @@ -433,8 +435,16 @@ string setmodel_state() newmodel_name = substring(self.playermodel, 0, strlen(self.playermodel) - 4); newmodel_extension = substring(self.playermodel, strlen(self.playermodel) - 4, 4); - if(self.stomach_load) - applymodel = strcat(newmodel_name, "_state", ftos(floor(self.stomach_load)), newmodel_extension); + float vore_state; + if(self.stomach_load > self.stomach_maxload * 0.6) + vore_state = 3; + else if(self.stomach_load > self.stomach_maxload * 0.3) + vore_state = 2; + else if(self.stomach_load) + vore_state = 1; + + if(vore_state) + applymodel = strcat(newmodel_name, "_state", ftos(vore_state), newmodel_extension); else applymodel = self.playermodel; @@ -457,7 +467,7 @@ void Client_setmodel(string applymodel) applymodel = CheckPlayerModel(applymodel); // this is never "", so no endless loop m1 = self.mins; m2 = self.maxs; - setmodel_apply(applymodel); + setmodel_apply(applymodel, FALSE); setsize (self, m1, m2); } @@ -469,7 +479,7 @@ void Client_uncustomizeentityforclient() float Client_customizeentityforclient() { entity modelsource; - string applymodel; + string stomachmodel; if(self.modelindex == 0) return TRUE; @@ -511,27 +521,35 @@ float Client_customizeentityforclient() // now change the predator's player model into a stomach model for the prey // in other words, when a player is swallowed by another player, the predator becomes an inward stomach model so the prey can see theirself in the stomach // this is only visible to the prey however, otherwise players would appear as a floating stomach to everyone (ewww) + stomachmodel = strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_stomach.md3"); // 4 is the extension length - // don't do this if we have chase_active enabled, as we'd be seeing a floating stomach from third person view - if(other.cvar_chase_active > 0 || other.classname == "observer") // the classname check prevents a bug - { - Client_setmodel(setmodel_state()); - if not(self.predator.classname == "player" || self.fakeprey) - self.alpha = default_player_alpha; - return TRUE; - } - if(other.spectatee_status) + float chase; + chase = other.cvar_chase_active; + + if(other.spectatee_status && other.spectatee_status == num_for_edict(other.enemy)) other = other.enemy; // also do this for the player we are spectating + + // don't do this if we have chase_active enabled, as we'd be seeing a floating stomach from third person view + if not(chase || other.classname == "observer") // the observer check prevents a bug if(other.predator == self || other.fakepredator == self) { - applymodel = strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_stomach.md3"); // 4 is the extension length - Client_setmodel(applymodel); + Client_setmodel(stomachmodel); + self.effects |= EF_NODEPTHTEST; // don't hide behind walls self.alpha = other.cvar_cl_vore_stomachmodel; return TRUE; } + Client_setmodel(setmodel_state()); - if not(self.predator.classname == "player" || self.fakeprey) + self.effects &~= EF_NODEPTHTEST; + if not(self.stat_eaten || self.fakeprey) self.alpha = default_player_alpha; + else if(cvar("g_vore_neighborprey_distance") && !self.fakeprey && (self.predator == other.predator || self.predator == other.fakepredator) && !(chase || other.classname == "observer")) + { + self.alpha = default_player_alpha; // allow seeing neighboring prey + self.effects |= EF_NODEPTHTEST; // don't hide behind the stomach's own EF_NODEPTHTEST + } + else + self.alpha = -1; // hide prey return TRUE; } @@ -725,7 +743,7 @@ void FixPlayermodel() { m1 = self.mins; m2 = self.maxs; - setmodel_apply (defaultmodel); + setmodel_apply (defaultmodel, TRUE); setsize (self, m1, m2); chmdl = TRUE; } @@ -738,7 +756,7 @@ void FixPlayermodel() self.playermodel = CheckPlayerModel(self.playermodel); // this is never "", so no endless loop m1 = self.mins; m2 = self.maxs; - setmodel_apply (self.playermodel); + setmodel_apply (self.playermodel, TRUE); setsize (self, m1, m2); chmdl = TRUE; } @@ -828,6 +846,10 @@ void PutClientInServer (void) RemoveGrabber(self); // Wazat's Grabber + Vore_DeadPrey_Detach(self); + self.fakeprey = FALSE; // clear the fakeprey status + self.swallow_progress_pred = self.swallow_progress_prey = 0; + self.classname = "player"; self.wasplayer = TRUE; self.iscreature = TRUE; @@ -922,8 +944,6 @@ void PutClientInServer (void) SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient); - Vore_DeadPrey_Detach(self); - self.model = ""; FixPlayermodel(); @@ -980,6 +1000,7 @@ void PutClientInServer (void) if (cvar("g_spawnsound")) sound (self, CHAN_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM); + pointparticles(particleeffectnum("player_respawn"), self.origin, '0 0 0', 1); if(g_assault) { if(self.team == assault_attacker_team) @@ -1027,12 +1048,26 @@ float ClientInit_SendEntity(entity to, float sf) WriteString(MSG_ENTITY, world.fog); else WriteString(MSG_ENTITY, ""); - WriteCoord(MSG_ENTITY, cvar("g_campaign")); + WriteShort(MSG_ENTITY, cvar("g_campaign")); WriteByte(MSG_ENTITY, cvar("g_balance_armor_blockpercent") * 255.0); WriteByte(MSG_ENTITY, cvar("g_balance_weaponswitchdelay") * 255.0); - WriteCoord(MSG_ENTITY, cvar("g_vore")); - WriteCoord(MSG_ENTITY, cvar("g_balance_vore_swallow_limit")); + WriteShort(MSG_ENTITY, cvar("g_vore")); + WriteShort(MSG_ENTITY, cvar("g_healthsize")); + WriteShort(MSG_ENTITY, cvar("g_healthsize_min")); + WriteShort(MSG_ENTITY, cvar("g_healthsize_max")); + + // tell the client if this server uses armor + float armor_max; + if(cvar("g_balance_armor_start") || (cvar("g_lms") && cvar("g_lms_start_armor")) /*|| (inWarmupStage && cvar("g_warmup_start_armor"))*/ || cvar("g_balance_armor_regen") || cvar("g_balance_armor_regenlinear")) + armor_max = cvar("g_balance_armor_limit"); + WriteCoord(MSG_ENTITY, armor_max); + + float teamheal_max; + if(cvar("g_vore") && cvar("g_vore_teamvore") && cvar("g_balance_vore_teamheal")) + teamheal_max = cvar("g_balance_vore_teamheal_stable"); + WriteCoord(MSG_ENTITY, teamheal_max); + return TRUE; } @@ -1087,6 +1122,7 @@ Called when a client types 'kill' in the console ============= */ +.float clientkill_nexttime; void ClientKill_Now_TeamChange() { if(self.killindicator_teamchange == -1) @@ -1094,24 +1130,32 @@ void ClientKill_Now_TeamChange() self.team = -1; JoinBestTeam( self, FALSE, FALSE ); } + else if(self.killindicator_teamchange == -2) + { + if(g_ca) + self.caplayer = 0; + if(blockSpectators) + sprint(self, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n")); + PutObserverInServer(); + } else SV_ChangeTeam(self.killindicator_teamchange - 1); } void ClientKill_Now() -{ +{ + if(self.killindicator && !wasfreed(self.killindicator)) + remove(self.killindicator); + + self.killindicator = world; + if(self.killindicator_teamchange) ClientKill_Now_TeamChange(); // in any case: Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0'); - if(self.killindicator) - { - dprint("Cleaned up after a leaked kill indicator.\n"); - remove(self.killindicator); - self.killindicator = world; - } + // now I am sure the player IS dead } void KillIndicator_Think() { @@ -1128,6 +1172,11 @@ void KillIndicator_Think() ClientKill_Now(); // no oldself needed return; } + else if(g_cts && self.health == 1) // health == 1 means that it's silent + { + self.nextthink = time + 1; + self.cnt -= 1; + } else { if(self.cnt <= 10) @@ -1140,6 +1189,8 @@ void KillIndicator_Think() { if(self.owner.killindicator_teamchange == -1) centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds")); + else if(self.owner.killindicator_teamchange == -2) + centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds")); else centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds")); } @@ -1151,19 +1202,34 @@ void KillIndicator_Think() } } -void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto +void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec { float killtime; entity e; killtime = cvar("g_balance_kill_delay"); - if(g_race_qualifying) + if(g_race_qualifying || g_cts) killtime = 0; + if(g_cts && self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill + { + remove(self.killindicator); + self.killindicator = world; + + ClientKill_Now(); // allow instant kill in this case + return; + } + self.killindicator_teamchange = targetteam; - if(!self.killindicator) + if(!self.killindicator) { + if(self.modelindex && self.deadflag == DEAD_NO) + { + killtime = max(killtime, self.clientkill_nexttime - time); + self.clientkill_nexttime = time + killtime + cvar("g_balance_kill_antispam"); + } + if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO) { ClientKill_Now(); @@ -1179,7 +1245,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto self.killindicator.nextthink = time + (self.lip) * 0.05; self.killindicator.cnt = ceil(killtime); self.killindicator.count = bound(0, ceil(killtime), 10); - sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n")); + //sprint(self, strcat("^1You'll be dead in ", ftos(self.killindicator.cnt), " seconds\n")); for(e = world; (e = find(e, classname, "body")) != world; ) { @@ -1199,22 +1265,42 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto } if(self.killindicator) { - if(targetteam) - self.killindicator.colormod = TeamColor(targetteam); - else + if(targetteam == 0) // just die self.killindicator.colormod = '0 0 0'; + else if(targetteam == -1) // auto + self.killindicator.colormod = '0 1 0'; + else if(targetteam == -2) // spectate + self.killindicator.colormod = '0.5 0.5 0.5'; + else + self.killindicator.colormod = TeamColor(targetteam); } } void ClientKill (void) { - ClientKill_TeamChange(0); + if((g_arena || g_ca) && ((champion && champion.classname == "player" && player_count > 1) || player_count == 1)) // don't allow a kill in this case either + { + // do nothing + } + else + ClientKill_TeamChange(0); +} + +void CTS_ClientKill (entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed +{ + e.killindicator = spawn(); + e.killindicator.owner = e; + e.killindicator.think = KillIndicator_Think; + e.killindicator.nextthink = time + (e.lip) * 0.05; + e.killindicator.cnt = ceil(cvar("g_cts_finish_kill_delay")); + e.killindicator.health = 1; // this is used to indicate that it should be silent + e.lip = 0; } void DoTeamChange(float destteam) { float t, c0; - if(!teams_matter) + if(!teamplay) { if(destteam >= 0) SetPlayerColors(self, destteam); @@ -1434,8 +1520,7 @@ void ClientConnect (void) ctf_clientconnect(); }*/ - if(teams_matter || radar_showennemies) - attach_entcs(); + attach_entcs(); bot_relinkplayerlist(); @@ -1516,7 +1601,6 @@ Called when a client disconnects from the server ============= */ .entity chatbubbleentity; -.entity teambubbleentity; void ReadyCount(); void ClientDisconnect (void) { @@ -1564,9 +1648,6 @@ void ClientDisconnect (void) if (self.chatbubbleentity) remove (self.chatbubbleentity); - if (self.teambubbleentity) - remove (self.teambubbleentity); - if (self.killindicator) remove (self.killindicator); @@ -1611,7 +1692,7 @@ void ChatBubbleThink() remove(self); return; } - if ((self.owner.BUTTON_CHAT && !self.owner.deadflag && self.owner.predator.classname != "player" && self.owner.fakepredator.classname != "player") + if ((self.owner.BUTTON_CHAT && !self.owner.deadflag && !self.owner.stat_eaten && self.owner.fakepredator.classname != "player") #ifdef TETRIS || self.owner.tetris_on #endif @@ -1643,57 +1724,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.owner.predator.classname == "player" || self.owner.fakepredator.classname == "player") - self.model = ""; - else - { - if(cvar("g_balance_vore_teamheal") && cvar("g_vore_teamvore")) - if(self.owner.health < cvar("g_balance_vore_teamheal_stable")) - setmodel(self, "models/misc/teambubbleheal.spr"); // indicate that this player can be teamhealed - else - setmodel(self, "models/misc/teambubble.spr"); - } -}; - -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() @@ -1710,10 +1740,31 @@ void UpdateTeamBubble() else self.colormod = '1 1 1'; };*/ +.float oldcolormap; void respawn(void) { + if(self.alpha >= 0 && self.modelindex != 0 && cvar("g_respawn_ghosts")) + { + self.solid = SOLID_NOT; + self.takedamage = DAMAGE_NO; + self.movetype = MOVETYPE_FLY; + self.velocity = '0 0 1' * cvar("g_respawn_ghosts_speed"); + self.avelocity = randomvec() * cvar("g_respawn_ghosts_speed") * 3 - randomvec() * cvar("g_respawn_ghosts_speed") * 3; + self.effects |= EF_ADDITIVE; + self.oldcolormap = self.colormap; + self.colormap = 512; + pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1); + if(cvar("g_respawn_ghosts_maxtime")) + SUB_SetFade (self, time + cvar("g_respawn_ghosts_maxtime") / 2 + random () * (cvar("g_respawn_ghosts_maxtime") - cvar("g_respawn_ghosts_maxtime") / 2), 1.5); + } + CopyBody(1); self.effects |= EF_NODRAW; // prevent another CopyBody + if(self.oldcolormap) + { + self.colormap = self.oldcolormap; + self.oldcolormap = 0; + } PutClientInServer(); } @@ -1932,8 +1983,8 @@ void player_regen (void) if (!g_ca && (!g_lms || cvar("g_lms_regenerate"))) { - self.armorvalue = CalcRotRegen(self.armorvalue, mina, cvar("g_balance_armor_regen"), cvar("g_balance_armor_regenlinear"), regen_mod * frametime * (time > self.pauseregenarmor_finished), maxa, cvar("g_balance_armor_rot"), cvar("g_balance_armor_rotlinear"), rot_mod * frametime * (time > self.pauserotarmor_finished), limita, "misc/armor_regen.ogg"); - self.health = CalcRotRegen(self.health, minh, cvar("g_balance_health_regen"), cvar("g_balance_health_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished), maxh, cvar("g_balance_health_rot"), cvar("g_balance_health_rotlinear"), rot_mod * frametime * (time > self.pauserothealth_finished), limith, "misc/health_regen.ogg"); + self.armorvalue = CalcRotRegen(self.armorvalue, mina, cvar("g_balance_armor_regen"), cvar("g_balance_armor_regenlinear"), regen_mod * frametime * (time > self.pauseregenarmor_finished), maxa, cvar("g_balance_armor_rot"), cvar("g_balance_armor_rotlinear"), rot_mod * frametime * (time > self.pauserotarmor_finished), limita, "misc/armor_regen.wav"); + self.health = CalcRotRegen(self.health, minh, cvar("g_balance_health_regen"), cvar("g_balance_health_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished), maxh, cvar("g_balance_health_rot"), cvar("g_balance_health_rotlinear"), rot_mod * frametime * (time > self.pauserothealth_finished), limith, "misc/health_regen.wav"); // if player rotted to death... die! if(self.health < 1) @@ -2050,13 +2101,19 @@ void SpectateCopy(entity spectatee) { self.dmg_save = spectatee.dmg_save; self.dmg_inflictor = spectatee.dmg_inflictor; self.angles = spectatee.v_angle; + self.scale = spectatee.scale; self.fixangle = TRUE; self.stomach_load = spectatee.stomach_load; self.stat_eaten = spectatee.stat_eaten; self.stat_stomachload = spectatee.stat_stomachload; + self.stomach_maxload = spectatee.stomach_maxload; self.stat_digesting = spectatee.stat_digesting; self.stat_canleave = spectatee.stat_canleave; self.stat_canswallow = spectatee.stat_canswallow; + self.stat_sbring1_type = spectatee.stat_sbring1_type; + self.stat_sbring1_clip = spectatee.stat_sbring1_clip; + self.stat_sbring2_type = spectatee.stat_sbring2_type; + self.stat_sbring2_clip = spectatee.stat_sbring2_clip; setorigin(self, spectatee.origin); setsize(self, spectatee.mins, spectatee.maxs); SetZoomState(spectatee.zoomstate); @@ -2248,6 +2305,39 @@ float vercmp(string v1, string v2) return vercmp_recursive(v1, v2); } +void SetPlayerSize() +{ + if(cvar("g_healthsize")) + { + // change player scale based on the amount of health we have + + self.scale = bound(cvar("g_healthsize_min"), self.health, cvar("g_healthsize_max")) / cvar("g_healthsize"); + + // The following code sets the bounding box to match the player's size. + // It is currently disabled because of issues with engine movement prediction (cl_movement). + // The engine expects the bounding box to be default size, and changing it will cause glitches. + // This code may be enabled once the engine has the ability to use different bbox sizes for movement prediction. + if(self.crouch) + { + //setsize (self, PL_CROUCH_MIN * self.scale, PL_CROUCH_MAX * self.scale); + if(!self.stat_eaten) + self.view_ofs = PL_CROUCH_VIEW_OFS * self.scale; + } + else + { + //setsize (self, PL_MIN * self.scale, PL_MAX * self.scale); + if(!self.stat_eaten) + self.view_ofs = PL_VIEW_OFS * self.scale; + } + } + + if(self.stat_eaten && cvar("g_vore_neighborprey_distance")) + { + // resize prey if neighborprey is enabled + self.scale *= cvar("g_vore_neighborprey_scale"); + } +} + void ObserverThink() { if (self.flags & FL_JUMPRELEASED) { @@ -2436,6 +2526,29 @@ void PlayerPreThink (void) if(frametime) { + + if(self.health <= 0 && cvar("g_deathglow")) + { + if(self.glowmod_x > 0) + self.glowmod_x -= cvar("g_deathglow") * frametime; + else + self.glowmod_x = -1; + if(self.glowmod_y > 0) + self.glowmod_y -= cvar("g_deathglow") * frametime; + else + self.glowmod_y = -1; + if(self.glowmod_z > 0) + self.glowmod_z -= cvar("g_deathglow") * frametime; + else + self.glowmod_z = -1; + } + else + { + // set weapon and player glowmod + self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2; + self.weaponentity_glowmod = self.glowmod; + } + player_powerups(); } @@ -2570,6 +2683,8 @@ void PlayerPreThink (void) } } + SetPlayerSize(); + FixPlayermodel(); GrabberFrame(); @@ -2773,7 +2888,6 @@ void PlayerPostThink (void) if(self.classname == "player") { CheckRules_Player(); UpdateChatBubble(); - UpdateTeamBubble(); if (self.impulse) ImpulseCommands(); if (intermission_running)