More timed scripts items

Open discussion forum. For topics that do not fit anywhere else.
Locked
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

More timed scripts items

Post by Yukiko »

[Edited on 2/12/2007 by Yukiko to correct errors in the endStrength script and to clarify bug noted below.]


First here's a script that's missing in the subscripts folde under 'magery'.

endStrength.src

Code: Select all

/*
 * $Id: endStrength.src 921 2007-02-09 21:00:00Z tekproxy with a tiny mod by Yukiko to turn end Cunning to endStrength $
 *
 */
 
use uo;
use os;

include "include/attributes";

program TimedScript_EndStrength(params)

	var mobile := params[1];
        
	var points := CInt(GetObjProperty(mobile, "StrengthMod"));	
	AP_ModifyStatMod(mobile, STRENGTH, -(points));
	EraseObjProperty(mobile, "StrengthMod");
	
	return 1;
endprogram
I'll have you know I slaved over a hot laptop for over 2 minutes creating that script so don't anyone ever say I never wrote a script for the Distro. Making the changes to endCunning to create that script weren't easy I'll tell you! All that deleting and typing....
*grins*

Now on to a problem I am having with the timed scripts. The mods aren't being removed properly after a log out and reconnect or login.

When the login script gets run after a complete logout I get a SysMessage from TS_StartController that the script is already running.

The mods stick and, if they are cast on yourself, for some reason this prevents you from casting another spell because it trips the "protection clause" in spellSTarter.

"Protection clause" of spellStarter:

Code: Select all

		if ( !protection )
			// There is a small chance, perhaps, that the mobile is damaged and then regens
			// or is healed enough in the ~50ms delay between checking. It could be more
			// accurate to grab the pid from ApplyDamageEX and send a damaged event to this
			// script, on top of also checking the health.
			if ( orig_hp > GetBaseStrength(mobile) )
				SendSysMessage(mobile, "Your concentration is disturbed, thus ruining thy spell.", color := 33);
				FailSpell(mobile);
				PlaySoundEffect(mobile, SFX_SPELL_FAIL);
				PlayObjectCenteredEffect(mobile, FX_SPELL_FAIL, 5, 50);
				return 0;
			endif
		endif


I must admit that I have no clue what's happening there or with the timed script thingy. Tek or Aus might need to look at that. I am writing a work around until it's fixed.
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

Thanks for letting me know about this. I added the script in and added more comments to the code explaining what was going on there. You're going to find more if you keep digging, magery isn't finished yet. I keep a todo list in the docs directory.

Always had a little trouble with timed scripts. Not sure if it was because I was doing something wrong or a tiny problem in the package itself.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

There is one correction to my version that you'll have to make if you didn't see it already, change the include line to:

Code: Select all

include ":attributes:attributes";
I am still working with the old, but expanded, attributes.inc file in the includes folder.
Locked