]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
Merge branch 'master' into terencehill/translate_colors_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index f5f5ad905ddc59b68769ff8c37d03a8bbe7b1e8c..42904695c693b35e39835bed217e3c78ef2635c8 100644 (file)
@@ -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,17 +39,17 @@ 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(entity this, float keepvelocity)
 {
@@ -132,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)
@@ -146,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)
@@ -361,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)
        {
@@ -374,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);
@@ -395,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))
                {
@@ -428,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);
@@ -507,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)
@@ -546,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);
 
@@ -627,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;