示例#1
0
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        if (extraProjectiles > 0 && !spiralMovement)
        {
            foreach (DamageEnemyOnHit component in abilityObject.GetComponents <DamageEnemyOnHit>())
            {
                component.canDamageSameEnemyAgain = false;
            }
        }

        if (chains > 0)
        {
            ChainOnHit chain = abilityObject.AddComponent <ChainOnHit>();
            chain.chainsRemaining          = chains;
            chain.abilityToChain           = ability;
            chain.range                    = 8f;
            chain.destroyAfterChainAttempt = true;
            chain.cannotHitSame            = true;
            chain.offset                   = new Vector3(0f, 1.2f, 0f);
        }

        if (chains > 0 || hasChained)
        {
            // add a copy of this mutator to the ability object, but remove the chains (because it will chain anyway), the increased damage to first enemy hit, and the on cast stuff
            HammerThrowMutator newMutator = Comp <HammerThrowMutator> .GetOrAdd(abilityObject);

            newMutator.chains            = 0;
            newMutator.increasedDamage   = increasedDamage;
            newMutator.extraProjectiles  = 0;
            newMutator.armourShredChance = 0f;

            newMutator.noPierce = noPierce;
            newMutator.chanceForDoubleDamage    = chanceForDoubleDamage;
            newMutator.increasedDamage          = increasedDamage;
            newMutator.moreDamageAgainstStunned = moreDamageAgainstStunned;

            newMutator.spiralMovement = false;

            newMutator.aoeVoidDamage          = aoeVoidDamage;
            newMutator.increasedAoEBaseDamage = increasedAoEBaseDamage;

            newMutator.increasedProjectileSpeed = increasedProjectileSpeed;
            newMutator.increasedStunChance      = increasedStunChance;
            newMutator.moreDamage = moreDamage;
            newMutator.noReturn   = true;
            newMutator.canDamageSameEnemyAgain = false;
            newMutator.hasChained = true;
        }

        if (noReturn)
        {
            DestroyAfterDuration        dad       = abilityObject.GetComponent <DestroyAfterDuration>();
            ReturnToCasterAfterDuration component = abilityObject.GetComponent <ReturnToCasterAfterDuration>();
            component.duration = 10000f;
            if (spiralMovement)
            {
                dad.duration = 6f;
            }
            else
            {
                dad.duration = 2.5f;
            }
            if (!hasChained)
            {
                abilityObject.AddComponent <DestroyOnInanimateCollison>();
                ReturnOnInanimateCollision ret = abilityObject.GetComponent <ReturnOnInanimateCollision>();
                if (ret)
                {
                    Destroy(ret);
                }
            }
        }

        // aoe void damage
        if (aoeVoidDamage)
        {
            foreach (Transform child in abilityObject.GetComponentsInChildren <Transform>(true))
            {
                if (child.name == "aura")
                {
                    child.gameObject.SetActive(true);
                }
            }
            RepeatedlyDamageEnemiesWithinRadius repeatDamage = abilityObject.GetComponent <RepeatedlyDamageEnemiesWithinRadius>();
            if (repeatDamage == null)
            {
                repeatDamage = abilityObject.AddComponent <RepeatedlyDamageEnemiesWithinRadius>();
            }
            if (repeatDamage.baseDamageStats.damage == null)
            {
                repeatDamage.baseDamageStats.damage = new List <DamageStatsHolder.DamageTypesAndValues>();
            }
            repeatDamage.addBaseDamage(DamageType.VOID, 6f * (1 + increasedAoEBaseDamage));
            repeatDamage.damageInterval = 0.5f;
            repeatDamage.radius         = 1.5f;
            repeatDamage.baseDamageStats.addedDamageScaling = 0.2f;
            repeatDamage.tags.Add(Tags.AbilityTags.AoE);
            repeatDamage.tags.Add(Tags.AbilityTags.Throwing);
            repeatDamage.tags.Add(Tags.AbilityTags.DoT);
        }

        // add extra projectiles
        if (extraProjectiles != 0)
        {
            ExtraProjectiles extraProjectilesObject = abilityObject.GetComponent <ExtraProjectiles>();
            if (extraProjectilesObject == null)
            {
                extraProjectilesObject = abilityObject.AddComponent <ExtraProjectiles>(); extraProjectilesObject.numberOfExtraProjectiles = 0;
            }
            extraProjectilesObject.numberOfExtraProjectiles += extraProjectiles;
            if (projectileNova)
            {
                extraProjectilesObject.angle = 144f;
                if (extraProjectiles >= 6)
                {
                    extraProjectilesObject.angle = 160;
                }
            }
        }

        // remove pierce
        if (noPierce && chains <= 0 && !hasChained)
        {
            Pierce pierce = abilityObject.GetComponent <Pierce>();
            if (pierce == null)
            {
                pierce = abilityObject.AddComponent <Pierce>(); pierce.objectsToPierce = 0;
            }
            if (chains <= 0 && !hasChained)
            {
                abilityObject.AddComponent <DestroyOnFailingToPierceEnemy>();
            }
        }

        // add chance to shred armour
        if (armourShredChance > 0)
        {
            ChanceToApplyStatusOnEnemyHit chanceTo = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            chanceTo.chance       = armourShredChance;
            chanceTo.statusEffect = StatusEffectList.getEffect(StatusEffectID.ArmourShred);
        }

        if (increasedStunChance != 0)
        {
            foreach (DamageStatsHolder damage in abilityObject.GetComponents <DamageStatsHolder>())
            {
                damage.baseDamageStats.increasedStunChance += increasedStunChance;
            }
        }

        if (increasedDamage != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(increasedDamage);
            }
        }

        if (moreDamage != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(moreDamage);
            }
        }

        if (chanceForDoubleDamage > 0)
        {
            float rand = Random.Range(0f, 1f);
            if (rand < chanceForDoubleDamage)
            {
                foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
                {
                    for (int i = 0; i < holder.baseDamageStats.damage.Count; i++)
                    {
                        holder.addBaseDamage(holder.baseDamageStats.damage[i].damageType, holder.getBaseDamage(holder.baseDamageStats.damage[i].damageType));
                    }
                }
            }
        }

        if (moreDamageAgainstStunned != 0)
        {
            // create the conditional
            DamageConditionalEffect conditionalEffect = new DamageConditionalEffect();
            StunnedConditional      conditional       = new StunnedConditional();
            conditionalEffect.conditional = conditional;
            conditionalEffect.effect      = new DamageEffectMoreDamage(moreDamageAgainstStunned);
            // add the conditional to all damage stats holders
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.baseDamageStats.conditionalEffects.Add(conditionalEffect);
            }
        }

        if (increasedProjectileSpeed != 0)
        {
            AbilityMover mover = abilityObject.GetComponent <AbilityMover>();
            mover.speed *= (1 + increasedProjectileSpeed);
        }

        if (spiralMovement)
        {
            SpiralMovement spira = abilityObject.AddComponent <SpiralMovement>();
            spira.constantVelocity      = SpiralMovement.ConstantType.BothAreMaxima;
            spira.tangentialVelocity    = 5.3f * (1 + increasedProjectileSpeed);
            spira.angleChangedPerSecond = 157f * (1 + increasedProjectileSpeed);
            spira.outwardSpeed          = 1.15f;
            spira.outwardDistance       = 0.6f;

            AbilityMover mover = abilityObject.GetComponent <AbilityMover>();
            mover.speed = 0;

            if (centreOnCaster)
            {
                spira.centreOnCaster      = true;
                spira.offsetFromTransform = new Vector3(0f, 1.2f, 0f);
            }

            if (extraProjectiles > 0)
            {
                spira.randomStartAngle = true;
            }
        }



        return(abilityObject);
    }
示例#2
0
    public override void updateMutator()
    {
        HammerThrowMutator mutator = PlayerFinder.getPlayer().GetComponent <HammerThrowMutator>();

        int   extraProjectiles  = 0;
        float armourShredChance = 0f;

        bool  noPierce                 = false;
        float increasedAttackSpeed     = 0f;
        float chanceForDoubleDamage    = 0f;
        float increasedDamage          = 0f;
        float moreDamageAgainstStunned = 0f;

        bool freeWhenOutOfMana = false;
        bool centreOnCaster    = false;
        bool spiralMovement    = false;

        float healthGainOnHit = 0f;
        float manaGainOnHit   = 0f;

        bool  aoeVoidDamage          = false;
        float increasedAoEBaseDamage = 0f;

        float increasedProjectileSpeed = 0f;
        bool  projectileNova           = false;

        int   chains            = 0;
        float increasedManaCost = 0f;
        float manaEfficiency    = 0f;

        bool  cooldown            = false;
        int   addedCharges        = 0;
        float increasedStunChance = 0f;
        float moreDamage          = 0f;
        bool  noReturn            = false;

        foreach (SkillTreeNode node in GetComponentsInChildren <SkillTreeNode>())
        {
            if (node.name == "Hammer Throw Tree Attack Speed")
            {
                increasedAttackSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.06f;
            }
            if (node.name == "Hammer Throw Tree Damage vs Proj Speed")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    increasedDamage          += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
                    increasedProjectileSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.1f;
                }
            }
            if (node.name == "Hammer Throw Tree Mana Efficiency")
            {
                manaEfficiency += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.3f;
            }
            if (node.name == "Hammer Throw Tree Free When Out of Mana")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    increasedDamage  += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.2f;
                    freeWhenOutOfMana = true;
                }
            }
            if (node.name == "Hammer Throw Tree Shreds Armour")
            {
                armourShredChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.1f;
            }
            if (node.name == "Hammer Throw Tree Void Damage In Aoe")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    increasedAttackSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.2f;
                    aoeVoidDamage         = true;
                }
            }
            if (node.name == "Hammer Throw Tree More Aoe Damage")
            {
                increasedAoEBaseDamage += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.25f;
            }
            if (node.name == "Hammer Throw Tree Stun Chance")
            {
                increasedStunChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
            }
            if (node.name == "Hammer Throw Tree Stun Chance vs Pierce")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    increasedStunChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.6f;
                    noPierce             = true;
                }
            }
            if (node.name == "Hammer Throw Tree Stun Chain")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    increasedStunChance += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.6f;
                    moreDamage          += -0.3f;
                    chains  += 1;
                    noReturn = true;
                }
            }
            if (node.name == "Hammer Throw Tree Additional Chain")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    increasedAttackSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.1f;
                    increasedDamage       = node.GetComponent <SkillTreeNode>().pointsAllocated * -0.1f;
                    chains += node.GetComponent <SkillTreeNode>().pointsAllocated * 1;
                }
            }
            if (node.name == "Hammer Throw Tree Damage To Stunned")
            {
                moreDamageAgainstStunned += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.25f;
            }
            if (node.name == "Hammer Throw Tree Health On Hit")
            {
                healthGainOnHit += node.GetComponent <SkillTreeNode>().pointsAllocated * 1f;
            }
            if (node.name == "Hammer Throw Tree Mana On Hit")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    manaGainOnHit += 3f;
                    cooldown       = true;
                }
            }
            if (node.name == "Hammer Throw Tree Projectile Speed")
            {
                increasedProjectileSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.15f;
            }
            if (node.name == "Hammer Throw Tree No Return")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    noReturn = true;
                    chanceForDoubleDamage += 0.3f;
                }
            }
            if (node.name == "Hammer Throw Tree Extra Projectiles")
            {
                extraProjectiles += node.GetComponent <SkillTreeNode>().pointsAllocated * 2;
                increasedDamage  += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.2f;
            }
            if (node.name == "Hammer Throw Tree Nova Projectiles")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    extraProjectiles *= 2;
                    projectileNova    = true;
                }
            }
            if (node.name == "Hammer Throw Tree Spirals")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    chanceForDoubleDamage -= 0.15f;
                    extraProjectiles       = Mathf.CeilToInt(extraProjectiles * 0.5f);
                    spiralMovement         = true;
                }
            }
            if (node.name == "Hammer Throw Tree Moves With Caster")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    chanceForDoubleDamage -= 0.15f;
                    centreOnCaster         = true;
                }
            }
        }


        if (cooldown)
        {
            mutator.addedCharges     = 1 + addedCharges;
            mutator.addedChargeRegen = 0.25f;
        }
        else
        {
            mutator.addedCharges     = 0;
            mutator.addedChargeRegen = 0;
        }

        if (spiralMovement && projectileNova)
        {
            extraProjectiles = Mathf.CeilToInt(extraProjectiles * 0.5f);
        }

        mutator.extraProjectiles  = extraProjectiles;
        mutator.armourShredChance = armourShredChance;

        mutator.noPierce                 = noPierce;
        mutator.increasedAttackSpeed     = increasedAttackSpeed;
        mutator.chanceForDoubleDamage    = chanceForDoubleDamage;
        mutator.increasedDamage          = increasedDamage;
        mutator.moreDamageAgainstStunned = moreDamageAgainstStunned;

        mutator.freeWhenOutOfMana = freeWhenOutOfMana;
        mutator.centreOnCaster    = centreOnCaster;
        mutator.spiralMovement    = spiralMovement;

        mutator.healthGainOnHit = healthGainOnHit;
        mutator.manaGainOnHit   = manaGainOnHit;

        mutator.aoeVoidDamage          = aoeVoidDamage;
        mutator.increasedAoEBaseDamage = increasedAoEBaseDamage;

        mutator.increasedProjectileSpeed = increasedProjectileSpeed;
        mutator.projectileNova           = projectileNova;

        mutator.chains = chains;

        mutator.increasedManaCost    = increasedManaCost;
        mutator.addedManaCostDivider = manaEfficiency;
        mutator.increasedStunChance  = increasedStunChance;
        mutator.moreDamage           = moreDamage;
        mutator.noReturn             = noReturn;
    }