Finished Treasures of the Main and Legends Adrift. Fixed quests appearing in private areas (echos). Fixed other bugs. Implemented NPC Linkshells. Added more options to nudge command. Added nudgenpc command. Added testbnpckill command.

This commit is contained in:
Filip Maj 2022-03-11 02:17:46 -05:00
parent ebba56602c
commit 65ee91e49c
14 changed files with 864 additions and 38 deletions

View file

@ -642,7 +642,7 @@ namespace Meteor.Map.Actors
return new Vector3(positionX, positionY, positionZ);
}
public void SetPos(float x, float y, float z, float rot = 0, bool instant = false)
public void SetPos(float x, float y, float z, float rot = 0, bool instant = false, Player player = null)
{
oldPositionX = positionX;
oldPositionY = positionY;
@ -657,8 +657,9 @@ namespace Meteor.Map.Actors
// todo: handle zone?
if (instant)
{
CurrentArea.BroadcastPacketAroundPoint(oldPositionX, oldPositionY, CreateSpawnTeleportPacket(0));
CurrentArea.BroadcastPacketAroundPoint(positionX, positionY, CreateSpawnTeleportPacket(0));
player.QueuePacket(CreateSpawnTeleportPacket(0));
//CurrentArea.BroadcastPacketAroundPoint(oldPositionX, oldPositionY, CreateSpawnTeleportPacket(0));
//CurrentArea.BroadcastPacketAroundPoint(positionX, positionY, CreateSpawnTeleportPacket(0));
}
else
CurrentArea.BroadcastPacketAroundActor(this, MoveActorToPositionPacket.BuildPacket(Id, x, y, z, rot, moveState));

View file

@ -33,9 +33,10 @@ namespace Meteor.Map.actors.area
private readonly Zone ParentZone;
private readonly string PrivateAreaName;
private readonly int PrivateAreaType;
private readonly bool CanExitArea;
public PrivateArea(Zone parent, string classPath, string privateAreaName, int privateAreaType, ushort bgmDay, ushort bgmNight, ushort bgmBattle)
: base(parent.ZoneId, parent.ZoneName, parent.RegionId, classPath, bgmDay, bgmNight, bgmBattle, parent.isIsolated, parent.isInn, parent.canRideChocobo, parent.canStealth, true)
public PrivateArea(Zone parent, string classPath, string privateAreaName, int privateAreaType, bool canExitArea, ushort music)
: base(parent.ZoneId, parent.ZoneName, parent.RegionId, classPath, music, music, music, parent.isIsolated, parent.isInn, parent.canRideChocobo, parent.canStealth, true)
{
this.ParentZone = parent;
this.PrivateAreaName = privateAreaName;
@ -52,6 +53,11 @@ namespace Meteor.Map.actors.area
return PrivateAreaType;
}
public bool CanExitPrivateArea()
{
return CanExitArea;
}
public override bool IsPublic()
{
return false;

View file

@ -38,7 +38,7 @@ namespace Meteor.Map.actors.area
}
public PrivateAreaContent(Zone parent, string classPath, string privateAreaName, int privateAreaType, Director director, Player contentStarter) //TODO: Make it a list
: base(parent, classPath, privateAreaName, privateAreaType, 0, 0, 0)
: base(parent, classPath, privateAreaName, privateAreaType, false, 0)
{
currentDirector = director;
LuaEngine.GetInstance().CallLuaFunction(contentStarter, this, "onCreate", false, currentDirector);

View file

@ -1840,18 +1840,27 @@ namespace Meteor.Map.Actors
public Quest[] GetQuestsForNpc(Npc npc)
{
Quest[] quests = questStateManager.GetQuestsForNpc(npc);
Quest[] quests = questStateManager.GetQuestsForNpc(npc, CurrentArea.IsPrivate());
Array.Sort(quests, (q1, q2) => (q1.HasData() ? 1 : 0) - (q2.HasData() ? 1 : 0));
return quests;
}
public void HandleBNpcKill(uint bnpcClassId)
{
foreach (Quest quest in questScenario)
{
if (quest != null)
quest.OnKillBNpc(this, bnpcClassId);
}
}
public bool HandleNpcLs(uint id)
{
foreach (Quest quest in questScenario)
{
if (quest != null && quest.HasNpcLsMsgs(id))
{
quest.OnNpcLS(this);
quest.OnNpcLs(this);
return true;
}
}

View file

@ -194,7 +194,12 @@ namespace Meteor.Map.Actors.QuestNS
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onNotice", true, triggerName);
}
public void OnNpcLS(Player caller)
public void OnKillBNpc(Player caller, uint classId)
{
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onKillBNpc", true, classId);
}
public void OnNpcLs(Player caller)
{
LuaEngine.GetInstance().CallLuaFunction(caller, this, "onNpcLS", true, data.GetNpcLsFrom(), data.GetMsgStep());
}

View file

@ -151,9 +151,12 @@ namespace Meteor.Map.Actors.QuestNS
return ActiveQuests.Find(quest => quest.GetQuestId() == id);
}
public Quest[] GetQuestsForNpc(Npc npc)
public Quest[] GetQuestsForNpc(Npc npc, bool isPrivateArea)
{
return ActiveQuests.FindAll(quest => quest.IsQuestENPC(player, npc)).ToArray();
if (isPrivateArea)
return ActiveQuests.FindAll(quest => quest.IsQuestENPC(player, npc) && quest.GetSequence() != Quest.SEQ_NOT_STARTED).ToArray();
else
return ActiveQuests.FindAll(quest => quest.IsQuestENPC(player, npc)).ToArray();
}
public byte[] GetCompletionSliceBytes(ushort from, ushort to)

View file

@ -144,9 +144,8 @@ namespace Meteor.Map
privateAreaName,
privateAreaType,
className,
dayMusic,
nightMusic,
battleMusic
canExitArea,
music
FROM server_zones_privateareas
WHERE privateAreaName IS NOT NULL";
@ -161,7 +160,7 @@ namespace Meteor.Map
if (zoneList.ContainsKey(parentZoneId))
{
Zone parent = zoneList[parentZoneId];
PrivateArea privArea = new PrivateArea(parent, reader.GetString("className"), reader.GetString("privateAreaName"), reader.GetInt32("privateAreaType"), reader.GetUInt16("dayMusic"), reader.GetUInt16("nightMusic"), reader.GetUInt16("battleMusic"));
PrivateArea privArea = new PrivateArea(parent, reader.GetString("className"), reader.GetString("privateAreaName"), reader.GetInt32("privateAreaType"), reader.GetBoolean("canExitArea"), reader.GetUInt16("music"));
parent.AddPrivateArea(privArea);
}
else
@ -939,7 +938,7 @@ namespace Meteor.Map
DoZoneChange(player, player.CurrentArea.ZoneId, null, 0, 15, x, y, z, rotation);
}
public void WarpToPosition(Player player, float x, float y, float z, float rotation)
public void WarpToPosition(Player player, float x, float y, float z, float rotation, bool debugInstant = false)
{
//Remove player from currentZone if transfer else it's login
if (player.CurrentArea != null)
@ -956,13 +955,18 @@ namespace Meteor.Map
//Send packets
player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.Id, 0x10));
player.playerSession.QueuePacket(player.CreateSpawnTeleportPacket(0));
player.playerSession.QueuePacket(player.CreateSpawnTeleportPacket(debugInstant ? (ushort) 0x0 : (ushort) 0xF));
player.playerSession.LockUpdates(false);
player.SendInstanceUpdate();
}
}
public void WarpToCharaPosition(Player player, Character target)
{
WarpToPosition(player, target.positionX, target.positionY, target.positionZ, target.rotation);
}
//Moves actor to new zone, and sends packets to spawn at the given coords.
public void DoZoneChangeContent(Player player, PrivateAreaContent contentArea, float spawnX, float spawnY, float spawnZ, float spawnRotation, ushort spawnType = SetActorPositionPacket.SPAWNTYPE_WARP_DUTY)
{