Page 1 of 1

Beggar .js help

Posted: Mon Jan 30, 2006 3:56 am
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!

Posted: Mon Jan 30, 2006 4:09 am
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.

Posted: Mon Jan 30, 2006 4:12 am
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!

Posted: Mon Jan 30, 2006 4:24 am
by stranf
Thanks again for all your help!

I'll probably be posting debug questions when I run into a jam. 8) .

Posted: Mon Jan 30, 2006 4:34 am
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

Posted: Mon Jan 30, 2006 9:13 am
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.