The item_skill for attacking monster

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderator: Moderators

Message
Author
sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

The item_skill for attacking monster

#1 Post by sofax222 »

I try implement the item_skill for attacking monster.
But now, I got a problem !
How to got the ID of the monster that the char is attacking ??
I try the "AI::args->{attackID}" !
But, it is not always corret !

Is there something like "char->{attackID}" ?

Soulless
Noob
Noob
Posts: 7
Joined: 24 Sep 2010, 04:27
Noob?: Yes
Location: facebook.com/ladysoulless
Contact:

Re: The item_skill for attacking monster

#2 Post by Soulless »

i used this to identify current attack target..

AI::args->{ID}

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: The item_skill for attacking monster

#3 Post by sofax222 »

Soulless wrote:i used this to identify current attack target..

AI::args->{ID}
I know this !
It is true when the current action is "attack" (AI::action eq 'attack')...
It is false when the current action is not "attack".

For example, bot found a monster to attack, then add a attack task (with the target AI::args->{ID}) to the AI queue.
Then, insert a "rout" or "move" task to AI queue, to move to the target monster.
In this moment ("route" action), the AI::args->{ID} is undefined !
The AI::args->{ID} is definded in the sequece "attack" task !
At this "route" moment, how to get the AI::args->{ID} ??

I found a method as :

Code: Select all

................
	my $attackIndex = AI::findAction("attack");
	if ($attackIndex ne "") {
		my $args = AI::args($attackIndex);
		if (defined($args->{'ID'})) {
			my $targetID = $args->{'ID'};
................
Is thers any other method better than this ?

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

Re: The item_skill for attacking monster

#4 Post by EternalHarvest »

AI::findAction is the preferred method, since queue can contain just about everything.

However, if you want to trigger something while attacking, you may want to check for AI::is('attack') - if so, AI::args would refer to attack too.

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: The item_skill for attacking monster

#5 Post by sofax222 »

Thxs ! I got it !

Locked