neothereal
Member
Can you script something so ratter orbits or keeps at range on its focused target?
probably it will work?function Fight()
{
Shipeactivate_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
}
I did notice these functions in obj_Ship.issmethod 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]
Thiseactivate_AfterBurner[]
}
}
; Returns the targeting range minus 10%
member:int OptimalTargetingRange()
{
return ${Math.Calc[${_Me.Ship.MaxTargetRange}*0.90]}
}
#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__ */
You sir...are wrong. Works fine with a drake using HM (grouped)script doesn't work - don't activate a HM-launchers![]()
And I say again: "script doesn't work"You sir...are wrong. Works fine with a drake using HM (grouped)
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
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.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.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}]
}
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.
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.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}]
}