OGame Automizer Development Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome on the OGame Automizer Development/Support Forum

If this is your first visit, be sure to check out the
http://ogameautomizer.com/doc/manual.html : A guide written by OA users with consultation of OA author (En)

http://ogameautomizer.com/doc/manual_de.html : A guide written by OA users with consultation of OA author (Benutzerschnittstellenhandbuch) (GE)

http://ogameautomizer.com/doc/scripting_manual.html : OA Scripting Manual (En)

Pages: [1] 2 3 ... 6

Author Topic: Easiest way to scan moons with OA Scripting  (Read 29995 times)

0 Members and 1 Guest are viewing this topic.

Ablesegenauigkeit

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 75
    • View Profile
Easiest way to scan moons with OA Scripting
« on: March 12, 2012, 08:09:50 PM »

Hey DH, hey community,

I want to have a script which spys moons of my choice/in a range or of certain players.

I am not really sure how to do it, so my thoughts/problems are:

- getPlanet from where I want to send the spies.
- for-loop from i=0 to j-1, j is the number of moons i want to spy, i have to increase each step (i++).
- using sendFleet(...) command, but before that I would need a database connection for the enemies coords, right?
how can I get the results of the database, using only coordinates of ENEMIES, so no allies etc and maybe just typing in the names of the players i want to spy in a certain range?
Will it work with result.getBoolean("IsMoon") and if yes what do I have to setup before ?!

I see that oa scripting is probably the most amazing and powerful feature added to OA yet, though I never programmed myself and it is hard to me to understand what I am doing there.

Thanks for your help!


edit: oh sorry wrong section, would you move it to "Additional API requests"?
« Last Edit: March 12, 2012, 09:21:32 PM by Devil's Hand »
Logged

Devil's Hand

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2,523
    • View Profile
Re: Easiest way to scan moons with OA Scripting ?!
« Reply #1 on: March 12, 2012, 09:17:49 PM »

You will need additional API provided by this build: http://ogameautomizer.com/BetaVersion/OGameAutomizer.jar
Solution:
Code: [Select]
// Config
def coord = getPlanets().get(0).coordinates  // or Coordinates.get('X:YYY:Z')
def radius = 20
def spy2send = 2

// Definition of function to print a player info
def printPlayer = { player ->
  printOut player.playerID + "|" + player.playerName + "|" + player.planetName + "\t" +
    player.rank + "\t" +
    player.galaxy + ":" + player.system + ":" + player.planet + " " + player.isMoon + "\t" +
    player.getActivityStatusString() + "\t" +  // player.globalActivityStatus one of : OGamePlayerAbstract.ACTIVE_ACTIVITY_STATUS, INACTIVE_ACTIVITY_STATUS, LONGINACTIVE_ACTIVITY_STATUS, NOOB_ACTIVITY_STATUS, VACATION_ACTIVITY_STATUS, STRONG_ACTIVITY_STATUS, BANNED_ACTIVITY_STATUS, UNKNOWN_ACTIVITY_STATUS
    player.metalDebris + "\t" +
    player.crystalDebris + "\t" +
    (player.allianceID == 0 ? "No_Ally" : player.allianceID + "|" + player.allianceName + "|" + player.allianceRank);
}

// iterate over all targets to select only targets that meet the requirements
for(player in getPlayers()){
  if(player.galaxy==coord.galaxy && player.system>=coord.system-radius && player.system<=coord.system+radius &&
    !player.isAllyInAvoidAttackList && !player.isInAvoidAttackList &&
    (player.globalActivityStatus == OGamePlayerAbstract.ACTIVE_ACTIVITY_STATUS || player.globalActivityStatus == OGamePlayerAbstract.INACTIVE_ACTIVITY_STATUS || player.globalActivityStatus == OGamePlayerAbstract.LONGINACTIVE_ACTIVITY_STATUS) &&
    player.isMoon /*&& player.playerName.equals("Player Name") && player.rank>=XXX*/){
    // print info about the player to be probed
    printPlayer player
    // wait till have needed spies
    while(getNumberOf(ESPIONAGEPROBE, coord) < spy2send || !hasAvailableFleetSlot()){
      printOut "waiting for spies or free fleet slots..."
      printOut "Has Available Fleet slots: " + hasAvailableFleetSlot()
      printOut "ESPIONAGE PROBEs on planet: " + getNumberOf(ESPIONAGEPROBE, coord)
      sleep 30000
    }
    // send a spy ...
    def sent = sendFleet(  // sendFleet function returns a boolean [true,false], Groovy infers the type of 'sent' variable at compile time
      getPlanetFromCoordinates(coord).name,  //Planet Name: "Main Planet"
      new Coordinates(player.galaxy,player.system,player.planet,(player.isMoon ? Coordinates.MOON_TYPE : Coordinates.PLANET_TYPE)),     //Target Coordinates (yours or enemy)
      FleetMission.ESPIONAGE_MISSION,  //Missions: ATTACK_MISSION, TRANSPORT_MISSION, DEPLOYMENT_MISSION, ESPIONAGE_MISSION, COLONIZATION_MISSION, RECYCLE_MISSION, EXPEDITION_MISSION
      100,          //Speed [10-100] means 10%-100%, speed step is 10% => 10,20,30,...,100
      [ESPIONAGEPROBE : spy2send]  //SMALLCARGO, LARGECARGO, LIGHTFIGHTER, HEAVYFIGHTER, CRUISER, BATTLESHIP, COLONYSHIP, RECYCLER, ESPIONAGEPROBE, BOMBER, DESTROYER, DEATHSTAR, BATTLECRUISER
    )
    if(sent) printOut "Fleet sent !"
    else printOut "Fleet sent failed !"
  }
}

Have Fun !
DH
« Last Edit: June 10, 2014, 12:28:16 AM by Devil's Hand »
Logged

Ablesegenauigkeit

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 75
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #2 on: March 13, 2012, 09:41:56 AM »

Dude you are freaking awesome.
Thank you so much ;-))))))))
Logged

Ablesegenauigkeit

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 75
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #3 on: March 13, 2012, 09:55:19 PM »

is there a function such as "player.isAvoided" or something like that to avoid the own ally + some players you don't want to spy (e.g. in database) ?


btw: works like a bomb. awesome. I added
 player.globalActivityStatus == OGamePlayerAbstract.ACTIVE_ACTIVITY_STATUS so it only takes active players.
do you have a "list" of all functions which are implemented?
freaking powerful :)
« Last Edit: March 13, 2012, 10:15:37 PM by Ablesegenauigkeit »
Logged

Devil's Hand

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2,523
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #4 on: March 13, 2012, 09:59:38 PM »

is there a function such as "player.isAvoided" or something like that to avoid the own ally + some players you don't want to spy (e.g. in database) ?
In Hunter script example:
player.isAllyInAvoidAttackList + "\t" +
player.isInAvoidAttackList + "\t" +   //the one you are searching = "player.isAvoided"
player.isUnderSurveillance + "\t" +
player.isTarget + "\t" +
player.triggerTimeMin

Of cause you should set to avoid ally/player first in the GUI. More API for Hunter is on the way.

Regards,
« Last Edit: March 13, 2012, 10:01:39 PM by Devil's Hand »
Logged

Ablesegenauigkeit

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 75
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #5 on: March 13, 2012, 10:16:19 PM »

Wow that was fast.
So easy - I can't believe it! :-)


 player.galaxy+":"+player.system+":"+player.planet,      //Target Coordinates (yours or enemy)

how can I set up that oa sends spies to the moon and not the planet? player.isMoon delivers a boolean right? player.planet is the position, the the coords are right but not the selection that is goes to the moon ....
« Last Edit: March 13, 2012, 10:27:54 PM by Ablesegenauigkeit »
Logged

zaltan

  • Newbie
  • *
  • Offline Offline
  • Posts: 17
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #6 on: March 13, 2012, 11:58:40 PM »

My problem is that it says I've 0 spyprobes but actually I do have 80 probes, any idea? >.< i'm sorry but i've never done a script i'm a bit lost(I've tried doing something EXTREMELY simple in OA but I've 0 knowledge).

P.D. Would be possible for me to learn hwo to do script with tutorials or something like that about java? or it's quiet difficult
Logged

Devil's Hand

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2,523
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #7 on: March 14, 2012, 01:00:57 AM »

player.galaxy+":"+player.system+":"+player.planet,      //Target Coordinates (yours or enemy)

how can I set up that oa sends spies to the moon and not the planet? player.isMoon delivers a boolean right? player.planet is the position, the the coords are right but not the selection that is goes to the moon ....

Should be:
Code: [Select]
new Coordinates(player.galaxy,player.system,player.planet,Coordinates.MOON_TYPE)P.S example fixed

Code: [Select]
//Coordinates manipulation
printOut new Coordinates((byte)1,(short)2,(byte)3,Coordinates.MOON_TYPE)  //PLANET_TYPE, DEBRIS_TYPE, MOON_TYPE
def coord = Coordinates.getCoordinates("[5:5:10] SuperMoon...")  //valid values: "1:1:1", "[1:1:1]", "[1:1:1] M..." (the last one is for Moon coordinates)
printOut coord
printOut new Coordinates(coord.galaxy,coord.system,coord.planet,Coordinates.PLANET_TYPE)
printOut "["+coord.galaxy+":"+coord.system+":"+coord.planet+"]"+(coord.isMoon() ? " Moon" : "")

Quote
My problem is that it says I've 0 spyprobes but actually I do have 80 probes, any idea
Check that you have selected the right planet, in worse case provide your script.

Regards,
Logged

zaltan

  • Newbie
  • *
  • Offline Offline
  • Posts: 17
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #8 on: March 14, 2012, 04:20:13 PM »

I guess i'm placing my planet name in the wrong place :S what i do is
: change this line:
      getPlanetFromCoordinates(coord).name,  //Planet Name: "Main Planet"
to:
      getPlanetFromCoordinates(coord).I place my planet name here,  //Planet Name: "Main Planet"

and i haven't changed anything else

P.D. if i want it to send 5 probes per spy i should change this line im right?:
def spy2send = 2
Logged

Devil's Hand

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2,523
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #9 on: March 14, 2012, 08:16:11 PM »

@zaltan:
Code: [Select]
getPlanetFromCoordinates(coord).name,  //Planet Name: "Main Planet"change to
Code: [Select]
getPlanet("Planet Name").name,
Quote
P.D. if i want it to send 5 probes per spy i should change this line im right?:
def spy2send = 2
right
Logged

Ronald

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #10 on: April 07, 2012, 05:34:01 PM »

Devil, the problem with this is that getPlayers() returns an unordered hash, thus you'll be jumping from random moon to moon within that certain radius. Is there a way to make it more human? Like, starts in the beginning of the radius, spies all the moons from that SS and then increments the SS?

Thanks in advance...
Logged

Devil's Hand

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2,523
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #11 on: April 07, 2012, 08:28:55 PM »

replace:
Code: [Select]
def iter = getPlayers().iterator()by:
Code: [Select]
@ClassesDefinitionStart
class CoordComparator implements Comparator {
  public int compare(Object o1, Object o2){
    return o1.getCoordinates().compareTo(o2.getCoordinates())
  }
}
@ClassesDefinitionEnd

def p = getPlayers()
Collections.sort(p, new CoordComparator())
def iter = p.iterator()

Regards,
« Last Edit: April 08, 2012, 03:06:35 AM by Devil's Hand »
Logged

Ronald

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #12 on: April 07, 2012, 10:19:36 PM »

You sir are indeed a genious! This will be very helpful since I'm trying to develop some sort of farming bot but just with the spy component.

Thanks a lot!!! Really nice project you have here Devil :)
Logged

horatio

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #13 on: April 10, 2012, 07:11:02 PM »

I haven't been using OA for several months and some major improvements were introduced.
Really a genius job done.

Is it possible that OA spys every active, inactive and long inactive player in one galaxy (1-499) and do not take into consideration possible activity like in hunter mode + skips ally players. Also if it spies across the galaxies (2 or more) to use slower speeds to be able to spy.
I tried to do it with hunter but it is impossible (takes too long)
I wanted to fill galaxytool with spies and than search for players that have a lot of defence and a lot of ressoureces on planet/moon.

thnx in advance
« Last Edit: April 10, 2012, 07:53:40 PM by horatio »
Logged

Ablesegenauigkeit

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 75
    • View Profile
Re: Easiest way to scan moons with OA Scripting
« Reply #14 on: April 18, 2012, 10:27:41 AM »

Hey,

I have more than one moon and want to scan around all my moons.
I tried it with a for-loop, though it won't work.

Also I used the script to scan planets. Problem: it scans all planets with moons twice. It would be cool if the second scan would hit the moon OR to disable the second scan.

Any ideas?

Thanks in advance :-)
Logged
Pages: [1] 2 3 ... 6
 

Page created in 0.075 seconds with 20 queries.