Added back loading defaulttalk npcs through script. Should speed up warps now! Added loading mapobj ifno through a db table, removing the need for unique scripts. Deleted ported mapobj scripts.

This commit is contained in:
Filip Maj 2022-03-03 19:34:33 -05:00
parent b773098abf
commit 2cb6a9f6bd
74 changed files with 49 additions and 267 deletions

View File

@ -24,13 +24,6 @@ end
function onEventStarted(player, npc, eventType, eventName) function onEventStarted(player, npc, eventType, eventName)
local chosenQuest = nil; local chosenQuest = nil;
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
print(tostring(eventType));
if (eventType == 1) then if (eventType == 1) then
local defaultTalk = player:GetDefaultTalkQuest(npc); local defaultTalk = player:GetDefaultTalkQuest(npc);
local tutorialTalk = player:GetTutorialQuest(npc); local tutorialTalk = player:GetTutorialQuest(npc);

View File

@ -128,13 +128,13 @@ function onTalk(player, quest, npc, eventName)
player:EndEvent(); player:EndEvent();
end end
function onEmote(player, quest, npc, emoteId, eventName) function onEmote(player, quest, npc, eventName)
local npcClassId = npc.GetActorClassId(); local npcClassId = npc.GetActorClassId();
local seq = quest:GetSequence(); local seq = quest:GetSequence();
local data = quest:GetData(); local data = quest:GetData();
local incCounter = false; local incCounter = false;
if (seq == SEQ_000 and emoteId == 123) then if (seq == SEQ_000 and eventName == "emoteDefault1") then
if (npcClassId == AERGWNYT) then if (npcClassId == AERGWNYT) then
if (not data:GetFlag(FLAG_TALKED_AERGWNYT)) then if (not data:GetFlag(FLAG_TALKED_AERGWNYT)) then
callClientFunction(player, "delegateEvent", player, quest, "processEventAergwynt"); callClientFunction(player, "delegateEvent", player, quest, "processEventAergwynt");

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 0x141, 0xcde;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 0x187, 0x2;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB84;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB83;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB81;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB7D;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x14b, 0x14aa;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB7E;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB80;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB7F;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x141, 0xB82;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x96C;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x96A;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x96D;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x970;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x974;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x972;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x83, 0x1B8E;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x83, 0x1B89;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x83, 0x1B90;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x976;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x954;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x956;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x952;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x958;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x960;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x95A;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x95E;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x95C;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x96D;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x94C;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x94E;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x94A;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x950;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x944;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x946;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x942;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x948;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x968;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x962;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x79, 0x966;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 0xC4, 0x1C8;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 0x187, 0x2;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 5142, 323;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 5143, 323;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 5142, 326;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 5143, 326;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 5145, 252;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 5144, 201;
end

View File

@ -1,7 +0,0 @@
require ("global")
function onEventStarted(player, npc, triggerName)
defaultSrt = GetStaticActor("DftSrt");
callClientFunction(player, "delegateEvent", player, defaultSrt, "defaultTalkWithPilot_001");
player:endEvent();
end

View File

@ -1,7 +0,0 @@
require ("global")
function onEventStarted(player, npc, triggerName)
defaultSrt = GetStaticActor("DftSrt");
callClientFunction(player, "delegateEvent", player, defaultSrt, "defaultTalkWithPilot_001");
player:endEvent();
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFC8;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFC6;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFC7;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0x101D;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFD7;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFCC;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0x101E;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFCB;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFCA;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFC9;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFD9;
end

View File

@ -1,3 +0,0 @@
function init(npc)
return false, false, 0, 0, 0x1A5, 0xFDB;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 0x1af, 0xDC5;
end

View File

@ -1,5 +0,0 @@
require ("global")
function init(npc)
return false, false, 0, 0, 0x1eb, 0x2;
end

View File

@ -517,7 +517,7 @@ namespace Meteor.Map.Actors
if (actorClass == null) if (actorClass == null)
return; return;
Npc npc = new Npc(mActorList.Count + 1, actorClass, location.uniqueId, this, location.x, location.y, location.z, location.rot, 0, location.motionPack, null); Npc npc = new Npc(mActorList.Count + 1, actorClass, location.uniqueId, this, location.x, location.y, location.z, location.rot, 0, location.motionPack, null, location.mapObjLayoutId, location.mapObjInstanceId);
npc.LoadEventConditions(actorClass.eventConditions); npc.LoadEventConditions(actorClass.eventConditions);

View File

@ -34,7 +34,10 @@ namespace Meteor.Map.actors.area
public float rot; public float rot;
public uint motionPack; public uint motionPack;
public SpawnLocation(uint classId, string uniqueId, uint zoneId, string privAreaName, int privAreaLevel, float x, float y, float z, float rot, uint animId) public uint mapObjLayoutId;
public uint mapObjInstanceId;
public SpawnLocation(uint classId, string uniqueId, uint zoneId, string privAreaName, int privAreaLevel, float x, float y, float z, float rot, uint animId, uint mapObjLayoutId, uint mapObjInstanceId)
{ {
this.classId = classId; this.classId = classId;
this.uniqueId = uniqueId; this.uniqueId = uniqueId;
@ -46,6 +49,8 @@ namespace Meteor.Map.actors.area
this.z = z; this.z = z;
this.rot = rot; this.rot = rot;
this.motionPack = animId; this.motionPack = animId;
} this.mapObjLayoutId = mapObjLayoutId;
this.mapObjInstanceId = mapObjInstanceId;
}
} }
} }

View File

@ -51,13 +51,13 @@ namespace Meteor.Map.Actors
private uint actorClassId; private uint actorClassId;
private string uniqueIdentifier; private string uniqueIdentifier;
private bool isMapObj = false; private bool IsMapObjChara = false;
private uint layout, instance; private uint MapObjLayoutId, MapObjInstanceId;
public NpcWork npcWork = new NpcWork(); public NpcWork npcWork = new NpcWork();
public NpcSpawnType npcSpawnType; public NpcSpawnType npcSpawnType;
public Npc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot, ushort actorState, uint animationId, string customDisplayName) public Npc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot, ushort actorState, uint animationId, string customDisplayName, uint mapObjLayoutId = 0, uint mapObjInstanceId = 0)
: base((4 << 28 | spawnedArea.Id << 19 | ((uint)actorNumber + 5))) : base((4 << 28 | spawnedArea.Id << 19 | ((uint)actorNumber + 5)))
{ {
this.positionX = posX; this.positionX = posX;
@ -101,24 +101,19 @@ namespace Meteor.Map.Actors
npcWork.pushCommandSub = actorClass.pushCommandSub; npcWork.pushCommandSub = actorClass.pushCommandSub;
npcWork.pushCommandPriority = actorClass.pushCommandPriority; npcWork.pushCommandPriority = actorClass.pushCommandPriority;
if (actorClassId == 1080078 || actorClassId == 1080079 || actorClassId == 1080080 || (actorClassId >= 1080123 && actorClassId <= 1080135) || (actorClassId >= 5000001 && actorClassId <= 5000090) || (actorClassId >= 5900001 && actorClassId <= 5900038)) if (mapObjLayoutId != 0 && mapObjInstanceId != 0)
{ {
isMapObj = true; isStatic = true;
List<LuaParam> lParams = LuaEngine.GetInstance().CallLuaFunctionForReturn(null, this, "init", false); IsMapObjChara = true;
if (lParams == null || lParams.Count < 6) MapObjLayoutId = mapObjLayoutId;
isMapObj = false; MapObjInstanceId = mapObjInstanceId;
else
{
layout = (uint)(Int32)lParams[4].value;
instance = (uint)(Int32)lParams[5].value;
isStatic = true;
}
} }
GenerateActorName((int)actorNumber); GenerateActorName((int)actorNumber);
this.aiContainer = new AIContainer(this, null, new PathFind(this), new TargetFind(this)); this.aiContainer = new AIContainer(this, null, new PathFind(this), new TargetFind(this));
} }
public Npc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot, uint layout, uint instance) public Npc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot, uint mapObjLayoutId = 0, uint mapObjInstanceId = 0)
: base((4 << 28 | spawnedArea.Id << 19 | (uint)actorNumber)) : base((4 << 28 | spawnedArea.Id << 19 | (uint)actorNumber))
{ {
this.positionX = posX; this.positionX = posX;
@ -148,9 +143,13 @@ namespace Meteor.Map.Actors
npcWork.pushCommandSub = actorClass.pushCommandSub; npcWork.pushCommandSub = actorClass.pushCommandSub;
npcWork.pushCommandPriority = actorClass.pushCommandPriority; npcWork.pushCommandPriority = actorClass.pushCommandPriority;
this.isMapObj = true; if (mapObjLayoutId != 0 && mapObjInstanceId != 0)
this.layout = layout; {
this.instance = instance; isStatic = true;
IsMapObjChara = true;
MapObjLayoutId = mapObjLayoutId;
MapObjInstanceId = mapObjInstanceId;
}
GenerateActorName((int)actorNumber); GenerateActorName((int)actorNumber);
this.aiContainer = new AIContainer(this, null, new PathFind(this), new TargetFind(null)); this.aiContainer = new AIContainer(this, null, new PathFind(this), new TargetFind(null));
@ -208,8 +207,8 @@ namespace Meteor.Map.Actors
subpackets.Add(CreateSpeedPacket()); subpackets.Add(CreateSpeedPacket());
subpackets.Add(CreateSpawnPositonPacket(0x0)); subpackets.Add(CreateSpawnPositonPacket(0x0));
if (isMapObj) if (IsMapObjChara)
subpackets.Add(SetActorBGPropertiesPacket.BuildPacket(Id, instance, layout)); subpackets.Add(SetActorBGPropertiesPacket.BuildPacket(Id, MapObjLayoutId, MapObjInstanceId));
else else
subpackets.Add(CreateAppearancePacket()); subpackets.Add(CreateAppearancePacket());

View File

@ -1815,7 +1815,7 @@ namespace Meteor.Map.Actors
break; break;
} }
if (defaultTalk != null && defaultTalk.IsQuestENPC(this, npc)) if (defaultTalk != null && defaultTalk.IsQuestENPCByScript(this, npc))
return defaultTalk; return defaultTalk;
return null; return null;

View File

@ -195,6 +195,12 @@ namespace Meteor.Map.Actors.QuestNS
return (questState?.HasENpc(npc.GetActorClassId()) ?? false); return (questState?.HasENpc(npc.GetActorClassId()) ?? false);
} }
public bool IsQuestENPCByScript(Player caller, Npc npc)
{
List<LuaParam> returned = LuaEngine.GetInstance().CallLuaFunctionForReturn(caller, this, "IsQuestENPC", true, npc, this);
return returned != null && returned.Count != 0 && returned[0].typeID == 3;
}
public void StartSequence(ushort sequence) public void StartSequence(ushort sequence)
{ {
if (sequence == SEQ_NOT_STARTED) if (sequence == SEQ_NOT_STARTED)

View File

@ -31,7 +31,7 @@ namespace Meteor.Map.packets.send.actor
public const ushort OPCODE = 0x00D8; public const ushort OPCODE = 0x00D8;
public const uint PACKET_SIZE = 0x28; public const uint PACKET_SIZE = 0x28;
public static SubPacket BuildPacket(uint sourceActorId, uint val1, uint val2) public static SubPacket BuildPacket(uint sourceActorId, uint layoutId, uint instanceId)
{ {
byte[] data = new byte[PACKET_SIZE - 0x20]; byte[] data = new byte[PACKET_SIZE - 0x20];
@ -39,8 +39,8 @@ namespace Meteor.Map.packets.send.actor
{ {
using (BinaryWriter binWriter = new BinaryWriter(mem)) using (BinaryWriter binWriter = new BinaryWriter(mem))
{ {
binWriter.Write((UInt32)val1); binWriter.Write((UInt32)instanceId);
binWriter.Write((UInt32)val2); binWriter.Write((UInt32)layoutId);
} }
} }

View File

@ -335,8 +335,11 @@ namespace Meteor.Map
positionY, positionY,
positionZ, positionZ,
rotation, rotation,
motionPack motionPack,
layoutId,
instanceId
FROM server_eventnpc_spawn_locations FROM server_eventnpc_spawn_locations
LEFT JOIN server_eventnpc_mapobj ON server_eventnpc_spawn_locations.id = server_eventnpc_mapobj.id
"; ";
MySqlCommand cmd = new MySqlCommand(query, conn); MySqlCommand cmd = new MySqlCommand(query, conn);
@ -364,7 +367,10 @@ namespace Meteor.Map
float rot = reader.GetFloat("rotation"); float rot = reader.GetFloat("rotation");
uint motionPack = reader.GetUInt32("motionPack"); uint motionPack = reader.GetUInt32("motionPack");
SpawnLocation spawn = new SpawnLocation(classId, uniqueId, zoneId, privAreaName, privAreaType, x, y, z, rot, motionPack); uint layoutId = !reader.IsDBNull(reader.GetOrdinal("layoutId")) ? reader.GetUInt32("layoutId") : 0;
uint instanceId = !reader.IsDBNull(reader.GetOrdinal("instanceId")) ? reader.GetUInt32("instanceId") : 0;
SpawnLocation spawn = new SpawnLocation(classId, uniqueId, zoneId, privAreaName, privAreaType, x, y, z, rot, motionPack, layoutId, instanceId);
zone.AddSpawnLocation(spawn); zone.AddSpawnLocation(spawn);