Пример #1
0
    public void CalculateSpellDamageTaken(SpellDamage damageInfo, int damage, TrinitySpellInfo spellInfo, bool crit)
    {
        if (damage < 0)
        {
            return;
        }

        Unit victim = damageInfo.Target;

        if (victim == null || !victim.IsAlive())
        {
            return;
        }

        SpellSchoolMask damageSchoolMask = damageInfo.SchoolMask;

        // Script Hook For CalculateSpellDamageTaken -- Allow scripts to change the Damage post class mitigation calculations
        //sScriptMgr->ModifySpellDamageTaken(damageInfo->target, damageInfo->attacker, damage);

        // Calculate absorb resist

        /*if (damage > 0)
         * {
         *  CalcAbsorbResist(victim, damageSchoolMask, SPELL_DIRECT_DAMAGE, damage, &damageInfo->absorb, &damageInfo->resist, spellInfo);
         *  damage -= damageInfo->absorb + damageInfo->resist;
         * }
         * else
         *  damage = 0;*/

        damageInfo.Damage = damage;
        damageInfo.Crit   = crit;
    }
Пример #2
0
    public void CastSpell(Unit target, TrinitySpellInfo spellInfo, TriggerCastFlags triggerFlags, AuraEffect triggeredByAura, Guid originalCaster)
    {
        SpellCastTargets targets = new SpellCastTargets();

        targets.UnitTarget = target;
        CastSpell(targets, spellInfo, triggerFlags, triggeredByAura, originalCaster);
    }
Пример #3
0
    public void StartCooldown(TrinitySpellInfo spellInfo, TrinitySpell spell = null)
    {
        float cooldown = spellInfo.RecoveryTime;

        float currentTime = Time.time;
        float recTime     = currentTime;

        // #TODO : Add modifiers

        // replace negative cooldowns by 0
        if (cooldown < 0)
        {
            cooldown = 0;
        }

        // no cooldown after applying spell mods
        if (cooldown == 0)
        {
            return;
        }

        recTime = currentTime + cooldown;

        // self spell cooldown
        if (recTime != currentTime)
        {
            AddCooldown(spellInfo.Id, recTime);
        }
    }
Пример #4
0
    public void DealSpellDamage(SpellDamage damageInfo)
    {
        if (damageInfo == null)
        {
            return;
        }

        Unit victim = damageInfo.Target;

        if (victim == null)
        {
            return;
        }

        if (!victim.IsAlive())
        {
            return;
        }

        TrinitySpellInfo spellProto = WarcraftDatabase.SpellInfos.ContainsKey(damageInfo.SpellID) ? WarcraftDatabase.SpellInfos[damageInfo.SpellID] : null;

        if (spellProto == null)
        {
            Debug.LogErrorFormat("Unit.DealSpellDamage has wrong damageInfo->SpellID: {0}", damageInfo.SpellID);
            return;
        }

        // Call default DealDamage
        CleanDamage cleanDamage = new CleanDamage(damageInfo.Absorb, damageInfo.Damage);

        DealDamage(victim, damageInfo.Damage, cleanDamage, DamageEffectType.SPELL_DIRECT_DAMAGE, damageInfo.SchoolMask, spellProto);

        SpellManager.SpellDamageEvent(this, victim, damageInfo.Damage, damageInfo.Crit);
    }
    public TrinitySpellEffectInfo(TrinitySpellInfo info, int effectIndex, TrinitySpellEffectInfoEntry effectEntry)
    {
        spellInfo   = info;
        EffectIndex = effectIndex;

        Effect          = effectEntry.Effect;
        AuraType        = effectEntry.AuraType;
        ApplyAuraPeriod = effectEntry.ApplyAuraPeriod;
        DieSides        = effectEntry.DieSides;

        TargetA = effectEntry.TargetA;
        TargetB = effectEntry.TargetB;

        BasePoints        = effectEntry.BasePoints;
        PointsPerResource = effectEntry.PointsPerResource;
        Amplitude         = effectEntry.Amplitude;
        ChainAmplitude    = effectEntry.ChainAmplitude;

        MiscValue  = effectEntry.MiscValue;
        MiscValueB = effectEntry.MiscValueB;
        Mechanic   = effectEntry.Mechanic;

        PositionFacing = effectEntry.PositionFacing;
        Radius         = effectEntry.RadiusEntryId > 0 ? WarcraftDatabase.SpellRadiuses[effectEntry.RadiusEntryId] : null;

        TriggerSpell           = effectEntry.TriggerSpell;
        BonusCoefficient       = effectEntry.BonusCoefficient;
        BonusCoefficientFromAP = effectEntry.BonusCoefficientFromAP;
    }
Пример #6
0
 public static void ApplySpellCastSound(Unit target, TrinitySpellInfo spellInfo)
 {
     if (WarcraftDatabase.SpellCastSounds.ContainsKey(spellInfo.Id))
     {
         AudioSource.PlayClipAtPoint(WarcraftDatabase.SpellCastSounds[spellInfo.Id], target.transform.position);
     }
 }
Пример #7
0
    public float ApplyEffectModifiers(TrinitySpellInfo spellProto, int effect_index, float value)
    {
        var modOwner = this;

        /*modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_ALL_EFFECTS, value);
         * switch (effect_index)
         * {
         *  case 0:
         *      modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT1, value);
         *      break;
         *  case 1:
         *      modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT2, value);
         *      break;
         *  case 2:
         *      modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT3, value);
         *      break;
         *  case 3:
         *      modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT4, value);
         *      break;
         *  case 4:
         *      modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT5, value);
         *      break;
         * }*/
        return(value);
    }
    public TrinitySpell(Unit caster, TrinitySpellInfo info, TriggerCastFlags triggerFlags, Guid originalCasterId, bool skipCheck = false)
    {
        SpellValue = new SpellValue(info);

        Caster    = caster;
        SpellInfo = info;

        CastId         = Guid.NewGuid();
        OriginalCastId = CastId;
        SkipCheck      = skipCheck;

        ExecutedCurrently          = false;
        ApplyMultiplierMask        = 0;
        DamageMultipliers          = new float[3];
        ReferencedFromCurrentSpell = false;

        SpellSchoolMask = SpellInfo.SchoolMask;

        if (originalCasterId != Guid.Empty)
        {
            OriginalCasterGuid = originalCasterId;
        }
        else
        {
            OriginalCasterGuid = caster.Character.Id;
        }

        if (OriginalCasterGuid == caster.Character.Id)
        {
            OriginalCaster = caster;
        }
        else
        {
            OriginalCaster = ArenaManager.ArenaUnits.Find(unit => unit.Character.Id == OriginalCasterGuid);
        }

        SpellState       = SpellState.NONE;
        TriggerCastFlags = triggerFlags;

        UnitTarget       = null;
        DestTarget       = null;
        Damage           = 0;
        Variance         = 0.0f;
        EffectHandleMode = SpellEffectHandleMode.LAUNCH;
        EffectInfo       = null;

        DiminishLevel = DiminishingLevels.LEVEL_1;
        DiminishGroup = DiminishingGroup.NONE;

        EffectDamage  = 0;
        EffectHealing = 0;
        SpellAura     = null;

        SpellVisual = SpellInfo.VisualId;
        CanReflect  = SpellInfo.DamageClass == SpellDamageClass.MAGIC && !SpellInfo.HasAttribute(SpellAttributes.CANT_BE_REFLECTED) &&
                      !SpellInfo.IsPassive() && !SpellInfo.IsPositive();

        UniqueTargets = new List <TargetInfo>();
        SpellEffects  = new List <TrinitySpellEffectInfo>(SpellInfo.SpellEffectInfos);
    }
Пример #9
0
    public void HandleCooldowns(TrinitySpellInfo spellInfo, TrinitySpell spell)
    {
        if (spellInfo.IsPassive() || (spell != null && spell.IsIgnoringCooldowns()))
        {
            return;
        }

        StartCooldown(spellInfo, spell);
    }
Пример #10
0
    public bool IsReady(TrinitySpellInfo spellInfo, bool isIgnoringCooldowns)
    {
        if (HasCooldown(spellInfo.Id, isIgnoringCooldowns))
        {
            return(false);
        }

        return(true);
    }
Пример #11
0
    public int CalculateSpellDamage(Unit target, TrinitySpellInfo spellProto, int effectIndex, int basePoints, float variance)
    {
        TrinitySpellEffectInfo effect = spellProto.GetEffect(effectIndex);

        if (variance > 0)
        {
            variance = 0.0f;
        }

        return(effect != null?effect.CalcValue(this, basePoints, target, variance) : 0);
    }
Пример #12
0
 public static void ApplySpellVisuals(Unit target, TrinitySpellInfo spellInfo)
 {
     if (WarcraftDatabase.SpellVisuals.ContainsKey(spellInfo.VisualId))
     {
         Instantiate(WarcraftDatabase.SpellVisuals[spellInfo.VisualId], target.transform.position, target.transform.rotation);
     }
     else
     {
         Debug.LogError("No visuals for spell #" + spellInfo.Id);
     }
 }
Пример #13
0
    public void CastSpell(SpellCastTargets targets, TrinitySpellInfo spellInfo, TriggerCastFlags triggerFlags, AuraEffect triggeredByAura, Guid originalCaster)
    {
        if (spellInfo == null)
        {
            Debug.LogError("Unknown spell for unit: " + gameObject.name);
            return;
        }

        TrinitySpell spell = new TrinitySpell(this, spellInfo, triggerFlags, originalCaster);

        spell.Prepare(targets, triggeredByAura);
    }
Пример #14
0
    public SpellMissInfo SpellHitResult(Unit victim, TrinitySpellInfo spellInfo, bool canReflect)
    {
        // Check for immune

        /*if (victim->IsImmunedToSpell(spellInfo))
         *  return SPELL_MISS_IMMUNE;*/

        // All positive spells can`t miss
        /// @todo client not show miss log for this spells - so need find info for this in dbc and use it!
        if (spellInfo.IsPositive() && !IsHostileTo(victim)) // prevent from affecting enemy by "positive" spell
        {
            return(SpellMissInfo.NONE);
        }

        // Check for immune

        /*if (victim->IsImmunedToDamage(spellInfo))
         *  return SPELL_MISS_IMMUNE;*/

        if (this == victim)
        {
            return(SpellMissInfo.NONE);
        }

        // Try victim reflect spell

        /*if (CanReflect)
         * {
         *  int32 reflectchance = victim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS);
         *      Unit::AuraEffectList const& mReflectSpellsSchool = victim->GetAuraEffectsByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL);
         *  for (Unit::AuraEffectList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i)
         *      if ((*i)->GetMiscValue() & spellInfo->GetSchoolMask())
         *          reflectchance += (*i)->GetAmount();
         *  if (reflectchance > 0 && roll_chance_i(reflectchance))
         *  {
         *      // Start triggers for remove charges if need (trigger only for victim, and mark as active spell)
         *      ProcDamageAndSpell(victim, PROC_FLAG_NONE, PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG, PROC_EX_REFLECT, 1, BASE_ATTACK, spellInfo);
         *      return SPELL_MISS_REFLECT;
         *  }
         * }*/

        /*switch (spellInfo->DmgClass)
         * {
         *  case SPELL_DAMAGE_CLASS_RANGED:
         *  case SPELL_DAMAGE_CLASS_MELEE:
         *      return MeleeSpellHitResult(victim, spellInfo);
         *  case SPELL_DAMAGE_CLASS_NONE:
         *      return SPELL_MISS_NONE;
         *  case SPELL_DAMAGE_CLASS_MAGIC:
         *      return MagicSpellHitResult(victim, spellInfo);
         * }*/
        return(SpellMissInfo.NONE);
    }
Пример #15
0
    public void CastSpell(Unit target, int spellId, TriggerCastFlags triggerFlags, AuraEffect triggeredByAura, Guid originalCaster)
    {
        TrinitySpellInfo spellInfo = WarcraftDatabase.SpellInfos.ContainsKey(spellId) ? WarcraftDatabase.SpellInfos[spellId] : null;

        if (spellInfo == null)
        {
            Debug.LogError("Unknown spell for unit: " + gameObject.name);
            return;
        }

        CastSpell(target, spellInfo, triggerFlags, triggeredByAura, originalCaster);
    }
    void LoadSpellInfo()
    {
        SpellInfos = new Dictionary <int, TrinitySpellInfo>();

        #region Frost Nova Id : 1, Effects : 1, 2

        var spellInfo = new TrinitySpellInfo()
        {
            Id                 = 1,
            Dispel             = DispelType.MAGIC,
            Mechanic           = Mechanics.FREEZE,
            Attributes         = SpellAttributes.DAMAGE_DOESNT_BREAK_AURAS | SpellAttributes.CANT_BE_REFLECTED,
            Targets            = TargetTypes.TARGET_UNIT_SRC_AREA_ENEMY,
            SchoolMask         = SpellSchoolMask.FROST,
            DamageClass        = SpellDamageClass.MAGIC,
            PreventionType     = SpellPreventionType.SILENCE | SpellPreventionType.PACIFY,
            ExplicitTargetMask = SpellCastTargetFlags.UNIT_ENEMY,
            InterruptFlags     = SpellInterruptFlags.NONE,
            FamilyName         = SpellFamilyNames.MAGE,

            ChargeCategory = SpellHelper.ZeroChargeCategory,
            CastTime       = SpellHelper.InstantCastTime,
            Range          = SpellHelper.SelfCastRange,
            Duration       = SpellDurations[8],
            PowerCosts     = new List <SpellPowerCost>()
            {
                SpellHelper.BasicManaCost
            },

            RecoveryTime          = 0.5f,
            StartRecoveryTime     = 0.0f,
            StartRecoveryCategory = 0,

            Speed = 0.0f,

            StackAmount        = 0,
            MaxAffectedTargets = 0,

            SpellIconId  = 1,
            ActiveIconId = 2,
            VisualId     = 1,
        };

        spellInfo.SpellEffectInfos.Add(new TrinitySpellEffectInfo(spellInfo, 0, SpellEffectEntries[1]));
        spellInfo.SpellEffectInfos.Add(new TrinitySpellEffectInfo(spellInfo, 1, SpellEffectEntries[2]));

        SpellInfos.Add(spellInfo.Id, spellInfo);

        #endregion
    }
Пример #17
0
 public float GetSpellMaxRangeForTarget(Unit target, TrinitySpellInfo spellInfo)
 {
     if (spellInfo.Range == null)
     {
         return(0);
     }
     if (spellInfo.Range.MaxRangeFriend == spellInfo.Range.MaxRangeHostile)
     {
         return(spellInfo.GetMaxRange(false));
     }
     if (!target)
     {
         return(spellInfo.GetMaxRange(true));
     }
     return(spellInfo.GetMaxRange(!IsHostileTo(target)));
 }
    public SpellValue(TrinitySpellInfo spellInfo)
    {
        EffectBasePoints = new int[SpellHelper.MaxSpellEffects];

        for (int i = 0; i < spellInfo.SpellEffectInfos.Count; i++)
        {
            if (spellInfo.SpellEffectInfos[i] != null)
            {
                EffectBasePoints[spellInfo.SpellEffectInfos[i].EffectIndex] = spellInfo.SpellEffectInfos[i].BasePoints;
            }
        }

        MaxAffectedTargets = spellInfo.MaxAffectedTargets;
        RadiusMod          = 1.0f;
        AuraStackAmount    = 1;
    }
Пример #19
0
    public int DealDamage(Unit victim, int damage, CleanDamage cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, TrinitySpellInfo spellProto)
    {
        // Hook for OnDamage Event
        //sScriptMgr->OnDamage(this, victim, damage);

        if (damage < 1)
        {
            return(0);
        }

        int health = victim.Character.health.CurrentValue;

        if (health <= damage)
        {
            Debug.Log("DealDamage: Victim just died");

            Kill(victim);
        }
        else
        {
            Debug.Log("DealDamage: Alive");

            victim.Character.health.Decrease(damage);
            //victim.ModifyHealth(-damage);
        }
        return(damage);
    }
Пример #20
0
 public void CastSpell(Unit target, TrinitySpellInfo spellInfo, bool triggered, AuraEffect triggeredByAura, Guid originalCaster)
 {
     CastSpell(target, spellInfo, triggered ? TriggerCastFlags.FULL_MASK : TriggerCastFlags.NONE, triggeredByAura, originalCaster);
 }