Example #1
0
    public override GameObject adapt(GameObject entity)
    {
        if (thornBear)
        {
            // activate thorns
            foreach (EntityObjectIndicator eoi in entity.GetComponentsInChildren <EntityObjectIndicator>(true))
            {
                if (eoi.objectType == EntityObjectIndicator.EntityObjectType.Thorn)
                {
                    eoi.gameObject.SetActive(true);
                }
            }

            // change attack
            ThornTotemAttackMutator ttam = entity.AddComponent <ThornTotemAttackMutator>();
            ttam.singleProjectile          = true;
            ttam.firstProjectileIsAccurate = true;
            ttam.increasedDamage           = 3f;
            ttam.chanceForDoubleDamage     = ThornAttackChanceForDoubleDamage;
            ttam.chanceToShredArmour       = ThornAttackChanceToShredArmour;
            ttam.chanceToPoison            = thornPoisonChance;
            ttam.targetsToPierce           = thornAttackEnemiesToPierce;
        }

        if (retaliates)
        {
            ThornBurstMutator tbm = entity.AddComponent <ThornBurstMutator>();
            tbm.chanceToPoison = thornPoisonChance;
            tbm.chanceToBleed  = thornBurstBleedChance;
            tbm.addedSpeed     = thornBurstAddedSpeed;
        }

        if (clawTotemOnKillChance > 0)
        {
            ChanceToCastOnKill ctcok = entity.AddComponent <ChanceToCastOnKill>();
            ctcok.summonerCasts = true;
            ctcok.castChance    = clawTotemOnKillChance;
            ctcok.ability       = AbilityIDList.getAbility(AbilityID.summonClawTotem);
        }


        if (swipes)
        {
            SwipeMutator sm = entity.AddComponent <SwipeMutator>();
            sm.addedPhysicalDamage = 32;
        }

        return(base.adapt(entity));
    }
Example #2
0
    public override void updateMutator()
    {
        ThornBurstMutator mutator                = PlayerFinder.getPlayer().GetComponent <ThornBurstMutator>();
        float             chanceToPoison         = 0f;
        float             chanceToBleed          = 0f;
        float             extraProjectilesChance = 0f;
        float             pierceChance           = 0f;
        float             reducedSpread          = 0f;
        float             addedSpeed             = 0f;
        bool  thornShield                              = false;
        float addedShieldDuration                      = 0f;
        float chanceOfRecreatingThornShield            = 0f;
        bool  thornShieldAiming                        = false;
        bool  canCastOnAllies                          = false;
        float castWhenHitChance                        = 0f;
        float increasedDamage                          = 0f;
        float thornTrailOnKillChance                   = 0f;
        float sunderingThornsOnHitChance               = 0f;
        float increasedSunderingThornsCooldownRecovery = 0f;

        foreach (SkillTreeNode node in GetComponentsInChildren <SkillTreeNode>())
        {
            if (node.name == "Thorn Burst Skill Tree Poison Chance")
            {
                chanceToPoison += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
            }
            if (node.name == "Thorn Burst Skill Tree Extra Projectiles Chance")
            {
                extraProjectilesChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.34f;
            }
            if (node.name == "Thorn Burst Skill Tree Pierce Chance")
            {
                pierceChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
            }
            if (node.name == "Thorn Burst Skill Tree Reduced Spread")
            {
                reducedSpread += node.GetComponent <SkillTreeNode>().pointsAllocated * 20f;
            }
            if (node.name == "Thorn Burst Skill Tree Added Speed")
            {
                addedSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * 1.8f;
            }
            if (node.name == "Thorn Burst Skill Tree Thorn Shield")
            {
                thornShield = (node.GetComponent <SkillTreeNode>().pointsAllocated > 0);
            }
            if (node.name == "Thorn Burst Skill Tree Added Shield Duration")
            {
                addedShieldDuration += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.3f;
            }
            if (node.name == "Thorn Burst Skill Tree Recreation Chance")
            {
                chanceOfRecreatingThornShield += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.1f;
            }
            if (node.name == "Thorn Burst Skill Tree Shield Aiming")
            {
                thornShieldAiming = (node.GetComponent <SkillTreeNode>().pointsAllocated > 0);
                reducedSpread    += node.GetComponent <SkillTreeNode>().pointsAllocated * 20f;
            }
            if (node.name == "Thorn Burst Skill Tree Cast On Allies")
            {
                canCastOnAllies = (node.GetComponent <SkillTreeNode>().pointsAllocated > 0);
            }
            if (node.name == "Thorn Burst Skill Tree Cast When Hit")
            {
                castWhenHitChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.1f;
            }
            if (node.name == "Thorn Burst Skill Tree Damage and Cast When Hit")
            {
                castWhenHitChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.05f;
                increasedDamage   += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.05f;
            }
            if (node.name == "Thorn Burst Thorn Trail")
            {
                thornTrailOnKillChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.25f;
                increasedDamage        += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.2f;
            }
            if (node.name == "Thorn Burst Sundering Thorns")
            {
                sunderingThornsOnHitChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.07f;
            }
            if (node.name == "Thorn Burst Sundering Thorns Cooldown")
            {
                increasedSunderingThornsCooldownRecovery += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.35f;
            }
            if (node.name == "Thorn Burst Bleed Chance")
            {
                chanceToBleed   += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.1f;
                increasedDamage += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.1f;
            }
        }
        mutator.chanceToPoison                           = chanceToPoison;
        mutator.extraProjectilesChance                   = extraProjectilesChance;
        mutator.pierceChance                             = pierceChance;
        mutator.reducedSpread                            = reducedSpread;
        mutator.addedSpeed                               = addedSpeed;
        mutator.thornShield                              = thornShield;
        mutator.addedShieldDuration                      = addedShieldDuration;
        mutator.chanceOfRecreatingThornShield            = chanceOfRecreatingThornShield;
        mutator.thornShieldAiming                        = thornShieldAiming;
        mutator.canCastOnAllies                          = canCastOnAllies;
        mutator.castWhenHitChance                        = castWhenHitChance;
        mutator.increasedDamage                          = increasedDamage;
        mutator.thornTrailOnKillChance                   = thornTrailOnKillChance;
        mutator.sunderingThornsOnHitChance               = sunderingThornsOnHitChance;
        mutator.increasedSunderingThornsCooldownRecovery = increasedSunderingThornsCooldownRecovery;
        mutator.chanceToBleed                            = chanceToBleed;
    }
Example #3
0
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        // if this skill casts a thorn shield that casts thorn burst then different things needs to be done to it
        if (thornShield)
        {
            // switch the ability object for a thorn shield
            Destroy(abilityObject);
            abilityObject = Instantiate(AbilityIDList.getAbility(AbilityID.thornShield).abilityPrefab, location, Quaternion.Euler(targetLocation - location));

            // the thorn shield's thorn burst mutator must be given the correct values
            ThornBurstMutator thornShieldMutator = abilityObject.GetComponent <ThornBurstMutator>();
            if (thornShieldMutator)
            {
                thornShieldMutator.extraProjectilesChance        = extraProjectilesChance;
                thornShieldMutator.chanceToPoison                = chanceToPoison;
                thornShieldMutator.pierceChance                  = pierceChance;
                thornShieldMutator.reducedSpread                 = reducedSpread;
                thornShieldMutator.addedSpeed                    = addedSpeed;
                thornShieldMutator.thornShieldAiming             = thornShieldAiming;
                thornShieldMutator.addedShieldDuration           = addedShieldDuration;
                thornShieldMutator.chanceOfRecreatingThornShield = chanceOfRecreatingThornShield;
                thornShieldMutator.increasedDamage               = increasedDamage;
                thornShieldMutator.chanceToBleed                 = chanceToBleed;
                thornShieldMutator.thornShield                   = false;

                if (chanceOfRecreatingThornShield > 0)
                {
                    float rand = Random.Range(0f, 1f);
                    if (rand < chanceOfRecreatingThornShield)
                    {
                        thornShieldMutator.thisShieldRecreatesItself = true;
                    }
                    else
                    {
                        thornShieldMutator.thisShieldRecreatesItself = false;
                    }
                }
            }

            if (addedShieldDuration > 0)
            {
                if (abilityObject.GetComponent <DestroyAfterDuration>())
                {
                    abilityObject.GetComponent <DestroyAfterDuration>().duration += addedShieldDuration;
                }
            }

            // if the caster can cast on allies or this is a shield
            if (canCastOnAllies || (GetComponent <BuffParent>() && transform.parent))
            {
                abilityObject.GetComponent <AttachToCreatorOnCreation>().runOnCreation = false;
                AttachToNearestAllyOnCreation attachToAlly = abilityObject.AddComponent <AttachToNearestAllyOnCreation>();
                attachToAlly.replaceExistingBuff = false;
                attachToAlly.displacement        = abilityObject.GetComponent <AttachToCreatorOnCreation>().displacement;
                abilityObject.AddComponent <StartsAtTarget>();
            }

            return(abilityObject);
        }

        // only do this if the caster is a shield
        changeTargetLocation = false;
        if (GetComponent <BuffParent>() && transform.parent)
        {
            if (thornShieldAiming)
            {
                changeTargetLocation = true;
                newTargetLocation    = transform.position + transform.parent.forward;
            }

            if (thisShieldRecreatesItself)
            {
                thornShield = true;
                GetComponent <AbilityObjectConstructor>().constructAbilityObject(ability, location, targetLocation, null, false);
                thornShield = false;
            }

            // reduce the delay on the extra projectiles, otherwise it looks unnatural because their cast point does not move
            ExtraProjectiles extraProj = abilityObject.GetComponent <ExtraProjectiles>();
            if (extraProj)
            {
                extraProj.delayWindow = 0.05f;
            }
        }

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

        if (chanceToPoison > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Poison);
            newComponent.chance       = chanceToPoison;
        }

        if (chanceToBleed > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Bleed);
            newComponent.chance       = chanceToBleed;
        }

        if (pierceChance > 0)
        {
            float rand = Random.Range(0f, 1f);
            if (rand < pierceChance)
            {
                Pierce pierce = abilityObject.GetComponent <Pierce>();
                if (pierce == null)
                {
                    pierce = abilityObject.AddComponent <Pierce>(); pierce.objectsToPierce = 0;
                }
                pierce.objectsToPierce += 100;
            }
        }

        if (reducedSpread != 0)
        {
            ExtraProjectiles extraProjectilesObject = abilityObject.GetComponent <ExtraProjectiles>();
            if (extraProjectilesObject == null)
            {
                extraProjectilesObject = abilityObject.AddComponent <ExtraProjectiles>(); extraProjectilesObject.numberOfExtraProjectiles = 0;
            }
            extraProjectilesObject.angle -= reducedSpread;
        }

        if (extraProjectilesChance != 0)
        {
            float rand = Random.Range(0f, 1f);
            if (rand < extraProjectilesChance)
            {
                ExtraProjectiles extraProjectilesObject = abilityObject.GetComponent <ExtraProjectiles>();
                if (extraProjectilesObject == null)
                {
                    extraProjectilesObject = abilityObject.AddComponent <ExtraProjectiles>(); extraProjectilesObject.numberOfExtraProjectiles = 0;
                }
                extraProjectilesObject.numberOfExtraProjectiles += 6;
            }
        }

        if (addedSpeed > 0)
        {
            abilityObject.GetComponent <AbilityMover>().speed += addedSpeed;
        }

        return(abilityObject);
    }