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

@ -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;
}
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)