Пример #1
0
        public override void LoadContent()
        {
            // make rooms separately, add Floor class to hold rooms

            Game1.Player.LoadContent();

            if (_newGame)
            {
                GenerateFloor(3);

                foreach (Room room in _floor)
                {
                    room.LoadContent();
                }

                _newGame = false;
            }

            ActionInterface = new CombatInterface(Enemy, this);
            ActionInterface.LoadContent();

            //SpellHandler.LoadContent();

            // switch game state
            Game1.GameState = Game1.State.Playing;
        }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            CombatInterface.UpdateBar("enemyHealth", _maxHp, _hp);

            CombatInterface.UpdateBar("enemyMana", _maxMana, _mana);

            if (!ActionScreen.PlayerTurn)
            {
                UseTurn(gameTime);
            }
        }
        public override void Update(long msTick)
        {
            if (msTick <= _rezTime)
            {
                return;
            }

            _slayerChoppa.RezUnit(_slayerChoppa.Realm == Realms.REALMS_REALM_ORDER ? (ushort)1489 : (ushort)1795, 25, true);

            AbilityDamageInfo damageThisPass = AbilityMgr.GetExtraDamageFor(_slayerChoppa.Realm == Realms.REALMS_REALM_ORDER ? (ushort)1489 : (ushort)1795, 0, 0);

            List <Object> objects;

            lock (_slayerChoppa.PlayersInRange)
                objects = new List <Object>(_slayerChoppa.ObjectsInRange);

            int count = 0;

            foreach (Object obj in objects)
            {
                Unit unit = obj as Unit;
                if (unit == null || unit == _slayerChoppa)
                {
                    continue;
                }

                if (unit.ObjectWithinRadiusFeet(_slayerChoppa, 40) && CombatInterface.CanAttack(_slayerChoppa, unit) && _slayerChoppa.LOSHit(unit))
                {
                    CombatManager.InflictDamage(damageThisPass.Clone(), _slayerChoppa.AbtInterface.GetMasteryLevelFor(3), _slayerChoppa, unit);
                }

                ++count;

                if (count == 9)
                {
                    break;
                }
            }

            Dispose();
        }
Пример #4
0
        /// <summary>
        /// Identifies target of an ability before it is casted and checks its validity (pvp flag, visibility...).
        /// </summary>
        /// <param name="abInfo">Ability that is about to be casted</param>
        /// <param name="instigator">Instigator of the ability</param>
        /// <param name="foeVisible">True if current targeted foe is visible</param>
        /// <param name="allyVisible">True if current targeted ally is visible</param>
        /// <returns>True if target is valid for the ability</returns>
        private bool GetTarget(AbilityInfo abInfo, Unit instigator, bool foeVisible, bool allyVisible)
        {
            if (_pendingInfo.Range == 0 || _pendingInfo.CommandInfo == null)
            {
                _pendingInfo.Target = _caster;
                return(true);
            }

            if (_pendingInfo.TargetType == CommandTargetTypes.SiegeCannon)
            {
                _pendingInfo.Target = ((Creature)_caster).SiegeInterface.BuildTargetList(instigator);
                return(true);
            }

            CommandTargetTypes selectType = (CommandTargetTypes)((int)_pendingInfo.TargetType & 7);

            switch (selectType)
            {
            case CommandTargetTypes.Caster:
                _pendingInfo.Target = _caster;
                break;

            case CommandTargetTypes.Ally:
                if (!allyVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ALLY);
                if (_pendingInfo.Target == _caster || !CombatInterface.IsFriend(_caster, _pendingInfo.Target) || (_pendingInfo.Target is Creature && !(_pendingInfo.Target is Pet)))
                {
                    return(false);
                }
                if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates))
                {
                    Group myGroup = ((Player)_caster).PriorityGroup;
                    if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                    {
                        return(false);
                    }
                }
                break;

            case CommandTargetTypes.AllyOrSelf:
                if (!allyVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ALLY) ?? _caster;

                if (!CombatInterface.IsFriend(_caster, _pendingInfo.Target) ||
                    (_pendingInfo.Target is Creature && !(_pendingInfo.Target is Pet)))
                {
                    if ((_pendingInfo.Target is Boss) && (_caster is Creature))
                    {
                        // Allow healing on a boss -- careful to not allow lord heal from player
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (_pendingInfo.Target != _caster)
                {
                    if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates))
                    {
                        Group myGroup = ((Player)_caster).PriorityGroup;
                        if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                        {
                            return(false);
                        }
                    }
                }
                break;

            case CommandTargetTypes.AllyOrCareerTarget:
                if (!allyVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ALLY);

                if (!CombatInterface.IsFriend(_caster, _pendingInfo.Target) || _pendingInfo.Target != null && (_pendingInfo.Target is Creature && !(_pendingInfo.Target is Pet)))
                {
                    return(false);
                }
                if (_pendingInfo.Target != null && _pendingInfo.Target != _caster)
                {
                    if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates))
                    {
                        Group myGroup = ((Player)_caster).PriorityGroup;
                        if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    Player petCareerPlr = null;
                    if (_caster is Player)
                    {
                        petCareerPlr = _caster as Player;
                    }
                    if (petCareerPlr != null)
                    {
                        _pendingInfo.Target = petCareerPlr.CrrInterface.GetTargetOfInterest();
                    }

                    if (_pendingInfo.Target == null || _pendingInfo.Target == _caster)
                    {
                        _pendingInfo.Target = null;
                        return(false);
                    }
                }

                break;

            case CommandTargetTypes.Enemy:
                if (!foeVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ENEMY);
                if (!CombatInterface.CanAttack(_caster, _pendingInfo.Target))
                {
                    _pendingInfo.Target = null;
                }
                else
                {
                    if (!_caster.CbtInterface.IsPvp)
                    {
                        Player plrCaster = _caster as Player;
                        if (plrCaster != null && _pendingInfo.Target.CbtInterface.IsPvp)
                        {
                            ((CombatInterface_Player)plrCaster.CbtInterface).EnablePvp();
                        }
                    }
                }

                Player plrTarget = _pendingInfo.Target as Player;

                if (plrTarget != null && plrTarget.Palisade != null && (plrTarget.Palisade.IsObjectInFront(_caster, 180) ^ plrTarget.Palisade.IsObjectInFront(plrTarget, 180)))
                {
                    _pendingInfo.Target = plrTarget.Palisade;
                }

                //8410 - Terrible Embrace ; 9057 - Wings of Heaven ; 9178 - Fetch! ; 9186 - Pounce
                if (_pendingInfo.Target != null &&
                    (abInfo.Entry == 8410 || abInfo.Entry == 9057 || abInfo.Entry == 9178 || abInfo.Entry == 9186) &&
                    Math.Abs(_caster.Z - _pendingInfo.Target.Z) > 300)
                {
                    _caster.AbtInterface.SetCooldown(abInfo.Entry, -1);
                    return(false);
                }

                break;

            case CommandTargetTypes.CareerTarget:     // Target of Interest (oath friend/dark protector/pet if player, master if pet)
                var player = _caster as Player;
                if (player != null)
                {
                    _pendingInfo.Target = player.CrrInterface.GetTargetOfInterest();
                }
                else
                {
                    var pet = _caster as Pet;
                    if (pet != null)
                    {
                        _pendingInfo.Target = pet.Owner;
                    }
                    else
                    {
                        Log.Error("NewAbility", "Ability " + _pendingInfo.Entry + " with targettype 5 has no target!");
                        _pendingInfo.Target = null;
                    }
                }
                break;

            default:
                Log.Error("NewAbility", "Ability " + _pendingInfo.Entry + " with TargetType zero in 3 LSBs!");
                _pendingInfo.Target = _caster;
                break;
            }

            if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates) && _pendingInfo.Target != _caster)
            {
                Group myGroup = ((Player)_caster).PriorityGroup;
                if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                {
                    return(false);
                }
            }

            return(_pendingInfo.Target != null);
        }
Пример #5
0
        private void PropagateFoe()
        {
            int addedThisTick = 0;

            if (_otherPendingTargetList.Count > 0)
            {
                lock (_otherPendingTargetList)
                {
                    foreach (NewBuff buff in _otherPendingTargetList)
                    {
                        _otherTargetList.Add(buff.Target, new AuraInfo(buff, _passNum));
                    }

                    _otherPendingTargetList.Clear();
                }
            }

            foreach (Object obj in Target.ObjectsInRange)
            {
                Unit foe = obj as Unit;

                if (foe == null || foe.IsInvulnerable)
                {
                    continue;
                }

                if (!Target.IsDead && foe.ObjectWithinRadiusFeet(Target, MaxFoeRadius - 10) && CombatInterface.CanAttack(Caster, foe) && ((Caster is Creature) || (!(foe is Player) || foe.CbtInterface.IsPvp)) && Target.LOSHit(foe))
                {
                    if (_otherTargetList.ContainsKey(foe))
                    {
                        if (_otherTargetList[foe].Buff.BuffHasExpired)
                        {
                            _otherTargetList.Remove(foe);
                        }
                        else
                        {
                            _otherTargetList[foe].PassNum = _passNum;
                        }
                        continue;
                    }

                    if (addedThisTick + _otherTargetList.Count == 9)
                    {
                        continue;
                    }

                    if (Duration == 0)
                    {
                        foe.BuffInterface.QueueBuff(new BuffQueueInfo(Caster, BuffLevel, AbilityMgr.GetBuffInfo(_buffInfo.Entry, Caster, foe), RegisterOtherBuff));
                    }
                    else
                    {
                        BuffInfo BI = AbilityMgr.GetBuffInfo(_buffInfo.Entry, Caster, foe);
                        BI.IsAoE    = true;
                        BI.Duration = Math.Max((ushort)1, (ushort)(RemainingTimeMs * 0.001f));
                        foe.BuffInterface.QueueBuff(new BuffQueueInfo(Caster, BuffLevel, BI, RegisterOtherBuff));
                    }

                    ++addedThisTick;
                }

                else
                {
                    if (!_otherTargetList.ContainsKey(foe))
                    {
                        continue;
                    }

                    // Group member out of range - finish the buff and remove them
                    if (!_otherTargetList[foe].Buff.BuffHasExpired)
                    {
                        _otherTargetList[foe].Buff.BuffHasExpired = true;
                    }

                    _otherTargetList.Remove(foe);
                }
            }


            List <Unit> oldUnits = _otherTargetList.Keys.ToList();

            // Remove any units not refreshed on this tick
            foreach (Unit oldfoe in oldUnits)
            {
                if (_otherTargetList[oldfoe].PassNum == _passNum)
                {
                    continue;
                }

                _otherTargetList[oldfoe].Buff.BuffHasExpired = true;
                _otherTargetList.Remove(oldfoe);
            }
        }
Пример #6
0
        /// <summary>
        /// This method assigns aggro from heals and selects new target, based on current max hate
        /// </summary>
        private void ProcessAggro()
        {
            if (!_unit.IsPet())
            {
                ulong maxHatred     = 0;
                int   nextTargetOid = 0;
                Unit  nextTarget    = null;

                foreach (Player player in _unit.PlayersInRange.ToList())
                {
                    if (player != null && CombatInterface.CanAttack(_unit, player))
                    {
                        if (player.IsDead)
                        {
                            Aggros[player.Oid].Hatred = 0;
                        }
                        else
                        {
                            if (player.CbtInterface.IsInCombat)
                            {
                                foreach (KeyValuePair <ushort, AggroInfo> healAggro in player.HealAggros)
                                {
                                    foreach (KeyValuePair <ushort, AggroInfo> aggro in Aggros)
                                    {
                                        if (!(_unit is Pet) && healAggro.Key == aggro.Key && CombatStart < healAggro.Value.HealingReceivedTime && aggro.Value.HealingReceivedTime != healAggro.Value.HealingReceivedTime)
                                        {
                                            aggro.Value.Hatred += (ulong)((healAggro.Value.HealingReceived) * GetDetaunt(healAggro.Key));
                                            healAggro.Value.HealingReceivedTime = aggro.Value.HealingReceivedTime;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (Object obj in _unit.ObjectsInRange.ToList())
                {
                    Unit u = obj as Unit;
                    if (u != null && (!u.IsDead && !u.PendingDisposal && !u.IsDisposed) && CombatInterface.CanAttack(_unit, u))
                    {
                        foreach (KeyValuePair <ushort, AggroInfo> aggro in Aggros)
                        {
                            if (aggro.Key == obj.Oid)
                            {
                                if (aggro.Value.Hatred > maxHatred)
                                {
                                    maxHatred     = aggro.Value.Hatred;
                                    nextTargetOid = obj.Oid;
                                    nextTarget    = u;
                                }
                            }
                        }
                    }
                }

                if (nextTarget != null && _pet == null)
                {
                    AddHatred(nextTarget, nextTarget.IsPlayer(), 0);
                }
            }
        }
Пример #7
0
        public static void F_COMMAND_CONTROLLED(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            if (cclient.Plr?.CrrInterface == null)
            {
                return;
            }

            IPetCareerInterface petInterface = cclient.Plr.CrrInterface as IPetCareerInterface;

            Pet myPet = petInterface?.myPet;

            if (myPet == null)
            {
                return;
            }

            ushort     abilityid = packet.GetUint16();
            PetCommand command   = (PetCommand)packet.GetUint8();

            switch (command)
            {
            case PetCommand.Stay:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                myPet.MvtInterface.StopMove();
                myPet.FollowMode = 1;
                myPet.IsHeeling  = false;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Holding position by request.");
                myPet.SendPetUpdate();
                break;     // stay

            case PetCommand.Follow:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                myPet.AiInterface.ProcessCombatEnd();
                if (myPet.StsInterface.Speed == 0)
                {
                    break;
                }
                myPet.MvtInterface.ScaleSpeed(myPet.SpeedMult);
                myPet.MvtInterface.Recall(cclient.Plr);
                myPet.FollowMode = 2;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Heeling by request.");
                myPet.SendPetUpdate();
                break;     // heel

            case PetCommand.Passive:
                myPet.AiInterface.SetBrain(new PassiveBrain(myPet));
                petInterface.AIMode = 3;
                myPet.AIMode        = 3;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Passive state.");
                break;     // mode Passive

            case PetCommand.Defensive:
                myPet.AiInterface.SetBrain(new GuardBrain(myPet));
                petInterface.AIMode = 4;
                myPet.AIMode        = 4;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Defensive state.");
                break;     // mode Defensive

            case PetCommand.Aggressive:
                myPet.AiInterface.SetBrain(new AggressiveBrain(myPet));
                petInterface.AIMode = 5;
                myPet.AIMode        = 5;
                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Aggressive state.");
                break;     // mode Aggressive

            case PetCommand.Attack:
                long now = TCPManager.GetTimeStampMS();
                if (cclient.Plr.IsMounted || now <= myPet.AttackReuseTimer + COMMAND_ATTACK_REUSE)
                {
                    return;
                }
                myPet.AttackReuseTimer = now;
                Unit target = cclient.Plr.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ENEMY);
                if (target == null || !CombatInterface.CanAttack(myPet, target))
                {
                    return;
                }

                if (!cclient.Plr.LOSHit(target))
                {
                    return;
                }

                myPet.AiInterface.Debugger?.SendClientMessage("[MR]: Attacking by request.");
                myPet.IsHeeling  = false;
                myPet.FollowMode = 0;
                myPet.Owner.CbtInterface.RefreshCombatTimer();
                myPet.AiInterface.ProcessCombatStart(target);
                myPet.SendPetUpdate();
                break;     //attack

            case PetCommand.Release:
                myPet.Destroy();
                break;

            case PetCommand.AbilityCast:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                foreach (NPCAbility pa in myPet.AbtInterface.NPCAbilities)
                {
                    if (pa.Entry == abilityid)
                    {
                        if (pa.Range > 0)
                        {
                            Unit abTarget = myPet.CbtInterface.GetCurrentTarget();
                            if (abTarget == null || !myPet.LOSHit(abTarget))
                            {
                                return;
                            }
                        }
                        myPet.AbtInterface.StartCast(myPet, abilityid, 1);
                        break;
                    }
                }
                break;

            case PetCommand.Autocast:
                if (cclient.Plr.IsMounted)
                {
                    return;
                }
                foreach (NPCAbility pa in myPet.AbtInterface.NPCAbilities)
                {
                    if (pa.Entry != abilityid)
                    {
                        continue;
                    }

                    pa.AutoUse = !pa.AutoUse;
                    myPet.SendPetUpdate();
                    break;
                }
                break;
            }
        }
Пример #8
0
        public override void Update(GameTime gameTime)
        {
            CombatInterface.UpdateBar("playerHealth", _maxHp, _hp);

            CombatInterface.UpdateBar("playerMana", _maxMana, _mana);
        }
Пример #9
0
 public override void Unload()
 {
     ActionInterface = null;
     // give player info back to game1
     Game1.GameContent.Unload();
 }