Example #1
0
        public void GiveExpToCharacter(MapleCharacter attacker, int exp, bool highestDamage, int numExpSharers)
        {
            if (Id == 9300027)
            {
                exp = 1;
            }
            if (highestDamage)
            {
                //if (eventInstance != null)
                //{
                //    eventInstance.monsterKilled(attacker, this);
                //}
                m_highestDamageChar = attacker;
            }
            if (attacker.Hp > 0)
            {
                var personalExp = exp;
                if (exp > 0)
                {
                    if (m_stati.ContainsKey(MonsterStatus.Taunt))
                    {
                        var alterExp = m_stati[MonsterStatus.Taunt].Stati[MonsterStatus.Taunt];
                        personalExp *= (int)(1.0 + alterExp / 100.0);
                    }
                    var holySymbol = attacker.GetBuffedValue(MapleBuffStat.HolySymbol);
                    if (holySymbol != null)
                    {
                        if (numExpSharers == 1)
                        {
                            personalExp *= (int)(1.0 + holySymbol.Value / 500.0);
                        }
                        else
                        {
                            personalExp *= (int)(1.0 + holySymbol.Value / 100.0);
                        }
                    }
                }
                if (exp < 0)
                {
                    personalExp = int.MaxValue;
                }
                personalExp /= attacker.Diseases.Contains(MapleDisease.Curse) ? 2 : 1;
                attacker.GainExp(personalExp, true, false, highestDamage);

                try
                {
                    attacker.MobKilled(Id);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
Example #2
0
        public static void GainExp(string[] split, MapleClient c)
        {
            MapleCharacter chr = c.Account.Character;

            if (split.Length > 1)
            {
                int exp = int.Parse(split[1]);
                if (exp > 0)
                {
                    chr.GainExp(exp);
                }
            }
        }
Example #3
0
        public override void Act(MapleCharacter chr, int questId)
        {
            switch (Type)
            {
            case QuestActionType.exp:     //int: give exp
                chr.GainExp(Data, true, false);
                break;

            case QuestActionType.money:     //int: mesars
                chr.Inventory.GainMesos(Data, false, true);
                break;

            case QuestActionType.buffItemID:     //int: apply item effect to player
                //todo data = item id
                break;

            case QuestActionType.pop:     //int: fame
                chr.AddFame(Data);
                break;

            case QuestActionType.nextQuest:     //int: next quest in chain? check moopledev/v118
                //todo
                break;

            case QuestActionType.willEXP:     //int
                chr.AddTraitExp(Data, MapleCharacterStat.Will);
                break;

            case QuestActionType.senseEXP:     //int
                chr.AddTraitExp(Data, MapleCharacterStat.Sense);
                break;

            case QuestActionType.insightEXP:     //int
                chr.AddTraitExp(Data, MapleCharacterStat.Insight);
                break;

            case QuestActionType.craftEXP:     //int
                chr.AddTraitExp(Data, MapleCharacterStat.Craft);
                break;

            case QuestActionType.charismaEXP:     //int
                chr.AddTraitExp(Data, MapleCharacterStat.Charisma);
                break;

            case QuestActionType.charmEXP:     //int
                chr.AddTraitExp(Data, MapleCharacterStat.Charm);
                break;
            }
        }
Example #4
0
        public void Run(MapleCharacter c, int?extSelection)
        {
            MapleQuestStatus status;

            switch (Type)
            {
            case MapleQuestActionType.Exp:
                status = c.GetQuest(m_quest);
                if (status.Status == MapleQuestStatusType.NotStarted && status.Forfeited > 0)
                {
                    break;
                }
                c.GainExp(MapleDataTool.GetInt(Data) * c.Client.ChannelServer.ExpRate, true, true);
                break;

            case MapleQuestActionType.Item:
                var ii    = MapleItemInformationProvider.Instance;
                var props = new Dictionary <int, int>();
                foreach (var iEntry in Data.Children)
                {
                    if (iEntry.GetChildByPath("prop") != null &&
                        MapleDataTool.GetInt(iEntry.GetChildByPath("prop")) != -1 && CanGetItem(iEntry, c))
                    {
                        for (var i = 0; i < MapleDataTool.GetInt(iEntry.GetChildByPath("prop")); i++)
                        {
                            props.Add(props.Count, MapleDataTool.GetInt(iEntry.GetChildByPath("id")));
                        }
                    }
                }
                var selection = 0;
                var extNum    = 0;
                if (props.Any())
                {
                    props.TryGetValue((int)(Randomizer.NextDouble() * props.Count), out selection);
                }
                foreach (var iEntry in Data.Children)
                {
                    if (!CanGetItem(iEntry, c))
                    {
                        continue;
                    }
                    if (iEntry.GetChildByPath("prop") != null)
                    {
                        if (MapleDataTool.GetInt(iEntry.GetChildByPath("prop")) == -1)
                        {
                            if (extSelection.HasValue && extSelection.Value != extNum++)
                            {
                                continue;
                            }
                        }
                        else if (MapleDataTool.GetInt(iEntry.GetChildByPath("id")) != selection)
                        {
                            continue;
                        }
                    }
                    if (MapleDataTool.GetInt(iEntry.GetChildByPath("count"), 0) < 0)
                    {
                        // remove items

                        var itemId   = MapleDataTool.GetInt(iEntry.GetChildByPath("id"));
                        var iType    = ii.GetInventoryType(itemId);
                        var quantity = (short)(MapleDataTool.GetInt(iEntry.GetChildByPath("count"), 0) * -1);
                        try
                        {
                            //MapleInventoryManipulator.removeById(c.Client, iType, itemId, quantity, true, false);
                        }
                        catch
                        {
                            Console.WriteLine("Completing a quest without meeting the requirements");
                        }
                        c.Client.Send(PacketCreator.GetShowItemGain(itemId,
                                                                    (short)MapleDataTool.GetInt(iEntry.GetChildByPath("count"), 0), true));
                    }
                    else
                    {
                        // add items

                        var itemId   = MapleDataTool.GetInt(iEntry.GetChildByPath("id"));
                        var quantity = (short)MapleDataTool.GetInt(iEntry.GetChildByPath("count"), 0);
                        var logInfo  = new StringBuilder(c.Name);
                        logInfo.Append(" received ");
                        logInfo.Append(quantity);
                        logInfo.Append(" as reward from a quest");
                        // MapleInventoryManipulator.addById(c.Client, itemId, quantity, logInfo.ToString(), null, -1);
                        c.Client.Send(PacketCreator.GetShowItemGain(itemId, quantity, true));
                    }
                }
                break;

            case MapleQuestActionType.Nextquest:
                status = c.GetQuest(m_quest);
                var nextQuest = MapleDataTool.GetInt(Data);
                if (status.Status == MapleQuestStatusType.NotStarted && status.Forfeited > 0)
                {
                    break;
                }
                c.Client.Send(PacketCreator.UpdateQuestFinish((short)m_quest.GetQuestId(), status.Npcid,
                                                              (short)nextQuest));
                MapleQuest.GetInstance(nextQuest).Start(c, status.Npcid);
                break;

            case MapleQuestActionType.Meso:
                status = c.GetQuest(m_quest);
                if (status.Status == MapleQuestStatusType.NotStarted && status.Forfeited > 0)
                {
                    break;
                }
                c.GainMeso(MapleDataTool.GetInt(Data), true, false, true);
                break;

            case MapleQuestActionType.Quest:
                foreach (var qEntry in Data)
                {
                    var questid = MapleDataTool.GetInt(qEntry.GetChildByPath("id"));
                    var stat    = MapleDataTool.GetInt(qEntry.GetChildByPath("state"), 0);
                    c.UpdateQuest(new MapleQuestStatus(MapleQuest.GetInstance(questid), (MapleQuestStatusType)stat));
                }
                break;

            case MapleQuestActionType.Skill:
                foreach (var sEntry in Data)
                {
                    var skillid        = MapleDataTool.GetInt(sEntry.GetChildByPath("id"));
                    var skillLevel     = (byte)MapleDataTool.GetInt(sEntry.GetChildByPath("skillLevel"));
                    var masterLevel    = (byte)MapleDataTool.GetInt(sEntry.GetChildByPath("masterLevel"));
                    var skillObject    = SkillFactory.GetSkill(skillid);
                    var shouldLearn    = false;
                    var applicableJobs = sEntry.GetChildByPath("job");
                    foreach (var applicableJob in applicableJobs)
                    {
                        var job = MapleJob.GetByJobId(MapleDataTool.GetShort(applicableJob));
                        if (c.Job == job)
                        {
                            shouldLearn = true;
                            break;
                        }
                    }
                    if (skillObject.IsBeginnerSkill)
                    {
                        shouldLearn = true;
                    }
                    skillLevel  = Math.Max(skillLevel, c.GetSkillLevel(skillObject));
                    masterLevel = Math.Max(masterLevel, skillObject.MaxLevel);
                    if (shouldLearn)
                    {
                        c.ChangeSkillLevel(skillObject, skillLevel, masterLevel);
                        c.DropMessage(
                            $"你已获得 {SkillFactory.GetSkillName(skillid)} 当前等级 {skillLevel} 最高等级 {masterLevel}");
                    }
                }
                break;

            case MapleQuestActionType.Fame:
                status = c.GetQuest(m_quest);
                if (status.Status == MapleQuestStatusType.NotStarted && status.Forfeited > 0)
                {
                    break;
                }
                c.Fame += MapleDataTool.GetShort(Data);
                c.UpdateSingleStat(MapleStat.Fame, c.Fame);
                var fameGain = MapleDataTool.GetInt(Data);
                c.Client.Send(PacketCreator.GetShowFameGain(fameGain));
                break;

            case MapleQuestActionType.Buff:
                status = c.GetQuest(m_quest);
                if (status.Status == MapleQuestStatusType.NotStarted && status.Forfeited > 0)
                {
                    break;
                }
                var mii = MapleItemInformationProvider.Instance;
                //mii.GetItemEffect(MapleDataTool.GetInt(data)).applyTo(c);
                break;

            case MapleQuestActionType.Petskill:
                status = c.GetQuest(m_quest);
                if (status.Status == MapleQuestStatusType.NotStarted && status.Forfeited > 0)
                {
                    break;
                }
                var flag = MapleDataTool.GetInt("petskill", Data);
                //c.getPet(0).setFlag((byte)(c.getPet(0).getFlag() | InventoryConstants.Items.Flags.getFlagByInt(flag)));
                break;

            default:
                break;
            }
        }
Example #5
0
        public void Kill(MapleCharacter killer, bool dropItems = true)
        {
            lock (MobLock)
            {
                //killer.Client.CheatTracker.KillTrigger(this);

                Alive = false;
                int            exp        = WzInfo.Exp * ServerConstants.ExpRate;
                MapleCharacter dropOwner  = killer;
                int            HighestExp = 0;
                foreach (KeyValuePair <int, long> kvp in AttackerDamageList)
                {
                    MapleCharacter attacker = Map.GetCharacter(kvp.Key);
                    if (attacker != null)
                    {
                        double expPercent = ((double)Math.Min(kvp.Value, WzInfo.HP) / (double)WzInfo.HP);
                        int    expToGive  = (int)((expPercent * exp) * (attacker.Stats.ExpR / 100.0));
                        //Drops go to the person who did the most damage
                        if (expToGive > HighestExp)
                        {
                            HighestExp = expToGive;
                            dropOwner  = attacker;
                        }
                        attacker.GainExp(expToGive, true, true);
                    }
                }
                if (dropItems)
                {
                    Map.SpawnMapItemsFromMonster(this, this.Position, dropOwner);
                }
                dropOwner.UpdateQuestKills(WzInfo.MobId); //TODO: whole party on map
                Map.BroadcastPacket(MapleMonster.KillMob(ObjectId));
                Map.RemoveMob(ObjectId);

                #region Final Pact
                if (dropOwner.Job == JobConstants.DARKKNIGHT)
                {
                    Buff buff = dropOwner.GetBuff(DarkKnight.FINAL_PACT2);
                    if (buff != null)
                    {
                        buff.Stacks--;
                        if (buff.Stacks <= 0)
                        {
                            dropOwner.Client.SendPacket(Skill.ShowBuffEffect(DarkKnight.FINAL_PACT2, dropOwner.Level, null, false));
                            dropOwner.CancelBuff(DarkKnight.FINAL_PACT2);
                        }
                        else
                        {
                            uint remainingTimeMS = buff.Duration - (uint)DateTime.UtcNow.Subtract(buff.StartTime).TotalMilliseconds;
                            dropOwner.Client.SendPacket(Buff.UpdateFinalPactKillCount(buff.Stacks, remainingTimeMS));
                        }
                    }
                }
                #endregion

                Map = null;
                foreach (MonsterBuff effect in Buffs)
                {
                    effect.Dispose(true);
                }
            }
        }