Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #31  
Old 08-09-2011, 08:27 PM
Adddeeee Adddeeee is offline
Registered User
Join Date: Aug 2011
Posts: 30
Adddeeee is on a distinguished road
Thank you very much! Now I think I understand the DB NPC

Although, I still have problems with the PlayerTouchsMe. It seems as if the player touches the NPC when the player is located to the top left of the NPC.

This is the NPC script:

Graal Script Code:
join("shop");

//#CLIENTSIDE

function onCreated()
{
  
showcharacter();
  
nick "Candy"//Sets the nickname of the character
  
ap 100//Sets the ap of the character. Also affects the colour of the nickname
  
headimg "head722.gif"//What head image to use
  
bodyimg "body8.png";   //What body image to use
  
colors[0] = "orange";     //Sets the skin colour
  
colors[1] = "lightblue";     //Sets the coat colour
  
colors[2] = "yellow";     //Sets the sleeves colour
  
colors[3] = "darkred";     //Sets the shoes colour
  
colors[4] = "lightgreen";     //Sets the belt colour
  
shieldimg "no-shield.gif"//Sets the shield image
  
shieldpower 1//Must have this or the shield won't show


and this is the shop class:

Graal Script Code:
function onCreated()
{
   
setShape(13232);
   
this.shop_id "basicshop";
}

function 
onPlayerTouchsMe()
{
  
this.listofitems DB_Items.getShopItems(this.shop_id);
  
triggerclient("gui""-shopcontrol"this.listofitemsthis.xthis.y);         

Am I missing something that causes the PlayerTouchsMe to fire when I'm located to the top left of the NPC?
Reply With Quote
  #32  
Old 08-09-2011, 08:30 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
You're setting the shape to a 32px by 32px block, which doesn't perfectly fit the character. Try something like 38x48 (change the setShape). I can't remember exactly what it should be, so just change the values until it's working as you want it to, being sure to update the level in-between changes.
__________________
Reply With Quote
  #33  
Old 08-09-2011, 08:32 PM
Adddeeee Adddeeee is offline
Registered User
Join Date: Aug 2011
Posts: 30
Adddeeee is on a distinguished road
Ah okay, I thought 32x32 pixels was the default character size :O

Isn't the "hit box" drawn from the upper left corner of the NPC to the lower right corner as a rectangle with the size specified in setShape?
Reply With Quote
  #34  
Old 08-09-2011, 08:53 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
For normal NPCs 48 by 48 will do fine on server-side, and you're right on about the hit box.

The point of your shop class is to make it accept any shop id, so in your NPC you should be setting the shop id not in the class itself. I.e:

Graal Script Code:
function onCreated() {
  
this.shopid "basicshop";
  
this.join("shop");

In your class you can then do a check like this..

Graal Script Code:
// Undefined shops default to the basic shop
if (this.shop_id == NULLthis.shop_id "basicshop"
__________________
Quote:
Reply With Quote
  #35  
Old 08-09-2011, 09:03 PM
Adddeeee Adddeeee is offline
Registered User
Join Date: Aug 2011
Posts: 30
Adddeeee is on a distinguished road
Yepp I did that just to check if it worked. I'm going to setup different shop IDs and add them to the different NPCs before joining the class.

But if I set the setshape to 48, 48 wouldn't I touch the NPC even when I'm far away from it?

EDIT: NOticed that it worked just fine But what about the 32, 32 hit box?

Feels like I need an explanation why the hit box is 32,32 while the NPC should be set to 48,48? Is it because the NPCs image blocks the player?

Last edited by Adddeeee; 08-09-2011 at 09:14 PM..
Reply With Quote
  #36  
Old 08-09-2011, 09:20 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Adddeeee View Post
Yepp I did that just to check if it worked. I'm going to setup different shop IDs and add them to the different NPCs before joining the class.

But if I set the setshape to 48, 48 wouldn't I touch the NPC even when I'm far away from it?
It's in pixels, so no. I don't think it will be touched until the "wall" of your player collides with it on the server-side.
__________________
Quote:
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:54 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.