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 04-06-2011, 04:41 AM
skillmaster19 skillmaster19 is offline
Registered User
Join Date: Oct 2010
Posts: 392
skillmaster19 will become famous soon enough
player to player interaction

How would I make it so the actions of one player trigger someone elses? For example if a player fires a weapon all players within a 8x4 area of the players direction are effected.(like being hit by a sword).

Another example would be a slap item that causes the player next to the player that uses the weapon to say "owww, that hurt!" I understand there are projectile functions, but I want to know the best way to immediatly effect the players within a certain area.
Reply With Quote
  #2  
Old 04-06-2011, 04:51 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
I am not sure if there is an equivalent of getareanpcs( x,y,width,height ) to get players. One way to accomplish what you want is to loop through the players object. Test each player's coordinates to determine whether they are inside your rectangle.
Reply With Quote
  #3  
Old 04-06-2011, 05:36 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
PHP Code:
for ( temp.0temp.allPlayerscounttemp.++;)
{

//Use if to check player coords with players[ temp.p]


__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #4  
Old 04-06-2011, 05:41 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
I imagine you ask for the slap example because of UN's, the way UN's works is by using a triggeraction. The other player then receives the triggeraction and handles it to change ani
Reply With Quote
  #5  
Old 04-06-2011, 05:44 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 MrOmega View Post
PHP Code:
for ( temp.0temp.allPlayerscounttemp.++;)
{

//Use if to check player coords with players[ temp.p]


If you're using allplayerscount, then you need to use allplayers, not players.

You should also use allplayers.size() rather than allplayerscount as it makes no sense to use the latter.

I would recommend using a foreach loop.

PHP Code:
function hitPlayers(xyradius) {
  for (
temp.pl findNearestPlayers(xy)) {
    if (
getDistance(pl.xpl.yxy) < radius && pl != player) {
      
pl.chat "I was hit!";
    }
  }
}

function 
getDistance(x1y1x2y2) {
  return (((
x1 x2) ^ 0.5) + ((y1 y2) ^ 0.5)) ^ 2;

This should work, haven't tested it though.
__________________

Last edited by cbk1994; 04-06-2011 at 09:05 PM..
Reply With Quote
  #6  
Old 04-06-2011, 08:45 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
tirggeraction sounds about right
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #7  
Old 04-06-2011, 08:52 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Deas_Voice View Post
tirggeraction sounds about right
To cover an 8x4 section of tiles. Hell no.

Best plan of action would be to...

1. Loop through the players on clientside and check if they're in the '8x4' section
2. Send the list of players in the section to the server-side
3. Double-check that they're in the square (perhaps with some leniency)
4. Triggerclient each person in the square, or even just change their animation and chat if that's all that's necessary.

It looks like this:

PHP Code:
function onActionServerSide() {
  if (
params[0] == "hitpeople") {
    
// Do the same check up here, or maybe even a radius check like cbk suggested.
    
for (temp.plplayers) {
      if (
temp.pl.x in |tx,tx+dw| && temp.pl.y in |ty,ty+dh|) {
        
temp.pl.chat "Ow!";
        
temp.pl.setani("hurt""");
      }
    }
  }
}

//#CLIENTSIDE
function hitPeople() {
  
// Determine the 8x4 Section
  // tx = topleft x
  // ty = topleft y
  // dw = width of section
  // dh = height of section
  // Find Players
  
for (temp.plplayers) {
    
// Check if Player is in Section
    
if (temp.pl.x in |tx,tx+dw| && temp.pl.y in |ty,ty+dh|) {
      
// Add Account to the List of those being Hit
      
temp.hitting.add(temp.pl.account);
    }
  }
  
// Check if Hitting Anyone
  
if (temp.hitting.size() > 0) {
    
// Trigger the server
    
triggerserver("gui"this.name"hitpeople"temp.hitting);
  }

__________________
Quote:

Last edited by fowlplay4; 04-06-2011 at 09:04 PM..
Reply With Quote
  #8  
Old 04-06-2011, 08:57 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by fowlplay4 View Post
To cover an 8x4 section of tiles. Hell no.

Best plan of action would be to...

1. Loop through the players on clientside and check if they're in the '8x4' section
2. Send the list of players in the section to the server-side
3. Double-check that they're in the square (perhaps with some leniency)
4. Triggerclient each person in the square, or even just change their animation and chat if that's all that's necessary.
ouch, didn't read too well. saw "oww, that hurts" and the word "slap".

your right, i'm sorry.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
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 12:18 PM.


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