use_skill returns true on auto-recovery failure

Metraxis

Member
Build 2295:

My self-buffing code has this snippet in it:

Code:
			while(have_effect(TEffect) < turns && flag) {
				flag = use_skill(1, TSkill);
			}
			return (have_effect(TEffect) >= turns);

Unfortunately, it is not behaving as I intend.

My intent is for this snippet to keep casting the skill until I have the target number of turns of the effect, but to stop if it fails to cast the skill (for example, because I have run out of meat and cannot afford any more mmj.) 

However, use_skill() seems to return true even if it is unable to cast the skill due to autorecovery failure.  So is this a bug, or am I just being stupid?
 

Friedfisch

New member
Re: Is this a bug, or am I just being stupid?

i guess you might try this one:

while ((have_effect(TEffect) < turns) && flag)
 

Metraxis

Member
Re: Is this a bug, or am I just being stupid?

I actually tried that, and it didn't help. A little creative print() ing showed that use_skill() seems to always return true, even if there was not enough mp to cast the skill. I worked around the problem by checking after each cast to be sure that I had more turns of the effect than before.
 

holatuwol

Developer
[quote author=Metraxis link=topic=576.msg2784#msg2784 date=1163275615]
I actually tried that, and it didn't help.  A little creative print() ing showed that use_skill() seems to always return true, even if there was not enough mp to cast the skill.  I worked around the problem by checking after each cast to be sure that I had more turns of the effect than before.
[/quote]

Not entirely true; there are a lot of spellcasting failures that will result in a false value.  However, auto-recovery was not considered a spellcasting failure (it was considered an internal error) and therefore it should have caused a script abort ... except you were storing the value which reset that flag.  I don't have a multi to test the fix (I tend to be well-stocked on MP restores), but you should be seeing false come back when auto-recovery fails in the next release.
 
Top