From: mand1nga <mand1nga@xonotic.org>
Date: Tue, 16 Aug 2011 06:15:38 +0000 (-0300)
Subject: Many minor improvements
X-Git-Tag: xonotic-v0.5.0~122^2^2~3
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c43366d84b411525517bc684d6be01c86cb77b3b;p=xonotic%2Fxonotic-data.pk3dir.git

Many minor improvements
---

diff --git a/qcsrc/server/assault.qc b/qcsrc/server/assault.qc
index 77d7d36fc..517da8168 100644
--- a/qcsrc/server/assault.qc
+++ b/qcsrc/server/assault.qc
@@ -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 {
diff --git a/qcsrc/server/bot/havocbot/role_assault.qc b/qcsrc/server/bot/havocbot/role_assault.qc
index edb4995be..e662a3500 100644
--- a/qcsrc/server/bot/havocbot/role_assault.qc
+++ b/qcsrc/server/bot/havocbot/role_assault.qc
@@ -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)
 			{
diff --git a/qcsrc/server/func_breakable.qc b/qcsrc/server/func_breakable.qc
index 1e474c0d6..192e5cd7f 100644
--- a/qcsrc/server/func_breakable.qc
+++ b/qcsrc/server/func_breakable.qc
@@ -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