Sauerbraten auto trigger hack

 · 1 min read
 · Jean Schurger

Here is a nasty hack for sauerbraten to pull the trigger when you are aiming at opponent. It then shoot for nothing to let you not been too much accurate.

--- cube2-0.0.20130404+dfsg.orig/fpsgame/fps.cpp
+++ cube2-0.0.20130404+dfsg/fpsgame/fps.cpp
@@ -901,8 +901,19 @@ namespace game
             dynent *o = intersectclosest(d->o, worldpos, d);
             if(o && o->type==ENT_PLAYER && isteam(((fpsent *)o)->team, d->team))
             {
-                crosshair = 1;
-                r = g = 0;
+              crosshair = 1;
+              r = g = 0;
+            } else if (o && o->type==ENT_PLAYER && !isteam(((fpsent *)o)->team, d->team)) {
+              if (d->falsehit == 0) {
+                d->attacking = true;
+                d->falsehit = 2;
+              }
+            } else {
+              if (d->falsehit > 0) {
+                d->attacking = true;
+              } else {
+                d->attacking = false;
+              }
             }
         }

--- cube2-0.0.20130404+dfsg.orig/fpsgame/game.h
+++ cube2-0.0.20130404+dfsg/fpsgame/game.h
@@ -551,7 +551,7 @@ struct fpsent : dynent, fpsstate
     int playermodel;
     ai::aiinfo *ai;
     int ownernum, lastnode;
-
+    int falsehit = 0;
     vec muzzle;

     fpsent() : weight(100), clientnum(-1), privilege(PRIV_NONE), lastupdate(0), plag(0), ping(0), lifesequence(0), respawned(-1), suicided(-1), lastpain(0), attacksound(-1), attackchan(-1), idlesound(-1), idlechan(-1), frags(0), flags(0), deaths(0), totaldamage(0), totalshots(0), edit(NULL), smoothmillis(-1), playermodel(-1), ai(NULL), ownernum(-1), muzzle(-1, -1, -1)
--- cube2-0.0.20130404+dfsg.orig/fpsgame/weapon.cpp
+++ cube2-0.0.20130404+dfsg/fpsgame/weapon.cpp
@@ -793,6 +793,9 @@ namespace game

         if(d==player1 || d->ai)
         {
+          if (d->falsehit > 0) {
+            d->falsehit--;
+          }
             addmsg(N_SHOOT, "rci2i6iv", d, lastmillis-maptime, d->gunselect,
                    (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF),
                    (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF),