I've had a looked around but I can't find the variable that the reason of death is store under (for pve death, eg Cold, Bear, Suicide, Wolf etc)
Using the OnEntityDeath hook
Anyone able to provide the insight, not too shabby with my c# and had a look at wulfs Death Notes, but it's a little convoluted as it's entirely split up into classes and I can't track down where the reason gets set
Getting reason/cause of death?
Discussion in 'Rust Development' started by Zanderwar, Feb 5, 2017.
-
Wulf Community Admin
DeathNotes isn't my plugin.
You can get the attacker and such from Rust's HitInfo that is one of the arguments for the hook. If you'd like to see what HitInfo is, you can open up Rust's Assembly-CSharp.dll in a .NET decompiler such as JustDecompile. -
its in the hitinfo
Code:private void OnEntityDeath(BaseCombatEntity basecombatentity, HitInfo hitinfo) { Rust.DamageType dmg = hitinfo.damageTypes.GetMajorityDamageType(); }
-
-
Well if its a player or animal that did the killing you could go about it like this
Code:private void OnEntityDeath(BaseCombatEntity basecombatentity, HitInfo hitinfo) { string AttackerName = ""; try { AttackerName = hitinfo.Initiator.ToPlayer().displayName; // attacker is player } catch { } if (AttackerName == "") { try { Dictionary<string, string> AnimalTypes = new Dictionary<string, string>(); AnimalTypes.Add("bear", "Bear"); AnimalTypes.Add("boar", "Boar"); AnimalTypes.Add("chicken", "Chicken"); AnimalTypes.Add("horse", "Horse"); AnimalTypes.Add("stag", "Stag"); AnimalTypes.Add("wolf", "Wolf"); if (AnimalTypes.ContainsKey(hitinfo.Initiator.ShortPrefabName)) { AttackerName = AnimalTypes[hitinfo.Initiator.ShortPrefabName]; // attacker is known animal } } catch { } } }