public static void CheckPlayerLevelUp(PacketHitList hitList, Client client) { PacketHitList.MethodStart(ref hitList); if (client.Player.GetActiveRecruit().Exp > client.Player.GetActiveRecruit().GetNextLevel()) { if (client.Player.GetActiveRecruit().Level < Exp.ExpManager.Exp.MaxLevels) { Scripting.ScriptManager.InvokeSub("PlayerLevelUp", hitList, client); hitList.AddPacketToMap(client.Player.Map, TcpPacket.CreatePacket("levelup", client.ConnectionID.ToString())); //Messenger.SendDataToMap(client.Player.MapID, TcpPacket.CreatePacket("levelup", client.ConnectionID.ToString())); } if (client.Player.GetActiveRecruit().Level >= Exp.ExpManager.Exp.MaxLevels) { client.Player.GetActiveRecruit().Level = Exp.ExpManager.Exp.MaxLevels; client.Player.GetActiveRecruit().Exp = ExpManager.Exp[Exp.ExpManager.Exp.MaxLevels - 1]; } } else { PacketBuilder.AppendEXP(client, hitList); //Messenger.SendEXP(client); } PacketHitList.MethodEnded(ref hitList); //Messenger.SendActiveTeam(index); //Messenger.SendHP(index); //Messenger.SendStats(index); //Messenger.BattleMsg(index, "You.", Text.BrightBlue); }
public void AddHitList(PacketHitList hitlist) { for (int i = 0; i < hitlist.HitList.Count; i++) { AddPacketList(hitlist.HitList.KeyByIndex(i), hitlist.HitList.ValueByIndex(i)); } }
public static void AppendAdminMsg(PacketHitList hitlist, string Msg, Color Color) { foreach (Client i in ClientManager.GetClients()) { if (i.IsPlaying() && Ranks.IsAllowed(i, Enums.Rank.Moniter)) { hitlist.AddPacket(i, TcpPacket.CreatePacket("msg", Msg, Color.ToArgb().ToString())); } } }
public static void DisplayInvisibleKeyTile(Client client, IMap map, int x, int y, PacketHitList packetList) { Tile tile = new Tile(new DataManager.Maps.Tile()); MapCloner.CloneTile(map, x, y, tile); tile.Mask = 0; tile.MaskSet = 4; tile.Type = Enums.TileType.Walkable; Messenger.SendTemporaryTileTo(packetList, client, x, y, tile); }
public static void MethodStart(ref PacketHitList hitlist) { if (hitlist == null) { hitlist = new PacketHitList(); } else { hitlist.CallLevel++; } }
public static bool MoveNpcDown(IMap map, Client target, PacketHitList packetList, int mapNpcSlot) { // Down if (map.ActiveNpc[mapNpcSlot].Y < target.Player.Y) { if (MovementProcessor.CanNpcMove(map, mapNpcSlot, Enums.Direction.Down)) { MovementProcessor.NpcMove(packetList, map, mapNpcSlot, map.ActiveNpc[mapNpcSlot].Direction, Enums.Speed.Walking); return true; } } return false; }
public static void MethodEnded(ref PacketHitList hitlist) { if (hitlist.CallLevel == 0) { if (hitlist.CachingEnabled) { hitlist.BuildHitListFromCache(); } Messenger.SendData(hitlist); } else { hitlist.CallLevel--; } }
public static void CheckForSublevelGoal(Client client, PacketHitList packetList) { for (int i = 0; i < client.Player.TriggerEvents.Count; i++) { if (client.Player.TriggerEvents[i].Trigger == TriggerEventTrigger.SteppedOnTile && client.Player.TriggerEvents[i].ID.StartsWith("ESTSublevelGoal")) { SteppedOnTileTriggerEvent tEvent = client.Player.TriggerEvents[i] as SteppedOnTileTriggerEvent; if (client.Player.MapID == tEvent.MapID) { DisplayVisibleSublevelGoalTile(client, client.Player.Map, tEvent.X, tEvent.Y, packetList); } } } }
public static void AppendActiveTeam(Client client, PacketHitList hitlist) { TcpPacket packet = new TcpPacket("activeteam"); Player player = client.Player; for (int i = 0; i < Constants.MAX_ACTIVETEAM; i++) { if (client.Player.Team[i].Loaded == true) { packet.AppendParameters(player.Team[i].Name, player.Team[i].Species.ToString(), player.Team[i].Form.ToString(), ((int)player.Team[i].Shiny).ToString(), ((int)player.Team[i].Sex).ToString(), player.Team[i].HP.ToString(), player.Team[i].MaxHP.ToString(), Server.Math.CalculatePercent(player.Team[i].Exp, Exp.ExpManager.Exp[player.Team[i].Level - 1]).ToString(), player.Team[i].Level.ToString(), ((int)player.Team[i].StatusAilment).ToString(), player.Team[i].HeldItemSlot.ToString()); } else { packet.AppendParameter("notloaded"); } } packet.FinalizePacket(); hitlist.AddPacket(client, packet); }
public static void DisplayInvisibleSublevelGoalTile(Client client, IMap map, int x, int y, PacketHitList packetList) { PacketHitList.MethodStart(ref packetList); Tile tile = new Tile(new DataManager.Maps.Tile()); MapCloner.CloneTile(map, x, y, tile); tile.Mask = 0; tile.MaskSet = 7; tile.Type = Enums.TileType.Walkable; Messenger.SendTemporaryTileTo(packetList, client, x, y, tile); MapCloner.CloneTile(map, x, y - 1, tile); tile.Fringe = 0; tile.FringeSet = 7; tile.Type = Enums.TileType.Walkable; Messenger.SendTemporaryTileTo(packetList, client, x, y - 1, tile); PacketHitList.MethodEnded(ref packetList); }
public static bool MoveNpcInDirection(Enums.Direction direction, IMap map, Client target, PacketHitList packetList, int mapNpcSlot) { switch (direction) { case Enums.Direction.Up: { return MoveNpcUp(map, target, packetList, mapNpcSlot); } case Enums.Direction.Down: { return MoveNpcDown(map, target, packetList, mapNpcSlot); } case Enums.Direction.Left: { return MoveNpcLeft(map, target, packetList, mapNpcSlot); } case Enums.Direction.Right: { return MoveNpcRight(map, target, packetList, mapNpcSlot); } } return false; }
public void HandoutExp(Client giver, ulong exp, PacketHitList hitlist) { PacketHitList.MethodStart(ref hitlist); bool totalForAll = true; ulong newExp; if (totalForAll) { newExp = exp; } else { newExp = exp * (ulong)(Members.Count + 3) / 4 / (ulong)Members.Count; } if (!(giver.Player.GetActiveRecruit().Level == Exp.ExpManager.Exp.MaxLevels) && giver.Player.Hunted && !giver.Player.Dead) { Scripting.ScriptManager.InvokeSub("PlayerEXP", hitlist, giver, newExp); Combat.BattleProcessor.CheckPlayerLevelUp(hitlist, giver); } foreach (Client i in GetOnlineMemberClients()) { if (i.IsPlaying() && i != giver) { //PartyMember member = members.FindMember(i.Player.CharID); //if (member != null) { if (giver.Player.Map == i.Player.Map) { if (!(i.Player.GetActiveRecruit().Level == Exp.ExpManager.Exp.MaxLevels) && i.Player.Hunted && !i.Player.Dead) { int lowestBound = 8000; int chosenMiddle = 8000; if (i.Player.GetActiveRecruit().Level < giver.Player.GetActiveRecruit().Level) { int diff = giver.Player.GetActiveRecruit().Level - i.Player.GetActiveRecruit().Level; lowestBound -= diff * diff * 100 / 5; int distance = Math.Max(Math.Abs(giver.Player.X - i.Player.X), Math.Abs(giver.Player.Y - i.Player.Y)); if (distance > 40) distance = 40; if (distance < 8) distance = 8; chosenMiddle = lowestBound * (distance - 8) / 40 + chosenMiddle * (40 - (distance - 8)) / 40; if (chosenMiddle < 0) chosenMiddle = 0; } ulong moddedExp = newExp * (ulong)chosenMiddle / 8000; if (moddedExp < 1) moddedExp = 1; Scripting.ScriptManager.InvokeSub("PlayerEXP", hitlist, i, moddedExp); Combat.BattleProcessor.CheckPlayerLevelUp(hitlist, i); } else { // The party member is at the max level, so do nothing } } //} } } PacketHitList.MethodEnded(ref hitlist); }
public void BuildHitList(PacketHitList hitList) { this.hitList = hitList; ListPair <IMap, List <Client> > clientCollection = new ListPair <IMap, List <Client> >(); ListPair <IMap, Object[]> borderingMapCollection = new ListPair <IMap, object[]>(); for (int i = 0; i < hitListCache.Count; i++) { object[] param = hitListCache[i]; switch ((PacketHitListTargets)param[0]) { case PacketHitListTargets.Client: { AddPacket((Client)param[1], (TcpPacket)param[2]); } break; case PacketHitListTargets.All: { foreach (Client client in ClientManager.GetClients()) { if (client.IsPlaying()) { AddPacket(client, (TcpPacket)param[1]); } } } break; case PacketHitListTargets.RangedMapBut: { Maps.IMap map = param[2] as IMap; int range = (int)param[6]; Client client = param[1] as Client; foreach (Client mapClient in GetMapClients(clientCollection, map)) { if (mapClient != null && (client == null || mapClient.TcpID != client.TcpID)) { if (range == -1 || PacketHitList.IsInRange(range, (int)param[4], (int)param[5], mapClient.Player.X, mapClient.Player.Y)) { AddPacket(mapClient, (TcpPacket)param[3]); } } } } break; // TODO: Should be fixed... (PacketHitListCache) //case PacketHitListTargets.PlayersInSightBut: { // Client sender = param[1] as Client; // IMap centralMap = param[2] as IMap; // int range = (int)param[6]; // foreach (Client mapClient in centralMap.GetSurroundingClients(centralMap)) { // if (sender == null || sender != mapClient) { // if (range == -1 || SeamlessWorldHelper.IsInSight(centralMap, (int)param[4], (int)param[5], mapClient.Player.Map, mapClient.Player.X, mapClient.Player.Y)) { // AddPacket(mapClient, (TcpPacket)param[3]); // } // } // } // } // break; case PacketHitListTargets.Party: { Party party = param[1] as Party; foreach (Client partyClient in party.GetOnlineMemberClients()) { if (partyClient.IsPlaying()) { AddPacket(partyClient, (TcpPacket)param[2]); } } } break; // TODO: Should be fixed... (PacketHitListCache) //case PacketHitListTargets.Others: { // Combat.ICharacter source = param[1] as Combat.ICharacter; // IMap map = param[2] as IMap; // TcpPacket packet = param[3] as TcpPacket; // Enums.OutdateType updateType = (Enums.OutdateType)param[4]; // foreach (IMap borderingMap in GetBorderingMaps(borderingMapCollection, map)) { // foreach (Client borderingMapClient in GetMapClients(clientCollection, borderingMap)) { // if (borderingMapClient.Player.GetActiveRecruit() != source) { // if (AI.MovementProcessor.WillCharacterSeeCharacter(borderingMap, borderingMapClient.Player.GetActiveRecruit(), map, source)) { // if (!borderingMapClient.Player.IsSeenCharacterSeen(source)) { // borderingMapClient.Player.AddActivation(hitList, source); // } // this.AddPacket(borderingMapClient, packet); // } else { // if (updateType == Enums.OutdateType.Location && borderingMapClient.Player.IsSeenCharacterSeen(source)) { // this.AddPacket(borderingMapClient, packet); // //unsee character // borderingMapClient.Player.RemoveUnseenCharacters(); // } else { // borderingMapClient.Player.OutdateCharacter(source, updateType); // //outdate character // //} // //} else { // //outdate character // } // } // } // } // } // } // break; } } hitListCache.Clear(); }
private static void HealCharacterBelly(ICharacter character, int belly, PacketHitList hitlist) { if (character.CharacterType == Enums.CharacterType.Recruit) { Recruit recruit = character as Recruit; recruit.Belly += belly; if (recruit.Belly >= recruit.MaxBelly) { recruit.Belly = recruit.MaxBelly; if (belly > 10) { hitlist.AddPacketToMap(recruit.Owner.Player.Map, PacketBuilder.CreateBattleMsg(character.Name + "'s belly was filled completely.", Text.BrightGreen), character.X, character.Y, 10); } } else { if (belly > 10) { hitlist.AddPacketToMap(recruit.Owner.Player.Map, PacketBuilder.CreateBattleMsg(character.Name + "'s belly was filled somewhat.", Text.BrightGreen), character.X, character.Y, 10); } } PacketBuilder.AppendBelly(((Recruit)character).Owner, hitlist); } }
private static void HealCharacterPP(ICharacter character, IMap map, int pp, PacketHitList hitlist) { for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) { if (character.Moves[i] != null) { character.Moves[i].CurrentPP += pp; if (character.Moves[i].CurrentPP > character.Moves[i].MaxPP) { character.Moves[i].CurrentPP = character.Moves[i].MaxPP; } } } if (character.CharacterType == Enums.CharacterType.Recruit) { PacketBuilder.AppendPlayerMoves(((Recruit)character).Owner, hitlist); } hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + "'s moves regained " + pp + " PP.", Text.BrightGreen), character.X, character.Y, 10); }
private static void DamageCharacter(ICharacter character, IMap map, int dmg, Enums.KillType killType, PacketHitList hitlist, bool checkDeath) { int point = 0; try { character.HP -= dmg; if (dmg <= 0) { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " took no damage!", Text.BrightRed), character.X, character.Y, 10); //BothWaysBattleMsg(setup, setup.Defender.Name + " took no damage!", Text.BrightRed); } else { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " took " + dmg + " damage!", Text.BrightRed), character.X, character.Y, 10); //BothWaysBattleMsg(setup, setup.Defender.Name + " took " + damage + " damage!", Text.BrightRed); } point = 1; if (checkDeath && character.HP <= 0) { if (character.CharacterType == Enums.CharacterType.Recruit) { point = 2; hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("Oh, no! " + character.Name + " fainted!", Text.BrightRed)); point = 3; OnDeath(((Recruit)character).Owner, Enums.KillType.Other); point = 4; } else { if (character.HeldItem != null) { character.MapDropItem(character.HeldItem.Amount, null); } OnNpcDeath(hitlist, null, (MapNpc)character); //((MapNpc)character).Num = 0; //((MapNpc)character).HP = 0; map.ActiveNpc[((MapNpc)character).MapSlot] = new MapNpc(character.MapID, ((MapNpc)character).MapSlot); hitlist.AddPacketToMap(map, TcpPacket.CreatePacket("npcdead", ((MapNpc)character).MapSlot)); } } } catch(Exception ex) { Messenger.AdminMsg("Error: DamageCharacter", Text.Black); Messenger.AdminMsg(ex.ToString(), Text.Black); Messenger.AdminMsg(character.Name + " took " + dmg + " dmg at " + map.Name + " from " + killType + " with checkDeath=" + checkDeath + " and point=" + point, Text.Black); throw new Exception(); } }
private static void HealCharacter(ICharacter character, IMap map, int hp, PacketHitList hitlist) { try { if (character.VolatileStatus.GetStatus("HealBlock") != null) { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " couldn't recover HP due to the Heal Block!", Text.BrightRed), character.X, character.Y, 10); return; } if (character.HP + hp > character.MaxHP) { hp = character.MaxHP - character.HP; } character.HP += hp; if (hp <= 0) { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + "'s HP didn't change.", Text.BrightGreen), character.X, character.Y, 10); //BothWaysBattleMsg(setup, setup.Defender.Name + " took no damage!", Text.BrightRed); } else if (character.HP == character.MaxHP) { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " was fully healed!", Text.BrightGreen), character.X, character.Y, 10); } else { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " recovered " + hp + " HP!", Text.BrightGreen), character.X, character.Y, 10); //BothWaysBattleMsg(setup, setup.Defender.Name + " took " + damage + " damage!", Text.BrightRed); } } catch (Exception ex) { Messenger.AdminMsg("Error: HealCharacter: " + character.Name, Text.Black); Messenger.AdminMsg(ex.ToString(), Text.Black); throw new Exception(); } }
public static void OnNpcDeath(PacketHitList hitlist, ICharacter attacker, MapNpc npc) { try { // Called when a npc faints PacketHitList.MethodStart(ref hitlist); hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(npc.MapID), PacketBuilder.CreateBattleMsg(npc.Name + " fainted!", Text.WhiteSmoke), npc.X, npc.Y, 10); //aftermath if (HasAbility(npc, "Aftermath")) { bool explode = true; if (!HasAbility(npc, "Mold Breaker")) { TargetCollection checkedTargets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, MapManager.RetrieveActiveMap(npc.MapID), null, 0, 0, Enums.Direction.Up, true, true, false); for (int i = 0; i < checkedTargets.Count; i++) { if (HasAbility(checkedTargets[i], "Damp")) { explode = false; } } } if (explode) { hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(npc.MapID), PacketBuilder.CreateBattleMsg(npc.Name + " exploded!", Text.BrightRed), npc.X, npc.Y, 10); hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(npc.MapID), PacketBuilder.CreateSoundPacket("magic216.wav"), npc.X, npc.Y, 10); for (int i = npc.X - 1; i <= npc.X + 1; i++) { for (int j = npc.Y - 1; j <= npc.Y + 1; j++) { if (i < 0 || j < 0 || i > MapManager.RetrieveActiveMap(npc.MapID).MaxX || j > MapManager.RetrieveActiveMap(npc.MapID).MaxY) { } else { hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(npc.MapID), PacketBuilder.CreateSpellAnim(497, i, j)); } } } TargetCollection targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Room, 1, MapManager.RetrieveActiveMap(npc.MapID), npc, npc.X, npc.Y, Enums.Direction.Up, true, true, false); for (int i = 0; i < targets.Count; i++) { if (MapManager.RetrieveActiveMap(npc.MapID).Moral == Enums.MapMoral.None) { if (targets[i].HP > 0) { if (HasActiveBagItem(targets[i], 6, 0, 0)) { DamageCharacter(targets[i], MapManager.RetrieveActiveMap(targets[i].MapID), 1, Enums.KillType.Tile, hitlist, true); } else { DamageCharacter(targets[i], MapManager.RetrieveActiveMap(targets[i].MapID), targets[i].MaxHP / 4, Enums.KillType.Tile, hitlist, true); } } } } } else { hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(npc.MapID), PacketBuilder.CreateSoundPacket("magic320.wav"), npc.X, npc.Y, 10); hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(npc.MapID), PacketBuilder.CreateSpellAnim(505, npc.X, npc.Y)); hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(npc.MapID), PacketBuilder.CreateBattleMsg("The damp conditions prevented an explosion!", Text.Blue), npc.X, npc.Y, 10); } } //death flag TargetCollection witnesses = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, MapManager.RetrieveActiveMap(npc.MapID), npc, 0, 0, Enums.Direction.Up, false, true, false); for (int i = 0; i < witnesses.Count; i++) { AddExtraStatus(witnesses[i], MapManager.RetrieveActiveMap(npc.MapID), "SawAllyFaint", 0, null, "", hitlist); } RemoveAllBondedExtraStatus(npc, MapManager.RetrieveActiveMap(npc.MapID), hitlist, false); IMap map = MapManager.RetrieveActiveMap(npc.MapID); Client client = null; foreach (Client n in map.GetClients()) { client = n; break; } if (client != null) { bool doBossCheck = false; switch (npc.Num) { /* case 276: case 277: case 278: { //Dynamo Trio map.RemoveNpc(npc.MapSlot); if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && map.IsNpcSlotEmpty(3)) { map.Tile[9, 1].Mask = 96; map.Tile[9, 1].MaskSet = 4; map.Tile[9, 1].Type = Enums.TileType.Scripted; map.Tile[9, 1].Data1 = 46; map.Tile[9, 1].Data2 = 0; map.Tile[9, 1].Data3 = 0; map.Tile[9, 1].String1 = "19"; map.Tile[9, 1].String2 = "1"; map.Tile[9, 1].String3 = "10:7"; hitlist.AddPacketToMap(map, PacketBuilder.CreateTilePacket(9, 1, map)); } } break; */ case 304: {//registeel map.RemoveNpc(npc.MapSlot); if (map.IsNpcSlotEmpty(5)) { BossBattles.EndRegisteelBattle(client); } } break;/* case 305: {//bronzong map.RemoveNpc(npc.MapSlot); if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && (npc.MapSlot == 1 || npc.MapSlot == 2)) { if (client.Player.GetStoryState(43) == true) { client.Player.SetStoryState(43, false); } StoryManager.PlayStory(client, 43); } else if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && map.IsNpcSlotEmpty(3) && map.IsNpcSlotEmpty(4)) { if (client.Player.GetStoryState(56) == true) { client.Player.SetStoryState(56, false); } StoryManager.PlayStory(client, 56); } } break;*/ case 220: {//Murkrow minions 2.0 if (map.IsNpcSlotEmpty(14)) { map.RemoveNpc(npc.MapSlot); } for (int i = 1; i < 14; i++) { if (map.IsNpcSlotEmpty(i) == false) { return; } } StoryManager.PlayStory(client, 160); } break; case 221: {//Honchkrow map.RemoveNpc(npc.MapSlot); for (int i = 1; i < 14; i++) { if (map.IsNpcSlotEmpty(i) == false) { map.RemoveNpc(i); } } StoryManager.PlayStory(client, 161); } break; case 224: {//Murkrow minions map.RemoveNpc(npc.MapSlot); for (int i = 1; i < 14; i++) { if (map.IsNpcSlotEmpty(i) == false) { return; } } StoryManager.PlayStory(client, 160); } break; case 259: case 306: { if (map.Name == "Iceberg Cave") { map.RemoveNpc(npc.MapSlot); if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && map.IsNpcSlotEmpty(3)) { BossBattles.EndRegiceBattle(client); } } } break; //case 177: { // map.RemoveNpc(npc.MapSlot); // if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && map.IsNpcSlotEmpty(3) && map.IsNpcSlotEmpty(4) && // map.IsNpcSlotEmpty(5) && map.IsNpcSlotEmpty(6) && map.IsNpcSlotEmpty(7)) { // BossBattles.RemoveLuxioTribe(client); // } //} //break; case 167: { //map.RemoveNpc(npc.MapSlot); //if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && map.IsNpcSlotEmpty(3) && map.IsNpcSlotEmpty(4) && //map.IsNpcSlotEmpty(5) && map.IsNpcSlotEmpty(6) && map.IsNpcSlotEmpty(7)) { // BossBattles.RemoveLuxioTribe(client); //} } break; /* case 465: { map.RemoveNpc(1); map.Tile[9, 4].Type = Enums.TileType.Scripted; map.Tile[9, 4].Data1 = 46; map.Tile[9, 4].Data2 = 0; map.Tile[9, 4].Data3 = 0; map.Tile[9, 4].String1 = "15"; map.Tile[9, 4].String2 = "93"; map.Tile[9, 4].String3 = "8:10"; map.Tile[9, 4].Mask = 96; map.Tile[9, 4].MaskSet = 4; hitlist.AddPacketToMap(map, PacketBuilder.CreateTilePacket(9, 4, map)); } break; */ //case 212: {//fake Gengar (adjust for the actual NPC number) // if (map.MapType == Enums.MapType.RDungeonMap) { // int num = (map as RDungeonMap).RDungeonIndex; // if ((num + 1) == 20) { // StoryManager.PlayStory(client, 287); // StoryManager.PlayStory(client, 288); // StoryManager.PlayStory(client, 289); // StoryManager.PlayStory(client, 286); // StoryManager.PlayStory(client, 290); // StoryManager.PlayStory(client, 291); // StoryManager.PlayStory(client, 292); // } // } // } // break; //case 804: {//real gengar defeated // map.RemoveNpc(npc.MapSlot); // for (int i = 2; i <= 3; i++) { // if (map.IsNpcSlotEmpty(i) == false) { // map.RemoveNpc(i); // } // } // map.SetAttribute(8, 4, Enums.TileType.Scripted, 36, 0, 0, "19", "1", ""); // map.SetAttribute(9, 10, Enums.TileType.Scripted, 13, 0, 0, "", "", ""); // map.SetAttribute(10, 10, Enums.TileType.Scripted, 13, 0, 0, "", "", ""); // map.SetAttribute(8, 5, Enums.TileType.Walkable, 0, 0, 0, "", "", ""); // map.SetAttribute(13, 6, Enums.TileType.Notice, 0, 0, 0, "You hesitate...", "It's probably a good idea not to sleep here again...", ""); // StoryManager.PlayStory(client, 285); // } // break; //case 806: //case 807: {//rotom forms // map.RemoveNpc(npc.MapSlot); // map.SetAttribute(9, 10, Enums.TileType.Scripted, 13, 0, 0, "", "", ""); // map.SetAttribute(10, 10, Enums.TileType.Scripted, 13, 0, 0, "", "", ""); // Messenger.PlayerMsg(client, "The exit was opened!", Text.Yellow); // } // break; case 805: {//spiritomb defeated map.RemoveNpc(npc.MapSlot); map.SetAttribute(9, 2, Enums.TileType.Scripted, 36, 0, 0, "21", "30", ""); map.SetTile(9, 2, 96, 4, 1); StoryManager.PlayStory(client, 303); } break; /* case 440: {//Articuno* map.RemoveNpc(1); map.SetTile(12, 5, 96, 4, 1); map.SetAttribute(12, 5, Enums.TileType.Scripted, 46, 0, 0, "20", "342", "13:13"); StoryManager.PlayStory(client, 171); } break; */ case 404: {//Heatran map.RemoveNpc(1); map.SetTile(10, 6, 96, 4, 3); map.SetAttribute(10, 6, Enums.TileType.Scripted, 46, 0, 0, "18", "1313", "12:12"); //NetScript.PlayStory(index, 171); } break; case 579: case 558: case 559: case 560: case 571: case 572: case 854: case 855: case 856: case 857: case 858: case 859: case 860: case 861: case 862: case 863: { //normal PBA enemies + boss if (map.Name == "Pitch-Black Pit") { int remainingEnemies = 0; for (int i = 0; i < Constants.MAX_MAP_NPCS; i++) { if (!map.IsNpcSlotEmpty(i)) remainingEnemies++; } if (remainingEnemies <= 1) { BossBattles.EndBossBattle(client, "Pitch-Black Pit"); } } else PitchBlackAbyss.UnlockRoom(client, map); } break; case 139: { BossBattles.EndBossBattle(client, "ThunderstormForest"); } break; case 177: { BossBattles.EndBossBattle(client, "ThunderstormForestPart2"); } break; /* case 588: case 587: { // EST Boss A Wave 1 if (map.Name == "Electrostasis Tower Chamber") { map.RemoveNpc(npc.MapSlot); if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && map.IsNpcSlotEmpty(3) && map.IsNpcSlotEmpty(4) && (npc.MapSlot == 1 || npc.MapSlot == 2 || npc.MapSlot == 3 || npc.MapSlot == 4)) { map.SetTile(4, 12, 0, 0, 1); map.SetAttribute(4, 12, Enums.TileType.Walkable, 0, 0, 0, "", "", ""); map.SetAttribute(9, 12, Enums.TileType.Story, 201, 0, 0, "", "", ""); hitlist.AddPacketToMap(map, PacketBuilder.CreateTilePacket(4, 12, map)); hitlist.AddPacketToMap(map, PacketBuilder.CreateTilePacket(9, 12, map)); } else if (map.IsNpcSlotEmpty(1) && map.IsNpcSlotEmpty(2) && map.IsNpcSlotEmpty(3) && map.IsNpcSlotEmpty(4) && map.IsNpcSlotEmpty(5) && map.IsNpcSlotEmpty(6) && map.IsNpcSlotEmpty(7) && (npc.MapSlot == 5 || npc.MapSlot == 6 || npc.MapSlot == 7)) { BossBattles.EndBossBattle(client, "ElectrostasisTowerA1"); } } } break; */ case 963: {// Joey, Exbel Woods Clearing int recruitIndex = -1; using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) { recruitIndex = client.Player.AddToRecruitmentBank(dbConnection, client.Player.CreateRecruitFromNpc(npc)); } int openSlot = client.Player.FindOpenTeamSlot(); if (recruitIndex != -1 && openSlot != -1) { client.Player.AddToTeam(recruitIndex, openSlot); client.Player.Team[openSlot].HP = client.Player.Team[openSlot].MaxHP; Messenger.BattleMsg(client, "You have recruited a new team member!", Text.BrightGreen); Messenger.SendActiveTeam(client); } else { Messenger.BattleMsg(client, "You cant recruit! You have too many team members in the assembly!", Text.BrightRed); } doBossCheck = true; } break; default: { doBossCheck = true; } break; } if (doBossCheck) { if (BossBattles.IsBossBattleMap(client)) { int remainingEnemies = 0; for (int i = 0; i < Constants.MAX_MAP_NPCS; i++) { if (!map.IsNpcSlotEmpty(i)) remainingEnemies++; } //Messenger.AdminMsg(remainingEnemies.ToString(), Text.Black); if (remainingEnemies <= 1) BossBattles.EndBossBattle(client, map.Name); } } } PacketHitList.MethodEnded(ref hitlist); } catch (Exception ex) { Messenger.AdminMsg("Error: OnNpcDeath", Text.Black); Messenger.AdminMsg("NPCNum: " + npc.Num, Text.Black); } }
public void AppendFriendsList(PacketHitList hitlist) { TcpPacket packet = new TcpPacket("friendslist"); packet.AppendParameter(Friends.Count); for (int i = 0; i < Friends.Count; i++) { Client clientIsOn = ClientManager.FindClient(Friends[i]); int ison; if (clientIsOn != null) { ison = 1; } else { ison = 0; } packet.AppendParameters(Friends[i], ison.ToString()); } packet.FinalizePacket(); hitlist.AddPacket(client, packet); }
public static void AppendOwnXY(Client client, PacketHitList hitlist) { hitlist.AddPacket(client, CreatePlayerXY(client)); client.Player.RefreshSeenCharacters(hitlist); }
public void RefreshSeenCharacters(PacketHitList hitlist) { ProcessCharacterVisibilities(hitlist); }
public void ProcessCharacterVisibilities(PacketHitList hitlist) { IMap map = GetCurrentMap(); Recruit activeRecruit = GetActiveRecruit(); for (int i = 0; i < 9; i++) { IMap borderingMap = MapManager.RetrieveBorderingMap(map, (Enums.MapID)i, true); if (borderingMap != null) { foreach (MapNpc activeNpc in borderingMap.ActiveNpc) { if (AI.MovementProcessor.WillCharacterSeeCharacter(map, activeRecruit, borderingMap, (Enums.MapID)i, activeNpc)) { //if (!IsSeenCharacterSeen(activeNpc)) { AddActivationIfCharacterNotSeen(hitlist, activeNpc); //} } else { // Character isn't in sight, remove from the list! lock (seenNpcs) { Dictionary<int, SeenCharacter> seenNpcsDictionary = null; if (seenNpcs.TryGetValue(borderingMap.MapID, out seenNpcsDictionary)) { SeenCharacter seenCharacter = null; if (seenNpcsDictionary.TryGetValue(activeNpc.MapSlot, out seenCharacter)) { seenCharacter.InSight = false; } } } } } foreach (Client n in borderingMap.GetClients()) { if (AI.MovementProcessor.WillCharacterSeeCharacter(map, activeRecruit, borderingMap, (Enums.MapID)i, n.Player.GetActiveRecruit())) { //if (!IsSeenCharacterSeen(n.Player.GetActiveRecruit())) { AddActivationIfCharacterNotSeen(hitlist, n.Player.GetActiveRecruit()); //} } else { // Character isn't in sight, remove from the list! lock (seenPlayers) { SeenCharacter seenCharacter = null; if (seenPlayers.TryGetValue(n.Player.CharID, out seenCharacter)) { seenCharacter.InSight = false; } } } } } } }
public static void OnStep(Client client, PacketHitList hitlist) { // NOTE: Remove the mapper+ check for release if (exPlayer.Get(client).AnniversaryEnabled && client.Player.CurrentChapter == null && Ranks.IsAllowed(client, Enums.Rank.Mapper)) { int currentAnniversarySection = client.Player.StoryHelper.ReadSetting("[Anniversary12]-CurrentSection").ToInt(); //Messenger.PlayerMsg(client, "Section: " + currentAnniversarySection, Text.BrightRed); // NOTE: Do /not/ remove the mapper+ check here, this resets the story when you reach the end if (currentAnniversarySection == annivRiddles.Length && Ranks.IsAllowed(client, Enums.Rank.Mapper)) { currentAnniversarySection = 0; client.Player.StoryHelper.SaveSetting("[Anniversary12]-CurrentSection", currentAnniversarySection.ToString()); Messenger.PlayerMsg(client, "Section reset!", Text.BrightRed); } if (currentAnniversarySection >= 0 && currentAnniversarySection < annivRiddles.Length) { AnniversaryRiddle currentRiddle = annivRiddles[currentAnniversarySection]; if (client.Player.MapID == currentRiddle.MapId && client.Player.X == currentRiddle.X && client.Player.Y == currentRiddle.Y) { client.Player.SetStoryState(currentRiddle.Story - 1, false); StoryManager.PlayStory(client, currentRiddle.Story - 1); currentAnniversarySection++; client.Player.StoryHelper.SaveSetting("[Anniversary12]-CurrentSection", currentAnniversarySection.ToString()); } } } if (exPlayer.Get(client).StoryEnabled && client.Player.CurrentChapter == null) { int currentStorySection = client.Player.StoryHelper.ReadSetting("[MainStory]-CurrentSection").ToInt(); switch (client.Player.MapID) { case "s737": { if (currentStorySection == 3) { // Tiny Grotto complete, first time [Bulbasaur mission] if (client.Player.X > 20 && client.Player.X < 35 && client.Player.Y > 43) { if (client.Player.GetDungeonCompletionCount(1 - 1) >= 1) { StoryManager.PlayStory(client, 614 - 1); } } } } break; case "s1934": { if (currentStorySection == 6) { if (client.Player.X == 10 && client.Player.Y == 9) { StoryManager.PlayStory(client, 616 - 1); } } } break; } } }
public static void ReviveCharacter(ICharacter character, IMap map, bool fullHeal, PacketHitList hitlist) { try { PacketHitList.MethodStart(ref hitlist); if (fullHeal) { character.HP = character.MaxHP; for (int i = 0; i < character.Moves.Length; i++) { character.Moves[i].CurrentPP = character.Moves[i].MaxPP; } if (character.CharacterType == Enums.CharacterType.Recruit) { ((Recruit)character).RestoreBelly(); } hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " was fully revived!", Text.BrightGreen)); } else { int hp = character.MaxHP / 2; if (hp < 1) hp = 1; character.HP = hp; //restore belly to 20 if (character.CharacterType == Enums.CharacterType.Recruit) { Recruit recruit = character as Recruit; if (recruit.Belly < 25) { recruit.Belly = 25; PacketBuilder.AppendBelly(recruit.Owner, hitlist); } } hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " was revived!", Text.BrightGreen)); } hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("magic682.wav"), character.X, character.Y, 10); hitlist.AddPacketToMap(map, PacketBuilder.CreateSpellAnim(509, character.X, character.Y)); if (character.CharacterType == Enums.CharacterType.Recruit) { ((Recruit)character).Owner.Player.Dead = false; PacketBuilder.AppendDead(((Recruit)character).Owner, hitlist); Messenger.ForceEndStoryTo(((Recruit)character).Owner); } RefreshCharacterMoves(character, map, hitlist); PacketHitList.MethodEnded(ref hitlist); } catch (Exception ex) { Messenger.AdminMsg(ex.ToString(), Text.Black); } }
public static void OnMapLoaded(Client client, IMap map, PacketHitList packetList) { if (exPlayer.Get(client).StoryEnabled) { int currentStorySection = client.Player.StoryHelper.ReadSetting("[MainStory]-CurrentSection").ToInt(); switch (map.MapID) { case "s50": { if (currentStorySection == 4) { // Retreive 500 Poke for Team Jaw if (client.Player.HasItem(1) >= 500) { // We have the 500 Poke client.Player.TakeItem(1, 500); // Move forward one section so we don't have to take the money again currentStorySection++; client.Player.StoryHelper.SaveSetting("[MainStory]-CurrentSection", currentStorySection.ToString()); } else { // We don't have the 500 Poke StoryManager.PlayStory(client, 619 - 1); } } if (currentStorySection == 5) { // We already delivered the 500 Poke to Team Jaw StoryManager.PlayStory(client, 615 - 1); } } break; case "s737": { if (currentStorySection == 1) { StoryManager.PlayStory(client, 612 - 1); } } break; case "s1286": { if (client.Player.Y > 8 && client.Player.Y < 40 && currentStorySection == 2) { StoryManager.PlayStory(client, 613 - 1); } } break; } } }
public void ProcessHunger(PacketHitList hitlist) { if (BellyStepCounter >= 100) { if (GetActiveRecruit().Belly > 20) { GetActiveRecruit().Belly -= (BellyStepCounter / 100); if (GetActiveRecruit().Belly <= 20) { hitlist.AddPacket(client, PacketBuilder.CreateBattleMsg("Getting hungry...", Text.Red)); hitlist.AddPacket(client, PacketBuilder.CreateSoundPacket("magic129.wav")); } PacketBuilder.AppendBelly(client, hitlist); } else if (GetActiveRecruit().Belly > 10) { GetActiveRecruit().Belly -= (BellyStepCounter / 100); if (GetActiveRecruit().Belly <= 10) { hitlist.AddPacket(client, PacketBuilder.CreateBattleMsg("Getting dizzy from hunger...", Text.Red)); hitlist.AddPacket(client, PacketBuilder.CreateSoundPacket("magic129.wav")); } PacketBuilder.AppendBelly(client, hitlist); } else if (GetActiveRecruit().Belly > 0) { GetActiveRecruit().Belly -= (BellyStepCounter / 100); if (GetActiveRecruit().Belly <= 0) { GetActiveRecruit().Belly = 0; hitlist.AddPacket(client, PacketBuilder.CreateBattleMsg("Oh no! Your belly is empty!", Text.Red)); hitlist.AddPacket(client, PacketBuilder.CreateSoundPacket("magic129.wav")); } PacketBuilder.AppendBelly(client, hitlist); } BellyStepCounter = BellyStepCounter % 100; } }
public void BuildHitList(PacketHitList hitList) { this.hitList = hitList; ListPair<IMap, List<Client>> clientCollection = new ListPair<IMap, List<Client>>(); ListPair<IMap, Object[]> borderingMapCollection = new ListPair<IMap, object[]>(); for (int i = 0; i < hitListCache.Count; i++) { object[] param = hitListCache[i]; switch ((PacketHitListTargets)param[0]) { case PacketHitListTargets.Client: { AddPacket((Client)param[1], (TcpPacket)param[2]); } break; case PacketHitListTargets.All: { foreach (Client client in ClientManager.GetClients()) { if (client.IsPlaying()) { AddPacket(client, (TcpPacket)param[1]); } } } break; case PacketHitListTargets.RangedMapBut: { Maps.IMap map = param[2] as IMap; int range = (int)param[6]; Client client = param[1] as Client; foreach (Client mapClient in GetMapClients(clientCollection, map)) { if (mapClient != null && (client == null || mapClient.TcpID != client.TcpID)) { if (range == -1 || PacketHitList.IsInRange(range, (int)param[4], (int)param[5], mapClient.Player.X, mapClient.Player.Y)) { AddPacket(mapClient, (TcpPacket)param[3]); } } } } break; // TODO: Should be fixed... (PacketHitListCache) //case PacketHitListTargets.PlayersInSightBut: { // Client sender = param[1] as Client; // IMap centralMap = param[2] as IMap; // int range = (int)param[6]; // foreach (Client mapClient in centralMap.GetSurroundingClients(centralMap)) { // if (sender == null || sender != mapClient) { // if (range == -1 || SeamlessWorldHelper.IsInSight(centralMap, (int)param[4], (int)param[5], mapClient.Player.Map, mapClient.Player.X, mapClient.Player.Y)) { // AddPacket(mapClient, (TcpPacket)param[3]); // } // } // } // } // break; case PacketHitListTargets.Party: { Party party = param[1] as Party; foreach (Client partyClient in party.GetOnlineMemberClients()) { if (partyClient.IsPlaying()) { AddPacket(partyClient, (TcpPacket)param[2]); } } } break; // TODO: Should be fixed... (PacketHitListCache) //case PacketHitListTargets.Others: { // Combat.ICharacter source = param[1] as Combat.ICharacter; // IMap map = param[2] as IMap; // TcpPacket packet = param[3] as TcpPacket; // Enums.OutdateType updateType = (Enums.OutdateType)param[4]; // foreach (IMap borderingMap in GetBorderingMaps(borderingMapCollection, map)) { // foreach (Client borderingMapClient in GetMapClients(clientCollection, borderingMap)) { // if (borderingMapClient.Player.GetActiveRecruit() != source) { // if (AI.MovementProcessor.WillCharacterSeeCharacter(borderingMap, borderingMapClient.Player.GetActiveRecruit(), map, source)) { // if (!borderingMapClient.Player.IsSeenCharacterSeen(source)) { // borderingMapClient.Player.AddActivation(hitList, source); // } // this.AddPacket(borderingMapClient, packet); // } else { // if (updateType == Enums.OutdateType.Location && borderingMapClient.Player.IsSeenCharacterSeen(source)) { // this.AddPacket(borderingMapClient, packet); // //unsee character // borderingMapClient.Player.RemoveUnseenCharacters(); // } else { // borderingMapClient.Player.OutdateCharacter(source, updateType); // //outdate character // //} // //} else { // //outdate character // } // } // } // } // } // } // break; } } hitListCache.Clear(); }
public void AddSeenCharacters(PacketHitList hitlist) { IMap map = GetCurrentMap(); Recruit activeRecruit = GetActiveRecruit(); for (int i = 0; i < 9; i++) { IMap borderingMap = MapManager.RetrieveBorderingMap(map, (Enums.MapID)i, true); if (borderingMap != null) { for (int n = 0; n < Constants.MAX_MAP_NPCS; n++) { if (AI.MovementProcessor.WillCharacterSeeCharacter(map, activeRecruit, borderingMap, (Enums.MapID)i, borderingMap.ActiveNpc[n])) { //if (!IsSeenCharacterSeen(borderingMap.ActiveNpc[n])) { AddActivationIfCharacterNotSeen(hitlist, borderingMap.ActiveNpc[n]); //} } } foreach (Client n in borderingMap.GetClients()) { if (AI.MovementProcessor.WillCharacterSeeCharacter(map, activeRecruit, borderingMap, (Enums.MapID)i, n.Player.GetActiveRecruit())) { //if (!IsSeenCharacterSeen(n.Player.GetActiveRecruit())) { AddActivationIfCharacterNotSeen(hitlist, n.Player.GetActiveRecruit()); //} } } } } }
public static void HandleDeath(PacketHitList hitlist, Client client, Enums.KillType killType, bool autoSwitch) { PacketHitList.MethodStart(ref hitlist); //aftermath if (HasAbility(client.Player.GetActiveRecruit(), "Aftermath")) { bool explode = true; if (!HasAbility(client.Player.GetActiveRecruit(), "Mold Breaker")) { TargetCollection checkedTargets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, client.Player.Map, null, 0, 0, Enums.Direction.Up, true, true, false); for (int i = 0; i < checkedTargets.Count; i++) { if (HasAbility(checkedTargets[i], "Damp")) { explode = false; } } } if (explode) { hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateBattleMsg(client.Player.GetActiveRecruit().Name + " exploded!", Text.BrightRed), client.Player.X, client.Player.Y, 10); hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("magic216.wav"), client.Player.X, client.Player.Y, 10); for (int i = client.Player.X - 1; i <= client.Player.X + 1; i++) { for (int j = client.Player.Y - 1; j <= client.Player.Y + 1; j++) { if (i < 0 || j < 0 || i > client.Player.Map.MaxX || j > client.Player.Map.MaxY) { } else { hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSpellAnim(497, i, j)); } } } TargetCollection targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Room, 1, client.Player.Map, client.Player.GetActiveRecruit(), client.Player.X, client.Player.Y, Enums.Direction.Up, true, true, true); for (int i = 0; i < targets.Count; i++) { if (client.Player.Map.Moral == Enums.MapMoral.None) { if (targets[i].HP > 0) { if (HasActiveBagItem(targets[i], 6, 0, 0)) { DamageCharacter(targets[i], client.Player.Map, 1, Enums.KillType.Tile, hitlist, true); } else { DamageCharacter(targets[i], client.Player.Map, targets[i].MaxHP / 4, Enums.KillType.Tile, hitlist, true); } } } } } else { hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSoundPacket("magic320.wav"), client.Player.X, client.Player.Y, 10); hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateSpellAnim(505, client.Player.X, client.Player.Y)); hitlist.AddPacketToMap(client.Player.Map, PacketBuilder.CreateBattleMsg("The damp conditions prevented an explosion!", Text.Blue), client.Player.X, client.Player.Y, 10); } } //death flag TargetCollection witnesses = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, client.Player.Map, client.Player.GetActiveRecruit(), 0, 0, Enums.Direction.Up, false, true, false); for (int i = 0; i < witnesses.Count; i++) { AddExtraStatus(witnesses[i], client.Player.Map, "SawAllyFaint", 0, null, "", hitlist); } // Remove status client.Player.GetActiveRecruit().StatusAilment = Enums.StatusAilment.OK; client.Player.GetActiveRecruit().StatusAilmentCounter = 0; List<ExtraStatus> passedStatus = GetTeamStatus(client.Player.GetActiveRecruit()); RemoveAllBondedExtraStatus(client.Player.GetActiveRecruit(), client.Player.Map, hitlist, false); client.Player.GetActiveRecruit().VolatileStatus.Clear(); foreach (ExtraStatus status in passedStatus) { client.Player.GetActiveRecruit().VolatileStatus.Add(status); } RefreshCharacterTraits(client.Player.GetActiveRecruit(), client.Player.Map, hitlist); PacketBuilder.AppendStatusAilment(client, hitlist); RemoveBuffs(client.Player.GetActiveRecruit()); if (Ranks.IsDisallowed(client, Enums.Rank.Moniter)) { client.Player.Hunted = false; PacketBuilder.AppendHunted(client, hitlist); } client.Player.Dead = true; PacketBuilder.AppendDead(client, hitlist); AskAfterDeathQuestion(client); /* if (client.Player.GetActiveRecruit().HeldItemSlot > -1) { if (client.Player.GetActiveRecruit().HeldItem.Num == 222) {//Enigma Berry if (Server.Math.Rand(0, 10) == 0) { Messenger.MapMsg(client.Player.MapID, client.Player.Name + " was revived!!!", Text.BrightGreen); client.Player.GetActiveRecruit().RestoreVitals(); client.Player.GetActiveRecruit().RestoreBelly(); Messenger.SendPlayerMoves(client); foreach (ExtraStatus status in passedStatus) { client.Player.GetActiveRecruit().VolatileStatus.Add(status); } PacketHitList.MethodEnded(ref hitlist); return; } } } if (client.Player.TournamentMatchUp != null) { client.Player.TournamentMatchUp.EndMatchUp(client.Player.TournamentMatchUp.SelectOtherMember(client).Client.Player.CharID); PacketHitList.MethodEnded(ref hitlist); return; } //For Reviver Seeds int slot = client.Player.HasItem(489); if (client.Player.MapID == MapManager.GenerateMapID(660)) { slot = 0; } if (slot > 0) { Messenger.MapMsg(client.Player.MapID, client.Player.Name + " was revived!", Text.BrightGreen); client.Player.GetActiveRecruit().RestoreVitals(); client.Player.GetActiveRecruit().RestoreBelly(); Messenger.SendPlayerMoves(client); client.Player.TakeItem(489, 1); client.Player.GiveItem(488, 1); //NetScript.SetPlayerInvItemNum(index, slot, 488); Messenger.SendInventory(client); foreach (ExtraStatus status in passedStatus) { client.Player.GetActiveRecruit().VolatileStatus.Add(status); } PacketHitList.MethodEnded(ref hitlist); return; } /* //Sacred Ash slot = client.Player.HasItem(523); if (client.Player.MapID == MapManager.GenerateMapID(660)) { slot = 0; } if (slot > 0) { Messenger.MapMsg(client.Player.MapID, client.Player.Name + " was revived!", Text.BrightGreen); client.Player.GetActiveRecruit().RestoreVitals(); client.Player.GetActiveRecruit().RestoreBelly(); Messenger.SendPlayerMoves(client); client.Player.GetActiveRecruit().AttackBuff += 2; client.Player.GetActiveRecruit().DefenseBuff += 2; client.Player.GetActiveRecruit().SpeedBuff += 2; client.Player.GetActiveRecruit().SpAtkBuff += 2; client.Player.TakeItem(523, 1); Messenger.SendInventory(client); return; } if (autoSwitch && client.Player.ActiveSlot != 0) { int activeSlot = client.Player.ActiveSlot; string name = client.Player.GetActiveRecruit().Name; foreach (ExtraStatus status in passedStatus) { client.Player.GetActiveRecruit().VolatileStatus.Add(status); Messenger.BattleMsg(client, status.Name, Text.BrightRed); } client.Player.SwapActiveRecruit(0); client.Player.RestoreRecruitStats(activeSlot); client.Player.RemoveFromTeam(activeSlot); if (!string.IsNullOrEmpty(name)) { Messenger.BattleMsg(client, name + " has fainted and returned home!", Text.BrightRed); } else { Messenger.BattleMsg(client, "Your team member has fainted and returned home!", Text.BrightRed); } Messenger.SendActiveTeam(client); } else { HandleGameOver(client, killType); } if (exPlayer.Get(client).VoltorbFlip) { Messenger.PlaySound(client, "Leave Slot Machine.wav"); } else { Messenger.PlaySound(client, "Death.wav"); } */ //Messenger.SendBattleDivider(client); //RefreshCharacterTraits(client.Player.GetActiveRecruit(), client.Player.Map, hitlist); PacketHitList.MethodEnded(ref hitlist); }
public void AddActivationIfCharacterNotSeen(PacketHitList hitlist, Combat.ICharacter target) { if (target == GetActiveRecruit()) return; SeenCharacter seencharacter; if (target.CharacterType == Enums.CharacterType.Recruit) { bool shouldActivate = false; lock (seenPlayers) { if (!seenPlayers.TryGetValue(((Recruit)target).Owner.Player.CharID, out seencharacter)) { seencharacter = new SeenCharacter(); seenPlayers.Add(((Recruit)target).Owner.Player.CharID, seencharacter); shouldActivate = true; } else { if (!seencharacter.InSight) { shouldActivate = true; } } } if (shouldActivate) { if (seencharacter.LocationOutdated) { //add location data hitlist.AddPacket(client, PacketBuilder.CreatePlayerXY(((Recruit)target).Owner)); hitlist.AddPacket(client, PacketBuilder.CreatePlayerDir(((Recruit)target).Owner)); seencharacter.LocationOutdated = false; } if (seencharacter.ConditionOutdated) { //add condition data hitlist.AddPacket(client, PacketBuilder.CreatePlayerStatusAilment(((Recruit)target).Owner)); //hitlist.AddPacket(client, PacketBuilder.CreatePlayerConfusion(((Recruit)target).Owner)); hitlist.AddPacket(client, PacketBuilder.CreatePlayerVolatileStatus(((Recruit)target).Owner)); seencharacter.ConditionOutdated = false; } //add activation param hitlist.AddPacket(client, PacketBuilder.CreatePlayerActivation(((Recruit)target).Owner, true)); //set isseen to true seencharacter.InSight = true; } } else if (target.CharacterType == Enums.CharacterType.MapNpc) { MapNpc npcTarget = (MapNpc)target; bool shouldActivate = false; lock (seenNpcs) { Dictionary<int, SeenCharacter> mapSeenNpcs = null; if (!seenNpcs.TryGetValue(npcTarget.MapID, out mapSeenNpcs)) { mapSeenNpcs = new Dictionary<int, SeenCharacter>(); seenNpcs.Add(npcTarget.MapID, mapSeenNpcs); shouldActivate = true; } if (!mapSeenNpcs.TryGetValue(npcTarget.MapSlot, out seencharacter)) { seencharacter = new SeenCharacter(); mapSeenNpcs.Add(npcTarget.MapSlot, seencharacter); shouldActivate = true; } else { if (!seencharacter.InSight) { shouldActivate = true; } } } if (shouldActivate) { if (seencharacter.LocationOutdated) { //add location data hitlist.AddPacket(client, PacketBuilder.CreateNpcXY(npcTarget)); hitlist.AddPacket(client, PacketBuilder.CreateNpcDir(npcTarget)); seencharacter.LocationOutdated = false; } if (seencharacter.ConditionOutdated) { //add condition data hitlist.AddPacket(client, PacketBuilder.CreateNpcHP(npcTarget)); hitlist.AddPacket(client, PacketBuilder.CreateNpcStatusAilment(npcTarget)); //hitlist.AddPacket(client, PacketBuilder.CreateNpcConfusion(npcTarget)); hitlist.AddPacket(client, PacketBuilder.CreateNpcVolatileStatus(npcTarget)); seencharacter.ConditionOutdated = false; } //add activation param hitlist.AddPacket(client, PacketBuilder.CreateNpcActivation(npcTarget, true)); //set isseen to true seencharacter.InSight = true; } } }
public static void OnDeath(PacketHitList hitlist, Client client, Enums.KillType killType) { try { HandleDeath(hitlist, client, killType, true); } catch (Exception ex) { Messenger.AdminMsg("Error: OnDeath", Text.Black); } }