mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 12:19:15 +12:00
Add pirate treasures, and pot of gold (Though, text is missing for Pot of Gold- i have to find one in public server first.)
This commit is contained in:
parent
e326dd2bf7
commit
cfdea72b6c
9 changed files with 346 additions and 2 deletions
|
@ -32,6 +32,11 @@ namespace HISP.Game
|
|||
|
||||
int pos = ((x * Height) + y);
|
||||
|
||||
if (overlay && Treasure.IsTileBuiredTreasure(x, y))
|
||||
return 193; // Burried Treasure tile.
|
||||
else if (overlay && Treasure.IsTilePotOfGold(x, y))
|
||||
return 186; // Pot of Gold tile.
|
||||
|
||||
if (overlay)
|
||||
return oMapData[pos];
|
||||
else
|
||||
|
|
|
@ -344,8 +344,12 @@ namespace HISP.Game
|
|||
public static string HorseEquipFormat;
|
||||
public static string BackToHorse;
|
||||
|
||||
// Treasure
|
||||
public static string PirateTreasureFormat;
|
||||
|
||||
|
||||
// Groomer
|
||||
|
||||
public static string GroomerBestToHisAbilitiesFormat;
|
||||
public static string GroomerCannotAffordMessage;
|
||||
public static string GroomerHorseCurrentlyAtFormat;
|
||||
|
@ -587,6 +591,10 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatPirateTreasure(int prize)
|
||||
{
|
||||
return PirateTreasureFormat.Replace("%PRIZE%", prize.ToString("N0"));
|
||||
}
|
||||
public static string FormatWorkshopCraftEntry(int iconId, string itemName, int price, int itemId, int craftId)
|
||||
{
|
||||
return WorkshopCraftEntryFormat.Replace("%ICONID%", iconId.ToString()).Replace("%ITEMNAME%", itemName).Replace("%PRICE%", price.ToString("N0")).Replace("%ITEMID%", itemId.ToString()).Replace("%CRAFTID%", craftId.ToString());
|
||||
|
|
|
@ -330,6 +330,15 @@ namespace HISP.Game
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(tool == Quest.Shovel)
|
||||
{
|
||||
// Also check Treasures
|
||||
if (Treasure.IsTileTreasure(x, y))
|
||||
Treasure.GetTreasureAt(x, y).CollectTreasure(user);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
239
Horse Isle Server/HorseIsleServer/Game/Treasure.cs
Normal file
239
Horse Isle Server/HorseIsleServer/Game/Treasure.cs
Normal file
|
@ -0,0 +1,239 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
public class Treasure
|
||||
{
|
||||
private static List<Treasure> treasures = new List<Treasure>();
|
||||
public static Treasure[] Treasures
|
||||
{
|
||||
get
|
||||
{
|
||||
return treasures.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private int value;
|
||||
|
||||
public int RandomId;
|
||||
public int X;
|
||||
public int Y;
|
||||
public int Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.value = value;
|
||||
Database.SetTreasureValue(RandomId, value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Type;
|
||||
public Treasure(int x, int y, string type, int randomId = -1, int moneyValue=-1)
|
||||
{
|
||||
RandomId = Security.RandomID.NextRandomId(randomId);
|
||||
|
||||
if(type == "BURIED")
|
||||
{
|
||||
if(moneyValue == -1)
|
||||
value = GameServer.RandomNumberGenerator.Next(100,5000);
|
||||
}
|
||||
else if(type == "RAINBOW")
|
||||
{
|
||||
if (moneyValue == -1)
|
||||
value = GameServer.RandomNumberGenerator.Next(10000, 50000);
|
||||
}
|
||||
|
||||
if (moneyValue != -1)
|
||||
value = moneyValue;
|
||||
|
||||
X = x;
|
||||
Y = y;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public static int NumberOfPirates()
|
||||
{
|
||||
int count = 0;
|
||||
foreach (Treasure treasure in Treasures)
|
||||
{
|
||||
if (treasure.Type == "BURIED")
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static int NumberOfRainbows()
|
||||
{
|
||||
int count = 0;
|
||||
foreach(Treasure treasure in Treasures)
|
||||
{
|
||||
if (treasure.Type == "RAINBOW")
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static bool IsTileTreasure(int x, int y)
|
||||
{
|
||||
foreach (Treasure treasure in Treasures)
|
||||
{
|
||||
if (treasure.X == x && treasure.Y == y)
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsTileBuiredTreasure(int x, int y)
|
||||
{
|
||||
foreach (Treasure treasure in Treasures)
|
||||
{
|
||||
if (treasure.Type == "BURIED")
|
||||
{
|
||||
if (treasure.X == x && treasure.Y == y)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsTilePotOfGold(int x, int y)
|
||||
{
|
||||
foreach(Treasure treasure in Treasures)
|
||||
{
|
||||
if(treasure.Type == "RAINBOW")
|
||||
{
|
||||
if (treasure.X == x && treasure.Y == y)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Treasure GetTreasureAt(int x, int y)
|
||||
{
|
||||
foreach (Treasure treasure in Treasures)
|
||||
{
|
||||
if (treasure.X == x && treasure.Y == y)
|
||||
return treasure;
|
||||
}
|
||||
throw new KeyNotFoundException("NO Treasure at " + x + "," + y);
|
||||
}
|
||||
|
||||
public static void AddValue()
|
||||
{
|
||||
foreach(Treasure treasure in treasures)
|
||||
{
|
||||
treasure.Value += 1;
|
||||
}
|
||||
}
|
||||
public void CollectTreasure(User user)
|
||||
{
|
||||
|
||||
treasures.Remove(this);
|
||||
GenerateTreasure();
|
||||
|
||||
byte[] MovementPacket = PacketBuilder.CreateMovementPacket(user.X, user.Y, user.CharacterId, user.Facing, PacketBuilder.DIRECTION_TELEPORT, true);
|
||||
user.LoggedinClient.SendPacket(MovementPacket);
|
||||
|
||||
user.Money += Value;
|
||||
|
||||
if(this.Type == "BURIED")
|
||||
{
|
||||
byte[] treasureReceivedPacket = PacketBuilder.CreateChat(Messages.FormatPirateTreasure(this.Value), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
user.LoggedinClient.SendPacket(treasureReceivedPacket);
|
||||
user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count++;
|
||||
|
||||
if(user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count >= 10)
|
||||
user.Awards.AddAward(Award.GetAwardById(18)); // Pirate Tracker
|
||||
|
||||
if (user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count >= 100)
|
||||
user.Awards.AddAward(Award.GetAwardById(19)); // Pirate Stalker
|
||||
}
|
||||
else if(this.Type == "RAINBOW")
|
||||
{
|
||||
user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PotOfGold).Count++;
|
||||
|
||||
if (user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PotOfGold).Count >= 3)
|
||||
user.Awards.AddAward(Award.GetAwardById(20)); // Leprechaun
|
||||
|
||||
if (user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count >= 20)
|
||||
user.Awards.AddAward(Award.GetAwardById(21)); // Lucky Leprechaun
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void GenerateTreasure()
|
||||
{
|
||||
while(NumberOfPirates() < 5)
|
||||
{
|
||||
// Pick x/y
|
||||
int tryX = GameServer.RandomNumberGenerator.Next(0, Map.Width);
|
||||
int tryY = GameServer.RandomNumberGenerator.Next(0, Map.Height);
|
||||
|
||||
if (!Map.CheckPassable(tryX, tryY)) // can the player walk here?
|
||||
continue;
|
||||
|
||||
if (World.InTown(tryX, tryY)) // in a town?
|
||||
continue;
|
||||
|
||||
if (Map.GetTileId(tryX, tryY, true) != 1) // is there allready an overlay here?
|
||||
continue;
|
||||
|
||||
if (Map.TerrainTiles[Map.GetTileId(tryX, tryY, false) - 1].Type != "BEACH")
|
||||
continue;
|
||||
|
||||
// Create Treasure
|
||||
Treasure treasure = new Treasure(tryX, tryY, "BURIED");
|
||||
treasures.Add(treasure);
|
||||
Database.AddTreasure(treasure.RandomId, treasure.X, treasure.Y, treasure.Value, treasure.Type);
|
||||
|
||||
Logger.DebugPrint("Created Pirate Treasure at " + treasure.X + "," + treasure.Y + " with value: " + treasure.Value);
|
||||
|
||||
}
|
||||
|
||||
while (NumberOfRainbows() < 1)
|
||||
{
|
||||
// Pick x/y
|
||||
int tryX = GameServer.RandomNumberGenerator.Next(0, Map.Width);
|
||||
int tryY = GameServer.RandomNumberGenerator.Next(0, Map.Height);
|
||||
|
||||
if (!Map.CheckPassable(tryX, tryY)) // can the player walk here?
|
||||
continue;
|
||||
|
||||
if (World.InTown(tryX, tryY)) // in a town?
|
||||
continue;
|
||||
|
||||
if (Map.GetTileId(tryX, tryY, true) != 1) // is there allready an overlay here?
|
||||
continue;
|
||||
|
||||
if (Map.TerrainTiles[Map.GetTileId(tryX, tryY, false) - 1].Type != "GRASS" && Map.TerrainTiles[Map.GetTileId(tryX, tryY, false) - 1].Type != "BEACH") // Grass and BEACH tiles only.
|
||||
continue;
|
||||
|
||||
// Create Treasure
|
||||
Treasure treasure = new Treasure(tryX, tryY, "RAINBOW");
|
||||
treasures.Add(treasure);
|
||||
Database.AddTreasure(treasure.RandomId, treasure.X, treasure.Y, treasure.Value, treasure.Type);
|
||||
|
||||
Logger.DebugPrint("Created Pot of Gold at " + treasure.X + "," + treasure.Y + " with value: " + treasure.Value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
Treasure[] treasuresLst = Database.GetTreasures();
|
||||
foreach (Treasure treasure in treasuresLst)
|
||||
{
|
||||
treasures.Add(treasure);
|
||||
}
|
||||
|
||||
GenerateTreasure();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue