Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------SCRIPT CONFIG--------------------------------\\
- moon = GetCachedCelestial("M:3:438:8")
- coord, _ = ParseCoord("P:3:439:9")
- maxFleetValue = 0
- numberOfProbes = 5
- Deathstars = 0
- Cr = 0
- Bs = 0
- dessy = 0
- Mission = 0
- time = import("time")
- func getShipBaseSpeed(ship) {
- speed = 0
- switch ship {
- case ESPIONAGEPROBE:
- speed = 100000000
- case CRUISER:
- speed = 15000
- case LIGHTFIGHTER:
- speed = 12500
- case BATTLESHIP:
- speed = 10000
- case BATTLECRUISER:
- speed = 10000
- case HEAVYFIGHTER:
- speed = 10000
- case SMALLCARGO:
- speed = 5000
- case LARGECARGO:
- speed = 7500
- case RECYCLER:
- speed = 2000
- case DESTROYER:
- speed = 5000
- case BOMBER:
- speed = 4000
- case COLONYSHIP:
- speed = 2500
- case DEATHSTAR:
- speed = 100
- default:
- speed = 0
- }
- return speed
- }
- func findLowestShipInFleet(ships, cd, id, hd) {
- speed = 0
- if ships.EspionageProbe > 0 {
- tmp = getShipBaseSpeed(ESPIONAGEPROBE)
- tmp = tmp + (tmp / 100 * 10 * cd)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(ESPIONAGEPROBE, speed)
- }
- if ships.Cruiser > 0 {
- tmp = getShipBaseSpeed(CRUISER)
- tmp = tmp + (tmp / 100 * 20 * id)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(CRUISER, speed)
- }
- if ships.LightFighter > 0 {
- tmp = getShipBaseSpeed(LIGHTFIGHTER)
- tmp = tmp + (tmp / 100 * 10 * cd)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(LIGHTFIGHTER, speed)
- }
- if ships.Battleship > 0 {
- tmp = getShipBaseSpeed(BATTLESHIP)
- tmp = tmp + (tmp / 100 * 30 * hd)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(BATTLESHIP, speed)
- }
- if ships.Battlecruiser > 0 {
- tmp = getShipBaseSpeed(BATTLECRUISER)
- tmp = tmp + (tmp / 100 * 30 * hd)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(BATTLECRUISER, speed)
- }
- if ships.HeavyFighter > 0 {
- tmp = getShipBaseSpeed(HEAVYFIGHTER)
- tmp = tmp + (tmp / 100 * 20 * id)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(HEAVYFIGHTER, speed)
- }
- if ships.SmallCargo > 0 {
- tmp = getShipBaseSpeed(SMALLCARGO)
- if id >= 5 {
- tmp = tmp + (tmp / 100 * 20 * id)
- } else {
- tmp = tmp + (tmp / 100 * 10 * cd)
- }
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(SMALLCARGO, speed)
- }
- if ships.LargeCargo > 0 {
- tmp = getShipBaseSpeed(LARGECARGO)
- tmp = tmp + (tmp / 100 * 10 * cd)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(LARGECARGO, speed)
- }
- if ships.Recycler > 0 {
- tmp = getShipBaseSpeed(RECYCLER)
- if hd >= 15 {
- tmp = tmp + (tmp / 100 * 30 * hd)
- } else if id >= 17 {
- tmp = tmp + (tmp / 100 * 20 * id)
- } else {
- tmp = tmp + (tmp / 100 * 10 * cd)
- }
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(RECYCLER, speed)
- }
- if ships.Destroyer > 0 {
- tmp = getShipBaseSpeed(DESTROYER)
- tmp = tmp + (tmp / 100 * 30 * hd)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(DESTROYER, speed)
- }
- if ships.Bomber > 0 {
- tmp = getShipBaseSpeed(BOMBER)
- if hd >= 8 {
- tmp = tmp + (tmp / 100 * 30 * hd)
- } else {
- tmp = tmp + (tmp / 100 * 20 * id)
- }
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(BOMBER, speed)
- }
- if ships.ColonyShip > 0 {
- tmp = getShipBaseSpeed(COLONYSHIP)
- tmp = tmp + (tmp / 100 * 20 * id)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(COLONYSHIP, speed)
- }
- if ships.Deathstar > 0 {
- tmp = getShipBaseSpeed(DEATHSTAR)
- tmp = tmp + (tmp / 100 * 30 * hd)
- if speed > tmp || speed == 0 {
- speed = tmp
- }
- //Print(DEATHSTAR, speed)
- }
- return speed
- }
- func getReport(coord) {
- report, err = GetEspionageReportFor(coord)
- if err != nil {
- LogError("[SPY] err getting espionage report " + err)
- }
- Print(report)
- list = {}
- if report.HasResearches {
- cd = report.CombustionDrive
- if (*cd) >= 1 { list.COMBUSTIONDRIVE = *cd } else { list.COMBUSTIONDRIVE = 0 }
- id = report.ImpulseDrive
- if (*id) >= 1 { list.IMPULSEDRIVE = *id } else { list.IMPULSEDRIVE = 0 }
- hd = report.HyperspaceDrive
- if (*hd) >= 1 { list.HYPERSPACEDRIVE = *hd } else { list.HYPERSPACEDRIVE = 0 }
- } else {
- LogInfo("[SPY] probes couldnt get research info")
- return nil
- }
- return list
- }
- func spyCoord(coord, origin) {
- LogInfo("spy " + coord)
- for {
- slots = GetSlots()
- if slots.InUse < slots.Total {
- fleet = NewFleet()
- fleet.SetOrigin(origin)
- fleet.SetDestination(coord)
- fleet.SetMission(SPY)
- fleet.AddShips(ESPIONAGEPROBE, numberOfProbes)
- fleet, err = fleet.SendNow()
- if err != nil {
- LogError("[SPY] error sending probes " + err)
- }
- Sleep((4 + fleet.ArriveIn) * 1000)
- break
- } else {
- Sleep(30000)
- }
- }
- }
- func doWork() {
- fleets, _ = Phalanx(moon.GetID(), coord)
- Impact = 0
- foundingFleet = 0
- for fleet in fleets {
- currentFleetValue = fleet.Ships.FleetValue()
- if currentFleetValue > maxFleetValue {
- maxFleetValue = currentFleetValue
- foundingFleet = fleet
- Deathstars = fleet.Ships.Deathstar
- Cr = fleet.Ships.Cruiser
- Bs = fleet.Ships.Battleship
- dessy = fleet.Ships.Destroyer
- Mission = fleet.Mission
- Impact = time.Now()
- Impact = Impact.Add(time.Second * fleet.ArriveIn)
- Impact = Impact.Add(time.Hour * 1)
- Print("============================================================")
- Print("Fleets Value: " + (Dotify(fleet.Ships.FleetValue())))
- Print("Fleets From: " + fleet.Origin)
- Print("Fleets to : " + fleet.Destination)
- Print("Arrives In: " + (ShortDur(fleet.ArriveIn)))
- Print("Impact Time: " + Impact.Format("15:04:05 PM"))
- Print("Fleet Mission: " + fleet.Mission)
- Print("Ships in the Air: " + fleet.Ships)
- Print("============================================================")
- }
- }
- for {
- activeFleet = false
- fleets, _ = Phalanx(moon.GetID(), coord)
- if len(fleets) > 0 {
- for fleet in fleets {
- if fleet.Ships.Deathstar == Deathstars && fleet.Ships.Cruiser == Cr && fleet.Ships.Battleship == Bs && fleet.Ships.Destroyer == dessy {
- activeFleet = true
- }
- }
- }
- if activeFleet == false {
- recalledTime = time.Now()
- recalledTime = recalledTime.Add(time.Hour * 1)
- Print("Fleet Recalled at " + recalledTime.Format("15:04:05 PM") + " Fleet had a value of " + (Dotify(maxFleetValue)) + " From the planet " + coord)
- PlaySound(1, 1.0)
- report = {}
- for {
- spyCoord(foundingFleet.Origin, moon)
- report = getReport(foundingFleet.Origin)
- if report != nil {
- break
- }
- }
- Print(report)
- lowestSpeedShipInFleet = findLowestShipInFleet(foundingFleet.Ships, report.COMBUSTIONDRIVE, report.IMPULSEDRIVE, report.HYPERSPACEDRIVE)
- distance = Distance(foundingFleet.Origin, foundingFleet.Destination)
- LogInfo("Here is your desired calculation")
- speedFactor = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
- for s in speedFactor {
- v = lowestSpeedShipInFleet // lowest ship in fleet
- a = OGAME_SERVER.Settings.FleetSpeed // fleet speed
- d = distance // distance between planets / moons
- flight = Round(((3500 / s) * Pow((d * 10 / v), (0.5)) + 10) / a)
- Print("============================ " + s*100 + " % ===============================")
- Print("flight time: ", ShortDur(flight))
- Print("Fleet Recalled at " + recalledTime.Format("3:04:15PM") + " Fleet had a value of " + (Dotify(maxFleetValue)) + " From the planet " + coord)
- Launchtime = Impact.Add(-flight * time.Second)
- Print("Launchtime = Impact Time:" + Impact.Format("15:04:05 PM") + " - flight: " + (ShortDur(flight)) + " = Launchtime: " + Launchtime.Format("15:04:05 PM"))
- Journey = recalledTime.Add(-Launchtime * time.Second)
- Print("Journey = Recall Time: " + recalledTime.Format("3:04:15 PM") + " - Launchtime:", Journey.Format("3:04:15 PM"))
- Return = recalledTime.Sub(Journey)
- //Return = recalledTime.Add(Duration)
- Return = Return.Add(1 * time.Hour)
- Print("Return = Recall Time add Journey:", Return.Format("3:04:15PM"))
- Print("==================================================================")
- // expectedTime = recalledTime.Add((secs - foundingFleet.ArriveIn) * time.Second)
- // LogInfo("Fleet could be back on " + s*100 + "% " + expectedTime.Format("Jan 02, 15:04:05"))
- }
- break
- }
- Sleep(3 * 1000)
- }
- }
- doWork()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement