internal static void ResumeStory(Client client, int storyNum) { client.Player.LoadingStory = true; Messenger.SendLoadingStoryTo(client); client.Player.CurrentChapter = Stories[storyNum]; Messenger.SendDataTo(client, TcpPacket.CreatePacket("storycheck", storyNum.ToString(), Stories[storyNum].Revision.ToString())); }
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 static void AddNewClass(Client client, string ClassName) { if (System.IO.File.Exists(GetTempFolder(client) + ClassName + ".cs") == false) { System.IO.File.WriteAllText(GetTempFolder(client) + ClassName + ".cs", "using Server;\nusing Server.Scripting;\nusing Server.Database;\nusing System;\nusing System.Drawing;\nusing System.Xml;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace Script \n{\npublic class " + ClassName + "\n{\n\n}\n}"); Messenger.SendDataTo(client, TcpPacket.CreatePacket("scriptfiledata", ClassName, GetScriptFile(client, ClassName))); } }
public static void AppendFileListToPacket(Client client, TcpPacket packet) { string[] files = System.IO.Directory.GetFiles(GetTempFolder(client)); packet.AppendParameter(files.Length.ToString()); for (int i = 0; i < files.Length; i++) { packet.AppendParameter(System.IO.Path.GetFileNameWithoutExtension(files[i])); } }
public static bool ContainsClient(Client client) { rwLock.EnterReadLock(); try { return clients.ContainsValue(client); } finally { rwLock.ExitReadLock(); } }
public static List<int> FindAllEvolutions(Client client, int evoIndex) { List<int> evoToLoad = new List<int>(); for (int i = 0; i < Evolutions[evoIndex].Branches.Count; i++) { evoToLoad.Add(i); } return evoToLoad; }
public bool CanAddToParty(Client client) { // If there are less than 4 members if (Members.Count < 4) { return true; } else { return false; } }
public bool Add(Client client) { if (CanAddToParty(client)) { Add(client.Player.CharID); SwitchOutExtraMembers(); return true; } else { return false; } }
public Party(string partyID, Client leader) { PartyID = partyID; Members = new List<string>(); Members.Add(leader.Player.CharID); using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) { PartyManager.SaveParty(dbConnection.Database, this); } }
public static void RunScript(Client client, int script, string param1, string param2, string param3, bool wait) { if (wait) { ScriptManager.InvokeSub("StoryScript", client, script, param1, param2, param3, wait); Messenger.SendDataTo(client, TcpPacket.CreatePacket("storyscriptcomplete")); } else { Messenger.SendDataTo(client, TcpPacket.CreatePacket("storyscriptcomplete")); ScriptManager.InvokeSub("StoryScript", client, script, param1, param2, param3, wait); } }
public MapLoadTriggerEvent(string id, TriggerEventAction action, int triggerCommand, bool autoRemove, Client client, string mapID) { this.id = id; this.action = action; this.triggerCommand = triggerCommand; this.autoRemove = autoRemove; this.client = client; this.mapID = mapID; }
public PlayerEventThread(Client ownerClient) { playerThread = new Thread(new ThreadStart(ProcessQueuedEvents)); resetEvent = new ManualResetEvent(false); eventQueue = new PlayerEventQueue(); this.ownerClient = ownerClient; playerThread.IsBackground = true; playerThread.Start(); }
public static void SaveScript(Client client) { foreach (string File in System.IO.Directory.GetFiles(IO.Paths.ScriptsFolder, "*.cs", System.IO.SearchOption.TopDirectoryOnly)) { System.IO.File.Delete(File); } foreach (string File in System.IO.Directory.GetFiles(GetTempFolder(client))) { //IO.File.Delete(ScriptFolder & Path.GetFileNameWithoutExtension(File) & ".txt") System.IO.File.Copy(File, IO.Paths.ScriptsFolder + System.IO.Path.GetFileNameWithoutExtension(File) + ".cs", true); } }
public static void PlayStory(Client client, int storyNum) { if (storyNum > -1 && storyNum <= Stories.MaxStories) { if (client.Player.CurrentChapter != null) { client.Player.StoryPlaybackCache.Add(Stories[storyNum]); } else { StartStoryCheck(client, storyNum); //PlayStory(client, Stories.Stories[storyNum]); } } }
public static void InitTempScript(Client client) { if (System.IO.Directory.Exists(GetTempFolder(client)) == true) { System.IO.Directory.Delete(GetTempFolder(client), true); } System.IO.Directory.CreateDirectory(GetTempFolder(client)); string[] files = System.IO.Directory.GetFiles(IO.Paths.ScriptsFolder, "*.cs", System.IO.SearchOption.TopDirectoryOnly); for (int i = 0; i < files.Length; i++) { System.IO.File.Copy(files[i], GetTempFolder(client) + System.IO.Path.GetFileNameWithoutExtension(files[i]) + ".cs"); } }
public static void AddNewClient(TcpClientIdentifier clientID, TcpClient tcpClient) { Client client = new Client(clientID, tcpClient); rwLock.EnterWriteLock(); try { clients.Add(clientID, client); } finally { rwLock.ExitWriteLock(); } }
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 StepCounterTriggerEvent(string id, TriggerEventAction action, int triggerCommand, bool autoRemove, Client client, int steps) { this.id = id; this.action = action; this.triggerCommand = triggerCommand; this.autoRemove = autoRemove; this.client = client; this.steps = steps; this.stepsCounted = 0; }
public SteppedOnTileTriggerEvent(string id, TriggerEventAction action, int triggerCommand, bool autoRemove, Client client, string mapID, int x, int y) { this.id = id; this.action = action; this.triggerCommand = triggerCommand; this.autoRemove = autoRemove; this.client = client; this.mapID = mapID; this.x = x; this.y = y; }
public static List<int> FindViableEvolutions(Client client, int evoIndex) { List<int> evoToLoad = new List<int>(); for (int i = 0; i < Evolutions[evoIndex].Branches.Count; i++) { bool canEvolve = Scripting.ScriptManager.InvokeFunction("ScriptedEvoReq", client, Evolutions[evoIndex].Branches[i].ReqScript, Evolutions[evoIndex].Branches[i].Data1, Evolutions[evoIndex].Branches[i].Data2, Evolutions[evoIndex].Branches[i].Data3).ToBool(); if (canEvolve) { evoToLoad.Add(i); } } return evoToLoad; }
public Recruit(Client owner) { this.owner = owner; recruitData = new RecruitData(); HeldItemSlot = -1; Mobility = new bool[16]; Darkness = -2; TimeMultiplier = 1000; ActiveItems = new List<int>(); VolatileStatus = new ExtraStatusCollection(); }
public static void AskQuestion(Client client, string questionID, string text, int storySprite, string[] choices) { client.Player.QuestionID = questionID; TcpPacket packet = new TcpPacket("askquestion"); packet.AppendParameters(text, storySprite.ToString(), questionID); packet.AppendParameter(choices.Length); foreach (string i in choices) { packet.AppendParameter(i); } packet.FinalizePacket(); SendDataTo(client, packet); SendHunted(client); }
public static Tournament CreateTournament(Client manager, string name, string hubMap, int hubStartX, int hubStartY) { Tournament tournament = new Tournament(GenerateUniqueID(), name, new WarpDestination(hubMap, hubStartX, hubStartY)); // Add the manager TournamentMember member = new TournamentMember(tournament, manager); member.Admin = true; member.Active = true; tournament.RegisterPlayer(member); tournaments.AddTournament(tournament); return tournament; }
public static void InvokeGenericTrigger(ITriggerEvent triggerEvent, Client client) { switch (triggerEvent.Action) { case TriggerEventAction.PlayStory: { StoryManager.PlayStory(client, triggerEvent.TriggerCommand); } break; case TriggerEventAction.RunScript: { Scripting.ScriptManager.InvokeSub("TriggerEventScript", client, triggerEvent); } break; } }
public static void PlayStory(Client client, Story story) { if (client.Player.CurrentChapter != null) { client.Player.StoryPlaybackCache.Add(story); } else { if (string.IsNullOrEmpty(story.Name)) { story.Name = "Scripted Story"; } client.Player.CurrentChapter = story; client.Player.LoadingStory = true; Messenger.SendLoadingStoryTo(client); Messenger.SendRunStoryTo(client, story); } }
public bool AddToParty(Client client) { if (CanAddToParty(client)) { Add(client.Player.CharID); //SwitchOutExtraMembers(); using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) { PartyManager.SaveParty(dbConnection.Database, this); } return true; } else { return false; } }
private static void StartStoryCheck(Client client, int storyNum) { if (client.Player.GetStoryState(storyNum) == false) { if (Stories[storyNum].StoryStart != 0) { if (client.Player.GetStoryState(Stories[storyNum].StoryStart - 1) == false) { return; } } client.Player.LoadingStory = true; Messenger.SendLoadingStoryTo(client); client.Player.CurrentChapter = Stories[storyNum]; Messenger.SendDataTo(client, TcpPacket.CreatePacket("storycheck", storyNum.ToString(), Stories[storyNum].Revision.ToString())); } }
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); }
internal static void ProcessData(Client client, string data) { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); long dataSplittingTime; watch.Start(); string[] parse = data.Split(TcpPacket.SEP_CHAR); watch.Stop(); dataSplittingTime = watch.ElapsedTicks; watch.Reset(); Server.Debug.ThreadCPUWatcher cpuWatch = new Debug.ThreadCPUWatcher(); cpuWatch.Start(); watch.Start(); ProcessData(client, parse); watch.Stop(); cpuWatch.StopWatcher(watch.ElapsedMilliseconds); Statistics.PacketStatistics.AddStatistic(parse[0], watch.ElapsedTicks, dataSplittingTime, cpuWatch.CPUusage); }
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 static bool IsPlaying(Client client) { return(true); }