Beispiel #1
0
        //Calculates bonus EXP for Links and Chains
        public static void AddBattleBonusEXP(Player attacker, BattleNpc defender, CommandResultContainer actionContainer)
        {
            ushort baseExp = GetBaseEXP(attacker, defender);

            //Only bother calculating the rest if there's actually exp to be gained.
            //0 exp sends no message
            if (baseExp > 0)
            {
                int totalBonus = 0;//GetMod(Modifier.bonusEXP)

                var linkCount = defender.GetMobMod(MobModifier.LinkCount);
                totalBonus += GetLinkBonus((byte)Math.Min(linkCount, 255));

                StatusEffect effect         = attacker.statusEffects.GetStatusEffectById((uint)StatusEffectId.EXPChain);
                ushort       expChainNumber = 0;
                uint         timeLimit      = 100;
                if (effect != null)
                {
                    expChainNumber = effect.GetTier();
                    timeLimit      = (uint)(GetChainTimeLimit(expChainNumber));
                    actionContainer?.AddEXPAction(new CommandResult(attacker.actorId, 33919, 0, expChainNumber, (byte)timeLimit));
                }

                totalBonus += GetChainBonus(expChainNumber);

                StatusEffect newChain = Server.GetWorldManager().GetStatusEffect((uint)StatusEffectId.EXPChain);
                newChain.SetSilent(true);
                newChain.SetDuration(timeLimit);
                newChain.SetTier((byte)(Math.Min(expChainNumber + 1, 255)));
                attacker.statusEffects.AddStatusEffect(newChain, attacker, true, true);

                actionContainer?.AddEXPActions(attacker.AddExp(baseExp, (byte)attacker.GetClass(), (byte)(totalBonus.Min(255))));
            }
        }
 public BattleNpcController(BattleNpc owner) :
     base(owner)
 {
     this.owner      = owner;
     this.lastUpdate = DateTime.Now;
     this.waitTime   = lastUpdate.AddSeconds(5);
 }
Beispiel #3
0
        private bool CanUseAction(StackEntry targ)
        {
            if (targ.target == null || targ.actionID == 0)
            {
                return(false);
            }
            var action = RawActions.SingleOrDefault(row => (ulong)row.RowId == targ.actionID);


            for (var i = 0; i < this.pluginInterface.ClientState.Actors.Length; i++)
            {
                var a = this.pluginInterface.ClientState.Actors[i];
                if (a != null && a.ActorId == targ.target.GetTargetActorId())
                {
                    if (Configuration.RangeCheck)
                    {
                        if (UnorthodoxFriendly.Contains((uint)action.RowId))
                        {
                            if (a.YalmDistanceX > 30)
                            {
                                return(false);
                            }
                        }
                        else if ((byte)action.Range < a.YalmDistanceX)
                        {
                            return(false);
                        }
                    }
                    if (a is PlayerCharacter)
                    {
                        return(action.CanTargetFriendly || action.CanTargetParty ||
                               action.CanTargetSelf ||
                               action.RowId == 17055 || action.RowId == 7443);
                    }
                    if (a is BattleNpc)
                    {
                        BattleNpc b = (BattleNpc)a;
                        if (b.BattleNpcKind != BattleNpcSubKind.Enemy)
                        {
                            return(action.CanTargetFriendly || action.CanTargetParty ||
                                   action.CanTargetSelf ||
                                   UnorthodoxFriendly.Contains((uint)action.RowId));
                        }
                    }
                    return(action.CanTargetHostile || UnorthodoxHostile.Contains((uint)action.RowId));
                }
            }
            return(false);
        }
Beispiel #4
0
        //See 1.19 patch notes for exp info.
        public static ushort GetBaseEXP(Player player, BattleNpc mob)
        {
            //The way EXP seems to work for most enemies is that it gets the lower character's level, gets the base exp for that level, then uses dlvl to modify that exp
            //Less than -19 dlvl gives 0 exp and no message is sent.
            //This equation doesn't seem to work for certain bosses or NMs.
            //Some enemies might give less EXP? Unsure on this. It seems like there might have been a change in base exp amounts after 1.19

            //Example:
            //Level 50 in a party kills a level 45 enemy
            //Base exp is 400, as that's the base EXP for level 45
            //That's multiplied by the dlvl modifier for -5, which is 0.5625, which gives 225
            //That's then multiplied by the party modifier, which seems to be 0.667 regardless of party size, which gives 150
            //150 is then modified by bonus experience from food, rested exp, links, and chains

            int dlvl = mob.GetLevel() - player.GetLevel();

            if (dlvl <= -20)
            {
                return(0);
            }

            int    baseLevel = Math.Min(player.GetLevel(), mob.GetLevel());
            ushort baseEXP   = BASEEXP[baseLevel];

            double dlvlModifier = 1.0;

            //There's 2 functions depending on if the dlvl is positive or negative.
            if (dlvl >= 0)
            {
                //I'm not sure if this caps out at some point. This is correct up to at least +9 dlvl though.
                dlvlModifier += 0.2 * dlvl;
            }
            else
            {
                //0.1x + 0.0025x^2
                dlvlModifier += 0.1 * dlvl + 0.0025 * (dlvl * dlvl);
            }

            //The party modifier isn't clear yet. It seems like it might just be 0.667 for any number of members in a group, but the 1.19 notes say it's variable
            //There also seem to be some cases where it simply doesn't apply but it isn't obvious if that's correct or when it applies if it is correct
            double partyModifier = player.currentParty.GetMemberCount() == 1 ? 1.0 : 0.667;

            baseEXP = (ushort)(baseEXP * dlvlModifier * partyModifier);

            return(baseEXP);
        }
Beispiel #5
0
 private void CreateNpc(BattleNpc npc, NpcIds npcIds)
 {
     npc.AltarNpc = CreateSceneNpc(npcIds.AltarId);
 }