mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 21:55:42 +12:00
Implement password tiles & venus fly trap in jungle isle.
This commit is contained in:
parent
b939c9e142
commit
4c7a9c8ed1
7 changed files with 181 additions and 89 deletions
|
@ -1 +1,4 @@
|
||||||
bank total @ 1/01/2021 : 14,961
|
bank total @ 1/01/2021 : 14,961
|
||||||
|
bank total @ 1/01/2021 : 15,070
|
||||||
|
|
||||||
|
You made $108 in interest since your last visit.
|
|
@ -127,6 +127,8 @@
|
||||||
"back_to_map":"^M",
|
"back_to_map":"^M",
|
||||||
"long_full_line":"^L",
|
"long_full_line":"^L",
|
||||||
"fountain":"Although it's not recommended, you could drink from this fountain if you are thirsty...^T6Drink from the public fountain. ^B1D^R1^X^Z",
|
"fountain":"Although it's not recommended, you could drink from this fountain if you are thirsty...^T6Drink from the public fountain. ^B1D^R1^X^Z",
|
||||||
|
"venus_flytrap_format":"The Giant Venus Flytrap chomped at you!<BR><B>OUCH!!</B><BR>It chomped your pocket, taking $%MONEY% with it!!",
|
||||||
|
"password_input":"<BR>^PLReply:|^PS14|ANSWER^R1",
|
||||||
"bank":{
|
"bank":{
|
||||||
"made_interest":"^LYou made $%MONEY% in interest since your last visit.^R1",
|
"made_interest":"^LYou made $%MONEY% in interest since your last visit.^R1",
|
||||||
"carrying_message":"^L(You are carrying $%MONEY% and have $%BANKMONEY% in the bank.)^R1",
|
"carrying_message":"^L(You are carrying $%MONEY% and have $%BANKMONEY% in the bank.)^R1",
|
||||||
|
|
|
@ -296,6 +296,8 @@ namespace HISP.Game
|
||||||
|
|
||||||
public static string TileFormat;
|
public static string TileFormat;
|
||||||
public static string Seperator;
|
public static string Seperator;
|
||||||
|
public static string VenusFlyTrapFormat;
|
||||||
|
public static string PasswordEntry;
|
||||||
|
|
||||||
public static string ExitThisPlace;
|
public static string ExitThisPlace;
|
||||||
public static string BackToMap;
|
public static string BackToMap;
|
||||||
|
@ -329,6 +331,10 @@ namespace HISP.Game
|
||||||
// Click
|
// Click
|
||||||
public static string NothingInterestingHere;
|
public static string NothingInterestingHere;
|
||||||
|
|
||||||
|
public static string FormatVenusFlyTrapMeta(int money)
|
||||||
|
{
|
||||||
|
return VenusFlyTrapFormat.Replace("%MONEY%", money.ToString("N0"));
|
||||||
|
}
|
||||||
public static string FormatBankIntrestMadeMeta(UInt64 intrestMade)
|
public static string FormatBankIntrestMadeMeta(UInt64 intrestMade)
|
||||||
{
|
{
|
||||||
return BankMadeInIntrestFormat.Replace("%MONEY%", intrestMade.ToString("N0"));
|
return BankMadeInIntrestFormat.Replace("%MONEY%", intrestMade.ToString("N0"));
|
||||||
|
|
|
@ -252,7 +252,14 @@ namespace HISP.Game
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
public static string buildVenusFlyTrap(User user)
|
||||||
|
{
|
||||||
|
int moneyLost = GameServer.RandomNumberGenerator.Next(0, 100);
|
||||||
|
if (moneyLost > user.Money)
|
||||||
|
moneyLost = user.Money;
|
||||||
|
user.Money -= moneyLost;
|
||||||
|
return Messages.FormatVenusFlyTrapMeta(moneyLost);
|
||||||
|
}
|
||||||
public static string buildInn(Inn inn)
|
public static string buildInn(Inn inn)
|
||||||
{
|
{
|
||||||
string message = Messages.InnBuyMeal;
|
string message = Messages.InnBuyMeal;
|
||||||
|
@ -593,7 +600,10 @@ namespace HISP.Game
|
||||||
{
|
{
|
||||||
return Messages.FountainMeta;
|
return Messages.FountainMeta;
|
||||||
}
|
}
|
||||||
|
private static string buildPassword()
|
||||||
|
{
|
||||||
|
return Messages.PasswordEntry + Messages.ExitThisPlace + Messages.MetaTerminator;
|
||||||
|
}
|
||||||
private static string buildBank(User user)
|
private static string buildBank(User user)
|
||||||
{
|
{
|
||||||
double moneyMade = 0;
|
double moneyMade = 0;
|
||||||
|
@ -686,6 +696,14 @@ namespace HISP.Game
|
||||||
{
|
{
|
||||||
message += buildWishingWell(user);
|
message += buildWishingWell(user);
|
||||||
}
|
}
|
||||||
|
if(TileCode == "VENUSFLYTRAP")
|
||||||
|
{
|
||||||
|
message += buildVenusFlyTrap(user);
|
||||||
|
}
|
||||||
|
if(TileCode == "PASSWORD")
|
||||||
|
{
|
||||||
|
message += buildPassword();
|
||||||
|
}
|
||||||
if(TileCode == "INN")
|
if(TileCode == "INN")
|
||||||
{
|
{
|
||||||
int InnID = int.Parse(TileArg);
|
int InnID = int.Parse(TileArg);
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace HISP.Game
|
||||||
{
|
{
|
||||||
int totalQp = 0;
|
int totalQp = 0;
|
||||||
QuestEntry[] quests = GetPublicQuestList();
|
QuestEntry[] quests = GetPublicQuestList();
|
||||||
foreach(QuestEntry quest in quests)
|
foreach (QuestEntry quest in quests)
|
||||||
{
|
{
|
||||||
totalQp += quest.QuestPointsEarned;
|
totalQp += quest.QuestPointsEarned;
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,8 @@ namespace HISP.Game
|
||||||
|
|
||||||
// Has completed other required quests?
|
// Has completed other required quests?
|
||||||
foreach (int questId in quest.RequiresQuestIdCompleted)
|
foreach (int questId in quest.RequiresQuestIdCompleted)
|
||||||
if (user.Quests.GetTrackedQuestAmount(quest.Id) < 1)
|
if (user.Quests.GetTrackedQuestAmount(quest.Id) < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Has NOT competed other MUST NOT BE required quests
|
// Has NOT competed other MUST NOT BE required quests
|
||||||
foreach (int questId in quest.RequiresQuestIdNotCompleted)
|
foreach (int questId in quest.RequiresQuestIdNotCompleted)
|
||||||
|
@ -122,7 +122,7 @@ namespace HISP.Game
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user has award unlocked
|
// Check if user has award unlocked
|
||||||
if(quest.AwardRequired != 0)
|
if (quest.AwardRequired != 0)
|
||||||
if (!user.Awards.HasAward(Award.GetAwardById(quest.AwardRequired)))
|
if (!user.Awards.HasAward(Award.GetAwardById(quest.AwardRequired)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -151,90 +151,101 @@ namespace HISP.Game
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CompleteQuest(User user, QuestEntry quest, bool npcActivation = false)
|
||||||
|
{
|
||||||
|
// Take Items
|
||||||
|
foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
|
||||||
|
{
|
||||||
|
InventoryItem itm = user.Inventory.GetItemByItemId(itemInfo.ItemId);
|
||||||
|
for (int i = 0; i < itemInfo.Quantity; i++)
|
||||||
|
user.Inventory.Remove(itm.ItemInstances[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
user.Money -= quest.MoneyCost;
|
||||||
|
// Give money
|
||||||
|
user.Money += quest.MoneyEarned;
|
||||||
|
// Give items
|
||||||
|
foreach (QuestItemInfo itemInfo in quest.ItemsEarned)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < itemInfo.Quantity; i++)
|
||||||
|
{
|
||||||
|
ItemInstance itm = new ItemInstance(itemInfo.ItemId);
|
||||||
|
user.Inventory.AddIgnoringFull(itm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (quest.WarpX != 0 && quest.WarpY != 0)
|
||||||
|
user.Teleport(quest.WarpX, quest.WarpY);
|
||||||
|
|
||||||
|
// Give quest points
|
||||||
|
user.QuestPoints += quest.QuestPointsEarned;
|
||||||
|
|
||||||
|
if (quest.ChainedQuestId != 0)
|
||||||
|
ActivateQuest(user, GetQuestById(quest.ChainedQuestId));
|
||||||
|
|
||||||
|
if (quest.Tracked)
|
||||||
|
user.Quests.TrackQuest(quest.Id);
|
||||||
|
|
||||||
|
|
||||||
|
if (quest.SuccessMessage != null)
|
||||||
|
{
|
||||||
|
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
user.LoggedinClient.SendPacket(ChatPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quest.SuccessNpcChat != null)
|
||||||
|
{
|
||||||
|
if (!npcActivation)
|
||||||
|
{
|
||||||
|
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessNpcChat, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
user.LoggedinClient.SendPacket(ChatPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Check if award unlocked
|
||||||
|
int questPointsPercent = Convert.ToInt32(Math.Floor(((decimal)user.QuestPoints / (decimal)GetTotalQuestPoints()) * (decimal)100.0));
|
||||||
|
if (questPointsPercent >= 25)
|
||||||
|
user.Awards.AddAward(Award.GetAwardById(1)); // 25% Quest Completion Award.
|
||||||
|
if (questPointsPercent >= 50)
|
||||||
|
user.Awards.AddAward(Award.GetAwardById(2)); // 50% Quest Completion Award.
|
||||||
|
if (questPointsPercent >= 75)
|
||||||
|
user.Awards.AddAward(Award.GetAwardById(3)); // 75% Quest Completion Award.
|
||||||
|
if (questPointsPercent >= 100)
|
||||||
|
user.Awards.AddAward(Award.GetAwardById(4)); // 100% Quest Completion Award.
|
||||||
|
|
||||||
|
// Is cloud isles quest?
|
||||||
|
if (quest.Id == 1373)
|
||||||
|
{
|
||||||
|
byte[] swfLoadPacket = PacketBuilder.CreateSwfModulePacket("ballooncutscene", PacketBuilder.PACKET_SWF_CUTSCENE);
|
||||||
|
user.LoggedinClient.SendPacket(swfLoadPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public static bool FailQuest(User user, QuestEntry quest, bool npcActivation = false)
|
||||||
|
{
|
||||||
|
if (quest.FailNpcChat != null)
|
||||||
|
{
|
||||||
|
if (!npcActivation)
|
||||||
|
{
|
||||||
|
byte[] ChatPacket = PacketBuilder.CreateChat(quest.FailNpcChat, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
user.LoggedinClient.SendPacket(ChatPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public static bool ActivateQuest(User user, QuestEntry quest, bool npcActivation = false)
|
public static bool ActivateQuest(User user, QuestEntry quest, bool npcActivation = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(CanComplete(user, quest))
|
if (CanComplete(user, quest))
|
||||||
{
|
{
|
||||||
// Take Items
|
return CompleteQuest(user, quest, npcActivation);
|
||||||
foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
|
}
|
||||||
{
|
else
|
||||||
InventoryItem itm = user.Inventory.GetItemByItemId(itemInfo.ItemId);
|
{
|
||||||
for (int i = 0; i < itemInfo.Quantity; i++)
|
return FailQuest(user, quest, npcActivation);
|
||||||
user.Inventory.Remove(itm.ItemInstances[0]);
|
|
||||||
|
|
||||||
}
|
|
||||||
user.Money -= quest.MoneyCost;
|
|
||||||
// Give money
|
|
||||||
user.Money += quest.MoneyEarned;
|
|
||||||
// Give items
|
|
||||||
foreach (QuestItemInfo itemInfo in quest.ItemsEarned)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < itemInfo.Quantity; i++)
|
|
||||||
{
|
|
||||||
ItemInstance itm = new ItemInstance(itemInfo.ItemId);
|
|
||||||
user.Inventory.AddIgnoringFull(itm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.WarpX != 0 && quest.WarpY != 0)
|
|
||||||
user.Teleport(quest.WarpX, quest.WarpY);
|
|
||||||
|
|
||||||
// Give quest points
|
|
||||||
user.QuestPoints += quest.QuestPointsEarned;
|
|
||||||
|
|
||||||
if (quest.ChainedQuestId != 0)
|
|
||||||
ActivateQuest(user, GetQuestById(quest.ChainedQuestId));
|
|
||||||
|
|
||||||
if (quest.Tracked)
|
|
||||||
user.Quests.TrackQuest(quest.Id);
|
|
||||||
|
|
||||||
if (quest.SuccessNpcChat != null)
|
|
||||||
{
|
|
||||||
if (!npcActivation)
|
|
||||||
{
|
|
||||||
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessNpcChat, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
|
||||||
user.LoggedinClient.SendPacket(ChatPacket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quest.SuccessMessage != null)
|
|
||||||
{
|
|
||||||
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
|
||||||
user.LoggedinClient.SendPacket(ChatPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Check if award unlocked
|
|
||||||
int questPointsPercent = Convert.ToInt32(Math.Floor(((decimal)user.QuestPoints / (decimal)GetTotalQuestPoints()) * (decimal)100.0));
|
|
||||||
if (questPointsPercent >= 25)
|
|
||||||
user.Awards.AddAward(Award.GetAwardById(1)); // 25% Quest Completion Award.
|
|
||||||
if (questPointsPercent >= 50)
|
|
||||||
user.Awards.AddAward(Award.GetAwardById(2)); // 50% Quest Completion Award.
|
|
||||||
if (questPointsPercent >= 75)
|
|
||||||
user.Awards.AddAward(Award.GetAwardById(3)); // 75% Quest Completion Award.
|
|
||||||
if (questPointsPercent >= 100)
|
|
||||||
user.Awards.AddAward(Award.GetAwardById(4)); // 100% Quest Completion Award.
|
|
||||||
|
|
||||||
// Is cloud isles quest?
|
|
||||||
if(quest.Id == 1373)
|
|
||||||
{
|
|
||||||
byte[] swfLoadPacket = PacketBuilder.CreateSwfModulePacket("ballooncutscene", PacketBuilder.PACKET_SWF_CUTSCENE);
|
|
||||||
user.LoggedinClient.SendPacket(swfLoadPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if(quest.FailNpcChat != null)
|
|
||||||
{
|
|
||||||
if(!npcActivation)
|
|
||||||
{
|
|
||||||
byte[] ChatPacket = PacketBuilder.CreateChat(quest.FailNpcChat, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
|
||||||
user.LoggedinClient.SendPacket(ChatPacket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public static bool DoesQuestExist(int id)
|
public static bool DoesQuestExist(int id)
|
||||||
|
|
|
@ -674,6 +674,9 @@ namespace HISP.Server
|
||||||
Messages.NoPitchforkMeta = gameData.messages.meta.hay_pile.no_pitchfork;
|
Messages.NoPitchforkMeta = gameData.messages.meta.hay_pile.no_pitchfork;
|
||||||
Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork;
|
Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork;
|
||||||
|
|
||||||
|
Messages.PasswordEntry = gameData.messages.meta.password_input;
|
||||||
|
Messages.VenusFlyTrapFormat = gameData.messages.meta.venus_flytrap_format;
|
||||||
|
|
||||||
// Inn
|
// Inn
|
||||||
Messages.InnBuyMeal = gameData.messages.meta.inn.buy_meal;
|
Messages.InnBuyMeal = gameData.messages.meta.inn.buy_meal;
|
||||||
Messages.InnBuyRest = gameData.messages.meta.inn.buy_rest;
|
Messages.InnBuyRest = gameData.messages.meta.inn.buy_rest;
|
||||||
|
|
|
@ -193,6 +193,55 @@ namespace HISP.Server
|
||||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 14:
|
||||||
|
if(dynamicInput.Length >= 1)
|
||||||
|
{
|
||||||
|
string password = dynamicInput[1];
|
||||||
|
// Get current tile
|
||||||
|
if(World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||||
|
{
|
||||||
|
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||||
|
if(tile.Code.StartsWith("PASSWORD-"))
|
||||||
|
{
|
||||||
|
string[] args = tile.Code.Replace("!","-").Split('-');
|
||||||
|
if(args.Length >= 3)
|
||||||
|
{
|
||||||
|
string expectedPassword = args[1];
|
||||||
|
int questId = int.Parse(args[2]);
|
||||||
|
if(password.ToLower() == expectedPassword.ToLower())
|
||||||
|
{
|
||||||
|
Quest.CompleteQuest(sender.LoggedinUser, Quest.GetQuestById(questId), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Quest.FailQuest(sender.LoggedinUser, Quest.GetQuestById(questId), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " Send invalid password input request. (Too few arguments!)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " Send password input request. (Not on password tile!)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent a password while not in a special tile.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid password request, (wrong size)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Logger.ErrorPrint("Unknown dynamic input: " + inputId.ToString() + " packet dump: " + BitConverter.ToString(packet).Replace("-", " "));
|
Logger.ErrorPrint("Unknown dynamic input: " + inputId.ToString() + " packet dump: " + BitConverter.ToString(packet).Replace("-", " "));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue