]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' of git://de.git.xonotic.org/xonotic/xonotic-data.pk3dir
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 20 Jun 2011 08:28:50 +0000 (10:28 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 20 Jun 2011 08:28:50 +0000 (10:28 +0200)
Conflicts:
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/havocbot/roles.qc

qcsrc/server/bot/aim.qc
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/havocbot/role_keepaway.qc [new file with mode: 0644]
qcsrc/server/bot/havocbot/roles.qc
qcsrc/server/mutators/gamemode_keepaway.qc

index 9300ac721d889366a386bc8b0a06fb0656ad1443..63e971b17da9c52cacc638e8ae6c3f006cff096f 100644 (file)
@@ -1,4 +1,5 @@
 
+entity ka_ball;
 // traces multiple trajectories to find one that will impact the target
 // 'end' vector is the place it aims for,
 // returns TRUE only if it hit targ (don't target non-solid entities)
@@ -113,6 +114,12 @@ float bot_shouldattack(entity e)
                if(e.freezetag_frozen)
                        return FALSE;
 
+       // If neither player has ball then don't attack unless the ball is on the
+       // ground.
+       if (g_keepaway)
+               if (!e.ballcarried && !self.ballcarried && ka_ball.owner)
+                       return FALSE;
+
        if(teamplay)
        {
                if(e.team==0)
index 265731f690d1d4ea231d976491301eb842f623ab..7c2f986346677e73b2cefc533cf45651ebd18cf0 100644 (file)
@@ -3,6 +3,7 @@
 #include "role_onslaught.qc"
 #include "role_keyhunt.qc"
 #include "role_freezetag.qc"
+#include "role_keepaway.qc"
 #include "roles.qc"
 
 void havocbot_ai()
diff --git a/qcsrc/server/bot/havocbot/role_keepaway.qc b/qcsrc/server/bot/havocbot/role_keepaway.qc
new file mode 100644 (file)
index 0000000..30d9649
--- /dev/null
@@ -0,0 +1,82 @@
+void() havocbot_role_ka_carrier;
+void() havocbot_role_ka_collector;
+void() havocbot_chooserole_ka;
+
+entity ka_ball;
+
+// Keepaway
+// If you don't have the ball, get it; if you do, kill people.
+
+void havocbot_goalrating_ball(float ratingscale, vector org)
+{
+       local float t, distance;
+       local entity ball_owner;
+       ball_owner = ka_ball.owner;
+
+       if (ball_owner == self)
+               return;
+
+       // If ball is carried by player then hunt them down.
+       if (ball_owner)
+       {
+               t = (self.health + self.armorvalue) / (ball_owner.health + ball_owner.armorvalue);
+               navigation_routerating(ball_owner, t * ratingscale, 2000);
+       }
+
+       // Ball has been dropped so collect.
+       navigation_routerating(ka_ball, ratingscale, 2000);
+};
+
+void havocbot_role_ka_carrier()
+{
+       if (self.deadflag != DEAD_NO)
+               return;
+
+       if (time > self.bot_strategytime)
+       {
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+
+               navigation_goalrating_start();
+               havocbot_goalrating_items(10000, self.origin, 10000);
+               havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
+               //havocbot_goalrating_waypoints(1, self.origin, 1000);
+               navigation_goalrating_end();
+       }
+
+       if (!self.ballcarried)
+       {
+               self.havocbot_role = havocbot_role_ka_collector;
+               self.bot_strategytime = 0;
+       }
+};
+
+void havocbot_role_ka_collector()
+{
+       if (self.deadflag != DEAD_NO)
+               return;
+
+       if (time > self.bot_strategytime)
+       {
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+
+               navigation_goalrating_start();
+               havocbot_goalrating_items(10000, self.origin, 10000);
+               havocbot_goalrating_enemyplayers(1000, self.origin, 10000);
+               havocbot_goalrating_ball(20000, self.origin);
+               navigation_goalrating_end();
+       }
+
+       if (self.ballcarried)
+       {
+               self.havocbot_role = havocbot_role_ka_carrier;
+               self.bot_strategytime = 0;
+       }
+};
+
+void havocbot_chooserole_ka()
+{
+       if (self.ballcarried)
+               self.havocbot_role = havocbot_role_ka_carrier;
+       else
+               self.havocbot_role = havocbot_role_ka_collector;
+};
index 96c901f9e9f301821d7cca6cedf05871f65bf731..ac52c698f6cdb10c6387799898f9f400ebc5ef54 100644 (file)
@@ -277,24 +277,6 @@ void havocbot_role_race()
        }
 };
 
-// Keepaway
-// If you don't have the ball, get it; if you do, kill people.
-void havocbot_role_ka()
-{
-       if(self.deadflag != DEAD_NO)
-               return;
-
-       if (self.bot_strategytime < time)
-       {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-               havocbot_goalrating_items(10000, self.origin, 10000);
-               havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
-               //havocbot_goalrating_waypoints(1, self.origin, 1000);
-               navigation_goalrating_end();
-       }
-}
-
 void havocbot_chooserole_dm()
 {
        self.havocbot_role = havocbot_role_dm;
@@ -310,11 +292,6 @@ void havocbot_chooserole_dom()
        self.havocbot_role = havocbot_role_dom;
 };
 
-void havocbot_chooserole_ka()
-{
-       self.havocbot_role = havocbot_role_ka;
-};
-
 void havocbot_chooserole()
 {
        dprint("choosing a role...\n");
index 85a29031a8ec8ecc8a55bb9a60f3f6a8c7613e9a..1d091b1156763ddf1c1b49d6ffbc0b0fda98b4f0 100644 (file)
@@ -4,6 +4,8 @@ void ka_RespawnBall(void);
 void ka_DropEvent(entity);
 void ka_TimeScoring(void);
 
+entity ka_ball;
+
 float ka_ballcarrier_waypointsprite_visible_for_player(entity);
 
 void ka_Initialize() // run at the start of a match, initiates game mode
@@ -50,6 +52,7 @@ void ka_SpawnBall() // loads various values for the ball, runs only once at star
        e.reset = ka_Reset;
        e.touch = ka_TouchEvent;
        e.owner = world;
+       ka_ball = e;
 
        InitializeEntity(e, ka_RespawnBall, INITPRIO_SETLOCATION); // is this the right priority? Neh, I have no idea.. Well-- it works! So. 
 }