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
  #1  
Old 06-06-2012, 01:42 AM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
Making a formula

I'm not sure how to write it out, but basically trying to make the 'zoom' value get higher as the player.y gets closer to the NPC's this.y

Here is what I got, and if I were to do full script with all values, it would be very very very very long. So looking for a more efficient way

PHP Code:
function onTimeOut() {
 
setTimer(0.05);

 if (
this.y in |player.y-5player.y|)
 { 
  
this.zoom 5;
  }
 if (
this.y in |player.y-8player.y-5|)
 { 
  
this.zoom 4.5;
  }  
 if (
this.y in |player.y-11player.y-8|)
 { 
  
this.zoom 4;
  }  
 if (
this.y in |player.y-14player.y-11|)
 { 
  
this.zoom 3.5;
  } 
 if (
this.y in |player.y-17player.y-14|)
 { 
  
this.zoom 1;
  }
 if (
this.y in |player.y-20player.y-100|)
 { 
  
this.zoom 0;
  }   
 } 
note: this is for the player being below the NPC
Reply With Quote
  #2  
Old 06-06-2012, 01:46 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
All you need is the distance on one axis. Get the absolute value of the difference between the two coordinates and then multiply it to scale, or use exponents to scale exponentially. Assign that new number to the zoom value.
Reply With Quote
  #3  
Old 06-06-2012, 01:50 AM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
Quote:
All you need is the distance on one axis. Get the absolute value of the difference between the two coordinates and then multiply it to scale, or use exponents to scale exponentially. Assign that new number to the zoom value.
Yeah, That sounds very confusing lol
Reply With Quote
  #4  
Old 06-06-2012, 01:51 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by greggiles View Post
Yeah, That sounds very confusing lol
Then maybe you need to start reevaluating your scripting projects?
Reply With Quote
  #5  
Old 06-06-2012, 02:10 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Start by calculating the distance between the player and the object. If considering both the X and Y axis:
  • Distance between player X and object X: abs(player.x - this.x)
  • Distance between player Y and object Y: abs(player.y - this.y)
From that you can determine the actual distance between the player and the object (perhaps using the Euclidean distance formula). Once you have some number that represents the distance, you can then calculate your zoom.

(The use of abs in the examples above transforms a possibly negative number into a positive "absolute" number. This is because you might get a negative value depending on if the player is to the left or right or above or below the object X and Y coordinates you specify. Details on abs here.)
__________________
Skyld
Reply With Quote
  #6  
Old 06-06-2012, 03:08 AM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
Quote:
Then maybe you need to start reevaluating your scripting projects?
Jokes on you I figured it out
Reply With Quote
  #7  
Old 06-06-2012, 03:16 AM
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 greggiles View Post
Jokes on you I figured it out
You really showed Dusty. Maybe now that troll will quit spamming the scripting forums with his elitist anti-noob attitude.
__________________
Reply With Quote
  #8  
Old 06-06-2012, 08:32 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by DustyPorViva View Post
Then maybe you need to start reevaluating your scripting projects?
Unfair; Hezzy002's post is very hard to read.
__________________
Testbed user: I figured since I can never find any scripters it was time to take desperate measures...and...TEACH MYSELF 0.0
Reply With Quote
  #9  
Old 06-06-2012, 08:38 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by DrakilorP2P View Post
Unfair; Hezzy002's post is very hard to read.
I didn't just base what I said off of this thread. Hell, the very same distance formula was explained just a few threads down just for him:

http://forums.graalonline.com/forums...hp?t=134266527
Reply With Quote
  #10  
Old 06-07-2012, 03:49 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quote:
Originally Posted by DrakilorP2P View Post
Unfair; Hezzy002's post is very hard to read.
I dunno, the most advanced things in there are references to absolute values and exponents.. Both of which are covered in 7th grade pre-algebra. It's your own fault if you can't comprehend it, provided you went to middle school. Not like we're talking about college level math here.

EDIT: Maybe the phrasing is a little awkward, I'll give you that.

Last edited by Hezzy002; 06-07-2012 at 04:18 AM..
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 08:10 AM.


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