Пример #1
0
 private void UseMeleeAttack(AttackAbility ability, float damage, float calculatedDamage)
 {
     if (ability == null && GetComponent <AbilityUser>().GCDTime > 0)
     {
         return;
     }
     GetComponent <AbilityUser>().GCDTime = AbilityUser.maxGCDTime;
     if (ability.FindAttribute("offGCD") != null)
     {
         GetComponent <AbilityUser>().GCDTime = 0f;
     }
     if ((ability.FindAttribute("chargeTowards") != null && ability.FindAttribute("chargeTowards").priority >= 50) || GetComponent <AbilityUser>().HasPassive("charge"))
     {
         ChargeTowards();
     }
     if (ability.FindAttribute("createDamageZone") != null)
     {
         CreateMeleeDamageZone(ability);
     }
     else if (ability.radius > 0)
     {
         HitAllInRadius((int)calculatedDamage, ability.radius, ability);
     }
     else
     {
         meleeAttackAbility = ability;
         meleeAttackDamage  = calculatedDamage;
         StartCoroutine(ActivateMeleeHitbox());
     }
 }
Пример #2
0
    public void TakeDamage(float amount, Element type, Character attacker, bool silent = false, AttackAbility ability = null, Transform projectileTransform = null)
    {
        if (GetComponent <MonsterMortal>() != null)
        {
            lastTargetHitByPlayer = gameObject;
        }
        var originalAmount = amount;

        if (GetComponent <MirrorImage>() != null)
        {
            Destroy(gameObject);
            return;
        }
        if (!silent)
        {
            MakeDamageHitNoise(type);
        }
        GetComponent <StatusEffectHost>().RemoveStealth();
        //if (GetComponent<Monster>() != null && attacker != null) GetComponent<AggroTable>().IncreaseAggro(attacker.gameObject, amount);
        ShowHitVisual(ability);
        var criticalRoll = UnityEngine.Random.Range(0f, 1f);

        amount = ModifyDamage(amount, criticalRoll, type, attacker, ability);
        if (BossImmunity())
        {
            amount = 0;
        }
        if (ability == null || ability.FindAttribute("delay") == null || ability.FindAttribute("delay").priority < 50)
        {
            hp -= amount;
        }
        if (hp <= 0 && GetComponent <MonsterMortal>() != null)
        {
            GetComponent <MonsterMortal>().killer = attacker.gameObject;
        }
        if (amount >= 0 && ability != null)
        {
            ApplyEffectsFromAttack(attacker, ability, amount, projectileTransform);
        }
        if (amount > 0 && GetComponent <MonsterSounds>() != null)
        {
            GetComponentInChildren <AudioGenerator>().PlaySoundByName(GetComponent <MonsterSounds>().onHit);
        }
        if (amount > 0 && GetComponent <OchreJelly>() != null)
        {
            GetComponent <OchreJelly>().Split();
        }
        if (ability == null || ability.FindAttribute("delay") == null || ability.FindAttribute("delay").priority < 50)
        {
            if (!silent && amount == 0 && amount != originalAmount)
            {
                CreateFloatingImmunityText(attacker);
            }
            else if (!silent)
            {
                CreateFloatingText(amount, criticalRoll, attacker, ability);
            }
            ResurrectIfApplicable();
        }
    }
Пример #3
0
 public void MeleeHitboxOn()
 {
     if (meleeAttackAbility == null || meleeAttackAbility.FindAttribute("stealthy") == null)
     {
         GetComponent <StatusEffectHost>().RemoveStealth();
     }
     isAttacking = true;
     GetComponent <AnimationController>().SetAttacking(true);
     if (meleeAttackAbility == null || meleeAttackAbility.FindAttribute("offGCD") == null)
     {
         GetComponent <AbilityUser>().GCDTime = AbilityUser.maxGCDTime;
     }
     GetComponent <AudioGenerator>().PlaySoundByName("sfx_melee_swipe3");
 }
Пример #4
0
    public void UseAttack(AttackAbility ability)
    {
        if (GetComponent <PlayerCharacter>() != null)
        {
            GetComponent <SimulatedNoiseGenerator>().CmdMakeNoise(transform.position, 22);
        }
        var damage           = CalculateAttackDamage(ability);
        var calculatedDamage = damage * ability.damage;

        if (ability.isRanged)
        {
            if (ability.FindAttribute("projectileSpread") != null && ability.FindAttribute("projectileSpread").priority >= 50)
            {
                UseProjectileSpread(ability, damage, calculatedDamage);
            }
            else if (ability.FindAttribute("bossDamageZone") != null)
            {
                UseBossDamageZone(ability, damage, calculatedDamage);
            }
            else if (ability.FindAttribute("bossHealingDamageZone") != null)
            {
                UseBossHealingDamageZone(ability, damage, calculatedDamage);
            }
            else if (ability.FindAttribute("bossCircleAoe") != null)
            {
                UseBossCircleAoe(ability, damage, calculatedDamage);
            }
            else if (ability.FindAttribute("bossLineAoe") != null)
            {
                UseBossLineAoe(ability, damage, calculatedDamage);
            }
            else if (ability.FindAttribute("bossBulletHell") != null)
            {
                UseBossBulletHell(ability, damage, calculatedDamage);
            }
            else if (ability.FindAttribute("bossHomingProjectile") != null)
            {
                UseBossHomingProjectile(ability, damage, calculatedDamage);
            }
            else if (ability.FindAttribute("bossJumpAndShoot") != null)
            {
                UseBossJumpAndShoot(ability, damage, calculatedDamage);
            }
            else
            {
                UseRangedAttack(ability, damage, calculatedDamage);
            }
        }
        else
        {
            UseMeleeAttack(ability, damage, calculatedDamage);
        }
    }
Пример #5
0
    public void ApplyEffectsFromAttack(Character attacker, AttackAbility ability, float damage, Transform projectileTransform)
    {
        Dictionary <string, Effect> effects = SetUpEffectDictionary(attacker, ability, damage, projectileTransform);
        int count = 0;

        foreach (var attribute in ability.attributes)
        {
            if (effects.ContainsKey(attribute.type) && attribute.priority >= 50 && count < 4)
            {
                effects[attribute.type](attribute);
            }
            count++;
        }
        if (attacker != null && attacker.GetComponent <AbilityUser>().HasPassive("knockback"))
        {
            AbilityEffects.KnockbackDefault(attacker, GetComponent <Character>());
        }
        if (attacker != null && attacker.GetComponent <AbilityUser>().HasPassive("pullEnemies"))
        {
            AbilityEffects.PullTowardsDefault(attacker, GetComponent <Character>());
        }
        if (ability.FindAttribute("createDamageZone") == null && ability.dotDamage > 0)
        {
            GetComponent <StatusEffectHost>().AddStatusEffect("dot", ability.dotTime, degree: ability.CalculateDotDamage(attacker), inflicter: attacker, ability: ability);
        }
    }
Пример #6
0
    private float ModifyDamage(float amount, float criticalRoll, Element type, Character attacker, AttackAbility ability)
    {
        if (GetComponent <Monster>() != null)
        {
            amount = GetComponent <Monster>().ModifyDamageForElements(amount, type);
        }
        float critRate = 0;

        //if (attacker != null && attacker.GetComponent<Attacker>() != null) critRate = attacker.GetComponent<Attacker>().critRate;
        if (attacker != null && attacker.GetComponent <Attacker>() != null)
        {
            critRate = CharacterAttribute.attributes["criticalHitChance"].instances[GetComponent <Character>()].TotalValue / 100f;
        }
        if (ability != null && ability.FindAttribute("increasedCritChance") != null)
        {
            critRate += (float)ability.FindAttribute("increasedCritChance").FindParameter("degree").value;
        }
        float critMultiplier = 0;

        //if (attacker != null && attacker.GetComponent<Attacker>() != null) critMultiplier = attacker.GetComponent<Attacker>().critMultiplier;
        if (attacker != null && attacker.GetComponent <Attacker>() != null)
        {
            critMultiplier = CharacterAttribute.attributes["criticalDamage"].instances[GetComponent <Character>()].TotalValue / 100f;
        }
        if (ability != null && ability.FindAttribute("increasedCritDamage") != null)
        {
            critMultiplier += (float)ability.FindAttribute("increasedCritDamage").FindParameter("degree").value;
        }
        if (attacker != null && criticalRoll <= critRate)
        {
            amount *= critMultiplier;
        }
        amount = ModifyDamageForVulnerability(amount);
        amount = ModifyDamageForShield(amount);
        amount = ModifyDamageForArmor(amount, attacker);
        amount = ModifyDamageForLuck(amount, type);
        if (attacker != null)
        {
            amount = ModifyDamageForDamageBoosts(ability, amount, attacker);
        }
        amount = ModifyDamageForDamageReduction(ability, amount);
        if (attacker != null)
        {
            amount = ModifyDamageForBlunting(amount, attacker);
        }
        return(amount);
    }
Пример #7
0
    private void CreateFloatingText(float amount, float criticalRoll, Character attacker, AttackAbility ability)
    {
        if (attacker == null || gameObject == null)
        {
            return;
        }
        var name = gameObject.name;

        if (name == "kittenCharacter(Clone)")
        {
            name = "Player";
        }
        var attackerName = attacker.gameObject.name;

        if (attackerName == "kittenCharacter(Clone)")
        {
            attackerName = "Player";
        }
        //var critRate = attacker.GetComponent<Attacker>().critRate;
        var critRate = CharacterAttribute.attributes["criticalHitChance"].instances[attacker.GetComponent <Character>()].TotalValue / 100f;

        if (ability != null && ability.FindAttribute("increasedCritChance") != null)
        {
            critRate += (float)ability.FindAttribute("increasedCritChance").FindParameter("degree").value;
        }
        if (amount < 0)
        {
            GetComponent <ObjectSpawner>().CreateFloatingHealingText((int)amount * -1, name + " healed for " + amount.ToString() + ".");
        }
        else if (attacker != null && attacker.GetComponent <Attacker>() != null && GetComponent <ObjectSpawner>() != null && criticalRoll > critRate && amount >= maxHP / 100f && name == "Player")
        {
            GetComponent <ObjectSpawner>().CreateFloatingDamageText((int)amount, attackerName, name);
        }
        else if (attacker != null && attacker.GetComponent <Attacker>() != null && GetComponent <ObjectSpawner>() != null && criticalRoll > critRate && name != "Player")
        {
            GetComponent <ObjectSpawner>().CreateFloatingDamageText((int)amount, attackerName, name);
        }
        else if (name == "Player" && amount >= maxHP / 100f)
        {
            GetComponent <ObjectSpawner>().CreateCriticalFloatingDamageText((int)amount, attackerName, name);
        }
        else if (name != "Player")
        {
            GetComponent <ObjectSpawner>().CreateCriticalFloatingDamageText((int)amount, attackerName, name);
        }
    }
Пример #8
0
    public float CalculateAttackDamage(AttackAbility ability)
    {
        var damage = GetBaseDamage(ability.baseStat);

        if (GetComponent <Monster>() != null)
        {
            damage *= 1.6f * 2f;                                  // stat boost to deal with armor // stat boost to offset difficulty
        }
        if (GetComponent <StatusEffectHost>().CheckForEffect("damage+"))
        {
            damage *= (1 + GetComponent <StatusEffectHost>().GetEffect("damage+").degree);
        }
        if (ability.FindAttribute("backstab") != null && GetComponent <StatusEffectHost>().CheckForEffect("stealth"))
        {
            damage *= (float)ability.FindAttribute("backstab").FindParameter("degree").value;
        }
        return(ApplyDamageBoosts(damage, ability));
    }
Пример #9
0
    public static void ProjectileAttack(Character character, Collider other, AttackAbility ability, int damage, float radius, float dotDamage, float dotTime, List <AbilityAttribute> attributes, GameObject gameObject, string faction)
    {
        var otherCharacter = other.gameObject.GetComponent <Character>();

        if (other.GetComponent <LockedDoor>() != null || other.GetComponent <LockedChest>() != null || (otherCharacter != null && !otherCharacter.CompareTag(faction)) || other.gameObject.CompareTag("Wall"))
        {
            if (ability != null && ability.FindAttribute("createDamageZone") != null)
            {
                CreateDamageZone(character, gameObject, ability, radius, faction);
            }
            else if (radius > 0)
            {
                CreateAoe(character, gameObject, ability, attributes, damage, radius, faction);
            }
            else if (otherCharacter != null && ability != null)
            {
                DamageCharacterWithProjectile(character, otherCharacter, ability, gameObject, damage, ability.element);
            }
            else if (otherCharacter != null && character.GetComponent <PlayerCharacter>() != null)
            {
                DamageCharacterWithProjectile(character, otherCharacter, null, gameObject, damage, Element.none);
            }
            else if (other.gameObject.GetComponent <LockedDoor>() != null)
            {
                DamageDoor(character, other, damage);
            }
            else if (other.gameObject.GetComponent <LockedChest>() != null)
            {
                DamageChest(character, other, damage);
            }
            else if (other.gameObject.CompareTag("Wall"))
            {
                Dictionary <Element, string> noises = new Dictionary <Element, string>()
                {
                    { Element.acid, "sfx_acid_damage1" }, { Element.bashing, "sfx_wall_hit2" }, { Element.fire, "sfx_fire_damage2" }, { Element.ice, "sfx_ice_damage1" }, { Element.none, "sfx_rock_impact2" }, { Element.piercing, "sfx_wall_hit2" }, { Element.slashing, "sfx_wall_hit2" }, { Element.light, "sfx_holy_damage1" }, { Element.dark, "sfx_profane_damage1" }
                };
                var noise = "sfx_rock_impact2";
                if (ability != null && noises.ContainsKey(ability.element))
                {
                    noise = noises[ability.element];
                }
                if (noise != "")
                {
                    MakeNoiseByName(noise, 0, null, null);
                }
            }
            gameObject.GetComponentInChildren <RangedHitboxDealDamage>().struck = true;
        }
    }
Пример #10
0
 public static void DamageCharacterWithProjectile(Character character, Character otherCharacter, AttackAbility ability, GameObject gameObject, float damage, Element element)
 {
     if (character == null || otherCharacter == null)
     {
         return;
     }
     character.GetComponent <SimulatedNoiseGenerator>().CmdMakeNoise(gameObject.transform.position, 22);
     DamageCharacter(character, otherCharacter, ability, damage, element);
     if (ability != null)
     {
         var attr = ability.FindAttribute("knockback");
         if (attr != null && attr.priority >= 50)
         {
             otherCharacter.transform.position += gameObject.transform.forward * (float)attr.FindParameter("degree").value;
         }
     }
 }