예제 #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;
        }
예제 #2
0
    private void DoBuffsAndRadiation(EntityAlive player)
    {
        if (RadiationDamage > 0)
        {
            player.DamageEntity(DamageSource.radiation, (int)RadiationDamage, false, 1f);
        }

        if (BuffActions == null || BuffActions.Count == 0 || GameTimer.Instance.ticks <= NextBuff)
        {
            return;
        }

        NextBuff = GameTimer.Instance.ticks + 200;

        using (var enumerator = BuffActions.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                if (enumerator.Current != null)
                {
                    enumerator.Current.Execute(BlockValue.type, player, false, EnumBodyPartHit.None, null);
                }
            }
        }
    }
예제 #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;
        }
예제 #4
0
    public void FindAndKillSurroundingEntities()
    {
        //if (entityDamage == 0 || entityVehicle.lastControllerVelocityMagnitude < 5f || Time.time - entityHitAgainDelay < lastEntityHitTime)
        if (entityDamage == 0 || lastControllerVelocityMagnitude < entityHitMinSpeed)
        {
            //DebugMsg("NOT damaging entity: entityDamage = " + entityDamage.ToString() + " | lastControllerVelocityMagnitude = " + entityVehicle.lastControllerVelocityMagnitude.ToString("0.000"));
            return;
        }
        else
        {
            //DebugMsg("lastControllerVelocityMagnitude = " + entityVehicle.lastControllerVelocityMagnitude.ToString("0.000"));
        }

        // Try-catch for now because of an error with Bandits and survivors
        try
        {
            Vector3    b = new Vector3(0f, entityVehicle.m_characterController.height / 2f, 0f);
            RaycastHit raycastHit;
            //if (Physics.CapsuleCast(entityVehicle.position - b, entityVehicle.position + b, destructionRadius, entityVehicle.motion.normalized, out raycastHit, entityVehicle.motion.magnitude, -1) && raycastHit.collider != null)
            if (Physics.CapsuleCast(entityVehicle.position - b, entityVehicle.position + b, destructionRadius, entityVehicle.motion.normalized, out raycastHit, destructionRadius + 1, -1) && raycastHit.collider != null)
            {
                RootTransformRefEntity component = raycastHit.collider.gameObject.GetComponent <RootTransformRefEntity>();
                if (component)
                {
                    EntityAlive entityAlive = component.RootTransform.GetComponent <Entity>() as EntityAlive;
                    //if (entityAlive != null && entityAlive != entityVehicle.AttachedEntities && entityAlive.Spawned && !entityAlive.IsDead())
                    if (entityAlive != null && entityAlive != entityVehicle.AttachedEntities && !entityAlive.IsDead() && !(entityAlive.entityId == lastHitEntityId && Time.time - entityHitAgainDelay < lastEntityHitTime))
                    {
                        int damage = entityDamage;
                        entityHitSpeedRatio = CustomVehiclesUtils.GetRatio(Mathf.Clamp(lastControllerVelocityMagnitude, entityHitMinSpeed, 18f), entityHitMinSpeed, 18f) + 1f;
                        entityHitDamage     = Mathf.RoundToInt((float)damage * entityHitSpeedRatio);
                        bool isCritical = lastControllerVelocityMagnitude > entityCriticalHitMinSpeed;
                        // Doing this in order to properly kill entities. Otherwise they die instantly without animation, and animal corpses disappear.
                        if (entityHitDamage > entityAlive.Health)
                        {
                            entityHitDamage = entityAlive.Health;
                            isCritical      = true;
                        }
                        DamageSourceEntity damageSourceEntity;
                        if (isCritical)
                        {
                            damageSourceEntity = new DamageSourceEntity(EnumDamageSourceType.Melee, entityVehicle.player.entityId, -raycastHit.normal);
                        }
                        else
                        {
                            damageSourceEntity = new DamageSourceEntity(EnumDamageSourceType.Melee, entityVehicle.player.entityId, -raycastHit.normal, raycastHit.transform.name, raycastHit.point, Vector2.zero);
                        }
                        //DamageSourceEntity damageSourceEntity = new DamageSourceEntity(EnumDamageSourceType.Melee, entityVehicle.player.entityId, -raycastHit.normal, raycastHit.transform.name, raycastHit.point, Vector2.zero);
                        lastHitEntityId = entityAlive.entityId;
                        entityAlive.DamageEntity(damageSourceEntity, entityHitDamage, isCritical, isCritical? 3f : 2f);

                        //DebugMsg("Damage Entity: " + entityAlive.entityId + " | lastControllerVelocityMagnitude = " + lastControllerVelocityMagnitude.ToString("0.000") + " (hit speed ratio = " + entityHitSpeedRatio.ToString("0.000")
                        //    + ") | damage = " + entityHitDamage.ToString("0.000") + " (" + entityAlive.Health.ToString() + "/" + entityAlive.GetMaxHealth().ToString() + ") | hit transform name = " + raycastHit.transform.name + " | critical = " + isCritical.ToString());

                        float vehDmg = (((float)entityAlive.GetMaxHealth()) / 3000.0f) * vehicleDamageFactor_entities * entityHitSpeedRatio;
                        DamageVehicle(vehDmg, 2f);
                        lastEntityHitTime = Time.time;
                    }
                }
            }
        }
        catch (System.Exception e)
        {
            Debug.LogError("An error occurred: " + e);
        }
    }