OpenKore / OpenKore/openkore

Random stuck in macro and eventMacro when doing do north/east/west/south

Open
#4,140 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Perl
Stars
1.5k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Openkore version git

OpenKore what-will-become-2.1 ( version ctime:2026_02_05 )

XKore Mode

Empty

RO Server Name

localhost (rAthena)

Link to RO server

localhost (rAthena)

Result

When I use rand in macro or eventMacro, it always gets stuck in the second iteration and so on.
I mean, it won't randomize the number anymore.
This problem only happens when doing do north, do east, etc.

Relevant Log Output

Expected Result

It should be randomize each call

Image
How to Reproduce
macros.txt
automacro test {
	location prontera
	call walk
	timeout 5
}

macro walk {
	pause 1
	$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)
}
Image
eventMacros.txt
automacro test {
	InMap prontera
	call walk
	timeout 5
}

macro walk {
	pause 1
	$fix = &rand(1, 4)
	$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)
}
Image
The workaround

By adding another variable with random

automacro test {
	InMap aegis
	call walk
	timeout 5
}

macro walk {
	pause 1
	$fix = &rand(1, 4)
	$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)
}
Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the supplied macros.txt and eventMacros.txt examples. Trace how @rand and &rand are handled when followed by do north, south, east, or west, then verify repeated macro iterations produce a newly randomized direction without requiring the extra random variable.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.