From: Mario Date: Thu, 7 Feb 2013 05:02:39 +0000 (+1100) Subject: Fix monster goal targeting X-Git-Tag: xonotic-v0.8.0~241^2^2~540 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b35e5297e3b67e79fc2fdf58e1824b9bf31ca790;p=xonotic%2Fxonotic-data.pk3dir.git Fix monster goal targeting --- diff --git a/qcsrc/server/mutators/gamemode_rts.qc b/qcsrc/server/mutators/gamemode_rts.qc index 847e8bbbf..1774bba92 100644 --- a/qcsrc/server/mutators/gamemode_rts.qc +++ b/qcsrc/server/mutators/gamemode_rts.qc @@ -59,11 +59,13 @@ MUTATOR_HOOKFUNCTION(rts_PlayerThink) } self.hasweapon_complain_spam = time + 99999; // no spam - entity head, wp = world; + entity head, w, wp = world; if(!self.cursor_trace_ent && self.BUTTON_ATCK && time >= self.last_click) { FOR_EACH_MONSTER(head) { + if(head.goalentity) head.goalentity.selected = TRUE; // do this to make sure we're not removing any owned waypoints below + if(head.owner != self) continue; head.selected = FALSE; @@ -71,6 +73,12 @@ MUTATOR_HOOKFUNCTION(rts_PlayerThink) if(!self.enemy) head.owner = world; } + + for(w = world; (w = find(w, classname, "monster_waypoint")); ) + { + if not(w.selected) + remove(w); + } } if(self.cursor_trace_ent.flags & FL_MONSTER && self.BUTTON_ATCK && time >= self.last_click) { @@ -102,26 +110,17 @@ MUTATOR_HOOKFUNCTION(rts_PlayerThink) if(e == world) { - float selected_count = 0; - FOR_EACH_MONSTER(head) { if(head.owner == self) selected_count += 1; } - if(selected_count > 0) - { - wp = spawn(); - setorigin(wp, self.cursor_trace_endpos); - } + wp = spawn(); + wp.classname = "monster_waypoint"; // set so we can kill this later + setorigin(wp, self.cursor_trace_endpos); } FOR_EACH_MONSTER(head) { if(head.owner != self) continue; + if not(head.selected) continue; - if(head.goalentity) - { - remove(head.goalentity); - head.goalentity = world; - } - - if(e && IsDifferentTeam(head, e) && e.takedamage) + if(e) head.enemy = e; else if(wp) { @@ -180,11 +179,13 @@ MUTATOR_HOOKFUNCTION(rts_MonsterThink) if(!self.selected) if(self.owner) - if(!self.enemy) self.owner = world; if(!IsDifferentTeam(self, self.enemy)) self.enemy = world; // no same team fighting + + if(!self.goalentity && !self.enemy && vlen(self.velocity) > 64) // wtf + self.moveto = self.origin; self.last_trace = time; // realtime moving?