Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Finding Killer (https://forums.graalonline.com/forums/showthread.php?t=87922)

sssssssssss 09-15-2009 08:22 AM

Finding Killer
 
Is there a way to find, if a player dies, who killed the player?

Crow 09-15-2009 02:42 PM

No. You will have to code something yourself.

Codein 09-15-2009 03:50 PM

Would be helpful if there was a reference to the object of the PKer passed or something D:

Gambet 09-15-2009 08:13 PM

Use triggerAction() to send the account information of the player hurting another player to the player getting hurt then whenever that player dies, simply read the account sent for the person that last hit him to read who he was killed by.

DustyPorViva 09-15-2009 08:19 PM

If you're using default? Not really. If you're persistent, you can add a weapon that duplicates default HD without the actual HD, and simply use it to detect who is hitting you.

fowlplay4 09-15-2009 09:20 PM

I was wondering this myself when I was making a Classic-Mode for Zodiac CTF.

Stefan should/could add an event on the serverside, I'd imagine this wouldn't be that hard because the server already handles the adding of player.kills + player.deaths.

function onPlayerKilled(killer_obj) { }

sssssssssss 09-16-2009 10:59 AM

I found this, and figured I could use this idea except instead of using onweaponfired, use onkeydown, keypress = "s". Although, if someone wouldnt mind helping sort through this to get to just the part that has to deal with the radius of the player, and marking who the player killed... xD

http://forums.graalonline.com/forums...ad.php?t=68271

Gambet 09-16-2009 04:12 PM

Quote:

Originally Posted by sssssssssss (Post 1523413)
I found this, and figured I could use this idea except instead of using onweaponfired, use onkeydown, keypress = "s". Although, if someone wouldnt mind helping sort through this to get to just the part that has to deal with the radius of the player, and marking who the player killed... xD

http://forums.graalonline.com/forums...ad.php?t=68271


Don't check if the player presses the 's' key, use the keydown() value just in case the player alters their default control configuration (via the F3 menu).


Also, what I said a few posts above still holds merit. Send a triggerAction() when the player swings their sword and have whoever they hit catch the action and work from there.

xXziroXx 09-16-2009 05:16 PM

Quote:

Originally Posted by Gambet (Post 1523442)
Don't check if the player presses the 's' key, use the keydown() value just in case the player alters their default control configuration (via the F3 menu).


Also, what I said a few posts above still holds merit. Send a triggerAction() when the player swings their sword and have whoever they hit catch the action and work from there.

I would rather use onKeyPressed and compare the keyname with the keyname(#) function, then running a constant timeout checking for keydown(#).

Good:
PHP Code:

function onKeyPressed(keynamekeycode)
{
  
// keyname(6) checks if the Grab button is pressed, default A on Qwerty.
  
if (keyname == keyname(6).lower()) {
    
// stuff
  
}



Bad:
PHP Code:

function onCreated()
  
setTimer(.05);

function 
onTimeOut()
{
  
// keydown(6) checks if the Grab button is pressed, default A on Qwerty.
  
if (keydown(6)) {
    
// stuff
  
}
  
setTimer(.05);



fowlplay4 09-16-2009 05:38 PM

I figure that:

PHP Code:

function onKeyPressed() {
  if (
keydown(6)) {

  }


Would suffice as well.

Crow 09-16-2009 05:53 PM

Quote:

Originally Posted by fowlplay4 (Post 1523460)
I figure that:

PHP Code:

function onKeyPressed() {
  if (
keydown(6)) {

  }


Would suffice as well.

I don't know why, but I prefer:

PHP Code:

function GraalControl.onKeyDown() {
  if (
keydown(6)) {
    ...
  }



sssssssssss 09-16-2009 07:00 PM

Quote:

Originally Posted by Gambet (Post 1523442)
Also, what I said a few posts above still holds merit. Send a triggerAction() when the player swings their sword and have whoever they hit catch the action and work from there.

Thats the problem im having, dont know how to find who hit/killed the player. Have no idea where to even start.

Admins 09-16-2009 07:02 PM

Theoretically we could add an event for it, something like onPlayerKilled or so. Right now the only way to detect would be to check if the kills increased, although that doesn't tell you who killed who.

Liberated 09-16-2009 07:03 PM

Quote:

Originally Posted by Stefan (Post 1523471)
Theoretically we could add an event for it, something like onPlayerKilled or so. Right now the only way to detect would be to check if the kills increased, although that doesn't tell you who killed who.

how does era do it then?

edit, nvm i understand thats the only way to do it inside an event.

Crow 09-16-2009 07:16 PM

Quote:

Originally Posted by Stefan (Post 1523471)
Theoretically we could add an event for it, something like onPlayerKilled or so. Right now the only way to detect would be to check if the kills increased, although that doesn't tell you who killed who.

Actually, emulating the default hit detection works as well. It won't replace the default systems though, it'll be there just to check if you hit a player, and if so, set some kind of last attacker flag on him.


Quote:

Originally Posted by Liberated (Post 1523472)
how does era do it then?

Custom system :oo:

sssssssssss 09-16-2009 07:27 PM

How do you check to see if the players kills increased? That would be sufficient for what Im doing possibly.

Also, stefan, adding an even for that would probably be very very helpful to the entire graal community.

DustyPorViva 09-16-2009 07:38 PM

Quote:

Originally Posted by Stefan (Post 1523471)
Theoretically we could add an event for it, something like onPlayerKilled or so. Right now the only way to detect would be to check if the kills increased, although that doesn't tell you who killed who.

It'd be better to pass who has last hit the player(though I'm not objecting to passing also who last killed the player).

sssssssssss 09-16-2009 07:42 PM

I would personally think if you were looking for who killed a player, better to pass through who killed it, rather than checking the hit each time to see if the player died.

DustyPorViva 09-16-2009 07:48 PM

Quote:

Originally Posted by sssssssssss (Post 1523483)
I would personally think if you were looking for who killed a player, better to pass through who killed it, rather than checking the hit each time to see if the player died.

But sometimes it'd be nice to check who hit a player. Therefor, you can kill two birds with one stone by checking when the player dies who last killed them(which undoubtfully would be the last player who hit them). Like I said though, I wouldn't be against both. Default needs more support like this.

sssssssssss 09-16-2009 09:13 PM

Quote:

Originally Posted by sssssssssss (Post 1523479)
How do you check to see if the players kills increased? That would be sufficient for what Im doing possibly.


anyone?

Crow 09-16-2009 09:26 PM

Quote:

Originally Posted by sssssssssss (Post 1523499)
anyone?

Loop?

fowlplay4 09-16-2009 11:19 PM

It's not hard to detect who you were killed by if your bow and bomb (unless you use putbomb) have custom scripts for compatibility with gmaps.

I'd imagine if you had a function to find the closest player with the sword animation within range when you the player dies, that would pretty much pinpoint the killer, but it's not a perfect detection method and could produce false positives.

I.e:

PHP Code:

//#CLIENTSIDE
function onPlayerDies() {
  
// Find closest player with sword animation
  // Other Script..



Deeek 09-17-2009 01:45 AM

Does onWasH!t() return any useful parameters?
Edit: WOW, censorship FTL

sssssssssss 09-17-2009 09:45 AM

For playerhurt, does this still apply in gs2?

Quote:

when the player is hurt then you can detect that in
scripts by doing if (playerhurt) ...
you can read the variable playerhurtpower to get
the amount of power that the player lost


new npc script variables playerhurtdx and playerhurtdy when the
player is hurt (otherwise they are 0)
Because if so, you could use a simple code in the weapon every single player has that reads if the player gets hurt and player.hearts==0, or use onPlayerDies(), then go to a
Quote:

findnearestplayer(float1, float2)
since the person who hurt the player SHOULD be closest.

Would that work? Am I correct? Or is my logic wrong?

Chompy 09-17-2009 02:31 PM

Quote:

Originally Posted by sssssssssss (Post 1523598)
since the person who hurt the player SHOULD be closest.

Would that work? Am I correct? Or is my logic wrong?

What if you get killed over range or if you are grouped by several players? (:

sssssssssss 09-17-2009 04:14 PM

Ok, well again I ask if anyone knows how to see if the players kils increase? Wouldn't even know what variable to use for that.

Mark Sir Link 09-17-2009 06:02 PM

Quote:

Originally Posted by sssssssssss (Post 1523639)
Ok, well again I ask if anyone knows how to see if the players kils increase? Wouldn't even know what variable to use for that.

player.kills

you could shove it in a timeout in the clientside and send a triggeraction to the server whenever it increases, but it seems messy and likely to fail to me.

sssssssssss 09-19-2009 02:46 AM

onPlayerDies() is only clientside correct? or can it be serverside?

fowlplay4 09-19-2009 03:05 AM

Quote:

Originally Posted by sssssssssss (Post 1523848)
onPlayerDies() is only clientside correct? or can it be serverside?

Try it and find out :P

sssssssssss 09-19-2009 05:59 AM

detects clientside :)


All times are GMT +2. The time now is 04:18 AM.

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