Example #1
0
        public override void OnThink()
        {
            base.OnThink();

            if (Combatant != null && DateTime.UtcNow >= m_NextAbilityAllowed && !Frozen)
            {
                if (DateTime.UtcNow >= m_NextMassiveBreathAllowed && AICombatEpicAction.CanDoMassiveFireBreathAttack(this))
                {
                    double totalDelay = 3;

                    SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1.0, totalDelay, true, 0, false, "", "", "-1");

                    Effects.PlaySound(Location, Map, GetAngerSound());

                    Direction direction = Utility.GetDirection(Location, Combatant.Location);

                    SpecialAbilities.DoMassiveBreathAttack(this, Location, direction, MassiveBreathRange, true, BreathType.Fire, true);

                    m_NextMassiveBreathAllowed = DateTime.UtcNow + NextMassiveBreathDelay + TimeSpan.FromSeconds(totalDelay);
                    m_NextAbilityAllowed       = DateTime.UtcNow + NextAbilityDelay + TimeSpan.FromSeconds(totalDelay);

                    LastSwingTime = DateTime.UtcNow + TimeSpan.FromSeconds(totalDelay + 2);
                    NextSpellTime = DateTime.UtcNow + TimeSpan.FromSeconds(totalDelay + 2);

                    return;
                }

                if (DateTime.UtcNow >= m_NextBreathAllowed && AICombatSpecialAction.CanDoFireBreathAttack(this))
                {
                    AICombatSpecialAction.DoFireBreathAttack(this, Combatant);

                    m_NextBreathAllowed  = DateTime.UtcNow + NextBreathDelay;
                    m_NextAbilityAllowed = DateTime.UtcNow + NextAbilityDelay;

                    LastSwingTime = DateTime.UtcNow + TimeSpan.FromSeconds(4);
                    NextSpellTime = DateTime.UtcNow + TimeSpan.FromSeconds(4);

                    return;
                }
            }
        }
Example #2
0
        public static bool DoCombatSpecialAction(BaseCreature creature)
        {
            CombatSpecialAction combatSpecialAction = CombatSpecialAction.None;

            int TotalValues = 0;

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

            DictTemp.Add(CombatSpecialAction.None, creature.DictCombatSpecialAction[CombatSpecialAction.None]);

            if (AICombatSpecialAction.CanDoApplyWeaponPoison(creature))
            {
                DictTemp.Add(CombatSpecialAction.ApplyWeaponPoison, creature.DictCombatSpecialAction[CombatSpecialAction.ApplyWeaponPoison]);
            }
            if (AICombatSpecialAction.CanDoThrowShipBomb(creature))
            {
                DictTemp.Add(CombatSpecialAction.ThrowShipBomb, creature.DictCombatSpecialAction[CombatSpecialAction.ThrowShipBomb]);
            }
            if (AICombatSpecialAction.CanDoCauseWounds(creature))
            {
                DictTemp.Add(CombatSpecialAction.CauseWounds, creature.DictCombatSpecialAction[CombatSpecialAction.CauseWounds]);
            }
            if (AICombatSpecialAction.CanDoFireBreathAttack(creature))
            {
                DictTemp.Add(CombatSpecialAction.FireBreathAttack, creature.DictCombatSpecialAction[CombatSpecialAction.FireBreathAttack]);
            }
            if (AICombatSpecialAction.CanDoIceBreathAttack(creature))
            {
                DictTemp.Add(CombatSpecialAction.IceBreathAttack, creature.DictCombatSpecialAction[CombatSpecialAction.IceBreathAttack]);
            }
            if (AICombatSpecialAction.CanDoPoisonBreathAttack(creature))
            {
                DictTemp.Add(CombatSpecialAction.PoisonBreathAttack, creature.DictCombatSpecialAction[CombatSpecialAction.PoisonBreathAttack]);
            }

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

            double ActionCheck      = Utility.RandomDouble();
            double CumulativeAmount = 0.0;
            double AdditionalAmount = 0.0;

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

                if (ActionCheck >= CumulativeAmount && ActionCheck < (CumulativeAmount + AdditionalAmount))
                {
                    combatSpecialAction = pair.Key;

                    switch (combatSpecialAction)
                    {
                    case CombatSpecialAction.ApplyWeaponPoison: AICombatSpecialAction.DoApplyWeaponPoison(creature); break;

                    case CombatSpecialAction.ThrowShipBomb: AICombatSpecialAction.DoThrowShipBomb(creature); break;

                    case CombatSpecialAction.CauseWounds: AICombatSpecialAction.DoCauseWounds(creature, creature.Combatant); break;

                    case CombatSpecialAction.FireBreathAttack: AICombatSpecialAction.DoFireBreathAttack(creature, creature.Combatant); break;

                    case CombatSpecialAction.IceBreathAttack: AICombatSpecialAction.DoIceBreathAttack(creature, creature.Combatant); break;

                    case CombatSpecialAction.PoisonBreathAttack: AICombatSpecialAction.DoPoisonBreathAttack(creature, creature.Combatant); break;
                    }

                    int specialActionDelay = (int)((double)Utility.RandomMinMax(creature.CombatSpecialActionMinDelay, creature.CombatSpecialActionMaxDelay));

                    creature.NextCombatSpecialActionAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(specialActionDelay);
                    creature.NextCombatEpicActionAllowed    = creature.NextCombatEpicActionAllowed.AddSeconds(5);

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

                    return(true);
                }

                CumulativeAmount += AdditionalAmount;
            }

            return(false);
        }