private void OnEntityDeath(EntityDeathEvent deathEvent) { if (deathEvent.Entity.Owner == Boss1) { Boss1 = null; BossDeath(); return; } if (deathEvent.Entity.Owner == Boss2) { Boss2 = null; BossDeath(); return; } if (deathEvent.Entity.Owner == Boss3) { Boss3 = null; BossDeath(); return; } if (deathEvent.Entity.Owner == Boss4) { Boss4 = null; BossDeath(); return; } if (deathEvent.Entity.Owner == Boss5) { Boss5 = null; BossDeath(); return; } }
private void OnEntityDeath(EntityDeathEvent e) { if (e.Entity == null || e.KillingDamage.DamageSource == null || e == null) { return; } ulong victimid = e.Entity.OwnerId; ulong attackerid = e.KillingDamage.DamageSource.OwnerId; if (data.Kills.ContainsKey(attackerid)) { data.Kills[attackerid] = data.Kills[attackerid] + 1; } else { data.Kills.Add(attackerid, 1); } if (data.Deaths.ContainsKey(victimid)) { data.Deaths[victimid] = data.Deaths[victimid] + 1; } else { data.Deaths.Add(victimid, 1); } SaveData(); }
private void OnEntityDeath(EntityDeathEvent e) { HookCalled("OnEntityDeath"); Puts(e.KillingDamage != null ? $"{e.Entity} was killed by {e.KillingDamage?.DamageSource} ({e.KillingDamage?.DamageTypes})" : $"{e.Entity} died."); }
private void OnEntityDeath(EntityDeathEvent e) { if (LogEntities == false) { return; } string str = ""; string entityPosition = e.Entity.Position.x + "," + e.Entity.Position.y + "," + e.Entity.Position.x; if (e.KillingDamage != null) { if (e.KillingDamage.DamageSource.IsPlayer) { str += e.KillingDamage.DamageSource.Owner.Name; } else if (IsEntityAnimal(e.KillingDamage.DamageSource)) { str += e.KillingDamage.DamageSource.name; } else if (e.Entity.IsPlayer) { str += e.Entity.Owner.DisplayName; } if (e.Entity.IsPlayer && !e.Entity.IsPlayer) { str += " has killed " + e.Entity.Owner.Name; } else if (IsAnimal(e)) { str += " has killed " + e.Entity.name; } else { str += " has killed himself"; } str += " [" + e.KillingDamage.DamageTypes + "," + e.KillingDamage.Amount + "] with a " + e.KillingDamage.Damager.name + " at [" + entityPosition + "]."; Log("Entities", str); } else { if (e.Entity.IsPlayer) { str += e.Entity.Owner.Name + " has died."; } else if (IsAnimal(e)) { str += e.Entity.name + " has died."; } else { str += e.Entity.name + " has been destroyed."; } Log("Entities", str); } }
private void OnEntityDeath(EntityDeathEvent deathEvent) { if (deathEvent.Entity.IsPlayer) { string killer = "[00FF00]" + deathEvent.KillingDamage.DamageSource.Owner.DisplayName; string message = "[FFFFFF]SERVER: [FF0000]" + deathEvent.Entity.Owner.DisplayName + " [FFFFFF]was killed by " + killer; PrintToChat(message); } }
/// <summary> /// Instantly kills the BattleEntity /// </summary> public void Kill() { CurHP = 0; ClearAllStatuses(); ClearStatModifiers(); InterruptCommand(); EntityDeathEvent?.Invoke(this); Debug.Log($"{Name} has fallen in battle!"); }
public void OnEntityDeath(EntityDeathEvent ev) { foreach (var player in ev.Entity.GetPlayersNear()) { player.Tcp.Send(new EntityDeathPacket() { EntityUID = ev.Entity.UID }); } ev.Entity.Die(); }
void OnEntityDeath(EntityDeathEvent e) { if (e.Entity == null || e.KillingDamage.DamageSource == null || e == null || e.Entity.IsPlayer == false || e.KillingDamage.DamageSource.Owner.IsServer || e.Entity.Owner.IsServer || e.KillingDamage.DamageSource.Owner == null) { return; } foreach (string dmgt in DamageT) { if (e.KillingDamage.DamageTypes.ToString() == dmgt) { PrintToChat($"{e.KillingDamage.DamageSource.Owner.DisplayName} killed {e.Entity.Owner.DisplayName}"); } } }
public void OnEntityDeath(EntityDeathEvent ev) { foreach (var player in ev.Entity.GetPlayersNear()) { player.Tcp.Send(new EntityDeathPacket() { EntityUID = ev.Entity.UID }); } Server.Map.UpdateEntityPosition(ev.Entity, from: ev.Entity.Position, to: null); if (ev.Entity.EntityType == EntityType.MONSTER) { Server.Map.Monsters.Remove(ev.Entity.UID); var monster = (Monster)ev.Entity; monster.OriginSpawner.CreateSpawnTask(); } }
// THIS CONTROLS WHEN A PLAYER IS KILLED private void OnEntityDeath(EntityDeathEvent deathEvent) { if (deathEvent.Entity.IsPlayer) { var killer = deathEvent.KillingDamage.DamageSource.Owner; var player = deathEvent.Entity.Owner; // Check for bounties var reward = GetBountyOnPlayer(player); if (reward.Count < 1) { return; } // Make sure the player is not in the same guild if (player.GetGuild().Name == killer.GetGuild().Name) { PrintToChat("[FF0000]Assassin's Guild[FFFFFF] : [00FF00]" + player.DisplayName + "[FFFFFF] was slain by a member of the same guild, so no bounty was collected!"); return; } // Get the inventory var inventory = killer.GetInventory(); // Give the rewards to the player foreach (var bounty in reward) { var resource = bounty[0]; var amount = Int32.Parse(bounty[1]); PrintToChat("Reward = " + resource + " " + amount.ToString()); // Create a blueprint var blueprintForName = InvDefinitions.Instance.Blueprints.GetBlueprintForName(resource, true, true); // Create item stack var invGameItemStack = new InvGameItemStack(blueprintForName, amount, null); // Add the reward to the inventory ItemCollection.AutoMergeAdd(inventory.Contents, invGameItemStack); } // Notify everyone PrintToChat("[FF0000]Assassin's Guild[FFFFFF] : [00FF00]" + killer.DisplayName + "[FFFFFF] has ended [FF00FF]" + player.DisplayName + "[FFFFFF]'s life and has secured the bounty on their head!"); } }
void OnEntityDeath(EntityDeathEvent Event) { if (!Event.Entity.IsPlayer || !Event.KillingDamage.DamageSource.IsPlayer) return; string killer = Event.KillingDamage.DamageSource.Owner.Id; string verifyQuery = $"SELECT victim FROM kills WHERE killer={killer} AND victim={victim}"; sqlLibrary.Query(verifyQuery, sqlConnection, list => { if (list == null) { // Reward Player sqlLibrary.Query(verifyQuery, sqlConnection, list => { } } else { // Player already killed. } }); }
private void OnEntityDeath(EntityDeathEvent e) { HookCalled("OnEntityDeath"); if (e.KillingDamage != null) Puts($"{e.Entity} was killed by {e.KillingDamage?.DamageSource} ({e.KillingDamage?.DamageTypes})"); else Puts($"{e.Entity} died."); }
private void OnEntityDeath(EntityDeathEvent deathEvent) { #region Null checks if (deathEvent == null) { return; } if (deathEvent.Entity == null) { return; } if (!deathEvent.Entity.IsPlayer) { return; } if (deathEvent.KillingDamage == null) { return; } if (deathEvent.KillingDamage.DamageSource == null) { return; } if (!deathEvent.KillingDamage.DamageSource.IsPlayer) { return; } #endregion var victim = deathEvent.Entity.Owner; var killer = deathEvent.KillingDamage.DamageSource.Owner; var boss = GetBoss(victim); if (boss == null) { return; } BossList.Remove(boss.Id); PrintToChat(GetMessage("Boss killed")); CheckAllBossesAreGone(); if (!BossGold) { return; } if (victim.Equals(killer)) { return; } if (boss.GoldReward <= 0) { return; } if (!GuildBossGold && victim.GetGuild().Equals(killer.GetGuild())) { killer.SendError(GetMessage("Guild member kill", killer)); return; } if (GrandExchange == null) { return; } GrandExchange.Call("GiveGold", killer, boss.GoldReward); killer.SendMessage(GetMessage("Gold gained", killer), boss.GoldReward); }
// Give credits when a player is killed private void OnEntityDeath(EntityDeathEvent deathEvent) { if (deathEvent.Entity == null) { return; } if (deathEvent.Entity.Owner == null) { return; } if (deathEvent.Entity.Owner.Name == "server") { return; } if (deathEvent.KillingDamage.DamageSource.IsPlayer) { if (deathEvent.KillingDamage == null) { Log("deathEvent.KillingDamage was null here!"); return; } if (deathEvent.KillingDamage.DamageSource == null) { Log("deathEvent.KillingDamage.DamageSource was null here!"); return; } if (deathEvent.KillingDamage.DamageSource.Owner == null) { Log("deathEvent.Damage.DamageSource.Owner was null here!"); return; } var player = deathEvent.KillingDamage.DamageSource.Owner; if (player == null) { Log("player variable was null here!"); return; } var entity = deathEvent.Entity; if (entity == null) { Log("entity variable was null here!"); return; } if (!deathEvent.Entity.IsPlayer) { if (_allowPveXp) { Health h = entity.TryGet <Health>(); if (h.ToString().Contains("Trebuchet")) { return; } if (h.ToString().Contains("Ballista")) { return; } bool villager = h.ToString().Contains("Plague Villager"); bool bear = h.ToString().Contains("Grizzly Bear"); bool wolf = h.ToString().Contains("Wolf"); bool werewolf = h.ToString().Contains("Werewolf"); bool babyChicken = h.ToString().Contains("Baby Chicken"); bool bat = h.ToString().Contains("Bat"); bool chicken = h.ToString().Contains("Chicken"); bool crab = h.ToString().Contains("Crab"); bool crow = h.ToString().Contains("Crow"); bool deer = h.ToString().Contains("Deer"); bool duck = h.ToString().Contains("Duck"); bool moose = h.ToString().Contains("Moose"); bool pigeon = h.ToString().Contains("Pigeon"); bool rabbit = h.ToString().Contains("Rabbit"); bool rooster = h.ToString().Contains("Rooster"); bool seagull = h.ToString().Contains("Seagull"); bool sheep = h.ToString().Contains("Sheep"); bool stag = h.ToString().Contains("Stag"); int XpAmount = 0; if (villager || bear || wolf || werewolf) { XpAmount = _random.Next(monsterKillMinXp, (monsterKillMaxXp + 1)); } if (babyChicken || bat || chicken || crab || crow || deer || duck || moose || pigeon || rabbit || rooster || seagull || sheep || stag) { XpAmount = _random.Next(animalKillMinXp, (animalKillMaxXp + 1)); } if (!(villager || bear || wolf || werewolf || babyChicken || bat || chicken || crab || crow || deer || duck || moose || pigeon || rabbit || rooster || seagull || sheep || stag)) { return; } int playerLvl = GetCurrentLevel(player); GiveXp(player, XpAmount); if (_playerXp[player.ToString()] < MaxPossibleXp) { PrintToChat(player, String.Format(GetMessage("CollectedXp", player.Id.ToString()), XpAmount)); } if (GetCurrentLevel(player) > playerLvl) { PrintToChat(player, String.Format(GetMessage("LevelUp", player.Id.ToString()), GetCurrentLevel(player))); } } } else { if (_allowPvpXp) { var victim = deathEvent.Entity.Owner; if (victim == null) { Log("Victim variable was null here!"); return; } if (victim.Id == 0 || player.Id == 0) { Log("Victim or Player had no id!"); return; } // Make sure player didn't kill themselves if (victim == player) { return; } if (victim.GetGuild() == null || player.GetGuild() == null) { Log("The victim or the player guild was null here!"); return; } // Make sure the player is not in the same guild if (victim.GetGuild().Name == player.GetGuild().Name) { PrintToChat(player, GetMessage("KilledGuildMember", player.Id.ToString())); return; } // Check victims wallet CheckPlayerExcists(victim); // Check the player has a wallet CheckPlayerExcists(player); // Give the rewards to the player int lvlVictim = GetCurrentLevel(victim); int lvlPlayer = GetCurrentLevel(player); int lvlDiff = lvlPlayer - lvlVictim; int xpGain = _random.Next(pvpGetMinXp, (pvpGetMaxXp + 1)); int xpLoss = _random.Next(pvpLoseMinXp, (pvpLoseMaxXp + 1)); double xpLvlLoss = (100 - (pvpXpLoss * lvlDiff)); if (xpLvlLoss < 0) { xpLvlLoss = 0; } else if (xpLvlLoss > 100) { xpLvlLoss = 100; } xpLvlLoss = xpLvlLoss / 100; xpGain = Convert.ToInt32(Convert.ToDouble(xpGain) * xpLvlLoss); xpLoss = Convert.ToInt32(Convert.ToDouble(xpLoss) * xpLvlLoss); GiveXp(player, xpGain); RemoveXp(victim, xpLoss); PrintToChat(player, String.Format(GetMessage("CollectedXp", player.Id.ToString()), xpGain)); PrintToChat(victim, String.Format(GetMessage("LostXp", player.Id.ToString()), xpLoss)); if (GetCurrentLevel(player) > lvlPlayer) { PrintToChat(player, String.Format(GetMessage("LevelUp", player.Id.ToString()), GetCurrentLevel(player))); } if (GetCurrentLevel(victim) < lvlVictim) { PrintToChat(victim, String.Format(GetMessage("LevelDown", player.Id.ToString()), GetCurrentLevel(victim))); } } } } //Save the data SaveXpData(); }
void OnEntityDeath(EntityDeathEvent Event) { if (!Event.Entity.IsPlayer) { return; } #region Data var DamageType = Event.KillingDamage.DamageTypes.ToString(); var DamageAmount = Event.KillingDamage.Amount.ToString(); var HitBox = Event.KillingDamage.HitBoxBone.ToString(); string Victim = Event.Entity.Owner.DisplayName; string Type = Event.KillingDamage.DamageTypes.ToString(); string Amount = ($"{DamageAmount} damage"); string Location = ($"{HitBox}"); #endregion #region DeathLocations string posX = Event.Entity.Position.x + ""; int indexX = posX.IndexOf("."); if (indexX > 0) { posX = posX.Substring(0, indexX); } string posZ = Event.Entity.Position.z + ""; int indexZ = posZ.IndexOf("."); if (indexZ > 0) { posZ = posZ.Substring(0, indexZ); } string Pos = ($"[{posX} , {posZ}]"); #endregion foreach (var player in covalence.Players.Connected) { #region DamageTypes if (DamageType.Contains("Impact")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } if (DamageType.Contains("Falling")) { return; } if (DamageType.Contains("Fire")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } if (DamageType.Contains("Drowning")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } if (DamageType.Contains("Plague")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } if (DamageType.Contains("Hunger")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } if (DamageType.Contains("Thirst")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } if (DamageType.Contains("Unknown")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } if (DamageType.Contains("OutOfBounds")) { PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos); return; } #endregion #region Main bool Server = Event.KillingDamage.DamageSource.Owner.IsServer; bool Player = Event.KillingDamage.DamageSource.IsPlayer; if (Player) { string Killer = Event.KillingDamage.DamageSource.Owner.DisplayName; string Damager = Event.KillingDamage.Damager.name; string Weapon = Damager.Replace("[Entity]", ""); PrintToChat(lang.GetMessage("DamageMessage", this, player.Id), Killer, Victim, Pos); PrintToChat(lang.GetMessage("DamageDetails", this, player.Id), Amount, Location, Weapon); return; } if (Server) { string Damage = Event.KillingDamage.DamageSource.name; string DamagerServer = Damage.Replace("[Entity]", ""); PrintToChat(lang.GetMessage("DamageServer", this, player.Id), Victim, DamagerServer, Pos); PrintToChat(lang.GetMessage("ShortDmgDetails", this, player.Id), Amount, Location); return; } #endregion } }