2019-06-19 01:10:15 -04:00
|
|
|
require("global");
|
|
|
|
|
|
|
|
properties = {
|
|
|
|
permissions = 0,
|
|
|
|
parameters = "ssss",
|
|
|
|
description =
|
|
|
|
[[
|
|
|
|
Add/Remove Quests, modify <phase> and <flag 0-32>.
|
|
|
|
!quest add/remove <quest> |
|
|
|
|
!quest phase <quest> <phase> |
|
|
|
|
!quest flag <quest> <flag> true/false |
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
function onTrigger(player, argc, command, var1, var2, var3)
|
|
|
|
|
|
|
|
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
|
|
|
local sender = "[quest] ";
|
|
|
|
local message = "Error";
|
|
|
|
|
2022-02-06 12:12:26 -05:00
|
|
|
print(tostring(argc));
|
2019-06-19 01:10:15 -04:00
|
|
|
if player then
|
|
|
|
if argc == 2 then
|
|
|
|
if command == "add" or command == "give" or command == "+" then
|
|
|
|
if tonumber(var1) then
|
|
|
|
if player:HasQuest(tonumber(var1)) == false then
|
|
|
|
player:AddQuest(tonumber(var1));
|
|
|
|
message = ("adding quest "..var1);
|
|
|
|
else
|
|
|
|
message = ("already have quest "..var1);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if player:HasQuest(var1) == false then
|
|
|
|
player:AddQuest(var1);
|
|
|
|
message = ("adding quest "..var1);
|
|
|
|
else
|
|
|
|
message = ("already have quest "..var1);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif command == "remove" or command == "delete" or command == "-" then
|
|
|
|
if tonumber(var1) and player:HasQuest(tonumber(var1)) == true then
|
2022-02-20 21:30:09 -05:00
|
|
|
player:RemoveQuest(tonumber(var1));
|
2019-06-19 01:10:15 -04:00
|
|
|
message = ("removing quest "..var1);
|
|
|
|
else
|
|
|
|
if player:HasQuest(var1) == true then
|
|
|
|
q2 = GetStaticActor(var1);
|
|
|
|
|
|
|
|
if q2 ~= nil then
|
2022-02-05 18:14:23 -05:00
|
|
|
q3 = q2.Id;
|
2019-06-19 01:10:15 -04:00
|
|
|
message = ("removing quest "..var1);
|
|
|
|
printf(q3);
|
|
|
|
q4 = bit32.band(q3, 0xA0F00000);
|
|
|
|
printf(q4);
|
|
|
|
|
2022-02-20 21:30:09 -05:00
|
|
|
player:RemoveQuest(quest.Name);
|
2019-06-19 01:10:15 -04:00
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("remove error: either incorrect ID or quest "..var1.." isn't active on character");
|
|
|
|
end
|
2022-02-06 12:12:26 -05:00
|
|
|
end
|
|
|
|
elseif command == "info" then
|
|
|
|
if tonumber(var1) then
|
|
|
|
if player:HasQuest(tonumber(var1)) then
|
|
|
|
quest = player:GetQuest(tonumber(var1));
|
|
|
|
|
|
|
|
local flagStr = "";
|
|
|
|
for i=0,31,1 do
|
2022-02-20 12:06:48 -05:00
|
|
|
if (quest:GetData():GetFlag(i)) then
|
2022-02-06 12:12:26 -05:00
|
|
|
flagStr = flagStr .. "O";
|
|
|
|
else
|
|
|
|
flagStr = flagStr .. "X";
|
|
|
|
end
|
|
|
|
if (i == 15) then
|
|
|
|
flagStr = flagStr .. "\n";
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-20 12:06:48 -05:00
|
|
|
local data = quest:GetData();
|
|
|
|
|
2022-02-06 12:12:26 -05:00
|
|
|
message = string.format("\nInfo for quest %s [%d]\n", quest.Name, quest:GetQuestId());
|
|
|
|
message = message .. string.format("Current Sequence: %d\n", quest:getSequence());
|
|
|
|
message = message .. string.format("Flags: \n%s\n", flagStr)
|
2022-02-20 12:06:48 -05:00
|
|
|
message = message .. string.format("Counters: %d,%d,%d,%d", data:getCounter(0), data:getCounter(1), data:getCounter(2), data:getCounter(3));
|
2022-02-06 12:12:26 -05:00
|
|
|
else
|
|
|
|
message = ("Quest not active: "..var1);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("error: invalid parameters used");
|
2019-06-19 01:10:15 -04:00
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("error: command "..command.." not recognized");
|
2022-02-06 12:12:26 -05:00
|
|
|
end
|
2019-06-19 01:10:15 -04:00
|
|
|
elseif argc == 3 then
|
2022-02-06 12:12:26 -05:00
|
|
|
if command == "seq" or command == "sequence" then
|
2019-06-19 01:10:15 -04:00
|
|
|
if (tonumber(var1) and tonumber(var2)) ~= nil then
|
|
|
|
if player:HasQuest(tonumber(var1)) == true then
|
2022-02-06 12:12:26 -05:00
|
|
|
player:GetQuest(tonumber(var1)):StartSequence(tonumber(var2));
|
|
|
|
message = ("changing sequence of quest "..var1.." to "..var2);
|
2019-06-19 01:10:15 -04:00
|
|
|
else
|
2022-02-06 12:12:26 -05:00
|
|
|
message = ("sequence error: either incorrect ID or quest "..var1.." isn't active on character");
|
2019-06-19 01:10:15 -04:00
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("error: invalid parameters used");
|
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("error: command "..command.." not recognized");
|
|
|
|
end;
|
|
|
|
|
|
|
|
elseif argc == 4 then
|
|
|
|
if command == "flag" then
|
|
|
|
if tonumber(var1) and (tonumber(var2) >= 0 and tonumber(var2) <= 32) then
|
|
|
|
questvar = tonumber(var1);
|
|
|
|
flagvar = (tonumber(var2));
|
|
|
|
boolvar = 0;
|
|
|
|
|
2022-02-06 12:12:26 -05:00
|
|
|
if var3 == "true" or var3 == "1" or var3 == "on" or var3 == "O" then
|
2019-06-19 01:10:15 -04:00
|
|
|
boolvar = true;
|
2022-02-06 12:12:26 -05:00
|
|
|
elseif var3 == "false" or var3 == "0" or var3 == "off" or var3 == "X" then
|
2019-06-19 01:10:15 -04:00
|
|
|
boolvar = false;
|
|
|
|
elseif var3 == "flip" or var3 == "toggle" then
|
|
|
|
if player:HasQuest(questvar) == true then
|
2022-02-20 12:06:48 -05:00
|
|
|
boolvar = not player:GetQuest(questvar):GetData():GetFlag(flagvar);
|
2019-06-19 01:10:15 -04:00
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("error: flag: boolean not recognized");
|
|
|
|
print(sender..message);
|
|
|
|
return;
|
|
|
|
end
|
|
|
|
|
2022-02-20 12:06:48 -05:00
|
|
|
var4 = player:GetQuest(questvar):GetData():GetFlag(flagvar);
|
2019-06-19 01:10:15 -04:00
|
|
|
|
|
|
|
if var4 ~= boolvar then
|
2022-02-06 12:12:26 -05:00
|
|
|
if (boolvar == true) then
|
2022-02-20 12:06:48 -05:00
|
|
|
player:GetQuest(questvar):GetData():SetFlag(flagvar);
|
2022-02-06 12:12:26 -05:00
|
|
|
else
|
2022-02-20 12:06:48 -05:00
|
|
|
player:GetQuest(questvar):GetData():ClearFlag(flagvar);
|
2022-02-06 12:12:26 -05:00
|
|
|
end
|
|
|
|
player:GetQuest(questvar):UpdateENPCs();
|
2022-02-20 21:30:09 -05:00
|
|
|
player:GetQuest(questvar):GetData():Save();
|
2019-06-19 01:10:15 -04:00
|
|
|
if boolvar == true then
|
|
|
|
message = ("changing flag "..tonumber(var2).." to true on quest "..questvar);
|
|
|
|
else
|
|
|
|
message = ("changing flag "..tonumber(var2).." to false on quest "..questvar);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("error: flag "..flagvar.." is already set to that state on quest "..questvar);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
message = ("error: command "..command.." not recognized");
|
2022-02-06 12:12:26 -05:00
|
|
|
end
|
|
|
|
elseif command == "counter" then
|
|
|
|
if tonumber(var1) and (tonumber(var2) >= 0 and tonumber(var2) <= 4) then
|
|
|
|
questvar = tonumber(var1);
|
|
|
|
index = (tonumber(var2));
|
|
|
|
|
2022-02-20 12:06:48 -05:00
|
|
|
player:GetQuest(questvar):GetData():SetCounter(index, tonumber(var3));
|
2022-02-06 12:12:26 -05:00
|
|
|
player:GetQuest(questvar):UpdateENPCs();
|
2022-02-20 21:30:09 -05:00
|
|
|
player:GetQuest(questvar):GetData():Save();
|
2022-02-06 12:12:26 -05:00
|
|
|
message = ("changing counter "..tonumber(var2).." to "..var3);
|
|
|
|
else
|
|
|
|
message = ("error: command "..command.." not recognized");
|
2019-06-19 01:10:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
player:SendMessage(messageID, sender, message);
|
|
|
|
print(sender..message);
|
|
|
|
end
|