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-06-2004, 11:46 PM
XiLe XiLe is offline
Lylic < Me
XiLe's Avatar
Join Date: Dec 2002
Location: My House
Posts: 224
XiLe is on a distinguished road
Send a message via AIM to XiLe Send a message via MSN to XiLe
Getting the Nearest Player

Someone told me that if I used "with (getnearestplayer)" it'd find the player closest to active character... I found out obviously that it's not true... I'm trying to make a weapon spell for Maloria and having a hard time doing this the way the owner wants it, where it just finds the nearest person in the level and executes commands... anyone know a way I can get the nearest player?
__________________
AIM: xilesaim MSN: [email protected]
I'm the Co-Owner of Atrius... If you've got questions, ask me
Reply With Quote
  #2  
Old 05-07-2004, 12:00 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
var = getnearestplayer(x,y) (serverside.)
Reply With Quote
  #3  
Old 05-07-2004, 02:41 AM
xManiamaNx xManiamaNx is offline
Supreme Dictator
xManiamaNx's Avatar
Join Date: Nov 2002
Location: 127.0.0.1
Posts: 385
xManiamaNx is on a distinguished road
Send a message via MSN to xManiamaNx Send a message via Yahoo to xManiamaNx
pid=getnearestplayer(x,y);
with (getplayer(#a(pid))) dostuff();
__________________
Maniaman

Play Maloria Now: [2.3] [3]
Maloria Website

Reply With Quote
  #4  
Old 05-07-2004, 12:28 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
thers a getnearestplayers too i think.. returns near players in an array?
Reply With Quote
  #5  
Old 05-07-2004, 01:46 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
yes, and a getnearestnpc(s?) I have them all in me commands
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #6  
Old 05-07-2004, 01:49 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
If you read Stefan's hp document, it explains that:

Quote:
function attackplayers() {
pid = playerid;
pindexes = getnearestplayers(this.attackx,this.attacky,player id!=pid);
dist = 0;
for (i=0; i<arraylen(pindexes); i++) {
with (players[pindexes[i]]) {
dx = playerx + 1.5 - this.attackx;
dy = playery + 2 - this.attacky;
dist = (dx*dx + dy*dy)^0.5;
if (dist<=2)
hurtplayer();
}
if (dist>2)
break;
}
}
function hurtplayer() {
newhp = strtofloat(#s(clientr.hp)) - this.attackpower;
if (newhp<=0) {
newhp = 3;
setani dead,;
} else {
setani hurt,;
}
setstring clientr.hp,#v(newhp);
}

The script uses the function getnearestplayers(x,y,condition)
to find the near players. The function gives an array
of player indexes, starting with the index of the nearest player.
By using the script command 'with' you can then manipulate
those players directly. Instead of changing the hitpoints of
the attacker, you will so change the variables of the
victim. The function hurtplayer() is setting an animation
and updating the string variable 'clientr.hp'.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #7  
Old 05-07-2004, 11:09 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by xManiamaNx
with (getplayer(#a(pid)))
with(players[pid])
Reply With Quote
  #8  
Old 05-08-2004, 06:03 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
and getareanpcs(x,y,width,height);
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 09:21 PM.


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