Making use of eval() in macro

Moderator: Moderators

Message
Author
Myself379
Human
Human
Posts: 24
Joined: 05 Oct 2010, 09:46
Noob?: No

Making use of eval() in macro

#1 Post by Myself379 »

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: Select all

$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: Select all

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.

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Making use of eval() in macro

#2 Post by EternalHarvest »

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: Select all

$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.

Myself379
Human
Human
Posts: 24
Joined: 05 Oct 2010, 09:46
Noob?: No

Re: Making use of eval() in macro

#3 Post by Myself379 »

ah! thanks for enlightening me

NEW*

In server that supports @warp commands

you must set these option first:

Code: Select all

teleportAuto_useChatCommand @warp [Your Map Here]
lockMap [Your Map Here]
1st version :

Code: Select all

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: Select all

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

Myself379
Human
Human
Posts: 24
Joined: 05 Oct 2010, 09:46
Noob?: No

Re: making use of _M and _F supported servers

#4 Post by Myself379 »

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: Select all

sub usernameChange{
	my $newName = $::config{username};
	$newName =~ s/_M$//;
	configModify("username", $newName);
}
to call this subroutine, simply call it using example as below :

Code: Select all

automacro whateverfoo {
        do eval usernameChange
}
Enjoy ! :)

Myself379
Human
Human
Posts: 24
Joined: 05 Oct 2010, 09:46
Noob?: No

Relog after kill monster

#5 Post by Myself379 »

Here's a scenario, you need to kill an MVP. Takes Garm(http://ratemyserver.net/index.php?page= ... ob_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: Select all

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: Select all

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 :)

TormenT
Human
Human
Posts: 33
Joined: 13 Nov 2012, 07:57
Noob?: No

Re: Making use of eval() in macro

#6 Post by TormenT »

Any help me how to use this ?

Code: Select all

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

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Making use of eval() in macro

#7 Post by EternalHarvest »

Just add "log $foo" and check what eq returns.

TormenT
Human
Human
Posts: 33
Joined: 13 Nov 2012, 07:57
Noob?: No

Re: Making use of eval() in macro

#8 Post by TormenT »

dont work
i got failed in macro debug in wxstart

i type cl in console for trigger

Code: Select all

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.

ever_boy_
Developers
Developers
Posts: 308
Joined: 06 Jul 2012, 13:44
Noob?: No

Re: Making use of eval() in macro

#9 Post by ever_boy_ »

what is your server?

TormenT
Human
Human
Posts: 33
Joined: 13 Nov 2012, 07:57
Noob?: No

Re: Making use of eval() in macro

#10 Post by TormenT »

bRO

Post Reply