Exemple #1
0
 public static void ZoneCheck(ClientInfo _cInfo, EntityAlive _player)
 {
     if (Box1.Count > 0)
     {
         for (int i = 0; i < Box1.Count; i++)
         {
             string[] _box1 = Box1[i];
             bool[]   _box2 = Box2[i];
             if (BoxCheck(_box1, _player.position.x, _player.position.y, _player.position.z, _box2))
             {
                 if (ZoneExit.ContainsKey(_player.entityId))
                 {
                     string _exitMsg;
                     if (ZoneExit.TryGetValue(_player.entityId, out _exitMsg))
                     {
                         if (_exitMsg != _box1[3])
                         {
                             if (Zone_Message)
                             {
                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _box1[2] + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                             }
                             if (_box1[4] != "")
                             {
                                 Response(_cInfo, _box1[4]);
                             }
                             ZoneExit[_player.entityId]    = _box1[3];
                             reminder[_player.entityId]    = DateTime.Now;
                             reminderMsg[_player.entityId] = _box1[5];
                         }
                     }
                 }
                 else
                 {
                     if (Zone_Message)
                     {
                         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _box1[2] + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                     if (_box1[4] != "")
                     {
                         Response(_cInfo, _box1[4]);
                     }
                     ZoneExit.Add(_player.entityId, _box1[3]);
                     reminder.Add(_player.entityId, DateTime.Now);
                     reminderMsg.Add(_player.entityId, _box1[5]);
                 }
                 if (_box2[1])
                 {
                     if (!ZonePvE.Contains(_player.entityId))
                     {
                         ZonePvE.Add(_player.entityId);
                     }
                 }
                 else if (ZonePvE.Contains(_player.entityId))
                 {
                     ZonePvE.Remove(_player.entityId);
                 }
                 return;
             }
         }
         if (ZoneExit.ContainsKey(_player.entityId))
         {
             if (Zone_Message)
             {
                 string _msg;
                 if (ZoneExit.TryGetValue(_player.entityId, out _msg))
                 {
                     if (_msg != "")
                     {
                         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _msg + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
             ZoneExit.Remove(_player.entityId);
             reminder.Remove(_player.entityId);
             reminderMsg.Remove(_player.entityId);
             if (ZonePvE.Contains(_player.entityId))
             {
                 ZonePvE.Remove(_player.entityId);
             }
         }
     }
     if (Lobby.IsEnabled && Lobby.LobbyPlayers.Contains(_cInfo.entityId) && !Lobby.InsideLobby(_player.position.x, _player.position.z))
     {
         Lobby.LobbyPlayers.Remove(_cInfo.entityId);
         if (Lobby.Return)
         {
             PersistentContainer.Instance.Players[_cInfo.playerId].LobbyReturnPos = "";
             PersistentContainer.Instance.Save();
             string _phrase556;
             if (!Phrases.Dict.TryGetValue(556, out _phrase556))
             {
                 _phrase556 = " you have left the lobby space. {PrivateCommand}{Command53} command is no longer available.";
                 _phrase556 = _phrase556.Replace("{PrivateCommand}", ChatHook.Command_Private);
                 _phrase556 = _phrase556.Replace("{Command53}", ChatHook.Command_Private);
             }
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase556 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     if (Market.IsEnabled && Market.MarketPlayers.Contains(_cInfo.entityId) && !Market.InsideMarket(_player.position.x, _player.position.z))
     {
         Market.MarketPlayers.Remove(_cInfo.entityId);
         if (Market.Return)
         {
             PersistentContainer.Instance.Players[_cInfo.playerId].MarketReturnPos = "";
             PersistentContainer.Instance.Save();
             string _phrase564;
             if (!Phrases.Dict.TryGetValue(564, out _phrase564))
             {
                 _phrase564 = " you have left the market space. {PrivateCommand}{Command51} command is no longer available.";
                 _phrase564 = _phrase564.Replace("{PrivateCommand}", ChatHook.Command_Private);
                 _phrase564 = _phrase564.Replace("{Command51}", ChatHook.Command_Private);
             }
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase564 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
 }
Exemple #2
0
 public static bool Exec(NetPackageDamageEntity __instance)
 {
     try
     {
         Entity victim = PersistentOperations.GetEntity(entityId(__instance));
         if (victim != null)
         {
             Entity attacker = PersistentOperations.GetEntity(attackerEntityId(__instance));
             if (attacker != null)
             {
                 if (victim is EntityPlayer)
                 {
                     ClientInfo cInfoVictim = PersistentOperations.GetClientInfoFromEntityId(victim.entityId);
                     if (cInfoVictim != null)
                     {
                         EntityPlayer victimPlayer = victim as EntityPlayer;
                         if (attacker is EntityPlayer)
                         {
                             ClientInfo cInfoAttacker = PersistentOperations.GetClientInfoFromEntityId(attacker.entityId);
                             if (cInfoAttacker != null)
                             {
                                 EntityPlayer attackingPlayer = attacker as EntityPlayer;
                                 if (attackingItem(__instance) != null)
                                 {
                                     if (DamageDetector.IsEnabled && !DamageDetector.IsValidPvP(victim as EntityPlayer, cInfoAttacker, strength(__instance), attackingItem(__instance)))
                                     {
                                         return(true);
                                     }
                                     if (InfiniteAmmo.IsEnabled && attackingItem(__instance).ItemClass.IsGun())
                                     {
                                         int slot = attackingPlayer.inventory.holdingItemIdx;
                                         if (InfiniteAmmo.Exec(cInfoAttacker, attackingPlayer, slot, attackingItem(__instance)))
                                         {
                                             return(true);
                                         }
                                     }
                                 }
                                 else
                                 {
                                     return(true);
                                 }
                                 if (NewPlayerProtection.IsEnabled)
                                 {
                                     if (NewPlayerProtection.IsProtected(victimPlayer))
                                     {
                                         Phrases.Dict.TryGetValue("NewPlayerProtection2", out string phrase);
                                         ChatHook.ChatMessage(cInfoAttacker, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                         return(true);
                                     }
                                     else if (NewPlayerProtection.IsProtected(attackingPlayer))
                                     {
                                         Phrases.Dict.TryGetValue("NewPlayerProtection1", out string phrase);
                                         ChatHook.ChatMessage(cInfoVictim, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                         return(true);
                                     }
                                 }
                                 //if (Zones.IsEnabled && !Zones.IsValid(cInfoVictim, cInfoAttacker))
                                 //{
                                 //    return true;
                                 //}
                                 if (Lobby.IsEnabled && Lobby.PvE && (Lobby.LobbyPlayers.Contains(victimPlayer.entityId) || Lobby.LobbyPlayers.Contains(attackingPlayer.entityId)))
                                 {
                                     Lobby.PvEViolation(cInfoAttacker);
                                     return(true);
                                 }
                                 if (Market.IsEnabled && Market.PvE && (Market.MarketPlayers.Contains(victimPlayer.entityId) || Market.MarketPlayers.Contains(attackingPlayer.entityId)))
                                 {
                                     Market.PvEViolation(cInfoAttacker);
                                     return(true);
                                 }
                                 float distance = attackingPlayer.GetDistance(victimPlayer);
                                 using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8))
                                 {
                                     sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' @ '{4}' hit '{5}' '{6}' named '{7}' @ '{8}' using '{9}' for '{10}' damage. Distance '{11}'", DateTime.Now, cInfoAttacker.PlatformId.CombinedString, cInfoAttacker.CrossplatformId.CombinedString, cInfoAttacker.playerName, cInfoAttacker.latestPlayerData.ecd.pos, cInfoVictim.PlatformId.CombinedString, cInfoVictim.CrossplatformId.CombinedString, cInfoVictim.playerName, cInfoVictim.latestPlayerData.ecd.pos, attackingItem(__instance).ItemClass.GetLocalizedItemName() ?? attackingItem(__instance).ItemClass.GetItemName(), strength(__instance), distance));
                                     sw.WriteLine();
                                     sw.Flush();
                                     sw.Close();
                                 }
                                 if (bFatal(__instance) && victimPlayer.IsAlive() && lastEntityKilled != victimPlayer.entityId)
                                 {
                                     lastEntityKilled = victimPlayer.entityId;
                                     if (KillNotice.IsEnabled && KillNotice.PvP)
                                     {
                                         KillNotice.PlayerKilledPlayer(cInfoVictim, victimPlayer, cInfoAttacker, attackingPlayer, attackingItem(__instance), strength(__instance));
                                     }
                                     if (Bounties.IsEnabled)
                                     {
                                         Bounties.PlayerKilled(victimPlayer, attackingPlayer, cInfoVictim, cInfoAttacker);
                                     }
                                     if (Wallet.IsEnabled && Wallet.PVP && Wallet.Player_Kill > 0)
                                     {
                                         Wallet.AddCurrency(cInfoAttacker.CrossplatformId.CombinedString, Wallet.Player_Kill);
                                     }
                                     if (MagicBullet.IsEnabled && !MagicBullet.Kill.Contains(cInfoAttacker.entityId))
                                     {
                                         MagicBullet.Kill.Add(cInfoAttacker.entityId);
                                     }
                                 }
                             }
                         }
                         else if (attacker is EntityZombie)
                         {
                             if (NewPlayerProtection.IsEnabled && NewPlayerProtection.IsProtected(victimPlayer))
                             {
                                 return(true);
                             }
                             if (KillNotice.IsEnabled && KillNotice.Zombie_Kills)
                             {
                                 int[] attack = new int[] { attacker.entityId, strength(__instance) };
                                 if (KillNotice.Damage.ContainsKey(victim.entityId))
                                 {
                                     KillNotice.Damage[victim.entityId] = attack;
                                 }
                                 else
                                 {
                                     KillNotice.Damage.Add(victim.entityId, attack);
                                 }
                             }
                         }
                         else if (attacker is EntityAnimal)
                         {
                             if (NewPlayerProtection.IsEnabled && NewPlayerProtection.IsProtected(victimPlayer))
                             {
                                 return(true);
                             }
                             if (KillNotice.IsEnabled && KillNotice.Animal_Kills)
                             {
                                 int[] attack = new int[] { attacker.entityId, strength(__instance) };
                                 if (KillNotice.Damage.ContainsKey(victim.entityId))
                                 {
                                     KillNotice.Damage[victim.entityId] = attack;
                                 }
                                 else
                                 {
                                     KillNotice.Damage.Add(victim.entityId, attack);
                                 }
                             }
                         }
                     }
                 }
                 else if (victim is EntityZombie && attacker is EntityPlayer)
                 {
                     ClientInfo cInfoAttacker = PersistentOperations.GetClientInfoFromEntityId(attacker.entityId);
                     if (cInfoAttacker != null)
                     {
                         EntityPlayer attackingPlayer = attacker as EntityPlayer;
                         if (attackingItem(__instance) != null)
                         {
                             if (DamageDetector.IsEnabled && !DamageDetector.IsValidEntityDamage(attackingPlayer, cInfoAttacker, strength(__instance), attackingItem(__instance)))
                             {
                                 return(true);
                             }
                             if (InfiniteAmmo.IsEnabled && attackingItem(__instance).ItemClass.IsGun())
                             {
                                 int slot = attackingPlayer.inventory.holdingItemIdx;
                                 if (InfiniteAmmo.Exec(cInfoAttacker, attackingPlayer, slot, attackingItem(__instance)))
                                 {
                                     return(true);
                                 }
                             }
                             if (bFatal(__instance) && victim.IsAlive() && lastEntityKilled != victim.entityId)
                             {
                                 lastEntityKilled = victim.entityId;
                                 if (Wallet.IsEnabled && Wallet.Zombie_Kill > 0)
                                 {
                                     Wallet.AddCurrency(cInfoAttacker.CrossplatformId.CombinedString, Wallet.Zombie_Kill);
                                 }
                                 if (BloodmoonWarrior.IsEnabled && BloodmoonWarrior.BloodmoonStarted && BloodmoonWarrior.WarriorList.Contains(cInfoAttacker.entityId))
                                 {
                                     if (BloodmoonWarrior.KilledZombies.TryGetValue(cInfoAttacker.entityId, out int killedZ))
                                     {
                                         BloodmoonWarrior.KilledZombies[cInfoAttacker.entityId] += 1;
                                     }
                                     else
                                     {
                                         BloodmoonWarrior.KilledZombies.Add(cInfoAttacker.entityId, 1);
                                     }
                                 }
                             }
                         }
                         else
                         {
                             return(true);
                         }
                         if (PersistentOperations.IsBloodmoon() && Market.IsEnabled && Market.MarketPlayers.Contains(cInfoAttacker.entityId))
                         {
                             Phrases.Dict.TryGetValue("Market12", out string phrase);
                             ChatHook.ChatMessage(cInfoAttacker, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                             return(true);
                         }
                         if (PersistentOperations.IsBloodmoon() && Lobby.IsEnabled && Lobby.LobbyPlayers.Contains(cInfoAttacker.entityId))
                         {
                             Phrases.Dict.TryGetValue("Lobby12", out string phrase);
                             ChatHook.ChatMessage(cInfoAttacker, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                             return(true);
                         }
                         int distance = (int)attackingPlayer.GetDistance(victim);
                         using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8))
                         {
                             sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' @ '{4}' hit '{5}' named '{6}' @ '{7}' using '{8}' for '{9}' damage. Distance '{10}'", DateTime.Now, cInfoAttacker.PlatformId.CombinedString, cInfoAttacker.CrossplatformId.CombinedString, cInfoAttacker.playerName, cInfoAttacker.latestPlayerData.ecd.pos, victim.entityId, victim.EntityClass.entityClassName, victim.position, attackingItem(__instance).ItemClass.GetLocalizedItemName() ?? attackingItem(__instance).ItemClass.GetItemName(), strength(__instance), distance));
                             sw.WriteLine();
                             sw.Flush();
                             sw.Close();
                         }
                     }
                 }
                 else if (victim is EntityAnimal && attacker is EntityPlayer)
                 {
                     ClientInfo cInfoAttacker = PersistentOperations.GetClientInfoFromEntityId(attacker.entityId);
                     if (cInfoAttacker != null)
                     {
                         EntityPlayer attackingPlayer = attacker as EntityPlayer;
                         if (attackingItem(__instance) != null)
                         {
                             if (DamageDetector.IsEnabled && !DamageDetector.IsValidEntityDamage(attackingPlayer, cInfoAttacker, strength(__instance), attackingItem(__instance)))
                             {
                                 return(true);
                             }
                             if (InfiniteAmmo.IsEnabled && attackingItem(__instance).ItemClass.IsGun())
                             {
                                 int slot = attackingPlayer.inventory.holdingItemIdx;
                                 if (InfiniteAmmo.Exec(cInfoAttacker, attackingPlayer, slot, attackingItem(__instance)))
                                 {
                                     return(true);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.Exec: {0}", e.Message));
     }
     return(false);
 }