Beispiel #1
0
        private IEnumerator DamageCoroutine()
        {
            yield return(new WaitForSeconds(0.3f));

            if (_player == null)
            {
                Destroy(gameObject);
                yield break;
            }

            foreach (var characterCollider in Colliders)
            {
                if (characterCollider == null || characterCollider == _player)
                {
                    continue;
                }

                var hitData = new HitData();
                hitData.m_point          = characterCollider.transform.position;
                hitData.m_dir            = (characterCollider.transform.position - _player.transform.position).normalized;
                hitData.m_damage.m_frost = _frostDamage;
                hitData.SetAttacker(_player);

                characterCollider.Damage(hitData);
            }

            Destroy(gameObject);
        }
            public static bool Prefix(Projectile __instance, ref Collider collider, Vector3 hitPoint)
            {
                if (__instance.name.Contains(customProjectileName))
                {
                    GameObject    gameObject   = (collider ? Projectile.FindHitObject(collider) : null);
                    IDestructible destructible = (gameObject ? gameObject.GetComponent <IDestructible>() : null);
                    if (destructible != null)
                    {
                        bool hitCharacter = false;
                        bool hitValid     = (bool)typeof(Projectile).GetMethod("IsValidTarget", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { destructible, hitCharacter });
                        if (!hitValid)
                        {
                            return(true);
                        }
                        HitData hitData = new HitData();
                        hitData.m_hitCollider = collider;
                        hitData.m_damage      = __instance.m_damage.Clone();
                        hitData.m_toolTier    = __instance.m_damage.m_chop == darkChopDamage ? 2 : 0;
                        if ((destructible is Character character) && !treelikeCreatures.Contains(character.m_name))
                        {
                            hitData.m_damage.m_pierce = 0;
                        }
                        hitData.m_pushForce     = 20;
                        hitData.m_backstabBonus = 3;
                        hitData.m_point         = hitPoint;
                        hitData.m_dir           = __instance.transform.forward;
                        hitData.m_dodgeable     = true;
                        hitData.m_blockable     = true;
                        hitData.m_skill         = MagicSkill.MagicSkillDef.m_skill;
                        var owner = (Character)typeof(Projectile).GetField("m_owner", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(__instance);
                        hitData.SetAttacker(owner);
                        destructible.Damage(hitData);

                        __instance.m_hitEffects.Create(hitPoint, Quaternion.identity);
                        if (__instance.m_hitNoise > 0f)
                        {
                            BaseAI.DoProjectileHitNoise(__instance.transform.position, __instance.m_hitNoise, owner);
                        }
                        ((ZNetView)typeof(Projectile).GetField("m_nview", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(__instance)).InvokeRPC("OnHit");
                        ZNetScene.instance.Destroy(__instance.gameObject);
                        return(false);
                    }
                }
                return(true);
            }
Beispiel #3
0
    // Token: 0x06000306 RID: 774 RVA: 0x00019C28 File Offset: 0x00017E28
    private void DoAOE(Vector3 hitPoint, ref bool hitCharacter, ref bool didDamage)
    {
        Collider[]           array   = Physics.OverlapSphere(hitPoint, this.m_aoe, Projectile.m_rayMaskSolids, QueryTriggerInteraction.UseGlobal);
        HashSet <GameObject> hashSet = new HashSet <GameObject>();

        foreach (Collider collider in array)
        {
            GameObject    gameObject = Projectile.FindHitObject(collider);
            IDestructible component  = gameObject.GetComponent <IDestructible>();
            if (component != null && !hashSet.Contains(gameObject))
            {
                hashSet.Add(gameObject);
                if (this.IsValidTarget(component, ref hitCharacter))
                {
                    Vector3 vector  = collider.ClosestPointOnBounds(hitPoint);
                    Vector3 vector2 = (Vector3.Distance(vector, hitPoint) > 0.1f) ? (vector - hitPoint) : this.m_vel;
                    vector2.y = 0f;
                    vector2.Normalize();
                    HitData hitData = new HitData();
                    hitData.m_hitCollider   = collider;
                    hitData.m_damage        = this.m_damage;
                    hitData.m_pushForce     = this.m_attackForce;
                    hitData.m_backstabBonus = this.m_backstabBonus;
                    hitData.m_point         = vector;
                    hitData.m_dir           = vector2.normalized;
                    hitData.m_statusEffect  = this.m_statusEffect;
                    hitData.m_dodgeable     = this.m_dodgeable;
                    hitData.m_blockable     = this.m_blockable;
                    hitData.m_skill         = this.m_skill;
                    hitData.SetAttacker(this.m_owner);
                    component.Damage(hitData);
                    didDamage = true;
                }
            }
        }
    }
Beispiel #4
0
    // Token: 0x06000308 RID: 776 RVA: 0x00019DEC File Offset: 0x00017FEC
    private void OnHit(Collider collider, Vector3 hitPoint, bool water)
    {
        GameObject gameObject = collider ? Projectile.FindHitObject(collider) : null;
        bool       flag       = false;
        bool       flag2      = false;

        if (this.m_aoe > 0f)
        {
            this.DoAOE(hitPoint, ref flag2, ref flag);
        }
        else
        {
            IDestructible destructible = gameObject ? gameObject.GetComponent <IDestructible>() : null;
            if (destructible != null)
            {
                if (!this.IsValidTarget(destructible, ref flag2))
                {
                    return;
                }
                HitData hitData = new HitData();
                hitData.m_hitCollider   = collider;
                hitData.m_damage        = this.m_damage;
                hitData.m_pushForce     = this.m_attackForce;
                hitData.m_backstabBonus = this.m_backstabBonus;
                hitData.m_point         = hitPoint;
                hitData.m_dir           = base.transform.forward;
                hitData.m_statusEffect  = this.m_statusEffect;
                hitData.m_dodgeable     = this.m_dodgeable;
                hitData.m_blockable     = this.m_blockable;
                hitData.m_skill         = this.m_skill;
                hitData.SetAttacker(this.m_owner);
                destructible.Damage(hitData);
                flag = true;
            }
        }
        if (water)
        {
            this.m_hitWaterEffects.Create(hitPoint, Quaternion.identity, null, 1f);
        }
        else
        {
            this.m_hitEffects.Create(hitPoint, Quaternion.identity, null, 1f);
        }
        if (this.m_spawnOnHit != null || this.m_spawnItem != null)
        {
            this.SpawnOnHit(gameObject, collider);
        }
        if (this.m_hitNoise > 0f)
        {
            BaseAI.DoProjectileHitNoise(base.transform.position, this.m_hitNoise, this.m_owner);
        }
        if (this.m_owner != null && flag && this.m_owner.IsPlayer())
        {
            (this.m_owner as Player).RaiseSkill(this.m_skill, flag2 ? 1f : 0.5f);
        }
        this.m_didHit           = true;
        base.transform.position = hitPoint;
        this.m_nview.InvokeRPC("OnHit", Array.Empty <object>());
        if (!this.m_stayAfterHitStatic)
        {
            ZNetScene.instance.Destroy(base.gameObject);
            return;
        }
        if (collider && collider.attachedRigidbody != null)
        {
            this.m_ttl = Mathf.Min(1f, this.m_ttl);
        }
    }
Beispiel #5
0
        private static void doMeleeAttack(Humanoid ___m_character, ItemDrop.ItemData ___m_weapon, Attack __instance,
                                          EffectList ___m_hitEffect, Skills.SkillType ___m_specialHitSkill, DestructibleType ___m_specialHitType,
                                          bool ___m_lowerDamagePerHit, float ___m_forceMultiplier, float ___m_staggerMultiplier, float ___m_damageMultiplier,
                                          int ___m_attackChainLevels, int ___m_currentAttackCainLevel, DestructibleType ___m_resetChainIfHit,
                                          ref int ___m_nextAttackChainLevel, EffectList ___m_hitTerrainEffect, float ___m_attackHitNoise, Vector3 pos,
                                          Collider col, Vector3 dir, GameObject ___m_spawnOnTrigger)
        {
            Vector3 zero  = Vector3.zero;
            bool    flag2 = false; //rename
            HashSet <Skills.SkillType> skillTypeSet = new HashSet <Skills.SkillType>();
            bool hitOccured = false;

            ___m_weapon.m_shared.m_hitEffect.Create(pos, Quaternion.identity);
            ___m_hitEffect.Create(pos, Quaternion.identity);

            GameObject hitObject = Projectile.FindHitObject(col);

            if (!(hitObject == ___m_character.gameObject))
            {
                Vagon component1 = hitObject.GetComponent <Vagon>();
                if (!component1 || !component1.IsAttached(___m_character))
                {
                    Character component2 = hitObject.GetComponent <Character>();
                    if (!(component2 != null) ||
                        (___m_character.IsPlayer() || BaseAI.IsEnemy(___m_character, component2)) &&
                        (!___m_weapon.m_shared.m_dodgeable || !component2.IsDodgeInvincible()))
                    {
                        hitOccured = true;
                    }
                }
            }

            if (!hitOccured)
            {
                return;
            }

            IDestructible component = hitObject.GetComponent <IDestructible>();

            if (component != null)
            {
                DestructibleType destructibleType = component.GetDestructibleType();
                Skills.SkillType skill            = ___m_weapon.m_shared.m_skillType;

                if (___m_specialHitSkill != Skills.SkillType.None &&
                    (destructibleType & ___m_specialHitType) != DestructibleType.None)
                {
                    skill = ___m_specialHitSkill;
                }

                float randomSkillFactor = ___m_character.GetRandomSkillFactor(skill);

                if (___m_lowerDamagePerHit)
                {
                    randomSkillFactor /= 0.75f;
                }

                HitData hitData = new HitData();
                hitData.m_toolTier     = ___m_weapon.m_shared.m_toolTier;
                hitData.m_statusEffect = ___m_weapon.m_shared.m_attackStatusEffect
                    ? ___m_weapon.m_shared.m_attackStatusEffect.name
                    : "";
                hitData.m_pushForce         = ___m_weapon.m_shared.m_attackForce * randomSkillFactor * ___m_forceMultiplier;
                hitData.m_backstabBonus     = ___m_weapon.m_shared.m_backstabBonus;
                hitData.m_staggerMultiplier = ___m_staggerMultiplier;
                hitData.m_dodgeable         = ___m_weapon.m_shared.m_dodgeable;
                hitData.m_blockable         = ___m_weapon.m_shared.m_blockable;
                hitData.m_skill             = skill;
                hitData.m_damage            = ___m_weapon.GetDamage();
                hitData.m_point             = pos;
                hitData.m_dir         = dir;
                hitData.m_hitCollider = col;
                hitData.SetAttacker(___m_character);
                hitData.m_damage.Modify(___m_damageMultiplier);
                hitData.m_damage.Modify(randomSkillFactor);
                hitData.m_damage.Modify((float)getLevelDamageFactorMethod.Invoke(__instance, null));
                if (___m_attackChainLevels > 1 && ___m_currentAttackCainLevel == ___m_attackChainLevels - 1)
                {
                    hitData.m_damage.Modify(2f);
                    hitData.m_pushForce *= 1.2f;
                }
                hitData.m_damage.Modify(MeshCooldown.calcDamageMultiplier());

                ___m_character.GetSEMan().ModifyAttack(skill, ref hitData);
                if (component is Character)
                {
                    flag2 = true;
                }
                component.Damage(hitData);
                if ((destructibleType & ___m_resetChainIfHit) != DestructibleType.None)
                {
                    ___m_nextAttackChainLevel = 0;
                }
                skillTypeSet.Add(skill);
            }

            ___m_weapon.m_shared.m_hitTerrainEffect.Create(pos,
                                                           Quaternion.identity); // Quaternion.identity might need to be replaced
            ___m_hitTerrainEffect.Create(pos, Quaternion.identity);

            if (___m_weapon.m_shared.m_spawnOnHitTerrain)
            {
                spawnOnHitTerrainMethod.Invoke(__instance,
                                               new object[] { pos, ___m_weapon.m_shared.m_spawnOnHitTerrain });
            }

            if (___m_weapon.m_shared.m_useDurability && ___m_character.IsPlayer())
            {
                ___m_weapon.m_durability -= ___m_weapon.m_shared.m_useDurabilityDrain;
            }
            ___m_character.AddNoise(___m_attackHitNoise);

            if (___m_weapon.m_shared.m_spawnOnHit)
            {
                Object.Instantiate(___m_weapon.m_shared.m_spawnOnHit, pos,
                                   Quaternion.identity).GetComponent <IProjectile>()
                ?.Setup(___m_character, zero, ___m_attackHitNoise, null, ___m_weapon);
            }
            foreach (Skills.SkillType skill in skillTypeSet)
            {
                ___m_character.RaiseSkill(skill, flag2 ? 1.5f : 1f);
            }

            if (!___m_spawnOnTrigger)
            {
                return;
            }
            Object.Instantiate(___m_spawnOnTrigger, zero,
                               Quaternion.identity).GetComponent <IProjectile>()?.Setup(___m_character,
                                                                                        ___m_character.transform.forward, -1f, null, ___m_weapon);

            return;
        }
Beispiel #6
0
    // Token: 0x060002DE RID: 734 RVA: 0x000173D0 File Offset: 0x000155D0
    private bool OnHit(Collider collider, Vector3 hitPoint)
    {
        GameObject gameObject = Projectile.FindHitObject(collider);

        if (this.m_hitList.Contains(gameObject))
        {
            return(false);
        }
        this.m_hitList.Add(gameObject);
        float num = 1f;

        if (this.m_owner && this.m_owner.IsPlayer() && this.m_skill != Skills.SkillType.None)
        {
            num = this.m_owner.GetRandomSkillFactor(this.m_skill);
        }
        bool          result    = false;
        IDestructible component = gameObject.GetComponent <IDestructible>();

        if (component != null)
        {
            Character character = component as Character;
            if (character)
            {
                if (this.m_nview == null && !character.IsOwner())
                {
                    return(false);
                }
                if (this.m_owner != null)
                {
                    if (!this.m_hitOwner && character == this.m_owner)
                    {
                        return(false);
                    }
                    if (!this.m_hitSame && character.m_name == this.m_owner.m_name)
                    {
                        return(false);
                    }
                    bool flag = BaseAI.IsEnemy(this.m_owner, character);
                    if (!this.m_hitFriendly && !flag)
                    {
                        return(false);
                    }
                    if (!this.m_hitEnemy && flag)
                    {
                        return(false);
                    }
                }
                if (!this.m_hitCharacters)
                {
                    return(false);
                }
                if (this.m_dodgeable && character.IsDodgeInvincible())
                {
                    return(false);
                }
            }
            else if (!this.m_hitProps)
            {
                return(false);
            }
            Vector3 dir     = this.m_attackForceForward ? base.transform.forward : (hitPoint - base.transform.position).normalized;
            HitData hitData = new HitData();
            hitData.m_hitCollider   = collider;
            hitData.m_damage        = this.GetDamage();
            hitData.m_pushForce     = this.m_attackForce * num;
            hitData.m_backstabBonus = this.m_backstabBonus;
            hitData.m_point         = hitPoint;
            hitData.m_dir           = dir;
            hitData.m_statusEffect  = this.m_statusEffect;
            hitData.m_dodgeable     = this.m_dodgeable;
            hitData.m_blockable     = this.m_blockable;
            hitData.m_toolTier      = this.m_toolTier;
            hitData.SetAttacker(this.m_owner);
            hitData.m_damage.Modify(num);
            component.Damage(hitData);
            if (this.m_damageSelf > 0f)
            {
                IDestructible componentInParent = base.GetComponentInParent <IDestructible>();
                if (componentInParent != null)
                {
                    HitData hitData2 = new HitData();
                    hitData2.m_damage.m_damage = this.m_damageSelf;
                    hitData2.m_point           = hitPoint;
                    hitData2.m_blockable       = false;
                    hitData2.m_dodgeable       = false;
                    componentInParent.Damage(hitData2);
                }
            }
            result = true;
        }
        this.m_hitEffects.Create(hitPoint, Quaternion.identity, null, 1f);
        return(result);
    }
Beispiel #7
0
    // Token: 0x060002F6 RID: 758 RVA: 0x00018CFC File Offset: 0x00016EFC
    private void DoMeleeAttack()
    {
        Transform transform;
        Vector3   vector;

        this.GetMeleeAttackDir(out transform, out vector);
        Vector3    point      = this.m_character.transform.InverseTransformDirection(vector);
        Quaternion quaternion = Quaternion.LookRotation(vector, Vector3.up);

        this.m_weapon.m_shared.m_triggerEffect.Create(transform.position, quaternion, transform, 1f);
        this.m_triggerEffect.Create(transform.position, quaternion, transform, 1f);
        Vector3 vector2                    = transform.position + Vector3.up * this.m_attackHeight + this.m_character.transform.right * this.m_attackOffset;
        float   num                        = this.m_attackAngle / 2f;
        float   num2                       = 4f;
        float   attackRange                = this.m_attackRange;
        List <Attack.HitPoint>     list    = new List <Attack.HitPoint>();
        HashSet <Skills.SkillType> hashSet = new HashSet <Skills.SkillType>();
        int layerMask                      = this.m_hitTerrain ? Attack.m_attackMaskTerrain : Attack.m_attackMask;

        for (float num3 = -num; num3 <= num; num3 += num2)
        {
            Quaternion rotation = Quaternion.identity;
            if (this.m_attackType == Attack.AttackType.Horizontal)
            {
                rotation = Quaternion.Euler(0f, -num3, 0f);
            }
            else if (this.m_attackType == Attack.AttackType.Vertical)
            {
                rotation = Quaternion.Euler(num3, 0f, 0f);
            }
            Vector3 vector3 = this.m_character.transform.TransformDirection(rotation * point);
            Debug.DrawLine(vector2, vector2 + vector3 * attackRange);
            RaycastHit[] array;
            if (this.m_attackRayWidth > 0f)
            {
                array = Physics.SphereCastAll(vector2, this.m_attackRayWidth, vector3, Mathf.Max(0f, attackRange - this.m_attackRayWidth), layerMask, QueryTriggerInteraction.Ignore);
            }
            else
            {
                array = Physics.RaycastAll(vector2, vector3, attackRange, layerMask, QueryTriggerInteraction.Ignore);
            }
            Array.Sort <RaycastHit>(array, (RaycastHit x, RaycastHit y) => x.distance.CompareTo(y.distance));
            foreach (RaycastHit raycastHit in array)
            {
                if (!(raycastHit.collider.gameObject == this.m_character.gameObject))
                {
                    Vector3 vector4 = raycastHit.point;
                    if (raycastHit.distance < 1E-45f)
                    {
                        if (raycastHit.collider is MeshCollider)
                        {
                            vector4 = vector2 + vector3 * attackRange;
                        }
                        else
                        {
                            vector4 = raycastHit.collider.ClosestPoint(vector2);
                        }
                    }
                    if (this.m_attackAngle >= 180f || Vector3.Dot(vector4 - vector2, vector) > 0f)
                    {
                        GameObject gameObject = Projectile.FindHitObject(raycastHit.collider);
                        if (!(gameObject == this.m_character.gameObject))
                        {
                            Vagon component = gameObject.GetComponent <Vagon>();
                            if (!component || !component.IsAttached(this.m_character))
                            {
                                Character component2 = gameObject.GetComponent <Character>();
                                if (!(component2 != null) || ((this.m_character.IsPlayer() || BaseAI.IsEnemy(this.m_character, component2)) && (!this.m_weapon.m_shared.m_dodgeable || !component2.IsDodgeInvincible())))
                                {
                                    this.AddHitPoint(list, gameObject, raycastHit.collider, vector4, raycastHit.distance);
                                    if (!this.m_hitThroughWalls)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        int     num4    = 0;
        Vector3 vector5 = Vector3.zero;
        bool    flag    = false;
        bool    flag2   = false;

        foreach (Attack.HitPoint hitPoint in list)
        {
            GameObject go      = hitPoint.go;
            Vector3    vector6 = hitPoint.avgPoint / (float)hitPoint.count;
            Vector3    vector7 = vector6;
            switch (this.m_hitPointtype)
            {
            case Attack.HitPointType.Closest:
                vector7 = hitPoint.closestPoint;
                break;

            case Attack.HitPointType.Average:
                vector7 = vector6;
                break;

            case Attack.HitPointType.First:
                vector7 = hitPoint.firstPoint;
                break;
            }
            num4++;
            vector5 += vector6;
            this.m_weapon.m_shared.m_hitEffect.Create(vector7, Quaternion.identity, null, 1f);
            this.m_hitEffect.Create(vector7, Quaternion.identity, null, 1f);
            IDestructible component3 = go.GetComponent <IDestructible>();
            if (component3 != null)
            {
                DestructibleType destructibleType = component3.GetDestructibleType();
                Skills.SkillType skillType        = this.m_weapon.m_shared.m_skillType;
                if (this.m_specialHitSkill != Skills.SkillType.None && (destructibleType & this.m_specialHitType) != DestructibleType.None)
                {
                    skillType = this.m_specialHitSkill;
                }
                float num5 = this.m_character.GetRandomSkillFactor(skillType);
                if (this.m_lowerDamagePerHit && list.Count > 1)
                {
                    num5 /= (float)list.Count * 0.75f;
                }
                HitData hitData = new HitData();
                hitData.m_toolTier          = this.m_weapon.m_shared.m_toolTier;
                hitData.m_statusEffect      = (this.m_weapon.m_shared.m_attackStatusEffect ? this.m_weapon.m_shared.m_attackStatusEffect.name : "");
                hitData.m_pushForce         = this.m_weapon.m_shared.m_attackForce * num5 * this.m_forceMultiplier;
                hitData.m_backstabBonus     = this.m_weapon.m_shared.m_backstabBonus;
                hitData.m_staggerMultiplier = this.m_staggerMultiplier;
                hitData.m_dodgeable         = this.m_weapon.m_shared.m_dodgeable;
                hitData.m_blockable         = this.m_weapon.m_shared.m_blockable;
                hitData.m_skill             = skillType;
                hitData.m_damage            = this.m_weapon.GetDamage();
                hitData.m_point             = vector7;
                hitData.m_dir         = (vector7 - vector2).normalized;
                hitData.m_hitCollider = hitPoint.collider;
                hitData.SetAttacker(this.m_character);
                hitData.m_damage.Modify(this.m_damageMultiplier);
                hitData.m_damage.Modify(num5);
                hitData.m_damage.Modify(this.GetLevelDamageFactor());
                if (this.m_attackChainLevels > 1 && this.m_currentAttackCainLevel == this.m_attackChainLevels - 1)
                {
                    hitData.m_damage.Modify(2f);
                    hitData.m_pushForce *= 1.2f;
                }
                this.m_character.GetSEMan().ModifyAttack(skillType, ref hitData);
                if (component3 is Character)
                {
                    flag2 = true;
                }
                component3.Damage(hitData);
                if ((destructibleType & this.m_resetChainIfHit) != DestructibleType.None)
                {
                    this.m_nextAttackChainLevel = 0;
                }
                hashSet.Add(skillType);
                if (!this.m_multiHit)
                {
                    break;
                }
            }
            if (go.GetComponent <Heightmap>() != null && !flag)
            {
                flag = true;
                this.m_weapon.m_shared.m_hitTerrainEffect.Create(vector6, quaternion, null, 1f);
                this.m_hitTerrainEffect.Create(vector6, quaternion, null, 1f);
                if (this.m_weapon.m_shared.m_spawnOnHitTerrain)
                {
                    this.SpawnOnHitTerrain(vector6, this.m_weapon.m_shared.m_spawnOnHitTerrain);
                }
                if (!this.m_multiHit)
                {
                    break;
                }
            }
        }
        if (num4 > 0)
        {
            vector5 /= (float)num4;
            if (this.m_weapon.m_shared.m_useDurability && this.m_character.IsPlayer())
            {
                this.m_weapon.m_durability -= this.m_weapon.m_shared.m_useDurabilityDrain;
            }
            this.m_character.AddNoise(this.m_attackHitNoise);
            this.m_animEvent.FreezeFrame(0.15f);
            if (this.m_weapon.m_shared.m_spawnOnHit)
            {
                IProjectile component4 = UnityEngine.Object.Instantiate <GameObject>(this.m_weapon.m_shared.m_spawnOnHit, vector5, quaternion).GetComponent <IProjectile>();
                if (component4 != null)
                {
                    component4.Setup(this.m_character, Vector3.zero, this.m_attackHitNoise, null, this.m_weapon);
                }
            }
            foreach (Skills.SkillType skill in hashSet)
            {
                this.m_character.RaiseSkill(skill, flag2 ? 1.5f : 1f);
            }
        }
        if (this.m_spawnOnTrigger)
        {
            IProjectile component5 = UnityEngine.Object.Instantiate <GameObject>(this.m_spawnOnTrigger, vector2, Quaternion.identity).GetComponent <IProjectile>();
            if (component5 != null)
            {
                component5.Setup(this.m_character, this.m_character.transform.forward, -1f, null, this.m_weapon);
            }
        }
    }
Beispiel #8
0
    // Token: 0x060002F3 RID: 755 RVA: 0x00018698 File Offset: 0x00016898
    private void DoAreaAttack()
    {
        Transform transform    = this.m_character.transform;
        Transform attackOrigin = this.GetAttackOrigin();
        Vector3   vector       = attackOrigin.position + Vector3.up * this.m_attackHeight + transform.forward * this.m_attackRange + transform.right * this.m_attackOffset;

        this.m_weapon.m_shared.m_triggerEffect.Create(vector, transform.rotation, attackOrigin, 1f);
        this.m_triggerEffect.Create(vector, transform.rotation, attackOrigin, 1f);
        Vector3 vector2 = vector - transform.position;

        vector2.y = 0f;
        vector2.Normalize();
        int     num               = 0;
        Vector3 vector3           = Vector3.zero;
        bool    flag              = false;
        bool    flag2             = false;
        float   randomSkillFactor = this.m_character.GetRandomSkillFactor(this.m_weapon.m_shared.m_skillType);
        int     layerMask         = this.m_hitTerrain ? Attack.m_attackMaskTerrain : Attack.m_attackMask;

        Collider[]           array   = Physics.OverlapSphere(vector, this.m_attackRayWidth, layerMask, QueryTriggerInteraction.UseGlobal);
        HashSet <GameObject> hashSet = new HashSet <GameObject>();

        foreach (Collider collider in array)
        {
            if (!(collider.gameObject == this.m_character.gameObject))
            {
                GameObject gameObject = Projectile.FindHitObject(collider);
                if (!(gameObject == this.m_character.gameObject) && !hashSet.Contains(gameObject))
                {
                    hashSet.Add(gameObject);
                    Vector3 vector4;
                    if (collider is MeshCollider)
                    {
                        vector4 = collider.ClosestPointOnBounds(vector);
                    }
                    else
                    {
                        vector4 = collider.ClosestPoint(vector);
                    }
                    IDestructible component = gameObject.GetComponent <IDestructible>();
                    if (component != null)
                    {
                        Vector3 vector5 = vector4 - vector;
                        vector5.y = 0f;
                        float num2 = Vector3.Dot(vector2, vector5);
                        if (num2 < 0f)
                        {
                            vector5 += vector2 * -num2;
                        }
                        vector5.Normalize();
                        HitData hitData = new HitData();
                        hitData.m_toolTier          = this.m_weapon.m_shared.m_toolTier;
                        hitData.m_statusEffect      = (this.m_weapon.m_shared.m_attackStatusEffect ? this.m_weapon.m_shared.m_attackStatusEffect.name : "");
                        hitData.m_pushForce         = this.m_weapon.m_shared.m_attackForce * randomSkillFactor * this.m_forceMultiplier;
                        hitData.m_backstabBonus     = this.m_weapon.m_shared.m_backstabBonus;
                        hitData.m_staggerMultiplier = this.m_staggerMultiplier;
                        hitData.m_dodgeable         = this.m_weapon.m_shared.m_dodgeable;
                        hitData.m_blockable         = this.m_weapon.m_shared.m_blockable;
                        hitData.m_skill             = this.m_weapon.m_shared.m_skillType;
                        hitData.m_damage.Add(this.m_weapon.GetDamage(), 1);
                        hitData.m_point       = vector4;
                        hitData.m_dir         = vector5;
                        hitData.m_hitCollider = collider;
                        hitData.SetAttacker(this.m_character);
                        hitData.m_damage.Modify(this.m_damageMultiplier);
                        hitData.m_damage.Modify(randomSkillFactor);
                        hitData.m_damage.Modify(this.GetLevelDamageFactor());
                        if (this.m_attackChainLevels > 1 && this.m_currentAttackCainLevel == this.m_attackChainLevels - 1 && this.m_lastChainDamageMultiplier > 1f)
                        {
                            hitData.m_damage.Modify(this.m_lastChainDamageMultiplier);
                            hitData.m_pushForce *= 1.2f;
                        }
                        this.m_character.GetSEMan().ModifyAttack(this.m_weapon.m_shared.m_skillType, ref hitData);
                        Character character = component as Character;
                        if (character)
                        {
                            if ((!this.m_character.IsPlayer() && !BaseAI.IsEnemy(this.m_character, character)) || (hitData.m_dodgeable && character.IsDodgeInvincible()))
                            {
                                goto IL_407;
                            }
                            flag2 = true;
                        }
                        component.Damage(hitData);
                        flag = true;
                    }
                    num++;
                    vector3 += vector4;
                }
            }
            IL_407 :;
        }
        if (num > 0)
        {
            vector3 /= (float)num;
            this.m_weapon.m_shared.m_hitEffect.Create(vector3, Quaternion.identity, null, 1f);
            this.m_hitEffect.Create(vector3, Quaternion.identity, null, 1f);
            if (this.m_weapon.m_shared.m_useDurability && this.m_character.IsPlayer())
            {
                this.m_weapon.m_durability -= 1f;
            }
            this.m_character.AddNoise(this.m_attackHitNoise);
            if (flag)
            {
                this.m_character.RaiseSkill(this.m_weapon.m_shared.m_skillType, flag2 ? 1.5f : 1f);
            }
        }
        if (this.m_spawnOnTrigger)
        {
            IProjectile component2 = UnityEngine.Object.Instantiate <GameObject>(this.m_spawnOnTrigger, vector, Quaternion.identity).GetComponent <IProjectile>();
            if (component2 != null)
            {
                component2.Setup(this.m_character, this.m_character.transform.forward, -1f, null, null);
            }
        }
    }
Beispiel #9
0
    // Token: 0x060002F0 RID: 752 RVA: 0x000180F0 File Offset: 0x000162F0
    private void FireProjectileBurst()
    {
        ItemDrop.ItemData ammoItem         = this.m_ammoItem;
        GameObject        attackProjectile = this.m_attackProjectile;
        float             num  = this.m_projectileVel;
        float             num2 = this.m_projectileVelMin;
        float             num3 = this.m_projectileAccuracy;
        float             num4 = this.m_projectileAccuracyMin;
        float             num5 = this.m_attackHitNoise;

        if (ammoItem != null && ammoItem.m_shared.m_attack.m_attackProjectile)
        {
            attackProjectile = ammoItem.m_shared.m_attack.m_attackProjectile;
            num  += ammoItem.m_shared.m_attack.m_projectileVel;
            num2 += ammoItem.m_shared.m_attack.m_projectileVelMin;
            num3 += ammoItem.m_shared.m_attack.m_projectileAccuracy;
            num4 += ammoItem.m_shared.m_attack.m_projectileAccuracyMin;
            num5 += ammoItem.m_shared.m_attack.m_attackHitNoise;
        }
        float num6 = this.m_character.GetRandomSkillFactor(this.m_weapon.m_shared.m_skillType);

        if (this.m_weapon.m_shared.m_holdDurationMin > 0f)
        {
            num3  = Mathf.Lerp(num4, num3, Mathf.Pow(this.m_attackDrawPercentage, 0.5f));
            num6 *= this.m_attackDrawPercentage;
            num   = Mathf.Lerp(num2, num, this.m_attackDrawPercentage);
        }
        Vector3 position;
        Vector3 vector;

        this.GetProjectileSpawnPoint(out position, out vector);
        Transform transform = this.m_character.transform;

        if (this.m_useCharacterFacing)
        {
            Vector3 forward = Vector3.forward;
            if (this.m_useCharacterFacingYAim)
            {
                forward.y = vector.y;
            }
            vector = transform.TransformDirection(forward);
        }
        if (this.m_launchAngle != 0f)
        {
            Vector3 axis = Vector3.Cross(Vector3.up, vector);
            vector = Quaternion.AngleAxis(this.m_launchAngle, axis) * vector;
        }
        for (int i = 0; i < this.m_projectiles; i++)
        {
            if (this.m_destroyPreviousProjectile && this.m_weapon.m_lastProjectile)
            {
                ZNetScene.instance.Destroy(this.m_weapon.m_lastProjectile);
                this.m_weapon.m_lastProjectile = null;
            }
            Vector3    vector2  = vector;
            Vector3    axis2    = Vector3.Cross(vector2, Vector3.up);
            Quaternion rotation = Quaternion.AngleAxis(UnityEngine.Random.Range(-num3, num3), Vector3.up);
            vector2 = Quaternion.AngleAxis(UnityEngine.Random.Range(-num3, num3), axis2) * vector2;
            vector2 = rotation * vector2;
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(attackProjectile, position, Quaternion.LookRotation(vector2));
            HitData    hitData    = new HitData();
            hitData.m_toolTier          = this.m_weapon.m_shared.m_toolTier;
            hitData.m_pushForce         = this.m_weapon.m_shared.m_attackForce * this.m_forceMultiplier;
            hitData.m_backstabBonus     = this.m_weapon.m_shared.m_backstabBonus;
            hitData.m_staggerMultiplier = this.m_staggerMultiplier;
            hitData.m_damage.Add(this.m_weapon.GetDamage(), 1);
            hitData.m_statusEffect = (this.m_weapon.m_shared.m_attackStatusEffect ? this.m_weapon.m_shared.m_attackStatusEffect.name : "");
            hitData.m_blockable    = this.m_weapon.m_shared.m_blockable;
            hitData.m_dodgeable    = this.m_weapon.m_shared.m_dodgeable;
            hitData.m_skill        = this.m_weapon.m_shared.m_skillType;
            hitData.SetAttacker(this.m_character);
            if (ammoItem != null)
            {
                hitData.m_damage.Add(ammoItem.GetDamage(), 1);
                hitData.m_pushForce += ammoItem.m_shared.m_attackForce;
                if (ammoItem.m_shared.m_attackStatusEffect != null)
                {
                    hitData.m_statusEffect = ammoItem.m_shared.m_attackStatusEffect.name;
                }
                if (!ammoItem.m_shared.m_blockable)
                {
                    hitData.m_blockable = false;
                }
                if (!ammoItem.m_shared.m_dodgeable)
                {
                    hitData.m_dodgeable = false;
                }
            }
            hitData.m_pushForce *= num6;
            hitData.m_damage.Modify(this.m_damageMultiplier);
            hitData.m_damage.Modify(num6);
            hitData.m_damage.Modify(this.GetLevelDamageFactor());
            this.m_character.GetSEMan().ModifyAttack(this.m_weapon.m_shared.m_skillType, ref hitData);
            IProjectile component = gameObject.GetComponent <IProjectile>();
            if (component != null)
            {
                component.Setup(this.m_character, vector2 * num, num5, hitData, this.m_weapon);
            }
            this.m_weapon.m_lastProjectile = gameObject;
        }
    }