Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-03-2012, 08:44 PM
garglius1 garglius1 is offline
Butcher of the Kingdoms
Join Date: Mar 2004
Location: Montreal, Quebec
Posts: 213
garglius1 is on a distinguished road
Send a message via MSN to garglius1
Warping while standing at a specific location

Hi. I have recently taken to making my graal kingdoms house levels, and after reading the guides online, it has been going fairly well. I've come to a point where I can't find the info I need to do exactly what I want to do, so I've come here to ask.

Essentially I have an NPC that looks like this:
PHP Code:
function onPlayerChats() {
  if (
player.chat == "I want out") {
    
player.setlevel2("insidedustari_mainfloor.nw",30.5,4.5);
  }


which works perfectly in warping me from the level it's in to the other level. What I am looking to do though is to make it work only when the player is standing in a specific area (a carpet on my floor) rather than working in the whole room. The coordinates for my carpet are:

top left corner : x= 28.5 y=48.5
top right corner: x=32.5 y=48.5
bottom left corner: x=28.5 y=52
Bottom right corner: x= 32.5 y=52

Essentially I would like it to be so that my warp command only works when standing within these coordinates. Any help and comments appreciated
__________________
-Garg, the former GK Pro-

5813... WHAT!
Reply With Quote
  #2  
Old 05-03-2012, 09:01 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Checking if a player is between the top left and bottom right corner should work.

PHP Code:
if (player.x in 28.548.5 | && player.y in 32.552 |) {
  
//warp player

Reply With Quote
  #3  
Old 05-03-2012, 09:58 PM
garglius1 garglius1 is offline
Butcher of the Kingdoms
Join Date: Mar 2004
Location: Montreal, Quebec
Posts: 213
garglius1 is on a distinguished road
Send a message via MSN to garglius1
I have it looking like this now

PHP Code:
function onPlayerChats() {
if (
player.x in 28.548.5 | && player.y in 32.552 |) {


  if (
player.chat == "I want out") {
    
player.setlevel2("insidedustari_mainfloor.nw",30.5,4.5);
  }
}

and it still warps me wherever I am in the level.
__________________
-Garg, the former GK Pro-

5813... WHAT!
Reply With Quote
  #4  
Old 05-03-2012, 10:18 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
I find it hard to work simple maths problems out, so I'll explain how to do it. Work out the distance from top left corner to top right and then the bottom left to the top left. I think that'll give me the numbers I need.
Reply With Quote
  #5  
Old 05-03-2012, 10:21 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
Quote:
Originally Posted by Emera View Post
I find it hard to work simple maths problems out, so I'll explain how to do it. Work out the distance from top left corner to top right and then the bottom left to the top left. I think that'll give me the numbers I need.
Why do you need distance? The solution you posted already will work just fine. If it's not working for garglius, then something else is going on.

edit: you entered the wrong coordinates

PHP Code:
player.x in |28.532.5| && player.y in |48.552
__________________
Reply With Quote
  #6  
Old 05-03-2012, 10:26 PM
garglius1 garglius1 is offline
Butcher of the Kingdoms
Join Date: Mar 2004
Location: Montreal, Quebec
Posts: 213
garglius1 is on a distinguished road
Send a message via MSN to garglius1
I've put a picture of the grey 'carpet' I want to be able to warp on with the measures around it. Top left to top right is 4, top left to bottom left is 3.5
Attached Thumbnails
Click image for larger version

Name:	Measures.jpg
Views:	181
Size:	500.7 KB
ID:	54579  
__________________
-Garg, the former GK Pro-

5813... WHAT!
Reply With Quote
  #7  
Old 05-03-2012, 10:58 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by cbk1994 View Post
Why do you need distance? The solution you posted already will work just fine. If it's not working for garglius, then something else is going on.

edit: you entered the wrong coordinates

PHP Code:
player.x in |28.532.5| && player.y in |48.552
I had a suspicion that I entered the wrong coordinates, but when I sat down to try and work it out my brain refused to cooperate lol. Thanks for posting the correct coords.
Reply With Quote
Reply


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 05:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.