Page 1 of 1

Exporting Night Sight

Posted: Thu Apr 19, 2007 4:06 pm
by stranf
Now that I have the worldlight fixed (thanks grimson, renaming regions.wsc did the trick), I was wondering how I can tweak night sight. Since spells can be exported, maybe we can do this.

As far as I know, night sight seems over-powered for a first circle spell. As I understand, it changes the worldlight to the brightlight setting. I am unsure of the duration.

I tested it with my mage, in a dungeon (I have dungeons at pitchblack level 15 light), and he casts night sight and it is clear as day, as it should be. However, I feel the duration is a bit long, and the brightlevel is a bit bright. Especially for a first level.

I was wondering if I can export night-sight to .js, so that I can adjust the duration and light level.

I am unsure how to code this, or the functions required to export a spell from code to .js.

Posted: Fri Apr 20, 2007 10:44 am
by Maarc
Given the amount of code involved, you probably want to edit level1targ.js rather than do it all by hand. If you have a look through, you'll see there's a *lot* of setup code dealing with magery. But what you REALLY care about is DispatchSpell(). Bung in another else if, basically.

Basically, you need to translate this code into JS :)

Code: Select all

	Effects->tempeffect( src, target, 2, 0, 0, 0);
	if( target->IsMurderer() )
		criminal( caster );
Not ... much, I know. Which will look something a lot like:

Code: Select all

	DoTempEffect( 0, caster, ourTarg, 2, 0, 0, 0 );
	if( ourTarg.murderer )
		caster.criminal = true;
Now, that probably doesn't give you the level of control that you're looking for. In reality, it's probably something more like:

Code: Select all

	ourTarg.lightlevel = 5; // set fixed light level here
	ourTarg.StartTimer( caster.magery * 1000 / 2, 1, true );
	if( ourTarg.murderer )
		caster.criminal = true;
and add a callback function (thiiiink this might work)

Code: Select all

function onTimer( mObj, timerID )
{
	if( timerID == 1 )
		mObj.lightlevel = -1;
}
Haven't got an environment to test in at the moment, but that looks like the right sort of thing. Oh, and don't forget a

Code: Select all

	RegisterSpell( 6, true );	// night sight
in the SpellRegistration() function of your JS file.

Good luck!

Posted: Sat Apr 21, 2007 2:54 am
by stranf
Works like a charm. Thanks. I'm fiddling with the timer now to tweak it to a level I like.

Posted: Sat Apr 21, 2007 7:01 am
by Maarc
Really? Shit a brick, I didn't expect it to work straight off haha, I coded that blind.

FWIW, the code sets the timeout to be Magery / 2. So 500 seconds for GM mage. But you have to multiply by 1000 (I think), because you specify milliseconds? Can't remember quite right, think it's something like that.

Enjoy :)

Posted: Sat Apr 21, 2007 2:38 pm
by stranf
I was expecting some debugging myself. I did have to do that... I added the OnTimer as its own function, as I was unaware that the original script already had an OnTimer function.

This didn't give me a compile error, and the script would fire from the c++ code instead of the .js code. even though no error was reported. Took me about 20 minutes to figure that one out.

The timer is the most difficult spot to tweak. I wanted to make sure the code worked so I set it as "Magery" and sure enough it worked for less than a second.

I want my dungeons to be dark, so I did it as skills* 20 and got about a 30 second burst from a master wizard. I kicked it up to skills * 45 so it should be around 1-1.5 minutes, which is where I wanted a level 1 light spell cast by a GM to be.

500 seconds = 8 min. and would ruin the fun of my dark dungeons. :P

Posted: Sat Apr 21, 2007 4:03 pm
by Grimson
So now you just have to make sure no one turns the "dark nights" setting in his client off ;).

Posted: Sat Apr 21, 2007 4:41 pm
by stranf
exactly. Too bad we can't have a gm-functin to turn this "on". :)

Actually, since all of us rotate who GMs quests, all of our PCs pretty much have access to all GM clients. So "cheating" with dark nights off is probably one of the least things they could do. lol.