예제 #1
0
        void Cursor_OnValidation(CombatCursor sender, CombatCursorEventArgs e)
        {
            if (!Combat.GetCell(Combat.Cursor.CellPosition).IsWithinArea(CurrentSpell.RangeArea, CurrentCombatant.CellPosition))
                return;

            Spell = new CombatSpell(CurrentSpell, CurrentCombatant);
               // Spell = new RandomEffectAreaSpell(CurrentSpell, CurrentCombatant);

            Log("launches " + Spell.GetName());

            Spell.Launch(e.CellPosition);
            Spell.OnStopping += new CombatSpellEventHandler(Spell_OnStopping);
            SpellIsPerforming = true;

            Combat.Cursor.Close();

            End();
        }
예제 #2
0
 void Spell_OnStopping(CombatSpell sender, CombatSpellEventArgs e)
 {
     Combat.ChangeState(BlazeraLib.Combat.EState.ActionSelection);
 }
예제 #3
0
        public static bool DoCombatSpell(BaseCreature creature)
        {
            if (creature.Combatant == null)
            {
                return(false);
            }

            Dictionary <CombatSpell, int> DictTemp = new Dictionary <CombatSpell, int>();

            if (AICombatSpell.CanDoCombatSpellSpellDamage1(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamage1, creature.DictCombatSpell[CombatSpell.SpellDamage1]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDamage2(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamage2, creature.DictCombatSpell[CombatSpell.SpellDamage2]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDamage3(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamage3, creature.DictCombatSpell[CombatSpell.SpellDamage3]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDamage4(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamage4, creature.DictCombatSpell[CombatSpell.SpellDamage4]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDamage5(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamage5, creature.DictCombatSpell[CombatSpell.SpellDamage5]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDamage6(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamage6, creature.DictCombatSpell[CombatSpell.SpellDamage6]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDamage7(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamage7, creature.DictCombatSpell[CombatSpell.SpellDamage7]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDamageAOE7(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDamageAOE7, creature.DictCombatSpell[CombatSpell.SpellDamageAOE7]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellPoison(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellPoison, creature.DictCombatSpell[CombatSpell.SpellPoison]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellNegative1to3(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellNegative1to3, creature.DictCombatSpell[CombatSpell.SpellNegative1to3]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellNegative4to7(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellNegative4to7, creature.DictCombatSpell[CombatSpell.SpellNegative4to7]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellSummon5(creature))
            {
                DictTemp.Add(CombatSpell.SpellSummon5, creature.DictCombatSpell[CombatSpell.SpellSummon5]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellSummon8(creature))
            {
                DictTemp.Add(CombatSpell.SpellSummon8, creature.DictCombatSpell[CombatSpell.SpellSummon8]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellDispelSummon(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellDispelSummon, creature.DictCombatSpell[CombatSpell.SpellDispelSummon]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellHarmfulField(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellHarmfulField, creature.DictCombatSpell[CombatSpell.SpellHarmfulField]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellNegativeField(creature, creature.Combatant))
            {
                DictTemp.Add(CombatSpell.SpellNegativeField, creature.DictCombatSpell[CombatSpell.SpellNegativeField]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellBeneficial1to2(creature, creature))
            {
                DictTemp.Add(CombatSpell.SpellBeneficial1to2, creature.DictCombatSpell[CombatSpell.SpellBeneficial1to2]);
            }
            if (AICombatSpell.CanDoCombatSpellSpellBeneficial3to5(creature, creature))
            {
                DictTemp.Add(CombatSpell.SpellBeneficial3to5, creature.DictCombatSpell[CombatSpell.SpellBeneficial3to5]);
            }

            int TotalValues = 0;

            //Calculate Total Values
            foreach (KeyValuePair <CombatSpell, int> pair in DictTemp)
            {
                TotalValues += pair.Value;
            }

            double ActionCheck = Utility.RandomDouble();

            double CumulativeAmount = 0.0;
            double AdditionalAmount = 0.0;

            Spell selectedSpell = null;

            //Determine CombatSpell
            foreach (KeyValuePair <CombatSpell, int> pair in DictTemp)
            {
                AdditionalAmount = (double)pair.Value / (double)TotalValues;

                if (ActionCheck >= CumulativeAmount && ActionCheck < (CumulativeAmount + AdditionalAmount))
                {
                    CombatSpell combatSpell = pair.Key;
                    Spell       spell       = null;

                    switch (combatSpell)
                    {
                    case CombatSpell.SpellDamage1: spell = AICombatSpell.GetSpellDamage1(creature, creature.Combatant); break;

                    case CombatSpell.SpellDamage2: spell = AICombatSpell.GetSpellDamage2(creature, creature.Combatant); break;

                    case CombatSpell.SpellDamage3: spell = AICombatSpell.GetSpellDamage3(creature, creature.Combatant); break;

                    case CombatSpell.SpellDamage4: spell = AICombatSpell.GetSpellDamage4(creature, creature.Combatant); break;

                    case CombatSpell.SpellDamage5: spell = AICombatSpell.GetSpellDamage5(creature, creature.Combatant); break;

                    case CombatSpell.SpellDamage6: spell = AICombatSpell.GetSpellDamage6(creature, creature.Combatant); break;

                    case CombatSpell.SpellDamage7: spell = AICombatSpell.GetSpellDamage7(creature, creature.Combatant); break;

                    case CombatSpell.SpellDamageAOE7: spell = AICombatSpell.GetSpellDamageAOE7(creature, creature.Combatant); break;

                    case CombatSpell.SpellPoison: spell = AICombatSpell.GetSpellPoison(creature, creature.Combatant); break;

                    case CombatSpell.SpellNegative1to3: spell = AICombatSpell.GetSpellNegative1to3(creature, creature.Combatant); break;

                    case CombatSpell.SpellNegative4to7: spell = AICombatSpell.GetSpellNegative4to7(creature, creature.Combatant); break;

                    case CombatSpell.SpellSummon5: spell = AICombatSpell.GetSpellSummon5(creature); break;

                    case CombatSpell.SpellSummon8: spell = AICombatSpell.GetSpellSummon8(creature); break;

                    case CombatSpell.SpellDispelSummon: spell = AICombatSpell.GetSpellDispelSummon(creature, creature.Combatant); break;

                    case CombatSpell.SpellHarmfulField: spell = AICombatSpell.GetSpellHarmfulField(creature, creature.Combatant); break;

                    case CombatSpell.SpellNegativeField: spell = AICombatSpell.GetSpellNegativeField(creature, creature.Combatant); break;

                    case CombatSpell.SpellBeneficial1to2: spell = AICombatSpell.GetSpellBeneficial1to2(creature, creature); break;

                    case CombatSpell.SpellBeneficial3to5: spell = AICombatSpell.GetSpellBeneficial3to5(creature, creature); break;
                    }

                    if (spell != null)
                    {
                        if (creature.AcquireNewTargetEveryCombatAction)
                        {
                            creature.m_NextAcquireTargetAllowed = DateTime.UtcNow;
                        }

                        if (creature is UOACZBaseUndead)
                        {
                            UOACZBaseUndead uoaczBaseUndead = creature as UOACZBaseUndead;
                            uoaczBaseUndead.m_LastActivity = DateTime.UtcNow;
                        }

                        spell.Cast();

                        return(true);
                    }

                    break;
                }

                CumulativeAmount += AdditionalAmount;
            }

            return(false);
        }