]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/accuracy.qc
#include this
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / accuracy.qc
index 0f077a5fb83e570fed8c41861ce141a544c78c10..706b00b5f3945db08b17f87e5897ef80ed07221f 100644 (file)
@@ -1,6 +1,21 @@
+#if defined(CSQC)
+#elif defined(MENUQC)
+#elif defined(SVQC)
+       #include "../../dpdefs/progsdefs.qc"
+    #include "../../dpdefs/dpextensions.qc"
+    #include "../../common/constants.qh"
+    #include "../../common/util.qh"
+    #include "../../common/weapons/weapons.qh"
+    #include "accuracy.qh"
+    #include "../autocvars.qh"
+    #include "../constants.qh"
+    #include "../defs.qh"
+    #include "../mutators/mutators_include.qh"
+#endif
+
 float accuracy_byte(float n, float d)
 {
-       //print(sprintf("accuracy: %d / %d\n", n, d));
+       //printf("accuracy: %d / %d\n", n, d);
        if(n <= 0)
                return 0;
        if(n > d)
@@ -20,12 +35,12 @@ float accuracy_send(entity to, float sf)
        a = a.accuracy;
 
        if(to != a.owner)
-               if not(self.owner.cvar_cl_accuracy_data_share && autocvar_sv_accuracy_data_share)
+               if (!(self.owner.cvar_cl_accuracy_data_share && autocvar_sv_accuracy_data_share))
                        sf = 0;
        // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy!
        WriteInt24_t(MSG_ENTITY, sf);
        if(sf == 0)
-               return TRUE;
+               return true;
        // note: we know that client and server agree about SendFlags...
        for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w)
        {
@@ -36,7 +51,7 @@ float accuracy_send(entity to, float sf)
                else
                        f *= 2;
        }
-       return TRUE;
+       return true;
 }
 
 // init/free
@@ -46,7 +61,7 @@ void accuracy_init(entity e)
        e.accuracy.owner = e;
        e.accuracy.classname = "accuracy";
        e.accuracy.drawonlytoclient = e;
-       Net_LinkEntity(e.accuracy, FALSE, 0, accuracy_send);
+       Net_LinkEntity(e.accuracy, false, 0, accuracy_send);
 }
 
 void accuracy_free(entity e)
@@ -94,7 +109,7 @@ void accuracy_add(entity e, float w, float fired, float hit)
 
        if(b == accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w])))
                return;
-       w = pow(2, mod(w, 24));
+       w = pow(2, w % 24);
        a.SendFlags |= w;
        FOR_EACH_CLIENT(a)
                if(IS_SPEC(a))
@@ -104,17 +119,22 @@ void accuracy_add(entity e, float w, float fired, float hit)
 
 float accuracy_isgooddamage(entity attacker, entity targ)
 {
-       if(!inWarmupStage)
-       if(IS_CLIENT(targ))
+       frag_attacker = attacker;
+       frag_target = targ;
+       float mutator_check = MUTATOR_CALLHOOK(AccuracyTargetValid);
+
+       if(!warmup_stage)
        if(targ.deadflag == DEAD_NO)
-       if(IsDifferentTeam(attacker, targ))
-               return TRUE;
-       return FALSE;
+       if(!targ.frozen)
+       if(mutator_check == MUT_ACCADD_INVALID || (mutator_check == MUT_ACCADD_VALID && IS_CLIENT(targ)))
+       if(DIFF_TEAM(attacker, targ))
+               return true;
+       return false;
 }
 
 float accuracy_canbegooddamage(entity attacker)
 {
-       if(!inWarmupStage)
-               return TRUE;
-       return FALSE;
+       if(!warmup_stage)
+               return true;
+       return false;
 }