]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix Point Blank achievement, add condition for received bullets
authorAriosJentu <darthpoezd@gmail.com>
Sat, 24 Aug 2019 16:14:01 +0000 (02:14 +1000)
committerAriosJentu <darthpoezd@gmail.com>
Sat, 24 Aug 2019 16:14:01 +0000 (02:14 +1000)
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/g_damage.qc

index c0680d87566e37ef35601e056cfd21ba004be8a4..6be223d13c7dac6c905e6b3572e3c68079bb45c7 100644 (file)
@@ -2396,6 +2396,7 @@ Called every frame for each client before the physics are run
 .float last_vehiclecheck;
 void PlayerPreThink (entity this)
 {
+
        STAT(GUNALIGN, this) = CS(this).cvar_cl_gunalign; // TODO
        STAT(MOVEVARS_CL_TRACK_CANJUMP, this) = CS(this).cvar_cl_movement_track_canjump;
 
@@ -2595,6 +2596,28 @@ void PlayerPreThink (entity this)
                if(this.(weaponentity).m_weapon == WEP_Null)
                        this.(weaponentity).clip_load = this.(weaponentity).clip_size = 0;
        }
+
+       //Bullets timer
+       if (this.shotgun_timer) {
+       
+               if (this.shotgun_timer_time < 2) { //2 frames for reloading weapon
+                       this.shotgun_timer_time++;
+       
+               } else {
+
+                       if (this.shotgun_inc_pointblank) {
+                               entity attaker = this.shotgun_bullets_received_from;
+                               entity achv = attaker.achievements;
+                               achv.inc_achievement(achv, "pointblank");
+                               achv.announce(achv, attaker, "Point Blank!", "pointblank");
+                       }
+
+                       this.shotgun_timer = 0;
+                       this.shotgun_timer_time = 0;
+                       this.shotgun_bullets_received = 0;
+                       this.shotgun_inc_pointblank = 0;
+               }
+       }
 }
 
 void DrownPlayer(entity this)
index bc4a60e1a88d5f55d7688e0b5756d2f06329d885..f65c01d24f11cecae71a8826eeac4d6dcb251efc 100644 (file)
@@ -199,6 +199,12 @@ CLASS(Player, Client)
     ATTRIB(Player, prevstrengthsoundattempt, float, this.prevstrengthsoundattempt);
     ATTRIB(Player, buff_shield, float, this.buff_shield);
 
+    ATTRIB(Player, shotgun_timer, bool, this.shotgun_timer);
+    ATTRIB(Player, shotgun_timer_time, int, this.shotgun_timer_time);
+    ATTRIB(Player, shotgun_bullets_received, int, this.shotgun_bullets_received);
+    ATTRIB(Player, shotgun_bullets_received_from, entity, this.shotgun_bullets_received_from);
+    ATTRIB(Player, shotgun_inc_pointblank, bool, this.shotgun_inc_pointblank);
+
     INIT(Player) {
         this.classname = STR_PLAYER;
         IL_PUSH(g_players, this);
index 83bedab47198ba316e081c91d9d3930c8384ae37..9bb72981857df0ab57b97d719edc7fb577a92095 100644 (file)
@@ -875,15 +875,21 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
 
 
        //Weapons achievements
-       entity attacker_achv = attacker_save.achievements;
        if (DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) {
 
                float distance = vlen(targ.origin-attacker.origin);
+               
+               if (targ.shotgun_timer) {
+                       targ.shotgun_bullets_received += 1;
+               } else {
+                       targ.shotgun_bullets_received_from = attacker_save;
+                       targ.shotgun_bullets_received = 1;
+                       targ.shotgun_timer = 1;                 
+               }
 
                //Add condition to look at, not only for distance
-               if (distance < 60) {
-                       attacker_achv.inc_achievement(attacker_achv, "pointblank");
-                       attacker_achv.announce(attacker_achv, attacker_save, "Point Blank!", "pointblank");
+               if (distance < 65 && targ.shotgun_bullets_received) {
+                       targ.shotgun_inc_pointblank = 1;
                }
        }
 }