// Update is called once per frame void Update() { if (sceneLoader) { // this happens when loading starts if (sceneLoader.sceneLoading && !summonsAreChildren) { summonsAreChildren = true; SummonTracker tracker = GetComponent <SummonTracker>(); if (tracker) { // make all summons children of the player so that they become persistent for (int i = 0; i < tracker.summons.Count; i++) //foreach (Summoned summon in tracker.summons) { // don't add dying summons if (!Dying.isDying(tracker.summons[i].gameObject)) { tracker.summons[i].transform.parent = transform; } // delete old dying summons else { Destroy(tracker.summons[i]); } } } } // this happens once a scene has loaded if (!sceneLoader.sceneLoading && summonsAreChildren) { summonsAreChildren = false; SummonTracker tracker = GetComponent <SummonTracker>(); if (tracker) { // put all the summons at the players position and set their parent to null foreach (Summoned summon in tracker.summons) { // do not set their parent to null if they attach to the parent if (!summon.GetComponent <AttachToSummoner>()) { bool navmeshEnabled = false; NavMeshAgent agent = summon.GetComponent <NavMeshAgent>(); if (agent) { navmeshEnabled = agent.enabled; agent.enabled = false; } summon.transform.position = transform.position + randomPositionOnRing(0.5f); summon.transform.parent = null; if (agent && navmeshEnabled) { agent.enabled = true; } } } } } } }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.summonWraith); health = GetComponent <BaseHealth>(); mana = GetComponent <BaseMana>(); if (health) { statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject); tracker = Comp <SummonTracker> .GetOrAdd(gameObject); AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject); listener.onCritEvent += OnCrit; } // get wraith prefabs if (flameWraithPrefab == null) { Ability wraithAbility = Ability.getAbility(AbilityID.summonFlameWraith); if (wraithAbility && wraithAbility.abilityPrefab) { SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>(); if (summon) { flameWraithPrefab = summon.entity; } } wraithAbility = Ability.getAbility(AbilityID.summonPutridWraith); if (wraithAbility && wraithAbility.abilityPrefab) { SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>(); if (summon) { putridWraithPrefab = summon.entity; } } wraithAbility = Ability.getAbility(AbilityID.summonBloodWraith); if (wraithAbility && wraithAbility.abilityPrefab) { SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>(); if (summon) { bloodWraithPrefab = summon.entity; } } } // spirit escape prefab if (spiritEscapePrefab == null) { spiritEscapePrefab = PrefabList.getPrefab("spiritEscape"); } base.Awake(); }
public void initialise() { if (!tracker && references && references.creator) { tracker = references.creator.GetComponent <SummonTracker>(); if (!tracker) { tracker = references.creator.AddComponent <SummonTracker>(); } tracker.AddSummon(this); } }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.ripBlood); AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject); listener.onHitEvent += OnHit; listener.onKillEvent += OnKill; statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject); tracker = Comp <SummonTracker> .GetOrAdd(gameObject); aoc = Comp <AbilityObjectConstructor> .GetOrAdd(gameObject); mana = GetComponent <BaseMana>(); baseStats = GetComponent <BaseStats>(); base.Awake(); }
public SummonTracker GetSummonTracker() { if (tracker) { return(tracker); } else if (!tracker && references && references.creator) { tracker = references.creator.GetComponent <SummonTracker>(); if (!tracker) { tracker = references.creator.AddComponent <SummonTracker>(); } tracker.AddSummon(this); return(tracker); } return(null); }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.sacrifice); dotTag.Add(Tags.AbilityTags.DoT); AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject); listener.onKillEvent += OnKill; BaseHealth health = GetComponent <BaseHealth>(); if (health) { statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject); tracker = Comp <SummonTracker> .GetOrAdd(gameObject); } aoc = Comp <AbilityObjectConstructor> .GetOrAdd(gameObject); mana = GetComponent <BaseMana>(); baseStats = GetComponent <BaseStats>(); boneNovaOffset = new Vector3(0f, 1.2f, 0f); base.Awake(); }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.marrowShards); physTag.Add(Tags.AbilityTags.Physical); AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject); listener.onKillEvent += OnKill; listener.onCritEvent += OnCrit; health = GetComponent <BaseHealth>(); if (health) { statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject); tracker = Comp <SummonTracker> .GetOrAdd(gameObject); } aoc = Comp <AbilityObjectConstructor> .GetOrAdd(gameObject); mana = GetComponent <BaseMana>(); baseStats = GetComponent <BaseStats>(); boneNovaOffset = new Vector3(0f, 1.2f, 0f); spiritEscapeOffset = new Vector3(0f, 1.1f, 0f); spiritEscapePrefab = PrefabList.getPrefab("spiritEscape"); base.Awake(); }
public void Start() { if (transform.parent) { CreationReferences references = GetComponent <CreationReferences>(); if (references && references.creator) { SummonTracker tracker = references.creator.GetComponent <SummonTracker>(); { if (tracker) { foreach (Summoned summon in tracker.summons) { TargetFinder tf = summon.GetComponent <TargetFinder>(); if (tf) { tf.preferredTarget = transform.parent.gameObject; } } } } } } }
// Use this for initialization public override void onCreation() { bool success = false; CreationReferences references = GetComponent <CreationReferences>(); if (!references || !references.creator) { if (destroyIfFailedToMove) { SelfDestroyer dest = Comp <SelfDestroyer> .GetOrAdd(gameObject); dest.failedAbility = true; dest.die(); } return; } SummonTracker tracker = references.creator.GetComponent <SummonTracker>(); if (!tracker) { if (destroyIfFailedToMove) { SelfDestroyer dest = Comp <SelfDestroyer> .GetOrAdd(gameObject); dest.failedAbility = true; dest.die(); } return; } // find a lit of summon List <Summoned> summons = new List <Summoned>(); foreach (Summoned summoned in tracker.summons) { if (summoned) { summons.Add(summoned); } } // remove inactive objects from the list for (int i = summons.Count - 1; i >= 0; i--) { if (!summons[i].gameObject.activeSelf) { summons.Remove(summons[i]); } } // remove dying objects from the list if (requiredLifeState == lifeState.alive) { for (int i = summons.Count - 1; i >= 0; i--) { if (summons[i].GetComponent <Dying>() != null) { if (summons[i].GetComponent <StateController>().currentState == summons[i].GetComponent <StateController>().dying) { summons.Remove(summons[i]); } } } } // or remove living objects from the list else if (requiredLifeState == lifeState.dead) { for (int i = summons.Count - 1; i >= 0; i--) { if (summons[i].GetComponent <Dying>() != null) { if (summons[i].GetComponent <StateController>().currentState != summons[i].GetComponent <StateController>().dying) { summons.Remove(summons[i]); } } else { summons.Remove(summons[i]); } } } if (summons.Count == 0) { if (destroyIfFailedToMove) { SelfDestroyer dest = Comp <SelfDestroyer> .GetOrAdd(gameObject); dest.failedAbility = true; dest.die(); } return; } else { // find the nearest summon Summoned nearest = summons[0]; float distance = Vector3.Distance(transform.position, nearest.transform.position); foreach (Summoned summon in summons) { if (Vector3.Distance(transform.position, summon.transform.position) < distance) { nearest = summon; distance = Vector3.Distance(transform.position, summon.transform.position); } } // move to the summon's location transform.position = nearest.transform.position; // change to the summon's rotation transform.rotation = nearest.transform.rotation; success = true; if (kill) { Dying dying = nearest.GetComponent <Dying>(); if (dying) { if (eraseCorpse) { dying.setDelays(0.01f, 0.02f); } dying.myHealth.HealthDamage(dying.myHealth.maxHealth * 200); } } } if (destroyIfFailedToMove && success == false) { SelfDestroyer dest = Comp <SelfDestroyer> .GetOrAdd(gameObject); dest.failedAbility = true; dest.die(); } }
public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation) { if (castsLightning) { RepeatedlyCastAtNearestEnemyWithinRadius cast = abilityObject.AddComponent <RepeatedlyCastAtNearestEnemyWithinRadius>(); cast.abilityToCast = AbilityIDList.getAbility(AbilityID.furyLeapLightning); cast.castInterval = lightningInterval; cast.radius = 3f; } if (movespeedOnLanding != 0) { BuffCreatorOnDeath buff = abilityObject.AddComponent <BuffCreatorOnDeath>(); abilityObject.AddComponent <BuffCreatorOnDeath>().addBuffToList(Tags.Properties.Movespeed, 0f, movespeedOnLanding, null, null, 3f, null, "FuryLeapMoveSpeed"); } if (attackAndCastSpeedOnLanding != 0) { BuffCreatorOnDeath buff = abilityObject.AddComponent <BuffCreatorOnDeath>(); buff.addBuffToList(Tags.Properties.AttackSpeed, 0f, attackAndCastSpeedOnLanding, null, null, 3f, null, "FuryLeapAttackSpeed"); buff.addBuffToList(Tags.Properties.CastSpeed, 0f, attackAndCastSpeedOnLanding, null, null, 3f, null, "FuryLeapCastSpeed"); } if (eligiblePetsJumpToo) { SummonTracker summonTracker = GetComponent <SummonTracker>(); if (summonTracker) { foreach (Summoned summon in summonTracker.summons) { if (summon.GetComponent <CanJump>() && summon.GetComponent <UsingAbility>() && summon.GetComponent <StateController>() && summon.GetComponent <StateController>().currentState&& summon.GetComponent <StateController>().currentState.priority < 60) { summon.GetComponent <UsingAbility>().UseAbility(AbilityIDList.getAbility(AbilityID.furyLeap), targetLocation, false, false); } } } } FuryLeapAoeMutator flam = abilityObject.AddComponent <FuryLeapAoeMutator>(); flam.increasedDamage = increasedDamage; flam.increasedRadius = increasedRadius; flam.increasedStunChance = increasedStunChance; flam.moreDamageAgainstFullHealth = moreDamageAgainstFullHealth; flam.addedCritMultiplier = addedCritMultiplier; if (chanceToPull > 0) { float rand = Random.Range(0f, 1f); if (rand < chanceToPull) { abilityObject.AddComponent <CreateAbilityObjectOnDeath>().abilityToInstantiate = AbilityIDList.getAbility(AbilityID.bigPull); } } if (chanceToSummonVinesAtStart > 0) { float rand = Random.Range(0f, 1f); if (rand < chanceToSummonVinesAtStart) { GetComponent <UsingAbility>().UseAbility(AbilityIDList.getAbility(AbilityID.summonVines), transform.position, false, false); } } if (chanceToSummonVinesAtEnd > 0) { float rand = Random.Range(0f, 1f); if (rand < chanceToSummonVinesAtStart) { abilityObject.AddComponent <CreateAbilityObjectOnDeath>().abilityToInstantiate = AbilityIDList.getAbility(AbilityID.summonVines); } } return(abilityObject); }
public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation) { if (increasedRadius != 0) { foreach (CreateOnDeath cod in abilityObject.GetComponents <CreateOnDeath>()) { cod.increasedRadius = increasedRadius; cod.increasedHeight = increasedRadius; } foreach (CapsuleCollider col in abilityObject.GetComponents <CapsuleCollider>()) { col.height *= (1 + increasedRadius); col.radius *= (1 + increasedRadius); } } if (necrotic) { // replace vfx CreateOnDeath cod = abilityObject.GetComponent <CreateOnDeath>(); if (cod && cod.objectsToCreateOnDeath != null && cod.objectsToCreateOnDeath.Count > 0) { cod.objectsToCreateOnDeath[0] = new CreateOnDeath.GameObjectHolder(PrefabList.getPrefab("NecroticBloodSplatterOnDeathVFX")); } // convert damage foreach (DamageStatsHolder damage in abilityObject.GetComponents <DamageStatsHolder>()) { damage.convertAllDamageOfType(DamageType.PHYSICAL, DamageType.NECROTIC); } } if (chanceToPoison > 0) { ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>(); newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Poison); newComponent.chance = chanceToPoison; } if (armourReductionChance > 0 && Random.Range(0f, 1f) < armourReductionChance) { DebuffOnEnemyHit component = abilityObject.AddComponent <DebuffOnEnemyHit>(); if (reducesDarkProtectionInstead) { if (armourReductionStacks) { component.addDebuffToList(Tags.Properties.DarkProtection, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration)); } else { component.addDebuffToList(Tags.Properties.DarkProtection, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration), null, "blood splatter armour reduction"); } } else { if (armourReductionStacks) { component.addDebuffToList(Tags.Properties.Armour, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration)); } else { component.addDebuffToList(Tags.Properties.Armour, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration), null, "blood splatter armour reduction"); } } } if (minionBuffs != null && minionBuffs.Count > 0) { string buffName = "blood splatter buff"; BuffOnAllyHit component = abilityObject.AddComponent <BuffOnAllyHit>(); component.onlyApplyToCreatorsMinions = true; for (int i = 0; i < minionBuffs.Count; i++) { string fullBuffName = buffName + minionBuffs[i].property; foreach (Tags.AbilityTags _tag in minionBuffs[i].tagList) { fullBuffName += _tag; } component.addBuffToList(minionBuffs[i].property, minionBuffs[i].addedValue, minionBuffs[i].increasedValue, minionBuffs[i].moreValues, minionBuffs[i].quotientValues, 4f, minionBuffs[i].tagList, fullBuffName); } } if (increasedStunChance != 0) { foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>()) { holder.baseDamageStats.increasedStunChance += increasedStunChance; } } // increase damage based on the number of minions float realIncreasedDamage = increasedDamage; if (increasedDamagePerMinion != 0) { if (references && references.creator) { SummonTracker tracker = references.creator.GetComponent <SummonTracker>(); if (tracker && tracker.summons != null) { realIncreasedDamage += increasedDamagePerMinion * tracker.summons.Count; } } } if (realIncreasedDamage != 0) { foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>()) { holder.increaseAllDamage(realIncreasedDamage); } } if (moreDamageInstances != null && moreDamageInstances.Count > 0) { float moreDamage = 1f; foreach (float instance in moreDamageInstances) { moreDamage *= 1 + instance; } foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>()) { holder.increaseAllDamage(moreDamage - 1); } } return(abilityObject); }
public void Start() { CreationReferences references = GetComponent <CreationReferences>(); if (references && references.creator) { SummonTracker summonTracker = references.creator.GetComponent <SummonTracker>(); if (summonTracker) { List <Summoned> minionsToUse = new List <Summoned>(); List <Summoned> creatorMinions = summonTracker.summons; if (creatorMinions.Count > 0) { // select minions if (minionsToUseAbility == MinionUseType.Nearest) { Summoned selected = creatorMinions[0]; float selectedDistance = Vector3.Distance(transform.position, creatorMinions[0].transform.position); float distance = 0; foreach (Summoned minion in creatorMinions) { distance = Vector3.Distance(transform.position, minion.transform.position); if (distance < selectedDistance && (!requiresCanUseMovementAbilities || minion.GetComponent <CanUseMovementAbilities>())) { selectedDistance = distance; selected = minion; } } if (!requiresCanUseMovementAbilities || selected.GetComponent <CanUseMovementAbilities>()) { minionsToUse.Add(selected); } } else if (minionsToUseAbility == MinionUseType.Random) { int attempts = 0; Summoned selected = null; while (attempts < 20) { selected = creatorMinions[Random.Range(0, creatorMinions.Count)]; if (!requiresCanUseMovementAbilities || selected.GetComponent <CanUseMovementAbilities>()) { attempts = 100000; minionsToUse.Add(selected); } } } else if (minionsToUseAbility == MinionUseType.All) { if (!requiresCanUseMovementAbilities) { minionsToUse.AddRange(creatorMinions); } else { foreach (Summoned minion in creatorMinions) { if (minion.GetComponent <CanUseMovementAbilities>()) { minionsToUse.Add(minion); } } } } // make the minions use the ability Vector3 targetPostion = GetComponent <LocationDetector>().targetLocation; UsingAbility ua = null; foreach (Summoned minion in minionsToUse) { ua = minion.GetComponent <UsingAbility>(); if (ua) { ua.UseAbility(ability, targetPostion, false, false); ua.transform.LookAt(targetPostion); } } } } } }