porting Plugins

From OpenKore Wiki
(Redirected from Porting Plugins)
Jump to navigation Jump to search

OpenKore 1.9 is, in some ways, internally incompatible with OpenKore 1.6. So some plugins for 1.6 don't work in 1.9. This guide teaches you how to port your plugins.

Network message sending

The interface for sending messages (packets) to the server has changed. So functions like sendAttack(), sendSit(), etc. must be called in a different way.


sendFoo(\$remote_socket, ...);

- and/or -




($messageSender is a global variable)

And change:

Network::Send::decrypt(\$newmsg, $msg);


Network::Receive->decrypt(\$newmsg, $msg);

One exception is the sendMessage function. Change:

sendMessage($net, $from, $msg, $type);


sendMessage(\$remote_socket, $from, $msg, $type);


sendMessage($messageSender, $from, $msg, $type);

Win32 functions

The 'WinUtils' module has been renamed to 'Utils::Win32'.

Original Change to
use WinUtils; use Utils::Win32;
WinUtils::foo(...); Utils::Win32::foo(...);

Field class

Don't use %field anymore, it has been replaced with $field (also a global variable), which is an object of type Field.

Original Change to
something(\%field); something($field);
message "Field name is $field{name}\n"; message "Field name is " . $field->name() . "\n";

Skill class

The 'Skills' class has been replace by the Skill class. The interface is slightly different. Here's a summary of things that have to be changed:

Original Change to
use Skills; use Skill;
Skills->new(id => ...)
new Skills(id => ...)
Skill->new(idn => ...)
new Skill(idn => ...)
$skill->handle() $skill->getHandle()
$skill->id() $skill->getIDN()
$skill->name() $skill->getName()

Character inventory

The code for maintaining the character inventory has changed since version 2.0.1. Storage inventory and cart inventory are not affected by this change. $char->{inventory} doesn't exist anymore. Instead, one should use $char->inventory, which returns an InventoryList object. Use the InventoryList methods to access the inventory.

Change things like this:

my $invIndex = findIndexString($char->{inventory}, "name", "Jellopy");
my $item = $char->{inventory}[$invIndex];


my $item = $char->inventory->getByName("Jellopy");

InventoryList is a subclass of ObjectList, so you can use all the usual ObjectList methods on InventoryList. For example, getting an item by inventory index used to be done like this:

my $item = $char->{inventory}[$invIndex];

Now it is:

my $item = $char->inventory->get($invIndex);

And iteration has changed from:

for (my $i = 0; $i < @{$char->{inventory}}; $i++) {
   my $item = $char->{inventory}[$i];
   next if (!$item || !%{$item});
   # ...do something with $item...


foreach my $item (@{$char->inventory->getItems()}) {
   # ObjectList guarantees that there are no undefined items when iterating through it

   # ...do something with $item...