Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Detecting if a player has been hit by another player? (https://forums.graalonline.com/forums/showthread.php?t=134267312)

Emera 10-29-2012 07:15 PM

Detecting if a player has been hit by another player?
 
Hey. Is there a function to check if a player has been hit by another player's sword? I can't seem to find one of the forums or on the wiki.

xAndrewx 10-30-2012 08:03 PM

function onWasHit isn't it? I've not done classic systems for a while

Crow 10-30-2012 08:14 PM

Last time I tried, onWasHit() does not work on GMAPs.

Emera 10-30-2012 08:50 PM

onWasHit() doesn't do it :(

DustyPorViva 10-30-2012 08:55 PM

Pretty sure there is a serverside function like onplayerhurt() that now returns who/what hurt the player. I just don't know the exact name.

callimuc 10-30-2012 09:52 PM

i think player.hurted returns a boolean if the player has been hurt or not

Crono 10-30-2012 11:23 PM

sounds pretty easy to do if it does't already exist! i also thought it was the "onwaShit" function. :cool:

ffcmike 11-01-2012 07:39 PM

If you didn't find a Clientside solution yet and onWasHit is being invoked by all forms of damage, you could try:

PHP Code:

function onWasHit(){
  
//receive original x and y from before first frame of recoil movement
  
temp.player.player.hurtdx;
  
temp.player.player.hurtdy;
  
temp.plist findnearestplayers(temp.xtemp.y);
  for(
temp.pl temp.plist){
    if(
temp.pl.ani.name == "sword"){
      
temp.bx temp.pl.0.5 + (vecx(temp.pl.dir) * 2);
      
temp.by temp.pl.+ (vecy(temp.pl.dir) * 2);
      if(
        
temp.0.5 <= temp.bx &&
        
temp.2.5 >= temp.bx &&
        
temp.<= temp.by &&
        
temp.>= temp.by
      
){
        
this.playerSlashed(temp.pl);
        return;
      }
    }
  }




All times are GMT +2. The time now is 03:39 AM.

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