Exemplo n.º 1
0
        static bool Prefix(EntityAlive __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            // Check if there's a door in our way, then open it.
            if (__instance.GetAttackTarget() == null)
            {
                // If it's an animal, don't let them attack blocks
                EntityAliveFarmingAnimalSDX animal = __instance as EntityAliveFarmingAnimalSDX;
                if (animal)
                {
                    if (__instance.GetAttackTarget() == null)
                    {
                        return(false);
                    }
                }
            }

            if (__instance.GetAttackTarget() != null)
            {
                __instance.RotateTo(__instance.GetAttackTarget(), 30f, 30f);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static bool ZCheck(ClientInfo _cInfo, EntityPlayer _player)
        {
            List <Entity> Entities = GameManager.Instance.World.Entities.list;

            for (int i = 0; i < Entities.Count; i++)
            {
                Entity _entity = Entities[i];
                if (_entity != null && _player != _entity && _entity.IsSpawned() && !_entity.IsClientControlled())
                {
                    string _tags = _entity.EntityClass.Tags.ToString();
                    if (_tags.Contains("zombie") || _tags.Contains("hostile"))
                    {
                        EntityAlive _entityAlive = GameManager.Instance.World.Entities.dict[_entity.entityId] as EntityAlive;
                        if (_entityAlive != null && _player == _entityAlive.GetAttackTarget())
                        {
                            if (((_player.position.x - _entity.position.x) * (_player.position.x - _entity.position.x) + (_player.position.z - _entity.position.z) * (_player.position.z - _entity.position.z)) < 50f * 50f)
                            {
                                Phrases.Dict.TryGetValue(851, out string _phrase851);
                                ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase851 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
 public static bool EntityAlive_OnEntityDeath_Prefix(EntityAlive __instance)
 {
     try
     {
         if (ReservedSlots.Bonus_Exp > 0 && __instance is EntityZombie)
         {
             EntityAlive entityAlive = __instance.GetAttackTarget();
             if (entityAlive != null && entityAlive is EntityPlayer)
             {
                 ClientInfo cInfo = PersistentOperations.GetClientInfoFromEntityId(entityAlive.entityId);
                 if (cInfo != null && ReservedSlots.IsEnabled && (ReservedSlots.Dict.ContainsKey(cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(cInfo.CrossplatformId.CombinedString)))
                 {
                     if (ReservedSlots.Bonus_Exp > 100)
                     {
                         ReservedSlots.Bonus_Exp = 100;
                     }
                     int   experience = EntityClass.list[__instance.entityClass].ExperienceValue;
                     float percent    = ReservedSlots.Bonus_Exp / 100f;
                     float bonus      = experience * percent;
                     experience = (int)bonus;
                     cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityAddExpClient>().Setup(entityAlive.entityId, experience, Progression.XPTypes.Kill));
                     Log.Out(string.Format("[SERVERTOOLS] Added bonus experience of '{0}' to reserved player '{1}' '{2}' named '{3}'", experience, cInfo.PlatformId.CombinedString, cInfo.CrossplatformId.CombinedString, cInfo.playerName));
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Injections.EntityAlive_OnEntityDeath_Prefix: {0}", e.Message));
     }
     return(true);
 }
Exemplo n.º 4
0
    public bool CheckSurroundingEntities()
    {
        this.NearbyEntities.Clear();
        EntityAlive leader = null;

        if (this.theEntity.Buffs.HasCustomVar("Leader"))
        {
            DisplayLog(" leader Detected.");
            int EntityID = (int)this.theEntity.Buffs.GetCustomVar("Leader");
            leader = this.theEntity.world.GetEntity(EntityID) as EntityAlive;
        }

        if (leader == null)
        {
            DisplayLog(" No leader detected.");
            return(false);
        }

        // Search in the bounds are to try to find the most appealing entity to follow.
        Bounds bb = new Bounds(this.theEntity.position, new Vector3(this.theEntity.GetSeeDistance(), 20f, this.theEntity.GetSeeDistance()));

        this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities);
        DisplayLog(" Nearby Entities: " + this.NearbyEntities.Count);
        for (int i = this.NearbyEntities.Count - 1; i >= 0; i--)
        {
            EntityAlive x = (EntityAlive)this.NearbyEntities[i];
            if (x != this.theEntity)
            {
                DisplayLog("Nearby Entity: " + x.EntityName);
                if (x.GetAttackTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);
                    return(true);
                }

                if (x.GetRevengeTarget() == leader)
                {
                    DisplayLog(" My leader is being avenged by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }

                if (x.GetDamagedTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by something that damaged it " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }
            }
        }

        return(false);
    }
Exemplo n.º 5
0
    public static Entity GetAttackOrReventTarget(int EntityID)
    {
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity)
        {
            if (myEntity.GetAttackTarget() != null)
            {
                return(myEntity.GetAttackTarget());
            }
            if (myEntity.GetRevengeTarget() == null)
            {
                return(myEntity.GetRevengeTarget());
            }
        }
        return(null);
    }
Exemplo n.º 6
0
    public bool CheckSurroundingEntities()
    {
        this.NearbyEntities.Clear();
        EntityAlive leader = EntityUtilities.GetLeaderOrOwner(this.theEntity.entityId) as EntityAlive;

        if (!leader)
        {
            return(false);
        }

        // Search in the bounds are to try to find the most appealing entity to follow.
        Bounds bb = new Bounds(this.theEntity.position, new Vector3(this.theEntity.GetSeeDistance(), 20f, this.theEntity.GetSeeDistance()));

        //Bounds bb = new Bounds(this.theEntity.position, new Vector3(20f, 20f,20f));
        this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities);
        DisplayLog(" Nearby Entities: " + this.NearbyEntities.Count);
        for (int i = this.NearbyEntities.Count - 1; i >= 0; i--)
        {
            EntityAlive x = (EntityAlive)this.NearbyEntities[i];
            if (x != this.theEntity)
            {
                if (x.IsDead())
                {
                    continue;
                }

                DisplayLog("Nearby Entity: " + x.EntityName);
                if (x.GetAttackTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);
                    return(true);
                }

                if (x.GetRevengeTarget() == leader)
                {
                    DisplayLog(" My leader is being avenged by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }

                if (x.GetDamagedTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by something that damaged it " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }
            }
        }

        return(false);
    }
Exemplo n.º 7
0
        static bool Prefix(EntityAlive __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            // Check if there's a door in our way, then open it.
            if (__instance.GetAttackTarget() == null)
            {
                // If it's an animal, don't let them attack blocks
                EntityAliveFarmingAnimalSDX animal = __instance as EntityAliveFarmingAnimalSDX;
                if (animal)
                {
                    if (__instance.GetAttackTarget() == null)
                    {
                        return(false);
                    }
                }
                //// If a door is found, try to open it. If it returns false, start attacking it.
                //EntityAliveSDX myEntity = __instance as EntityAliveSDX;
                //if (myEntity)
                //{
                //    if (myEntity.OpenDoor())
                //        return true;
                //}
            }

            if (__instance.GetAttackTarget() != null)
            {
                __instance.RotateTo(__instance.GetAttackTarget(), 30f, 30f);
            }

            return(true);
        }
Exemplo n.º 8
0
        public static void Postfix(EntityAlive __instance)
        {
            // If it's a zombie, don't do anything extra
            if (__instance.HasAnyTags(FastTags.CombineTags(FastTags.Parse("zombie"), FastTags.Parse("hostile"))))
            {
                return;
            }

            // If they have attack targets, don't interrupt them.
            if (__instance.GetAttackTarget() != null || __instance.GetRevengeTarget() != null)
            {
                return;
            }

            // Scan the area around the Entity
            List <global::Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(__instance, new Bounds(__instance.position, Vector3.one * 4f));

            if (entitiesInBounds.Count > 0)
            {
                for (int i = 0; i < entitiesInBounds.Count; i++)
                {
                    if (entitiesInBounds[i] is EntityPlayer)
                    {
                        // Check your faction relation. If you hate each other, don't stop and talk.
                        FactionManager.Relationship myRelationship = FactionManager.Instance.GetRelationshipTier(__instance, entitiesInBounds[i] as EntityAlive);
                        if (myRelationship == FactionManager.Relationship.Hate)
                        {
                            break;
                        }

                        // Give the player some space if NPC is too close.
                        if (__instance.GetDistance(entitiesInBounds[i]) < 1)
                        {
                            // Give the NPC a chance to move into position before facing the player.
                            __instance.moveHelper.SetMoveTo((entitiesInBounds[i] as EntityPlayer).GetLookVector(), false);
                            break;
                        }

                        // Turn to face the player, and stop the movement.
                        __instance.SetLookPosition(entitiesInBounds[i].getHeadPosition());
                        __instance.RotateTo(entitiesInBounds[i], 30f, 30f);
                        __instance.navigator.clearPath();
                        __instance.moveHelper.Stop();
                        break;
                    }
                }
            }
        }
Exemplo n.º 9
0
    public static bool CanExecuteTask(int EntityID, EntityUtilities.Orders order)
    {
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity)
        {
            if (GetCurrentOrder(EntityID) != order)
            {
                DisplayLog("CanExecuteTask(): Current Order does not match passed in Order: " + GetCurrentOrder(EntityID));
                return(false);
            }

            Entity leader   = EntityUtilities.GetLeader(EntityID);
            float  Distance = 0f;
            if (leader)
            {
                Distance = myEntity.GetDistance(leader);
            }

            // If we have an attack or revenge target, don't execute task
            if (myEntity.GetAttackTarget() != null && myEntity.GetAttackTarget().IsAlive())
            {
                // If we have a leader and they are far away, abandon the fight and go after your leader.
                if (Distance > 20)
                {
                    DisplayLog("CanExecuteTask(): I have an Attack Target but my Leader is too far away.");
                    myEntity.SetAttackTarget(null, 0);
                    return(true);
                }

                // I have an attack target, so don't keep doing your current task
                DisplayLog("CanExecuteTask(): I have an Attack Target: " + myEntity.GetAttackTarget().ToString());
                return(false);
            }

            if (myEntity.GetRevengeTarget() != null && myEntity.GetRevengeTarget().IsAlive())
            {
                if (Distance > 20)
                {
                    DisplayLog("CanExecuteTask(): I have a Revenge Target, but my leader is too far way.");
                    myEntity.SetRevengeTarget(null);
                    return(true);
                }
                DisplayLog("CanExecuteTask(): I have a Revenge Target: " + myEntity.GetRevengeTarget().ToString());
                return(false);
            }

            if (GetCurrentOrder(EntityID) == Orders.Follow)
            {
                DisplayLog("My Current Order is Follow");
                if (Distance < 2)
                {
                    if (myEntity.moveHelper != null)
                    {
                        myEntity.moveHelper.Stop();
                        DisplayLog(" Too Close to leader. Moving to Look Vector");
                        myEntity.moveHelper.SetMoveTo((leader as EntityAlive).GetLookVector(), false);
                    }
                    return(false);
                }
            }

            return(true);
        }
        return(true);
    }
Exemplo n.º 10
0
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 if (PlayerChecks.FlyEnabled && PlayerChecks.Movement.ContainsKey(_cInfo.entityId))
                 {
                     PlayerChecks.Movement.Remove(_cInfo.entityId);
                 }
                 if (Died.IsEnabled)
                 {
                     Died.PlayerKilled(_player);
                 }
                 if (KillNotice.IsEnabled)
                 {
                     if (KillNotice.Zombie_Kills && string.IsNullOrEmpty(_secondaryName))
                     {
                         List <Entity> Entities = GameManager.Instance.World.Entities.list;
                         for (int i = 0; i < Entities.Count; i++)
                         {
                             EntityAlive _entityAlive = Entities[i] as EntityAlive;
                             if (_entityAlive != null && _entityAlive.GetAttackTarget() == _player && _entityAlive.entityId != _player.entityId)
                             {
                                 if (KillNotice.Show_Level)
                                 {
                                     Phrases.Dict.TryGetValue(545, out string _phrase545);
                                     _phrase545 = _phrase545.Replace("{PlayerName}", _cInfo.playerName);
                                     _phrase545 = _phrase545.Replace("{Level}", _player.Progression.Level.ToString());
                                     _phrase545 = _phrase545.Replace("{ZombieName}", _entityAlive.EntityName);
                                     ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase545 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                                 }
                                 else
                                 {
                                     Phrases.Dict.TryGetValue(546, out string _phrase546);
                                     _phrase546 = _phrase546.Replace("{PlayerName}", _cInfo.playerName);
                                     _phrase546 = _phrase546.Replace("{ZombieName}", _entityAlive.EntityName);
                                     ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase546 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                                 }
                             }
                         }
                     }
                     else if (KillNotice.PvP && !string.IsNullOrEmpty(_secondaryName) && _mainName != _secondaryName)
                     {
                         ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName);
                         if (_cInfo2 != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo2.entityId))
                         {
                             EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                             if (_player2 != null)
                             {
                                 if (KillNotice.IsEnabled && _player2.IsAlive())
                                 {
                                     string _holdingItem = _player2.inventory.holdingItem.GetItemName();
                                     if (!string.IsNullOrEmpty(_holdingItem))
                                     {
                                         ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true);
                                         if (_itemValue.type != ItemValue.None.type)
                                         {
                                             KillNotice.Exec(_cInfo, _player, _cInfo2, _player2, _holdingItem);
                                             return(false);
                                         }
                                     }
                                 }
                                 if (Wallet.IsEnabled)
                                 {
                                     if (Wallet.PVP && Wallet.Player_Kills > 0)
                                     {
                                         Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                     }
                                     else if (Wallet.Player_Kills > 0)
                                     {
                                         Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                     }
                                 }
                                 if (Bounties.IsEnabled)
                                 {
                                     Bounties.PlayerKilled(_player, _player2, _cInfo, _cInfo2);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}", e.Message));
     }
     return(true);
 }