]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Many minor improvements
authormand1nga <mand1nga@xonotic.org>
Tue, 16 Aug 2011 06:15:38 +0000 (03:15 -0300)
committermand1nga <mand1nga@xonotic.org>
Tue, 16 Aug 2011 06:15:38 +0000 (03:15 -0300)
qcsrc/server/assault.qc
qcsrc/server/bot/havocbot/role_assault.qc
qcsrc/server/func_breakable.qc

index 77d7d36fc8773858f02120a697a3f2fa484c0f75..517da81684928019729e385b6feb244b32963021 100644 (file)
@@ -208,8 +208,6 @@ void spawnfunc_func_assault_destructible() {
        }
        self.spawnflags = 3;
        self.classname = "func_assault_destructible";
-       self.takedamage = TRUE;
-       self.bot_attack = TRUE;
        if(assault_attacker_team == COLOR_TEAM1) {
                self.team = COLOR_TEAM2;
        } else {
index edb4995bee5fb50f54d602cc5ba51f1b96e59c20..e662a350048870fcc6f41380c4b84a6c12feec3b 100644 (file)
@@ -1,6 +1,6 @@
 #define HAVOCBOT_AST_ROLE_NONE                 0
 #define HAVOCBOT_AST_ROLE_DEFENSE      2
-#define HAVOCBOT_AST_ROLE_OFFENSE      8
+#define HAVOCBOT_AST_ROLE_OFFENSE      4
 
 .float havocbot_role_flags;
 .float havocbot_attack_time;
@@ -12,11 +12,117 @@ void() havocbot_role_ast_defense;
 void() havocbot_role_ast_offense;
 .entity havocbot_ast_target;
 
+entity havocbot_ast_core;
+float havocbot_ast_core_unreachable;
+
 void(entity bot) havocbot_ast_reset_role;
 
 void(float ratingscale, vector org, float sradius) havocbot_goalrating_items;
 void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
-.entity assault_decreaser;
+
+void havocbot_ast_find_core()
+{
+       entity are, to1, to2, to3;
+
+       if(havocbot_ast_core_unreachable)
+               return;
+
+       are = findchain(classname, "target_assault_roundend");
+
+       for (; are; are = are.chain)
+       {
+               for(to1 = world; (to1 = find(to1, target, are.targetname)); )
+               {
+                       if(to1.classname == "func_assault_destructible")
+                       {
+                               havocbot_ast_core = to1;
+                               return;
+                       }
+
+                       for(to2 = world; (to2 = find(to2, target, to1.targetname)); )
+                       {
+                               if(to2.classname == "func_assault_destructible")
+                               {
+                                       havocbot_ast_core = to2;
+                                       return;
+                               }
+
+                               for(to3 = world; (to3 = find(to3, target, to2.targetname)); )
+                               {
+                                       if(to3.classname == "func_assault_destructible")
+                                       {
+                                               havocbot_ast_core = to3;
+                                               return;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       dprint("ERROR: Power core unreachable\n");
+       havocbot_ast_core_unreachable = TRUE;
+}
+
+void havocbot_goalrating_ast_core(float ratingscale)
+{
+       entity best, wp;
+       float radius, found, bestvalue, c;
+       vector p;
+
+       havocbot_ast_find_core();
+
+       if not(havocbot_ast_core)
+               return;
+
+       if not(havocbot_ast_core.takedamage)
+               havocbot_ast_core.takedamage = TRUE;
+
+       p = 0.5 * (havocbot_ast_core.absmin + havocbot_ast_core.absmax);
+//     dprint(vtos(ad.origin), " ", vtos(ad.absmin), " ", vtos(ad.absmax),"\n");
+       te_knightspike(p);
+       te_lightning2(world, '0 0 0', p);
+
+       // Find and rate waypoints around it
+       found = FALSE;
+       best = world;
+       bestvalue = 99999999999;
+       for(radius=0; radius<1000 && !found; radius+=500)
+       {
+               for(wp=findradius(p, radius); wp; wp=wp.chain)
+               {
+                       if(!(wp.wpflags & WAYPOINTFLAG_GENERATED))
+                       if(wp.classname=="waypoint")
+                       if(checkpvs(wp.origin, havocbot_ast_core))
+                       {
+                               found = TRUE;
+                               if(wp.cnt<bestvalue)
+                               {
+                                       best = wp;
+                                       bestvalue = wp.cnt;
+                               }
+                       }
+               }
+       }
+
+       if(best)
+       {
+               dprint("waypoints around target were found\n");
+       //      te_lightning2(world, '0 0 0', best.origin);
+       //      te_knightspike(best.origin);
+
+               navigation_routerating(best, ratingscale, 10000);
+               best.cnt += 1;
+
+               self.havocbot_attack_time = 0;
+
+               if(checkpvs(self.view_ofs, havocbot_ast_core))
+               if(checkpvs(self.view_ofs, best))
+               {
+               //      dprint("increasing attack time for this target\n");
+                       self.havocbot_attack_time = time + 2;
+               }
+       }
+}
 
 void havocbot_goalrating_ast_targets(float ratingscale)
 {
@@ -31,7 +137,7 @@ void havocbot_goalrating_ast_targets(float ratingscale)
                if (ad.target == "")
                        continue;
 
-               if(ad.state!=0)
+               if not(ad.bot_attack)
                        continue;
 
                found = FALSE;
@@ -49,18 +155,23 @@ void havocbot_goalrating_ast_targets(float ratingscale)
                }
 
                if(!found)
+               {
+                       dprint("target not found\n");
                        continue;
+               }
+               dprint("target #", etos(ad), " found\n");
+
 
                p = 0.5 * (ad.absmin + ad.absmax);
        //      dprint(vtos(ad.origin), " ", vtos(ad.absmin), " ", vtos(ad.absmax),"\n");
-               te_knightspike(p);
-               te_lightning2(world, '0 0 0', p);
+       //      te_knightspike(p);
+       //      te_lightning2(world, '0 0 0', p);
 
                // Find and rate waypoints around it
                found = FALSE;
                best = world;
                bestvalue = 99999999999;
-               for(radius=0; radius<1000 && !found; radius+=500)
+               for(radius=0; radius<1500 && !found; radius+=500)
                {
                        for(wp=findradius(p, radius); wp; wp=wp.chain)
                        {
index 1e474c0d641a34764fb55578f77614927f280f33..192e5cd7fb2e69f5b20b5708f4aec9af11224e28 100644 (file)
@@ -114,6 +114,7 @@ void func_breakable_behave_destroyed()
 {
        self.health = self.max_health;
        self.takedamage = DAMAGE_NO;
+       self.bot_attack = FALSE;
        self.event_damage = SUB_Null;
        self.state = 1;
        func_breakable_colormod();
@@ -128,6 +129,7 @@ void func_breakable_behave_restore()
                WaypointSprite_UpdateHealth(self.sprite, self.health);
        }
        self.takedamage = DAMAGE_AIM;
+       self.bot_attack = TRUE;
        self.event_damage = func_breakable_damage;
        self.state = 0;
        self.nextthink = 0; // cancel auto respawn