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 03-17-2001, 10:17 PM
Fai Fai is offline
!!!!!!!!!!!!!!!!!!!!!!!!!
Fai's Avatar
Join Date: Mar 2001
Location: New York
Posts: 4,491
Fai will become famous soon enough
Send a message via ICQ to Fai Send a message via AIM to Fai
I've spent hours trying to figure this out......

HOW DO YOU GET HITPLAYER(ORWHATVER) TO HIT ANYONE WHO IS IN THAT SPOT?!
__________________
SIGNATURE
Reply With Quote
  #2  
Old 03-18-2001, 07:23 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
-. .`

I'm gonna assume you want it to hit any player in a certain range around a point...

NPC Code:

if (whatever starts code) {
this.fromx = #;
this.fromy = #;
this.hitx = #;
this.hity = #;
this.hitradius = #;
this.hitpower = #;
for (this.p = playerscount-1; this.p > 0; this.p--) {
if ((((players[this.p].x + 1.5 - this.hitx)^2 - (players[this.p].y + 1.5 - this.hity)^2)^.5) <= this.hitradius) {
hitplayer this.p, this.hitpower, this.fromx, this.fromy;
}
}
}



basic pathagorean theorem for ya (a^2 + b^2 = C^2), or, in this case, (((a^2 + b^2)^.5) = c). Taking something to the power of .5 will find the square root, just in case you didn't know.

this.fromx/this.fromy - This is where the player will be hit back from. If it's a weapon the player fires, I'd suggest using the player that fired it as this.fromx and this.fromy. You may have arrows or spells though that do different. Maybe even a monster
this.hitx/this.hity/this.hitradius - This is where you are checking for a player. It will check with the center at (this.hitx, this.hity), and check if a player's center is within this.hitradius.
this.hitpower - how many halfhearts you want to take off the player. A hit power of 2 would take off 1 full heart.


Now, if you wanted to check within a box...

NPC Code:

if (whatever starts code) {
this.fromx = #;
this.fromy = #;
this.hitx = #;
this.hity = #;
this.hitwidth = #;
this.hitheight = #;
this.hitpower = #;
for (this.p = playerscount-1; this.p > 0; this.p--) {
if (players[this.p].x in |this.hitx, this.hitx+this.hitwidth| && players[this.p].y in |this.hity, this.hity+this.hitheight|) {
hitplayer this.p, this.hitpower, this.fromx, this.fromy;
}
}
}



Only difference is that it checks within a box, and that box checks for the player's top left to be in that box. this.hitwidth and this.hitheight define how big the box is that it should check for a player within.

Please excuse me if this isn't completely perfect, I don't really want to go testin' the scripts right now.
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 01:04 PM.


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