elseif army_cost >= enemy_cost then --they are at the gather point local num_at_gather_pt = 0 for i in self.attack_units do local tolerance_sqr = max_tolerance*max_tolerance local squad_ai = self.attack_units[i] --check I'm in proximity of the target if distance_sqr( squad_ai:GetSquad():GetPosition(), self.gather_pos ) < tolerance_sqr and not squad_ai:IsInCombat() and not squad_ai:IsInStateAttackMove() then squad_ai:DoAttackMove( self.gather_pos ) end local dist_sqr = distance_sqr( self.attack_units[i]:GetSquad():GetPosition(), self.gather_pos ) if dist_sqr <= max_tolerance*max_tolerance then num_at_gather_pt = num_at_gather_pt + 1 end end --attack if I have enough people if num_at_gather_pt >= self.min_units then Plan.SetState( self, "Attack!", AttackPlan.Attack ) return end end
Look at that line
--check I'm in proximity of the target if distance_sqr( squad_ai:GetSquad():GetPosition(), self.gather_pos ) < tolerance_sqr and not squad_ai:IsInCombat() and not squad_ai:IsInStateAttackMove() then squad_ai:DoAttackMove( self.gather_pos ) end
Shouldn't it better be if distance_sqr(...) > tolerance_sqr instead of "< " ???
This way it will try to gather more squads our of tolerance_sqr. Otherwise it will command squads already withing tolerance_sqr to move to self.gather_pos where they are already.
Edited by LarkinVB, 06 October 2005 - 12:52 PM.