Add PlayerDamage hook
This commit is contained in:
parent
439efac901
commit
45bf75c7b7
1 changed files with 30 additions and 0 deletions
|
|
@ -549,6 +549,33 @@ namespace TShockAPI
|
|||
return args.Handled;
|
||||
}
|
||||
|
||||
public class PlayerDamageEventArgs : HandledEventArgs
|
||||
{
|
||||
public byte ID { get; set; }
|
||||
public byte Direction { get; set; }
|
||||
public short Damage { get; set; }
|
||||
public byte PVP { get; set; }
|
||||
public byte Critical { get; set; }
|
||||
}
|
||||
public static HandlerList<PlayerDamageEventArgs> PlayerDamage;
|
||||
|
||||
private static bool OnPlayerDamage(byte id, byte dir, short dmg, byte pvp, byte crit)
|
||||
{
|
||||
if (PlayerDamage == null)
|
||||
return false;
|
||||
|
||||
var args = new PlayerDamageEventArgs
|
||||
{
|
||||
ID = id,
|
||||
Direction = dir,
|
||||
Damage = dmg,
|
||||
PVP = pvp,
|
||||
Critical = crit,
|
||||
};
|
||||
PlayerDamage.Invoke(null, args);
|
||||
return args.Handled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
public static void InitGetDataHandler()
|
||||
{
|
||||
|
|
@ -1902,6 +1929,9 @@ namespace TShockAPI
|
|||
var pvp = args.Data.ReadInt8();
|
||||
var crit = args.Data.ReadInt8();
|
||||
|
||||
if (OnPlayerDamage(id, direction, dmg, pvp, crit))
|
||||
return true;
|
||||
|
||||
int textlength = (int) (args.Data.Length - args.Data.Position - 1);
|
||||
string deathtext = "";
|
||||
if (textlength > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue