mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-24 05:37:46 +00:00
Added debug script for setting quest completion
This commit is contained in:
parent
c677479a03
commit
25f1b0fd95
3 changed files with 94 additions and 4 deletions
58
Data/scripts/commands/gm/completedQuest.lua
Normal file
58
Data/scripts/commands/gm/completedQuest.lua
Normal file
|
@ -0,0 +1,58 @@
|
|||
require("global");
|
||||
|
||||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "dd",
|
||||
description =
|
||||
[[
|
||||
Sets if a quest is completed.
|
||||
!completedQuest <questId> true/false
|
||||
]],
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, questId, flag)
|
||||
|
||||
print("HEY");
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
local sender = "[completedQuest] ";
|
||||
local message = "Error";
|
||||
|
||||
if (argc < 1) then
|
||||
return;
|
||||
end
|
||||
|
||||
local questId = tonumber(questId);
|
||||
local flag = flag or nil;
|
||||
|
||||
-- Fail if not valid questId
|
||||
if (questId < 110001 or questId > 110001 + 2048) then
|
||||
player:SendMessage(messageID, sender, "Invalid questId entered");
|
||||
return;
|
||||
end
|
||||
|
||||
-- Getting
|
||||
if (arc == 1) then
|
||||
player:SendMessage(messageID, sender, string.format("Quest %d completion is set to: %s", questId, tostring(player:IsQuestCompleted(questId))));
|
||||
return;
|
||||
-- Setting
|
||||
else
|
||||
-- Fail if not valid flag
|
||||
if (not flag == nil) then
|
||||
player:SendMessage(messageID, sender, "Invalid flag entered");
|
||||
else
|
||||
local boolFlag = false;
|
||||
|
||||
if (flag == "true" or flag == "1" or flag == "on" or flag == "O") then
|
||||
boolFlag = true;
|
||||
elseif (flag == "false" or flag == "0" or flag == "off" or flag == "X") then
|
||||
boolFlag = false;
|
||||
elseif flag == "flip" or flag == "toggle" then
|
||||
boolFlag = not player:IsQuestCompleted(questId);
|
||||
end
|
||||
|
||||
player:SetQuestComplete(questId, boolFlag);
|
||||
player:SendMessage(messageID, sender, string.format("Quest %d completion set to: %s", questId, tostring(player:IsQuestCompleted(questId))));
|
||||
return;
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1169,8 +1169,7 @@ namespace Meteor.Map.Actors
|
|||
|
||||
private void SendCompletedQuests(ushort from, ushort to)
|
||||
{
|
||||
Bitstream completed = questStateManager.GetCompletedBitstream();
|
||||
byte[] data = completed.GetSlice(from, to);
|
||||
byte[] data = questStateManager.GetCompletionSliceBytes(from, to);
|
||||
|
||||
SetActorPropetyPacket completedQuestWorkUpdate = new SetActorPropetyPacket(from, to, "playerWork/journal");
|
||||
completedQuestWorkUpdate.AddBitfield(Utils.MurmurHash2("playerWork.questScenarioComplete", 0), data);
|
||||
|
@ -1661,6 +1660,25 @@ namespace Meteor.Map.Actors
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool IsQuestCompleted(uint id)
|
||||
{
|
||||
return questStateManager.IsQuestComplete(id);
|
||||
}
|
||||
|
||||
public void SetQuestComplete(uint id, bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
Quest currentQuest = GetQuest(id);
|
||||
if (currentQuest != null)
|
||||
{
|
||||
CompleteQuest(currentQuest);
|
||||
return;
|
||||
}
|
||||
}
|
||||
questStateManager.ForceQuestCompleteFlag(id, flag);
|
||||
}
|
||||
|
||||
public Quest GetQuest(uint id)
|
||||
{
|
||||
for (int i = 0; i < questScenario.Length; i++)
|
||||
|
|
|
@ -156,9 +156,23 @@ namespace Meteor.Map.Actors.QuestNS
|
|||
return ActiveQuests.FindAll(quest => quest.IsQuestENPC(player, npc)).ToArray();
|
||||
}
|
||||
|
||||
public Bitstream GetCompletedBitstream()
|
||||
public byte[] GetCompletionSliceBytes(ushort from, ushort to)
|
||||
{
|
||||
return CompletedQuestsBitfield;
|
||||
return CompletedQuestsBitfield.GetSlice(from, to);
|
||||
}
|
||||
|
||||
public bool IsQuestComplete(uint questId)
|
||||
{
|
||||
return CompletedQuestsBitfield.Get(questId - SCENARIO_START);
|
||||
}
|
||||
|
||||
public void ForceQuestCompleteFlag(uint questId, bool flag)
|
||||
{
|
||||
if (flag)
|
||||
CompletedQuestsBitfield.Set(questId - SCENARIO_START);
|
||||
else
|
||||
CompletedQuestsBitfield.Clear(questId - SCENARIO_START);
|
||||
ComputeAvailable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue