Openkore.com

OpenKore Forums
It is currently 27 May 2018, 07:41

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Making use of eval() in macro
PostPosted: 16 Feb 2012, 21:50 
Offline
Human
Human

Joined: 05 Oct 2010, 09:46
Posts: 24
Here's what i found out and might be useful to you who need more precise function.
Such as : Detecting specific chat room's titles and joining it.

Intro
We know that there's isn't any macro to check titles of chat room. So how do we identified chat room's title ? Have you ever notice how the console commands, chat list ? Why is when you type chat list, it will display number of chat rooms, titles, number of person in rooms, etc... ? Of course there's a function that retrieve titles !! and with eval() you can identify chat room's titles in your immediate area, also you will able to identify the name of NPC/Player created the chat room.

How-to:
Browse into your /src/commands.pm
Here you'll find how your console command works. Start searching for "chat" and you'll be seeing this cmdChatRoom next to it, now search for the latter terms.

You'll arrived where the additional syntax after "chat", there are "modify", "kick", "join", "leave", "create", "list", "info"
What we're interested here is "list"

observed how the code were written, and what variables and corresponding to titles. you'll notice that $room->{title} carries the chat room's titles; Actor::get($room->{ownerID})->name carries the name of the owner of the chat. So how do we called them? After trial-and-error and searching in forums , you'll found out that it requires $:: in front of every variables.

take note that there are 2 types of eval in macro, the is condition eval which is : eval () another is macro eval which is : @eval()

To cut-short, in order to retrieve owner of chat rooms in the immediate area (you need a counter; therefore you need to loop this function until you found your desire titles)
Code:
$foo = @eval(Actor::get($::chatRooms{$::chatRoomsID[$i]}->{ownerID})->{name} eq 'NPC/Player names')


note:
1)the $i is a counter, it will keep looping until it found your 'NPC/Player names' and also the number you required in do chat join $i later.
2) 'NPC/Player names' is the name of Player/NPC(note that these names depends in /tables/npcs.txt) created the chat rooms. e.g.: RegistrationRed (in Battlegrounds)

Now when you join the chat room, you want to make sure the titles is correct after you join the chat room.
Code:
eval (($::chatRooms{$::currentChatRoom}->{title}) ne 'Chat Room Titles')


Where this condition will be triggered if the desire name is NOT Chat Room Titles and therefore, leave the chat room and looking for a correct ones. e.g.: Battle Station 5 Players

Now those guys who want to prevent you from entering the correct chat room is wasted !! As you are now able to tell the name of the NPC who created the chat room titled Battle Station 5 Players is RegistrationRed and will only join this chat room but not others !!

Have fun ^^

Credit goes to EternalHarvest and DrKN


Last edited by Myself379 on 17 Feb 2012, 06:22, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Making use of eval() in macro
PostPosted: 17 Feb 2012, 06:18 
Offline
Developers
Developers

Joined: 05 Dec 2008, 05:42
Posts: 1811
Myself379 wrote:
After trial-and-error and searching in forums , you'll found out that it requires $:: in front of every variables.

It's only due to macro plugin's misfeatures, though (and relies on openkore's Globals being exported into package main).
Myself379 wrote:
To cut-short, in order to retrieve owner of chat rooms in the immediate area (you need a counter; therefore you need to loop this function until you found your desire titles)
Code:
$foo = @eval(Actor::get($::chatRooms{$::chatRoomsID[$i]}->{ownerID})->{name} eq 'NPC/Player names')


note:
1)the $i is a counter, it will keep looping until it found your 'NPC/Player names' and also the number you required in do chat join $i later.

The loop (or grep, or whatever) can be done entirely inside eval too, returning binID for "chat join" from eval.


Top
 Profile  
 
 Post subject: Re: Making use of eval() in macro
PostPosted: 18 Feb 2012, 02:39 
Offline
Human
Human

Joined: 05 Oct 2010, 09:46
Posts: 24
ah! thanks for enlightening me

NEW*

In server that supports @warp commands

you must set these option first:
Code:
teleportAuto_useChatCommand @warp [Your Map Here]
lockMap [Your Map Here]


1st version :

Code:
automacro console_calculate_lockmap {
   location not [Your Map Here]
   timeout 5
   exclusive 1
   call {
   do c @go 5
   pause 1
   do tele
   }
}


Now the macro here does what it intend to do, warp to lockMap when it's not in there. But the problem is that you can't do autoSell, autoBuy, autoStorage. Since if you want to autoSell/autoBuy, you need to be in town but the macro keeps warping you to the lockMap. So you need to manually do it.

Solution

Code:
automacro console_calculate_lockmap {
   eval (($::field->baseName ne $::config{lockMap}) eq 1 && $ai_seq[0] eq "route")
   timeout 5
   exclusive 1
   call {
   do c @go 5
   pause 1
   do tele
   }
}


what it does is that, it will only warp ONLY when :
1) Is not in the lockMap
2) Is not doing autoSell, autoBuy, autoStorage
3) Is 'route' to lockMap

So this code is safe to use for Arrows/Bullets/Autosell/Autobuy user as it will not interfere with your 'warp to lockmap'. Thus eliminating the requirements to manual re-stock the arrows/bullets


Top
 Profile  
 
 Post subject: Re: making use of _M and _F supported servers
PostPosted: 17 May 2012, 11:35 
Offline
Human
Human

Joined: 05 Oct 2010, 09:46
Posts: 24
For those who are playing with _M/_F supported server (i.e.: you can register using _M/_F method for the server)

You might have an problem when you wanted to create a bot of army. Sure enough you can have 10 bots leveling from lvl 1 to whatever it takes. But keeping changing your username_M is a whole bunch of pain if you have 10 bots army.

This problem is amplify further if you get banned too much and you need to create again and again.

Solution

What this does it that it automatically changes your username in your config.txt automatically to eliminate the _M(or _F) behind it. This way, what you need to configure your config.txt for creating a new bot army is just the username

e.g: blablafoo_M and the macro will find the _M, delete it and reload the config.txt to become blablafoo

In your macros.txt

add:

Code:
sub usernameChange{
   my $newName = $::config{username};
   $newName =~ s/_M$//;
   configModify("username", $newName);
}


to call this subroutine, simply call it using example as below :

Code:
automacro whateverfoo {
        do eval usernameChange
}


Enjoy ! :)


Top
 Profile  
 
 Post subject: Relog after kill monster
PostPosted: 24 Sep 2012, 01:16 
Offline
Human
Human

Joined: 05 Oct 2010, 09:46
Posts: 24
Here's a scenario, you need to kill an MVP. Takes Garm(http://ratemyserver.net/index.php?page=mob_db&mob_id=1252) for example :

As you know base on RMS RO, Garm have a revive time of approx 120min~130min , so it's like every 2 hours. The problem is that you don't want to spend too much time on the xmas_fild01 for whatever reason. i.e.: You might get suspected, and for worst case ; you'll get banned

What you need is a counter that you've already kill the Monster/MVP. Assuming that you're botting in the map JUST for that specific monster. In this case : Garm

This method is known as Relog-Kill-Relog to avoid unnecessary time spend on that map which will raise speciousness. A simple technique which involve manipulation of console command : -

Code:
exp monster


The idea is that you, when you kill a monster ; it will automatically add counter to your "exp monster" therefore, you've kill it and is time to relog

in macros.txt, simply add 3 macros : -

Code:
automacro relog_after_kill {
   hook attack_end
   timeout 0
   exclusive 1
   call {
   [
   $currentCount = @eval($::monsters_Killed[0]{count})
   
   if ( $currentCount != $lastCount ) goto relog
   if ( $currentCount == $lastCount ) goto keepgoing
   
   :keepgoing
   $lastCount = @eval ($::monsters_Killed[0]{count})
   stop

   :relog
   do relog 7200
   log @eval (localtime)
   $lastCount = @eval ($::monsters_Killed[0]{count})
   stop
   ]
   }
}

macro sync {
   [
   log Old Current count is : $currentCount
   log Old Last count is : $lastCount
   
   $currentCount = @eval($::monsters_Killed[0]{count})
   $lastCount = @eval ($::monsters_Killed[0]{count})
   
   log New Current count is : $currentCount
   log New Last count is : $lastCount
   ]
}

macro expcount {
[
   log @eval ($::monsters_Killed[0]{'nameID'} = 1252)
   log @eval ($::monsters_Killed[0]{'name'} = "Garm")
   log @eval ($::monsters_Killed[0]{'count'} = 0)
]
}


The nameID = 1252, name = Garm is base on RMS RO (actually is base on openkore tables). To use this, once you've run the Openkore, simply type in the console to run the following :

1) macro expcount
2) macro sync

What macro expcount do was adding the Monster nameID,name,count into your "exp monster", then the macro sync is simply sync the $currentCount and $lastCount.

A hook is use "attack_end" which every time an AI attack ends, it will run the automacro; which IF the Garm is killed, therefore $currentCount and $lastCount will be different and relogs for 7200 seconds. IF is not Garm, then $currentCount and $lastCount will be the same and the hunt continues.

Any ideas which have better algorithm then this is appreciated :)


Top
 Profile  
 
 Post subject: Re: Making use of eval() in macro
PostPosted: 20 Nov 2012, 04:38 
Offline
Human
Human

Joined: 13 Nov 2012, 07:57
Posts: 34
Any help me how to use this ?

Code:
automacro IDChat {
   console /Lista da Sala de Chat/
   exclusive 1
   call {
   $foo = @eval(Actor::get($::chatRooms{$::chatRoomsID[$i]}->{ownerID})->{name} eq 'NPCb')
   if ($foo != NPCb) goto log1
      if ($foo = NPCb) goto log2
:log1
   log1 >>> $::ownerID $i
:log2
   log1 >>> $::ownerID $i
}
   }

why dont work? i tested with name real from npc


Top
 Profile  
 
 Post subject: Re: Making use of eval() in macro
PostPosted: 20 Nov 2012, 04:59 
Offline
Developers
Developers

Joined: 05 Dec 2008, 05:42
Posts: 1811
Just add "log $foo" and check what eq returns.


Top
 Profile  
 
 Post subject: Re: Making use of eval() in macro
PostPosted: 20 Nov 2012, 07:24 
Offline
Human
Human

Joined: 13 Nov 2012, 07:57
Posts: 34
dont work
i got failed in macro debug in wxstart

i type cl in console for trigger
Code:
automacro IDChat {
   console /Lista da Sala de Chat/
   exclusive 1
   call {
$foo = @eval(Actor::get($::chatRooms{$::chatRoomsID[$i]}->{ownerID})->{name} eq 'PUT REAL NPC NAME')
log $foo
}   
}


sometimes already read the first post but I can not understand.


Top
 Profile  
 
 Post subject: Re: Making use of eval() in macro
PostPosted: 20 Nov 2012, 18:01 
Offline
Developers
Developers

Joined: 06 Jul 2012, 13:44
Posts: 310
what is your server?


Top
 Profile  
 
 Post subject: Re: Making use of eval() in macro
PostPosted: 20 Nov 2012, 21:47 
Offline
Human
Human

Joined: 13 Nov 2012, 07:57
Posts: 34
bRO


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group