public bool AddPlayer(MapleCharacter chr) { if (Participants.ContainsKey(chr.Id)) { return(false); } int position = GetFreePosition(); if (position == -1) { return(false); //No space } MapleMessengerCharacter mcc = new MapleMessengerCharacter(position, chr); chr.ChatRoom = this; chr.Client.SendPacket(Packets.EnterRoom((byte)position)); var playerAddPacket = Packets.AddPlayer(mcc); BroadCastPacket(playerAddPacket, chr.Id); foreach (MapleMessengerCharacter participant in Participants.Values) { chr.Client.SendPacket(Packets.AddPlayer(participant)); } Participants.Add(chr.Id, mcc); return(true); }
public static int Create(int itemid, MapleCharacter chr) { try { MapleItemInformationProvider mii = MapleItemInformationProvider.Instance; using (var db = new NeoMapleStoryDatabase()) { var petmodel = new PetModel() { Name = mii.GetName(itemid), Level = 1, Closeness = 0, Fullness = 100, UniqueId = MapleCharacter.GetNextUniqueId() }; db.Pets.Add(petmodel); db.SaveChanges(); chr.Save(); return(petmodel.Id); } } catch (Exception e) { Console.WriteLine(e); return(-1); } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions(ActionState.NpcTalking)) { return; } try { int objectId = pr.ReadInt(); WzMap.Npc npc = chr.Map.GetNpc(objectId); if (npc == null) { ServerConsole.Warning("NPC is not on player {0}'s map: {1}", chr.Name, chr.Map.MapId); chr.EnableActions(); return; } NpcEngine.OpenNpc(npc.Id, objectId, c); } catch (Exception ex) { ServerConsole.Error("NpcChatHandler.Handle : " + ex); chr.EnableActions(); } }
public int GetMaxDrops(MapleCharacter chr) { var cserv = chr.Client.ChannelServer; int maxDrops; if (IsPqMonster()) { maxDrops = 1; //PQ Monsters always drop a max of 1 item (pass) - I think? MonsterCarnival monsters don't count } else if (Stats.IsExplosive) { maxDrops = 10 * cserv.BossDropRate; } else if (IsBoss && !Stats.IsExplosive) { maxDrops = 7 * cserv.BossDropRate; } else { maxDrops = 4 * cserv.DropRate; if (m_stati.ContainsKey(MonsterStatus.Taunt)) { var alterDrops = m_stati[MonsterStatus.Taunt].Stati[MonsterStatus.Taunt]; maxDrops *= 1 + alterDrops / 100; } } return(maxDrops); }
public static void Handle(MapleClient c, PacketReader pr) { if (c.Account.MigrationData == null) { c.Disconnect("Account was found to have no migration data"); return; } pr.Skip(1); pr.Skip(1); int characterId = pr.ReadInt(); string mac = pr.ReadMapleString(); string mac_hdd = pr.ReadMapleString(); string newpic = pr.ReadMapleString(); if (!c.Account.HasPic() && newpic.Length >= 6 && newpic.Length <= 16 && c.Account.HasCharacter(characterId) && Program.ChannelServers.Keys.Contains(c.Channel)) { ushort port = Program.ChannelServers[c.Channel].Port; c.Account.MigrationData.CharacterId = characterId; c.Account.MigrationData.Character = MapleCharacter.LoadFromDatabase(characterId, false); c.Account.MigrationData.Character.Hidden = c.Account.IsGM; c.Account.SetPic(newpic); Program.EnqueueMigration(characterId, c.Account.MigrationData); c.SendPacket(ChooseCharWithPicHandler.ChannelIpPacket(port, characterId)); } }
public static void HandleRegularEquipScroll(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } //[BC E0 27 09] [09 00] [05 00] [01 00] [00] int tickCount = pr.ReadInt(); short useSlot = pr.ReadShort(); short equipSlot = pr.ReadShort(); short whiteScrollMask = pr.ReadShort(); bool whiteScroll = (whiteScrollMask & 0x2) > 0; //1 byte left, don't know what it is MapleEquip equip; MapleItem scroll; if (GetAndCheckItemsFromInventory(chr.Inventory, equipSlot, useSlot, out equip, out scroll)) { if (scroll.ItemType == MapleItemType.RegularEquipScroll) { MapleEquipEnhancer.UseRegularEquipScroll(chr, equip, scroll, whiteScroll); } } chr.EnableActions(false); }
private bool CanGetItem(IMapleData item, MapleCharacter c) { if (item.GetChildByPath("gender") != null) { var gender = MapleDataTool.GetInt(item.GetChildByPath("gender")); if (gender != 2 && gender != (c.Gender ? 1 : 0)) { return(false); } } if (item.GetChildByPath("job") != null) { var job = MapleDataTool.GetInt(item.GetChildByPath("job")); if (job < 100) { if (MapleJob.GetBy5ByteEncoding(job).JobId / 100 != c.Job.JobId / 100) { return(false); } } else { if (job != c.Job.JobId) { return(false); } } } return(true); }
public static void HandleGain(MapleClient c) { MapleCharacter chr = c.Account.Character; if (chr.IsAran) { AranSystem resource = (AranSystem)chr.Resource; resource.LastComboIncreaseTime = DateTime.UtcNow; resource.Combo++; switch (resource.Combo) { case 10: case 20: case 30: case 40: case 50: case 60: case 70: case 80: case 90: case 100: int stacks = resource.Combo / 10; if (chr.GetSkillLevel(Aran1.COMBO_ABILITY) >= stacks) { HandleComboBuff(chr, resource.Combo); } break; } PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.ShowAranCombo); pw.WriteInt(resource.Combo); c.SendPacket(pw); } }
public static void HandleDecay(MapleClient c) { //ServerConsole.Info((DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond).ToString()); MapleCharacter chr = c.Account.Character; if (!chr.IsAran) { return; } AranSystem resource = (AranSystem)chr.Resource; if (resource.Combo > 1) { resource.Combo--; } Buff currentComboBuff = chr.GetBuff(Aran1.COMBO_ABILITY); if (currentComboBuff != null) { if (resource.Combo / 10 < currentComboBuff.Stacks / 10) { Buff newbuff = new Buff(Aran1.COMBO_ABILITY, currentComboBuff.Effect, SkillEffect.MAX_BUFF_TIME_MS, chr); newbuff.Stacks = resource.Combo; chr.GiveBuff(newbuff); } } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (chr.Party?.LeaderId != chr.Id) { return; } var availableCharacters = c.Account.Character.Map.GetCharacters().Where(x => !x.Hidden && x.Party == null && Math.Abs(chr.Level - x.Level) <= MAX_LEVEL_DIFFERENCE); int count = availableCharacters.Count(); if (count > 50) { return; } //[01] [46 7B 3C 00] [06 00 4B 61 7A 72 6F 6C] [90 01] [00 00] [15] PacketWriter pw = new PacketWriter(SendHeader.RecommendedPartyMembers); pw.WriteByte((byte)count); foreach (MapleCharacter recommendedChr in availableCharacters) { pw.WriteInt(recommendedChr.Id); pw.WriteMapleString(recommendedChr.Name); pw.WriteShort(recommendedChr.Job); pw.WriteShort(recommendedChr.SubJob); pw.WriteByte(recommendedChr.Level); } c.SendPacket(pw); }
public void ApplyBuffEffect(MapleCharacter target) { if (Parent.SkillId == Priest.HOLY_MAGIC_SHELL && target.HasSkillOnCooldown(Priest.HOLY_MAGIC_SHELL + 1000)) { return; } int time; if (Info.TryGetValue(CharacterSkillStat.time, out time)) { ulong ltime = 1000 * (ulong)time; if (ltime >= int.MaxValue) { ltime = MAX_BUFF_TIME_MS; } uint uTime = (uint)Math.Min(((target.Stats.BuffTimeR / 100.0) * ltime), SkillEffect.MAX_BUFF_TIME_MS); Buff buff = new Buff(Parent.SkillId, this, uTime, target, DateTime.UtcNow); target.GiveBuff(buff); } else { ServerConsole.Error("Buff from skill " + Parent.SkillId + " has no buff time"); } }
public void SetMaster(MapleCharacter character, MapleCharacter oldMaster) { character.GuildRank = 1; oldMaster.GuildRank = 2; SendToAllGuildMembers(GenerateSetMaster(character)); this.LeaderId = character.Id; }
public void Disband() { List <Character> GuildCharacters; using (LeattyContext DBContext = new LeattyContext()) { GuildCharacters = DBContext.Characters.Where(x => x.GuildId == GuildId).ToList(); } Guilds.Remove(this.GuildId); foreach (Character character in GuildCharacters) { MapleClient c = Program.GetClientByCharacterId(character.Id); c.Account.Character.Guild = null; if (c != null) { c.SendPacket(GenerateGuildDisbandPacket()); UpdateCharacterGuild(c.Account.Character, ""); c.Account.Character.GuildContribution = 0; c.Account.Character.AllianceRank = 5; c.Account.Character.GuildRank = 5; MapleCharacter.SaveToDatabase(c.Account.Character); } } }
public void BroadcastCharacterJoinedMessage(MapleCharacter fromcharacter) { PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.GuildData); pw.WriteByte(0x2D); pw.WriteUInt((uint)this.GuildId); pw.WriteInt(fromcharacter.Id); pw.WriteStaticString(fromcharacter.Name, 13); pw.WriteInt((int)fromcharacter.Job); pw.WriteInt((int)fromcharacter.Level); pw.WriteInt((int)fromcharacter.GuildRank); if (Program.IsCharacterOnline((int)fromcharacter.Id)) { pw.WriteInt(1); } else { pw.WriteInt(0); } pw.WriteInt(3);//nCommitment ?? "alliance rank" int contribution = (int)fromcharacter.GuildContribution; pw.WriteInt(contribution); SendToAllGuildMembers(pw); }
public static OutPacket GetCharInfo(MapleCharacter chr) { using (var packet = new OutPacket(SendOpcodes.WarpToMap)) { packet.WriteInt(chr.Client.ChannelId); packet.WriteByte(0x00); packet.WriteByte(0x01); packet.WriteByte(0x01); packet.WriteShort(0); packet.WriteInt((int)(Randomizer.NextDouble() * 10)); packet.WriteLong(DateUtiliy.GetFileTimestamp(DateTime.Now.GetTimeMilliseconds())); packet.WriteLong(-1); packet.WriteByte(0x00); LoginPacket.AddCharStats(packet, chr); packet.WriteByte((byte)chr.Buddies.Capacity); PacketCreator.AddInventoryInfo(packet, chr); PacketCreator.AddSkillRecord(packet, chr); PacketCreator.AddQuestRecord(packet, chr); PacketCreator.AddRingInfo(packet, chr); PacketCreator.AddTeleportRockRecord(packet, chr); packet.WriteShort(0); packet.WriteLong(0); packet.WriteByte(0x00); packet.WriteInt(0); packet.WriteLong(DateUtiliy.GetFileTimestamp(DateTime.Now.GetTimeMilliseconds())); return(packet); } }
public void Start(MapleCharacter c, int npc, bool force) { try { var arg1 = force && CheckNpcOnMap(c, npc); var arg2 = m_autoStart || CheckNpcOnMap(c, npc); var arg3 = CanStart(c, npc); if (arg1 || (arg2 && arg3)) { foreach (var action in StartActs) { action.Run(c, null); } var oldStatus = c.GetQuest(this); var newStatus = new MapleQuestStatus(this, MapleQuestStatusType.Started, npc); newStatus.CompletionTime = oldStatus.CompletionTime; newStatus.Forfeited = oldStatus.Forfeited; c.UpdateQuest(newStatus); } } catch { c.Client.Send(PacketCreator.ServerNotice(PacketCreator.ServerMessageType.Popup, "发生错误,请截图后联系管理员.")); } }
private static PacketWriter ResponsePacket(MapleCharacter chr1, MapleCharacter chr2) { PacketWriter pw = new PacketWriter(SendHeader.WeeklyMapleStar); pw.WriteByte(0x7); //pw.WriteShort(0); pw.WriteBool(chr1 != null); if (chr1 != null) { pw.WriteInt(chr1.Id); pw.WriteInt(1); //Heart amount pw.WriteInt(0); //10 0D 4A F5 pw.WriteInt(0); //50 3A D0 01 pw.WriteMapleString(chr1.Name); MapleCharacter.AddCharLook(pw, chr1, false); } pw.WriteBool(chr2 != null); if (chr2 != null) { pw.WriteInt(chr2.Id); pw.WriteInt(1); //Heart amount pw.WriteInt(0); //10 0D 4A F5 pw.WriteInt(0); //50 3A D0 01 pw.WriteMapleString(chr2.Name); MapleCharacter.AddCharLook(pw, chr2, false); } return(pw); }
public void Complete(MapleCharacter c, int npc, int selection, bool force) { try { var arg1 = m_autoPreComplete || CheckNpcOnMap(c, npc); var canbeComplete = CanComplete(c, npc); if (force || (arg1 && canbeComplete)) { foreach (var action in CompleteActs) { if (!action.Check(c)) { } } foreach (var action in CompleteActs) { action.Run(c, selection); } var oldStatus = c.GetQuest(this); var newStatus = new MapleQuestStatus(this, MapleQuestStatusType.Completed, npc); newStatus.Forfeited = oldStatus.Forfeited; c.UpdateQuest(newStatus); } else { c.DropMessage(PacketCreator.ServerMessageType.Popup, "你遇到任务错误.请稍后片刻。或请联系系统管理员"); } } catch { c.Client.Send(PacketCreator.ServerNotice(PacketCreator.ServerMessageType.Popup, "系统发生错误.请联系系统管理员解决")); } }
public static void Handle(MapleClient c, PacketReader pr) { int ReactorId = pr.ReadInt(); MapleCharacter Chr = c.Account.Character; if (Chr.ReactorActionState == null) { Chr.ReactorActionState = new ReactorActionState() { Hits = 1, ObjectId = ReactorId } } ; if (Chr.ReactorActionState.ObjectId != ReactorId) { return; } if (Chr.ReactorActionState.Hits > 3) { Chr.Map.DestroyReactor(ReactorId); return; } Chr.ReactorActionState.Hits += 1; SendActionResponse(c, Chr.ReactorActionState); }
public bool AddItem(MapleItem item, byte tradeSlot, short quantity, MapleCharacter itemOwner) { if (Partners.Count == 0) return false; //Partner hasn't accepted trade if (item.Tradeable) return false; //theyre probably hacking if they put in an untradable item too foreach (TradeItem[] arr in items) { if (arr.Any(t => t != null && t.Item == item)) //item is already added { return false; } } if (Type == TradeType.Trade) { if (tradeSlot > 9 || tradeSlot < 1) return false;//hacking if (Owner == itemOwner) { items[0][tradeSlot] = new TradeItem(item, quantity); } else { items[1][tradeSlot] = new TradeItem(item, quantity); } bool isOwner = Owner == itemOwner; Owner.Client.SendPacket(GenerateTradeItemAdd(item, !isOwner, tradeSlot)); Partners[0].Client.SendPacket(GenerateTradeItemAdd(item, isOwner, tradeSlot)); return true; } return false; }
public static void HandleSkillSwipe(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.IsPhantom || chr.Map == null) { return; } int targetId = pr.ReadInt(); MapleCharacter target = chr.Map.GetCharacter(targetId); if (target != null && target.IsExplorer) { PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.ShowStealSkills); pw.WriteByte(1); var stealableSkills = target.GetSkillList().Where(x => x.IsStealable); pw.WriteInt(stealableSkills.Any() ? 4 : 2); pw.WriteInt(targetId); pw.WriteInt(target.Job); pw.WriteInt(stealableSkills.Count()); foreach (Skill skill in stealableSkills) { pw.WriteInt(skill.SkillId); } c.SendPacket(pw); } }
public void AddMesos(MapleCharacter chr, long mesos) { if (Type == TradeType.Trade && Partners.Count == 1 && Partners[0].Trade == this) { if (chr == Owner) { if (OwnerMesos + mesos <= chr.Inventory.Mesos) { OwnerMesos += mesos; } Owner.Client.SendPacket(UpdateTradeMesos(OwnerMesos, 0)); Partners[0].Client.SendPacket(UpdateTradeMesos(OwnerMesos, 1)); MapleInventory.UpdateMesos(Owner.Client, Owner.Inventory.Mesos - OwnerMesos); } else if (chr == Partners[0]) { if (PartnerMesos + mesos <= chr.Inventory.Mesos) { PartnerMesos += mesos; } Owner.Client.SendPacket(UpdateTradeMesos(PartnerMesos, 1)); Partners[0].Client.SendPacket(UpdateTradeMesos(PartnerMesos, 0)); MapleInventory.UpdateMesos(Partners[0].Client, Partners[0].Inventory.Mesos - PartnerMesos); } } }
public static PacketWriter GiveCrossSurgeBuff(Buff buff, MapleCharacter chr, SkillEffect effect) { BuffedCharacterStats stats = chr.Stats; int damageIncPercent = effect.Info[CharacterSkillStat.x]; int absorbPercent = effect.Info[CharacterSkillStat.y]; PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.GiveBuff); WriteBuffMask(pw, buff.Effect.BuffInfo.Keys); double hpPercent = (chr.Hp / (double)stats.MaxHp) * 100; short dmgInc = (short)(hpPercent * (damageIncPercent / 100.0)); pw.WriteShort(dmgInc); pw.WriteInt(buff.SkillId); pw.WriteUInt(buff.Duration); pw.WriteInt(0); pw.WriteByte(0); int absorb = (int)((stats.MaxHp - chr.Hp) * (absorbPercent / 100.0)); absorb = Math.Min(absorb, 4000); pw.WriteInt(absorb); pw.WriteInt(0); pw.WriteInt(540); //? pw.WriteInt(1); pw.WriteByte(0); return(pw); }
public static MapleTrade CreateTrade(TradeType type, MapleCharacter owner) { MapleTrade t = new MapleTrade(type) {Owner = owner}; TradeIDs.Add(t.TradeID, t); owner.Client.SendPacket(t.GenerateTradeStart(owner, false)); return t; }
public PartyCharacterInfo GetPartyCharacterInfo(int characterId) { MapleCharacter chr = Program.GetCharacterById(characterId); if (chr != null) //Player is online { return(new PartyCharacterInfo(chr.Id, chr.Name, chr.Level, chr.Job, chr.SubJob, chr.Client.Channel, chr.MapId)); } else { PartyCharacterInfo chrInfo; lock (OfflineCharacterCache) { if (OfflineCharacterCache.TryGetValue(characterId, out chrInfo)) { return(chrInfo); } else { //Character info is not in the cache so we have to load the chr from DB and then store it chr = MapleCharacter.LoadFromDatabase(characterId, true); if (chr != null) { chrInfo = new PartyCharacterInfo(chr.Id, chr.Name, chr.Level, chr.Job, chr.SubJob); OfflineCharacterCache.Add(characterId, chrInfo); return(chrInfo); } else //There was an error loading the character from the DB { return(null); } } } } }
private static bool CanTransferItems(IEnumerable<TradeItem> list, MapleCharacter partner) { int equipCount = 0; int useCount = 0; int etcCount = 0; int setupCount = 0; foreach (TradeItem item in list) { if (item == null) continue; switch (item.Item.InventoryType) { case MapleInventoryType.Equip: equipCount++; break; case MapleInventoryType.Use: useCount++; break; case MapleInventoryType.Etc: etcCount++; break; case MapleInventoryType.Setup: setupCount++; break; } } if (partner.Inventory.GetFreeSlotCount(MapleInventoryType.Equip) < equipCount) return false; if (partner.Inventory.GetFreeSlotCount(MapleInventoryType.Use) < useCount) return false; if (partner.Inventory.GetFreeSlotCount(MapleInventoryType.Etc) < etcCount) return false; if (partner.Inventory.GetFreeSlotCount(MapleInventoryType.Setup) < setupCount) return false; return true; }
public static void HandlePlayer(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } pr.Skip(1); try { int tickCount = pr.ReadInt(); Point position = pr.ReadPoint(); int objectId = pr.ReadInt(); if (position.DistanceTo(chr.Position) >= 50) { c.CheatTracker.AddOffence(AntiCheat.OffenceType.LootFarAwayItem); } bool success = chr.Map.HandlePlayerItemPickup(c, objectId); chr.EnableActions(!success); //Client doesn't need to be notified if it was succesful } catch { chr.EnableActions(); } }
public static void HandleChangeDarkLight(MapleCharacter chr, int sourceSkillId) { LuminousSystem resource = (LuminousSystem)chr.Resource; if (sourceSkillId == LuminousBasics.SUNFIRE) { if (resource.LightLevel > 0) { chr.CancelBuffSilent(LuminousBasics.ECLIPSE); DataBuffer.CharacterSkillBuffer[LuminousBasics.SUNFIRE].GetEffect(1).ApplyBuffEffect(chr); resource.LightLevel--; resource.State = LuminousState.Light; } } else if (sourceSkillId == LuminousBasics.ECLIPSE) { if (resource.DarkLevel > 0) { chr.CancelBuffSilent(LuminousBasics.SUNFIRE); DataBuffer.CharacterSkillBuffer[LuminousBasics.ECLIPSE].GetEffect(1).ApplyBuffEffect(chr); resource.DarkLevel--; resource.State = LuminousState.Dark; } } chr.AddCooldown(LuminousBasics.SUNFIRE, 180000); chr.AddCooldown(LuminousBasics.ECLIPSE, 180000); chr.AddCooldown(LuminousBasics.CHANGE_LIGHT_DARK_MODE, 180000); }
public MapleSquad(int ch, MapleCharacter leader) { Leader = leader; Status = 1; Members.Add(leader); m_ch = ch; }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (chr.ActionState != ActionState.Enabled) { return; } //chr.ActionState = ActionState.Disabled; int tickCount = pr.ReadInt(); chr.SendBlueMessage("The cash shop is disabled at this time, please go to the Free Market Entrance to buy Cash Items."); chr.EnableActions(); /* * PacketWriter pw = new PacketWriter(); * pw.WriteHeader(SendHeaders.ChangeChannel); * pw.WriteBool(true); * pw.WriteBytes(ServerConstants.NexonIp[3]); * pw.WriteShort(ServerConstants.CashShopPort); * pw.WriteByte(0); * * c.Account.MigrationData.ToChannel = 0xFF; * c.Account.MigrationData.ToCashShop = true; * c.Account.MigrationData.ReturnChannel = c.Channel; * c.Account.MigrationData.CheatTracker = c.CheatTracker; * c.Account.MigrationData.Character = c.Account.Character; * Program.EnqueueMigration(c.Account.MigrationData.CharacterId, c.Account.MigrationData); * c.Account.Character.ActionState = ActionState.Disabled; * * c.SendPacket(pw);*/ }