mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-21 04:07:48 +00:00
Added completed quest sendback.
This commit is contained in:
parent
306f4ef346
commit
c677479a03
6 changed files with 35 additions and 24 deletions
|
@ -176,11 +176,17 @@ namespace Meteor.Common
|
||||||
srcShiftIndx = 0;
|
srcShiftIndx = 0;
|
||||||
destByteIndx++;
|
destByteIndx++;
|
||||||
i += 8;
|
i += 8;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool val = (Data[srcByteIndx] & (1 << srcShiftIndx)) != 0;
|
bool val = (Data[srcByteIndx] & (1 << srcShiftIndx++)) != 0;
|
||||||
|
|
||||||
curByte |= (byte)((val ? 1 : 0) << destShiftIndx++);
|
curByte |= (byte)((val ? 1 : 0) << destShiftIndx++);
|
||||||
|
if (srcShiftIndx == 8)
|
||||||
|
{
|
||||||
|
srcShiftIndx = 0;
|
||||||
|
srcByteIndx++;
|
||||||
|
}
|
||||||
if (destShiftIndx == 8)
|
if (destShiftIndx == 8)
|
||||||
{
|
{
|
||||||
toReturn[destByteIndx++] = curByte;
|
toReturn[destByteIndx++] = curByte;
|
||||||
|
|
|
@ -245,7 +245,7 @@ namespace Meteor.Common
|
||||||
{
|
{
|
||||||
for (var bitCount = 0; bitCount < 8; bitCount++)
|
for (var bitCount = 0; bitCount < 8; bitCount++)
|
||||||
{
|
{
|
||||||
if (i + bitCount >= array.Length)
|
if (i + bitCount >= array.Length - 1)
|
||||||
break;
|
break;
|
||||||
data[dataCounter] = (byte)(((array[i + bitCount] ? 1 : 0) << 7 - bitCount) | data[dataCounter]);
|
data[dataCounter] = (byte)(((array[i + bitCount] ? 1 : 0) << 7 - bitCount) | data[dataCounter]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ function onTrigger(player, argc, command, var1, var2, var3)
|
||||||
|
|
||||||
local flagStr = "";
|
local flagStr = "";
|
||||||
for i=0,31,1 do
|
for i=0,31,1 do
|
||||||
if (quest:GetFlag(i)) then
|
if (quest:GetData():GetFlag(i)) then
|
||||||
flagStr = flagStr .. "O";
|
flagStr = flagStr .. "O";
|
||||||
else
|
else
|
||||||
flagStr = flagStr .. "X";
|
flagStr = flagStr .. "X";
|
||||||
|
@ -76,10 +76,12 @@ function onTrigger(player, argc, command, var1, var2, var3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local data = quest:GetData();
|
||||||
|
|
||||||
message = string.format("\nInfo for quest %s [%d]\n", quest.Name, quest:GetQuestId());
|
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("Current Sequence: %d\n", quest:getSequence());
|
||||||
message = message .. string.format("Flags: \n%s\n", flagStr)
|
message = message .. string.format("Flags: \n%s\n", flagStr)
|
||||||
message = message .. string.format("Counters: %d,%d,%d,%d", quest:getCounter(0), quest:getCounter(1), quest:getCounter(2), quest:getCounter(3));
|
message = message .. string.format("Counters: %d,%d,%d,%d", data:getCounter(0), data:getCounter(1), data:getCounter(2), data:getCounter(3));
|
||||||
else
|
else
|
||||||
message = ("Quest not active: "..var1);
|
message = ("Quest not active: "..var1);
|
||||||
end
|
end
|
||||||
|
@ -118,7 +120,7 @@ function onTrigger(player, argc, command, var1, var2, var3)
|
||||||
boolvar = false;
|
boolvar = false;
|
||||||
elseif var3 == "flip" or var3 == "toggle" then
|
elseif var3 == "flip" or var3 == "toggle" then
|
||||||
if player:HasQuest(questvar) == true then
|
if player:HasQuest(questvar) == true then
|
||||||
boolvar = not player:GetQuest(questvar):GetFlag(flagvar);
|
boolvar = not player:GetQuest(questvar):GetData():GetFlag(flagvar);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
message = ("error: flag: boolean not recognized");
|
message = ("error: flag: boolean not recognized");
|
||||||
|
@ -126,13 +128,13 @@ function onTrigger(player, argc, command, var1, var2, var3)
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
var4 = player:GetQuest(questvar):GetFlag(flagvar);
|
var4 = player:GetQuest(questvar):GetData():GetFlag(flagvar);
|
||||||
|
|
||||||
if var4 ~= boolvar then
|
if var4 ~= boolvar then
|
||||||
if (boolvar == true) then
|
if (boolvar == true) then
|
||||||
player:GetQuest(questvar):SetFlag(flagvar);
|
player:GetQuest(questvar):GetData():SetFlag(flagvar);
|
||||||
else
|
else
|
||||||
player:GetQuest(questvar):ClearFlag(flagvar);
|
player:GetQuest(questvar):GetData():ClearFlag(flagvar);
|
||||||
end
|
end
|
||||||
player:GetQuest(questvar):UpdateENPCs();
|
player:GetQuest(questvar):UpdateENPCs();
|
||||||
player:GetQuest(questvar):SaveData();
|
player:GetQuest(questvar):SaveData();
|
||||||
|
@ -152,7 +154,7 @@ function onTrigger(player, argc, command, var1, var2, var3)
|
||||||
questvar = tonumber(var1);
|
questvar = tonumber(var1);
|
||||||
index = (tonumber(var2));
|
index = (tonumber(var2));
|
||||||
|
|
||||||
player:GetQuest(questvar):SetCounter(index, tonumber(var3));
|
player:GetQuest(questvar):GetData():SetCounter(index, tonumber(var3));
|
||||||
player:GetQuest(questvar):UpdateENPCs();
|
player:GetQuest(questvar):UpdateENPCs();
|
||||||
player:GetQuest(questvar):SaveData();
|
player:GetQuest(questvar):SaveData();
|
||||||
message = ("changing counter "..tonumber(var2).." to "..var3);
|
message = ("changing counter "..tonumber(var2).." to "..var3);
|
||||||
|
|
|
@ -1170,7 +1170,6 @@ namespace Meteor.Map.Actors
|
||||||
private void SendCompletedQuests(ushort from, ushort to)
|
private void SendCompletedQuests(ushort from, ushort to)
|
||||||
{
|
{
|
||||||
Bitstream completed = questStateManager.GetCompletedBitstream();
|
Bitstream completed = questStateManager.GetCompletedBitstream();
|
||||||
completed.SetAll(true);
|
|
||||||
byte[] data = completed.GetSlice(from, to);
|
byte[] data = completed.GetSlice(from, to);
|
||||||
|
|
||||||
SetActorPropetyPacket completedQuestWorkUpdate = new SetActorPropetyPacket(from, to, "playerWork/journal");
|
SetActorPropetyPacket completedQuestWorkUpdate = new SetActorPropetyPacket(from, to, "playerWork/journal");
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
private ushort currentSequence;
|
private ushort currentSequence;
|
||||||
private QuestState questState = null;
|
private QuestState questState = null;
|
||||||
private QuestData data = null;
|
private QuestData data = null;
|
||||||
private bool dataDirty = false;
|
|
||||||
|
|
||||||
// Creates a Static Quest for the StaticActors list.
|
// Creates a Static Quest for the StaticActors list.
|
||||||
public Quest(uint actorID, string className, string classPath)
|
public Quest(uint actorID, string className, string classPath)
|
||||||
|
@ -124,11 +123,11 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
|
|
||||||
public void UpdateENPCs()
|
public void UpdateENPCs()
|
||||||
{
|
{
|
||||||
if (dataDirty)
|
if (data.Dirty)
|
||||||
{
|
{
|
||||||
if (questState != null)
|
if (questState != null)
|
||||||
questState.UpdateState();
|
questState.UpdateState();
|
||||||
dataDirty = false;
|
data.ClearDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +199,6 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
owner.SendGameMessage(Server.GetWorldManager().GetActor(), 25116, 0x20, (object)GetQuestId());
|
owner.SendGameMessage(Server.GetWorldManager().GetActor(), 25116, 0x20, (object)GetQuestId());
|
||||||
|
|
||||||
currentSequence = sequence;
|
currentSequence = sequence;
|
||||||
dataDirty = true;
|
|
||||||
questState.UpdateState();
|
questState.UpdateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
private ushort counter2;
|
private ushort counter2;
|
||||||
private ushort counter3;
|
private ushort counter3;
|
||||||
private ushort counter4;
|
private ushort counter4;
|
||||||
private bool dataDirty = false;
|
|
||||||
|
public bool Dirty { get; private set; } = false;
|
||||||
|
|
||||||
public QuestData(Player owner, Quest parent, uint flags, ushort counter1, ushort counter2, ushort counter3, ushort counter4)
|
public QuestData(Player owner, Quest parent, uint flags, ushort counter1, ushort counter2, ushort counter3, ushort counter4)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +47,7 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
if (index >= 0 && index < 32)
|
if (index >= 0 && index < 32)
|
||||||
{
|
{
|
||||||
flags |= (uint)(1 << index);
|
flags |= (uint)(1 << index);
|
||||||
dataDirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,13 +56,13 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
if (index >= 0 && index < 32)
|
if (index >= 0 && index < 32)
|
||||||
{
|
{
|
||||||
flags &= (uint)~(1 << index);
|
flags &= (uint)~(1 << index);
|
||||||
dataDirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ushort IncCounter(int num)
|
public ushort IncCounter(int num)
|
||||||
{
|
{
|
||||||
dataDirty = true;
|
Dirty = true;
|
||||||
|
|
||||||
switch (num)
|
switch (num)
|
||||||
{
|
{
|
||||||
|
@ -79,13 +80,13 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
return counter4;
|
return counter4;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDirty = false;
|
Dirty = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ushort DecCounter(int num)
|
public ushort DecCounter(int num)
|
||||||
{
|
{
|
||||||
dataDirty = true;
|
Dirty = true;
|
||||||
|
|
||||||
switch (num)
|
switch (num)
|
||||||
{
|
{
|
||||||
|
@ -103,13 +104,13 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
return counter4;
|
return counter4;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDirty = false;
|
Dirty = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCounter(int num, ushort value)
|
public void SetCounter(int num, ushort value)
|
||||||
{
|
{
|
||||||
dataDirty = true;
|
Dirty = true;
|
||||||
|
|
||||||
switch (num)
|
switch (num)
|
||||||
{
|
{
|
||||||
|
@ -127,7 +128,7 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDirty = false;
|
Dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetFlag(int index)
|
public bool GetFlag(int index)
|
||||||
|
@ -159,6 +160,11 @@ namespace Meteor.Map.Actors.QuestNS
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearDirty()
|
||||||
|
{
|
||||||
|
Dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
Database.UpdateQuest(owner, parent);
|
Database.UpdateQuest(owner, parent);
|
||||||
|
|
Loading…
Add table
Reference in a new issue