public static bool Prefix([NotNull] EntityZombie __instance)
        {
            if (!PersistentData.Instance.PatchCorpseItemDupeExploit)
            {
                Log.Debug($"Skipping disabled patch prefix for {nameof(CorpseDupe)}.");
                return(true);
            }

            Log.Debug($"Executing patch prefix for {nameof(CorpseDupe)} ...");

            if (__instance.lootContainer != null && __instance.lootContainer.bTouched && !__instance.lootContainer.IsEmpty())
            {
                __instance.lootContainer.SetEmpty();

                // EntityAlive.entityThatKilledMe and EntityAlive.GetRevengeTarget() are always null, but this isn't:
                var sourceEntityId = __instance.GetDamageResponse().Source?.getEntityId() ?? -1;
                //var sourceEntity   = GameManager.Instance.World?.GetEntity(sourceEntityId);
                var sourceClientInfo = ConnectionManager.Instance?.GetClientInfoForEntityId(sourceEntityId);

                var pos = __instance.GetPosition().ToVector3i();

                Log.Out($"Cleared touched zombie corpse at {pos} killed by '{sourceClientInfo?.playerName ?? "[unknown]"}'.");
            }
            return(true);
        }
Exemple #2
0
        private void MagicBullet()
        {
            EntityZombie ztarget = null;
            EntityPlayer pTarget = null;

            foreach (EntityZombie zombie in O.zombieList)
            {
                if (zombie && zombie.IsAlive())
                {
                    Vector3 head = zombie.emodel.GetHeadTransform().position;
                    Vector3 w2s  = ESP.mainCam.WorldToScreenPoint(head);

                    // If they're outside of our FOV.
                    if (Vector2.Distance(new Vector2(Screen.width / 2, Screen.height / 2), new Vector2(w2s.x, w2s.y)) > 120f)
                    {
                        continue;
                    }

                    ztarget = zombie;
                }
            }

            foreach (EntityPlayer player in O.PlayerList)
            {
                if (player && player.IsAlive() && player != O.localPlayer)
                {
                    Vector3 head = player.emodel.GetHeadTransform().position;
                    Vector3 w2s  = ESP.mainCam.WorldToScreenPoint(head);

                    if (Vector2.Distance(new Vector2(Screen.width / 2, Screen.height / 2), new Vector2(w2s.x, w2s.y)) > 120f)
                    {
                        continue;
                    }

                    pTarget = player;
                }
            }

            if (pTarget)
            {
                // Purposely not giving the damage source an ID, so servers can't track you for killing people.
                DamageSource source = new DamageSource(EnumDamageSource.External, EnumDamageTypes.Concuss);

                ztarget.DamageEntity(source, 100, false, 1f);
                ztarget.AwardKill(O.localPlayer);
            }

            if (ztarget)
            {
                DamageSource source = new DamageSource(EnumDamageSource.External, EnumDamageTypes.Concuss);
                source.CreatorEntityId = O.localPlayer.entityId;

                ztarget.DamageEntity(source, 100, false, 1f);
                ztarget.AwardKill(O.localPlayer);

                O.localPlayer.AddKillXP(ztarget);
            }
        }
Exemple #3
0
        private void displayEntity(Entity entity)
        {
            EntityAlive  entityAlive  = null;
            EntityPlayer entityPlayer = null;
            EntityNPC    entityNPC    = null;
            EntityZombie entityZombie = null;

            if (entity is EntityAlive)
            {
                entityAlive = (EntityAlive)entity;
            }
            if (entity is EntityPlayer)
            {
                entityPlayer = (EntityPlayer)entity;
            }
            if (entity is EntityNPC)
            {
                entityNPC = (EntityNPC)entity;
            }
            if (entity is EntityZombie)
            {
                entityZombie = (EntityZombie)entity;
            }

            string entitydata = " [";

            entitydata += string.Empty;
            entitydata += "id=";
            entitydata += entity.entityId;
            entitydata += ", ";
            entitydata += entity.ToString();
            entitydata += ", Pos=";
            entitydata += entity.GetPosition();
            entitydata += ", Rot=";
            entitydata += entity.rotation;
            entitydata += ", Lifetime=";
            entitydata += ((entity.lifetime != 3.40282347E+38f) ? entity.lifetime.ToString("0.0") : "Max");
            entitydata += ", Remote=";
            entitydata += entity.isEntityRemote;
            entitydata += ", Dead=";
            entitydata += entity.IsDead();
            if (entityAlive != null)
            {
                entitydata += ", CreationTimeSinceLevelLoad=" + entityAlive.CreationTimeSinceLevelLoad;
                entitydata += ", MaxHealth=" + entityAlive.GetMaxHealth();
                entitydata += ", Health=" + entityAlive.Health;
            }
            if (entityZombie != null)
            {
                entitydata += ", IsScoutZombie=" + entityZombie.IsScoutZombie;
            }
            entitydata += "]";
            SendOutput(entitydata);
        }
Exemple #4
0
 public static void ZombieKilledPlayer(EntityZombie _zombie, EntityPlayer _victim, ClientInfo _cInfo, int _damage)
 {
     try
     {
         if (Show_Level)
         {
             if (Show_Damage)
             {
                 Phrases.Dict.TryGetValue("KillNotice5", out string phrase);
                 phrase = phrase.Replace("{Name1}", _cInfo.playerName);
                 phrase = phrase.Replace("{Level}", _victim.Progression.Level.ToString());
                 phrase = phrase.Replace("{Name2}", _zombie.EntityClass.entityClassName);
                 phrase = phrase.Replace("{Value}", _damage.ToString());
                 ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                 return;
             }
             else
             {
                 Phrases.Dict.TryGetValue("KillNotice6", out string phrase);
                 phrase = phrase.Replace("{Name1}", _cInfo.playerName);
                 phrase = phrase.Replace("{Level}", _victim.Progression.Level.ToString());
                 phrase = phrase.Replace("{Name2}", _zombie.EntityClass.entityClassName);
                 ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
             }
         }
         else
         {
             if (Show_Damage)
             {
                 Phrases.Dict.TryGetValue("KillNotice7", out string phrase);
                 phrase = phrase.Replace("{Name1}", _cInfo.playerName);
                 phrase = phrase.Replace("{Name2}", _zombie.EntityClass.entityClassName);
                 phrase = phrase.Replace("{Value}", _damage.ToString());
                 ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                 return;
             }
             else
             {
                 Phrases.Dict.TryGetValue("KillNotice8", out string phrase);
                 phrase = phrase.Replace("{Name1}", _cInfo.playerName);
                 phrase = phrase.Replace("{Name2}", _zombie.EntityClass.entityClassName);
                 ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in KillNotice.ZombieKilledPlayer: {0}", e.Message));
     }
 }
            //    Maybe I'll need this someday ;)
            //    FieldInfo fieldInfo = typeof(EntityAlive).GetField("IsFeral", BindingFlags.NonPublic);
            //    FieldInfo fieldInfo2 = typeof(EntityZombie).GetField("moveSpeeds", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
            //    Debug.LogWarning("Part 1 done");
            //    bool IsFeral2 = (bool)fieldInfo.GetValue(__instance);
            //    float[] moveSpeeds2 = (float[])fieldInfo2.GetValue(__instance);
            //    Debug.LogWarning("Part 2 done");
            //    EnumGamePrefs eProperty = EnumGamePrefs.ZombieMove;
            static bool Prefix(EntityZombie __instance, ref float __result, ref bool ___IsFeral, ref float[] ___moveSpeeds)
            {
                bool        nullifyrage = false;
                EntityClass entityClass = EntityClass.list[__instance.entityClass];

                bool.TryParse(entityClass.Properties.Values["Ragemode"], out nullifyrage);
                if (nullifyrage || __instance.Buffs.HasBuff("buffRageMode"))
                {
                    return(true);
                }
                EnumGamePrefs eProperty = EnumGamePrefs.ZombieMove;

                if (__instance.IsBloodMoon)
                {
                    eProperty = EnumGamePrefs.ZombieBMMove;
                }
                else if (___IsFeral)
                {
                    eProperty = EnumGamePrefs.ZombieFeralMove;
                }
                else if (__instance.world.IsDark())
                {
                    eProperty = EnumGamePrefs.ZombieMoveNight;
                }
                int   @int = GamePrefs.GetInt(eProperty);
                float num  = ___moveSpeeds[@int];

                if (num < 1f)
                {
                    num = __instance.moveSpeedAggro * (1f - num) + __instance.moveSpeedAggroMax * num;
                }
                else
                {
                    num = __instance.moveSpeedAggroMax * num;
                }
                float speed = EffectManager.GetValue(PassiveEffects.RunSpeed, null, num, __instance, null, default(FastTags), true, true, true, true, 1, true);

                __result = speed;
                return(false);
            }
Exemple #6
0
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_cInfo != null && _type == EnumGameMessages.EntityWasKilled)
         {
             EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
             if (player != null)
             {
                 if (KillNotice.IsEnabled && (KillNotice.Zombie_Kills || KillNotice.Animal_Kills) && string.IsNullOrEmpty(_secondaryName))
                 {
                     if (KillNotice.Damage.ContainsKey(player.entityId))
                     {
                         KillNotice.Damage.TryGetValue(player.entityId, out int[] damage);
                         EntityZombie zombie = PersistentOperations.GetZombie(damage[0]);
                         if (zombie != null)
                         {
                             KillNotice.ZombieKilledPlayer(zombie, player, _cInfo, damage[1]);
                         }
                         else
                         {
                             EntityAnimal animal = PersistentOperations.GetAnimal(damage[0]);
                             if (animal != null)
                             {
                                 KillNotice.AnimalKilledPlayer(animal, player, _cInfo, damage[1]);
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}", e.Message));
     }
     return(true);
 }
Exemple #7
0
        bool CreateZombie(ZombieAgent zombie, PlayerZone zone)
        {
            if (!CanSpawnActiveZombie())
            {
                return(false);
            }

            var   world = GameManager.Instance.World;
            Chunk chunk = (Chunk)world.GetChunkSync(World.toChunkXZ(Mathf.FloorToInt(zombie.pos.x)), 0, World.toChunkXZ(Mathf.FloorToInt(zombie.pos.z)));

            if (chunk == null)
            {
#if DEBUG
                Log.Out("[WalkerSim] Chunk not loaded at {0} {1}", zombie.pos, zombie.pos.z);
#endif
                return(false);
            }

            int height = world.GetTerrainHeight(Mathf.FloorToInt(zombie.pos.x), Mathf.FloorToInt(zombie.pos.z));

            Vector3 spawnPos = new Vector3(zombie.pos.x, height + 1.0f, zombie.pos.z);
            if (!CanZombieSpawnAt(spawnPos))
            {
#if DEBUG
                Log.Out("[WalkerSim] Unable to spawn zombie at {0}, CanMobsSpawnAtPos failed", spawnPos);
#endif
                return(false);
            }

            if (zombie.classId == -1)
            {
                zombie.classId = _biomeData.GetZombieClass(world, chunk, (int)spawnPos.x, (int)spawnPos.z, _prng);
                if (zombie.classId == -1)
                {
                    int lastClassId = -1;
                    zombie.classId = EntityGroups.GetRandomFromGroup("ZombiesAll", ref lastClassId);
#if DEBUG
                    Log.Out("Used fallback for zombie class!");
#endif
                }
            }

            EntityZombie zombieEnt = EntityFactory.CreateEntity(zombie.classId, spawnPos) as EntityZombie;
            if (zombieEnt == null)
            {
#if DEBUG
                Log.Error("[WalkerSim] Unable to create zombie entity!, Entity Id: {0}, Pos: {1}", zombie.classId, spawnPos);
#endif
                return(false);
            }

            zombieEnt.bIsChunkObserver = true;

            // TODO: Figure out a better way to make them walk towards something.
            if (true)
            {
                // Send zombie towards a random position in the zone.
                Vector3 targetPos = GetRandomZonePos(zone);
                if (targetPos == Vector3.zero)
                {
                    zombieEnt.SetInvestigatePosition(zone.center, 6000, false);
                }
                else
                {
                    zombieEnt.SetInvestigatePosition(targetPos, 6000, false);
                }
            }

            // If the zombie was previously damaged take health to this one.
            if (zombie.health != -1)
            {
                zombieEnt.Health = zombie.health;
            }
            else
            {
                zombie.health = zombieEnt.Health;
            }

            zombieEnt.IsHordeZombie = true;
            zombieEnt.IsBloodMoon   = _state.IsBloodMoon;

            zombieEnt.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);

            world.SpawnEntityInWorld(zombieEnt);

            zombie.entityId    = zombieEnt.entityId;
            zombie.currentZone = zone;
            zombie.lifeTime    = world.GetWorldTime();

            zone.numZombies++;

#if DEBUG
            Log.Out("[WalkerSim] Spawned zombie {0} at {1}", zombieEnt, spawnPos);
#endif
            lock (_activeZombies)
            {
                _activeZombies.Add(zombie);
            }

            return(true);
        }
Exemple #8
0
        bool UpdateActiveZombie(ZombieAgent zombie)
        {
            var world      = GameManager.Instance.World;
            int maxPerZone = MaxZombiesPerZone();

            bool removeZombie = false;

            var worldTime = world.GetWorldTime();
            var timeAlive = worldTime - zombie.lifeTime;

            var currentZone = zombie.currentZone as PlayerZone;

            if (currentZone != null)
            {
                currentZone.numZombies--;
                if (currentZone.numZombies < 0)
                {
                    currentZone.numZombies = 0;
                }
            }
            zombie.currentZone = null;

            Vector3 oldPos = new Vector3 {
                x = zombie.pos.x, y = zombie.pos.y, z = zombie.pos.z
            };
            EntityZombie ent = world.GetEntity(zombie.entityId) as EntityZombie;

            if (ent == null)
            {
#if DEBUG
                Log.Out("[WalkerSim] Failed to get zombie with entity id {0}", zombie.entityId);
#endif
                removeZombie = true;
                RespawnInactiveZombie(zombie);
            }
            else
            {
                zombie.pos    = ent.GetPosition();
                zombie.health = ((EntityZombie)ent).Health;
                zombie.dir    = -ent.rotation;

                if (ent.IsDead())
                {
                    removeZombie = true;
                    RespawnInactiveZombie(zombie);
                }
                else
                {
                    List <PlayerZone> zones = _playerZones.FindAllByPos2D(ent.GetPosition());
                    if (zones.Count == 0 && timeAlive >= MinZombieLifeTime)
                    {
#if DEBUG
                        Log.Out("[WalkerSim] Zombie {0} out of range, turning inactive", ent);
#endif
                        removeZombie = true;

                        world.RemoveEntity(zombie.entityId, EnumRemoveEntityReason.Despawned);

                        zombie.entityId    = -1;
                        zombie.currentZone = null;

                        TurnZombieInactive(zombie);
                    }
                    else
                    {
                        foreach (var zone in zones)
                        {
                            if (zone.numZombies + 1 < maxPerZone)
                            {
                                zone.numZombies++;
                                zombie.currentZone = zone;
                                // If the zombie is inside a player zone make sure we renew the life time.
                                zombie.lifeTime = worldTime;
                                break;
                            }
                        }
                    }
                }
            }

            return(removeZombie);
        }
 static void Postfix(EntityZombie __instance)
 {
     __instance.timeToDie = __instance.world.worldTime + 1800UL + (ulong)(22000f * __instance.rand.RandomFloat);
 }
Exemple #10
0
        private void UpdateActiveZombies()
        {
            var world              = GameManager.Instance.World;
            int maxPerZone         = MaxZombiesPerZone();
            int deactivatedZombies = 0;

            for (int i = 0; i < _activeZombies.Count; i++)
            {
                bool removeZombie = false;

                var zombie      = _activeZombies[i];
                var currentZone = zombie.currentZone as PlayerZone;
                if (currentZone != null)
                {
                    currentZone.numZombies--;
                    if (currentZone.numZombies < 0)
                    {
                        currentZone.numZombies = 0;
                    }
                }

                Vector3 oldPos = new Vector3 {
                    x = zombie.pos.x, y = zombie.pos.y, z = zombie.pos.z
                };
                EntityZombie ent = world.GetEntity(zombie.entityId) as EntityZombie;
                if (ent == null)
                {
#if DEBUG
                    Log.Out("[WalkerSim] Failed to get zombie with entity id {0}", zombie.entityId);
#endif
                    removeZombie = true;
                    RespawnInactiveZombie(zombie);
                }
                else
                {
                    zombie.pos    = ent.GetPosition();
                    zombie.health = ((EntityZombie)ent).Health;
                    zombie.dir    = -ent.rotation;

                    if (ent.IsDead())
                    {
                        deactivatedZombies++;
                        removeZombie = true;
                        RespawnInactiveZombie(zombie);
                    }
                    else
                    {
                        List <PlayerZone> zones = _playerZones.FindAllByPos2D(ent.GetPosition());
                        if (zones.Count == 0)
                        {
#if DEBUG
                            Log.Out("[WalkerSim] Zombie {0} out of range, turning inactive", ent);
#endif
                            deactivatedZombies++;
                            removeZombie = true;

                            world.RemoveEntity(zombie.entityId, EnumRemoveEntityReason.Despawned);

                            lock (_lock)
                            {
                                zombie.entityId    = -1;
                                zombie.currentZone = null;
                                _inactiveZombies.Add(zombie);
                            }
                        }
                        else
                        {
                            zombie.currentZone = null;
                            foreach (var zone in zones)
                            {
                                if (zone.numZombies + 1 < maxPerZone)
                                {
                                    zone.numZombies++;
                                    zombie.currentZone = zone;
                                    break;
                                }
                            }
                            if (zombie.currentZone == null)
                            {
#if DEBUG
                                Log.Out("Unable to assign zone for Zombie {0}, all zones full", ent);
#endif
                            }
                        }
                    }
                }

                if (removeZombie)
                {
                    lock (_lock)
                    {
                        _activeZombies.RemoveAt(i);
                        if (_activeZombies.Count == 0)
                        {
                            break;
                        }
                    }
                    i--;
                }
            }
        }