예제 #1
0
 public static void AppendPartyMemberData(Client member, PacketHitList hitlist, int slot)
 {
     if (!string.IsNullOrEmpty(member.Player.PartyID)) {
         Party playerParty = PartyManager.FindPlayerParty(member);
         hitlist.AddPacketToParty(playerParty, TcpPacket.CreatePacket("partymemberdata", slot.ToString(), member.Player.Name, member.Player.GetActiveRecruit().Species.ToString(), member.Player.GetActiveRecruit().Form.ToString(), ((int)member.Player.GetActiveRecruit().Shiny).ToString(), ((int)member.Player.GetActiveRecruit().Sex).ToString(),
                                               member.Player.GetActiveRecruit().Exp.ToString(), member.Player.GetActiveRecruit().GetNextLevel().ToString(),
                                               member.Player.GetActiveRecruit().HP.ToString(), member.Player.GetActiveRecruit().MaxHP.ToString()));
     }
 }
예제 #2
0
파일: Main.cs 프로젝트: MandL27/Server
        public static void OnMapLoaded(Client client, IMap map, PacketHitList packetList)
        {
            try {
                //make sure escorts and other allies aren't taken out of the dungeon
                if (map.Moral != Enums.MapMoral.None) {
                    int left = 0;
                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                        if (client.Player.Team[i].RecruitIndex < -1) {
                            client.Player.RemoveFromTeam(i);
                            left++;
                        }
                    }
                    if (left > 1) {
                        Messenger.PlayerMsg(client, "Some members left the team.", Text.Grey);
                        client.Player.SwapActiveRecruit(0);
                    } else if (left > 0) {
                        Messenger.PlayerMsg(client, "A member left the team.", Text.Grey);
                        client.Player.SwapActiveRecruit(0);
                    }
                }
                if (exPlayer.Get(client).FirstMapLoaded) {
                    if (map.Moral == Enums.MapMoral.None && client.Player.IsInParty()) {
                        packetList.AddPacketToParty(client.Player.PartyID, PacketBuilder.CreateChatMsg("[Party]: " + client.Player.Name + " reached " + map.Name + ".", Text.Cyan));
                    }

                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                        if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                            RemoveBuffs(client.Player.Team[i]);
                        }
                    }

                    //remove statuses
                    RemoveAllBondedExtraStatus(client.Player.GetActiveRecruit(), map, packetList, false);
                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                        if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                            client.Player.Team[i].VolatileStatus.Clear();
                            RefreshCharacterTraits(client.Player.Team[i], map, packetList);
                        }
                    }

                    for (int j = 0; j < Constants.MAX_ACTIVETEAM; j++) {
                        if (client.Player.Team[j] != null && client.Player.Team[j].Loaded) {
                            if (HasAbility(client.Player.Team[j], "Illusion")) {
                                int selectedSlot = j;

                                for (int i = 1; i < Constants.MAX_ACTIVETEAM; i++) {
                                    if (client.Player.Team[(selectedSlot + i) % Constants.MAX_ACTIVETEAM] != null && client.Player.Team[(selectedSlot + i) % Constants.MAX_ACTIVETEAM].Loaded) {
                                        selectedSlot = (selectedSlot + i) % Constants.MAX_ACTIVETEAM;
                                        break;
                                    }
                                }
                                if (selectedSlot != j) {
                                    AddExtraStatus(client.Player.Team[j], client.Player.Map, "Illusion", client.Player.Team[selectedSlot].Species, null, "", packetList, false);
                                }
                            }

                            //set illusion
                            if (client.Player.GetActiveRecruit().HasActiveItem(213)) {
                                AddExtraStatus(client.Player.Team[j], client.Player.Map, "Illusion", 25, null, "", packetList, false);
                            }
                            if (client.Player.GetActiveRecruit().HasActiveItem(224)) {
                                AddExtraStatus(client.Player.Team[j], client.Player.Map, "Illusion", 300, null, "", packetList, false);
                            }
                            if (client.Player.GetActiveRecruit().HasActiveItem(244)) {
                                AddExtraStatus(client.Player.Team[j], client.Player.Map, "Illusion", 387, null, "", packetList, false);
                            }
                            if (client.Player.GetActiveRecruit().HasActiveItem(245)) {
                                AddExtraStatus(client.Player.Team[j], client.Player.Map, "Illusion", 390, null, "", packetList, false);
                            }
                            if (client.Player.GetActiveRecruit().HasActiveItem(246)) {
                                AddExtraStatus(client.Player.Team[j], client.Player.Map, "Illusion", 393, null, "", packetList, false);
                            }
                        }
                    }

                    if (client.Player.Map.MapType == Enums.MapType.RDungeonMap) {

                        if (HasAbility(client.Player.GetActiveRecruit(), "Honey Gather")
                            && client.Player.FindInvSlot(-1) > -1) {
                            if (Server.Math.Rand(0, 400) <= client.Player.GetActiveRecruit().Level) {
                                client.Player.GiveItem(11, 0, "");
                                packetList.AddPacket(client, PacketBuilder.CreateBattleMsg(client.Player.GetActiveRecruit().Name + " gathered honey from somewhere.", Text.WhiteSmoke));
                            }
                        }

                    if (client.Player.Map.MapType == Enums.MapType.RDungeonMap) {

                        for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                           	if (client.Player.GetActiveRecruit() != null && client.Player.GetActiveRecruit().Loaded && !client.Player.Dead) {
                           		if (HasAbility(client.Player.GetActiveRecruit(), "Pickup")
                                    && client.Player.FindInvSlot(-1) > -1) {
                                    RDungeonFloor floor = RDungeonManager.RDungeons[((RDungeonMap)map).RDungeonIndex].Floors[((RDungeonMap)map).RDungeonFloor];
                                    if (floor.Items.Count > 0) {
                                        int rand = Server.Math.Rand(0, floor.Items.Count);
                                        if (Server.Math.Rand(0, 200) <= floor.Items[rand].AppearanceRate) {
                                            int amount = (floor.Items[rand].MinAmount + floor.Items[rand].MaxAmount) / 2;
                                            client.Player.GiveItem(floor.Items[rand].ItemNum, amount, floor.Items[rand].Tag);
                                            packetList.AddPacket(client, PacketBuilder.CreateBattleMsg(client.Player.GetActiveRecruit().Name + " found an item from somewhere.", Text.WhiteSmoke));
                                        }
                                    }
                                }
                            }
                        }
                    }
                  }

                    //if (client.Player.GetActiveRecruit().HasActiveItem(259) && client.Player.GetActiveRecruit().HeldItem.Num == 259 && map.Moral == Enums.MapMoral.House) {
                    //    AddExtraStatus(client.Player.GetActiveRecruit(), client.Player.Map, "Illusion", client.Player.GetActiveRecruit().HeldItem.Tag.ToInt(), null, "", packetList);
                    //}

                    if (map.Moral == Enums.MapMoral.None
                        || map.Moral == Enums.MapMoral.NoPenalty
                        || (client.Player.GetActiveRecruit().X >= 0 && client.Player.GetActiveRecruit().X <= map.MaxX
                        && client.Player.GetActiveRecruit().Y >= 0 && client.Player.GetActiveRecruit().Y <= map.MaxY
                        && map.Tile[client.Player.GetActiveRecruit().X, client.Player.GetActiveRecruit().Y].Type == Enums.TileType.Arena
                        && !client.Player.Dead)) {
                        if (HasAbility(client.Player.GetActiveRecruit(), "Sand Stream")) {
                            SetMapWeather(map, Enums.Weather.Sandstorm, packetList);
                        } else if (HasAbility(client.Player.GetActiveRecruit(), "Snow Warning")) {
                            SetMapWeather(map, Enums.Weather.Hail, packetList);
                        } else if (HasAbility(client.Player.GetActiveRecruit(), "Drizzle")) {
                            SetMapWeather(map, Enums.Weather.Raining, packetList);
                        } else if (HasAbility(client.Player.GetActiveRecruit(), "Drought")) {
                            SetMapWeather(map, Enums.Weather.Sunny, packetList);
                        } else if (HasAbility(client.Player.GetActiveRecruit(), "Air Lock")) {
                            SetMapWeather(map, Enums.Weather.None, packetList);
                        } else if (HasAbility(client.Player.GetActiveRecruit(), "Cloud Nine")) {
                            SetMapWeather(map, Enums.Weather.None, packetList);
                        }
                    }

                    int totalDef = 0;
                    int totalSpDef = 0;
                    TargetCollection targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, map, client.Player.GetActiveRecruit(), client.Player.GetActiveRecruit().X, client.Player.GetActiveRecruit().Y, Enums.Direction.Up, true, false, false);
                    for (int i = 0; i < targets.Foes.Count; i++) {
                        totalDef += targets.Foes[i].Def;
                        totalSpDef += targets.Foes[i].SpclDef;
                    }
                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                       	if (client.Player.Team[i] != null && client.Player.Team[i].Loaded
                       		&& HasAbility(client.Player.Team[i], "Download")) {
                           	if (totalDef < totalSpDef) {
                               	ChangeAttackBuff(client.Player.Team[i], map, 1, packetList);
                           	} else {
                               	ChangeSpAtkBuff(client.Player.Team[i], map, 1, packetList);
                           	}
                       	}
                    }

                    //if (HasAbility(client.Player.GetActiveRecruit(), "Natural Cure") && !CheckStatusProtection(client.Player.GetActiveRecruit(), map, Enums.StatusAilment.OK.ToString(), false, packetList)) {
                    //    packetList.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(client.Player.GetActiveRecruit().Name + "'s Natural Cure cured its status problem!", Text.WhiteSmoke), client.Player.X, client.Player.Y, 10);
                    //    SetStatusAilment(client.Player.GetActiveRecruit(), map, Enums.StatusAilment.OK, 0, packetList);
                    //}
                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                        if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                            if (HasAbility(client.Player.Team[i], "Natural Cure") && !CheckStatusProtection(client.Player.Team[i], map, Enums.StatusAilment.OK.ToString(), false, packetList)) {
                                packetList.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(client.Player.Team[i].Name + "'s Natural Cure cured its status problem!", Text.WhiteSmoke), client.Player.X, client.Player.Y, 10);
                                SetStatusAilment(client.Player.Team[i], map, Enums.StatusAilment.OK, 0, packetList);
                            }

                        }
                    }

                    //if (HasAbility(client.Player.GetActiveRecruit(), "Regenerator") && client.Player.GetActiveRecruit().HP < client.Player.GetActiveRecruit().MaxHP) {
                    //    HealCharacter(client.Player.GetActiveRecruit(), map, client.Player.GetActiveRecruit().MaxHP / 3, packetList);
                    //}

                    for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                        if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {
                            if (HasAbility(client.Player.Team[i], "Regenerator") && client.Player.Team[i].HP < client.Player.Team[i].MaxHP) {
                                HealCharacter(client.Player.Team[i], map, client.Player.Team[i].MaxHP / 3, packetList);
                            }

                        }
                    }

                    if (map.MapType == Enums.MapType.Instanced) {
                        //Messenger.AdminMsg("Players:"+map.PlayersOnMap.Count + " / " + BossBattles.IsBossBattleMap(client), Text.Pink);
                        if (BossBattles.IsBossBattleMap(client)) {
                            foreach (Client n in map.GetClients()) {
                                if (client == n) {
                                    BossBattles.StartBossBattle(n, (InstancedMap)map);
                                }
                                break;
                            }
                        }
                    }

                } else {

                    //if (Ranks.IsAllowed(client, Enums.Rank.Admin)) {
                    //	Messenger.PlayerMsg(client, "!", Text.Black);
                    //}
                }
                exPlayer.Get(client).FirstMapLoaded = true;

                for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) {
                    if (client.Player.Team[i] != null && client.Player.Team[i].Loaded) {

                   		RefreshCharacterTraits(client.Player.Team[i], map, packetList);
                  	}
                }

                StoryHelper.OnMapLoaded(client, map, packetList);
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: OnMapLoaded", Text.Black);
                Messenger.AdminMsg("Map: " + map.Name + "Client: " + client.Player.Name, Text.Black);
                //Messenger.AdminMsg(ex.ToString(), Text.Black);
            }
        }