how to update this old plugin?

All resolved question will be found here. It is recommended that you browse / search through this section first and see if your question has been answered before

Moderators: Moderators, Documentation Writers

Message
Author
genuineopenkore
Plain Yogurt
Plain Yogurt
Posts: 52
Joined: 16 Jan 2011, 03:06
Noob?: Yes

how to update this old plugin?

#1 Post by genuineopenkore »

this is a very old plugin and please help me to let this plugin work in Openkore 2.1 r7622
thanks in advance...

original plugin

Code: Select all

package locationSkill;

#
# Based on the suggestions by pmak
# This plugin is licensed under the GNU GPL
# Copyright 2005 by kaliwanagan
# --------------------------------------------------

use strict;
use Plugins;
use Globals;
use Log qw(message warning error);
use AI;
use Skills;

Plugins::register('locationSkill', 'cast skill at a certain location', \&Unload);
my $hook1 = Plugins::addHook('AI_post', \&call);
my $hook2 = Plugins::addHook('packet_skilluse', \&packet_skilluse);

sub Unload {
	Plugins::delHook('packet_skilluse', $hook2);
	Plugins::delHook('AI_post', $hook1);
}

my %skillUse;
my %delay;

sub packet_skilluse {
	my (undef, $args) = @_;
	my $skillID = $args->{'skillID'};
	my $sourceID = $args->{'sourceID'};
	my $x = $args->{'x'};
	my $y = $args->{'y'};
	
	if ($sourceID eq $accountID) {
		$skillUse{$skillID} = 1;
	}
}

sub call {
	if (AI::action eq 'locationSkill') {
		my $args = AI::args;
		if ($args->{'stage'} eq 'end') {
			AI::dequeue;
		} elsif ($args->{'stage'} eq 'skillUse') {
			main::ai_skillUse(
				$args->{'handle'}, 
				$args->{'lvl'}, 
				$args->{'maxCastTime'}, 
				$args->{'minCastTime'}, 
				$args->{'x'}, $args->{'y'}
			);
			$args->{'stage'} = 'end';
		}
	}
	locationSkill() if (AI::isIdle); 
}

sub locationSkill {
	my $prefix = "locationSkill_";
	my $i = 0;
	while (exists $config{$prefix.$i}) {
		if ((main::checkSelfCondition($prefix.$i)) &&
			main::timeOut($delay{$prefix.$i."_blockDelayBeforeUse"}) && 
			main::timeOut($delay{$prefix.$i."_blockDelayAfterUse"})
		) {
			my $skillObj = Skills->new(name => $config{$prefix.$i});
			unless ($skillObj->handle) {
				my $msg = "Unknown skill name ".$config{$prefix.$i}." in $prefix.$i\n";
				error $msg;
				configModify($prefix.$i."_disabled", 1);
				next;
			}

			my %skill;
			($skill{'x'}, $skill{'y'}, my $map) = split / *, */, $config{$prefix.$i."_coords"};
			my $pos = main::calcPosition($char);
			$skill{'x'} = $skill{'x'} || $pos->{'x'};
			$skill{'y'} = $skill{'y'} || $pos->{'y'};

			$delay{$prefix.$i."_blockDelayBeforeUse"}{'timeout'} = $config{$prefix.$i."_blockDelayBeforeUse"};
			if (!$delay{$prefix.$i."_blockDelayBeforeUse"}{'set'}) {
				$delay{$prefix.$i."_blockDelayBeforeUse"}{'time'} = time;
				$delay{$prefix.$i."_blockDelayBeforeUse"}{'set'} = 1;
			}
	
			$delay{$prefix.$skillObj->handle."_skillDelay"}{'timeout'} = $config{$prefix.$i."_skillDelay"};
			if ($skillUse{$skillObj->id}) { # set the delays only when the skill gets successfully cast
				$delay{$prefix.$skillObj->handle."_skillDelay"}{'time'} = time;
				$skillUse{$skillObj->id} = 0;
			}

			my %range;
			($range{'x'}, $range{'y'}, $range{'range'}) = split / *, */, $config{$prefix.$i."_whenAtCoords"};

			my $inRange;
			$inRange = (($pos->{'x'} <= ($range{'x'} + $range{'range'})) &&
						($pos->{'x'} >= ($range{'x'} - $range{'range'})) &&
						($pos->{'y'} <= ($range{'y'} + $range{'range'})) &&
						($pos->{'y'} >= ($range{'y'} - $range{'range'})));
			undef %range;

			if ((checkCoordsCondition($prefix.$i."_coords",\%skill)) &&
				main::timeOut($delay{$prefix.$skillObj->handle."_skillDelay"}) &&
				(($inRange || (!$config{$prefix.$i."_whenAtCoords"}))) && 
				(($map eq $field{'name'}) || !$map)
			) {
				$skill{'handle'} = $skillObj->handle;
				$skill{'lvl'} = ($config{$prefix.$i."_lvl"}) || 10;
				$skill{'maxCastTime'} = $config{$prefix.$i."_maxCastTime"};
				$skill{'minCastTime'} = $config{$prefix.$i."_minCastTime"};
				$skill{'stage'} = 'skillUse';
				AI::queue('locationSkill', \%skill);
				$delay{$prefix.$i."_blockDelayAfterUse"}{'timeout'} = $config{$prefix.$i."_blockDelayAfterUse"};
				$delay{$prefix.$i."_blockDelayAfterUse"}{'time'} = time;
				$delay{$prefix.$i."_blockDelayBeforeUse"}{'set'} = 0;
				last;
			}
		}
		$i++;
	}
}

sub checkCoordsCondition {
	my $prefix = shift;
	my $coord = shift;

	if ($config{$prefix."_whenGround"}) {
		return 0 unless main::whenGroundStatus($coord, $config{$prefix."_whenGround"});
	}
	if ($config{$prefix."_whenNotGround"}) {
		return 0 if main::whenGroundStatus($coord, $config{$prefix."_whenNotGround"});
	}

	return 1;
}

return 1; 
errors

Code: Select all

*** OpenKore what-will-become-2.1 ( r7622 ) - Custom Ragnarok Online client ***
***   http://www.openkore.com/   ***

Loading all plugins...
Loading plugin plugins/locationSkill.pl...
This plugin cannot be loaded because of a problem in the plugin. Please notify
the plugin's author about this problem, or remove the plugin so OpenKore can
start.

The error message is:
Plugin contains syntax errors:
Can't locate Skills.pm in @INC (@INC contains: src src/deps C:openkore/src/deps C:/openkore/src
C:/openkore .) at C:/openkore/plugins/locationSkill.pl line 14.
BEGIN failed--compilation aborted at C:/Documents and
Settings/BEP/Desktop/HW/plugins/locationSkill.pl line 14.

Press ENTER to exit this program.
i've changed

Code: Select all

use Skills;
to

Code: Select all

use Skill;
another error

Code: Select all

*** OpenKore what-will-become-2.1 ( r7622 ) - Custom Ragnarok Online client ***
***   http://www.openkore.com/   ***

Loading all plugins...
Loading plugin plugins/locationSkill.pl...
Variable "%field" is not imported at C:openkore/plugins/locationSkill.pl line 106.
This plugin cannot be loaded because of a problem in the plugin. Please notify
the plugin's author about this problem, or remove the plugin so OpenKore can
start.

The error message is:
Plugin contains syntax errors:
Global symbol "%field" requires explicit package name at C:/openkore/plugins/locationSkill.pl line 106.

Press ENTER to exit this program.

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

Re: how to update this old plugin?

#2 Post by EternalHarvest »

There's only $field object now, use $field->name or $field->baseName instead of $field{name}.

genuineopenkore
Plain Yogurt
Plain Yogurt
Posts: 52
Joined: 16 Jan 2011, 03:06
Noob?: Yes

Re: how to update this old plugin?

#3 Post by genuineopenkore »

thanks for your reply EternalHarvest

$field{name issue solved, but there's another error

Code: Select all

OpenKore version what-will-become-2.1
Network state = 5
Network handler = Network::DirectConnection
SVN revision: 7660
Loaded plugins:
  plugins/locationSkill.pl (locationSkill)
  plugins/macro.pl (macro)

Error message:
Can't locate object method "new" via package "Skills" (perhaps you forgot to load "Skills"?) at C:/Documents and Settings/plugins/locationSkill.pl line 67.

Stack trace:
Can't locate object method "new" via package "Skills" (perhaps you forgot to load "Skills"?) at C:/Documents and Settings/plugins/locationSkill.pl line 67.
 at C:/Documents and Settings/plugins/locationSkill.pl line 67
	locationSkill::locationSkill() called at C:/Documents and Settings/plugins/locationSkill.pl line 56
	locationSkill::call('AI_post', undef, undef) called at src/Plugins.pm line 431
	Plugins::callHook('AI_post') called at src/AI/CoreLogic.pm line 208
	AI::CoreLogic::iterate() called at src/functions.pl line 738
	main::mainLoop_initialized() called at src/functions.pl line 69
	main::mainLoop() called at src/Interface.pm line 75
	Interface::mainLoop('Interface::Console::Win32=HASH(0x13288cc)') called at openkore.pl line 97
	main::__start() called at start.pl line 136

Died at this line:
        ) {
*          my $skillObj = Skills->new(name => $config{$prefix.$i});
           unless ($skillObj->handle) {


Mushroom
Perl Monk
Perl Monk
Posts: 427
Joined: 04 Apr 2008, 14:04
Noob?: No
Location: Brazil

Re: how to update this old plugin?

#4 Post by Mushroom »

Remove the s from Skills.

Code: Select all

my $skillObj = Skill->new(name => $config{$prefix.$i});
Quit.

genuineopenkore
Plain Yogurt
Plain Yogurt
Posts: 52
Joined: 16 Jan 2011, 03:06
Noob?: Yes

Re: how to update this old plugin?

#5 Post by genuineopenkore »

Mushroom wrote:Remove the s from Skills.

Code: Select all

my $skillObj = Skill->new(name => $config{$prefix.$i});
solved!

thanks for the help mushroom

another error

Code: Select all

Died at this line:
           my $skillObj = Skill->new(name => $config{$prefix.$i});
*          unless ($skillObj->handle) {
              my $msg = "Unknown skill name ".$config{$prefix.$i}." in $prefix.$i\n";

Locked