need help with triggers

Forum where anything UOX3-related goes - including, but not limited to: newbie-support, ideas, general questions, comments, etc and-so-forth.
Post Reply
User avatar
Natas
UOX3 Novice
Posts: 70
Joined: Fri Mar 25, 2005 3:00 am
Location: Del Valle, texas United States
Has thanked: 0
Been thanked: 0

need help with triggers

Post by Natas »

Hi. I'm having trouble with starting my own triggers for my quests. I don't know a lot about js and can't start one from scratch. Could someone make me an outline for a trigger where if a chr drops an item on the npc a reward item will be placed in the chr bag and have the npc say a message? If someone could help me out I would appreicate it!

Thanks in advance...

-Natas-
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Here you have a working example. Drop a candle (from a newbie character, for instance) on an NPC who has this script attached, and you'll get 200 gold pieces as reward.

To attach the script to the NPC, save it in a .js file under the UOX3\JS\CUSTOM folder, add a new line in JSE_FILEASSOCIATIONS.SCP saying something like...
10000=custom/myquest.js
...just above the } bracket above [COMMAND SCRIPTS], save the file, reload it from UOX3 console by pressing '8', and use the 'SETSCPTRIG 10000 command on your quest NPC.

Code: Select all

function onDropItemOnNpc( pDropper, pDroppedOn, iDropped )
{
	if( iDropped.id == 0xa0f ) //If the item being dropped is a candle
	{
		pDroppedOn.TextMessage("Wow, you have found a candle for me! Thanks a lot!");
		pDroppedOn.TextMessage("Here, have 200 gold as thanks!");
		//Create a new item with ID 0x0eed (gold piece) with amount 200, in pDropper's backpack (true).
		var itemMade = CreateDFNItem( pDropper.socket, pDropper, "0x0eed", 200, "ITEM", true );
		//Delete the candle
		iDropped.Delete();
		[color=yellow]return 2;[/color]
	}
	else
	{
		pDroppedOn.TextMessage("Hm no thanks, not interested.");
		//Bounce item dropped on NPC back to player
		return 0;
	}
}
Last edited by Xuri on Thu Apr 07, 2005 11:49 pm, edited 1 time in total.
-= Ho Eyo He Hum =-
User avatar
Natas
UOX3 Novice
Posts: 70
Joined: Fri Mar 25, 2005 3:00 am
Location: Del Valle, texas United States
Has thanked: 0
Been thanked: 0

Post by Natas »

Thanks Xuri! That script worked great! But I have run into a problem which is most likely easy to fix for someone with more JS experince then me.

When ever I drop the item on the NPC it works fine but there is another message the npc says after the message that is in the script. The NPC says "Thank thee kindly, but I have done nothing to warrent a gift" I tryed playing with the script a bit but I just messed it all up and had to make a new one because I really don't now how to use JS very well yet.

Could you tell me how to get rid of this annoying "extra" message? It would help me out alot. Oh and BTW, how do I add a sound to the script when ever the item is successfuly droped on the NPC?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

To get rid of the extra feedback from the NPC, add a new line saying return 2; just below the iDropped.Delete(); line, as indicated in the highlighted part in the script example above (I edited it).

For a sound-effect, try a line saying pDroppedOn.SoundEffect( 256, true );, below iDropped.Delete(); and above return 2;
-= Ho Eyo He Hum =-
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Oh, by the way - if you're hearing all your human NPCs moaning and screaming all the time for no apparent reason, open DFNDATA\CREATURES\creatures.dfn, then locate and comment out the two following sections by placing two slashes // infront of each line like I've done below:

Code: Select all

//[CREATURE 0x190]
//{ Human
//BASESOUND=0x0
//ICON=0x2106
//SOUNDFLAG=0
//}

//[CREATURE 0x191]
//{ Human
//BASESOUND=0x0
//ICON=0x2107
//SOUNDFLAG=0
//}
You might have to restart your server for this change to go into effect though.
-= Ho Eyo He Hum =-
User avatar
Natas
UOX3 Novice
Posts: 70
Joined: Fri Mar 25, 2005 3:00 am
Location: Del Valle, texas United States
Has thanked: 0
Been thanked: 0

Post by Natas »

Yeah I noticed that when I created my first NPC. And I got feed up with it and disabled the NPC sounds all together. lol. Thanks for telling me how to fix it.
Post Reply