1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-21 20:27:47 +00:00

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)
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
local defaultTalk = player:GetDefaultTalkQuest(npc);
local tutorialTalk = player:GetTutorialQuest(npc);

View file

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

View file

@ -34,7 +34,10 @@ namespace Meteor.Map.actors.area
public float rot;
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.uniqueId = uniqueId;
@ -46,6 +49,8 @@ namespace Meteor.Map.actors.area
this.z = z;
this.rot = rot;
this.motionPack = animId;
this.mapObjLayoutId = mapObjLayoutId;
this.mapObjInstanceId = mapObjInstanceId;
}
}
}

View file

@ -51,13 +51,13 @@ namespace Meteor.Map.Actors
private uint actorClassId;
private string uniqueIdentifier;
private bool isMapObj = false;
private uint layout, instance;
private bool IsMapObjChara = false;
private uint MapObjLayoutId, MapObjInstanceId;
public NpcWork npcWork = new NpcWork();
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)))
{
this.positionX = posX;
@ -101,24 +101,19 @@ namespace Meteor.Map.Actors
npcWork.pushCommandSub = actorClass.pushCommandSub;
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;
List<LuaParam> lParams = LuaEngine.GetInstance().CallLuaFunctionForReturn(null, this, "init", false);
if (lParams == null || lParams.Count < 6)
isMapObj = false;
else
{
layout = (uint)(Int32)lParams[4].value;
instance = (uint)(Int32)lParams[5].value;
isStatic = true;
IsMapObjChara = true;
MapObjLayoutId = mapObjLayoutId;
MapObjInstanceId = mapObjInstanceId;
}
}
GenerateActorName((int)actorNumber);
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))
{
this.positionX = posX;
@ -148,9 +143,13 @@ namespace Meteor.Map.Actors
npcWork.pushCommandSub = actorClass.pushCommandSub;
npcWork.pushCommandPriority = actorClass.pushCommandPriority;
this.isMapObj = true;
this.layout = layout;
this.instance = instance;
if (mapObjLayoutId != 0 && mapObjInstanceId != 0)
{
isStatic = true;
IsMapObjChara = true;
MapObjLayoutId = mapObjLayoutId;
MapObjInstanceId = mapObjInstanceId;
}
GenerateActorName((int)actorNumber);
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(CreateSpawnPositonPacket(0x0));
if (isMapObj)
subpackets.Add(SetActorBGPropertiesPacket.BuildPacket(Id, instance, layout));
if (IsMapObjChara)
subpackets.Add(SetActorBGPropertiesPacket.BuildPacket(Id, MapObjLayoutId, MapObjInstanceId));
else
subpackets.Add(CreateAppearancePacket());

View file

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

View file

@ -195,6 +195,12 @@ namespace Meteor.Map.Actors.QuestNS
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)
{
if (sequence == SEQ_NOT_STARTED)

View file

@ -31,7 +31,7 @@ namespace Meteor.Map.packets.send.actor
public const ushort OPCODE = 0x00D8;
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];
@ -39,8 +39,8 @@ namespace Meteor.Map.packets.send.actor
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)val1);
binWriter.Write((UInt32)val2);
binWriter.Write((UInt32)instanceId);
binWriter.Write((UInt32)layoutId);
}
}

View file

@ -335,8 +335,11 @@ namespace Meteor.Map
positionY,
positionZ,
rotation,
motionPack
motionPack,
layoutId,
instanceId
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);
@ -364,7 +367,10 @@ namespace Meteor.Map
float rot = reader.GetFloat("rotation");
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);