mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-23 05:05:53 +12:00
Fix various things.
This commit is contained in:
parent
46c45eb8bb
commit
8a6a5ef36c
34 changed files with 1058 additions and 24 deletions
|
@ -43,6 +43,19 @@ namespace HISP.Game.Chat
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (args[0] == "QUEST")
|
||||
{
|
||||
int questId = 0;
|
||||
try
|
||||
{
|
||||
questId = int.Parse(args[1]);
|
||||
Quest.ActivateQuest(user, Quest.GetQuestById(questId));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
|
@ -173,6 +174,12 @@ namespace HISP.Game
|
|||
public static string GameHighScoreHeaderFormat;
|
||||
public static string GameHighScoreFormat;
|
||||
|
||||
// Awards
|
||||
|
||||
public static string AwardHeader;
|
||||
public static string NoAwards;
|
||||
public static string AwardFormat;
|
||||
|
||||
|
||||
// Shop
|
||||
public static string ThingsIAmSelling;
|
||||
|
@ -240,6 +247,11 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatAwardEntry(int iconId, string title, int moneyBonus)
|
||||
{
|
||||
return AwardFormat.Replace("%ICON%", iconId.ToString()).Replace("%NAME%", title).Replace("%BONUS%", moneyBonus.ToString("N0"));
|
||||
}
|
||||
|
||||
public static string FormatBestTimeHeader(string gameName)
|
||||
{
|
||||
return GameBestTimeHeaderFormat.Replace("%GAMETITLE%", gameName);
|
||||
|
@ -278,7 +290,9 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatQuestFooter(int totalQuestsComplete, int totalQuests, int questPoints, int totalQuestPoints)
|
||||
{
|
||||
return QuestFooterFormat.Replace("%TOTALCOMPLETED%", totalQuestsComplete.ToString("N0")).Replace("%TOTALQUESTS%", totalQuests.ToString("N0")).Replace("%TOTALPERCENT%", ((totalQuestsComplete / totalQuests) * 100).ToString()).Replace("%YOURQP%", questPoints.ToString("N0")).Replace("%YOURQP%", totalQuestPoints.ToString("N0")).Replace("%QPERCENT%", ((totalQuestsComplete / totalQuests) * 100).ToString()).Replace("%MAXQP%", totalQuestPoints.ToString("N0"));
|
||||
int questsComplete = Convert.ToInt32(Math.Floor(((decimal)totalQuestsComplete / (decimal)totalQuests) * (decimal)100.0));
|
||||
int questPointsComplete = Convert.ToInt32(Math.Floor(((decimal)questPoints / (decimal)totalQuestPoints) * (decimal)100.0));
|
||||
return QuestFooterFormat.Replace("%TOTALCOMPLETED%", totalQuestsComplete.ToString("N0")).Replace("%TOTALQUESTS%", totalQuests.ToString("N0")).Replace("%TOTALPERCENT%", questsComplete.ToString()).Replace("%YOURQP%", questPoints.ToString("N0")).Replace("%YOURQP%", totalQuestPoints.ToString("N0")).Replace("%QPERCENT%", questPointsComplete.ToString()).Replace("%MAXQP%", totalQuestPoints.ToString("N0"));
|
||||
}
|
||||
public static string FormatQuestLogQuest(string questTitle, int questPoints, string difficulty, string completionStatus)
|
||||
{
|
||||
|
@ -429,7 +443,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatShopEntry(int iconid, string count, string name, int price)
|
||||
{
|
||||
return ShopEntryFormat.Replace("%ICONID%", iconid.ToString()).Replace("%COUNT%", count).Replace("%TITLE%", name).Replace("%PRICE%", price.ToString());
|
||||
return ShopEntryFormat.Replace("%ICONID%", iconid.ToString()).Replace("%COUNT%", count).Replace("%TITLE%", name).Replace("%PRICE%", price.ToString("N0"));
|
||||
}
|
||||
public static string FormatWearButton(int randomId)
|
||||
{
|
||||
|
|
|
@ -323,7 +323,6 @@ namespace HISP.Game
|
|||
Transport.TransportLocation transportLocation = Transport.GetTransportLocation(transportLocationId);
|
||||
message += Messages.FormatTransportMessage(transportLocation.Type, transportLocation.LocationTitle, transportLocation.Cost, transportLocation.Id, transportLocation.GotoX, transportLocation.GotoY);
|
||||
}
|
||||
message += "^R1";
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
|
@ -358,6 +357,22 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
public static string BuildAwardList(User user)
|
||||
{
|
||||
string message = Messages.AwardHeader;
|
||||
if (user.Awards.AwardsEarned.Length <= 0)
|
||||
message += Messages.NoAwards;
|
||||
else
|
||||
foreach(Award.AwardEntry award in user.Awards.AwardsEarned)
|
||||
message += Messages.FormatAwardEntry(award.IconId, award.Title, award.MoneyBonus);
|
||||
|
||||
|
||||
|
||||
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildQuestLog(User user)
|
||||
{
|
||||
string message = "";
|
||||
|
@ -382,14 +397,8 @@ namespace HISP.Game
|
|||
message += Messages.FormatQuestLogQuest(quest.Title, quest.QuestPointsEarned, quest.Difficulty, fmsg);
|
||||
}
|
||||
|
||||
int totalComplete = 0;
|
||||
int totalQuestPoints = 0;
|
||||
foreach(Quest.QuestEntry quest in questList)
|
||||
{
|
||||
if(user.Quests.GetTrackedQuestAmount(quest.Id) > 0)
|
||||
totalComplete++;
|
||||
totalQuestPoints += quest.QuestPointsEarned;
|
||||
}
|
||||
int totalComplete = Quest.GetTotalQuestsComplete(user);
|
||||
int totalQuestPoints = Quest.GetTotalQuestPoints();
|
||||
|
||||
message += Messages.FormatQuestFooter(totalComplete, questList.Length, user.QuestPoints, totalQuestPoints);
|
||||
message += Messages.BackToMap;
|
||||
|
@ -434,7 +443,7 @@ namespace HISP.Game
|
|||
if (TileCode == "TRANSPORT")
|
||||
{
|
||||
Transport.TransportPoint point = Transport.GetTransportPoint(specialTile.X, specialTile.Y);
|
||||
message += Meta.BuildTransportInfo(point) + "^R1";
|
||||
message += Meta.BuildTransportInfo(point);
|
||||
}
|
||||
|
||||
if (TileCode == "STRAWPILE")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
|
@ -70,6 +71,21 @@ namespace HISP.Game
|
|||
}
|
||||
return totalQp;
|
||||
}
|
||||
|
||||
|
||||
public static int GetTotalQuestsComplete(User user)
|
||||
{
|
||||
QuestEntry[] questList = GetPublicQuestList();
|
||||
int totalComplete = 0;
|
||||
foreach (QuestEntry quest in questList)
|
||||
{
|
||||
if (user.Quests.GetTrackedQuestAmount(quest.Id) > 0)
|
||||
totalComplete++;
|
||||
}
|
||||
return totalComplete;
|
||||
}
|
||||
|
||||
|
||||
public static QuestEntry[] GetPublicQuestList()
|
||||
{
|
||||
QuestEntry[] quests = QuestList.OrderBy(o => o.Title).ToArray();
|
||||
|
@ -104,6 +120,11 @@ namespace HISP.Game
|
|||
|
||||
}
|
||||
|
||||
// Check if user has award unlocked
|
||||
if(quest.AwardRequired != 0)
|
||||
if (!user.Awards.HasAward(Award.GetAwardById(quest.AwardRequired)))
|
||||
return false;
|
||||
|
||||
// Check if i have required items
|
||||
foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
|
||||
{
|
||||
|
@ -180,6 +201,26 @@ namespace HISP.Game
|
|||
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 {
|
||||
|
@ -193,6 +234,7 @@ namespace HISP.Game
|
|||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
public static bool DoesQuestExist(int id)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue