Esempio n. 1
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;
        }
Esempio n. 2
0
        public static bool Prefix(ItemActionAttack __instance, ItemActionAttack.AttackHitInfo _attackDetails, ref float _weaponCondition, int _attackerEntityId)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

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

            if (entityAlive)
            {
                ItemValue itemValue = entityAlive.inventory.holdingItemItemValue;
                if (itemValue.HasQuality && entityAlive is EntityPlayerLocal)  // this checks if it has any passive effects, like degradation
                {
                    String strDisplay = "";
                    if (_attackDetails.WeaponTypeTag.Equals(ItemActionAttack.MeleeTag))
                    {
                        strDisplay += " Melee ";
                        float percent = itemValue.PercentUsesLeft;
                        if (percent > 0.8f)
                        {
                            _weaponCondition = 1f;
                        }
                        else if (percent > 0) // Perfecent left will be 0 on non-degradation things
                        {
                            _weaponCondition = percent;
                        }
                    }
                    else if (_attackDetails.WeaponTypeTag.Equals(ItemActionAttack.RangedTag))
                    {
                        strDisplay += " Ranged ";
                    }

                    strDisplay += itemValue.ItemClass.GetItemName() + " Percent Left: " + itemValue.PercentUsesLeft + " Weapon Condition: " + _weaponCondition;
                    AdvLogging.DisplayLog(AdvFeatureClass, strDisplay);
                }
            }
            return(true);
        }
Esempio n. 3
0
        public static void Postfix(ItemActionAttack __instance, ItemActionAttack.AttackHitInfo _attackDetails, ref float _weaponCondition, int _attackerEntityId)
        {
            // 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;
                //LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityAlive as EntityPlayerLocal);
                //if(uiforPlayer)
                //{
                //    // Grab a hand item to see if its being worn.
                //    ItemValue handItems = ItemClass.GetItem("armorClothGloves", false );
                //    if(uiforPlayer.xui.PlayerEquipment.IsEquipmentTypeWorn( handItems ))
                //        isWearingGloves = true;
                //}

                //BlockValue blockValue = _attackDetails.blockBeingDamaged;
                //if (blockValue.type != 0 )
                //{
                //    if (blockValue.Block.blockMaterial.MaxDamage <= 1)
                //        isWearingGloves = true;
                //}
                // 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;
        }