Beggar .js help

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Beggar .js help

Post by stranf »

Ok, it seems nobody has a beggar script, so I think I'll write one now that I've had some experience with the loremaster.


Basically what I envision is something like (onGive) (that fires when an object is given to an NPC)

pseudocode:

Code: Select all

function onGive(mChar,myNPC,ourOBJ)
{
 if (ourOBJ == (goldIdhex#)
    {
      mChar.karma=mChar.karma+50;
      myNPC.TextMessage("Wow, I'm rich now and don't have to live in      Minoc slums!");

     ourObj=destroyRescourse();
     

  if(ourOBJ==(ediblefoodhex#s)
    {  do junk
    }

}
//eof
     } 




}


Ok, I can figure out rescource destruction form the pgate script, but I'm going to need to know:

1: what event to call when a player drops gold or food on an NPC.
2: Can somebody look in the source code and rip the id hex #s for editible food objects? (I'm assuming it's there, since the computer needs to know what is or isn't food when you eat)

I'd like to be able to give beggars food as well as money.

Thanks!
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

This is the function you are wanting

Code: Select all

onDropItemOnNpc  
Prototype function onDropItemOnNpc( pDropper, pDroppedOn, iDropped )

 
When triggered When iDropped is dropped on pDroppedOn  
Notes First iDropped's script is activated, and if it doesn't bounce, then same script is activated for pDroppedOn
Return Value Table:
0 == bounce
1 == don't bounce, use code
2 == don't bounce, don't use code  
Purpose  
Example of Usage function onDropItemOnNpc( pDropper, pDroppedOn, iDropped )
{
	pDropper.TextMessage("Here, I offer you my this object as a gift of friendship.");
	pDroppedOn.TextMessage("Fudge off!");
	iDropped.colour =13;
	return 0;
}
I'll see if I can dig up the hex ID's (or see how exactly UOX3 handles it, it may be by type.
Scott
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Yes, as I figured UOX3 knows an item is a food item based on its TYPE.

The type for food is 14

IE if( item.type == 14 ) // food!
Scott
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Thanks again for all your help!

I'll probably be posting debug questions when I run into a jam. 8) .
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

I just threw this doc together, but it may help future questions of that nature.

It's a listing of all UOX3's item types in numerical order.

http://sourceforge.net/docman/display_d ... _id=113893
Scott
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 »

I'm not home right now, but I think I recall having trouble with the return values for the onDropItemOnNpc event. Hrm. Might remember incorrectly though.
-= Ho Eyo He Hum =-
Post Reply