Keep at Range or Orbit

Hi,

i´d like that function, too.

For example my HAMs only reach 20km range.
How can I tell the bot to keep enemies at this range or closer?

Also has anyone a script that loots faction and officer wrecks/items?
 
EXACTLY


Well, you should not be using HAMS for this, IMHO, but regardless, yes I need/want/desire a script that will enable the ratter to keep at range or orbit the targeted/focused rat.


Anyone???!!
 
I need/want/desire this script too!

but... after DT I try to modify in obj_Combat.iss the FIGHT function.

function Fight()
{
Ship:Deactivate_Cloak
while ${Ship.IsCloaked}
{
waitframe
}
;Ship:Offline_Cloak
;Ship:Online_Salvager

; Reload the weapons -if- ammo is below 30% and they arent firing
Ship:Reload_Weapons[FALSE]

; Activate the weapons, the modules class checks if there's a target (no it doesn't - ct)
Ship:Activate_TargetPainters
Ship:Activate_StasisWebs
Ship:Activate_Weapons
Ship:Orbit[20000]
Ship.Drones:SendDrones
}
probably it will work?
maybe Amadeus know the right answer ? :) I mean "how to set orbit for my evebot" ;)
 
Last edited:
method StopShip()
{
EVE:Execute[CmdStopShip]
}

; Approaches EntityID to within 5% of Distance, then stops ship. Momentum will handle the rest.
function Approach(int64 EntityID, int64 Distance)
{
if ${Entity[${EntityID}](exists)}
{
variable float64 OriginalDistance = ${Entity[${EntityID}].Distance}
variable float64 CurrentDistance

If ${OriginalDistance} < ${Distance}
{
return
}
OriginalDistance:Inc[10]

CurrentDistance:Set[${Entity[${EntityID}].Distance}]
UI:UpdateConsole["Approaching: ${Entity[${EntityID}].Name} - ${Math.Calc[(${CurrentDistance} - ${Distance}) / ${Me.Ship.MaxVelocity}].Ceil} Seconds away"]

This:Activate_AfterBurner[]
do
{
Entity[${EntityID}]:Approach
wait 50
CurrentDistance:Set[${Entity[${EntityID}].Distance}]

if ${Entity[${EntityID}](exists)} && \
${OriginalDistance} < ${CurrentDistance}
{
UI:UpdateConsole["DEBUG: obj_Ship:Approach: ${Entity[${EntityID}].Name} is getting further away! Is it moving? Are we stuck, or colliding?", LOG_MINOR]
}
}
while ${CurrentDistance} > ${Math.Calc64[${Distance} * 1.05]}
EVE:Execute[CmdStopShip]
This:Deactivate_AfterBurner[]
}
}

; Returns the targeting range minus 10%
member:int OptimalTargetingRange()
{
return ${Math.Calc[${_Me.Ship.MaxTargetRange}*0.90]}
}
I did notice these functions in obj_Ship.iss
Only a simple guide on how to use them :)

Especially when you are using missiles - that its gets the missiles velocity+max flight*0.90 and then align to it.
Same goes for guns
 
Do I need to alter something in here? Or just use this snippet as is?

Thanks for this man, but can you guide me a tad more on this?

Neothereal <----- newb...
 
It's not perfect yet, but here is a 99% working snippet;

USE AT OWN RISK :)

just make a backup of obj_Combat.iss

and then replace the content of the original with this one:

PHP:
#ifndef __OBJ_COMBAT__
#define __OBJ_COMBAT__

objectdef obj_Combat
{
	variable string SVN_REVISION = "$Rev: 1662 $"
	variable int Version

	variable time NextPulse
	variable int PulseIntervalInSeconds = 1

	variable string CombatMode
	variable string CurrentState = "IDLE"
	variable bool   Fled = FALSE

	method Initialize()
	{
		UI:UpdateConsole["obj_Combat: Initialized", LOG_MINOR]
	}

	method Shutdown()
	{
	}

	method Pulse()
	{
		if ${EVEBot.Paused}
		{
			return
		}

		if ${Time.Timestamp} >= ${This.NextPulse.Timestamp}
		{
			This:SetState

			This.NextPulse:Set[${Time.Timestamp}]
			This.NextPulse.Second:Inc[${This.PulseIntervalInSeconds}]
			This.NextPulse:Update
		}
	}

	method SetState()
	{
		if ${_Me.InStation} == TRUE
		{
	  		This.CurrentState:Set["INSTATION"]
	  		return
		}

		if ${EVEBot.ReturnToStation}
		{
			This.CurrentState:Set["FLEE"]
			return
		}

		if ${_Me.GetTargets} > 0
		{
			This.CurrentState:Set["FIGHT"]
		}
		else
		{
			This.CurrentState:Set["IDLE"]
		}
	}

	method SetMode(string newMode)
	{
		This.CombatMode:Set[${newMode}]
	}

	member:string Mode()
	{
		return ${This.CombatMode}
	}

	function ProcessState()
	{
		if ${This.CurrentState.NotEqual["INSTATION"]}
		{
			if ${_Me.ToEntity.IsWarpScrambled}
			{
				; TODO - we need to quit if a red warps in while we're scrambled -- cybertech
				UI:UpdateConsole["Warp Scrambled: Ignoring System Status"]
			}
			elseif !${Social.IsSafe}
			{
				UI:UpdateConsole["Debug: Fleeing: Local isn't safe"]
				call This.Flee
				return
			}
			elseif (!${Ship.IsAmmoAvailable} && ${Config.Combat.RunOnLowAmmo})
			{
				UI:UpdateConsole["Debug: Fleeing: Low ammo"]
				; TODO - what to do about being warp scrambled in this case?		
				call This.Flee
				return
			}
			call This.ManageTank
		}

		UI:UpdateConsole["Debug: Combat: This.Fled = ${This.Fled} This.CurrentState = ${This.CurrentState} Social.IsSafe = ${Social.IsSafe}"]

		switch ${This.CurrentState}
		{
			case INSTATION
				if ${Social.IsSafe}
				{
					call Station.Undock
				}
				break
			case IDLE
				break
			case FLEE
				call This.Flee
				break
			case FIGHT
				call This.Fight
				break
		}
	}

	function Fight()
	{
		Ship:Deactivate_Cloak
		while ${Ship.IsCloaked}
		{
			waitframe
		}
		;Ship:Offline_Cloak
		;Ship:Online_Salvager

		; Reload the weapons -if- ammo is below 30% and they arent firing
		Ship:Reload_Weapons[FALSE]

		; Activate the weapons, the modules class checks if there's a target (no it doesn't - ct)
		Ship:Activate_TargetPainters
		Ship:Activate_StasisWebs
		; Ship:Activate_Weapons
		; Ship.Drones:SendDrones
		
		; Test ship range
		
	variable bool missionComplete = FALSE
	variable time breakTime

	while !${missionComplete}
	{
		 ; wait up to 15 seconds for spawns to appear
		 breakTime:Set[${Time.Timestamp}]
		 breakTime.Second:Inc[15]
		 breakTime:Update

		 while TRUE
		 {
			if ${This.HostileCount} > 0
			{
			   break
			}

			if ${Time.Timestamp} >= ${breakTime.Timestamp}
			{
			   break
			}

			waitframe
		 }
		UI:UpdateConsole[" --- check 1b: ${This.HostileCount}"]
		if ${This.HostileCount} > 0
		{
			; wait up to 15 seconds for agro
			breakTime:Set[${Time.Timestamp}]
			breakTime.Second:Inc[15]
			breakTime:Update
   
			while TRUE
			{
			   if ${_Me.GetTargetedBy} > 0
			   {
				  break
			   }
   
			   if ${Time.Timestamp} >= ${breakTime.Timestamp}
			   {
				  break
			   }
   
			   waitframe
			}

			while ${This.HostileCount} > 0
			{
			UI:UpdateConsole[" --- check WHILE: ${This.HostileCount}"]
			   if ${_Me.GetTargetedBy} > 0 || ${Math.Calc[${_Me.GetTargeting}+${_Me.GetTargets}]} > 0
			   {
			   UI:UpdateConsole[" --- check call This.TargetAgressors"]
				  call This.TargetAgressors
			   }
			   else
			   {
			   UI:UpdateConsole[" --- check call This.PullTarget"]
				  call This.PullTarget
			   }

			  ; This.Combat:SetState
			  ; call This.Combat.ProcessState

			   wait 100
			}
		}
		if ${This.HostileCount} == 0
		{
		missionComplete:Set[TRUE]
		
		}
		waitframe
	}

	
	}

	function TargetAgressors()
   {
	  variable index:entity targetIndex
	  variable iterator     targetIterator

	  EVE:DoGetEntities[targetIndex, CategoryID, CATEGORYID_ENTITY]
	  targetIndex:GetIterator[targetIterator]
		;${Ship.OptimalTargetingRange}*0.10
	  UI:UpdateConsole["GetTargeting = ${_Me.GetTargeting}, GetTargets = ${_Me.GetTargets}"]
	  UI:UpdateConsole["${Ship.SafeMaxLockedTargets} : ${_Me.GetTargeting} + ${_Me.GetTargets}"]
	  
	  if ${targetIterator:First(exists)}
	  {
		 do
		 {
			 ; if ${targetIterator.Value.IsLockedTarget}  && \
			   ; ${Ship.SafeMaxLockedTargets} >= ${Math.Calc[${_Me.GetTargeting}+${_Me.GetTargets}]}
			; {
			UI:UpdateConsole["${targetIterator.Value.IsTargetingMe} : ${targetIterator.Value.BeingTargeted} + ${targetIterator.Value.IsLockedTarget}"]
			if ${targetIterator.Value.IsTargetingMe} && \
			   !${targetIterator.Value.BeingTargeted} && \
			   ${targetIterator.Value.IsLockedTarget} && \
			   ${Ship.SafeMaxLockedTargets} <= ${Math.Calc[${_Me.GetTargeting}+${_Me.GetTargets}]}
			{
			UI:UpdateConsole["${targetIterator.Value.Distance}"]
			   if ${targetIterator.Value.Distance} > 5000
			   {
				  Ship:Deactivate_Weapons
				  Ship:Activate_AfterBurner
				  targetIterator.Value:Approach
				  wait 10
			   }
			   else
			   {
				targetIterator.Value:Approach
				 ; EVE:Execute[CmdStopShip]
				  Ship:Deactivate_AfterBurner
				  Ship.Drones:SendDrones
				  ;targetIterator.Value:LockTarget
				  Ship:Activate_Weapons
				  wait 10
			   }
			   
			 }
		 }
		 ;return TRUE
		 while ${targetIterator:Next(exists)}
		; return FALSE
	  }
   }
   
   function PullTarget()
   {
	  variable index:entity targetIndex
	  variable iterator     targetIterator

	  EVE:DoGetEntities[targetIndex, CategoryID, CATEGORYID_ENTITY]
	  targetIndex:GetIterator[targetIterator]

	  /* FOR NOW just pull the closest target */
	  if ${targetIterator:First(exists)}
	  {
		 do
		 {
			if ${targetIterator.Value.Distance} > 10000
				  {
					 Ship:Activate_AfterBurner
					 targetIterator.Value:Approach
				  }
				  else
				  {
					 EVE:Execute[CmdStopShip]
					 Ship:Deactivate_AfterBurner
					 targetIterator.Value:LockTarget
					 Ship:Activate_Weapons
					 wait 10
					
				  }
		 }
		 while ${targetIterator:Next(exists)}
	  }
   }
   
   member:int HostileCount()
   {
	  variable index:entity targetIndex
	  variable iterator     targetIterator
	  variable int          targetCount = 0

	  EVE:DoGetEntities[targetIndex, CategoryID, CATEGORYID_ENTITY]
	  targetIndex:GetIterator[targetIterator]

	  if ${targetIterator:First(exists)}
	  {
		 do
		 {
			switch ${targetIterator.Value.GroupID} 
			{
			   case GROUP_LARGECOLLIDABLEOBJECT
			   case GROUP_LARGECOLLIDABLESHIP
			   case GROUP_LARGECOLLIDABLESTRUCTURE
				  continue

			   default               
				  targetCount:Inc
				  break
			}
		 }
		 while ${targetIterator:Next(exists)}
	  }

	  return ${targetCount}
   }
   
   member:bool TargetNPCs()
	{
		variable index:entity Targets
		variable iterator Target
		variable bool HasTargets = FALSE

		if ${_Me.Ship.MaxLockedTargets} == 0
		{
			UI:UpdateConsole["Jammed, cant target..."]
			return TRUE
		}
		
		EVE:DoGetEntities[Targets, CategoryID, CATEGORYID_ENTITY]
		Targets:GetIterator[Target]

		if ${Target:First(exists)}
		{
		   do
		   {
			switch ${Target.Value.GroupID} 
			{
			   case GROUP_LARGECOLLIDABLEOBJECT
			   case GROUP_LARGECOLLIDABLESHIP
			   case GROUP_LARGECOLLIDABLESTRUCTURE
				  continue

			   default               
				  break
			}
			
			   if !${Target.Value.IsLockedTarget} && !${Target.Value.BeingTargeted}
			   {
				   if ${_Me.GetTargets} < ${Ship.MaxLockedTargets}
				   {
					   UI:UpdateConsole["Locking ${Target.Value.Name}"]
					   Target.Value:LockTarget
				   }
			   }
				
			   ; Set the return value so we know we have targets
			   HasTargets:Set[TRUE]
		   }
		   while ${Target:Next(exists)}
	  }
			
		if ${HasTargets} && ${Me.ActiveTarget(exists)}
		{
			variable int OrbitDistance
			OrbitDistance:Set[${Math.Calc[${_Me.Ship.MaxTargetRange}*0.40/1000].Round}]
			OrbitDistance:Set[${Math.Calc[${OrbitDistance}*1000]}]
			Me.ActiveTarget:Orbit[${OrbitDistance}]
		}
		
		return ${HasTargets}
	}
   
	function Flee()
	{
		This.CurrentState:Set["FLEE"]
		This.Fled:Set[TRUE]

		if ${Config.Combat.RunToStation}
		{
			call This.FleeToStation
		}
		else
		{
			call This.FleeToSafespot
		}
	}

	function FleeToStation()
	{
		if !${Station.Docked}
		{
			call Station.Dock
		}
	}

	function FleeToSafespot()
	{
		if ${Safespots.IsAtSafespot}
		{
			if !${Ship.IsCloaked}
			{
				Ship:Activate_Cloak[]
			}
		}
		else
		{
			; Are we at the safespot and not warping?
			if ${_Me.ToEntity.Mode} != 3
			{
				call Safespots.WarpTo
				wait 30
			}
		}
	}

	method CheckTank()
	{
		if ${This.Fled}
		{
			/* don't leave the "fled" state until we regen */
			if (${_Me.Ship.ArmorPct} < 50 || \
				(${_Me.Ship.ShieldPct} < 80 && ${Config.Combat.MinimumShieldPct} > 0) || \
				${_Me.Ship.CapacitorPct} < 80 )
			{
					This.CurrentState:Set["FLEE"]
					UI:UpdateConsole["Debug: Staying in Flee State: Armor: ${_Me.Ship.ArmorPct} Shield: ${_Me.Ship.ShieldPct} Cap: ${_Me.Ship.CapacitorPct}", LOG_DEBUG]
			}
			else
			{
					This.Fled:Set[FALSE]
					This.CurrentState:Set["IDLE"]
			}
		}
		elseif (${_Me.Ship.ArmorPct} < ${Config.Combat.MinimumArmorPct}  || \
				${_Me.Ship.ShieldPct} < ${Config.Combat.MinimumShieldPct} || \
				${_Me.Ship.CapacitorPct} < ${Config.Combat.MinimumCapPct})
		{
			UI:UpdateConsole["Armor is at ${_Me.Ship.ArmorPct.Int}%: ${Me.Ship.Armor.Int}/${Me.Ship.MaxArmor.Int}", LOG_CRITICAL]
			UI:UpdateConsole["Shield is at ${_Me.Ship.ShieldPct.Int}%: ${Me.Ship.Shield.Int}/${Me.Ship.MaxShield.Int}", LOG_CRITICAL]
			UI:UpdateConsole["Cap is at ${_Me.Ship.CapacitorPct.Int}%: ${Me.Ship.Capacitor.Int}/${Me.Ship.MaxCapacitor.Int}", LOG_CRITICAL]

			if !${Config.Combat.RunOnLowTank}
			{
				UI:UpdateConsole["Run On Low Tank Disabled: Fighting", LOG_CRITICAL]
			}
			elseif ${_Me.ToEntity.IsWarpScrambled}
			{
				UI:UpdateConsole["Warp Scrambled: Fighting", LOG_CRITICAL]
			}
			else
			{
				UI:UpdateConsole["Fleeing due to defensive status", LOG_CRITICAL]
				This.CurrentState:Set["FLEE"]
			}
		}
	}

	function ManageTank()
	{
		if ${_Me.Ship.ArmorPct} < 100
		{
			/* Turn on armor reps, if you have them
				Armor reps do not rep right away -- they rep at the END of the cycle.
				To counter this we start the rep as soon as any damage occurs.
			*/
			Ship:Activate_Armor_Reps[]
		}
		elseif ${_Me.Ship.ArmorPct} > 98
		{
			Ship:Deactivate_Armor_Reps[]
		}

		if ${_Me.Ship.ShieldPct} < 85 || ${Config.Combat.AlwaysShieldBoost}
		{   /* Turn on the shield booster, if present */
			Ship:Activate_Shield_Booster[]
		}
		elseif ${_Me.Ship.ShieldPct} > 95 && !${Config.Combat.AlwaysShieldBoost}
		{
			Ship:Deactivate_Shield_Booster[]
		}

		if ${_Me.Ship.CapacitorPct} < 20
		{   /* Turn on the cap booster, if present */
			Ship:Activate_Cap_Booster[]
		}
		elseif ${_Me.Ship.CapacitorPct} > 80
		{
			Ship:Deactivate_Cap_Booster[]
		}

		; Active shield (or armor) hardeners
		; If you don't have hardeners this code does nothing.
		if ${_Me.GetTargetedBy} > 0
		{
			Ship:Activate_Hardeners[]

			/* We have aggro now, yay! Let's launch some drones */
			if !${This.Fled} && ${Config.Combat.LaunchCombatDrones} && \
				${Ship.Drones.DronesInSpace} == 0 && \
				!${Ship.InWarp}
			{
				Ship.Drones:LaunchAll[]
			}
		}
		else
		{
			Ship:Deactivate_Hardeners[]
		}

		This:CheckTank
	}
}

#endif /* __OBJ_COMBAT__ */
 
I shall check it out man. Thanks

although, I'm not using AB, but I don't think it will matter. I just want the F ship to move.
 
You sir...are wrong. Works fine with a drake using HM (grouped)
And I say again: "script doesn't work" :)

I group all launchers to one group, script activate some modules, but not weapons modules.

Maybe this debug information can help to you.

13:42:01: Debug: Combat: This.Fled = FALSE This.CurrentState = IDLE Social.IsSafe = TRUE
13:42:01: Debug: Ratter: This.Combat.Fled = FALSE This.CurrentState = FIGHT Social.IsSafe = TRUE
13:42:01: NPC: Angel War General(Battleship) 800k isk
13:42:01: NPC: Battleship Value is 800k isk
13:42:02: Locking Angel War General
13:42:07: Debug: Combat: This.Fled = FALSE This.CurrentState = IDLE Social.IsSafe = TRUE
13:42:07: Debug: Ratter: This.Combat.Fled = FALSE This.CurrentState = FIGHT Social.IsSafe = TRUE
13:42:12: Activating Invulnerability Field II
13:42:12: Launching drones...
13:42:12: Debug: Combat: This.Fled = FALSE This.CurrentState = FIGHT Social.IsSafe = TRUE
13:42:12: Activating Phased Weapon Navigation Array Generation Extron
13:42:12: --- check 1b: 1
13:42:12: --- check WHILE: 1
13:42:12: --- check call This.TargetAgressors
13:42:12: GetTargeting = 0, GetTargets = 1
13:42:12: 3 : 0 + 1
13:42:12: TRUE : FALSE + TRUE
13:42:16: 4 drones deployed
13:42:22: --- check WHILE: 1
13:42:22: --- check call This.TargetAgressors
13:42:22: GetTargeting = 0, GetTargets = 1
13:42:22: 3 : 0 + 1
13:42:22: TRUE : FALSE + TRUE
13:42:32: --- check WHILE: 1
13:42:32: --- check call This.TargetAgressors
13:42:32: GetTargeting = 0, GetTargets = 1
13:42:32: 3 : 0 + 1
13:42:32: TRUE : FALSE + TRUE
13:42:42: --- check WHILE: 1
13:42:42: --- check call This.TargetAgressors
13:42:42: GetTargeting = 0, GetTargets = 1
13:42:42: 3 : 0 + 1
13:42:42: TRUE : FALSE + TRUE
13:42:52: --- check WHILE: 1
13:42:52: --- check call This.TargetAgressors
13:42:52: GetTargeting = 0, GetTargets = 1
 

thorthor

Member
The easiest way to let the bot orbit:
In obj_Targets look for variable int OrbitDistance and change the lines to

if ${HasTargets} && ${Me.ActiveTarget(exists)}
{
variable int OrbitDistance = 45000
;OrbitDistance:Set[${Math.Calc[${_Me.Ship.MaxTargetRange}*0.40/1000].Round}]
;OrbitDistance:Set[${Math.Calc[${OrbitDistance}*1000]}]
Me.ActiveTarget:Orbit[${OrbitDistance}]
}
 
the easiest way to let the bot orbit:
In obj_targets look for variable int orbitdistance and change the lines to

if ${hastargets} && ${me.activetarget(exists)}
{
variable int orbitdistance = 45000
;orbitdistance:set[${math.calc[${_me.ship.maxtargetrange}*0.40/1000].round}]
;orbitdistance:set[${math.calc[${orbitdistance}*1000]}]
me.activetarget:eek:rbit[${orbitdistance}]
}

works like a charm.... U da man
 
if ${hastargets} && ${me.activetarget(exists)}
{
variable int orbitdistance = 45000
;orbitdistance:set[${math.calc[${_me.ship.maxtargetrange}*0.40/1000].round}]
;orbitdistance:set[${math.calc[${orbitdistance}*1000]}]
me.activetargetrbit[${orbitdistance}]
}
If you leave those ; there, then I think you will have to manually put your desired orbit distance by right clicking the button.
 
Works like a charm. whatever u set your orbit distance to int he script, simply match that in game on the 'set default orbit' distance option on your overview :)


Love it!!

Especially in the tempest with 1400's, take that transversal way down, good for tracking :)
 
very odd, it worked one time and one time only, but now it just does something weird, it alligns out and doesn't orbit at all.

this is very odd.
 

diraven

Active Member
very odd, it worked one time and one time only, but now it just does something weird, it alligns out and doesn't orbit at all.

this is very odd.
if ${hastargets} && ${me.activetarget(exists)}
{
variable int orbitdistance
orbitdistance:set[${math.calc[${_me.ship.maxtargetrange}*0.20/1000].round}]
;orbitdistance:set[${math.calc[${orbitdistance}*1000]}]
me.activetargetrbit[${orbitdistance}]
}
I decided to do this. I changed it so it will simply orbit at 20 max target range. Seems to work fine. Setting orbitdistance would only work sometimes for me.
 
Top Bottom