Esempio n. 1
0
        public override bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool quiet)
        {
            if (!base.IsAllowedToAttack(attacker, defender, quiet))
            {
                return(false);
            }

            // if controlled NPC - do checks for owner instead
            if (attacker is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)attacker).Brain as IControlledBrain;
                if (controlled != null)
                {
                    attacker = controlled.GetLivingOwner();
                    quiet    = true;                  // silence all attacks by controlled npc
                }
            }
            if (defender is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)defender).Brain as IControlledBrain;
                if (controlled != null)
                {
                    defender = controlled.GetLivingOwner();
                }
            }

            //"You can't attack yourself!"
            if (attacker == defender)
            {
                if (quiet == false)
                {
                    MessageToLiving(attacker, "You can't attack yourself!");
                }
                return(false);
            }

            //Don't allow attacks on same realm members on Normal Servers
            if (attacker.Realm == defender.Realm && !(attacker is GamePlayer && ((GamePlayer)attacker).DuelTarget == defender))
            {
                // allow confused mobs to attack same realm
                if (attacker is GameNPC && (attacker as GameNPC).IsConfused)
                {
                    return(true);
                }

                if (attacker.Realm == 0)
                {
                    return(FactionMgr.CanLivingAttack(attacker, defender));
                }

                if (quiet == false)
                {
                    MessageToLiving(attacker, "You can't attack a member of your realm!");
                }
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet)
        {
            if (source == null || target == null)
            {
                return(false);
            }

            // if controlled NPC - do checks for owner instead
            if (source is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain;
                if (controlled != null)
                {
                    source = controlled.GetLivingOwner();
                    quiet  = true;                    // silence all attacks by controlled npc
                }
            }
            if (target is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain;
                if (controlled != null)
                {
                    target = controlled.GetLivingOwner();
                }
            }

            if (source == target)
            {
                return(true);
            }

            // clients with priv level > 1 are considered friendly by anyone
            if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1)
            {
                return(true);
            }
            // checking as a gm, targets are considered friendly
            if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1)
            {
                return(true);
            }

            // mobs can heal mobs, players heal players/NPC
            if (source.Realm == 0 && target.Realm == 0)
            {
                return(true);
            }

            //keep guards
            if (source is GameKeepGuard && target is GamePlayer)
            {
                if (!GameServer.KeepManager.IsEnemy(source as GameKeepGuard, target as GamePlayer))
                {
                    return(true);
                }
            }

            if (target is GameKeepGuard && source is GamePlayer)
            {
                if (!GameServer.KeepManager.IsEnemy(target as GameKeepGuard, source as GamePlayer))
                {
                    return(true);
                }
            }

            //doors need special handling
            if (target is GameKeepDoor && source is GamePlayer)
            {
                return(GameServer.KeepManager.IsEnemy(target as GameKeepDoor, source as GamePlayer));
            }

            if (source is GameKeepDoor && target is GamePlayer)
            {
                return(GameServer.KeepManager.IsEnemy(source as GameKeepDoor, target as GamePlayer));
            }

            //components need special handling
            if (target is GameKeepComponent && source is GamePlayer)
            {
                return(GameServer.KeepManager.IsEnemy(target as GameKeepComponent, source as GamePlayer));
            }

            //Peace flag NPCs are same realm
            if (target is GameNPC)
            {
                if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0)
                {
                    return(true);
                }
            }

            if (source is GameNPC)
            {
                if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0)
                {
                    return(true);
                }
            }

            if (source is GamePlayer && target is GamePlayer)
            {
                return(true);
            }

            if (source is GamePlayer && target is GameNPC && target.Realm != 0)
            {
                return(true);
            }

            if (quiet == false)
            {
                MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!");
            }
            return(false);
        }
Esempio n. 3
0
        public override bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool quiet)
        {
            if (!base.IsAllowedToAttack(attacker, defender, quiet))
            {
                return(false);
            }

            // if controlled NPC - do checks for owner instead
            if (attacker is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)attacker).Brain as IControlledBrain;
                if (controlled != null)
                {
                    attacker = controlled.GetLivingOwner();
                    quiet    = true;                  // silence all attacks by controlled npc
                }
            }
            if (defender is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)defender).Brain as IControlledBrain;
                if (controlled != null)
                {
                    defender = controlled.GetLivingOwner();
                }
            }

            // can't attack self
            if (attacker == defender)
            {
                if (quiet == false)
                {
                    MessageToLiving(attacker, "You can't attack yourself!");
                }
                return(false);
            }

            //ogre: sometimes other players shouldn't be attackable
            GamePlayer playerAttacker = attacker as GamePlayer;
            GamePlayer playerDefender = defender as GamePlayer;

            if (playerAttacker != null && playerDefender != null)
            {
                //check group
                if (playerAttacker.Group != null && playerAttacker.Group.IsInTheGroup(playerDefender))
                {
                    if (!quiet)
                    {
                        MessageToLiving(playerAttacker, "You can't attack your group members.");
                    }
                    return(false);
                }

                if (playerAttacker.DuelTarget != defender)
                {
                    //check guild
                    if (playerAttacker.Guild != null && playerAttacker.Guild == playerDefender.Guild)
                    {
                        if (!quiet)
                        {
                            MessageToLiving(playerAttacker, "You can't attack your guild members.");
                        }
                        return(false);
                    }

                    // Player can't hit other members of the same BattleGroup
                    BattleGroup mybattlegroup = (BattleGroup)playerAttacker.TempProperties.getProperty <object>(BattleGroup.BATTLEGROUP_PROPERTY, null);

                    if (mybattlegroup != null && mybattlegroup.IsInTheBattleGroup(playerDefender))
                    {
                        if (!quiet)
                        {
                            MessageToLiving(playerAttacker, "You can't attack a member of your battlegroup.");
                        }
                        return(false);
                    }

                    // Safe regions
                    if (m_safeRegions != null)
                    {
                        foreach (int reg in m_safeRegions)
                        {
                            if (playerAttacker.CurrentRegionID == reg)
                            {
                                if (quiet == false)
                                {
                                    MessageToLiving(playerAttacker, "You're currently in a safe zone, you can't attack other players here.");
                                }
                                return(false);
                            }
                        }
                    }


                    // Players with safety flag can not attack other players
                    if (playerAttacker.Level < m_safetyLevel && playerAttacker.SafetyFlag)
                    {
                        if (quiet == false)
                        {
                            MessageToLiving(attacker, "Your PvP safety flag is ON.");
                        }
                        return(false);
                    }

                    // Players with safety flag can not be attacked in safe regions
                    if (playerDefender.Level < m_safetyLevel && playerDefender.SafetyFlag)
                    {
                        bool unsafeRegion = false;
                        foreach (int regionID in m_unsafeRegions)
                        {
                            if (regionID == playerDefender.CurrentRegionID)
                            {
                                unsafeRegion = true;
                                break;
                            }
                        }
                        if (unsafeRegion == false)
                        {
                            //"PLAYER has his safety flag on and is in a safe area, you can't attack him here."
                            if (quiet == false)
                            {
                                MessageToLiving(attacker, playerDefender.Name + " has " + playerDefender.GetPronoun(1, false) + " safety flag on and is in a safe area, you can't attack " + playerDefender.GetPronoun(2, false) + " here.");
                            }
                            return(false);
                        }
                    }
                }
            }

            if (attacker.Realm == 0 && defender.Realm == 0)
            {
                return(FactionMgr.CanLivingAttack(attacker, defender));
            }

            //allow confused mobs to attack same realm
            if (attacker is GameNPC && (attacker as GameNPC).IsConfused && attacker.Realm == defender.Realm)
            {
                return(true);
            }

            // "friendly" NPCs can't attack "friendly" players
            if (defender is GameNPC && defender.Realm != 0 && attacker.Realm != 0 && defender is GameKeepGuard == false && defender is GameFont == false)
            {
                if (quiet == false)
                {
                    MessageToLiving(attacker, "You can't attack a friendly NPC!");
                }
                return(false);
            }
            // "friendly" NPCs can't be attacked by "friendly" players
            if (attacker is GameNPC && attacker.Realm != 0 && defender.Realm != 0 && attacker is GameKeepGuard == false)
            {
                return(false);
            }

            #region Keep Guards
            //guard vs guard / npc
            if (attacker is GameKeepGuard)
            {
                if (defender is GameKeepGuard)
                {
                    return(false);
                }

                if (defender is GameNPC && (defender as GameNPC).Brain is IControlledBrain == false)
                {
                    return(false);
                }
            }

            //player vs guard
            if (defender is GameKeepGuard && attacker is GamePlayer &&
                GameServer.KeepManager.IsEnemy(defender as GameKeepGuard, attacker as GamePlayer) == false)
            {
                if (quiet == false)
                {
                    MessageToLiving(attacker, "You can't attack a friendly NPC!");
                }
                return(false);
            }

            //guard vs player
            if (attacker is GameKeepGuard && defender is GamePlayer &&
                GameServer.KeepManager.IsEnemy(attacker as GameKeepGuard, defender as GamePlayer) == false)
            {
                return(false);
            }
            #endregion

            return(true);
        }
Esempio n. 4
0
        public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet)
        {
            if (source == null || target == null)
            {
                return(false);
            }

            // if controlled NPC - do checks for owner instead
            if (source is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain;
                if (controlled != null)
                {
                    source = controlled.GetLivingOwner();
                    quiet  = true;                    // silence all attacks by controlled npc
                }
            }
            if (target is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain;
                if (controlled != null)
                {
                    target = controlled.GetLivingOwner();
                }
            }

            if (source == target)
            {
                return(true);
            }

            // clients with priv level > 1 are considered friendly by anyone
            if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1)
            {
                return(true);
            }
            // checking as a gm, targets are considered friendly
            if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1)
            {
                return(true);
            }

            //Peace flag NPCs are same realm
            if (target is GameNPC)
            {
                if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0)
                {
                    return(true);
                }
            }

            if (source is GameNPC)
            {
                if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0)
                {
                    return(true);
                }
            }

            if (source.Realm != target.Realm)
            {
                if (quiet == false)
                {
                    MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!");
                }
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        public override int CalcValue(GameLiving living, eProperty property)
        {
            if (living.IsMezzed || living.IsStunned)
            {
                return(0);
            }

            double speed = living.BuffBonusMultCategory1.Get((int)property);

            if (living is GamePlayer)
            {
                GamePlayer player = (GamePlayer)living;
                //				Since Dark Age of Camelot's launch, we have heard continuous feedback from our community about the movement speed in our game. The concerns over how slow
                //				our movement is has continued to grow as we have added more and more areas in which to travel. Because we believe these concerns are valid, we have decided
                //				to make a long requested change to the game, enhancing the movement speed of all players who are out of combat. This new run state allows the player to move
                //				faster than normal run speed, provided that the player is not in any form of combat. Along with this change, we have slightly increased the speed of all
                //				secondary speed buffs (see below for details). Both of these changes are noticeable but will not impinge upon the supremacy of the primary speed buffs available
                //				to the Bard, Skald and Minstrel.
                //				- The new run speed does not work if the player is in any form of combat. All combat timers must also be expired.
                //				- The new run speed will not stack with any other run speed spell or ability, except for Sprint.
                //				- Pets that are not in combat have also received the new run speed, only when they are following, to allow them to keep up with their owners.
                double horseSpeed = (player.IsOnHorse ? player.ActiveHorse.Speed * 0.01 : 1.0);
                if (speed > horseSpeed)
                {
                    horseSpeed = 1.0;
                }

                if (ServerProperties.Properties.ENABLE_PVE_SPEED)
                {
                    if (speed == 1 && !player.InCombat && !player.IsStealthed && !player.CurrentRegion.IsRvR)
                    {
                        speed *= 1.25;                         // new run speed is 125% when no buff
                    }
                }

                if (player.IsOverencumbered && player.Client.Account.PrivLevel < 2 && ServerProperties.Properties.ENABLE_ENCUMBERANCE_SPEED_LOSS)
                {
                    double Enc = player.Encumberance;                     // calculating player.Encumberance is a bit slow with all those locks, don't call it much
                    if (Enc > player.MaxEncumberance)
                    {
                        speed *= ((((player.MaxSpeedBase * 1.0 / GamePlayer.PLAYER_BASE_SPEED) * (-Enc)) / (player.MaxEncumberance * 0.35f)) + (player.MaxSpeedBase / GamePlayer.PLAYER_BASE_SPEED) + ((player.MaxSpeedBase / GamePlayer.PLAYER_BASE_SPEED) * player.MaxEncumberance / (player.MaxEncumberance * 0.35)));
                        if (speed <= 0)
                        {
                            speed = 0;
                            player.Out.SendMessage("You are encumbered and cannot move.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        }
                    }
                    else
                    {
                        player.IsOverencumbered = false;
                    }
                }
                if (player.IsStealthed)
                {
                    MasteryOfStealthAbility mos       = player.GetAbility <MasteryOfStealthAbility>();
                    GameSpellEffect         bloodrage = SpellHandler.FindEffectOnTarget(player, "BloodRage");
                    VanishEffect            vanish    = player.EffectList.GetOfType <VanishEffect>();

                    double stealthSpec = player.GetModifiedSpecLevel(Specs.Stealth);
                    if (stealthSpec > player.Level)
                    {
                        stealthSpec = player.Level;
                    }
                    speed *= 0.3 + (stealthSpec + 10) * 0.3 / (player.Level + 10);
                    if (vanish != null)
                    {
                        speed *= vanish.SpeedBonus;
                    }
                    if (mos != null)
                    {
                        speed *= 1 + MasteryOfStealthAbility.GetSpeedBonusForLevel(mos.Level);
                    }
                    if (bloodrage != null)
                    {
                        speed *= 1 + (bloodrage.Spell.Value * 0.01);                         // 25 * 0.01 = 0.25 (a.k 25%) value should be 25.
                    }
                }

                if (GameRelic.IsPlayerCarryingRelic(player))
                {
                    if (speed > 1.0)
                    {
                        speed = 1.0;
                    }

                    horseSpeed = 1.0;
                }

                if (player.IsSprinting)
                {
                    speed *= 1.3;
                }

                speed *= horseSpeed;
            }
            else if (living is GameNPC)
            {
                if (!living.InCombat)
                {
                    IControlledBrain brain = ((GameNPC)living).Brain as IControlledBrain;
                    if (brain != null)
                    {
                        GameLiving owner = brain.GetLivingOwner();
                        if (owner != null)
                        {
                            if (owner == brain.Body.CurrentFollowTarget)
                            {
                                speed *= 1.25;

                                double ownerSpeedAdjust = (double)owner.MaxSpeed / (double)GamePlayer.PLAYER_BASE_SPEED;

                                if (ownerSpeedAdjust > 1.0)
                                {
                                    speed *= ownerSpeedAdjust;
                                }

                                if (owner is GamePlayer && (owner as GamePlayer).IsOnHorse)
                                {
                                    speed *= 1.45;
                                }
                            }
                        }
                    }
                }

                double healthPercent = living.Health / (double)living.MaxHealth;
                if (healthPercent < 0.33)
                {
                    speed *= 0.2 + healthPercent * (0.8 / 0.33);                     //33%hp=full speed 0%hp=20%speed
                }
            }

            speed = living.MaxSpeedBase * speed + 0.5;             // 0.5 is to fix the rounding error when converting to int so root results in speed 2 (191*0.01=1.91+0.5=2.41)

            GameSpellEffect iConvokerEffect = SpellHandler.FindEffectOnTarget(living, "SpeedWrap");

            if (iConvokerEffect != null && living.EffectList.GetOfType <ChargeEffect>() == null)
            {
                if (living.EffectList.GetOfType <SprintEffect>() != null && speed > 248)
                {
                    return(248);
                }
                else if (speed > 191)
                {
                    return(191);
                }
            }

            if (speed < 0)
            {
                return(0);
            }

            return((int)speed);
        }