Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-08-2011, 03:49 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Distance?

Okay i'm going to start working on something and it requires a distance formula between a player and another player(or npc). When I mess around with one distances come up as negatives sometimes depending where the player is. I have ran into one a few times a while back but I can't seem to find it.

Any help would be appreciated, thank you


EDIT: I did a quick mockup of what my end goal is to be (with players only. npc was just to test)
Pretty much the further a player is from another player the less alpha the player has. I just have no idea how I could accomplish this. GANIs? Add a weapon to everyone that has it?

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
setshape(13232);
  
setTimer(0.05);
}

function 
onTimeout() {
  
temp.np findnearestplayer(this.xthis.y);
  
temp.dx this.player.x;
  
temp.dy this.player.y;
  
this.chat temp.np ": " temp.dx "," temp.dy;
  
  if (
temp.dx && temp.dy <= 3) {
    
this.alpha 1;
  }
  
  if (
temp.dx && temp.dy 3) {
    if (
temp.dx && temp.dy <= 6) {
      
this.alpha 0.75;
    }
  }
  
  if (
temp.dx && temp.dy 6) {
    if (
temp.dx && temp.dy <= 9) {
      
this.alpha 0.5;
    }
  }
  
  if (
temp.dx && temp.dy 9) {
    if (
temp.dx && temp.dy <= 12) {
      
this.alpha 0.25;
    }
  }
  
  if (
temp.dx && temp.dy 12) {
    if (
temp.dx && temp.dy <= 15) {
      
this.alpha 0;
    }
  }
  
setTimer(0.05);


Last edited by pig132; 10-08-2011 at 03:59 AM..
Reply With Quote
 

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:42 PM.


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