Simple OpenKore Launcher

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Simple OpenKore Launcher

#1 Post by sli »

UPDATE: There are now two different versions of this launcher. See below.

I haven't actually tested it as of posting it, but here's a little launcher I just wrote mainly as a sample for anyone who'd like one. It's a tad programmer-slanted (config is an associative array), but should be fairly simple to figure out. Just a note about the config, mon_control and item_control take a path name (like control/mon_control_new.txt), and rname is the name you appended to the config file (ex: for control/config-Link.txt, which is my config for Link To The Past, the rname is "Link"). Also, None is a keyword, NOT A STRING. If you quote it, things will break. The acct setting is trivial, it just helps you differentiate between characters on different accounts. Notice I just use "main" and "alt" for mine.

Code: Select all

import os

CONFIG = {
    'Flipkick':{
        'rname':None,
        'acct':'main',
        'mon_control':None,
        'items_control':None
    },

    'Malevolyn':{
        'rname':None,
        'acct':'main',
        'mon_control':None,
        'items_control':None
    },

    'Link To The Past':{
        'rname':'Link',
        'acct':'alt',
        'mon_control':None,
        'items_control':None
    },

    'Dash':{
        'rname':None,
        'acct':'alt',
        'mon_control':'control/mon_control-Dash.txt',
        'items_control':None
    },

    'Tike Myson':{
        'rname':'Tike',
        'acct':'main',
        'mon_control':'control/mon_control-Dash.txt',
        'items_control':None
    }
}

CHAR_LIST = CONFIG.keys()
CHAR_LIST.sort()

print '---- Characters ----'

at = 0
for k in CHAR_LIST:
    if 'acct' in CONFIG[k]: acct = ' (Account: %s)' % CONFIG[k]['acct']
    else: acct = ''
    print '%s: %s%s' % (at,k,acct)
    at += 1
print

while 1:
    c = raw_input('Choose: ')
    try:
        c = int(c)
        break
    except:
        print 'Please enter a NUMBER. Try again.'
        continue

print '\nStarting bot for %s...\n' % CHAR_LIST[c]

n = CHAR_LIST[c]
if 'rname' in CONFIG[n] and CONFIG[n]['rname']: rn = CONFIG[n]['rname']
else: rn = n

if os.name == 'nt':
    execStr = 'perl openkore.pl --config=control/config-' + rn + '.txt'
else:
    execStr = 'perl ./openkore.pl --config=control/config-' + rn + '.txt'

if 'mon_control' in CONFIG[n] and CONFIG[n]['mon_control']:
    execStr += ' --mon_control=' + CONFIG[n]['mon_control']

if 'items_control' in CONFIG[n] and CONFIG[n]['items_control']:
    execStr += ' --items_control=' + CONFIG[n]['items_control']

if 'sys' in CONFIG[n] and CONFIG[n]['sys'] :
    execStr += ' --sys=' + CONFIG[n]['sys']

if 'pickupitems' in CONFIG[n] and CONFIG[n]['pickupitems']:
    execStr += ' --pickupitems=' + CONFIG[n]['pickupitems']

while 1:
    os.system(execStr)
    print '\n'

New INI-based version - Use this one if you don't mind having two files (instead of just one) or aren't comfortable editing code.

Code: Select all

import os, ConfigParser

ini = ConfigParser.SafeConfigParser()
ini.read('Launcher.ini')

CHAR_LIST = ini.sections()
CHAR_LIST.sort()

print '---- Characters ----'

at = 0
for k in CHAR_LIST:
    if ini.has_option(k, 'acct'): acct = ' (Account: %s)' % ini.get(k, 'acct')
    else: acct = ''
    print '%s: %s%s' % (at,k,acct)
    at += 1
print

while 1:
    c = raw_input('Choose: ')
    try:
        c = int(c)
        break
    except:
        print 'Please enter a NUMBER. Try again.'
        continue

print '\nStarting bot for %s...\n' % CHAR_LIST[c]

n = CHAR_LIST[c]
if ini.has_option(n, 'rname'): rn = ini.get(n, 'rname')
else: rn = n

if os.name == 'nt':
    execStr = 'perl openkore.pl --config=control/config-' + rn + '.txt'
else:
    execStr = 'perl ./openkore.pl --config=control/config-' + rn + '.txt'

if ini.has_option(n, 'mon_control'):
    execStr += ' --mon_control=' + ini.get(n, 'mon_control')

if ini.has_option(n, 'items_control'):
    execStr += ' --items_control=' + ini.get(n, 'items_control')

if ini.has_option(n, 'sys'):
    execStr += ' --sys=' + ini.get(n, 'sys')

if ini.has_option(n, 'pickupitems'):
    execStr += ' --pickupitems=' + ini.get(n, 'pickupitems')

while 1:
    os.system(execStr)
    print '\n'
And here is a sample Launcher.ini. Things to note include the two different setting styles and the semi-advanced string substitution with %()s:

Code: Select all

[Flipkick]
acct=main

[Malevolyn]
acct=main

[Link To The Past]
BASE: control/Link
rname: Link
acct: alt
items_control: %(BASE)s/item_control-Link.txt

[Dash]
acct=alt
mon_control=control/mon_control-Dash.txt

[Tike Myson]
rname=Tike
mon_control=control/mon_control-Dash.txt
Sample output:

Code: Select all

---- Characters ----
0: Dash (Account: alt)
1: Flipkick (Account: main)
2: Link To The Past (Account: alt)
3: Malevolyn (Account: main)

Choose: 1

Starting bot for Flipkick...

*** OpenKore what-will-become-2.0.7 (SVN Version)  - Custom Ragnarok Online client ***
***   http://www.openkore.com/   ***

Loading all plugins...
Loading plugin plugins/critCount.pl...
Loading plugin plugins/koreSnarl.pl...
...
cs : ee : realist
sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: Simple OpenKore Launcher

#2 Post by sli »

Bump for bug fix.
cs : ee : realist
isieo
Kami-Sama Desu~
Kami-Sama Desu~
Posts: 195
Joined: 04 Apr 2008, 09:24
Noob?: Yes
Location: 31th Dimension

Re: Simple OpenKore Launcher

#3 Post by isieo »

make a gui =P
Silence
Human
Human
Posts: 26
Joined: 17 Aug 2008, 01:20
Noob?: No

Re: Simple OpenKore Launcher

#4 Post by Silence »

Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: Simple OpenKore Launcher

#5 Post by Technology »

@ silence
dKore is for windows only.
This launcher is cross platform.
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: Simple OpenKore Launcher

#6 Post by sli »

It also doesn't cater itself to noobs because you still have to manage the files yourself. This just gives you a universal way of starting all your bots. I'd like to rewrite it in C or something, but I'm lazy. I'll at least write a version using Python's ConfigParser module which would allow some bitchin' features. For example:

Code: Select all

[Flipkick]
base=control\Flipkick
config=%(base)s\config.txt
mon_control=%(base)s\mon_control.txt
Yes, you can reference other config variable inside the same block with the %()s syntax.
cs : ee : realist
Silence
Human
Human
Posts: 26
Joined: 17 Aug 2008, 01:20
Noob?: No

Re: Simple OpenKore Launcher

#7 Post by Silence »

Technology wrote:@ silence
dKore is for windows only.
This launcher is cross platform.
point noted
sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: Simple OpenKore Launcher

#8 Post by sli »

Bump for INI-based version. XML version, anyone? Why the hell not, it'll be done in a few minutes.
cs : ee : realist
mnemonic
Noob
Noob
Posts: 1
Joined: 30 Oct 2008, 13:45
Noob?: No

Re: Simple OpenKore Launcher

#9 Post by mnemonic »

I appreciate your effort in making the code, my only question is how to stop the bot using your launcher?

ctrl+c isn't working for me, it just loops and loops.

the only way I can do to stop the bot is through using the kill -9 {pid} :)

Thanks,
sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: Simple OpenKore Launcher

#10 Post by sli »

Try ctrl+z, or just close the terminal.
cs : ee : realist