mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-23 05:05:53 +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
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue