public override string GetRightHandTransformName()
    {
        String HandTransform = base.GetRightHandTransformName();

        //  Debug.Log("Entity ID: " + this.entityId + " Hand Transform: " + HandTransform);
        return(HandTransform);

        if (this.inventory.holdingItem.HasAnyTags(FastTags.Parse("melee")))
        {
            HandTransform = "RightWeapon";
        }
        if (this.inventory.holdingItem.HasAnyTags(FastTags.Parse("gun")))
        {
            HandTransform = "Gunjoint";
        }
        if (this.inventory.holdingItem.HasAnyTags(FastTags.Parse("bow")))
        {
            HandTransform = "LeftWeapon";
        }
        if (this.inventory.holdingItem.HasAnyTags(FastTags.Parse("pistol")))
        {
            HandTransform = "RightWeapon";
        }

        // If we are using the default weapon, re-set the hand item as per the xml.
        if (this.inventory.holdingItemIdx == 0)
        {
            HandTransform = base.GetRightHandTransformName();
        }

        return(HandTransform);
    }
Esempio n. 2
0
        public static bool Prefix(EntityHornet __instance, Context ___utilityAIContext, EntitySeeCache ___seeCache, EntityLookHelper ___lookHelper, ref int ___aggroCooldown)
        {
            if (!__instance.HasAnyTags(FastTags.Parse("allowEAI")))
            {
                return(true);
            }

            if (GamePrefs.GetBool(EnumGamePrefs.DebugStopEnemiesMoving))
            {
                __instance.SetMoveForwardWithModifiers(0f, 0f, false);
                if (__instance.aiManager != null)
                {
                    __instance.aiManager.UpdateDebugName();
                }
                return(true);
            }

            if (__instance.GetAttackTarget() != null)
            {
                __instance.SetRevengeTarget(__instance.GetAttackTarget());
            }

            __instance.CheckDespawn();
            ___seeCache.ClearIfExpired();
            using (ProfilerUsingFactory.Profile("entities.live.ai.manager"))
            {
                __instance.aiManager.Update();
            }

            using (ProfilerUsingFactory.Profile("entities.live.ai.getpath"))
            {
                PathInfo path = PathFinderThread.Instance.GetPath(__instance.entityId);
                if (path.path != null)
                {
                    bool flag = true;
                    flag = __instance.aiManager.CheckPath(path);

                    if (flag)
                    {
                        __instance.navigator.SetPath(path, path.speed);
                    }
                }
                __instance.navigator.UpdateNavigation();
            }
            __instance.moveHelper.UpdateMoveHelper();
            ___lookHelper.onUpdateLook();
            if (__instance.distraction != null && (__instance.distraction.IsDead() || __instance.distraction.IsMarkedForUnload()))
            {
                __instance.distraction = null;
            }
            if (__instance.pendingDistraction != null && (__instance.pendingDistraction.IsDead() || __instance.pendingDistraction.IsMarkedForUnload()))
            {
                __instance.pendingDistraction = null;
            }

            return(true);
        }
Esempio n. 3
0
        public static void Postfix(ref EntityAlive __instance)
        {
            if (!__instance.HasAnyTags(FastTags.Parse("allowEAI")))
            {
                return;
            }
            var entityClass = EntityClass.list[__instance.entityClass];

            if (SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer)
            {
                __instance.aiManager.CopyPropertiesFromEntityClass(entityClass);
            }
        }
Esempio n. 4
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;
                    }
                }
            }
        }
Esempio n. 5
0
 private static void UpdateXml()
 {
     FileWatcher.EnableRaisingEvents = false;
     using (StreamWriter sw = new StreamWriter(filePath))
     {
         sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
         sw.WriteLine("<KillNotice>");
         sw.WriteLine("    <Weapons>");
         if (Dict.Count > 0)
         {
             foreach (KeyValuePair <string, string> kvp in Dict)
             {
                 sw.WriteLine(string.Format("        <Weapon Name=\"{0}\" NewName=\"{1}\" />", kvp.Key, kvp.Value));
             }
         }
         else
         {
             List <ItemClass> _itemClassMelee  = ItemClass.GetItemsWithTag(FastTags.Parse("melee"));
             List <ItemClass> _itemClassRanged = ItemClass.GetItemsWithTag(FastTags.Parse("ranged"));
             for (int i = 0; i < _itemClassMelee.Count; i++)
             {
                 ItemClass     _itemClass = _itemClassMelee[i];
                 List <string> _tags      = _itemClass.ItemTags.GetTagNames();
                 if (_itemClass.CreativeMode != EnumCreativeMode.None && _itemClass.CreativeMode != EnumCreativeMode.Dev && !_tags.Contains("ammo"))
                 {
                     sw.WriteLine(string.Format("        <Weapon Name=\"{0}\" NewName=\"{1}\" />", _itemClass.GetItemName(), _itemClass.GetLocalizedItemName() ?? _itemClass.GetItemName()));
                 }
             }
             for (int i = 0; i < _itemClassRanged.Count; i++)
             {
                 ItemClass     _itemClass = _itemClassRanged[i];
                 List <string> _tags      = _itemClass.ItemTags.GetTagNames();
                 if (_itemClass.CreativeMode != EnumCreativeMode.None && _itemClass.CreativeMode != EnumCreativeMode.Dev && !_tags.Contains("ammo"))
                 {
                     sw.WriteLine(string.Format("        <Weapon Name=\"{0}\" NewName=\"{1}\" />", _itemClass.GetItemName(), _itemClass.GetLocalizedItemName() ?? _itemClass.GetItemName()));
                 }
             }
         }
         sw.WriteLine("    </Weapons>");
         sw.WriteLine("</KillNotice>");
         sw.Flush();
         sw.Close();
     }
     FileWatcher.EnableRaisingEvents = true;
 }
Esempio n. 6
0
        public static void GetCurrencyName()
        {
            List <ItemClass> itemClassCurrency = ItemClass.GetItemsWithTag(FastTags.Parse("currency"));

            if (itemClassCurrency != null && itemClassCurrency.Count > 0)
            {
                Currency_Item = itemClassCurrency[0].Name;
                Log.Out(string.Format("[SERVERTOOLS] Wallet and Bank tool set to utilize item named '{0}'", Currency_Item));
            }
            else
            {
                No_Currency      = true;
                Wallet.IsEnabled = false;
                Bank.IsEnabled   = false;
                Config.WriteXml();
                Config.LoadXml();
                Log.Out(string.Format("[SERVERTOOLS] Unable to find an item with the tag 'currency' in the item list. Wallet and Bank tool are disabled until server restart"));
            }
        }
Esempio n. 7
0
    public static bool IsHuman(int EntityID)
    {
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity == null)
        {
            return(false);
        }

        // Read the ConfigBlock to detect what constitutes a human, or rather, what can think
        string[] Tags = Configuration.GetPropertyValue("AdvancedNPCFeatures", "HumanTags").Split(',');
        foreach (String Tag in Tags)
        {
            if (myEntity.HasAnyTags(FastTags.Parse(Tag)))
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 8
0
 private static void UpgradeXml()
 {
     try
     {
         FileWatcher.EnableRaisingEvents = false;
         using (StreamWriter sw = new StreamWriter(FilePath, false, Encoding.UTF8))
         {
             sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
             sw.WriteLine("<KillNotice>");
             sw.WriteLine(string.Format("<ST Version=\"{0}\" />", Config.Version));
             sw.WriteLine("    <!-- <Weapon Name=\"\" NewName=\"\" /> -->");
             for (int i = 0; i < OldNodeList.Count; i++)
             {
                 if (OldNodeList[i].NodeType == XmlNodeType.Comment && !OldNodeList[i].OuterXml.Contains("<!-- <Weapon Name=\"\""))
                 {
                     sw.WriteLine(OldNodeList[i].OuterXml);
                 }
             }
             sw.WriteLine();
             sw.WriteLine();
             bool blank = true;
             for (int i = 0; i < OldNodeList.Count; i++)
             {
                 if (OldNodeList[i].NodeType != XmlNodeType.Comment)
                 {
                     XmlElement line = (XmlElement)OldNodeList[i];
                     if (line.HasAttributes && line.Name == "Weapon")
                     {
                         blank = false;
                         string name = "", newName = "";
                         if (line.HasAttribute("Name"))
                         {
                             name = line.GetAttribute("Name");
                         }
                         if (line.HasAttribute("NewName"))
                         {
                             newName = line.GetAttribute("NewName");
                         }
                         sw.WriteLine(string.Format("    <Weapon Name=\"{0}\" NewName=\"{1}\" />", name, newName));
                     }
                 }
             }
             if (blank)
             {
                 List <ItemClass> _itemClassMelee  = ItemClass.GetItemsWithTag(FastTags.Parse("melee"));
                 List <ItemClass> _itemClassRanged = ItemClass.GetItemsWithTag(FastTags.Parse("ranged"));
                 for (int i = 0; i < _itemClassMelee.Count; i++)
                 {
                     ItemClass     _itemClass = _itemClassMelee[i];
                     List <string> _tags      = _itemClass.ItemTags.GetTagNames();
                     if (_itemClass.CreativeMode != EnumCreativeMode.None && _itemClass.CreativeMode != EnumCreativeMode.Dev && !_tags.Contains("ammo"))
                     {
                         sw.WriteLine(string.Format("    <Weapon Name=\"{0}\" NewName=\"{1}\" />", _itemClass.GetItemName(), _itemClass.GetLocalizedItemName() ?? _itemClass.GetItemName()));
                     }
                 }
                 for (int i = 0; i < _itemClassRanged.Count; i++)
                 {
                     ItemClass     _itemClass = _itemClassRanged[i];
                     List <string> _tags      = _itemClass.ItemTags.GetTagNames();
                     if (_itemClass.CreativeMode != EnumCreativeMode.None && _itemClass.CreativeMode != EnumCreativeMode.Dev && !_tags.Contains("ammo"))
                     {
                         sw.WriteLine(string.Format("    <Weapon Name=\"{0}\" NewName=\"{1}\" />", _itemClass.GetItemName(), _itemClass.GetLocalizedItemName() ?? _itemClass.GetItemName()));
                     }
                 }
             }
             sw.WriteLine("</KillNotice>");
             sw.Flush();
             sw.Close();
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in KillNotice.UpgradeXml: {0}", e.Message));
     }
     FileWatcher.EnableRaisingEvents = true;
     LoadXml();
 }
Esempio n. 9
0
        public static void Postfix(ItemActionAttack __instance, ItemActionAttack.AttackHitInfo _attackDetails, ref float _weaponCondition, int _attackerEntityId, ItemValue damagingItemValue)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return;
            }

            EntityAlive entityAlive = GameManager.Instance.World.GetEntity(_attackerEntityId) as EntityAlive;

            if (entityAlive)
            {
                bool isWearingGloves = false;

                // Throw weapon, skipping
                if (damagingItemValue != null && damagingItemValue.ItemClass.HasAnyTags(FastTags.Parse("thrownWeapon")))
                {
                    return;
                }

                // Check if its the player hand
                if (entityAlive.inventory.holdingItem.GetItemName() == "meleeHandPlayer" && _attackDetails.damageGiven > 0 && !isWearingGloves)
                {
                    AdvLogging.DisplayLog(AdvFeatureClass, "Attacking Entity is an EntityAlive: " + entityAlive.inventory.holdingItemItemValue.ItemClass.GetItemName() + " Inflicting Damage");
                    DamageSource dmg = new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Bashing);
                    entityAlive.DamageEntity(dmg, 1, false, 1f);
                }
            }

            return;
        }
        public static bool Prefix(ItemActionEntryScrap __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }
            #region vanilla_code
            XUi            xui            = __instance.ItemController.xui;
            XUiC_ItemStack xuiC_ItemStack = (XUiC_ItemStack)__instance.ItemController;

            ItemStack itemStack       = xuiC_ItemStack.ItemStack.Clone();
            Recipe    scrapableRecipe = CraftingManager.GetScrapableRecipe(itemStack.itemValue, itemStack.count);
            if (scrapableRecipe == null)
            {
                return(true);
            }

            XUiController xuiController = __instance.ItemController.xui.FindWindowGroupByName("workstation_workbench");
            if (xuiController == null || !xuiController.WindowGroup.isShowing)
            {
                xuiController = xui.FindWindowGroupByName("crafting");
            }

            XUiC_CraftingWindowGroup childByType = xuiController.GetChildByType <XUiC_CraftingWindowGroup>();
            if (childByType == null)
            {
                return(true);
            }
            #endregion  vanilla_code

            LocalPlayerUI    uiforPlayer = LocalPlayerUI.GetUIForPlayer(__instance.ItemController.xui.playerUI.entityPlayer);
            List <ItemStack> scrapItems  = new List <ItemStack>();

            ItemClass forId = ItemClass.GetForId(itemStack.itemValue.type);
            // Check if ScrapItems is specified
            if (forId.Properties.Classes.ContainsKey("ScrapItems"))
            {
                DynamicProperties dynamicProperties3 = forId.Properties.Classes["ScrapItems"];
                scrapItems = ItemsUtilities.ParseProperties(dynamicProperties3);
                ItemsUtilities.Scrap(scrapItems, itemStack, __instance.ItemController);
                return(false);
            }
            else if (forId.Properties.Contains("ScrapItems")) // Support for <property name="ScrapItems" value="resourceWood,0,resourceLeather,2" />
            {
                string strData = forId.Properties.Values["ScrapItems"].ToString();
                scrapItems = ItemsUtilities.ParseProperties(strData);
                ItemsUtilities.Scrap(scrapItems, itemStack, __instance.ItemController);
                return(false);
            }
            // Check if Repair Items is specified, if the ScrapItems wasn't.
            else if (forId.Properties.Classes.ContainsKey("RepairItems"))
            {
                DynamicProperties dynamicProperties3 = forId.Properties.Classes["RepairItems"];
                scrapItems = ItemsUtilities.ParseProperties(dynamicProperties3);
                ItemsUtilities.Scrap(scrapItems, itemStack, __instance.ItemController);
                return(false);
            }
            else if (forId.RepairTools == null || forId.RepairTools.Length <= 0)
            {
                if (CraftingManager.GetRecipe(forId.GetItemName()) == null)
                {
                    return(true);
                }

                if (CraftingManager.GetRecipe(forId.GetItemName()).tags.Test_AnySet(FastTags.Parse("usevanillascrap")))
                {
                    return(true);
                }

                // If there's a recipe, reduce it
                Recipe recipe = ItemsUtilities.GetReducedRecipes(forId.GetItemName(), 2);

                ItemsUtilities.Scrap(recipe.ingredients, itemStack, __instance.ItemController);
                return(false);
            }
            return(true);
        }
        public static bool Prefix(ItemActionEntryRepair __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            XUi               xui       = __instance.ItemController.xui;
            ItemValue         itemValue = ((XUiC_ItemStack)__instance.ItemController).ItemStack.itemValue;
            ItemClass         forId     = ItemClass.GetForId(itemValue.type);
            EntityPlayerLocal player    = xui.playerUI.entityPlayer;

            XUiC_CraftingWindowGroup childByType = xui.FindWindowGroupByName("crafting").GetChildByType <XUiC_CraftingWindowGroup>();

            List <ItemStack> repairItems = new List <ItemStack>();

            // If the item has a repairItems, use that, instead of the vanilla version.
            if (forId.Properties.Classes.ContainsKey("RepairItems"))
            {
                Recipe            recipe             = new Recipe();
                DynamicProperties dynamicProperties3 = forId.Properties.Classes["RepairItems"];
                recipe.ingredients = ItemsUtilities.ParseProperties(dynamicProperties3);

                // Get an adjusted Craftint time from the player.
                recipe.craftingTime = (int)EffectManager.GetValue(PassiveEffects.CraftingTime, null, recipe.craftingTime, xui.playerUI.entityPlayer, recipe, FastTags.Parse(recipe.GetName()), true, true, true, true, 1, true);
                ItemsUtilities.ConvertAndCraft(recipe, player, __instance.ItemController);
                return(false);
            }
            else if (forId.Properties.Contains("RepairItems")) // to support <property name="RepairItems" value="resourceWood,10,resourceForgedIron,10" />
            {
                Recipe recipe  = new Recipe();
                string strData = forId.Properties.Values["RepairItems"].ToString();
                recipe.ingredients = ItemsUtilities.ParseProperties(strData);

                // Get an adjusted Craftint time from the player.
                recipe.craftingTime = (int)EffectManager.GetValue(PassiveEffects.CraftingTime, null, recipe.craftingTime, xui.playerUI.entityPlayer, recipe, FastTags.Parse(recipe.GetName()), true, true, true, true, 1, true);
                ItemsUtilities.ConvertAndCraft(recipe, player, __instance.ItemController);
                return(false);
            }
            // If there's no RepairTools defined, then fall back to recipe reduction
            else if (forId.RepairTools == null || forId.RepairTools.Length <= 0)
            {
                // Determine, based on percentage left,
                int RecipeCountReduction = 2;
                if (itemValue.PercentUsesLeft < 0.2)
                {
                    RecipeCountReduction = 3;
                }

                // Use the helper method to reduce the recipe count, and control displaying on the UI for consistenncy.
                ItemsUtilities.ConvertAndCraft(forId.GetItemName(), RecipeCountReduction, player, __instance.ItemController);
                return(false);
            }

            // Fall back to possible RepairTools
            return(true);
        }
            static bool Prefix(ItemValue __instance, ref int _type, ref int minQuality, ref int maxQuality, ref bool _bCreateDefaultModItems, ref FastTags modsToInstall, ref float modInstallDescendingChance)
            {
                if (maxQuality == 6)
                {
                    maxQuality = 120;
                }

                return(true);
            }