Sleep() and another analogue

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Forum Regular
Posts: 308
Joined: Sat Mar 18, 2006 1:41 am
Location: Germany

Sleep() and another analogue

Post by Harley » Mon Aug 07, 2017 1:34 pm

Hi there!)

I hope that I don't disturb you much.

After solution with removing Property from Array (thanks CWO) I went on and implement nice Buff Icons display for our shard.

That system was made with RusseL help and with guialtran help.

I synthesized these two and made it.
But! I still have another issue, which I can't understand how to fix it.

Example with Target Spell script - Reactive Armor.

Code: Select all

	DoTempMod( cast_on, str_mod, CInt( power ), CInt( duration ), mod_type, spelldata.caster );

	var buff_icons := BuffOn( cast_on,, power, duration );
We set with function DoTempMod() params on character and after set on buff icons with BuffOn().
All works fine!

But! If we use script with Target Area Spell like Arch Protections or Mass Curse, where is foreach endforeach - we have a trouble. Script cast to the first character and stopped, 'cause wait to remove Buff icons from that character and follow to another.

Example with Mass Curse:

Code: Select all

	foreach cast_on in ....
					DoTempMod( cast_on, Lower(spelldata.cfg_elem.mod), (0 - mod_amount), 15, Lower(spelldata.cfg_elem.ModType));

					var buff_icons := BuffOn( cast_on,, mod_amount, 15 );
In my BuffOn there is function at the end of script:

TimeToBuffOff( who, icon, duration );

Code: Select all

function TimeToBuffOff( who, buff, duration )

	if (duration <= 0)
		duration := 0;
	//print(" | TimeToBuffOff() | duration : " + duration ); // DEBUG



	//BuffOff( who, buff );
	BuffDebuff_removeIcone2( who, buff );

So, you can now understand. When I use Mass Curse or Arch Protection at the first character, my script follow to that TimeToBuffOff function, and wait, 'cause there is Sleep() function. Scripts wait and doesn't want to move to another character at the radius of 10 tiles. When time is over and Sleep() comes to the end, script follow to the next character and again wait....

I don't know, how and what I have to do, to fix this trouble with Sleep() function.
Oh, eah.. You can see Detach(); function and it doesn't work.

Best regards!

User avatar
POL Expert
Posts: 1136
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Sleep() and another analogue

Post by CWO » Mon Aug 07, 2017 3:04 pm

Detach() is used for an entirely different purpose but you probably do still want it here since you don't want to have the script attached while it's sleeping (if it is attached). Either TimeToBuffOff needs to be moved to a start_script() call or you need to move TimeToBuffOff out of the BuffOn function and put it after the foreach. You'll likely have to make the "who" parameter into an array and do a foreach inside TimeToBuffOff after the sleep to debuff everyone.

Post Reply