Implement password tiles & venus fly trap in jungle isle.

This commit is contained in:
SilicaAndPina 2021-01-02 12:40:57 +13:00
parent b939c9e142
commit 4c7a9c8ed1
7 changed files with 181 additions and 89 deletions

View file

@ -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.

View file

@ -127,6 +127,8 @@
"back_to_map":"^M",
"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",
"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":{
"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",

View file

@ -296,7 +296,9 @@ namespace HISP.Game
public static string TileFormat;
public static string Seperator;
public static string VenusFlyTrapFormat;
public static string PasswordEntry;
public static string ExitThisPlace;
public static string BackToMap;
public static string LongFullLine;
@ -329,6 +331,10 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatVenusFlyTrapMeta(int money)
{
return VenusFlyTrapFormat.Replace("%MONEY%", money.ToString("N0"));
}
public static string FormatBankIntrestMadeMeta(UInt64 intrestMade)
{
return BankMadeInIntrestFormat.Replace("%MONEY%", intrestMade.ToString("N0"));

View file

@ -252,7 +252,14 @@ namespace HISP.Game
}
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)
{
string message = Messages.InnBuyMeal;
@ -593,7 +600,10 @@ namespace HISP.Game
{
return Messages.FountainMeta;
}
private static string buildPassword()
{
return Messages.PasswordEntry + Messages.ExitThisPlace + Messages.MetaTerminator;
}
private static string buildBank(User user)
{
double moneyMade = 0;
@ -686,6 +696,14 @@ namespace HISP.Game
{
message += buildWishingWell(user);
}
if(TileCode == "VENUSFLYTRAP")
{
message += buildVenusFlyTrap(user);
}
if(TileCode == "PASSWORD")
{
message += buildPassword();
}
if(TileCode == "INN")
{
int InnID = int.Parse(TileArg);

View file

@ -23,7 +23,7 @@ namespace HISP.Game
{
public string Type;
public int ActivateX;
public int ActivateY;
public int ActivateY;
}
public struct QuestEntry
{
@ -66,7 +66,7 @@ namespace HISP.Game
{
int totalQp = 0;
QuestEntry[] quests = GetPublicQuestList();
foreach(QuestEntry quest in quests)
foreach (QuestEntry quest in quests)
{
totalQp += quest.QuestPointsEarned;
}
@ -107,8 +107,8 @@ namespace HISP.Game
// Has completed other required quests?
foreach (int questId in quest.RequiresQuestIdCompleted)
if (user.Quests.GetTrackedQuestAmount(quest.Id) < 1)
return false;
if (user.Quests.GetTrackedQuestAmount(quest.Id) < 1)
return false;
// Has NOT competed other MUST NOT BE required quests
foreach (int questId in quest.RequiresQuestIdNotCompleted)
@ -117,12 +117,12 @@ namespace HISP.Game
// Has allready tracked this quest?
if (user.Quests.GetTrackedQuestAmount(quest.Id) >= quest.MaxRepeats)
return false;
return false;
}
// Check if user has award unlocked
if(quest.AwardRequired != 0)
if (quest.AwardRequired != 0)
if (!user.Awards.HasAward(Award.GetAwardById(quest.AwardRequired)))
return false;
@ -151,90 +151,101 @@ namespace HISP.Game
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)
{
if(CanComplete(user, quest))
if (CanComplete(user, quest))
{
// 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.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;
return CompleteQuest(user, quest, npcActivation);
}
else
{
return FailQuest(user, quest, npcActivation);
}
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)

View file

@ -674,6 +674,9 @@ namespace HISP.Server
Messages.NoPitchforkMeta = gameData.messages.meta.hay_pile.no_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
Messages.InnBuyMeal = gameData.messages.meta.inn.buy_meal;
Messages.InnBuyRest = gameData.messages.meta.inn.buy_rest;

View file

@ -193,6 +193,55 @@ namespace HISP.Server
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
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:
Logger.ErrorPrint("Unknown dynamic input: " + inputId.ToString() + " packet dump: " + BitConverter.ToString(packet).Replace("-", " "));
break;