Exemplo n.º 1
0
        public override void PerformAbilityHit(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectInput)
        {
            base.PerformAbilityHit(source, target, abilityEffectInput);

            List <StatusEffectNode> removeEffects = new List <StatusEffectNode>();

            CharacterUnit targetCharacterUnit = CharacterUnit.GetCharacterUnit(target);

            if (targetCharacterUnit != null && targetCharacterUnit.BaseCharacter != null && targetCharacterUnit.BaseCharacter.CharacterStats != null)
            {
                foreach (StatusEffectNode statusEffectNode in targetCharacterUnit.BaseCharacter.CharacterStats.StatusEffects.Values)
                {
                    if (statusEffectNode.StatusEffect.StatusEffectType != null && effectTypes.Contains(statusEffectNode.StatusEffect.StatusEffectType))
                    {
                        removeEffects.Add(statusEffectNode);
                    }
                    if (maxClearEffects != 0 && removeEffects.Count >= maxClearEffects)
                    {
                        break;
                    }
                }

                foreach (StatusEffectNode statusEffectNode in removeEffects)
                {
                    statusEffectNode.CancelStatusEffect();
                }
            }
        }
Exemplo n.º 2
0
        public override bool CanUseOn(Interactable target, IAbilityCaster source, AbilityEffectContext abilityEffectContext = null, bool playerInitiated = false, bool performRangeCheck = true)
        {
            if (target == null)
            {
                return(false);
            }
            CharacterUnit characterUnit = CharacterUnit.GetCharacterUnit(target);

            if (characterUnit == null)
            {
                return(false);
            }
            if (characterUnit.BaseCharacter.CharacterStats.IsAlive == false && characterUnit.BaseCharacter.CharacterStats.IsReviving == false)
            {
                return(true);
            }
            if (characterUnit.BaseCharacter.CharacterStats.IsAlive == true)
            {
                if (playerInitiated)
                {
                    source.AbilityManager.ReceiveCombatMessage("Cannot cast " + resourceName + ". Target is already alive");
                }
            }
            if (characterUnit.BaseCharacter.CharacterStats.IsReviving == true)
            {
                if (playerInitiated)
                {
                    source.AbilityManager.ReceiveCombatMessage("Cannot cast " + resourceName + ". Target is already reviving");
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        /*
         * // bypass the creation of the status effect and just make its visual prefab
         * public void RawCast(BaseCharacter source, GameObject target, GameObject originalTarget, AbilityEffectOutput abilityEffectInput) {
         *  base.Cast(source, target, originalTarget, abilityEffectInput);
         * }
         */

        public override Dictionary <PrefabProfile, GameObject> Cast(IAbilityCaster source, Interactable target, Interactable originalTarget, AbilityEffectContext abilityEffectInput)
        {
            //Debug.Log("StatusEffect.Cast(" + source.name + ", " + (target? target.name : "null") + ")");
            if (!CanUseOn(target, source))
            {
                //Debug.Log("StatusEffect.Cast(" + source.name + ", " + (target ? target.name : "null") + ") CANNOT USE RETURNING");
                return(null);
            }
            Dictionary <PrefabProfile, GameObject> returnObjects = base.Cast(source, target, originalTarget, abilityEffectInput);
            // make ourselves the top threat in his threat table
            CharacterUnit targetCharacterUnit = CharacterUnit.GetCharacterUnit(target);

            if (targetCharacterUnit != null)
            {
                if (targetCharacterUnit.BaseCharacter != null && targetCharacterUnit.BaseCharacter.CharacterCombat != null && targetCharacterUnit.BaseCharacter.CharacterCombat.AggroTable != null)
                {
                    //Debug.Log("StatusEffect.Cast(" + source.name + ", " + (target ? target.name : "null") + ") CHARACTER COMBAT IS NOT NULL");
                    AggroNode AgroNode      = targetCharacterUnit.BaseCharacter.CharacterCombat.AggroTable.MyTopAgroNode;
                    float     usedAgroValue = 0f;
                    if (AgroNode != null)
                    {
                        usedAgroValue = AgroNode.aggroValue;
                    }
                    if (source != null)
                    {
                        source.AbilityManager.GenerateAgro(targetCharacterUnit, (int)(usedAgroValue + extraThreat));
                    }
                }
            }

            // override aggro checks

            return(returnObjects);
        }
Exemplo n.º 4
0
        public override bool ProcessAbilityHit(Interactable target, int finalAmount, IAbilityCaster source, CombatMagnitude combatMagnitude, AbilityEffect abilityEffect, AbilityEffectContext abilityEffectContext, PowerResource powerResource)
        {
            bool returnValue = CharacterUnit.GetCharacterUnit(target).BaseCharacter.CharacterCombat.TakeDamage(abilityEffectContext, powerResource, finalAmount, source, combatMagnitude, this);

            if (returnValue == false)
            {
                return(false);
            }

            return(base.ProcessAbilityHit(target, finalAmount, source, combatMagnitude, abilityEffect, abilityEffectContext, powerResource));
        }
Exemplo n.º 5
0
        public override bool ProcessAbilityHit(Interactable target, int finalAmount, IAbilityCaster source, CombatMagnitude combatMagnitude, AbilityEffect abilityEffect, AbilityEffectContext abilityEffectContext, PowerResource powerResource)
        {
            //Debug.Log(DisplayName + ".HealEffect.ProcessAbilityHit(" + (target == null ? "null" : target.gameObject.name) + ", " + finalAmount + ", " + source.AbilityManager.UnitGameObject.name + ")");

            abilityEffectContext.powerResource = powerResource;
            bool returnValue = CharacterUnit.GetCharacterUnit(target).BaseCharacter.CharacterStats.RecoverResource(abilityEffectContext, powerResource, finalAmount, source, true, combatMagnitude);

            if (returnValue == false)
            {
                return(false);
            }

            return(base.ProcessAbilityHit(target, finalAmount, source, combatMagnitude, abilityEffect, abilityEffectContext, powerResource));
        }
Exemplo n.º 6
0
        private void ResurrectTarget(Interactable target)
        {
            if (target == null)
            {
                // our target despawned in the middle of the cast
                return;
            }
            CharacterUnit characterUnit = CharacterUnit.GetCharacterUnit(target);

            if (characterUnit == null)
            {
                //Debug.Log("CharacterUnit is null? target despawn during cast?");
                return;
            }
            characterUnit.BaseCharacter.CharacterStats.Revive();
        }
Exemplo n.º 7
0
        public override Dictionary <PrefabProfile, GameObject> Cast(IAbilityCaster source, Interactable target, Interactable originalTarget, AbilityEffectContext abilityEffectContext)
        {
            //Debug.Log(DisplayName + ".KnockBackEffect.Cast()");
            if (target == null)
            {
                return(null);
            }

            Dictionary <PrefabProfile, GameObject> returnObjects = base.Cast(source, target, originalTarget, abilityEffectContext);

            Vector3 sourcePosition = source.AbilityManager.UnitGameObject.transform.position;
            Vector3 targetPosition = target.transform.position;

            CharacterUnit targetCharacterUnit = CharacterUnit.GetCharacterUnit(target);

            if (targetCharacterUnit != null && targetCharacterUnit.BaseCharacter != null && targetCharacterUnit.BaseCharacter.CharacterAbilityManager != null)
            {
                //Debug.Log("KnockBackEffect.Cast(): stop casting");
                targetCharacterUnit.BaseCharacter.CharacterAbilityManager.StopCasting();
            }

            if (knockbackType == KnockbackType.Knockback)
            {
                if (targetCharacterUnit != null && targetCharacterUnit.BaseCharacter.UnitController.UnitMotor != null)
                {
                    //Debug.Log("KnockBackEffect.Cast(): casting on character");
                    targetCharacterUnit.BaseCharacter.UnitController.UnitMotor.Move(GetKnockBackVelocity(sourcePosition, targetPosition), true);
                }
                else
                {
                    Rigidbody rigidbody = target.GetComponent <Rigidbody>();
                    if (rigidbody != null)
                    {
                        rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
                        rigidbody.AddForce(GetKnockBackVelocity(sourcePosition, targetPosition), ForceMode.VelocityChange);
                    }
                }
            }
            else
            {
                Collider[] colliders = new Collider[0];
                //int playerMask = 1 << LayerMask.NameToLayer("Default");
                //int characterMask = 1 << LayerMask.NameToLayer("CharacterUnit");
                //int validMask = (playerMask | characterMask);
                //int validMask = playerMask;
                //colliders = Physics.OverlapSphere(targetPosition, explosionRadius, validMask);
                Vector3 explosionCenter = Vector3.zero;
                if (abilityEffectContext.groundTargetLocation != Vector3.zero)
                {
                    explosionCenter = abilityEffectContext.groundTargetLocation;
                }
                else
                {
                    explosionCenter = targetPosition;
                }
                colliders = Physics.OverlapSphere(explosionCenter, explosionRadius, explosionMask);
                foreach (Collider collider in colliders)
                {
                    //Debug.Log(DisplayName + ".KnockBackEffect.Cast() hit: " + collider.gameObject.name + "; layer: " + collider.gameObject.layer);
                    Rigidbody rigidbody = collider.gameObject.GetComponent <Rigidbody>();
                    if (rigidbody != null)
                    {
                        //Debug.Log(DisplayName + ".KnockBackEffect.Cast() rigidbody was not null on : " + collider.gameObject.name + "; layer: " + collider.gameObject.layer);

                        //rigidbody.AddForce(GetKnockBackVelocity(targetPosition, collider.gameObject.transform.position), ForceMode.VelocityChange);

                        // we have to handle player knockback specially, as they need to be in knockback state or the idle update will freeze them in place
                        if (collider.gameObject == PlayerManager.MyInstance.ActiveUnitController.gameObject)
                        {
                            PlayerManager.MyInstance.PlayerUnitMovementController.KnockBack();
                        }

                        // if this is a character, we want to freeze their rotation.  for inanimate objects, we want rotation
                        Interactable _interactable = collider.gameObject.GetComponent <Interactable>();
                        if (_interactable != null && CharacterUnit.GetCharacterUnit(_interactable) != null)
                        {
                            rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
                        }
                        rigidbody.AddExplosionForce(explosionForce, explosionCenter, 0, upwardModifier, ForceMode.VelocityChange);
                    }
                }
            }

            return(returnObjects);
        }