Page 1 of 1

<onSkillCast> problem /loop

Posted: Thu Sep 03, 2009 5:24 am
by d003232
I want to use the <onSkillCast> event for my emergency skills. Simply because if I use the normal skill casting round, it takes very often to long to use the emergency skills. So my idea is, to check for an emergency situation after every cast.

Code: Select all

<onSkillCast>
	if( 15 > player.HP/player.MaxHP*100 ) then
	    player:cast("PRIEST_SOUL_SOURCE");
	elseif( 25 > player.HP/player.MaxHP*100 ) then
	    player:cast("PRIEST_HOLY_AURA");
	    player:cast("PRIEST_URGENT_HEAL");
	    player:cast("PRIEST_URGENT_HEAL");
	end;
</onSkillCast>
Problems seems now, that the bot also use the '<onSkillCast>' event if he casts allready within <onSkillCast>. So he loop endless.

If I find a little more time, I would/will try to look for a solution.

btw: I couldn't get that coding to work with the '&lt' symbol. So I turn it around as '>' query.

Re: <onSkillCast> problem /loop

Posted: Thu Sep 03, 2009 7:35 am
by Administrator
Compare arg1.Name with the skill you are casting inside onSkillCast so you know not to try to cast it again. Also, try putting the semicolon in '<' and it should work.

Re: <onSkillCast> problem /loop

Posted: Thu Sep 03, 2009 3:41 pm
by d003232
Administrator wrote:Compare arg1.Name with the skill you are casting inside onSkillCast so you know not to try to cast it again.
The bot will now execute the event onSkillCast only if he cast skills directly from the skill list. It will not be executed, if someone cast a skill from within the onSkillCast event. I think that's the easiest solution and I don't think that people need a recursive onSkillCast event.

I could also create a global variable 'onSkillCast_recursiv' ( true | false) or so, witch could easily checked within the event. But if there are no demands for a recursive use, I would prefere the first solution: onSkillCast event only for skills directly from the skill list.
Administrator wrote: Also, try putting the semicolon in '<' and it should work.
Damned, I never noticed that ';' :evil: