Alberta Daily Cargo Quest Plugin

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

Message
Author
wwaallaa
Noob
Noob
Posts: 9
Joined: 09 Jun 2010, 23:42
Noob?: Yes

Alberta Daily Cargo Quest Plugin

#1 Post by wwaallaa »

i tried making a plugin version of alberta daily cargo quest macro
i am not using this anymore because i am gettting a hard time gaining a job level when a character is in high base level, alberta daily quest gives a lot of base exp unfortunately it doesn't give job exp

here it is:

Code: Select all

package cargoquest;

use Plugins;
#use strict;
use Globals;
use Misc;
use Utils;
use Log qw(message);
use I18N qw(bytesToString);

Plugins::register('cargo_quest', 'cargo quest', \&Unload, \&Reload);

my $hooks = Plugins::addHooks(
		['in_game', \&reset_variables, undef],
		['packet/npc_talk', \&respNPC, undef],
		['AI_pre', \&AIpre, undef]
);

my $quest;
my $time = time;
my $qtimeout = 1;
my $questNPC;
my $questAction;
my (@x, @y);
my $random;
my $crate_number;

#if ever disconnected, reset variables
sub reset_variables
{
	undef $quest;
	$time = time;
	$qtimeout = 1;
	undef $quest_queue;
	undef @x;
	undef @y;
	undef $random;
	undef $crate_number;
}

sub AIpre
{
	if(timeOut($time, $qtimeout) && !$quest)
	{
		if(($field->{name} eq "alberta"))
		{
			AI::queue('albertaquest', {questNPC => 'portnpc'});
			$quest = 1;
			&quest_action;
			last;
		}
		else
		{
			main::ai_route("alberta", undef, undef,
				attackOnRoute => 0,
				noSitAuto => 1);
			message "Moving to Alberta.\n", "info";
			$qtimeout = 20;
			last;
		}
	}
	else
	{
		my $npcs = $npcsList->getItems();
		foreach my $npc (@{$npcs})
		{
			my $posx = $npc->{pos}{x};
			my $posy = $npc->{pos}{y};
			$questAction = "talk";
			if(($npc->name eq "[Quest] Port Manager#") && ($questNPC eq "portnpc"))
			{
				&sub_quest_action("Port NPC", $posx, $posy);
				last;
			}
			elsif(($npc->name eq "Deadly Cargo [1]#") && ($questNPC eq "crate1"))
			{
				$crate_number = 1;
				&sub_quest_action("First Crate", $posx, $posy);
				last;
			}
			elsif(($npc->name eq "Deadly Cargo [2]#") && ($questNPC eq "crate2"))
			{
				$crate_number = 2;
				&sub_quest_action("Second Crate", $posx, $posy);
				last;
			}
			elsif(($npc->name eq "Deadly Cargo [3]#") && ($questNPC eq "crate3"))
			{
				$crate_number = 3;
				&sub_quest_action("Third Crate", $posx, $posy);
				last;
			}
			elsif(($npc->name eq "Deadly Cargo [4]#") && ($questNPC eq "crate4"))
			{
				$crate_number = 4;
				&sub_quest_action("Fourth Crate", $posx, $posy);
				last;
			}
			elsif(($npc->name eq "Deadly Cargo [5]#") && ($questNPC eq "crate5"))
			{
				$crate_number = 5;
				&sub_quest_action("Fifth Crate", $posx, $posy);
				last;
			}
			elsif(($npc->name eq "Deadly Cargo [6]#") && ($questNPC eq "crate6"))
			{
				
				$crate_number = 6;
				&sub_quest_action("Sixth Crate", $posx, $posy);
				last;
			}
			else
			{
				next;
			}
		}
	}
	$time = time;
}

sub respNPC
{
	my ($self, $args) = @_;

	my $ID = unpack("V", substr($args->{RAW_MSG}, 4, 4));
	my $msg = unpack("Z*", substr($args->{RAW_MSG}, 8));

	$msg = I18N::bytesToString($msg);
	
	$_ = $msg;
	if(/recognize the first crate/ || /get me the first crate/)
	{
		AI::clear;
		AI::queue('albertaquest', {questNPC => 'crate1'});
		&quest_action;
	}
	if(/retrieve the second crate/ || /get me the second crate/)
	{
		AI::clear;
		AI::queue('albertaquest', {questNPC => 'crate2'});
		&quest_action;
	}
	if(/third crate should be with/)
	{
		AI::clear;
		AI::queue('albertaquest', {questNPC => 'crate3'});
		&quest_action;
	}
	if(/get me the fourth crate/)
	{
		AI::clear;
		AI::queue('albertaquest', {questNPC => 'crate4'});
		&quest_action;
	}
	if(/find the fifth crate/)
	{
		AI::clear;
		AI::queue('albertaquest', {questNPC => 'crate5'});
		&quest_action;
	}
	if(/sixth create has been found/ || /wounded scouts have reported/)
	{
		AI::clear;
		AI::queue('albertaquest', {questNPC => 'crate6'});
		&quest_action;
	}
	if(/before it changes its mind/ || /have already moved/)
	{
		AI::clear;
		AI::queue('albertaquest', {questNPC => 'portnpc'});
		&quest_action;
	}
	if(/already did work for today/ || /come back 20 hours/)
	{
		message "[Q] Finished quest! Quitting...", "info";
		quit();
	}
	if(/That HURT!!/)
	{
		AI::queue('albertaquest', {questNPC => 'crate1'}) if $crate_number == 1;
		AI::queue('albertaquest', {questNPC => 'crate2'}) if $crate_number == 2;
		AI::queue('albertaquest', {questNPC => 'crate3'}) if $crate_number == 3;
		AI::queue('albertaquest', {questNPC => 'crate4'}) if $crate_number == 4;
		AI::queue('albertaquest', {questNPC => 'crate5'}) if $crate_number == 5;
		AI::queue('albertaquest', {questNPC => 'crate6'}) if $crate_number == 6;
		&quest_action;
	}
}

sub quest_action
{
	return if !AI::action('albertaquest');
	$questNPC = AI::args->{questNPC};	
	$questAction = "move";
	if($questNPC eq "crate1") #1st crate
	{
		@x = ("187","188","189","190","191");
		@y = ("164","165","166","167","168");
		$random = rand(4);
		&sub_quest_action("First Crate", $x[$random], $y[$random]);
	}
	elsif($questNPC eq "crate2") #2nd crate
	{
		@x = ("224","225","226","227","228");
		@y = ("102","103","104","105","106");
		$random = rand(4);
		&sub_quest_action("Second Crate", $x[$random], $y[$random]);
	}
	elsif($questNPC eq "crate3") #3rd crate
	{
		@x = ("238","239","240","241","242");
		@y = ("88","89","90","91","92");
		$random = rand(4);
		&sub_quest_action("Third Crate", $x[$random], $y[$random]);
	}
	elsif($questNPC eq "crate4") #4th crate
	{
		@x = ("238","239","240","241","242");
		@y = ("64","65","66","67","68");
		$random = rand(4);
		&sub_quest_action("Fourth Crate", $x[$random], $y[$random]);
	}
	elsif($questNPC eq "crate5") #5th crate
	{
		@x = ("235","236","237","238","239");
		@y = ("40","41","42","43","44");
		$random = rand(4);
		&sub_quest_action("Fifth Crate", $x[$random], $y[$random]);
	}
	elsif($questNPC eq "crate6") #6th crate
	{
		@x = ("114","115","116","117","118");
		@y = ("215","216","217","218","219");
		$random = rand(4);
		&sub_quest_action("Sixth Crate", $x[$random], $y[$random]);
	}
	elsif($questNPC eq "portnpc") #port npc
	{
		@x = ("94","95","96","97","98");
		@y = ("60","61","62","63","64");
		$random = rand(4);
		&sub_quest_action("Port NPC", $x[$random], $y[$random]);
	}
	else
	{
		message "[Q] Dead End!!\n", "info"; #this will not appear
	}
}

sub sub_quest_action
{
	if($questAction eq "move")
	{
		main::ai_route($field->{name}, "$_[1]", "$_[2]",
					attackOnRoute => 0,
					noSitAuto => 1);
		message "[Q] Moving to $_[0]. ($_[1], $_[2])\n", "info";
	}
	if($questAction eq "talk")
	{
		main::ai_talkNPC($_[1], $_[2], "c r0 n");
		message "[Q] Talking to $_[0] at ($_[1], $_[2])\n", "info";		
		$questNPC = "";
	}
}

sub Reload
{
	&Unload;
}
sub Unload
{
	Plugins::delHooks($hooks);
}
# Important! Otherwise plugin will appear to fail to load.
return 1;
i can code but i am not good in coding

blackwing01
Noob
Noob
Posts: 1
Joined: 21 Oct 2011, 19:39
Noob?: Yes

Re: Alberta Daily Cargo Quest Plugin

#2 Post by blackwing01 »

do we need to put something on our config file for this?

Post Reply