mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-18 19:01:32 +12:00
Change Dropped Items spawning Algorithm
This commit is contained in:
parent
02f5af9995
commit
29fe3ec024
9 changed files with 311 additions and 57 deletions
|
@ -61,7 +61,8 @@
|
||||||
"grab_all_message":"You grabbed all objects off the ground.",
|
"grab_all_message":"You grabbed all objects off the ground.",
|
||||||
"dropped_item_message":"You dropped an item on the ground.",
|
"dropped_item_message":"You dropped an item on the ground.",
|
||||||
"grab_but_inv_full":"Your inventory is full! Cannot grab items.",
|
"grab_but_inv_full":"Your inventory is full! Cannot grab items.",
|
||||||
"grab_all_but_inv_full":"You grabbed what you could, but your inventory is full."
|
"grab_all_but_inv_full":"You grabbed what you could, but your inventory is full.",
|
||||||
|
"drop_tile_full":"Cannot drop any more objects here, too many on ground already."
|
||||||
},
|
},
|
||||||
"shop":{
|
"shop":{
|
||||||
"cant_afford_1":"You cannot afford that item!",
|
"cant_afford_1":"You cannot afford that item!",
|
||||||
|
@ -138,7 +139,9 @@
|
||||||
"saved":"Current contents of the Drawing Room saved in your slot #%SLOT%.",
|
"saved":"Current contents of the Drawing Room saved in your slot #%SLOT%.",
|
||||||
"load":"Current contents of the Drawing Room loaded from your slot #%SLOT%.",
|
"load":"Current contents of the Drawing Room loaded from your slot #%SLOT%.",
|
||||||
"plz_clear_load":"Drawing room memory is full. Please CLEAR to start a new drawing.",
|
"plz_clear_load":"Drawing room memory is full. Please CLEAR to start a new drawing.",
|
||||||
"plz_clear_draw":"Drawing room memory is full. Your additional drawing is not being seen. Please CLEAR to start a new drawing."
|
"plz_clear_draw":"Drawing room memory is full. Your additional drawing is not being seen. Please CLEAR to start a new drawing.",
|
||||||
|
"not_subscribed_draw":"Drawing not sent to other players when you are not a subscriber.",
|
||||||
|
"not_subscribed_load":"Cannot load drawings when you are not a subscriber.",
|
||||||
},
|
},
|
||||||
"groomer":{
|
"groomer":{
|
||||||
"groomed_best_it_can":"Your horse %HORSEBREED% is now groomed as best as this groomer can!",
|
"groomed_best_it_can":"Your horse %HORSEBREED% is now groomed as best as this groomer can!",
|
||||||
|
@ -147,8 +150,6 @@
|
||||||
"apply_service":"^I258^T8Apply grooming services for $%PRICE% ^B3G%RANDOMID%^R1",
|
"apply_service":"^I258^T8Apply grooming services for $%PRICE% ^B3G%RANDOMID%^R1",
|
||||||
"apply_all":"^R1^R1^I258^T8Groom all %COUNT% horses for $%PRICE% ^B3g^R1",
|
"apply_all":"^R1^R1^I258^T8Groom all %COUNT% horses for $%PRICE% ^B3g^R1",
|
||||||
"cannot_improve":"^I258^T9This groomer cannot improve this horse's groom.^R1",
|
"cannot_improve":"^I258^T9This groomer cannot improve this horse's groom.^R1",
|
||||||
"not_subscribed_draw":"Drawing not sent to other players when you are not a subscriber.",
|
|
||||||
"not_subscribed_load":"Cannot load drawings when you are not a subscriber.",
|
|
||||||
},
|
},
|
||||||
"farrier":{
|
"farrier":{
|
||||||
"shoes_total":"^LYour horse %HORSENAME%: shoes currently %TOTAL%/%MAX%^R1",
|
"shoes_total":"^LYour horse %HORSENAME%: shoes currently %TOTAL%/%MAX%^R1",
|
||||||
|
|
|
@ -7,4 +7,8 @@ namespace HISP.Game
|
||||||
public class InventoryException : Exception { };
|
public class InventoryException : Exception { };
|
||||||
public class InventoryFullException : InventoryException { };
|
public class InventoryFullException : InventoryException { };
|
||||||
public class InventoryMaxStackException : InventoryException { };
|
public class InventoryMaxStackException : InventoryException { };
|
||||||
|
|
||||||
|
// Drawingroom
|
||||||
|
public class DrawingroomException : Exception { };
|
||||||
|
public class DrawingroomFullException : DrawingroomException { };
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,40 +93,43 @@ namespace HISP.Game.Horse
|
||||||
|
|
||||||
public void RandomWander()
|
public void RandomWander()
|
||||||
{
|
{
|
||||||
int direction = GameServer.RandomNumberGenerator.Next(0, 3);
|
while(true)
|
||||||
int tryX = this.X;
|
|
||||||
int tryY = this.Y;
|
|
||||||
|
|
||||||
switch(direction)
|
|
||||||
{
|
{
|
||||||
case 0:
|
int direction = GameServer.RandomNumberGenerator.Next(0, 3);
|
||||||
tryX += 1;
|
int tryX = this.X;
|
||||||
break;
|
int tryY = this.Y;
|
||||||
case 1:
|
|
||||||
tryX -= 1;
|
switch (direction)
|
||||||
break;
|
{
|
||||||
case 2:
|
case 0:
|
||||||
tryY += 1;
|
tryX += 1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 1:
|
||||||
tryY -= 1;
|
tryX -= 1;
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
tryY += 1;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
tryY -= 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// Horses cannot be in towns.
|
||||||
|
if (World.InTown(tryX, tryY))
|
||||||
|
continue;
|
||||||
|
if (World.InSpecialTile(tryX, tryY))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Map.CheckPassable(tryX, tryY)) // Can the player stand here?
|
||||||
|
{
|
||||||
|
Logger.DebugPrint(this.Instance.Breed.Name + " Randomly wandered to: " + tryX.ToString() + ", " + tryY.ToString());
|
||||||
|
X = tryX;
|
||||||
|
Y = tryY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Horses cannot be in towns.
|
|
||||||
if (World.InTown(tryX, tryY))
|
|
||||||
return;
|
|
||||||
if (World.InSpecialTile(tryX, tryY))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (Map.CheckPassable(tryX, tryY))
|
|
||||||
{
|
|
||||||
X = tryX;
|
|
||||||
Y = tryY;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Escape()
|
public void Escape()
|
||||||
|
@ -239,9 +242,8 @@ namespace HISP.Game.Horse
|
||||||
if (wildHorse.Timeout <= 0)
|
if (wildHorse.Timeout <= 0)
|
||||||
Despawn(wildHorse);
|
Despawn(wildHorse);
|
||||||
|
|
||||||
if(wildHorse.Timeout % 5 == 0)
|
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
|
||||||
if (GameServer.RandomNumberGenerator.Next(0, 100) > 50)
|
wildHorse.RandomWander();
|
||||||
wildHorse.RandomWander();
|
|
||||||
}
|
}
|
||||||
if(WildHorses.Length < 40)
|
if(WildHorses.Length < 40)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,6 +112,7 @@ namespace HISP.Game.Items
|
||||||
{
|
{
|
||||||
if(GameServer.GetUsersAt(item.X, item.Y,true,true).Length == 0)
|
if(GameServer.GetUsersAt(item.X, item.Y,true,true).Length == 0)
|
||||||
{
|
{
|
||||||
|
Logger.DebugPrint("Despawned Item at " + item.X + ", " + item.Y);
|
||||||
RemoveDroppedItem(item);
|
RemoveDroppedItem(item);
|
||||||
removedCount++;
|
removedCount++;
|
||||||
}
|
}
|
||||||
|
@ -132,6 +133,9 @@ namespace HISP.Game.Items
|
||||||
}
|
}
|
||||||
public static void GenerateItems()
|
public static void GenerateItems()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Logger.InfoPrint("Generating items, (this may take awhile on a fresh database!)");
|
||||||
|
|
||||||
int newItems = 0;
|
int newItems = 0;
|
||||||
foreach (Item.ItemInformation item in Item.Items)
|
foreach (Item.ItemInformation item in Item.Items)
|
||||||
{
|
{
|
||||||
|
@ -165,6 +169,9 @@ namespace HISP.Game.Items
|
||||||
|
|
||||||
if (item.SpawnParamaters.SpawnOnTileType == TileType)
|
if (item.SpawnParamaters.SpawnOnTileType == TileType)
|
||||||
{
|
{
|
||||||
|
if (GetItemsAt(tryX, tryY).Length > 26) // Max here
|
||||||
|
continue;
|
||||||
|
|
||||||
ItemInstance instance = new ItemInstance(item.Id);
|
ItemInstance instance = new ItemInstance(item.Id);
|
||||||
DroppedItem droppedItem = new DroppedItem();
|
DroppedItem droppedItem = new DroppedItem();
|
||||||
droppedItem.X = tryX;
|
droppedItem.X = tryX;
|
||||||
|
@ -199,6 +206,9 @@ namespace HISP.Game.Items
|
||||||
|
|
||||||
if (Map.CheckPassable(spawnOn.X, spawnOn.Y))
|
if (Map.CheckPassable(spawnOn.X, spawnOn.Y))
|
||||||
{
|
{
|
||||||
|
if (GetItemsAt(spawnOn.X, spawnOn.Y).Length > 26) // Max here
|
||||||
|
continue;
|
||||||
|
|
||||||
ItemInstance instance = new ItemInstance(item.Id);
|
ItemInstance instance = new ItemInstance(item.Id);
|
||||||
DroppedItem droppedItem = new DroppedItem();
|
DroppedItem droppedItem = new DroppedItem();
|
||||||
droppedItem.X = spawnOn.X;
|
droppedItem.X = spawnOn.X;
|
||||||
|
@ -260,6 +270,8 @@ namespace HISP.Game.Items
|
||||||
|
|
||||||
if (Map.CheckPassable(tryX, tryY))
|
if (Map.CheckPassable(tryX, tryY))
|
||||||
{
|
{
|
||||||
|
if (GetItemsAt(tryX, tryY).Length > 26) // Max here
|
||||||
|
continue;
|
||||||
|
|
||||||
ItemInstance instance = new ItemInstance(item.Id);
|
ItemInstance instance = new ItemInstance(item.Id);
|
||||||
DroppedItem droppedItem = new DroppedItem();
|
DroppedItem droppedItem = new DroppedItem();
|
||||||
|
@ -286,13 +298,14 @@ namespace HISP.Game.Items
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Pick a random isle:
|
// Pick a random isle:
|
||||||
int isleId = GameServer.RandomNumberGenerator.Next(0, World.Isles.Count);
|
//int isleId = GameServer.RandomNumberGenerator.Next(0, World.Isles.Count);
|
||||||
World.Isle isle = World.Isles[isleId];
|
//World.Isle isle = World.Isles[isleId];
|
||||||
|
|
||||||
// Pick a random location inside the isle
|
// Pick a random location inside the isle
|
||||||
int tryX = GameServer.RandomNumberGenerator.Next(isle.StartX, isle.EndX);
|
//int tryX = GameServer.RandomNumberGenerator.Next(isle.StartX, isle.EndX);
|
||||||
int tryY = GameServer.RandomNumberGenerator.Next(isle.StartY, isle.EndY);
|
//int tryY = GameServer.RandomNumberGenerator.Next(isle.StartY, isle.EndY);
|
||||||
|
int tryX = GameServer.RandomNumberGenerator.Next(0, Map.Width);
|
||||||
|
int tryY = GameServer.RandomNumberGenerator.Next(0, Map.Height);
|
||||||
|
|
||||||
if (World.InSpecialTile(tryX, tryY))
|
if (World.InSpecialTile(tryX, tryY))
|
||||||
continue;
|
continue;
|
||||||
|
@ -304,6 +317,9 @@ namespace HISP.Game.Items
|
||||||
|
|
||||||
if (item.SpawnParamaters.SpawnOnTileType == TileType)
|
if (item.SpawnParamaters.SpawnOnTileType == TileType)
|
||||||
{
|
{
|
||||||
|
if (GetItemsAt(tryX, tryY).Length > 26) // Max here
|
||||||
|
continue;
|
||||||
|
|
||||||
ItemInstance instance = new ItemInstance(item.Id);
|
ItemInstance instance = new ItemInstance(item.Id);
|
||||||
DroppedItem droppedItem = new DroppedItem();
|
DroppedItem droppedItem = new DroppedItem();
|
||||||
droppedItem.X = tryX;
|
droppedItem.X = tryX;
|
||||||
|
@ -312,7 +328,7 @@ namespace HISP.Game.Items
|
||||||
droppedItem.instance = instance;
|
droppedItem.instance = instance;
|
||||||
droppedItemsList.Add(droppedItem);
|
droppedItemsList.Add(droppedItem);
|
||||||
Database.AddDroppedItem(droppedItem);
|
Database.AddDroppedItem(droppedItem);
|
||||||
Logger.DebugPrint("Created Item ID: " + instance.ItemId + " in " + isle.Name + " at: X: " + droppedItem.X + " Y: " + droppedItem.Y);
|
Logger.DebugPrint("Created Item ID: " + instance.ItemId + " at: X: " + droppedItem.X + " Y: " + droppedItem.Y);
|
||||||
newItems++;
|
newItems++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -340,7 +356,6 @@ namespace HISP.Game.Items
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
ReadFromDatabase();
|
ReadFromDatabase();
|
||||||
Logger.InfoPrint("Generating items, (this may take awhile on a fresh database!)");
|
|
||||||
GenerateItems();
|
GenerateItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,7 @@ namespace HISP.Game
|
||||||
public static string GrabbedAllItemsButInventoryFull;
|
public static string GrabbedAllItemsButInventoryFull;
|
||||||
public static string GrabbedAllItemsMessage;
|
public static string GrabbedAllItemsMessage;
|
||||||
public static string DroppedAnItemMessage;
|
public static string DroppedAnItemMessage;
|
||||||
|
public static string DroppedItemTileIsFull;
|
||||||
public static string ItemInformationFormat;
|
public static string ItemInformationFormat;
|
||||||
|
|
||||||
// Pond
|
// Pond
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
using HISP.Server;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HISP.Game.SwfModules
|
||||||
|
{
|
||||||
|
class Drawingroom
|
||||||
|
{
|
||||||
|
private string drawing;
|
||||||
|
public string Drawing
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return drawing;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(value.Length < 65535)
|
||||||
|
{
|
||||||
|
Database.SetDrawingRoomDrawing(Id, value);
|
||||||
|
drawing = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new DrawingroomFullException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int Id;
|
||||||
|
public Drawingroom(int roomId)
|
||||||
|
{
|
||||||
|
if (!Database.DrawingRoomExists(roomId))
|
||||||
|
Database.CreateDrawingRoom(roomId);
|
||||||
|
drawing = Database.GetDrawingRoomDrawing(roomId);
|
||||||
|
Id = roomId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,8 @@ namespace HISP.Server
|
||||||
string Leaderboards = "CREATE TABLE Leaderboards(playerId INT, minigame TEXT(128), wins INT, looses INT, timesplayed INT, score INT, type TEXT(128))";
|
string Leaderboards = "CREATE TABLE Leaderboards(playerId INT, minigame TEXT(128), wins INT, looses INT, timesplayed INT, score INT, type TEXT(128))";
|
||||||
string NpcStartPoint = "CREATE TABLE NpcStartPoint(playerId INT, npcId INT, chatpointId INT)";
|
string NpcStartPoint = "CREATE TABLE NpcStartPoint(playerId INT, npcId INT, chatpointId INT)";
|
||||||
string PoetryRooms = "CREATE TABLE PoetryRooms(poetId INT, X INT, Y INT, roomId INT)";
|
string PoetryRooms = "CREATE TABLE PoetryRooms(poetId INT, X INT, Y INT, roomId INT)";
|
||||||
|
string SavedDrawings = "CREATE TABLE SavedDrawings(playerId INT, Drawing1 TEXT(65535), Drawing2 TEXT(65535), Drawing3 TEXT(65535))";
|
||||||
|
string DrawingRooms = "CREATE TABLE DrawingRooms(roomId INT, Drawing TEXT(65535))";
|
||||||
string Horses = "CREATE TABLE Horses(randomId INT, ownerId INT, ranchId INT, leaser INT, breed INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, autoSell INT, trainTimer INT, category TEXT(128), spoiled INT, magicUsed INT)";
|
string Horses = "CREATE TABLE Horses(randomId INT, ownerId INT, ranchId INT, leaser INT, breed INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, autoSell INT, trainTimer INT, category TEXT(128), spoiled INT, magicUsed INT)";
|
||||||
string WildHorse = "CREATE TABLE WildHorse(randomId INT, originalOwner INT, breed INT, x INT, y INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, timeout INT, autoSell INT, trainTimer INT, category TEXT(128), spoiled INT, magicUsed INT)";
|
string WildHorse = "CREATE TABLE WildHorse(randomId INT, originalOwner INT, breed INT, x INT, y INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, timeout INT, autoSell INT, trainTimer INT, category TEXT(128), spoiled INT, magicUsed INT)";
|
||||||
string LastPlayer = "CREATE TABLE LastPlayer(roomId TEXT(1028), playerId INT)";
|
string LastPlayer = "CREATE TABLE LastPlayer(roomId TEXT(1028), playerId INT)";
|
||||||
|
@ -44,6 +46,33 @@ namespace HISP.Server
|
||||||
string BannedPlayers = "CREATE TABLE BannedPlayers(playerId INT, ipAddress TEXT(1028), reason TEXT(1028))";
|
string BannedPlayers = "CREATE TABLE BannedPlayers(playerId INT, ipAddress TEXT(1028), reason TEXT(1028))";
|
||||||
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = SavedDrawings;
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.WarnPrint(e.Message);
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = DrawingRooms;
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.WarnPrint(e.Message);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -264,7 +293,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
Logger.WarnPrint(e.Message);
|
Logger.WarnPrint(e.Message);
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -306,7 +335,7 @@ namespace HISP.Server
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -365,9 +394,10 @@ namespace HISP.Server
|
||||||
Logger.WarnPrint(e.Message);
|
Logger.WarnPrint(e.Message);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void AddTrackedItem(int playerId, Tracking.TrackableItem what, int count)
|
public static void AddTrackedItem(int playerId, Tracking.TrackableItem what, int count)
|
||||||
{
|
{
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
@ -403,7 +433,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
public static int GetTrackedCount(int playerId, Tracking.TrackableItem what)
|
public static int GetTrackedCount(int playerId, Tracking.TrackableItem what)
|
||||||
{
|
{
|
||||||
|
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
db.Open();
|
db.Open();
|
||||||
|
@ -610,7 +640,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
int randomId = reader.GetInt32(0);
|
int randomId = reader.GetInt32(0);
|
||||||
int breedId = reader.GetInt32(4);
|
int breedId = reader.GetInt32(4);
|
||||||
|
|
||||||
HorseInfo.Breed horseBreed = HorseInfo.GetBreedById(breedId);
|
HorseInfo.Breed horseBreed = HorseInfo.GetBreedById(breedId);
|
||||||
string name = reader.GetString(5);
|
string name = reader.GetString(5);
|
||||||
string description = reader.GetString(6);
|
string description = reader.GetString(6);
|
||||||
|
@ -721,12 +751,12 @@ namespace HISP.Server
|
||||||
sqlCommand.Dispose();
|
sqlCommand.Dispose();
|
||||||
return count >= 1;
|
return count >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddWildHorse(WildHorse horse)
|
public static void AddWildHorse(WildHorse horse)
|
||||||
{
|
{
|
||||||
|
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
db.Open();
|
db.Open();
|
||||||
|
@ -761,7 +791,7 @@ namespace HISP.Server
|
||||||
sqlCommand.Parameters.AddWithValue("@personality", horse.Instance.AdvancedStats.Personality);
|
sqlCommand.Parameters.AddWithValue("@personality", horse.Instance.AdvancedStats.Personality);
|
||||||
sqlCommand.Parameters.AddWithValue("@height", horse.Instance.AdvancedStats.Height);
|
sqlCommand.Parameters.AddWithValue("@height", horse.Instance.AdvancedStats.Height);
|
||||||
|
|
||||||
if(horse.Instance.Equipment.Saddle != null)
|
if (horse.Instance.Equipment.Saddle != null)
|
||||||
sqlCommand.Parameters.AddWithValue("@saddle", horse.Instance.Equipment.Saddle.Id);
|
sqlCommand.Parameters.AddWithValue("@saddle", horse.Instance.Equipment.Saddle.Id);
|
||||||
else
|
else
|
||||||
sqlCommand.Parameters.AddWithValue("@saddle", null);
|
sqlCommand.Parameters.AddWithValue("@saddle", null);
|
||||||
|
@ -781,7 +811,7 @@ namespace HISP.Server
|
||||||
else
|
else
|
||||||
sqlCommand.Parameters.AddWithValue("@companion", null);
|
sqlCommand.Parameters.AddWithValue("@companion", null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -797,7 +827,7 @@ namespace HISP.Server
|
||||||
|
|
||||||
sqlCommand.Dispose();
|
sqlCommand.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadWildHorses()
|
public static void LoadWildHorses()
|
||||||
|
@ -812,7 +842,7 @@ namespace HISP.Server
|
||||||
sqlCommand.Prepare();
|
sqlCommand.Prepare();
|
||||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||||
|
|
||||||
while(reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
int randomId = reader.GetInt32(0);
|
int randomId = reader.GetInt32(0);
|
||||||
int breedId = reader.GetInt32(2);
|
int breedId = reader.GetInt32(2);
|
||||||
|
@ -861,7 +891,7 @@ namespace HISP.Server
|
||||||
int y = reader.GetInt32(4);
|
int y = reader.GetInt32(4);
|
||||||
int timeout = reader.GetInt32(29);
|
int timeout = reader.GetInt32(29);
|
||||||
WildHorse WildHorse = new WildHorse(inst, x, y, timeout, false);
|
WildHorse WildHorse = new WildHorse(inst, x, y, timeout, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlCommand.Dispose();
|
sqlCommand.Dispose();
|
||||||
|
@ -886,6 +916,9 @@ namespace HISP.Server
|
||||||
|
|
||||||
public static int GetLastPlayer(string roomId)
|
public static int GetLastPlayer(string roomId)
|
||||||
{
|
{
|
||||||
|
if (!Database.LastPlayerExist(roomId))
|
||||||
|
Database.AddLastPlayer(roomId, -1);
|
||||||
|
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
db.Open();
|
db.Open();
|
||||||
|
@ -903,6 +936,8 @@ namespace HISP.Server
|
||||||
|
|
||||||
public static void SetLastPlayer(string roomId, int playerId)
|
public static void SetLastPlayer(string roomId, int playerId)
|
||||||
{
|
{
|
||||||
|
if (!Database.LastPlayerExist(roomId))
|
||||||
|
Database.AddLastPlayer(roomId, -1);
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
db.Open();
|
db.Open();
|
||||||
|
@ -980,7 +1015,7 @@ namespace HISP.Server
|
||||||
sqlCommand.Parameters.AddWithValue("@room", room);
|
sqlCommand.Parameters.AddWithValue("@room", room);
|
||||||
sqlCommand.Prepare();
|
sqlCommand.Prepare();
|
||||||
int xpos = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
int xpos = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||||
|
|
||||||
sqlCommand.Dispose();
|
sqlCommand.Dispose();
|
||||||
return xpos;
|
return xpos;
|
||||||
}
|
}
|
||||||
|
@ -1003,6 +1038,152 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool SavedDrawingsExist(int playerId)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "SELECT COUNT(*) FROM SavedDrawings WHERE playerId=@playerId";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
int count = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
return count >= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void CreateSavedDrawings(int playerId)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "INSERT INTO SavedDrawings VALUES(@playerId,'','','')";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool DrawingRoomExists(int room)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "SELECT COUNT(*) FROM DrawingRooms WHERE roomId=@room";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@room", room);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
int count = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
return count >= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateDrawingRoom(int room)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "INSERT INTO DrawingRooms VALUES(@roomId,'')";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@roomId", room);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetDrawingRoomDrawing(int room, string Drawing)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "UPDATE DrawingRooms SET Drawing=@drawing WHERE roomId=@room";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@drawing", Drawing);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@room", room);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static string GetDrawingRoomDrawing(int room)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "SELECT Drawing FROM DrawingRooms WHERE roomId=@room";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@room", room);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
string drawing = sqlCommand.ExecuteScalar().ToString();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
return drawing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveDrawingSlot1(int playerId, string drawing)
|
||||||
|
{
|
||||||
|
if (!SavedDrawingsExist(playerId))
|
||||||
|
CreateSavedDrawings(playerId);
|
||||||
|
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "UPDATE SavedDrawings SET Drawing1=@drawing WHERE playerId=@playerId";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@drawing", drawing);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveDrawingSlot2(int playerId, string drawing)
|
||||||
|
{
|
||||||
|
if (!SavedDrawingsExist(playerId))
|
||||||
|
CreateSavedDrawings(playerId);
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "UPDATE SavedDrawings SET Drawing2=@drawing WHERE playerId=@playerId";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@drawing", drawing);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveDrawingSlot3(int playerId, string drawing)
|
||||||
|
{
|
||||||
|
if (!SavedDrawingsExist(playerId))
|
||||||
|
CreateSavedDrawings(playerId);
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "UPDATE SavedDrawings SET Drawing3=@drawing WHERE playerId=@playerId";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@drawing", drawing);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetServerTime(int time, int day, int year)
|
public static void SetServerTime(int time, int day, int year)
|
||||||
{
|
{
|
||||||
|
|
|
@ -912,6 +912,7 @@ namespace HISP.Server
|
||||||
Messages.ItemInformationFormat = gameData.messages.meta.dropped_items.item_information_format;
|
Messages.ItemInformationFormat = gameData.messages.meta.dropped_items.item_information_format;
|
||||||
Messages.GrabAllItemsButton = gameData.messages.meta.dropped_items.grab_all;
|
Messages.GrabAllItemsButton = gameData.messages.meta.dropped_items.grab_all;
|
||||||
Messages.DroppedAnItemMessage = gameData.messages.dropped_items.dropped_item_message;
|
Messages.DroppedAnItemMessage = gameData.messages.dropped_items.dropped_item_message;
|
||||||
|
Messages.DroppedItemTileIsFull = gameData.messages.dropped_items.drop_tile_full;
|
||||||
Messages.GrabbedAllItemsMessage = gameData.messages.dropped_items.grab_all_message;
|
Messages.GrabbedAllItemsMessage = gameData.messages.dropped_items.grab_all_message;
|
||||||
Messages.GrabbedItemMessage = gameData.messages.dropped_items.grab_message;
|
Messages.GrabbedItemMessage = gameData.messages.dropped_items.grab_message;
|
||||||
Messages.GrabAllItemsMessage = gameData.messages.dropped_items.grab_all_message;
|
Messages.GrabAllItemsMessage = gameData.messages.dropped_items.grab_all_message;
|
||||||
|
|
|
@ -3107,6 +3107,12 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
InventoryItem itm = sender.LoggedinUser.Inventory.GetItemByRandomid(randomId);
|
InventoryItem itm = sender.LoggedinUser.Inventory.GetItemByRandomid(randomId);
|
||||||
ItemInstance instance = itm.ItemInstances[0];
|
ItemInstance instance = itm.ItemInstances[0];
|
||||||
|
if(DroppedItems.GetItemsAt(sender.LoggedinUser.X, sender.LoggedinUser.Y).Length > 26)
|
||||||
|
{
|
||||||
|
byte[] tileIsFullPacket = PacketBuilder.CreateChat(Messages.DroppedItemTileIsFull, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
sender.SendPacket(tileIsFullPacket);
|
||||||
|
break;
|
||||||
|
}
|
||||||
DroppedItems.AddItem(instance, sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
DroppedItems.AddItem(instance, sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||||
sender.LoggedinUser.Inventory.Remove(instance);
|
sender.LoggedinUser.Inventory.Remove(instance);
|
||||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.DroppedAnItemMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.DroppedAnItemMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue