mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-10 22:44:36 +02: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:
parent
b773098abf
commit
2cb6a9f6bd
74 changed files with 49 additions and 267 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -335,8 +335,11 @@ namespace Meteor.Map
|
|||
positionY,
|
||||
positionZ,
|
||||
rotation,
|
||||
motionPack
|
||||
FROM server_eventnpc_spawn_locations
|
||||
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);
|
||||
|
@ -363,8 +366,11 @@ namespace Meteor.Map
|
|||
float z = reader.GetFloat("positionZ");
|
||||
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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue