public static int HasItem(int index, int itemNum) { int i = 0; // Check for subscript out of range if (C_Player.IsPlaying(index) == false || itemNum <= 0 || itemNum > Constants.MAX_ITEMS) { return(0); } for (i = 1; i <= Constants.MAX_INV; i++) { // Check to see if the player has the item if (C_Player.GetPlayerInvItemNum(index, i) == itemNum) { if (Types.Item[itemNum].Type == (byte)Enums.ItemType.Currency || Types.Item[itemNum].Stackable == 1) { return(C_Player.GetPlayerInvItemValue(index, i)); } else { return(1); } return(0); } } return(0); }
internal static void SendDropItem(int invNum, int amount) { ByteStream buffer = new ByteStream(4); if (System.Convert.ToBoolean(C_Banks.InBank != 0 || C_Shops.InShop != 0)) { return; } // do basic checks if (invNum < 1 || invNum > Constants.MAX_INV) { return; } if (C_Variables.PlayerInv[invNum].Num <1 || C_Variables.PlayerInv[invNum].Num> Constants.MAX_ITEMS) { return; } if (Types.Item[C_Player.GetPlayerInvItemNum(C_Variables.Myindex, invNum)].Type == (byte)Enums.ItemType.Currency || Types.Item[C_Player.GetPlayerInvItemNum(C_Variables.Myindex, invNum)].Stackable == 1) { if (amount < 1 || amount > C_Variables.PlayerInv[invNum].Value) { return; } } buffer.WriteInt32((System.Int32)Packets.ClientPackets.CMapDropItem); buffer.WriteInt32(invNum); buffer.WriteInt32(amount); C_NetworkConfig.Socket.SendData(buffer.Data, buffer.Head); buffer.Dispose(); }
public void BtnMapReport_Click(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Mapper) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } C_NetworkSend.SendRequestMapreport(); }
internal static void SendPlayerDir() { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((System.Int32)Packets.ClientPackets.CPlayerDir); buffer.WriteInt32(C_Player.GetPlayerDir(C_Variables.Myindex)); C_NetworkConfig.Socket.SendData(buffer.Data, buffer.Head); buffer.Dispose(); }
public void BtnSpawnItem_Click(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Creator) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } C_NetworkSend.SendSpawnItem(System.Convert.ToInt32(cmbSpawnItem.SelectedIndex + 1), System.Convert.ToInt32(nudSpawnItemAmount.Value)); }
public void BtnALoc_Click(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Mapper) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } C_Variables.BLoc = !C_Variables.BLoc; }
internal static void Packet_QuestMessage(ref byte[] data) { ByteStream buffer = new ByteStream(data); QuestNum = buffer.ReadInt32(); QuestMessage = buffer.ReadString().Trim(); QuestMessage = QuestMessage.Replace("$playername$", C_Player.GetPlayerName(C_Variables.Myindex)); QuestNumForStart = buffer.ReadInt32(); UpdateQuestChat = true; buffer.Dispose(); }
public void BtnAdminSetSprite_Click(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Mapper) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } if (nudAdminSprite.Value < 1) { return; } C_NetworkSend.SendSetSprite(System.Convert.ToInt32(nudAdminSprite.Value)); }
public void BtnAdminBan_Click(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Mapper) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } if (Microsoft.VisualBasic.Strings.Trim(System.Convert.ToString(txtAdminName.Text)).Length < 1) { return; } C_NetworkSend.SendBan(Microsoft.VisualBasic.Strings.Trim(System.Convert.ToString(txtAdminName.Text))); }
public static void Packet_Visit(ref byte[] data) { int i = 0; ByteStream buffer = new ByteStream(data); i = buffer.ReadInt32(); C_Variables.DialogType = C_Constants.DialogueTypeVisit; C_Variables.DialogMsg1 = "You have been invited to visit " + C_Player.GetPlayerName(i).Trim() + "'s house."; C_Variables.DialogMsg2 = ""; C_Variables.DialogMsg3 = ""; buffer.Dispose(); C_Variables.UpdateDialog = true; }
public void BtnAdminWarpTo_Click(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Mapper) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } // Check to make sure its a valid map # if (nudAdminMap.Value > 0 && nudAdminMap.Value <= Constants.MAX_MAPS) { C_NetworkSend.WarpTo(System.Convert.ToInt32(nudAdminMap.Value)); } else { C_Text.AddText("Invalid map number.", (System.Int32)Enums.ColorType.BrightRed); } }
public void LstMaps_DoubleClick(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Mapper) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } // Check to make sure its a valid map # if (lstMaps.FocusedItem.Index + 1 > 0 && lstMaps.FocusedItem.Index + 1 <= Constants.MAX_MAPS) { C_NetworkSend.WarpTo(System.Convert.ToInt32(lstMaps.FocusedItem.Index + 1)); } else { C_Text.AddText("Invalid map number: " + (lstMaps.FocusedItem.Index + 1), (System.Int32)Enums.QColorType.AlertColor); } }
public void BtnAdminSetAccess_Click(object sender, EventArgs e) { if (C_Player.GetPlayerAccess(C_Variables.Myindex) < (int)Enums.AdminType.Creator) { C_Text.AddText("You need to be a high enough staff member to do this!", (System.Int32)Enums.QColorType.AlertColor); return; } if (Microsoft.VisualBasic.Strings.Trim(System.Convert.ToString(txtAdminName.Text)).Length < 2) { return; } if (Information.IsNumeric(Microsoft.VisualBasic.Strings.Trim(System.Convert.ToString(txtAdminName.Text))) || cmbAccess.SelectedIndex < 0) { return; } C_NetworkSend.SendSetAccess(Microsoft.VisualBasic.Strings.Trim(System.Convert.ToString(txtAdminName.Text)), System.Convert.ToByte(cmbAccess.SelectedIndex)); }
public static void Packet_CheckMap(ref byte[] data) { int x; int y; int i = 0; byte needMap = 0; ByteStream buffer = new ByteStream(data); C_Variables.GettingMap = true; // Erase all players except self for (i = 1; i <= C_Variables.TotalOnline; i++) //MAX_PLAYERS { if (i != C_Variables.Myindex) { C_Player.SetPlayerMap(i, 0); } } // Erase all temporary tile values C_GameLogic.ClearTempTile(); ClearMapNpcs(); ClearMapItems(); C_DataBase.ClearBlood(); ClearMap(); // Get map num x = buffer.ReadInt32(); // Get revision y = buffer.ReadInt32(); needMap = (byte)1; // Either the revisions didn't match or we dont have the map, so we need it buffer = new ByteStream(4); buffer.WriteInt32((System.Int32)Packets.ClientPackets.CNeedMap); buffer.WriteInt32(needMap); C_NetworkConfig.Socket.SendData(buffer.Data, buffer.Head); buffer.Dispose(); }
public void Picscreen_MouseDown(object sender, MouseEventArgs e) { if (!C_GuiFunctions.CheckGuiClick(e.X, e.Y, e)) { if (C_Constants.InMapEditor) { FrmEditor_MapEditor.Default.MapEditorMouseDown((System.Int32)e.Button, e.X, e.Y, false); } // left click if (e.Button == MouseButtons.Left) { // if we're in the middle of choose the trade target or not if (!C_Trade.TradeRequest) { if (C_Pets.PetAlive(C_Variables.Myindex)) { if (C_GameLogic.IsInBounds()) { C_Pets.PetMove(C_Variables.CurX, C_Variables.CurY); } } // targetting C_NetworkSend.PlayerSearch(C_Variables.CurX, C_Variables.CurY, (byte)0); } else { // trading C_Trade.SendTradeRequest(C_Types.Player[C_Variables.MyTarget].Name); } C_UpdateUI.PnlRClickVisible = false; C_Pets.ShowPetStats = false; // right click } else if (e.Button == MouseButtons.Right) { if (C_Variables.ShiftDown || C_UpdateUI.VbKeyShift == true) { // admin warp if we're pressing shift and right clicking if (C_Player.GetPlayerAccess(C_Variables.Myindex) >= 2) { C_NetworkSend.AdminWarp(C_Variables.CurX, C_Variables.CurY); } } else { // rightclick menu if (C_Pets.PetAlive(C_Variables.Myindex)) { if (C_GameLogic.IsInBounds() && C_Variables.CurX == C_Types.Player[C_Variables.Myindex].Pet.X & C_Variables.CurY == C_Types.Player[C_Variables.Myindex].Pet.Y) { C_Pets.ShowPetStats = true; } } else { C_NetworkSend.PlayerSearch(C_Variables.CurX, C_Variables.CurY, (byte)1); } } C_Housing.FurnitureSelected = 0; } } C_GuiFunctions.CheckGuiMouseDown(e.X, e.Y, e); if (!FrmAdmin.Default.Visible || !FrmOptions.Default.Visible) { Focus(); } }
public static void Startup() { SFML.Portable.Activate(); SetStatus(Strings.Get("loadscreen", "loading")); FrmMenu.Default.Visible = true; Application.DoEvents(); C_Types.CharSelection = new C_Types.CharSelRec[4]; C_Types.Player = new C_Types.PlayerRec[Constants.MAX_PLAYERS + 1]; for (var i = 1; i <= Constants.MAX_PLAYERS; i++) { C_Player.ClearPlayer(i); } C_AutoTiles.ClearAutotiles(); //Housing C_Housing.House = new C_Housing.HouseRec[C_Housing.MaxHouses + 1]; C_Housing.HouseConfig = new C_Housing.HouseRec[C_Housing.MaxHouses + 1]; //quests C_Quest.ClearQuests(); //npc's C_DataBase.ClearNpcs(); C_Maps.Map.Npc = new int[Constants.MAX_MAP_NPCS + 1]; C_Maps.MapNpc = new C_Types.MapNpcRec[Constants.MAX_MAP_NPCS + 1]; for (var i = 0; i <= Constants.MAX_MAP_NPCS; i++) { for (var x = 0; x <= (int)Enums.VitalType.Count - 1; x++) { C_Maps.MapNpc[(int)i].Vital = new int[(int)x + 1]; } } C_Shops.ClearShops(); C_DataBase.ClearAnimations(); C_DataBase.ClearAnimInstances(); C_Banks.ClearBank(); C_Projectiles.MapProjectiles = new C_Projectiles.MapProjectileRec[C_Projectiles.MaxProjectiles + 1]; C_Projectiles.Projectiles = new C_Projectiles.ProjectileRec[C_Projectiles.MaxProjectiles + 1]; C_Items.ClearItems(); //craft C_Crafting.ClearRecipes(); //party C_Parties.ClearParty(); //pets C_Pets.ClearPets(); C_Variables.GettingMap = true; C_Variables.VbQuote = System.Convert.ToString((char)34); // " // Update the form with the game's name before it's loaded FrmGame.Default.Text = C_Constants.GameName; SetStatus(Strings.Get("loadscreen", "options")); // load options if (File.Exists(Application.StartupPath + "\\Data\\Config.xml")) { C_DataBase.LoadOptions(); } else { C_DataBase.CreateOptions(); } // randomize rnd's seed VBMath.Randomize(); SetStatus(Strings.Get("loadscreen", "network")); FrmMenu.Default.Text = C_Constants.GameName; // DX7 Master Object is already created, early binding SetStatus(Strings.Get("loadscreen", "graphics")); C_Maps.CheckTilesets(); C_DataBase.CheckCharacters(); C_DataBase.CheckPaperdolls(); C_DataBase.CheckAnimations(); C_Items.CheckItems(); C_Resources.CheckResources(); C_DataBase.CheckSkillIcons(); C_DataBase.CheckFaces(); C_DataBase.CheckFog(); C_DataBase.CacheMusic(); C_DataBase.CacheSound(); C_DataBase.CheckEmotes(); C_DataBase.CheckPanoramas(); C_Housing.CheckFurniture(); C_Projectiles.CheckProjectiles(); C_DataBase.CheckParallax(); C_Graphics.InitGraphics(); // check if we have main-menu music if (C_Types.Options.Music == 1 && C_Types.Options.MenuMusic.Trim().Length > 0) { C_Sound.PlayMusic(C_Types.Options.MenuMusic.Trim()); C_Sound.MusicPlayer.Volume = 100; } // Reset values C_Variables.Ping = -1; // set values for directional blocking arrows C_Variables.DirArrowX[1] = 12; // up C_Variables.DirArrowY[1] = 0; C_Variables.DirArrowX[2] = 12; // down C_Variables.DirArrowY[2] = 23; C_Variables.DirArrowX[3] = 0; // left C_Variables.DirArrowY[3] = 12; C_Variables.DirArrowX[4] = 23; // right C_Variables.DirArrowY[4] = 12; //set gui switches C_UpdateUI.HudVisible = true; SetStatus(Strings.Get("loadscreen", "starting")); Started = true; C_UpdateUI.Frmmenuvisible = true; C_UpdateUI.Pnlloadvisible = false; //C_UpdateUI.PnlInventoryVisible = true; C_NetworkConfig.InitNetwork(); C_GameLogic.GameLoop(); }
internal static void DrawParty() { int I = 0; int x = 0; int y = 0; int barwidth = 0; int playerNum = 0; string theName = ""; Rectangle[] rec = new Rectangle[2]; // render the window // draw the bars if (Party.Leader > 0) // make sure we're in a party { // draw leader playerNum = Party.Leader; // name theName = C_Player.GetPlayerName(playerNum).Trim(); // draw name y = 100; x = 10; C_Text.DrawText(x, y, theName, SFML.Graphics.Color.Yellow, SFML.Graphics.Color.Black, C_Graphics.GameWindow); // draw hp if (C_Types.Player[playerNum].Vital[(byte)Enums.VitalType.HP] > 0) { // calculate the width to fill barwidth = System.Convert.ToInt32(C_Types.Player[playerNum].Vital[(byte)Enums.VitalType.HP] / (C_Player.GetPlayerMaxVital(playerNum, Enums.VitalType.HP)) * 64); // draw bars rec[1] = new Rectangle(x, y, barwidth, 6); RectangleShape rectShape = new RectangleShape(new Vector2f(barwidth, 6)) { Position = new Vector2f(x, y + 15), FillColor = SFML.Graphics.Color.Red }; C_Graphics.GameWindow.Draw(rectShape); } // draw mp if (C_Types.Player[playerNum].Vital[(byte)Enums.VitalType.MP] > 0) { // calculate the width to fill barwidth = System.Convert.ToInt32(C_Types.Player[playerNum].Vital[(byte)Enums.VitalType.MP] / (C_Player.GetPlayerMaxVital(playerNum, Enums.VitalType.MP)) * 64); // draw bars rec[1] = new Rectangle(x, y, barwidth, 6); RectangleShape rectShape2 = new RectangleShape(new Vector2f(barwidth, 6)) { Position = new Vector2f(x, y + 24), FillColor = SFML.Graphics.Color.Blue }; C_Graphics.GameWindow.Draw(rectShape2); } // draw members for (I = 1; I <= Constants.MAX_PARTY_MEMBERS; I++) { if (Party.Member[I] > 0) { if (Party.Member[I] != Party.Leader) { // cache the index playerNum = Party.Member[I]; // name theName = C_Player.GetPlayerName(playerNum).Trim(); // draw name y = 100 + ((I - 1) * 30); C_Text.DrawText(x, y, theName, SFML.Graphics.Color.White, SFML.Graphics.Color.Black, C_Graphics.GameWindow); // draw hp y = 115 + ((I - 1) * 30); // make sure we actually have the data before rendering if (C_Player.GetPlayerVital(playerNum, Enums.VitalType.HP) > 0 && C_Player.GetPlayerMaxVital(playerNum, Enums.VitalType.HP) > 0) { barwidth = System.Convert.ToInt32(C_Types.Player[playerNum].Vital[(byte)Enums.VitalType.HP] / (C_Player.GetPlayerMaxVital(playerNum, Enums.VitalType.HP)) * 64); } rec[1] = new Rectangle(x, y, barwidth, 6); RectangleShape rectShape = new RectangleShape(new Vector2f(barwidth, 6)) { Position = new Vector2f(x, y), FillColor = SFML.Graphics.Color.Red }; C_Graphics.GameWindow.Draw(rectShape); // draw mp y = 115 + ((I - 1) * 30); // make sure we actually have the data before rendering if (C_Player.GetPlayerVital(playerNum, Enums.VitalType.MP) > 0 && C_Player.GetPlayerMaxVital(playerNum, Enums.VitalType.MP) > 0) { barwidth = System.Convert.ToInt32(C_Types.Player[playerNum].Vital[(byte)Enums.VitalType.MP] / (C_Player.GetPlayerMaxVital(playerNum, Enums.VitalType.MP)) * 64); } rec[1] = new Rectangle(x, y, barwidth, 6); RectangleShape rectShape2 = new RectangleShape(new Vector2f(barwidth, 6)) { Position = new Vector2f(x, y + 8), FillColor = SFML.Graphics.Color.Blue }; C_Graphics.GameWindow.Draw(rectShape2); } } } } }
internal static void DrawPlayerName(int index) { int textX = 0; int textY = 0; Color color = new Color(); Color backcolor = new Color(); string name = ""; // Check access level if (C_Player.GetPlayerPk(index) == 0) { switch (C_Player.GetPlayerAccess(index)) { case (int)Enums.AdminType.Player: color = SFML.Graphics.Color.Red; backcolor = SFML.Graphics.Color.Black; break; case (int)Enums.AdminType.Monitor: color = SFML.Graphics.Color.Black; backcolor = SFML.Graphics.Color.White; break; case (int)Enums.AdminType.Mapper: color = SFML.Graphics.Color.Cyan; backcolor = SFML.Graphics.Color.Black; break; case (int)Enums.AdminType.Developer: color = SFML.Graphics.Color.Green; backcolor = SFML.Graphics.Color.Black; break; case (int)Enums.AdminType.Creator: color = SFML.Graphics.Color.Yellow; backcolor = SFML.Graphics.Color.Black; break; } } else { color = SFML.Graphics.Color.Red; } name = C_Types.Player[index].Name.Trim(); // calc pos textX = System.Convert.ToInt32(C_Graphics.ConvertMapX(C_Player.GetPlayerX(index) * C_Constants.PicX) + C_Types.Player[index].XOffset + (C_Constants.PicX / 2)); textX = System.Convert.ToInt32(textX - ((double)GetTextWidth(name.Trim()) / 2)); if (C_Player.GetPlayerSprite(index) < 1 || C_Player.GetPlayerSprite(index) > C_Graphics.NumCharacters) { textY = C_Graphics.ConvertMapY(C_Player.GetPlayerY(index) * C_Constants.PicY) + C_Types.Player[index].YOffset - 16; } else { // Determine location for text textY = System.Convert.ToInt32(C_Graphics.ConvertMapY(C_Player.GetPlayerY(index) * C_Constants.PicY) + C_Types.Player[index].YOffset - ((double)C_Graphics.CharacterGfxInfo[C_Player.GetPlayerSprite(index)].Height / 4) + 16); } // Draw name DrawText(textX, textY, name.Trim(), color, backcolor, C_Graphics.GameWindow); }
public static void DrawTrade() { int i = 0; int x = 0; int y = 0; int itemnum = 0; int itempic = 0; string amount = ""; Rectangle rec = new Rectangle(); Rectangle recPos = new Rectangle(); SFML.Graphics.Color colour = new SFML.Graphics.Color(); amount = System.Convert.ToString(0); colour = SFML.Graphics.Color.White; if (!C_Variables.InGame) { return; } //first render panel C_Graphics.RenderSprite(C_Graphics.TradePanelSprite, C_Graphics.GameWindow, C_UpdateUI.TradeWindowX, C_UpdateUI.TradeWindowY, 0, 0, C_Graphics.TradePanelGfxInfo.Width, C_Graphics.TradePanelGfxInfo.Height); //Headertext C_Text.DrawText(C_UpdateUI.TradeWindowX + 70, C_UpdateUI.TradeWindowY + 6, "Your Offer", SFML.Graphics.Color.White, SFML.Graphics.Color.Black, C_Graphics.GameWindow, (byte)15); C_Text.DrawText(C_UpdateUI.TradeWindowX + 260, C_UpdateUI.TradeWindowY + 6, C_UpdateUI.Tradername + "'s Offer.", SFML.Graphics.Color.White, SFML.Graphics.Color.Black, C_Graphics.GameWindow, (byte)15); for (i = 1; i <= Constants.MAX_INV; i++) { // blt your own offer itemnum = C_Player.GetPlayerInvItemNum(C_Variables.Myindex, TradeYourOffer[i].Num); if (itemnum > 0 && itemnum <= Constants.MAX_ITEMS) { itempic = Types.Item[itemnum].Pic; if (itempic > 0 && itempic <= C_Graphics.NumItems) { if (C_Graphics.ItemsGfxInfo[itempic].IsLoaded == false) { C_Graphics.LoadTexture(itempic, (byte)4); } //seeying we still use it, lets update timer ref var with_1 = ref C_Graphics.ItemsGfxInfo[itempic]; with_1.TextureTimer = C_General.GetTickCount() + 100000; rec.Y = 0; rec.Height = C_Constants.PicY; rec.X = 0; rec.Width = C_Constants.PicX; recPos.Y = C_UpdateUI.TradeWindowY + C_UpdateUI.OurTradeY + C_UpdateUI.InvTop + ((C_UpdateUI.InvOffsetY + 32) * ((i - 1) / C_UpdateUI.InvColumns)); recPos.Height = C_Constants.PicY; recPos.X = C_UpdateUI.TradeWindowX + C_UpdateUI.OurTradeX + C_UpdateUI.InvLeft + ((C_UpdateUI.InvOffsetX + 32) * ((i - 1) % C_UpdateUI.InvColumns)); recPos.Width = C_Constants.PicX; C_Graphics.RenderSprite(C_Graphics.ItemsSprite[itempic], C_Graphics.GameWindow, recPos.X, recPos.Y, rec.X, rec.Y, rec.Width, rec.Height); // If item is a stack - draw the amount you have if (TradeYourOffer[i].Value >= 1) { y = recPos.Top + 22; x = recPos.Left - 4; // Draw currency but with k, m, b etc. using a convertion function if (double.Parse(amount) < 1000000) { colour = SFML.Graphics.Color.White; } else if (double.Parse(amount) > 1000000 && long.Parse(amount) < 10000000) { colour = SFML.Graphics.Color.Yellow; } else if (double.Parse(amount) > 10000000) { colour = SFML.Graphics.Color.Green; } amount = System.Convert.ToString(TradeYourOffer[i].Value); C_Text.DrawText(x, y, C_GameLogic.ConvertCurrency(System.Convert.ToInt32(amount)), colour, SFML.Graphics.Color.Black, C_Graphics.GameWindow); } } } }
public void FrmMainGame_KeyUp(object sender, KeyEventArgs e) { int skillnum = 0; if (e.KeyCode == Keys.S) { C_UpdateUI.VbKeyDown = false; } if (e.KeyCode == Keys.W) { C_UpdateUI.VbKeyUp = false; } if (e.KeyCode == Keys.A) { C_UpdateUI.VbKeyLeft = false; } if (e.KeyCode == Keys.D) { C_UpdateUI.VbKeyRight = false; } if (e.KeyCode == Keys.Down) { C_UpdateUI.VbKeyDown = false; } if (e.KeyCode == Keys.Up) { C_UpdateUI.VbKeyUp = false; } if (e.KeyCode == Keys.Left) { C_UpdateUI.VbKeyLeft = false; } if (e.KeyCode == Keys.Right) { C_UpdateUI.VbKeyRight = false; } if (e.KeyCode == Keys.ShiftKey) { C_UpdateUI.VbKeyShift = false; } if (e.KeyCode == Keys.ControlKey) { C_UpdateUI.VbKeyControl = false; } if (e.KeyCode == Keys.Alt) { C_UpdateUI.VbKeyAlt = false; } //hotbar if (e.KeyCode == Keys.NumPad1) { skillnum = C_Types.Player[C_Variables.Myindex].Hotbar[1].Slot; if (skillnum != 0) { C_Player.PlayerCastSkill(skillnum); } } if (e.KeyCode == Keys.NumPad2) { skillnum = C_Types.Player[C_Variables.Myindex].Hotbar[2].Slot; if (skillnum != 0) { C_Player.PlayerCastSkill(skillnum); } } if (e.KeyCode == Keys.NumPad3) { skillnum = C_Types.Player[C_Variables.Myindex].Hotbar[3].Slot; if (skillnum != 0) { C_Player.PlayerCastSkill(skillnum); } } if (e.KeyCode == Keys.NumPad4) { skillnum = C_Types.Player[C_Variables.Myindex].Hotbar[4].Slot; if (skillnum != 0) { C_Player.PlayerCastSkill(skillnum); } } if (e.KeyCode == Keys.NumPad5) { skillnum = C_Types.Player[C_Variables.Myindex].Hotbar[5].Slot; if (skillnum != 0) { C_Player.PlayerCastSkill(skillnum); } } if (e.KeyCode == Keys.NumPad6) { skillnum = C_Types.Player[C_Variables.Myindex].Hotbar[6].Slot; if (skillnum != 0) { C_Player.PlayerCastSkill(skillnum); } } if (e.KeyCode == Keys.NumPad7) { skillnum = C_Types.Player[C_Variables.Myindex].Hotbar[7].Slot; if (skillnum != 0) { C_Player.PlayerCastSkill(skillnum); } } //admin if (e.KeyCode == Keys.Insert) { if (C_Types.Player[C_Variables.Myindex].Access > 0) { C_NetworkSend.SendRequestAdmin(); } } //hide gui if (e.KeyCode == Keys.F10) { C_Variables.HideGui = !C_Variables.HideGui; } //lets check for keys for inventory etc if (!ChatModule.ChatInput.Active) { //inventory if (e.KeyCode == Keys.I) { C_UpdateUI.PnlInventoryVisible = !C_UpdateUI.PnlInventoryVisible; } //Character window if (e.KeyCode == Keys.C) { C_UpdateUI.PnlCharacterVisible = !C_UpdateUI.PnlCharacterVisible; } //quest window if (e.KeyCode == Keys.Q) { C_Quest.PnlQuestLogVisible = !C_Quest.PnlQuestLogVisible; } //options window if (e.KeyCode == Keys.O) { FrmOptions.Default.Visible = !FrmOptions.Default.Visible; } //skill window if (e.KeyCode == Keys.K) { C_UpdateUI.PnlSkillsVisible = !C_UpdateUI.PnlSkillsVisible; } } }
// //////////////////////// // // Visual Interaction // // //////////////////////// internal static void LoadQuestlogBox() { int questNum = 0; int curTask = 0; int I = 0; if (SelectedQuest == 0) { return; } for (I = 1; I <= MaxQuests; I++) { if (QuestNames[SelectedQuest].Trim() == Quest[I].Name.Trim()) { questNum = I; } } if (questNum == 0) { return; } curTask = C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].ActualTask; if (curTask >= Quest[questNum].Task.Length) { return; } //Quest Log (Main Task) QuestTaskLogText = Quest[questNum].QuestLog.Trim(); //Actual Task QuestTaskLogText = Quest[questNum].Task[curTask].TaskLog.Trim(); //Last dialog if (C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].ActualTask > 1) { if (System.Convert.ToString(Quest[questNum].Task[curTask - 1].Speech).Trim().Length > 0) { QuestDialogText = System.Convert.ToString(System.Convert.ToString(Quest[questNum].Task[curTask - 1].Speech).Trim().Replace("$playername$", C_Player.GetPlayerName(C_Variables.Myindex))); } else { QuestDialogText = System.Convert.ToString(Quest[questNum].Chat[1].Replace("$playername$", C_Player.GetPlayerName(C_Variables.Myindex))).Trim(); } } else { QuestDialogText = System.Convert.ToString(Quest[questNum].Chat[1].Replace("$playername$", C_Player.GetPlayerName(C_Variables.Myindex))).Trim(); } //Quest Status if (C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].Status == (int)Enums.QuestStatusType.Started) { QuestStatus2Text = Strings.Get("quests", "queststarted"); AbandonQuestText = Strings.Get("quests", "questcancel"); AbandonQuestVisible = true; } else if (C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].Status == (int)Enums.QuestStatusType.Completed) { QuestStatus2Text = Strings.Get("quests", "questcomplete"); AbandonQuestVisible = false; } else { QuestStatus2Text = "???"; AbandonQuestVisible = false; } switch (Quest[questNum].Task[curTask].TaskType) { //defeat x amount of Npc case (int)Enums.QuestType.Slay: int curCount_1 = C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].CurrentCount; int maxAmount_1 = Quest[questNum].Task[curTask].Amount; string npcName_1 = Types.Npc[Quest[questNum].Task[curTask].Npc].Name; ActualTaskText = Strings.Get("quests", "questgoslay", curCount_1, maxAmount_1, npcName_1); //"Defeat " & CurCount & "/" & MaxAmount & " " & NpcName break; //gather x amount of items case (int)Enums.QuestType.Collect: int curCount_2 = C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].CurrentCount; int maxAmount_2 = Quest[questNum].Task[curTask].Amount; string itemName_1 = Types.Item[Quest[questNum].Task[curTask].Item].Name; ActualTaskText = Strings.Get("quests", "questgocollect", curCount_2, maxAmount_2, itemName_1); //"Collect " & CurCount & "/" & MaxAmount & " " & ItemName break; //go talk to npc case (int)Enums.QuestType.Talk: string npcName_2 = Types.Npc[Quest[questNum].Task[curTask].Npc].Name; ActualTaskText = Strings.Get("quests", "questtalkto", npcName_2); //"Go talk to " & NpcName break; //reach certain map case (int)Enums.QuestType.Reach: string mapName = C_Types.MapNames[Quest[questNum].Task[curTask].Map]; ActualTaskText = Strings.Get("quests", "questgoto", mapName); //"Go to " & MapName break; case (int)Enums.QuestType.Give: //give x amount of items to npc string npcName_3 = Types.Npc[Quest[questNum].Task[curTask].Npc].Name; int curCount_3 = C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].CurrentCount; int maxAmount_3 = Quest[questNum].Task[curTask].Amount; string itemName_2 = Types.Item[Quest[questNum].Task[curTask].Item].Name; ActualTaskText = Strings.Get("quests", "questgive", npcName_3, itemName_2, curCount_3, maxAmount_3); //"Give " & NpcName & " the " & ItemName & CurCount & "/" & MaxAmount & " they requested" break; //defeat certain amount of players case (int)Enums.QuestType.Kill: int curCount_4 = C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].CurrentCount; int maxAmount_4 = Quest[questNum].Task[curTask].Amount; ActualTaskText = Strings.Get("quests", "questkill", curCount_4, maxAmount_4); //"Defeat " & CurCount & "/" & MaxAmount & " Players in Battle" break; //go collect resources case (int)Enums.QuestType.Gather: int curCount = C_Types.Player[C_Variables.Myindex].PlayerQuest[questNum].CurrentCount; int maxAmount_5 = Quest[questNum].Task[curTask].Amount; string resourceName = Types.Resource[Quest[questNum].Task[curTask].Resource].Name; ActualTaskText = Strings.Get("quests", "questgather", curCount, maxAmount_5, resourceName); //"Gather " & CurCount & "/" & MaxAmount & " " & ResourceName break; //fetch x amount of items from npc case (int)Enums.QuestType.Fetch: string npcName = Types.Item[Quest[questNum].Task[curTask].Npc].Name; int maxAmount = Quest[questNum].Task[curTask].Amount; string itemName = Types.Item[Quest[questNum].Task[curTask].Item].Name; ActualTaskText = Strings.Get("quests", "questfetch", itemName, maxAmount, npcName); //"Fetch " & ItemName & "X" & MaxAmount & " from " & NpcName break; default: //ToDo ActualTaskText = "errr..."; break; } //Rewards QuestRewardsText = new string[Quest[questNum].RewardCount + 1 + 1]; for (I = 1; I <= Quest[questNum].RewardCount; I++) { QuestRewardsText[I] = Types.Item[Quest[questNum].RewardItem[I]].Name + " X" + Conversion.Str(Quest[questNum].RewardItemAmount[I]); } QuestRewardsText[I] = Conversion.Str(Quest[questNum].RewardExp) + " EXP"; }
internal static void DrawChatBubble(int index) { List <string> theArray = default(List <string>); int x = 0; int y = 0; int i = 0; int maxWidth = 0; int x2 = 0; int y2 = 0; if (C_Variables.ChatBubble[index].TargetType == (byte)Enums.TargetType.Player) { // it's a player if (C_Player.GetPlayerMap((C_Variables.ChatBubble[index].Target)) == C_Player.GetPlayerMap(C_Variables.Myindex)) { // it's on our map - get co-ords x = C_Graphics.ConvertMapX((C_Types.Player[C_Variables.ChatBubble[index].Target].X * 32) + C_Types.Player[C_Variables.ChatBubble[index].Target].XOffset) + 16; y = C_Graphics.ConvertMapY((C_Types.Player[C_Variables.ChatBubble[index].Target].Y * 32) + C_Types.Player[C_Variables.ChatBubble[index].Target].YOffset) - 40; } } else if (C_Variables.ChatBubble[index].TargetType == (byte)Enums.TargetType.Npc) { // it's on our map - get co-ords x = C_Graphics.ConvertMapX((C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].X * 32) + C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].XOffset) + 16; y = C_Graphics.ConvertMapY((C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].Y * 32) + C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].YOffset) - 40; } else if (C_Variables.ChatBubble[index].TargetType == (byte)Enums.TargetType.Event) { x = C_Graphics.ConvertMapX((C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].X * 32) + C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].XOffset) + 16; y = C_Graphics.ConvertMapY((C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].Y * 32) + C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].YOffset) - 40; } // word wrap the text theArray = WordWrap(System.Convert.ToString(C_Variables.ChatBubble[index].Msg), C_Constants.ChatBubbleWidth, WrapMode.Font, WrapType.Smart, 13); // find max width for (i = 0; i <= theArray.Count - 1; i++) { if (GetTextWidth(theArray[i]) > maxWidth) { maxWidth = GetTextWidth(theArray[i]); } } // calculate the new position x2 = x - (maxWidth / 2); y2 = y - (theArray.Count * 12); // render bubble - top left C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 - 9, y2 - 5, 0, 0, 9, 5, 9, 5); // top right C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + maxWidth, y2 - 5, 119, 0, 9, 5, 9, 5); // top C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2, y2 - 5, 10, 0, maxWidth, 5, 5, 5); // bottom left C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 - 9, y, 0, 19, 9, 6, 9, 6); // bottom right C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + maxWidth, y, 119, 19, 9, 6, 9, 6); // bottom - left half C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2, y, 10, 19, System.Convert.ToSingle((maxWidth / 2) - 5), 6, 9, 6); // bottom - right half C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + (maxWidth / 2) + 6, y, 10, 19, System.Convert.ToSingle((maxWidth / 2) - 5), 6, 9, 6); // left C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 - 9, y2, 0, 6, 9, theArray.Count * 12, 9, 1); // right C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + maxWidth, y2, 119, 6, 9, theArray.Count * 12, 9, 1); // center C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2, y2, 9, 5, maxWidth, theArray.Count * 12, 1, 1); // little pointy bit C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x - 5, y, 58, 19, 11, 11, 11, 11); // render each line centralised for (i = 0; i <= theArray.Count - 1; i++) { DrawText((int)(x - ((double)GetTextWidth(theArray[i]) / 2)), y2, theArray[i], C_Graphics.ToSfmlColor(System.Drawing.ColorTranslator.FromOle(Information.QBColor((int)(C_Variables.ChatBubble[index].Colour)))), Color.Black, C_Graphics.GameWindow); y2 = y2 + 12; } // check if it's timed out - close it if so if (C_Variables.ChatBubble[index].Timer + 5000 < C_General.GetTickCount()) { C_Variables.ChatBubble[index].Active = false; } }