Macro based on Quest Time

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

TBC2014
Noob
Noob
Posts: 4
Joined: 09 May 2014, 15:29
Noob?: No

Macro based on Quest Time

#1 Post by TBC2014 »

I've spent several hours looking for the answer myself and decided to ask ~_~

I'm trying to create a macro which will be triggered if the server time is equal or beyond the quest time.
I'm trying to figure out what syntax is needed for @eval

Code: Select all

$temp1 = @eval($::questList->{####}->{time?}->{1098}->{count}
I've searched using "eval <perl expression>" to hopefully get a list of all per expressions

In the past I was able to modify another macro that is triggered if the number of kills in the quest is fulfilled *see below*

Code: Select all

## Anubis Hunt ##

automacro Anubis_Hunt{
	hook packet/quest_update_mission_hunt
		#hook target_died
	exclusive 1
	call {
		$temp1 = @eval($::questList->{9056}->{missions}->{1098}->{count})
		if ($temp1 == 50) call Crowd_Control_NPC
		:end
	}
}

macro Crowd_Control_NPC {
	$x = @random ("116","117","118","119","120","121","123")
	$y = @random ("122","123","124","125","126","127","128","129","130","131","132","133","134","135")
	do move $x $y
	pause 1
	do talknpc 116 120 c n
	pause 2
	do talknpc 116 120 c n
	pause 2
	talk resp 0
	pause 2
	talk resp 0
	pause 2
	talk resp 2
}
I've found this *below* from: http://forums.openkore.com/viewtopic.php?f=32&t=170056

Code: Select all

automacro testsub {
   eval (100 * $::char->{exp} / $::char->{exp_max} ) >= 60
   run-once 1
   call {
         do quit
   }
}

Ultimately, I stumbled upon this *see below* and I feel that the syntax is patterned here.

Code: Select all

sub cmdQuest {
	if (!$net || $net->getState() != Network::IN_GAME) {
		error TF("You must be logged in the game to use this command '%s'\n", shift);
		return;
	}
	my ($cmd, $args_string) = @_;
	my @args = parseArgs($args_string, 3);
	if ($args[0] eq 'set') {
		if ($args[1] =~ /^\d+/) {
			# note: we need the questID here now, might be better if we could make it so you only have to insert some questIndex
			$messageSender->sendQuestState($args[1], ($args[2] eq 'on'));
		} else {
			message T("Usage: quest set <questID> <on|off>\n"), "info";
		}
	} elsif ($args[0] eq 'list') {
		my $k = 0;
		my $msg;
		$msg .= center(" " . T("Quest List") . " ", 79, '-') . "\n";
		foreach my $questID (keys %{$questList}) {
			my $quest = $questList->{$questID};
			$msg .= swrite(sprintf("\@%s \@%s \@%s \@%s \@%s", ('>'x2), ('<'x4), ('<'x30), ('<'x10), ('<'x24)),
				[$k, $questID, $quests_lut{$questID} ? $quests_lut{$questID}{title} : '', $quest->{active} ? T("active") : T("inactive"), $quest->{time} ? scalar localtime $quest->{time} : '']);
			foreach my $mobID (keys %{$quest->{missions}}) {
				my $mission = $quest->{missions}->{$mobID};
				$msg .= swrite(sprintf("\@%s \@%s \@%s", ('>'x2), ('<'x30), ('<'x30)),
					[" -", $mission->{mobName}, sprintf(defined $mission->{goal} ? '%d/%d' : '%d', @{$mission}{qw(count goal)})]);
			}
			$k++;
		}
		$msg .= sprintf("%s\n", ('-'x79));
		message($msg, "list");
	} elsif ($args[0] eq 'info') {
		if ($args[1] =~ /^\d+/) {
			# note: we need the questID here now, might be better if we could make it so you only have to insert some questIndex
			if ($quests_lut{$args[1]}) {
				my $msg = center (' ' . ($quests_lut{$args[1]}{title} || T('Quest Info')) . ' ', 79, '-') . "\n";
				$msg .= "$quests_lut{$args[1]}{summary}\n" if $quests_lut{$args[1]}{summary};
				$msg .= TF("Objective: %s\n", $quests_lut{$args[1]}{objective}) if $quests_lut{$args[1]}{objective};
				message $msg;
			} else {
				message T("Unknown quest\n"), "info";
			}
		} else {
			message T("Usage: quest info <questID>\n"), "info";
		}
	} else {
		message T("Quest commands: set, list, info\n"), "info";
	}
}
TBC2014
Noob
Noob
Posts: 4
Joined: 09 May 2014, 15:29
Noob?: No

Re: Macro based on Quest Time

#2 Post by TBC2014 »

Update: 1: There seems to be a "Wait Quest" then after the wait quest it will reveal the true quest
2: I think the quest can be activated through the time, searching for references regarding time triggers
TBC2014
Noob
Noob
Posts: 4
Joined: 09 May 2014, 15:29
Noob?: No

Re: Macro based on Quest Time

#3 Post by TBC2014 »

Another Update:

It seems that even if I use the && statement to check the arguement. The minutes are not properly counted.
For example: It is 6:20 AM
X = 6, True
Y = 20, False
Therefore it should not activate (using excel as another reference, I may have forgotten my math hahaha). But in Kore it is still triggered

Code: Select all

automacro 001 {
	location somewhere
	run-once 1
	priority 5
	call {
		log $.hour
		$x = $.hour
		if ($x = 6) goto checkmin
		stop
		:checkmin
		log $.minute
		$y = $.minute
		if ($y <= 15) goto task
		:task
		do c XD
	   }
}
-------

I saw the "edit" button O_O, too late though

Another Update:

It seems that using:

Code: Select all

localtime > 07:00:00
localtime < 08:00:00
as trigger works better, though I'd still prefer to know if I can hook it through the Quest itself
c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: Macro based on Quest Time

#4 Post by c4c1n6kr3m1 »

eval !%talk && ( $::questList->{'2303'}->{'time'} < time )

!%talk so it wont trigger in the middle conversation with npc
the rest is what you need
TBC2014
Noob
Noob
Posts: 4
Joined: 09 May 2014, 15:29
Noob?: No

Re: Macro based on Quest Time

#5 Post by TBC2014 »

Hmmm.. it does not trigger.
c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: Macro based on Quest Time

#6 Post by c4c1n6kr3m1 »

i'm sure it's working, i used for my older macro

Code: Select all

eval ( $varStack{".time"} > $::questList->{7267}->{time} && ($::questList->{7267}->{active}?1:0) == 1)
sometimes

Code: Select all

eval ($::questList->{'2303'}->{'active'} == 1 && $::questList->{'2303'}->{'time'} < time)
for hunting quest

Code: Select all

eval (($::questList->{7139}->{active}?1:0) == 1 && ($::questList->{7139}->{missions}->{1076}->{count}) == 15)