X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_player.qc;h=8aaf68cda69dac1753364cfe1e84cd07c10129c3;hb=b0423598270855d5f0a3206d46f0ebf43182b411;hp=c6b0359c4ee89bd20f3b05de8df71eae2c251f7f;hpb=c6fae88a462bf6e5ded37ac2fcdde0f844be9314;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index c6b0359c4..8aaf68cda 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -9,6 +9,7 @@ #include "teamplay.qh" #include "weapons/throwing.qh" #include "command/common.qh" +#include "../common/state.qh" #include "../common/anim.qh" #include "../common/animdecide.qh" #include "../common/csqcmodel_settings.qh" @@ -19,6 +20,8 @@ #include "../common/minigames/sv_minigames.qh" +#include "../common/physics/player.qh" +#include "../common/effects/qc/all.qh" #include "../common/mutators/mutator/waypoints/waypointsprites.qh" #include "../common/triggers/include.qh" @@ -36,92 +39,91 @@ void Drop_Special_Items(entity player) void CopyBody_Think() {SELFPARAM(); - if(self.CopyBody_nextthink && time > self.CopyBody_nextthink) + if(this.CopyBody_nextthink && time > this.CopyBody_nextthink) { - self.CopyBody_think(); - if(wasfreed(self)) + this.CopyBody_think(); + if(wasfreed(this)) return; - self.CopyBody_nextthink = self.nextthink; - self.CopyBody_think = self.think; - self.think = CopyBody_Think; + this.CopyBody_nextthink = this.nextthink; + this.CopyBody_think = this.think; + this.think = CopyBody_Think; } - CSQCMODEL_AUTOUPDATE(self); - self.nextthink = time; + CSQCMODEL_AUTOUPDATE(this); + this.nextthink = time; } -void CopyBody(float keepvelocity) -{SELFPARAM(); - if (self.effects & EF_NODRAW) +void CopyBody(entity this, float keepvelocity) +{ + if (this.effects & EF_NODRAW) return; - setself(new(body)); - self.enemy = this; - self.lip = this.lip; - self.colormap = this.colormap; - self.iscreature = this.iscreature; - self.teleportable = this.teleportable; - self.damagedbycontents = this.damagedbycontents; - self.angles = this.angles; - self.v_angle = this.v_angle; - self.avelocity = this.avelocity; - self.damageforcescale = this.damageforcescale; - self.effects = this.effects; - self.glowmod = this.glowmod; - self.event_damage = this.event_damage; - self.anim_state = this.anim_state; - self.anim_time = this.anim_time; - self.anim_lower_action = this.anim_lower_action; - self.anim_lower_time = this.anim_lower_time; - self.anim_upper_action = this.anim_upper_action; - self.anim_upper_time = this.anim_upper_time; - self.anim_implicit_state = this.anim_implicit_state; - self.anim_implicit_time = this.anim_implicit_time; - self.anim_lower_implicit_action = this.anim_lower_implicit_action; - self.anim_lower_implicit_time = this.anim_lower_implicit_time; - self.anim_upper_implicit_action = this.anim_upper_implicit_action; - self.anim_upper_implicit_time = this.anim_upper_implicit_time; - self.dphitcontentsmask = this.dphitcontentsmask; - self.death_time = this.death_time; - self.pain_finished = this.pain_finished; - self.health = this.health; - self.armorvalue = this.armorvalue; - self.armortype = this.armortype; - self.model = this.model; - self.modelindex = this.modelindex; - self.skin = this.skin; - self.species = this.species; - self.movetype = this.movetype; - self.solid = this.solid; - self.ballistics_density = this.ballistics_density; - self.takedamage = this.takedamage; - self.customizeentityforclient = this.customizeentityforclient; - self.uncustomizeentityforclient = this.uncustomizeentityforclient; - self.uncustomizeentityforclient_set = this.uncustomizeentityforclient_set; + entity clone = new(body); + clone.enemy = this; + clone.lip = this.lip; + clone.colormap = this.colormap; + clone.iscreature = this.iscreature; + clone.teleportable = this.teleportable; + clone.damagedbycontents = this.damagedbycontents; + clone.angles = this.angles; + clone.v_angle = this.v_angle; + clone.avelocity = this.avelocity; + clone.damageforcescale = this.damageforcescale; + clone.effects = this.effects; + clone.glowmod = this.glowmod; + clone.event_damage = this.event_damage; + clone.anim_state = this.anim_state; + clone.anim_time = this.anim_time; + clone.anim_lower_action = this.anim_lower_action; + clone.anim_lower_time = this.anim_lower_time; + clone.anim_upper_action = this.anim_upper_action; + clone.anim_upper_time = this.anim_upper_time; + clone.anim_implicit_state = this.anim_implicit_state; + clone.anim_implicit_time = this.anim_implicit_time; + clone.anim_lower_implicit_action = this.anim_lower_implicit_action; + clone.anim_lower_implicit_time = this.anim_lower_implicit_time; + clone.anim_upper_implicit_action = this.anim_upper_implicit_action; + clone.anim_upper_implicit_time = this.anim_upper_implicit_time; + clone.dphitcontentsmask = this.dphitcontentsmask; + clone.death_time = this.death_time; + clone.pain_finished = this.pain_finished; + clone.health = this.health; + clone.armorvalue = this.armorvalue; + clone.armortype = this.armortype; + clone.model = this.model; + clone.modelindex = this.modelindex; + clone.skin = this.skin; + clone.species = this.species; + clone.movetype = this.movetype; + clone.solid = this.solid; + clone.ballistics_density = this.ballistics_density; + clone.takedamage = this.takedamage; + clone.customizeentityforclient = this.customizeentityforclient; + clone.uncustomizeentityforclient = this.uncustomizeentityforclient; + clone.uncustomizeentityforclient_set = this.uncustomizeentityforclient_set; if (keepvelocity == 1) - self.velocity = this.velocity; - self.oldvelocity = self.velocity; - self.alpha = this.alpha; - self.fade_time = this.fade_time; - self.fade_rate = this.fade_rate; - //self.weapon = this.weapon; - setorigin(self, this.origin); - setsize(self, this.mins, this.maxs); - self.prevorigin = this.origin; - self.reset = SUB_Remove; - - Drag_MoveDrag(this, self); - - if(self.colormap <= maxclients && self.colormap > 0) - self.colormap = 1024 + this.clientcolors; - - CSQCMODEL_AUTOINIT(self); - self.CopyBody_nextthink = this.nextthink; - self.CopyBody_think = this.think; - self.nextthink = time; - self.think = CopyBody_Think; + clone.velocity = this.velocity; + clone.oldvelocity = clone.velocity; + clone.alpha = this.alpha; + clone.fade_time = this.fade_time; + clone.fade_rate = this.fade_rate; + //clone.weapon = this.weapon; + setorigin(clone, this.origin); + setsize(clone, this.mins, this.maxs); + clone.prevorigin = this.origin; + clone.reset = SUB_Remove; + clone._ps = this._ps; + + Drag_MoveDrag(this, clone); + + if(clone.colormap <= maxclients && clone.colormap > 0) + clone.colormap = 1024 + this.clientcolors; + + CSQCMODEL_AUTOINIT(clone); + clone.CopyBody_nextthink = this.nextthink; + clone.CopyBody_think = this.think; + clone.nextthink = time; + clone.think = CopyBody_Think; // "bake" the current animation frame for clones (they don't get clientside animation) - animdecide_load_if_needed(self); - animdecide_setframes(self, false, frame, frame1time, frame2, frame2time); - - setself(this); + animdecide_load_if_needed(clone); + animdecide_setframes(clone, false, frame, frame1time, frame2, frame2time); } void player_setupanimsformodel() @@ -133,8 +135,8 @@ void player_setupanimsformodel() void player_anim () {SELFPARAM(); - int deadbits = (self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2)); - if(IS_DEAD(self)) { + int deadbits = (this.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2)); + if(IS_DEAD(this)) { if (!deadbits) { // Decide on which death animation to use. if(random() < 0.5) @@ -147,14 +149,14 @@ void player_anim () deadbits = 0; } int animbits = deadbits; - if(STAT(FROZEN, self)) + if(STAT(FROZEN, this)) animbits |= ANIMSTATE_FROZEN; - if(self.movetype == MOVETYPE_FOLLOW) + if(this.movetype == MOVETYPE_FOLLOW) animbits |= ANIMSTATE_FOLLOW; - if(self.crouch) + if(this.crouch) animbits |= ANIMSTATE_DUCK; - animdecide_setstate(self, animbits, false); - animdecide_setimplicitstate(self, (IS_ONGROUND(self))); + animdecide_setstate(this, animbits, false); + animdecide_setimplicitstate(this, IS_ONGROUND(this)); } void PlayerCorpseDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) @@ -362,7 +364,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, { this.pusher = attacker; this.pushltime = time + autocvar_g_maxpushtime; - this.istypefrag = this.BUTTON_CHAT; + this.istypefrag = PHYS_INPUT_BUTTON_CHAT(this); } else if(time < this.pushltime) { @@ -375,6 +377,13 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, this.istypefrag = 0; } + if (time < this.spawnshieldtime && autocvar_g_spawnshield_blockdamage < 1) + { + vector v = healtharmor_applydamage(this.armorvalue, max(0, autocvar_g_spawnshield_blockdamage), deathtype, damage); + take = v.x; + save = v.y; + } + frag_damage = damage; MUTATOR_CALLHOOK(PlayerDamage_SplitHealthArmor, inflictor, attacker, this, force, take, save); take = bound(0, damage_take, this.health); @@ -396,7 +405,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, if (take > 100) Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, this, attacker); - if (time >= this.spawnshieldtime) + if (time >= this.spawnshieldtime || autocvar_g_spawnshield_blockdamage < 1) { if (!(this.flags & FL_GODMODE)) { @@ -429,7 +438,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, { if(deathtype == DEATH_FALL.m_id) PlayerSound(this, playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND); - else if(this.health > 75) // TODO make a "gentle" version? + else if(this.health > 75) PlayerSound(this, playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND); else if(this.health > 50) PlayerSound(this, playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND); @@ -508,7 +517,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, if(valid_damage_for_weaponstats) WeaponStats_LogKill(awep.m_id, abot, PS(this).m_weapon.m_id, vbot); - if(autocvar_sv_gentle < 1) // TODO make a "gentle" version? + if(autocvar_sv_gentle < 1) if(sound_allowed(MSG_BROADCAST, attacker)) { if(deathtype == DEATH_DROWN.m_id) @@ -547,7 +556,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, excess = frag_damage; Weapon wep = PS(this).m_weapon; - WITH(entity, self, this, wep.wr_playerdeath(wep)); + WITHSELF(this, wep.wr_playerdeath(wep)); RemoveGrapplingHook(this); @@ -628,7 +637,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, // reset fields the weapons may use just in case FOREACH(Weapons, it != WEP_Null, LAMBDA( - WITH(entity, self, this, it.wr_resetplayer(it)); + WITHSELF(this, it.wr_resetplayer(it)); for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { ATTACK_FINISHED_FOR(this, it.m_id, slot) = 0; @@ -648,6 +657,12 @@ void MoveToTeam(entity client, int team_colour, int type) LogTeamchange(client.playerid, client.team, type); } +/** print(), but only print if the server is not local */ +void dedicated_print(string input) +{ + if (server_is_dedicated) print(input); +} + /** * message "": do not say, just test flood control * return value: @@ -655,20 +670,14 @@ void MoveToTeam(entity client, int team_colour, int type) * 0 = reject * -1 = fake accept */ -int Say(entity source, float teamsay, entity privatesay, string msgin, bool floodcontrol) +int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodcontrol) { - string msgstr, colorstr, cmsgstr, namestr, fullmsgstr, sourcemsgstr, fullcmsgstr, sourcecmsgstr, colorprefix; - float flood; - var .float flood_field; - float ret; - string privatemsgprefix = string_null; float privatemsgprefixlen = 0; - - if(!teamsay && !privatesay) - if(substring(msgin, 0, 1) == " ") - msgin = substring(msgin, 1, strlen(msgin) - 1); // work around DP say bug (say_team does not have this!) + if (!teamsay && !privatesay) if (substring(msgin, 0, 1) == " ") + msgin = substring(msgin, 1, -1); // work around DP say bug (say_team does not have this!) msgin = formatmessage(msgin); + string colorstr; if (!IS_PLAYER(source)) colorstr = "^0"; // black for spectators else if(teamplay) @@ -682,6 +691,11 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo if(intermission_running) teamsay = false; + if (!source) { + colorstr = ""; + teamsay = false; + } + if(msgin != "") msgin = trigger_magicear_processmessage_forallears(source, teamsay, privatesay, msgin); @@ -696,18 +710,18 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo } */ - if(autocvar_g_chat_teamcolors) - namestr = playername(source); - else - namestr = source.netname; + string namestr = ""; + if (source) + namestr = autocvar_g_chat_teamcolors ? playername(source) : source.netname; - if(strdecolorize(namestr) == namestr) - colorprefix = "^3"; - else - colorprefix = "^7"; + string colorprefix = (strdecolorize(namestr) == namestr) ? "^3" : "^7"; - if(msgin != "") - { + string msgstr, cmsgstr; + string privatemsgprefix = string_null; + int privatemsgprefixlen = 0; + if (msgin == "") { + msgstr = cmsgstr = ""; + } else { if(privatesay) { msgstr = strcat("\{1}\{13}* ", colorprefix, namestr, "^3 tells you: ^7"); @@ -741,23 +755,22 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo msgin = strreplace("/me", strcat(colorprefix, namestr), msgin); msgstr = strcat("\{1}^4* ", "^7", msgin); } - else - msgstr = strcat("\{1}", colorprefix, namestr, "^7: ", msgin); + else { + msgstr = "\{1}"; + msgstr = strcat(msgstr, (namestr != "") ? strcat(colorprefix, namestr, "^7: ") : "^7"); + msgstr = strcat(msgstr, msgin); + } cmsgstr = ""; } msgstr = strcat(strreplace("\n", " ", msgstr), "\n"); // newlines only are good for centerprint } - else - { - msgstr = cmsgstr = ""; - } - fullmsgstr = msgstr; - fullcmsgstr = cmsgstr; + string fullmsgstr = msgstr; + string fullcmsgstr = cmsgstr; // FLOOD CONTROL - flood = 0; - flood_field = floodcontrol_chat; + int flood = 0; + var .float flood_field = floodcontrol_chat; if(floodcontrol) { float flood_spl; @@ -829,6 +842,7 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo source.(flood_field) = flood = 0; } + string sourcemsgstr, sourcecmsgstr; if(flood == 2) // cannot happen for empty msgstr { if(autocvar_g_chat_flood_notify_flooder) @@ -849,8 +863,7 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo sourcecmsgstr = cmsgstr; } - if(!privatesay) - if (!IS_PLAYER(source)) + if (!privatesay && source && !IS_PLAYER(source)) { if (!intermission_running) if(teamsay || (autocvar_g_chat_nospectators == 1) || (autocvar_g_chat_nospectators == 2 && !(warmup_stage || gameover))) @@ -864,6 +877,7 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo if(privatesay) sourcemsgstr = strcat(privatemsgprefix, substring(sourcemsgstr, privatemsgprefixlen, -1)); + int ret; if(source.muted) { // always fake the message @@ -904,7 +918,7 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo { sprint(source, sourcemsgstr); dedicated_print(msgstr); // send to server console too - FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && it.active_minigame == source.active_minigame, LAMBDA(sprint(it, msgstr))); + FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && it.active_minigame == source.active_minigame, sprint(it, msgstr)); } else if(teamsay > 0) // team message, only sent to team mates { @@ -912,26 +926,27 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo dedicated_print(msgstr); // send to server console too if(sourcecmsgstr != "") centerprint(source, sourcecmsgstr); - FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source && it.team == source.team, LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source && it.team == source.team, { sprint(it, msgstr); if(cmsgstr != "") centerprint(it, cmsgstr); - )); + }); } else if(teamsay < 0) // spectator message, only sent to spectators { sprint(source, sourcemsgstr); dedicated_print(msgstr); // send to server console too - FOREACH_CLIENT(!IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source, LAMBDA(sprint(it, msgstr))); - } - else if(sourcemsgstr != msgstr) // trimmed/server fixed message, sent to all players - { - sprint(source, sourcemsgstr); - dedicated_print(msgstr); // send to server console too - FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source, LAMBDA(sprint(it, msgstr))); + FOREACH_CLIENT(!IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source, sprint(it, msgstr)); } else - bprint(msgstr); // entirely normal message, sent to all players -- bprint sends to server console too. + { + if (source) { + sprint(source, sourcemsgstr); + dedicated_print(msgstr); // send to server console too + MX_Say(strcat(playername(source), "^7: ", msgin)); + } + FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source, sprint(it, msgstr)); + } } return ret;