Call consult script from another consult script.

asturia

Minion
I have 2 consultscripts that deal with different things.
One is this:
Code:
void main(int initround, monster foe, string url)
{
	int puttycounter = get_property("spookyPuttyCopiesMade").string_to_int();
	if (puttycounter < 5)
	{
		if (item_amount($item[spooky putty sheet]) > 0)
		{
			throw_item($item[spooky putty sheet]);
		}
		else
		{
			attack();
		}
	}
	else
	{
		attack();
	}
}

It checks if it can use a spooky putty sheet in combat or not.
If it can not use is I want it to attack. but now I want to change the attack option so that it uses the FirstThingsFirst cosnult script instead.

Any idea how I do this?
 

zarqon

Well-known member
Edit FirstThingsFirst, and put the contents of your main() at the top of FTF's main(), without the else's. Also, change

PHP:
throw_item($item[spooky putty sheet]);

to

PHP:
act(throw_item($item[spooky putty sheet]));

Then everything should be hunky-dory.
 

asturia

Minion
How about this?

Code:
void main(int initround, monster foe, string url) {
	round = initround;
	nowfightingonstageone = foe;           // make the monster global for intheclear()
	handle_grin(foe,url);
	if (intheclear() && contains_text(url,"You get the jump"))
	{
		url = class_action(url);
	} 
	else url = try_skill(url,$skill[entangling noodles]);
	if (m == $monster[goth giant]
	{
		int puttycounter = get_property("spookyPuttyCopiesMade").string_to_int();
		if (puttycounter < 5)
		{
			if (item_amount($item[spooky putty sheet]) > 0)
			{
				act(throw_item($item[spooky putty sheet]));
			}
		}
	}
	handle_olfaction(foe,url);
	if (my_location() == $location[barrrney's barrr]) handle_insults(url);
	use_special_item(foe,url);
	if (my_maxhp() - my_hp() > 15) try_skill(url,$skill[saucy salve]);
	clear_poison(url);
	if (round == initround) url = attack();     // can't have it do nothing
}

does it only throws a putty sheet at a goth giant now?
that was the first reason why I had 2 consult scripts.

I had in my ccs
Code:
[default]
consult firstthingfirst.ash
attack

[goth giant]
consult puttysheet.ash
consult firstthingfirst.ash
attack

I'm even thinking of adding a third so that it only uses my Mayfly thingie when the skill is available.
 

zarqon

Well-known member
Haha, I was wondering why you would want to use it on any old monster.

So, put it in FTF's use_special_item() function then... You will need to stick it in an if statement like the other monsters in that function:

PHP:
if (m == $monster[goth giant] && item_amount($item[spooky putty sheet]) > 0) {
  if (to_int(get_property("spookyPuttyCopiesMade")) < 5)
   return act(throw_item($item[spooky putty sheet]));
}

I'll probably be adding putty sheet support to FTF, just haven't gotten around to it yet.

EDIT: In your previous post, you can't use m for the monster variable, since that exists in use_special_item(), not main(). Change m to foe and it'll do what you want.
 

asturia

Minion
thanks for the help.
I'll test it tomorrow and let you know how it worked.

Just to confirm.
When encountering a goth giant, it will now try to first use a putty sheet and then try to olfaction it?
Is this correct?

I have now this in my ccs:
Code:
[Goth Giant]
1: skill Summon Mayfly Swarm
2: consult FirstThingsFirst.ash
3:attack
 
Top