[eventmacro log] The array @monsters has size 3 and its members are poring, wolf and maya

pop

pop syntax is as follows:

&pop(@array)

pop must have 1 parameter: the array you want to pop.

Here's an example of an array, and it after a pop:

@jobs = (teacher, doctor, seller)
log The array \@jobs has size @jobs and its members are $jobs[0], $jobs[1] and $jobs[2]
&pop(@jobs)
log The array \@jobs has size @jobs and its members are $jobs[0], $jobs[1]
&pop(@jobs)
log The array \@jobs has size @jobs and its members are $jobs[0]

This prints this:

[eventmacro log] The array @jobs has size 3 and its members are teacher, doctor and seller
[eventmacro log] The array @jobs has size 2 and its members are teacher, doctor
[eventmacro log] The array @jobs has size 1 and its members are teacher

shift

shift syntax is as follows:

&shift(@array)

shift must have 1 parameter: the array you want to shift.
Here's an example of an array, and it after a shift:

@jobs = (teacher, doctor, seller)
log The array \@jobs has size @jobs and its members are $jobs[0], $jobs[1] and $jobs[2]
&shift(@jobs)
log The array \@jobs has size @jobs and its members are $jobs[0], $jobs[1]
&shift(@jobs)
log The array \@jobs has size @jobs and its members are $jobs[0]

This prints this:

[eventmacro log] The array @jobs has size 3 and its members are teacher, doctor and seller
[eventmacro log] The array @jobs has size 2 and its members are doctor, seller
[eventmacro log] The array @jobs has size 1 and its members are seller

After a shift the whole array is moved to the left, so after the first shift the member 'seller' which was in index 2 moved to index 1, and after the second shift it moved to index 0.

unshift

unshift syntax is as follows:

&unshift(@array, newmember)

unshift must have 2 parameters: the array you want to unshift, and the new member to be placed at the beginning of the array.

Note that since unshift puts the new member in the start of the array the first member is now 'apple' which was added last.

And this macro:

macro print_names {
@array = (apple, banana)
log The array \@array has size @array and its first member is $array[0], and the second is $array[1]
&unshift(@array, pineapple)
log The array \@array has size @array and its first member is $array[0], and the second is $array[1]
&unshift(@array, melon)
log The array \@array has size @array and its first member is $array[0], and the second is $array[1]
}

Prints this:

[eventmacro log] The array @array has size 2 and its first member is apple, and the second is banana
[eventmacro log] The array @array has size 3 and its first member is pineapple, and the second is apple
[eventmacro log] The array @array has size 4 and its first member is melon, and the second is pineapple

Hashes

To set the value of hash variable, it must be declared with its pairs inside parentheses, separated by comma, and the key and the value must be separated by =>:

%variable = (key1 => value1, key2 => value2, key3 => value3)

To get a value of a certain key, use $ at the start instead of %, and put the key after the variable name, enclosed by { and }:

$variable{key1}

Keys can contain letters and numbers.

Get the number of keys in the hash:

%variable

macro Hello {
%ages = (john => 25, george => 32)
log John is $ages{john} years old, and George is $ages{george} years old
}

This would print in the console:

[eventmacro log] log John is 25 years old, and George is 32 years old

The definition of separate hash members is the same as a normal scalar.

[eventmacro log] The hash \%fruitsprice has size 2.
[eventmacro log] The apple price is 1000 and the banana price is 700
[eventmacro log] The hash \%fruitsprice has size 1.
[eventmacro log] The price of banana is 700
[eventmacro log] The price of apple has vanished:

Special Variables

There are special read-only variables which begin with a dot. They are pre-defined with the eventMacro plugin.

Special Keywords

These keywords (having common form of &<keyword>(<arguments>) each) interpolated to corresponding values just about anywhere inside macro blocks (except goto, end, label definitions, macro name in call, set). Macro variables can be used in arguments, with the exception for &nick().

Line 3 starts the chaining mode. This line has no delay. Lines 4, 5 and 6 are run as soon as the previous command has finished with no delay and they cannot be interrupted. Line 7 stops the chaining mode and line 8 will be run $macro_delay seconds after that.

Sub-lines

Instead of using one command/var assignments per line, you can separate them using a semi-colon ";".

Syntax of command conditions

If

Right now, macro if conditions are very close to the perl if statements. It accepts unlimited number of statements in just one if condition line, regexp matching is allowed (unfortunately, no backreference using parenthesis) and the use of && for and meaning and || for or meaning.

Postfix control

The command before the if statement will only be executed if the condition is true.
The way to create the condition is the same as previously explained.

In this example below, the two commands are equivalent:

call buy if ($.zeny > 1000)
if ($.zeny > 1000) call buy

Else

In case if is used with open braces ( { ), it's possible to use the command else along closed braces ( } ) in the end of the command block if, to start a new command block that will be executed if if is false.

In this case, the first block of commands will be executed if the condition is true. If it is false, the second block of commands (preceded by the elsif) will be executed if its condition is true. Should also be false, the command blocks else to be executed.

Note: As in the else, inside braces of elsif you're allowed to use tons of commands.Note: It is not compulsory to wear the else or elsif.

Switch/case

It's similar to if followed by enumerous elsif. It's useful to leave the code cleaner when the paramater being analyzed is the same, this way you don't need to repeat it.

switch (arg1) {
case (<Operators> arg2) (goto <label> | call <macro> <parameters> | stop | {)
(If you use "{", the commands should be used here and in a separated line that should be closed with the block "}")
case (<Operators> arg2) (goto <label> | call <macro> <parameters> | stop | {)
(If you use "{", the commands should be used here and in a separated line that should be closed with the block "}")
...
else (goto <label> | call <macro> <parameters> | stop | {)
(If you use "{", the commands should be used here and in a separated line that should be closed with the block "}")
}

Note: The use of else is optional.
Note: In case that no case ends being true, else will be activate if it exists.

Examples

This macro will go a random walk

macro walk {
$num = &rand(1, 4)
if ($num == 1) {
do c I will follow the path 1
do north
}
if ($num == 2) {
do c I will follow the path 2
do south
}
if ($num == 3) {
do c I will follow the path 3
do east
}
if ($num == 4) {
do c I will follow the path 4
do west
}
}

Simplified version of the above macro, using postfix control.

macro walk {
$num = &rand(1, 4)
do c I will follow the path $num
do north if ($num == 1)
do south if ($num == 2)
do east if ($num == 3)
do west if ($num == 4)
}

The following macro will tell if you've over 1.000z or 1.000z or less.

run-once defines if the automacro can activate only once, or multiple times.

If not used in the automacro the default value will be used, which is: 0.

When it's value is 1 the automacro will only activate once, when it's 0 it can activate multiple times.

To make an automacro with run-once value of 1 which already was already activated be able to run again you can use the command 'release' Macro Syntax.

automacro myautomacro {
<automacro conditions and parameters (and only them)>
run-once 1
call myMacro
}
automacro myaotherauto {
<automacro conditions and parameters (and only them)>
run-once 0
call myMacro
}
macro myMacro {
<macro instructions (and only them, as this is regular macro)>
log This macro will be called by myautomacro only once
log but this macro can be called by myaotherauto many times
}

CheckOnAI

CheckOnAI is an optional parameter.

CheckOnAI defines in which AI states the automacro can activate.

The default value for this parameter can be set in the config key eventMacro_CheckOnAI Configuration files.

If not used in the automacro the default value will be used, which is the config key eventMacro_CheckOnAI.

If eventMacro_CheckOnAI is not set in the config the default value will be used, which is: auto

It's values can be a combination of auto, manual and off, separated by comma.

automacro MyAuto {
<automacro conditions and parameters (and only them)>
CheckOnAI manual
call myMacro
}
macro myMacro {
<macro instructions (and only them, as this is regular macro)>
log This macro will only be called by MyAuto when AI is manual
}
automacro MyAuto2 {
<automacro conditions and parameters (and only them)>
CheckOnAI manual, off
call myMacro
}
macro myMacro2 {
<macro instructions (and only them, as this is regular macro)>
log This macro will only be called by MyAuto2 when AI is manual or off
}

disabled

disabled is an optional parameter.

disabled defines if the automacro is active of not.

If not used in the automacro the default value will be used, which is: 0.

When it's value is 1 the automacro won't activate ever, when it's 0 it can activate normally.

automacro MyAuto {
<automacro conditions and parameters (and only them)>
disabled 1
call myMacro
}
macro myMacro {
<macro instructions (and only them, as this is regular macro)>
log This macro will never be called by MyAuto
}
automacro MyAuto2 {
<automacro conditions and parameters (and only them)>
disabled 0
call myMacro
}
macro myMacro2 {
<macro instructions (and only them, as this is regular macro)>
log This macro will be called by MyAuto2 normally
}

overrideAI

overrideAI is an optional parameter.

overrideAI defines if eventMacro will put itself in the AI queue.

If not used in the automacro the default value will be used, which is: 0.

When it's value is 0 the macro will be put into AI queue as 'eventMacro' and the next macro command will only be run if current AI is 'eventMacro'.

When it's value is 1 the macro will not be put into AI queue and the next macro command will always be run.

It's important to note that when it's value is 1 since it won't be put into AI queue normal AI functions will continue as normal, like mob hunting or autostorage.

automacro MyAuto {
<automacro conditions and parameters (and only them)>
overrideAI 0
call myMacro
}
macro myMacro {
<macro instructions (and only them, as this is regular macro)>
do move prontera
log This will only be printed when the 'move prontera' has been completed, since 'move' takes the first place in AI queue.
}
automacro MyAuto2 {
<automacro conditions and parameters (and only them)>
overrideAI 1
call myMacro
}
macro myMacro2 {
<macro instructions (and only them, as this is regular macro)>
do move prontera
log This will be printed after a macro_delay has passed before the last command, because it won't check AI queue.
}

exclusive

exclusive is an optional parameter.

exclusive defines if the macro can be interrupted or not.

If not used in the automacro the default value will be used, which is: 0.

When it's value is 0 the macro can be interrupted by other automacros.

When it's value is 1 the macro can not be interrupted by other automacros.

automacro MyAuto {
<automacro conditions and parameters (and only them)>
exclusive 0
call myMacro
}
macro myMacro {
<macro instructions (and only them, as this is regular macro)>
log This would probably cause a bug because the automacro would activate every AI cycle since the macro is interruptible.
}
automacro MyAuto2 {
<automacro conditions and parameters (and only them)>
exclusive 1
call myMacro
}
macro myMacro2 {
<macro instructions (and only them, as this is regular macro)>
log Since exclusive is 1 the macro is now uninterruptible and will work properly.
}

priority

priority is an optional parameter.

priority defines the priority for activation the automacro has between all automacros, the lower the priority, the sooner ir will be checked.

If not used in the automacro the default value will be used, which is: 0.

macro_delay defines the time in seconds to wait between macro commands.

If not used in the automacro the default value will be used, which is: 1.

Must have a numeric value.

automacro MyAuto {
<automacro conditions and parameters (and only them)>
macro_delay 2
call {
log This will be printed at the macro execution
log This will be printed 2 seconds after
}
}
automacro MyAuto2 {
<automacro conditions and parameters (and only them)>
macro_delay 5
call {
log This will be printed at the macro execution
log This will be printed 5 seconds after
}
}

orphan

orphan is an optional parameter.

orphan defines how will eventMacro deal with macros when 'eventMacro' is cleaned out of AI queue.

The default value for this parameter can be set in the config key eventMacro_orphans Configuration files.

If not used in the automacro the default value will be used, which is the config key eventMacro_orphans.

If eventMacro_orphans is not set in the config the default value will be used, which is: terminate

The valid values and their descriptions are the following:

Value

Description

terminate

terminates the macro (equivalent to eventMacro stop)

terminate_last_call

terminates only the last call of the queue, this means that if macro 'mac1' called 'mac2' which called 'mac3', who got orphaned, only 'mac3' gets terminated, and queue returns to 'mac2'.

reregister

re-registers to AI queue, overriding other entries. This means to force the continuation of the macro.

reregister_safe

re-registers to AI queue when AI gets idle. This means the macro will continue when all other tasks are done.

repeat

repeat is an optional parameter.

repeat defines how many times the macro defined by call will be called.

If not used in the automacro the default value will be used, which is: 1.

Must have a numeric value.

automacro <automacro name> {
<automacro conditions and parameters (and only them)>
repeat 3
call myMacro
}
macro myMacro {
<macro instructions (and only them, as this is regular macro)>
log This message will be printed 3 times, because the macro will be called 3 times
}

timeout

timeout is an optional parameter.

timeout defines the time in seconds before this automacro can activate again after an activation.

If not used in the automacro the default value will be used, which is: 0.

Must have a numeric value.

automacro <automacro name> {
<automacro conditions and parameters (and only them)>
timeout 60
call myMacro
}
macro myMacro {
<macro instructions (and only them, as this is regular macro)>
log This macro will only be called every 60 seconds
}

Conditions

Conditions are separated into 2 categories: state and event.

Most conditions set special variables when the automacro activates.

Most conditions accept variables in their code.

Each automacro can only have one event condition.

Most state conditions can be used more than once in each automacro.

Each condition will have it's detailed explanation below.

eventMacro has a modular condition system, each file inside eventMacro/Condition is a condition.

State

State conditions have a defined status of true or false.

An automacro will only activate when all of it's state conditions are true.

$.CartCurrentWeightLast => Saves the last cart weight that made CartCurrentWeight become true
$.CartCurrentWeightLastPercent => Saves the last cart weight percentage that made CartCurrentWeight become true

$.CartCurrentSizeLast => Saves the last cart item quantity that made CartCurrentSize become true
$.CartCurrentSizeLastPercent => Saves the last cart item quantity percentage that made CartCurrentSize become true

$.CharCurrentWeightLast => Saves the last player weight that made CharCurrentWeight become true
$.CharCurrentWeightLastPercent => Saves the last player weight percentage that made CharCurrentWeight become true

$.SkillLevelLastName => Saves the name of the last skill that made SkillLevel become true
$.SkillLevelLastID => Saves the ID of the last skill that made SkillLevel become true
$.SkillLevelLastHandle => Saves the Handle of the last skill that made SkillLevel become true
$.SkillLevelLastLevel => Saves the level of the last skill that made SkillLevel become true

$.ChatRoomNearLastID => Saves the ID of the last chat room that made ChatRoomNear become true
$.ChatRoomNearLastOwnerID => Saves the ID of the owner of the last chat room that made ChatRoomNear become true
$.ChatRoomNearLastOwnerName => Saves the name of the owner of the last chat room that made ChatRoomNear become true
$.ChatRoomNearLastTitle => Saves the title of the last chat room that made ChatRoomNear become true

InMap

Description: Checks if the current map match one of the given maps.

Syntax:

InMap <comma separated list of maps>

Map can be a variable.

Example:

InMap prontra, geffen, gef_fild10

Set variables:

$.InMapLast => Saves the last map that made InMap become true

InLockMap

Description: Is true if you are in lockmap and it is set to 1 or you are not in lockmap and it is set to 0.

Syntax:

InLockMap <1|0>

Example:

InLockMap 1

InSaveMap

Description: Is true if you are in savemap and it is set to 1 or you are not in savemap and it is set to 0.

Syntax:

InSaveMap <1|0>

Example:

InSaveMap 0

IsInCoordinate

Description: Checks if the current coordinates match one of the given ones.

Syntax:

IsInCoordinate <comma separated list of pairs of x and y coordinates>

It also accepts ranges in place of coordinates. (like 100..200 for x and 50..100 for y)

$.IsInMapAndCoordinateLast => Saves the last coordinate that made IsInMapAndCoordinate become true
$.IsInMapAndCoordinateLastMemberIndex => Saves the list index in condition that made IsInMapAndCoordinate become true

InPvP

Description: Checks if the current pvp type of the map matches the given type.

Syntax:

InPvP <comma separated list of pvp types>

Valid pvp types: pvp, gvg and battleground

Example:

InPvP battleground, pvp

Set variables:

$.InPvPLast => Saves the last pvp type that made InPvP become true

InCity

Description: Checks if the player is in a city or not.

Syntax:

InCity <0 | 1>

When value is 0: Only true if map is not a city

When value is 1: Only true if map is a city

Example:

InCity 1

Set variables:

$.InCityLast => Saves the name of the last map that made InCity become true

$.NpcNearLast => Saves the name of the last npc that made NpcNear become true
$.NpcNearLastPos => Saves the position of the last npc that made NpcNear become true (can be used for 'talknpc' command)
$.NpcNearLastBinId => Saves the openkore ID of the last npc that made NpcNear become true (can be used for 'talk' command)
$.NpcNearLastDist => Saves the distance of the last npc that made NpcNear become true

NpcNearDist

Description: Checks if there is a npc in a given distance which name matches the given regex.

$.NpcNearDistLast => Saves the name of the last npc that made NpcNearDist become true
$.NpcNearDistLastPos => Saves the position of the last npc that made NpcNearDist become true (can be used for 'talknpc' command)
$.NpcNearDistLastBinId => Saves the openkore ID of the last npc that made NpcNearDist become true (can be used for 'talk' command)
$.NpcNearDistLastDist => Saves the distance of the last npc that made NpcNearDist become true

NpcNotNear

Description: Checks if there's no npc near which name matches the given regex.

$.PlayerNearLast => Saves the name of the last player that made PlayerNear become true
$.PlayerNearLastPos => Saves the position of the last player that made PlayerNear become true
$.PlayerNearLastBinId => Saves the openkore ID of the last player that made PlayerNear become true
$.PlayerNearLastDist => Saves the distance of the last player that made PlayerNear become true

PlayerNearDist

Description: Checks if there is a player in a given distance which name matches the given regex.

$.PlayerNearDistLast => Saves the name of the last player that made PlayerNearDist become true
$.PlayerNearDistLastPos => Saves the position of the last player that made PlayerNearDist become true
$.PlayerNearDistLastBinId => Saves the openkore ID of the last player that made PlayerNearDist become true
$.PlayerNearDistLastDist => Saves the distance of the last player that made PlayerNearDist become true

PlayerNotNear

Description: Checks if there's no player near which name matches the given regex.

$.MobNearLast => Saves the name of the last mob that made MobNear become true
$.MobNearLastPos => Saves the position of the last mob that made MobNear become true
$.MobNearLastBinId => Saves the openkore ID of the last mob that made MobNear become true
$.MobNearLastDist => Saves the distance of the last mob that made MobNear become true

MobNearDist

Description: Checks if there is a mob in a given distance which name matches the given regex.

$.MobNearDistLast => Saves the name of the last mob that made MobNearDist become true
$.MobNearDistLastPos => Saves the position of the last mob that made MobNearDist become true
$.MobNearDistLastBinId => Saves the openkore ID of the last mob that made MobNearDist become true
$.MobNearDistLastDist => Saves the distance of the last mob that made MobNearDist become true

MobNotNear

Description: Checks if there's no mob near which name matches the given regex.

$.IsEquippedIDLastID => Saves the id of the last equip which made IsEquippedID become true
$.IsEquippedIDLastName => Saves the name of the last equip which made IsEquippedID become true
$.IsEquippedIDLastSlot => Saves the slot of the last equip which made IsEquippedID become true
$.IsEquippedIDLastListIndex => Saves the index in the condition list of the last equip which made IsEquippedID become true

IsNotEquippedID

Description: Checks if the player doesn't have an item equipped which ID matches the given one.

$.ConfigKeyLastKey => Saves the key of the last config key that made ConfigKey become true
$.ConfigKeyLastValue => Saves the value of the last config key that made ConfigKey become true
$.ConfigKeyLastMemberIndex => Saves the list index in condition list that made ConfigKey become true

ConfigKeyNot

Description: Checks if the at least one of the config key pairs doesn't match their desired value.

$.ConfigKeyNotLastKey => Saves the key of the last config key that made ConfigKeyNot become true
$.ConfigKeyNotLastWantedValue => Saves the desired value specified in the condifion of the last config key that made ConfigKeyNot become true
$.ConfigKeyNotLastKeyValue => Saves the value of the last config key that made ConfigKeyNot become true
$.ConfigKeyNotLastMemberIndex => Saves the list index in condition list that made ConfigKeyNot become true

This macro will make sure all config keys specified in ConfigKeyNot have the desired value.

ConfigKeyNotExist

Description: Checks if the at least one of the config keys doesn't exist in config.txt.

Syntax:

ConfigKeyNotExist <comma separated list config keys>

Config key can be a variable

Example:

ConfigKeyNotExist gameGuard, saveMap

Set variables:

$.ConfigKeyNotExistLastKey => Saves the last config key that made ConfigKeyNotExist become true
$.ConfigKeyNotExistLastMemberIndex => Saves the list index in condition list that made ConfigKeyNotExist become true

This macro will make sure you added the config keys for gameGuard and cmdOnLogin plugin.

InProgressBar

Description: Checks if the player is waiting for a progress bar to end.

Syntax:

InProgressBar <0 | 1>

When value is 0: Only true if not waiting for a progress bar

When value is 1: Only true if waiting for a progress bar

Example:

InProgressBar 1

Sets no variables

StatusActiveHandle

Description: Checks if the player has one of the given status, uses status HANDLE.

Syntax:

StatusActiveHandle <comma separated list of status handles>

Status handle can be a variable

Example:

StatusActiveHandle EFST_INC_AGI, EFST_IMPOSITIO

Set variables:

$.StatusActiveHandleLastName => Saves the name of the last stauts that made StatusActiveHandle become true
$.StatusActiveHandleLastHandle => Saves the handle of the last stauts that made StatusActiveHandle become true
$.StatusActiveHandleLastListIndex => Saves the list index in condition of the last stauts that made StatusActiveHandle become true

StatusInactiveHandle

Description: Checks if the player doesn't have one of the given status, uses status HANDLE.

Syntax:

StatusInactiveHandle <comma separated list of status handles>

Status handle can be a variable

Example:

StatusInactiveHandle EFST_BLESSING, EFST_CONCENTRATION

Set variables:

$.StatusInactiveHandleLastName => Saves the name of the last stauts that made StatusInactiveHandle become true
$.StatusInactiveHandleLastHandle => Saves the handle of the last stauts that made StatusInactiveHandle become true
$.StatusInactiveHandleLastListIndex => Saves the list index in condition of the last stauts that made StatusInactiveHandle become true

QuestActive

Description: Checks if the player has one of the given quests active, uses quest ID (use command 'quest list' to see ID).

Syntax:

QuestActive <comma separated list of quests ID>

Quest ID can be a variable

Example:

QuestActive 7121, 7122

Set variables:

$.QuestActiveLastID => Saves the ID of the last quest that made QuestActive become true
$.QuestActiveLastListIndex => Saves the list index in condition of the last quest that made QuestActive become true

QuestInactive

Description: Checks if the player has of the given quests inactive, uses quest ID (use command 'quest list' to see ID).

Syntax:

QuestInactive <comma separated list of quests ID>

Quest ID can be a variable

Example:

QuestInactive 7121, 7122

Set variables:

$.QuestInactiveLastID => Saves the ID of the last quest that made QuestInactive become true
$.QuestInactiveLastListIndex => Saves the list index in condition of the last quest that made QuestInactive become true

QuestOnTime

Description: Checks if the player has one of the given quests active, and this quest has a timer that hasn't ended yet, uses quest ID (use command 'quest list' to see ID).

Syntax:

QuestOnTime <comma separated list of quests ID>

Quest ID can be a variable

Example:

QuestOnTime 7121, 7122

Set variables:

$.QuestOnTimeLastID => Saves the ID of the last quest that made QuestOnTime become true
$.QuestOnTimeLastListIndex => Saves the list index in condition of the last quest that made QuestOnTime become true

QuestTimeOverdue

Description: Checks if the player has one of the given quests active, and this quest has a timer that has already ended, uses quest ID (use command 'quest list' to see ID).

Syntax:

QuestTimeOverdue <comma separated list of quests ID>

Quest ID can be a variable

Example:

QuestTimeOverdue 7121, 7122

Set variables:

$.QuestTimeOverdueLastID => Saves the ID of the last quest that made QuestTimeOverdue become true
$.QuestTimeOverdueLastListIndex => Saves the list index in condition of the last quest that made QuestTimeOverdue become true

QuestHuntCompleted

Description: Checks if the player has one of the given quests active, and this quest has a hunt mission which wasn't completed yet, uses quest ID and Mob ID (use command 'quest list' to see ID).

$.QuestHuntCompletedLastQuestID => Saves the Quest ID of the last quest that made QuestHuntCompleted become true
$.QuestHuntCompletedLastMobID => Saves the Mob ID of the last quest that made QuestHuntCompleted become true
$.QuestHuntCompletedLastListIndex => Saves the list index in condition of the last quest that made QuestHuntCompleted become true

QuestHuntOngoing

Description: Checks if the player has one of the given quests active, and this quest has a hunt mission which has not been completed yet, uses quest ID and Mob ID (use command 'quest list' to see ID).

$.QuestHuntOngoingLastQuestID => Saves the Quest ID of the last quest that made QuestHuntOngoing become true
$.QuestHuntOngoingLastMobID => Saves the Mob ID of the last quest that made QuestHuntOngoing become true
$.QuestHuntOngoingLastListIndex => Saves the list index in condition of the last quest that made QuestHuntOngoing become true

NoPlayerNear

Description: Checks if there are any players near, it's true when there's none.

Syntax:

NoPlayerNear 1

Example:

NoPlayerNear 1

Sets no variables.

NoPortalNear

Description: Checks if there are any portals near, it's true when there's none.

Syntax:

NoPortalNear 1

Example:

NoPortalNear 1

Sets no variables.

NoMobNear

Description: Checks if there are any mobs near, it's true when there's none.

Syntax:

NoMobNear 1

Example:

NoMobNear 1

Sets no variables.

NoNpcNear

Description: Checks if there are any npcs near, it's true when there's none.

Syntax:

NoNpcNear 1

Example:

NoNpcNear 1

Sets no variables.

PlayerNearCount

Description: Checks if the number of players near match the given math condition.

$.PubMsgDistLastName => Saves the name of the player which message activated PubMsgDist
$.PubMsgDistLastMsg => Saves the message which activated PubMsgDist
$.PubMsgDistLastPos => Saves the position of the player which message activated PubMsgDist
$.PubMsgDistLastDist => Saves the distance to the player which message activated PubMsgDist
$.PubMsgDistLastID => Saves the openkore ID of the player which message activated PubMsgDist

PubMsgName

Description: Is checked on public messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex.

The first regex is for the message, the second one is for the player name

Example:

PubMsgName /(buff|bless)/ /Player to buff/
PubMsgName /stop/ /GM/

Set variables:

$.PubMsgNameLastName => Saves the name of the player which message activated PubMsgName
$.PubMsgNameLastMsg => Saves the message which activated PubMsgName

PubMsgNameDist

Description: Is checked on public messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex and the distance matches the condition.

$.PubMsgNameDistLastName => Saves the name of the player which message activated PubMsgNameDist
$.PubMsgNameDistLastMsg => Saves the message which activated PubMsgNameDist
$.PubMsgNameDistLastPos => Saves the position of the player which message activated PubMsgNameDist
$.PubMsgNameDistLastDist => Saves the distance to the player which message activated PubMsgNameDist
$.PubMsgNameDistLastID => Saves the openkore ID of the player which message activated PubMsgNameDist

PrivMsg

Description: Is checked on private messages, is true when the message matches the given regex.

$.PrivMsgDistLastName => Saves the name of the player which message activated PrivMsgDist
$.PrivMsgDistLastMsg => Saves the message which activated PrivMsgDist
$.PrivMsgDistLastPos => Saves the position of the player which message activated PrivMsgDist
$.PrivMsgDistLastDist => Saves the distance to the player which message activated PrivMsgDist
$.PrivMsgDistLastID => Saves the openkore ID of the player which message activated PrivMsgDist

PrivMsgName

Description: Is checked on private messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex.

The first regex is for the message, the second one is for the player name

Example:

PrivMsgName /(buff|bless)/ /Player to buff/
PrivMsgName /stop/ /GM/

Set variables:

$.PrivMsgNameLastName => Saves the name of the player which message activated PrivMsgName
$.PrivMsgNameLastMsg => Saves the message which activated PrivMsgName

PrivMsgNameDist

Description: Is checked on private messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex and the distance matches the condition.

$.PrivMsgNameDistLastName => Saves the name of the player which message activated PrivMsgNameDist
$.PrivMsgNameDistLastMsg => Saves the message which activated PrivMsgNameDist
$.PrivMsgNameDistLastPos => Saves the position of the player which message activated PrivMsgNameDist
$.PrivMsgNameDistLastDist => Saves the distance to the player which message activated PrivMsgNameDist
$.PrivMsgNameDistLastID => Saves the openkore ID of the player which message activated PrivMsgNameDist

PartyMsg

Description: Is checked on party messages, is true when the message matches the given regex.

$.PartyMsgDistLastName => Saves the name of the player which message activated PartyMsgDist
$.PartyMsgDistLastMsg => Saves the message which activated PartyMsgDist
$.PartyMsgDistLastPos => Saves the position of the player which message activated PartyMsgDist
$.PartyMsgDistLastDist => Saves the distance to the player which message activated PartyMsgDist
$.PartyMsgDistLastID => Saves the openkore ID of the player which message activated PartyMsgDist

PartyMsgName

Description: Is checked on party messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex.

The first regex is for the message, the second one is for the player name

Example:

PartyMsgName /(buff|bless)/ /Player to buff/
PartyMsgName /stop/ /GM/

Set variables:

$.PartyMsgNameLastName => Saves the name of the player which message activated PartyMsgName
$.PartyMsgNameLastMsg => Saves the message which activated PartyMsgName

PartyMsgNameDist

Description: Is checked on party messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex and the distance matches the condition.

$.PartyMsgNameDistLastName => Saves the name of the player which message activated PartyMsgNameDist
$.PartyMsgNameDistLastMsg => Saves the message which activated PartyMsgNameDist
$.PartyMsgNameDistLastPos => Saves the position of the player which message activated PartyMsgNameDist
$.PartyMsgNameDistLastDist => Saves the distance to the player which message activated PartyMsgNameDist
$.PartyMsgNameDistLastID => Saves the openkore ID of the player which message activated PartyMsgNameDist

GuildMsg

Description: Is checked on guild messages, is true when the message matches the given regex.

$.GuildMsgDistLastName => Saves the name of the player which message activated GuildMsgDist
$.GuildMsgDistLastMsg => Saves the message which activated GuildMsgDist
$.GuildMsgDistLastPos => Saves the position of the player which message activated GuildMsgDist
$.GuildMsgDistLastDist => Saves the distance to the player which message activated GuildMsgDist
$.GuildMsgDistLastID => Saves the openkore ID of the player which message activated GuildMsgDist

GuildMsgName

Description: Is checked on guild messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex.

The first regex is for the message, the second one is for the player name

Example:

GuildMsgName /(buff|bless)/ /Player to buff/
GuildMsgName /stop/ /GM/

Set variables:

$.GuildMsgNameLastName => Saves the name of the player which message activated GuildMsgName
$.GuildMsgNameLastMsg => Saves the message which activated GuildMsgName

GuildMsgNameDist

Description: Is checked on guild messages, is true when the message matches the given regex and the name of the player which sent it also matches it's given regex and the distance matches the condition.

$.GuildMsgNameDistLastName => Saves the name of the player which message activated GuildMsgNameDist
$.GuildMsgNameDistLastMsg => Saves the message which activated GuildMsgNameDist
$.GuildMsgNameDistLastPos => Saves the position of the player which message activated GuildMsgNameDist
$.GuildMsgNameDistLastDist => Saves the distance to the player which message activated GuildMsgNameDist
$.GuildMsgNameDistLastID => Saves the openkore ID of the player which message activated GuildMsgNameDist

NpcMsg

Description: Is checked on npc conversation messages, is true when the message matches the given regex.

$.NpcMsgDistLastName => Saves the name of the npc which message activated NpcMsgDist
$.NpcMsgDistLastMsg => Saves the message which activated NpcMsgDist
$.NpcMsgDistLastPos => Saves the position of the npc which message activated NpcMsgDist
$.NpcMsgDistLastDist => Saves the distance to the npc which message activated NpcMsgDist
$.NpcMsgDistLastID => Saves the openkore ID of the npc which message activated NpcMsgDist

NpcMsgName

Description: Is checked on npc conversation messages, is true when the message matches the given regex and the name of the npc which sent it also matches it's given regex.

The first regex is for the message, the second one is for the npc name

Example:

NpcMsgName /You don't have zeny/ /kafra/

Set variables:

$.NpcMsgNameLastName => Saves the name of the npc which message activated NpcMsgName
$.NpcMsgNameLastMsg => Saves the message which activated NpcMsgName

NpcMsgNameDist

Description: Is checked on npc conversation messages, is true when the message matches the given regex and the name of the npc which sent it also matches it's given regex and the distance matches the condition.

$.NpcMsgNameDistLastName => Saves the name of the npc which message activated NpcMsgNameDist
$.NpcMsgNameDistLastMsg => Saves the message which activated NpcMsgNameDist
$.NpcMsgNameDistLastPos => Saves the position of the npc which message activated NpcMsgNameDist
$.NpcMsgNameDistLastDist => Saves the distance to the npc which message activated NpcMsgNameDist
$.NpcMsgNameDistLastID => Saves the openkore ID of the npc which message activated NpcMsgNameDist

LocalMsg

Description: Is checked on local broadcast messages, is true when the message matches the given regex.

$.ZennyChangedLastChange => Saves the amount of zenny changed that made ZennyChanged activate
$.ZennyChangedLastZennyAfter => Saves the amount of zenny left after the change that made ZennyChanged activate

Comments

The macro files allow comments, i.e. lines that are ignored by the eventMacro plugin.

Lines starting with a # will be treated as a comment.

Everything after a space and followed by a # will also be ignored.

macro happy {
#this is a comment line
log I'm Happy # this is also a comment
}

Will print:

[eventmacro log] I'm Happy

Examples with Explanations

I assume you already know how to use Console Commands and understand how they work. If not, before going further, read through all Console Commands and try out ones like a, ai, move, cart get, storage add, talk, deal, take, direction commands, sl, sm, relog, pm and others.

Keep another page with this manual open for cross reference.

Okay, so there are 2 types of blocks

automacros – these trigger automatically

macros – these do not trigger automatically but need to be called manually or by an automacro

Automacros

Automacros automatically trigger when certain conditions are met, just like how blocks in config.txt trigger depending on the conditions set in them.

The point of automacros is that you use them to check for conditions. When the condition is fulfilled, you can either respond to it in the automacro or call a macro to do it. The format for automacro is...

For example, suppose you're playing manually but your slave priest is on Kore, and you want it to warn you if it's running out of sp, you can use an automacro like this....

automacro sp {
CurrentSP < 200
timeout 10
call {
do c sp low
}
}

Taking it line by line,

automacro sp { - you need to put automacro to tell kore that its an automacro. Then you put the name of the macro, in this case its “sp”. Then you need to put an opening bracket “{“ which tells Kore that the automacro's code begins there.

CurrentSP < 200 – After the “{“, you put the conditions on successive lines. Here, there is only one condition and I think its clear that the condition is that sp should be below 200.

timeout 10 – This isn't a condition or a command, it works the same way it works in normal Kore blocks, so this automacro cannot trigger within 10 seconds of it already having been triggered. I ALWAYS put timeouts, so even if my conditions are faulty, the automacro doesn't spam and mess up whatever my bot is doing. Otherwise if your automacro is messed up then you could die or something, so its better to put an appropriate timeout.

call { – The word “call” tells Kore that now you're going to be putting commands, not conditions. The opening bracket “{“ tells Kore that the commands will start now. These commands are the ones that will get carried out when the conditions are met, here when sp goes below 200.

do c sp low – “do” tells Kore that this is a command, something to be done. After “do”, just leave a space and type in the console command you want to execute exactly the way you do in the Kore console.

So basically whenever, the bot's sp goes below 200, it says in public chat “sp low”. This also has the advantage of making your bot not look like a bot =p.

Here's another macro which illustrates how you can use macros to handle weird situations which Kore is not equipped to deal with. When fighting against metalings, they often strip you and then your oh-so-smart bot punches! To get around this, put the weapon you use in default auto equip and use this macro.

automacro strip { - Tell Kore this is an automacro, and it's name is "strip". The '{' tells Kore the code of the automacro starts here.

StatusActiveHandle EFST_NOEQUIPWEAPON - The only condition in this macro. This checks your list of statuses for the status handle "EFST_NOEQUIPWEAPON". Thus, when you are stripped by a Metaling, you get the "EFST_NOEQUIPWEAPON" status and this condition will be fulfilled.

timeout 10 - Ensures automacro is not spammed, and 10 seconds is enough time to execute the automacro. So after 10 seconds, if for some reason you are still stripped, this automacro will trigger again. However, if you re-login and are stripped within 10 seconds, then macro will not trigger again untill the 10 seconds are up.

call { - The word "call" and "{" tells Kore that the commands to be executed start after the '{'

do tele - "do" tells Kore that what comes after is a console command to be carried out. Here, the command is "tele" so you teleport away from the Metaling, so that in case you lag or something, you aren't killed while executing the next instruction which is.....

do relog 10 - Tells Kore to relogin in 10 seconds, because when you login again, your "strip weapon" status is cleared.

} - The closing bracket '}' tells Kore the commands have ended.

} - The closing bracket '}' tells Kore the macro code has ended.

Summarising, on being stripped, you teleport away from the monster and then relogin, with a timeout of 10 seconds to ensure that the automacro is not spammed. Since the weapon you're using is filled in the default weapon option, after re-logging in, Kore will automatically re-equip that weapon.

Let's try a more complicated macro. If you have a priest, you would want it to warp back to its lockmap or the nearest warp-able map near its lockmap. This macro does it. From the savemap, the bot takes the same route to the lockmap each time. So in the first map outside the town, just set it to move to a designated tile, and cast warp on a nearby tile, and then move to that tile. You will need delays to allow the spell to be cast and commands to be completed.

automacro warp { - As explained, the automacro's name is warp, and “{“ indicates that the automacro begins.

InMap get_fild07 - The first condition, the automacro will only trigger if the map is gef_fild07.

InInventory “Blue Gemstone” > 0 - Second condition, ensures there is atleast one blue gemstone in the inventory so that warp portal can be cast. Obviously you need a getAuto in config.txt for the gemstones.

timeout 20 - Ensures that the bot does not spam the automacro. The timeout should be large enough to allow the completion of the automacro, so that the automacro does not trigger again while it is in execution.

call { - Tells Kore that the commands start here.

do ai manual - Frequently, I use this command in the more complicated and longer macros, so that Kore doesn't get diverted into doing something else while your macro is running, for example, attacking a monster or gathering up an item. In this case I'm using it so that the bot doesn't continue walking.

pause 1 - Inserts a delay of 1 second before the next command is carried out, VERY IMPORTANT. If you don't use delays then Kore can and will miss steps in the macro and the result is a mess.

do move 319 187 - The “move” console command is used to move your bot to a set location.

do sl 27 316 188 - The “sl” console command is used to make your priest cast warp portal on a convenient spot near your location, in this case (316,188).

pause 2 - Very Important. A delay of 2 seconds is put, allowing enough time to cast warp portal. If you priest has low dex, this delay should be increased.

do warp 1 - Console command “warp” is used to select memo location 1.

pause 1 - 1 second delay to allow the portal to form.

do move 316 188 - Move to the portal and Voila! You have been warped to the map.

do ai on - You set ai to manual at the beginning of this macro, so now you need to turn it back on.

} - Closing bracket indicates end of commands.

} - Closing bracket indicates end of automacro code.

Note the use of appropriate delays and timeouts in this automacro.

The EventMacro plugin also has many useful built-in variables which give you your position for example. It's all listed in the eventMacro manual. I just want to show how to extract your position from these variables.

$.pos gives you your position. Now to get your x and y coordinates the code is,

$px = &arg ("$.pos", 1)
$py = &arg ("$.pos", 2)

Here, the x coordinate is the 1st value in $.pos so we have a '1'. Similarly, the y coordinate is the second value in $.pos so we have a '2'.

If you have a “MobNear” condition in your automacro, $.MobNearLastPos gives the position of that monster. To extract the x and y coordinates the code is,

$mx = &arg ("$.MobNearLastPos", 1)
$my = &arg ("$.MobNearLastPos", 2)

"run-once"

Frequently, the run-once condition is used instead of a timeout. It allows the automacro to run only once so that the automacro isn't spammed. To get the automacro to run again, a release command needs to be executed. However, due to a rogue situation that the macro hangs and the release macro isn't executed, your automacro is effectively stuck. To get around this, use a timeout instead of using run-once.

How to write a macro

Now that you have some idea of what a macro is, try writing one

Figure out under exactly what conditions you want your automacro to trigger

Logically think out the steps your bot needs to perform in the automacro. Go step by step over this carefully.

Ensure you have inserted appropriate pauses between the steps.

Ensure you have a timeout or a run-once in your macro to prevent spamming of it.

Now put the code in eventMacros.txt and start the bot or reload eventMacros.txt. If all is fine you won't get any error messages. But if there is a problem in the syntax, say you missed out a “}”, then you will get an error message and the macro won't work. Figure out what the error is, correct it, and reload eventMacros.txt again to check if you corrected it properly or not.

Collected Macros

I would like to share some useful macros, hopefully not angering anyone here.

Identify with Magnifier

You got unidentified Items in your inventory and want to identify them using magnifiers? Use "eventMacro id" on console until all items are identified. You don't have to type anything else, the macro will identify the first item found, after that the second and so on.

This macro, once called, will automatically walk to the prontera forge and refine Rough Ori / Elu as long as there are more than 5 in your inventory. I did not find something like that yet, please post everything (better) I may have missed.