![]() |
Need Help - Detection
I was wondering if there was anyway to detect if a moving NPC touches a player, or is a certain distance from a player so that the NPC can carry out something.
ie. A moving NPC touches the player and their health is reduced. If anyone could guide me towards how you would go about doing this it would be appreciated. :) |
if (playertouchsme) ?
or loop through every player using distance formula to check if they're within a distance. Distance formula: D=((x1-x2)^2 + (y1-y2)^2)^(1/2) where (x1,y1),(x2,y2) are the coordinates of the two objects (this case npc and player) |
if (playertouchsme) only triggers when the obvious happens: the player touches the NPC, not the other way around. To do what you're wanting, you would need to have a timeout constantly check the distance of the player from the NPC, as was already mentioned. However, use 0.5 at the end of that formula rather than (1/2). There's no need for extra calculation there.
|
Quote:
|
Quote:
testplayer(x,y)? where x and y are the coordinates of the npc? |
Serverside scripting functions:
NPC Code: or NPC Code: |
Hehe, I didn't know there was a getnearestplayers ;-)
cool |
Quote:
|
Quote:
|
Quote:
|
Quote:
|
I thought we weren't allowed to post full scripts ? Bad stefan. Bad boy.
|
Quote:
|
Quote:
yes I made that word up, it's a very good word if I may add *gets back to updating commands.rtf* ... *wonders if anyone cares about the updated commands.rtf* |
Oh dear god i do.
Add getnearestplayers, command wench. |
All times are GMT +2. The time now is 09:52 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.