Page 1 of 1

Self Destruct on Cue!

Posted: Wed Sep 19, 2007 12:11 am
by Mindless Automaton
A combo of the speech_001.js and stranf's firetrap.js for some good clean fun!

Code: Select all

function onSpeech( myString, myPlayer, myNPC )
{
	if( !myNPC.InRange( myPlayer, 2 ) )
		return;
	var Speech_Array = myString.split(" ");
	var i = 0, currObj = 0;
	for( i = 1; i <= Speech_Array.length; i++ ) 
	{
		if( Speech_Array[currObj].match( /\bboom\b/i ) )	
		{			myNPC.TurnToward( myPlayer );
					var damage = RandomNumber(20,10);
					myNPC.MagicEffect( 43 );
					myNPC.SoundEffect(0x0207, true);
					myNPC.health =myNPC.health - damage;
			return;		}
		currObj++;
	}
}// [EOF]
You may need to adjust the damage if you want it to kill some bigger critters. I used it on small furries. :)

Enjoy!

Posted: Thu Sep 20, 2007 4:54 am
by giwo
lol, nice!

Grimson/Xuri/Maarc - I'm too lazy to look, didn't we expose some form of JS Method that handled dealing damage (rather than health = health - damage).

Posted: Thu Sep 20, 2007 9:56 am
by Maarc
Yup we did. Damage(). It was for damage tracking stuff, so (if desired, not done in code), you could apportion out karma/fame stuff based on who did what damage. Takes 1 (amount), 2 (amount and attacker) or 3 (amount, attacker and doRepsys) parameters.