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-
need help with triggers
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
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.
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 =-
- 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
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?
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?
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
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;
For a sound-effect, try a line saying pDroppedOn.SoundEffect( 256, true );, below iDropped.Delete(); and above return 2;
-= Ho Eyo He Hum =-
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
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:
You might have to restart your server for this change to go into effect though.
Code: Select all
//[CREATURE 0x190]
//{ Human
//BASESOUND=0x0
//ICON=0x2106
//SOUNDFLAG=0
//}
//[CREATURE 0x191]
//{ Human
//BASESOUND=0x0
//ICON=0x2107
//SOUNDFLAG=0
//}-= Ho Eyo He Hum =-