diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json
index a1d173c..55b13ef 100644
--- a/DataCollection/gamedata.json
+++ b/DataCollection/gamedata.json
@@ -10,9 +10,14 @@
"drawing_notice":"Drawing not sent to other players when you are not a subscriber.",
"click_nothing_message":"Nothing interesting here...",
"playtime_timeout":"You have run out of playtime for now. In one minute you will be disconnected. You gain one minute of playtime every 8 minutes. Please come back later!",
- "competition_gear":{
+ "random_movement":"You are sooo %STAT%. You wander dizzily in a different direction.",
+ "equips":{
"removed_competition_gear":"You removed selected competition gear.",
- "equip_competition_gear_format":"The %ITEM% are now selected as competition gear."
+ "removed_jewelry":"You removed selected jewelry.",
+ "equip_competition_gear_format":"The %ITEM% are now selected as competition gear.",
+ "max_jewelry":"Only 4 pieces of jewelry can be worn at one time.",
+ "equip_jewelry":"You are now wearing %ITEM%."
+
},
"sec_code":{
"invalid_sec_code":"Data Code Error. You did not get the bonus. You should reconnect if you get this message again.",
@@ -55,7 +60,7 @@
"commands":{
"mute_help":"Mute Channel Not Recognized. (ALL/ADS/GLOBAL/ISLAND/NEAR/HERE/BUDDY/PM/BR/SOCIALS/LOGINS)",
"player_command_completed":"PLAYER COMMAND [%COMMAND%] COMPLETED",
- "admin_command_completed":"COMMAND [%COMMAND%]:"
+ "admin_command_completed":"COMMAND [%COMMAND%]:",
},
"disconnect":{
"banned":"Your account has been BANNED. You will no longer be able to login",
@@ -109,20 +114,26 @@
"legs_format":"^R1^I%ICON%^T7%ITEM% on your legs.^B4X3",
"feet_format":"^R1^I%ICON%^T7%ITEM% on your feet.^B4X4"
},
+ "jewelry":{
+ "slot_1":"^I%ICON%^T7%ITEM%^B4X5^R1",
+ "slot_2":"^I%ICON%^T7%ITEM%^B4X6^R1",
+ "slot_3":"^I%ICON%^T7%ITEM%^B4X7^R1",
+ "slot_4":"^I%ICON%^T7%ITEM%^B4X8^R1"
+ },
+ "hunger_stat_name":"hungry",
+ "thirst_stat_name":"thirsty",
+ "tired_stat_name":"tired",
+ "player_stats":[
+ "not at all %STAT%","a tiny bit %STAT%","a little bit %STAT%",
+ "kind of %STAT","%STAT%","really %STAT%","seriously %STAT%",
+ "desperately %STAT%","incredibly %STAT%","unbearably %STAT%"
+ ],
"msg":{
"no_jewelry_equipped":"You have no Jewelry on.",
"no_competition_gear":"^LYou have nothing interesting for special competition gear.",
"competition_gear_selected":"^LYou have the following selected for competition gear:",
+ "jewelry_selected":"You have the following lovely jewelry on:",
- "incredibly":"incredibly %STAT%",
- "desprately":"desperately %STAT%",
- "seriously":"seriously %STAT%",
- "really":"really %STAT%",
- "normal":"%STAT%",
- "kind_of":"kind of %STAT",
- "little_bit":"a little bit %STAT%",
- "tiny_bit":"a tiny bit %STAT%",
- "not_at_all":"not at all %STAT%"
},
},
"shop":{
@@ -301,6 +312,7 @@
"for_sender":{
"here_format":"%USERNAME%: %MESSAGE% (%AMOUNT% here)",
"isle_format":"%USERNAME%: %MESSAGE% [%AMOUNT% on isle]",
+ "ads_format":"%USERNAME: %MESSAGE% [%AMOUNT% listening]",
"near_format":"%USERNAME%: %MESSAGE% [%AMOUNT% near]",
"mod_format":"%USERNAME%: %MESSAGE% [%AMOUNT% mods]",
"admin_format":"%USERNAME%: %MESSAGE% [%AMOUNT% admins]",
diff --git a/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs b/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs
index 476a10a..0303edf 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs
@@ -55,9 +55,9 @@ namespace HISP.Game.Chat
if (message[0] == '%')
{
if(message.StartsWith("%STICKBUG"))
- {
return Command.Stickbug(message, args, user);
- }
+ if (message.StartsWith("%GIVE"))
+ return Command.Give(message, args, user); ;
return false;
}
if (message[0] == '!')
diff --git a/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs b/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs
index a9dedc9..e41dafe 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs
@@ -1,5 +1,6 @@
using HISP.Player;
using HISP.Server;
+using System;
using System.Collections.Generic;
namespace HISP.Game.Chat
@@ -7,6 +8,46 @@ namespace HISP.Game.Chat
class Command
{
+ public static bool Give(string message, string[] args, User user)
+ {
+ if (args.Length <= 0)
+ return false;
+ if (!user.Administrator)
+ return false;
+ if(args[0] == "OBJECT")
+ {
+ int itemId = 0;
+ try
+ {
+ itemId = int.Parse(args[1]);
+ Item.GetItemById(itemId);
+ ItemInstance newItemInstance = new ItemInstance(itemId);
+ user.Inventory.AddIgnoringFull(newItemInstance);
+
+ }
+ catch(Exception)
+ {
+ return false;
+ }
+ }
+ if (args[0] == "MONEY")
+ {
+ int money = 0;
+ try
+ {
+ money = int.Parse(args[1]);
+ user.Money += money;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+
+ byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
+ user.LoggedinClient.SendPacket(chatPacket);
+ return true;
+ }
public static bool Stickbug(string message, string[] args, User user)
{
if (args.Length <= 0)
diff --git a/Horse Isle Server/Horse Isle Server/Game/GameExceptions.cs b/Horse Isle Server/Horse Isle Server/Game/GameExceptions.cs
index e1c653d..fec4c98 100644
--- a/Horse Isle Server/Horse Isle Server/Game/GameExceptions.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/GameExceptions.cs
@@ -1,8 +1,5 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+
namespace HISP.Game
{
diff --git a/Horse Isle Server/Horse Isle Server/Game/Messages.cs b/Horse Isle Server/Horse Isle Server/Game/Messages.cs
index a4b2e2a..4f38e45 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Messages.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Messages.cs
@@ -7,6 +7,8 @@ namespace HISP.Game
public static int RequiredChatViolations;
public static int DefaultInventoryMax;
+
+
// Tools
public static string BinocularsNothing;
public static string MagnifyNothing;
@@ -28,6 +30,11 @@ namespace HISP.Game
public static string StatsJewelFormat;
public static string StatsCompetitionGearFormat;
+ public static string JewelrySlot1Format;
+ public static string JewelrySlot2Format;
+ public static string JewelrySlot3Format;
+ public static string JewelrySlot4Format;
+
public static string CompetitionGearHeadFormat;
public static string CompetitionGearBodyFormat;
public static string CompetitionGearLegsFormat;
@@ -41,8 +48,15 @@ namespace HISP.Game
public static string NoJewerlyEquipped;
public static string NoCompetitionGear;
+ public static string JewelrySelected;
public static string CompetitionGearSelected;
+ public static string StatHunger;
+ public static string StatThirst;
+ public static string StatTired;
+
+ public static string[] StatPlayerFormats;
+
// Announcements
public static string NewUserMessage;
public static string WelcomeFormat;
@@ -87,6 +101,7 @@ namespace HISP.Game
public static string ChatViolationMessageFormat;
public static string PasswordNotice;
public static string CapsNotice;
+ public static string RandomMovement;
// Transport
@@ -109,8 +124,13 @@ namespace HISP.Game
// Competition Gear
- public static string EquipItemFormat;
- public static string UnequipItem;
+ public static string EquipCompetitionGearFormat;
+ public static string RemoveCompetitionGear;
+
+ // Jewelry
+ public static string EquipJewelryFormat;
+ public static string MaxJewelryMessage;
+ public static string RemoveJewelry;
// Inventory
public static string InventoryItemFormat;
@@ -182,9 +202,10 @@ namespace HISP.Game
public static string MetaTerminator;
// Disconnect Messages
- public static string BanMessage;
- public static string DuplicateLogin;
- public static string IdleKickMessageFormat;
+ public static string KickReasonBanned;
+ public static string KickReasonDuplicateLogin;
+ public static string KickReasonIdleFormat;
+ public static string KickReasonNoTime;
// Swf
public static string BoatCutscene;
@@ -194,6 +215,41 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
+ public static string FormatRandomMovementMessage(string statName)
+ {
+ return RandomMovement.Replace("%STAT%", statName);
+ }
+
+ public static string FormatJewerlyEquipMessage(string itemName)
+ {
+ return EquipJewelryFormat.Replace("%ITEM%", itemName);
+ }
+ public static string FormatEquipCompetitionGearMessage(string name)
+ {
+ return EquipCompetitionGearFormat.Replace("%ITEM%", name);
+ }
+
+ public static string FormatPlayerStat(string statFormat, string statName)
+ {
+ return statFormat.Replace("%STAT%", statName);
+ }
+ public static string FormatJewelrySlot1(string itemName, int icon)
+ {
+ return JewelrySlot1Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
+ }
+ public static string FormatJewelrySlot2(string itemName, int icon)
+ {
+ return JewelrySlot2Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
+ }
+ public static string FormatJewelrySlot3(string itemName, int icon)
+ {
+ return JewelrySlot3Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
+ }
+ public static string FormatJewelrySlot4(string itemName, int icon)
+ {
+ return JewelrySlot4Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
+ }
+
public static string FormatCompetitionGearHead(string itemName, int icon)
{
return CompetitionGearHeadFormat.Replace("%ITEM%", itemName).Replace("%ICON%",icon.ToString());
@@ -273,10 +329,6 @@ namespace HISP.Game
return PlayerCommandFormat.Replace("%COMMAND%", command);
}
- public static string FormatEquipItemMessage(string name)
- {
- return EquipItemFormat.Replace("%ITEM%", name);
- }
public static string FormatYouEarnedAnItemMessage(string itemName)
{
return YouEarnedAnItemFormat.Replace("%ITEM%", itemName);
@@ -552,7 +604,7 @@ namespace HISP.Game
// Disconnect
public static string FormatIdleKickMessage()
{
- return IdleKickMessageFormat.Replace("%KICK%", GameServer.IdleTimeout.ToString());
+ return KickReasonIdleFormat.Replace("%KICK%", GameServer.IdleTimeout.ToString());
}
}
diff --git a/Horse Isle Server/Horse Isle Server/Game/Meta.cs b/Horse Isle Server/Horse Isle Server/Game/Meta.cs
index 5277593..d35d894 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Meta.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Meta.cs
@@ -1,5 +1,6 @@
using HISP.Player;
using HISP.Server;
+using System;
namespace HISP.Game
{
@@ -160,7 +161,43 @@ namespace HISP.Game
return message;
}
- public static string buildNpc(User user, int x, int y)
+ private static string buildWornJewelery(User user)
+ {
+ string message = Messages.JewelrySelected;
+ if (user.EquipedJewelry.Slot1 != null)
+ message += Messages.FormatJewelrySlot1(user.EquipedJewelry.Slot1.Name, user.EquipedJewelry.Slot1.IconId);
+ if (user.EquipedJewelry.Slot2 != null)
+ message += Messages.FormatJewelrySlot2(user.EquipedJewelry.Slot2.Name, user.EquipedJewelry.Slot2.IconId);
+ if (user.EquipedJewelry.Slot3 != null)
+ message += Messages.FormatJewelrySlot3(user.EquipedJewelry.Slot3.Name, user.EquipedJewelry.Slot3.IconId);
+ if (user.EquipedJewelry.Slot4 != null)
+ message += Messages.FormatJewelrySlot4(user.EquipedJewelry.Slot4.Name, user.EquipedJewelry.Slot4.IconId);
+
+ if (message == Messages.JewelrySelected)
+ message = Messages.NoJewerlyEquipped;
+
+ return message;
+ }
+ private static string buildEquippedCompetitionGear(User user)
+ {
+ string message = Messages.CompetitionGearSelected;
+ if (user.EquipedCompetitionGear.Head != null)
+ message += Messages.FormatCompetitionGearHead(user.EquipedCompetitionGear.Head.Name, user.EquipedCompetitionGear.Head.IconId);
+ if (user.EquipedCompetitionGear.Body != null)
+ message += Messages.FormatCompetitionGearBody(user.EquipedCompetitionGear.Body.Name, user.EquipedCompetitionGear.Body.IconId);
+ if (user.EquipedCompetitionGear.Legs != null)
+ message += Messages.FormatCompetitionGearLegs(user.EquipedCompetitionGear.Legs.Name, user.EquipedCompetitionGear.Legs.IconId);
+ if (user.EquipedCompetitionGear.Feet != null)
+ message += Messages.FormatCompetitionGearFeet(user.EquipedCompetitionGear.Feet.Name, user.EquipedCompetitionGear.Feet.IconId);
+
+ if (message == Messages.CompetitionGearSelected)
+ message = Messages.NoCompetitionGear;
+
+ return message;
+
+ }
+
+ private static string buildNpc(User user, int x, int y)
{
string message = "";
Npc.NpcEntry[] entries = Npc.GetNpcByXAndY(x, y);
@@ -187,6 +224,22 @@ namespace HISP.Game
}
return message;
}
+
+
+ public static string EvenUserStatDistribution(int statValue)
+ {
+ int curValue = 1000;
+ int devisibleBy = Convert.ToInt32(Math.Floor((decimal)curValue / Messages.StatPlayerFormats.Length));
+
+ for (int i = 0; i < Messages.StatPlayerFormats.Length; i++)
+ {
+ curValue -= devisibleBy;
+ if (statValue >= curValue)
+ return Messages.StatPlayerFormats[i];
+
+ }
+ throw new Exception("A mathematically impossible error occured. please check wether the laws of physics still apply.");
+ }
public static string BuildNpcInfo(Npc.NpcEntry npcInfo)
{
string message = "";
@@ -217,28 +270,6 @@ namespace HISP.Game
}
return message;
}
- public static string BuildWornJewelery(User user)
- {
- return Messages.NoJewerlyEquipped;
- }
- public static string BuildEquippedCompetitionGear(User user)
- {
- string message = Messages.CompetitionGearSelected;
- if (user.EquipedCompetitionGear.Head != null)
- message += Messages.FormatCompetitionGearHead(user.EquipedCompetitionGear.Head.Name, user.EquipedCompetitionGear.Head.IconId);
- if (user.EquipedCompetitionGear.Body != null)
- message += Messages.FormatCompetitionGearBody(user.EquipedCompetitionGear.Body.Name, user.EquipedCompetitionGear.Body.IconId);
- if (user.EquipedCompetitionGear.Legs != null)
- message += Messages.FormatCompetitionGearLegs(user.EquipedCompetitionGear.Legs.Name, user.EquipedCompetitionGear.Legs.IconId);
- if (user.EquipedCompetitionGear.Feet != null)
- message += Messages.FormatCompetitionGearFeet(user.EquipedCompetitionGear.Feet.Name, user.EquipedCompetitionGear.Feet.IconId);
-
- if (message == Messages.CompetitionGearSelected)
- message = Messages.NoCompetitionGear;
-
- return message;
-
- }
public static string BuildStatsMenu(User user)
{
string message = Messages.FormatStatsBar(user.Username);
@@ -251,12 +282,12 @@ namespace HISP.Game
message += Messages.FormatFreeTime(user.FreeMinutes);
message += Messages.FormatPlayerDescriptionForStatsMenu(user.ProfilePage);
message += Messages.FormatExperience(user.Experience);
- message += Messages.FormatHungryStat("Not implemented yet :3");
- message += Messages.FormatThirstStat("Not implemented yet :3");
- message += Messages.FormatTiredStat("Not implemented yet :3");
+ message += Messages.FormatHungryStat(Messages.FormatPlayerStat(EvenUserStatDistribution(user.Hunger), Messages.StatHunger));
+ message += Messages.FormatThirstStat(Messages.FormatPlayerStat(EvenUserStatDistribution(user.Thirst), Messages.StatThirst));
+ message += Messages.FormatTiredStat(Messages.FormatPlayerStat(EvenUserStatDistribution(user.Thirst), Messages.StatTired));
message += Messages.FormatGenderStat(user.Gender);
- message += Messages.FormatJewelryStat(BuildWornJewelery(user));
- message += Messages.FormatCompetitionGearStat(BuildEquippedCompetitionGear(user));
+ message += Messages.FormatJewelryStat(buildWornJewelery(user));
+ message += Messages.FormatCompetitionGearStat(buildEquippedCompetitionGear(user));
message += Messages.StatsPrivateNotes;
message += Messages.StatsQuests;
message += Messages.StatsMinigameRanking;
@@ -346,11 +377,13 @@ namespace HISP.Game
message += Messages.FormatPlayerInventoryItemMeta(itemInfo.IconId, item.ItemInstances.Count, title);
int randomId = item.ItemInstances[0].RandomId;
+ if (itemInfo.Type != "QUEST" && itemInfo.Type != "TEXT" && World.CanDropItems(inv.BaseUser.X, inv.BaseUser.Y))
+ message += Messages.FormatItemDropButton(randomId);
if (itemInfo.Id == Item.Present || itemInfo.Id == Item.DorothyShoes || itemInfo.Id == Item.Telescope)
message += Messages.FormatItemUseButton(randomId);
- if (itemInfo.Type == "CLOTHES")
+ if (itemInfo.Type == "CLOTHES" || itemInfo.Type == "JEWELRY")
message += Messages.FormatWearButton(randomId);
if (itemInfo.Type == "TEXT")
@@ -362,8 +395,6 @@ namespace HISP.Game
if (Item.IsThrowable(itemInfo.Id))
message += Messages.FormatItemThrowButton(randomId);
- if (itemInfo.Type != "QUEST" && itemInfo.Type != "TEXT" && World.CanDropItems(inv.BaseUser.X, inv.BaseUser.Y))
- message += Messages.FormatItemDropButton(randomId);
message += Messages.FormatItemInformationButton(randomId);
message += "^R1";
}
diff --git a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj
index 079f104..9578b19 100644
--- a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj
+++ b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj
@@ -78,7 +78,8 @@
-
+
+
True
True
diff --git a/Horse Isle Server/Horse Isle Server/Player/CompetitionGear.cs b/Horse Isle Server/Horse Isle Server/Player/Equips/CompetitionGear.cs
similarity index 95%
rename from Horse Isle Server/Horse Isle Server/Player/CompetitionGear.cs
rename to Horse Isle Server/Horse Isle Server/Player/Equips/CompetitionGear.cs
index 5665268..26fbc41 100644
--- a/Horse Isle Server/Horse Isle Server/Player/CompetitionGear.cs
+++ b/Horse Isle Server/Horse Isle Server/Player/Equips/CompetitionGear.cs
@@ -1,12 +1,7 @@
using HISP.Game;
using HISP.Server;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-namespace HISP.Player
+namespace HISP.Player.Equips
{
class CompetitionGear
{
diff --git a/Horse Isle Server/Horse Isle Server/Player/Equips/Jewelry.cs b/Horse Isle Server/Horse Isle Server/Player/Equips/Jewelry.cs
new file mode 100644
index 0000000..4bf1887
--- /dev/null
+++ b/Horse Isle Server/Horse Isle Server/Player/Equips/Jewelry.cs
@@ -0,0 +1,112 @@
+using HISP.Game;
+using HISP.Server;
+
+namespace HISP.Player.Equips
+{
+ class Jewelry
+ {
+
+ private int playerId;
+ public Jewelry(int PlayerId)
+ {
+ playerId = PlayerId;
+ if (!Database.HasJewelry(PlayerId))
+ Database.InitJewelry(PlayerId);
+ int itemId = Database.GetJewelrySlot1(PlayerId);
+ if (itemId != 0)
+ slot1 = Item.GetItemById(itemId);
+
+ itemId = Database.GetJewelrySlot2(PlayerId);
+ if (itemId != 0)
+ slot2 = Item.GetItemById(itemId);
+
+ itemId = Database.GetJewelrySlot3(PlayerId);
+ if (itemId != 0)
+ slot3 = Item.GetItemById(itemId);
+
+ itemId = Database.GetJewelrySlot4(PlayerId);
+ if (itemId != 0)
+ slot4 = Item.GetItemById(itemId);
+
+ }
+ public Item.ItemInformation Slot1
+ {
+ get
+ {
+ return slot1;
+ }
+ set
+ {
+ if (value == null)
+ {
+ slot1 = null;
+ Database.SetJewelrySlot1(playerId, 0);
+ return;
+ }
+ Database.SetJewelrySlot1(playerId, value.Id);
+ slot1 = value;
+ }
+ }
+ public Item.ItemInformation Slot2
+ {
+ get
+ {
+ return slot2;
+ }
+ set
+ {
+ if (value == null)
+ {
+ slot2 = null;
+ Database.SetJewelrySlot2(playerId, 0);
+ return;
+ }
+ Database.SetJewelrySlot2(playerId, value.Id);
+ slot2 = value;
+ }
+ }
+ public Item.ItemInformation Slot3
+ {
+ get
+ {
+ return slot3;
+ }
+ set
+ {
+ if (value == null)
+ {
+ slot3 = null;
+ Database.SetJewelrySlot3(playerId, 0);
+ return;
+ }
+ Database.SetJewelrySlot3(playerId, value.Id);
+ slot3 = value;
+ }
+ }
+ public Item.ItemInformation Slot4
+ {
+ get
+ {
+ return slot4;
+ }
+ set
+ {
+ if (value == null)
+ {
+ slot4 = null;
+ Database.SetJewelrySlot4(playerId, 0);
+ return;
+ }
+ Database.SetJewelrySlot4(playerId, value.Id);
+ slot4 = value;
+ }
+ }
+
+
+ private Item.ItemInformation slot1;
+ private Item.ItemInformation slot2;
+ private Item.ItemInformation slot3;
+ private Item.ItemInformation slot4;
+
+ }
+}
diff --git a/Horse Isle Server/Horse Isle Server/Player/User.cs b/Horse Isle Server/Horse Isle Server/Player/User.cs
index a3dd432..991e22f 100644
--- a/Horse Isle Server/Horse Isle Server/Player/User.cs
+++ b/Horse Isle Server/Horse Isle Server/Player/User.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using HISP.Game;
using HISP.Server;
+using HISP.Player.Equips;
+
namespace HISP.Player
{
class User
@@ -14,6 +16,7 @@ namespace HISP.Player
public bool NewPlayer = false;
public GameClient LoggedinClient;
public CompetitionGear EquipedCompetitionGear;
+ public Jewelry EquipedJewelry;
public bool MuteAds = false;
public bool MuteGlobal = false;
public bool MuteIsland = false;
@@ -40,12 +43,17 @@ namespace HISP.Player
{
get
{
- return freeMinutes;
+ int freeTime = Database.GetFreeTime(Id);
+ if(freeTime > 360)
+ {
+ Database.SetFreeTime(Id, 360);
+ return 360;
+ }
+ return freeTime;
}
set
{
Database.SetFreeTime(Id, value);
- freeMinutes = value;
}
}
public bool Subscribed
@@ -98,6 +106,7 @@ namespace HISP.Player
chatViolations = value;
}
}
+
public string ProfilePage {
get
{
@@ -105,6 +114,7 @@ namespace HISP.Player
}
set
{
+
Database.SetPlayerProfile(value, Id);
profilePage = value;
}
@@ -149,7 +159,7 @@ namespace HISP.Player
}
}
- public int BankMoney
+ public UInt64 BankMoney
{
get
{
@@ -201,6 +211,59 @@ namespace HISP.Player
}
}
+
+ public int Hunger
+ {
+ get
+ {
+ return hunger;
+ }
+ set
+ {
+ if (value >= 1000)
+ value = 1000;
+ if (value <= 0)
+ value = 0;
+ Database.SetPlayerHunger(Id, value);
+ hunger = value;
+ }
+ }
+
+ public int Thirst
+ {
+ get
+ {
+ return thirst;
+ }
+ set
+ {
+ if (value >= 1000)
+ value = 1000;
+ if (value <= 0)
+ value = 0;
+ Database.SetPlayerHunger(Id, value);
+ thirst = value;
+ }
+ }
+
+ public int Tiredness
+ {
+ get
+ {
+ return tired;
+ }
+ set
+ {
+ if (value >= 1000)
+ value = 1000;
+ if (value <= 0)
+ value = 0;
+ Database.SetPlayerTiredness(Id, value);
+ tired = value;
+ }
+ }
+
+
private int chatViolations;
private int charId;
private int subscribedUntil;
@@ -210,10 +273,13 @@ namespace HISP.Player
private bool stealth = false;
private int y;
private int money;
- private int freeMinutes;
private int questPoints;
- private int bankMoney;
- private int experience;
+ private UInt64 bankMoney;
+ private int experience;
+ private int hunger;
+ private int thirst;
+ private int tired;
+
public byte[] SecCodeSeeds = new byte[3];
public int SecCodeInc = 0;
@@ -230,6 +296,7 @@ namespace HISP.Player
LoggedinClient.SendPacket(MovementPacket);
GameServer.Update(LoggedinClient);
}
+
public byte[] GenerateSecCode()
{
var i = 0;
@@ -249,6 +316,7 @@ namespace HISP.Player
return SecCode;
}
+
public User(GameClient baseClient, int UserId)
{
if (!Database.CheckUserExist(UserId))
@@ -262,6 +330,7 @@ namespace HISP.Player
EquipedCompetitionGear = new CompetitionGear(UserId);
+ EquipedJewelry = new Jewelry(UserId);
Id = UserId;
Username = Database.GetUsername(UserId);
@@ -275,7 +344,6 @@ namespace HISP.Player
charId = Database.GetPlayerCharId(UserId);
Facing = PacketBuilder.DIRECTION_DOWN;
- freeMinutes = Database.GetFreeTime(UserId);
experience = Database.GetExperience(UserId);
money = Database.GetPlayerMoney(UserId);
bankMoney = Database.GetPlayerBankMoney(UserId);
@@ -283,6 +351,11 @@ namespace HISP.Player
subscribed = Database.IsUserSubscribed(UserId);
subscribedUntil = Database.GetUserSubscriptionExpireDate(UserId);
profilePage = Database.GetPlayerProfile(UserId);
+
+ hunger = Database.GetPlayerHunger(UserId);
+ thirst = Database.GetPlayerThirst(UserId);
+ tired = Database.GetPlayerTiredness(UserId);
+
Gender = Database.GetGender(UserId);
MailBox = new Mailbox(this);
diff --git a/Horse Isle Server/Horse Isle Server/Server/Database.cs b/Horse Isle Server/Horse Isle Server/Server/Database.cs
index 3c71ec8..b4ead3f 100644
--- a/Horse Isle Server/Horse Isle Server/Server/Database.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/Database.cs
@@ -26,6 +26,7 @@ namespace HISP.Server
string TrackedQuest = "CREATE TABLE TrackedQuest(playerId INT, questId INT, timesCompleted INT)";
string OnlineUsers = "CREATE TABLE OnlineUsers(playerId INT, Admin TEXT(3), Moderator TEXT(3), Subscribed TEXT(3))";
string CompetitionGear = "CREATE TABLE CompetitionGear(playerId INT, headItem INT, bodyItem INT, legItem INT, feetItem INT)";
+ string Jewelry = "CREATE TABLE Jewelry(playerId INT, slot1 INT, slot2 INT, slot3 INT, slot4 INT)";
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
@@ -81,6 +82,19 @@ namespace HISP.Server
Logger.WarnPrint(e.Message);
};
+ try
+ {
+
+ MySqlCommand sqlCommand = db.CreateCommand();
+ sqlCommand.CommandText = Jewelry;
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Dispose();
+ }
+ catch (Exception e)
+ {
+ Logger.WarnPrint(e.Message);
+ };
+
try
{
@@ -312,6 +326,168 @@ namespace HISP.Server
}
}
+ public static bool HasJewelry(int playerId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "SELECT COUNT(1) FROM jewelry WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+
+ sqlCommand.Prepare();
+ int timesComplete = Convert.ToInt32(sqlCommand.ExecuteScalar());
+ sqlCommand.Dispose();
+ return timesComplete > 0;
+ }
+ }
+
+ public static void InitJewelry(int playerId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "INSERT INTO jewelry VALUES(@playerId,0,0,0,0)";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Dispose();
+ }
+ }
+
+ public static void SetJewelrySlot1(int playerId, int itemId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "UPDATE jewelry SET slot1=@itemId WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Parameters.AddWithValue("@itemId", itemId);
+
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Dispose();
+ }
+ }
+ public static int GetJewelrySlot1(int playerId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "SELECT slot1 FROM jewelry WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Prepare();
+ int timesComplete = Convert.ToInt32(sqlCommand.ExecuteScalar());
+ sqlCommand.Dispose();
+ return timesComplete;
+ }
+ }
+
+ public static void SetJewelrySlot2(int playerId, int itemId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "UPDATE jewelry SET slot2=@itemId WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Parameters.AddWithValue("@itemId", itemId);
+
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Dispose();
+ }
+ }
+ public static int GetJewelrySlot2(int playerId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "SELECT slot2 FROM jewelry WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Prepare();
+ int timesComplete = Convert.ToInt32(sqlCommand.ExecuteScalar());
+ sqlCommand.Dispose();
+ return timesComplete;
+ }
+ }
+
+
+ public static void SetJewelrySlot3(int playerId, int itemId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "UPDATE jewelry SET slot3=@itemId WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Parameters.AddWithValue("@itemId", itemId);
+
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Dispose();
+ }
+ }
+ public static int GetJewelrySlot3(int playerId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "SELECT slot3 FROM jewelry WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Prepare();
+ int timesComplete = Convert.ToInt32(sqlCommand.ExecuteScalar());
+ sqlCommand.Dispose();
+ return timesComplete;
+ }
+ }
+
+ public static void SetJewelrySlot4(int playerId, int itemId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "UPDATE jewelry SET slot4=@itemId WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Parameters.AddWithValue("@itemId", itemId);
+
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Dispose();
+ }
+ }
+ public static int GetJewelrySlot4(int playerId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "SELECT slot4 FROM jewelry WHERE playerId=@playerId";
+ sqlCommand.Parameters.AddWithValue("@playerId", playerId);
+ sqlCommand.Prepare();
+ int timesComplete = Convert.ToInt32(sqlCommand.ExecuteScalar());
+ sqlCommand.Dispose();
+ return timesComplete;
+ }
+ }
+
public static bool HasCompetitionGear(int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
@@ -630,6 +806,20 @@ namespace HISP.Server
sqlCommand.Dispose();
}
}
+ public static void IncAllUsersFreeTime(int minutes)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ MySqlCommand sqlCommand = db.CreateCommand();
+
+ sqlCommand.CommandText = "UPDATE userExt SET FreeMinutes=FreeMinutes+@minutes";
+ sqlCommand.Parameters.AddWithValue("@minutes", minutes);
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Dispose();
+ }
+ }
public static void SetFreeTime(int playerId, int minutes)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
@@ -1432,6 +1622,148 @@ namespace HISP.Server
}
}
}
+
+
+ public static int GetPlayerTiredness(int userId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ if (CheckUserExtExists(userId))
+ {
+ MySqlCommand sqlCommand = db.CreateCommand();
+ sqlCommand.CommandText = "SELECT Tiredness FROM UserExt WHERE Id=@id";
+ sqlCommand.Parameters.AddWithValue("@id", userId);
+ sqlCommand.Prepare();
+ int tiredness = Convert.ToInt32(sqlCommand.ExecuteScalar());
+
+ sqlCommand.Dispose();
+ return tiredness;
+ }
+ else
+ {
+ throw new KeyNotFoundException("Id " + userId + " not found in database.");
+ }
+ }
+ }
+
+ public static void SetPlayerTiredness(int id, int tiredness)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ if (CheckUserExist(id))
+ {
+ MySqlCommand sqlCommand = db.CreateCommand();
+ sqlCommand.CommandText = "UPDATE UserExt SET Tiredness=@tiredness WHERE Id=@id";
+ sqlCommand.Parameters.AddWithValue("@tiredness", tiredness);
+ sqlCommand.Parameters.AddWithValue("@id", id);
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+
+ sqlCommand.Dispose();
+ }
+ else
+ {
+ throw new KeyNotFoundException("Id " + id + " not found in database.");
+ }
+ }
+ }
+
+ public static void SetPlayerHunger(int id, int hunger)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ if (CheckUserExist(id))
+ {
+ MySqlCommand sqlCommand = db.CreateCommand();
+ sqlCommand.CommandText = "UPDATE UserExt SET Hunger=@hunger WHERE Id=@id";
+ sqlCommand.Parameters.AddWithValue("@Hunger", hunger);
+ sqlCommand.Parameters.AddWithValue("@id", id);
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+
+ sqlCommand.Dispose();
+ }
+ else
+ {
+ throw new KeyNotFoundException("Id " + id + " not found in database.");
+ }
+ }
+ }
+
+
+
+ public static int GetPlayerHunger(int userId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ if (CheckUserExtExists(userId))
+ {
+ MySqlCommand sqlCommand = db.CreateCommand();
+ sqlCommand.CommandText = "SELECT Hunger FROM UserExt WHERE Id=@id";
+ sqlCommand.Parameters.AddWithValue("@id", userId);
+ sqlCommand.Prepare();
+ int hunger = Convert.ToInt32(sqlCommand.ExecuteScalar());
+
+ sqlCommand.Dispose();
+ return hunger;
+ }
+ else
+ {
+ throw new KeyNotFoundException("Id " + userId + " not found in database.");
+ }
+ }
+ }
+
+ public static void SetPlayerThirst(int id, int thirst)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ if (CheckUserExist(id))
+ {
+ MySqlCommand sqlCommand = db.CreateCommand();
+ sqlCommand.CommandText = "UPDATE UserExt SET Thirst=@thirst WHERE Id=@id";
+ sqlCommand.Parameters.AddWithValue("@thirst", thirst);
+ sqlCommand.Parameters.AddWithValue("@id", id);
+ sqlCommand.Prepare();
+ sqlCommand.ExecuteNonQuery();
+
+ sqlCommand.Dispose();
+ }
+ else
+ {
+ throw new KeyNotFoundException("Id " + id + " not found in database.");
+ }
+ }
+ }
+
+ public static int GetPlayerThirst(int userId)
+ {
+ using (MySqlConnection db = new MySqlConnection(ConnectionString))
+ {
+ db.Open();
+ if (CheckUserExtExists(userId))
+ {
+ MySqlCommand sqlCommand = db.CreateCommand();
+ sqlCommand.CommandText = "SELECT Thirst FROM UserExt WHERE Id=@id";
+ sqlCommand.Parameters.AddWithValue("@id", userId);
+ sqlCommand.Prepare();
+ int tiredness = Convert.ToInt32(sqlCommand.ExecuteScalar());
+
+ sqlCommand.Dispose();
+ return tiredness;
+ }
+ else
+ {
+ throw new KeyNotFoundException("Id " + userId + " not found in database.");
+ }
+ }
+ }
+
public static int GetPlayerMoney(int userId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
@@ -1455,7 +1787,7 @@ namespace HISP.Server
}
}
- public static int GetPlayerBankMoney(int userId)
+ public static UInt64 GetPlayerBankMoney(int userId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
@@ -1466,7 +1798,7 @@ namespace HISP.Server
sqlCommand.CommandText = "SELECT BankBalance FROM UserExt WHERE Id=@id";
sqlCommand.Parameters.AddWithValue("@id", userId);
sqlCommand.Prepare();
- int BankMoney = Convert.ToInt32(sqlCommand.ExecuteScalar());
+ UInt64 BankMoney = Convert.ToUInt64(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return BankMoney;
@@ -1478,7 +1810,7 @@ namespace HISP.Server
}
}
- public static void SetPlayerBankMoney(int bankMoney, int id)
+ public static void SetPlayerBankMoney(UInt64 bankMoney, int id)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
diff --git a/Horse Isle Server/Horse Isle Server/Server/GameClient.cs b/Horse Isle Server/Horse Isle Server/Server/GameClient.cs
index 7866800..7d885c7 100644
--- a/Horse Isle Server/Horse Isle Server/Server/GameClient.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/GameClient.cs
@@ -23,15 +23,53 @@ namespace HISP.Server
private Timer warnTimer;
private Timer kickTimer;
+ private Timer minuteTimer;
private int keepAliveInterval = 60 * 1000;
private int updateInterval = 60 * 1000;
+ private int totalMinutesElapsed = 0;
+ private int oneMinute = 60 * 1000;
private int warnInterval = GameServer.IdleWarning * 60 * 1000;
private int kickInterval = GameServer.IdleTimeout * 60 * 1000;
-
+ private void minuteTimerTick(object state)
+ {
+ totalMinutesElapsed++;
+ if (LoggedIn)
+ {
+ LoggedinUser.FreeMinutes -= 1;
+ if (LoggedinUser.FreeMinutes <= 0)
+ {
+ LoggedinUser.FreeMinutes = 0;
+ if (!LoggedinUser.Subscribed && !LoggedinUser.Moderator && !LoggedinUser.Administrator)
+ Kick(Messages.KickReasonNoTime);
+ }
+
+ // unsure of actural timings, would be more or less impossible to know
+ // without the original source code :(
+ // From testing hunger seemed to go down fastest, then thirst, and finally tiredness.
+
+
+ if(totalMinutesElapsed % 1 == 0)
+ {
+ LoggedinUser.Hunger -= 1;
+ }
+
+ if (totalMinutesElapsed % 5 == 0)
+ {
+ LoggedinUser.Thirst -= 1;
+ }
+
+ if (totalMinutesElapsed % 10 == 0)
+ {
+ LoggedinUser.Tiredness -= 1;
+ }
+ }
+
+ minuteTimer.Change(oneMinute, oneMinute);
+ }
private void keepAliveTimerTick(object state)
{
Logger.DebugPrint("Sending keep-alive packet to "+ LoggedinUser.Username);
@@ -67,7 +105,7 @@ namespace HISP.Server
if(Client.LoggedIn)
{
if (Client.LoggedinUser.Id == id)
- Client.Kick(Messages.DuplicateLogin);
+ Client.Kick(Messages.KickReasonDuplicateLogin);
}
}
@@ -247,6 +285,7 @@ namespace HISP.Server
kickTimer = new Timer(new TimerCallback(kickTimerTick), null, kickInterval, kickInterval);
warnTimer = new Timer(new TimerCallback(warnTimerTick), null, warnInterval, warnInterval);
+ minuteTimer = new Timer(new TimerCallback(minuteTimerTick), null, oneMinute, oneMinute);
recvPackets = new Thread(() =>
{
diff --git a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs
index 0eaeb34..3bc2dde 100644
--- a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs
@@ -407,6 +407,11 @@ namespace HISP.Server
Messages.StatsJewelFormat = gameData.messages.meta.stats_page.stats_equipped;
Messages.StatsCompetitionGearFormat = gameData.messages.meta.stats_page.stats_competion_gear;
+ Messages.JewelrySlot1Format = gameData.messages.meta.stats_page.jewelry.slot_1;
+ Messages.JewelrySlot2Format = gameData.messages.meta.stats_page.jewelry.slot_2;
+ Messages.JewelrySlot3Format = gameData.messages.meta.stats_page.jewelry.slot_3;
+ Messages.JewelrySlot4Format = gameData.messages.meta.stats_page.jewelry.slot_4;
+
Messages.CompetitionGearHeadFormat = gameData.messages.meta.stats_page.competition_gear.head_format;
Messages.CompetitionGearBodyFormat = gameData.messages.meta.stats_page.competition_gear.body_format;
Messages.CompetitionGearLegsFormat = gameData.messages.meta.stats_page.competition_gear.legs_format;
@@ -418,11 +423,17 @@ namespace HISP.Server
Messages.StatsAwards = gameData.messages.meta.stats_page.stats_awards;
Messages.StatsMisc = gameData.messages.meta.stats_page.stats_misc;
-
+ Messages.JewelrySelected = gameData.messages.meta.stats_page.msg.jewelry_selected;
Messages.NoJewerlyEquipped = gameData.messages.meta.stats_page.msg.no_jewelry_equipped;
Messages.NoCompetitionGear = gameData.messages.meta.stats_page.msg.no_competition_gear;
Messages.CompetitionGearSelected = gameData.messages.meta.stats_page.msg.competition_gear_selected;
+ Messages.StatHunger = gameData.messages.meta.stats_page.hunger_stat_name;
+ Messages.StatThirst = gameData.messages.meta.stats_page.thirst_stat_name;
+ Messages.StatTired = gameData.messages.meta.stats_page.tired_stat_name;
+
+ Messages.StatPlayerFormats = gameData.messages.meta.stats_page.player_stats.ToObject();
+ Messages.RandomMovement = gameData.messages.random_movement;
// Transport
Messages.CantAffordTransport = gameData.messages.transport.not_enough_money;
@@ -579,10 +590,11 @@ namespace HISP.Server
// Disconnect Reasons
- Messages.BanMessage = gameData.messages.disconnect.banned;
- Messages.IdleKickMessageFormat = gameData.messages.disconnect.client_timeout.kick_message;
+ Messages.KickReasonBanned = gameData.messages.disconnect.banned;
+ Messages.KickReasonIdleFormat = gameData.messages.disconnect.client_timeout.kick_message;
+ Messages.KickReasonNoTime = gameData.messages.disconnect.no_playtime;
Messages.IdleWarningFormat = gameData.messages.disconnect.client_timeout.warn_message;
- Messages.DuplicateLogin = gameData.messages.disconnect.dupe_login;
+ Messages.KickReasonDuplicateLogin = gameData.messages.disconnect.dupe_login;
Chat.PrivateMessageSound = gameData.messages.chat.pm_sound;
@@ -595,8 +607,13 @@ namespace HISP.Server
// Competition Gear
- Messages.EquipItemFormat = gameData.messages.competition_gear.equip_competition_gear_format;
- Messages.UnequipItem = gameData.messages.competition_gear.removed_competition_gear;
+ Messages.EquipCompetitionGearFormat = gameData.messages.equips.equip_competition_gear_format;
+ Messages.RemoveCompetitionGear = gameData.messages.equips.removed_competition_gear;
+
+ // Jewerly
+ Messages.EquipJewelryFormat = gameData.messages.equips.equip_jewelry;
+ Messages.MaxJewelryMessage = gameData.messages.equips.max_jewelry;
+ Messages.RemoveJewelry = gameData.messages.equips.removed_jewelry;
// Click
Messages.NothingInterestingHere = gameData.messages.click_nothing_message;
diff --git a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs
index 5aca983..95799c1 100644
--- a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs
@@ -9,6 +9,7 @@ using HISP.Player;
using HISP.Game;
using HISP.Security;
using HISP.Game.Chat;
+using HISP.Player.Equips;
namespace HISP.Server
{
@@ -33,17 +34,29 @@ namespace HISP.Server
* Private stuff
*/
private static int gameTickSpeed = 4320; // Changing this to ANYTHING else will cause desync with the client.
+ private static int totalMinutesElapsed = 0;
+ private static int oneMinute = 1000 * 60; // Change ONLY if you want minutely events to happen more frequently.
private static List connectedClients = new List();
- private static Timer serverTimer;
- private static void onTick(object state)
+ private static Timer gameTimer; // Controls in-game time.
+ private static Timer minuteTimer; // ticks every real world minute.
+ private static void onGameTick(object state)
{
World.TickWorldClock();
- if (World.ServerTime.Minutes % 30 == 0)
+ gameTimer.Change(gameTickSpeed, gameTickSpeed);
+ }
+
+ private static void onMinuteTick(object state)
+ {
+ totalMinutesElapsed++;
+
+ if(totalMinutesElapsed % 8 == 0)
{
- DroppedItems.Update();
+ Database.IncAllUsersFreeTime(1);
}
- serverTimer.Change(gameTickSpeed, gameTickSpeed);
+
+ DroppedItems.Update();
+ minuteTimer.Change(oneMinute, oneMinute);
}
/*
@@ -304,7 +317,42 @@ namespace HISP.Server
}
User loggedInUser = sender.LoggedinUser;
- byte movementDirection = packet[1];
+ byte movementDirection = packet[1];
+
+ if (loggedInUser.Thirst <= 25 || loggedInUser.Hunger == 25 || loggedInUser.Tiredness == 25)
+ {
+ if (RandomNumberGenerator.Next(0, 15) == 10)
+ {
+ byte[] possibleDirections = new byte[] { PacketBuilder.MOVE_UP, PacketBuilder.MOVE_DOWN, PacketBuilder.MOVE_RIGHT, PacketBuilder.MOVE_LEFT };
+
+ if (possibleDirections.Contains(movementDirection))
+ {
+ byte newDirection = possibleDirections[RandomNumberGenerator.Next(0, possibleDirections.Length)];
+ if (newDirection != movementDirection)
+ {
+ movementDirection = newDirection;
+ if (loggedInUser.Thirst <= 25)
+ {
+ byte[] chatMessage = PacketBuilder.CreateChat(Messages.FormatRandomMovementMessage(Messages.StatThirst.ToUpper()), PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(chatMessage);
+ }
+ else if (loggedInUser.Hunger <= 25)
+ {
+ byte[] chatMessage = PacketBuilder.CreateChat(Messages.FormatRandomMovementMessage(Messages.StatHunger.ToUpper()), PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(chatMessage);
+ }
+ else if (loggedInUser.Tiredness <= 25)
+ {
+ byte[] chatMessage = PacketBuilder.CreateChat(Messages.FormatRandomMovementMessage(Messages.StatTired.ToUpper()), PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(chatMessage);
+ }
+
+ }
+ }
+ }
+ }
+
+
if (movementDirection == PacketBuilder.MOVE_ESCAPE)
{
@@ -358,6 +406,8 @@ namespace HISP.Server
if (movementDirection == PacketBuilder.MOVE_UP)
{
+
+
loggedInUser.Facing = PacketBuilder.DIRECTION_UP;
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y - 1))
{
@@ -847,14 +897,70 @@ namespace HISP.Server
Logger.HackerPrint(sender.LoggedinUser.Username + " Attempted to remove competition gear when none was equipped.");
}
break;
+ case '5':
+ if (sender.LoggedinUser.EquipedJewelry.Slot1 != null)
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedJewelry.Slot1.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedJewelry.Slot1 = null;
+ }
+ else
+ {
+ Logger.HackerPrint(sender.LoggedinUser.Username + " Attempted to remove jewery when none was equipped.");
+ }
+ break;
+ case '6':
+ if (sender.LoggedinUser.EquipedJewelry.Slot2 != null)
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedJewelry.Slot2.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedJewelry.Slot2 = null;
+ }
+ else
+ {
+ Logger.HackerPrint(sender.LoggedinUser.Username + " Attempted to remove jewery when none was equipped.");
+ }
+ break;
+ case '7':
+ if (sender.LoggedinUser.EquipedJewelry.Slot3 != null)
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedJewelry.Slot3.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedJewelry.Slot3 = null;
+ }
+ else
+ {
+ Logger.HackerPrint(sender.LoggedinUser.Username + " Attempted to remove jewery when none was equipped.");
+ }
+ break;
+ case '8':
+ if (sender.LoggedinUser.EquipedJewelry.Slot4 != null)
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedJewelry.Slot4.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedJewelry.Slot4 = null;
+ }
+ else
+ {
+ Logger.HackerPrint(sender.LoggedinUser.Username + " Attempted to remove jewery when none was equipped.");
+ }
+ break;
default:
Logger.InfoPrint(sender.LoggedinUser.Username + "Unimplemented \"remove worn item\" ItemInteraction packet: " + BitConverter.ToString(packet).Replace("-", " "));
break;
}
UpdateStats(sender);
- byte[] itemRemovedMessage = PacketBuilder.CreateChat(Messages.UnequipItem, PacketBuilder.CHAT_BOTTOM_RIGHT);
- sender.SendPacket(itemRemovedMessage);
+ if(toRemove >= '1' && toRemove <= '4')
+ {
+ byte[] itemRemovedMessage = PacketBuilder.CreateChat(Messages.RemoveCompetitionGear, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(itemRemovedMessage);
+ }
+ else if (toRemove >= '5' && toRemove <= '8')
+ {
+ byte[] itemRemovedMessage = PacketBuilder.CreateChat(Messages.RemoveJewelry, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(itemRemovedMessage);
+ }
break;
case PacketBuilder.ITEM_WEAR:
@@ -875,62 +981,100 @@ namespace HISP.Server
{
InventoryItem itm = sender.LoggedinUser.Inventory.GetItemByRandomid(randomId);
ItemInstance instance = itm.ItemInstances[0];
- sender.LoggedinUser.Inventory.Remove(instance);
-
+
Item.ItemInformation itemInf = instance.GetItemInfo();
- if(itemInf.MiscFlags.Length <= 0)
+ if(itemInf.Type == "CLOTHES")
{
- Logger.ErrorPrint(itemInf.Name + " Has no misc flags.");
- }
- switch(itemInf.MiscFlags[0])
+ if (itemInf.MiscFlags.Length <= 0)
+ {
+ Logger.ErrorPrint(itemInf.Name + " Has no misc flags.");
+ return;
+ }
+
+ switch (itemInf.MiscFlags[0])
+ {
+ case CompetitionGear.MISC_FLAG_HEAD:
+ if (sender.LoggedinUser.EquipedCompetitionGear.Head == null)
+ sender.LoggedinUser.EquipedCompetitionGear.Head = itemInf;
+ else
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Head.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedCompetitionGear.Head = itemInf;
+ }
+ break;
+ case CompetitionGear.MISC_FLAG_BODY:
+ if (sender.LoggedinUser.EquipedCompetitionGear.Body == null)
+ sender.LoggedinUser.EquipedCompetitionGear.Body = itemInf;
+ else
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Body.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedCompetitionGear.Body = itemInf;
+ }
+ break;
+ case CompetitionGear.MISC_FLAG_LEGS:
+ if (sender.LoggedinUser.EquipedCompetitionGear.Legs == null)
+ sender.LoggedinUser.EquipedCompetitionGear.Legs = itemInf;
+ else
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Legs.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedCompetitionGear.Legs = itemInf;
+ }
+ break;
+ case CompetitionGear.MISC_FLAG_FEET:
+ if (sender.LoggedinUser.EquipedCompetitionGear.Feet == null)
+ sender.LoggedinUser.EquipedCompetitionGear.Feet = itemInf;
+ else
+ {
+ ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Feet.Id);
+ sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
+ sender.LoggedinUser.EquipedCompetitionGear.Feet = itemInf;
+ }
+ break;
+ }
+ sender.LoggedinUser.Inventory.Remove(instance);
+ byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatEquipCompetitionGearMessage(itemInf.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(chatPacket);
+ }
+ else if(itemInf.Type == "JEWELRY")
{
- case CompetitionGear.MISC_FLAG_HEAD:
- if(sender.LoggedinUser.EquipedCompetitionGear.Head == null)
- sender.LoggedinUser.EquipedCompetitionGear.Head = itemInf;
- else
- {
- ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Head.Id);
- sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
- sender.LoggedinUser.EquipedCompetitionGear.Head = itemInf;
- }
- break;
- case CompetitionGear.MISC_FLAG_BODY:
- if (sender.LoggedinUser.EquipedCompetitionGear.Body == null)
- sender.LoggedinUser.EquipedCompetitionGear.Body = itemInf;
- else
- {
- ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Body.Id);
- sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
- sender.LoggedinUser.EquipedCompetitionGear.Body = itemInf;
- }
- break;
- case CompetitionGear.MISC_FLAG_LEGS:
- if (sender.LoggedinUser.EquipedCompetitionGear.Legs == null)
- sender.LoggedinUser.EquipedCompetitionGear.Legs = itemInf;
- else
- {
- ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Legs.Id);
- sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
- sender.LoggedinUser.EquipedCompetitionGear.Legs = itemInf;
- }
- break;
- case CompetitionGear.MISC_FLAG_FEET:
- if (sender.LoggedinUser.EquipedCompetitionGear.Feet == null)
- sender.LoggedinUser.EquipedCompetitionGear.Feet = itemInf;
- else
- {
- ItemInstance itemInstance = new ItemInstance(sender.LoggedinUser.EquipedCompetitionGear.Feet.Id);
- sender.LoggedinUser.Inventory.AddIgnoringFull(itemInstance);
- sender.LoggedinUser.EquipedCompetitionGear.Feet = itemInf;
- }
- break;
+ bool addedJewelry = false;
+ if (sender.LoggedinUser.EquipedJewelry.Slot1 == null)
+ {
+ sender.LoggedinUser.EquipedJewelry.Slot1 = itemInf;
+ addedJewelry = true;
+ }
+ else if (sender.LoggedinUser.EquipedJewelry.Slot2 == null)
+ {
+ sender.LoggedinUser.EquipedJewelry.Slot2 = itemInf;
+ addedJewelry = true;
+ }
+ else if (sender.LoggedinUser.EquipedJewelry.Slot3 == null)
+ {
+ sender.LoggedinUser.EquipedJewelry.Slot3 = itemInf;
+ addedJewelry = true;
+ }
+ else if (sender.LoggedinUser.EquipedJewelry.Slot4 == null)
+ {
+ sender.LoggedinUser.EquipedJewelry.Slot4 = itemInf;
+ addedJewelry = true;
+ }
+
+ if(addedJewelry)
+ {
+ sender.LoggedinUser.Inventory.Remove(instance);
+ byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatJewerlyEquipMessage(itemInf.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(chatPacket);
+ }
+ else
+ {
+ byte[] chatPacket = PacketBuilder.CreateChat(Messages.MaxJewelryMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(chatPacket);
+ }
}
-
-
-
- byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatEquipItemMessage(itemInf.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
- sender.SendPacket(chatPacket);
UpdateInventory(sender);
}
else
@@ -1437,7 +1581,6 @@ namespace HISP.Server
}
return usersHere.ToArray();
}
-
public static User GetUserByName(string username)
{
foreach(GameClient client in ConnectedClients)
@@ -1450,7 +1593,6 @@ namespace HISP.Server
}
throw new KeyNotFoundException("User was not found.");
}
-
public static User[] GetNearbyUsers(int x, int y, bool includeStealth=false, bool includeMuted=false)
{
int startX = x - 15;
@@ -1497,7 +1639,6 @@ namespace HISP.Server
}
return count;
}
-
public static int GetNumberOfAdminsOnline()
{
int count = 0;
@@ -1662,7 +1803,8 @@ namespace HISP.Server
ServerSocket.Bind(ep);
Logger.InfoPrint("Binding to ip: " + ConfigReader.BindIP + " On port: " + ConfigReader.Port.ToString());
ServerSocket.Listen(10000);
- serverTimer = new Timer(new TimerCallback(onTick), null, gameTickSpeed, gameTickSpeed);
+ gameTimer = new Timer(new TimerCallback(onGameTick), null, gameTickSpeed, gameTickSpeed);
+ minuteTimer = new Timer(new TimerCallback(onMinuteTick), null, oneMinute, oneMinute);
while (true)
{
Logger.InfoPrint("Waiting for new connections...");