Added two callbacks to the Director; onTalked and onCommand. Split the command and event starts and keep track of them separately.

This commit is contained in:
Filip Maj 2016-04-14 08:30:21 -04:00
parent 108f5aa677
commit d989ec2a58
12 changed files with 227 additions and 53 deletions

View file

@ -84,6 +84,15 @@ namespace FFXIVClassic_Map_Server.Actors
45000, 47000, 50000, 53000, 56000, 59000, 62000, 65000, 68000, 71000, //Level <= 40
74000, 78000, 81000, 85000, 89000, 92000, 96000, 100000, 100000, 110000}; //Level <= 50
//Event Related
public uint currentEventOwner = 0;
public string currentEventName = "";
public uint currentCommand = 0;
public string currentCommandName = "";
public uint eventMenuId = 0;
//Player Info
public uint[] timers = new uint[20];
public ushort currentJob;
@ -108,12 +117,7 @@ namespace FFXIVClassic_Map_Server.Actors
public bool hasGoobbue;
public byte chocoboAppearance;
public string chocoboName;
public byte mountState = 0;
//Event Related
public uint eventCurrentOwner = 0;
public string eventCurrentStarter = "";
public uint eventMenuId = 0;
public byte mountState = 0;
public uint achievementPoints;
@ -125,7 +129,7 @@ namespace FFXIVClassic_Map_Server.Actors
public Quest[] questScenario = new Quest[16];
public Quest[] questGuildleve = new Quest[8];
public Director currentDirector;// = new OpeningDirector(0x46080012);
public Director currentDirector;
public PlayerWork playerWork = new PlayerWork();
@ -256,7 +260,7 @@ namespace FFXIVClassic_Map_Server.Actors
if (isMyPlayer(playerActorId))
{
if (currentDirector != null)
lParams = LuaUtils.createLuaParamList("/Chara/Player/Player_work", false, false, true, currentDirector, 0, false, timers, true);
lParams = LuaUtils.createLuaParamList("/Chara/Player/Player_work", false, false, true, currentDirector, true, 0, false, timers, true);
else
lParams = LuaUtils.createLuaParamList("/Chara/Player/Player_work", false, false, false, true, 0, false, timers, true);
}
@ -472,12 +476,15 @@ namespace FFXIVClassic_Map_Server.Actors
public void sendZoneInPackets(WorldManager world, ushort spawnType)
{
queuePacket(SetMapPacket.buildPacket(actorId, zone.regionId, zone.actorId));
queuePacket(SetActorIsZoningPacket.buildPacket(actorId, actorId, false));
queuePacket(_0x10Packet.buildPacket(actorId, 0xFF));
queuePacket(SetMusicPacket.buildPacket(actorId, zone.bgmDay, 0x01));
queuePacket(SetWeatherPacket.buildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR));
queuePacket(SetMapPacket.buildPacket(actorId, zone.regionId, zone.actorId));
queuePacket(getSpawnPackets(actorId, spawnType));
//getSpawnPackets(actorId, spawnType).debugPrintPacket();
getSpawnPackets(actorId, spawnType).debugPrintPacket();
#region grouptest
//Retainers
@ -511,6 +518,7 @@ namespace FFXIVClassic_Map_Server.Actors
playerSession.queuePacket(getInitPackets(actorId));
BasePacket areaMasterSpawn = zone.getSpawnPackets(actorId);
BasePacket debugSpawn = world.GetDebugActor().getSpawnPackets(actorId);
BasePacket worldMasterSpawn = world.GetActor().getSpawnPackets(actorId);
@ -523,8 +531,8 @@ namespace FFXIVClassic_Map_Server.Actors
playerSession.queuePacket(debugSpawn);
if (directorSpawn != null)
{
directorSpawn.debugPrintPacket();
currentDirector.getInitPackets(actorId).debugPrintPacket();
//directorSpawn.debugPrintPacket();
// currentDirector.getInitPackets(actorId).debugPrintPacket();
queuePacket(directorSpawn);
queuePacket(currentDirector.getInitPackets(actorId));
//queuePacket(currentDirector.getSetEventStatusPackets(actorId));
@ -982,6 +990,17 @@ namespace FFXIVClassic_Map_Server.Actors
return null;
}
public bool hasQuest(string name)
{
for (int i = 0; i < questScenario.Length; i++)
{
if (questScenario[i] != null && questScenario[i].actorName.ToLower().Equals(name.ToLower()))
return true;
}
return false;
}
public bool hasQuest(uint id)
{
for (int i = 0; i < questScenario.Length; i++)
@ -1004,23 +1023,27 @@ namespace FFXIVClassic_Map_Server.Actors
return -1;
}
public void setDirector(string directorType)
public void setDirector(string directorType, bool sendPackets)
{
if (directorType.Equals("openingDirector"))
{
currentDirector = new OpeningDirector(0x46080012);
currentDirector = new OpeningDirector(this, 0x46080012);
}
else if (directorType.Equals("QuestDirectorMan0l001"))
{
currentDirector = new QuestDirectorMan0l001(0x46080012);
currentDirector = new QuestDirectorMan0l001(this, 0x46080012);
}
if (sendPackets)
{
queuePacket(RemoveActorPacket.buildPacket(actorId, 0x46080012));
queuePacket(currentDirector.getSpawnPackets(actorId));
queuePacket(currentDirector.getInitPackets(actorId));
//queuePacket(currentDirector.getSetEventStatusPackets(actorId));
//currentDirector.getSpawnPackets(actorId).debugPrintPacket();
//currentDirector.getInitPackets(actorId).debugPrintPacket();
}
// queuePacket(RemoveActorPacket.buildPacket(actorId, 0x46080012));
// queuePacket(currentDirector.getSpawnPackets(actorId));
// queuePacket(currentDirector.getInitPackets(actorId));
// queuePacket(currentDirector.getSetEventStatusPackets(actorId));
// currentDirector.getSpawnPackets(actorId).debugPrintPacket();
// currentDirector.getInitPackets(actorId).debugPrintPacket();
}
public Director getDirector()
@ -1068,22 +1091,32 @@ namespace FFXIVClassic_Map_Server.Actors
public void runEventFunction(string functionName, params object[] parameters)
{
List<LuaParam> lParams = LuaUtils.createLuaParamList(parameters);
SubPacket spacket = RunEventFunctionPacket.buildPacket(actorId, eventCurrentOwner, eventCurrentStarter, functionName, lParams);
SubPacket spacket = RunEventFunctionPacket.buildPacket(actorId, currentEventOwner, currentEventName, functionName, lParams);
spacket.debugPrintSubPacket();
queuePacket(spacket);
}
public void endEvent()
{
SubPacket p = EndEventPacket.buildPacket(actorId, eventCurrentOwner, eventCurrentStarter);
SubPacket p = EndEventPacket.buildPacket(actorId, currentEventOwner, currentEventName);
p.debugPrintSubPacket();
queuePacket(p);
eventCurrentOwner = 0;
eventCurrentStarter = "";
currentEventOwner = 0;
currentEventName = "";
eventMenuId = 0;
}
public void endCommand()
{
SubPacket p = EndEventPacket.buildPacket(actorId, currentCommand, currentCommandName);
p.debugPrintSubPacket();
queuePacket(p);
currentCommand = 0;
currentCommandName = "";
}
public void setCurrentMenuId(uint id)
{
eventMenuId = id;

View file

@ -1,5 +1,6 @@
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;
using FFXIVClassic_Map_Server.packets.send.actor;
using System;
using System.Collections.Generic;
@ -10,10 +11,12 @@ using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.actors.director
{
class Director : Actor
{
public Director(uint id) : base(id)
{
{
Player owner;
public Director(Player owner, uint id) : base(id)
{
this.owner = owner;
}
public virtual BasePacket getSpawnPackets(uint playerActorId, uint spawnType)
@ -37,5 +40,15 @@ namespace FFXIVClassic_Map_Server.actors.director
return BasePacket.createPacket(initProperties.buildPacket(playerActorId, actorId), true, false);
}
public void onTalked(Npc npc)
{
LuaEngine.doDirectorOnTalked(this, owner, npc);
}
public void onCommand(Command command)
{
LuaEngine.doDirectorOnCommand(this, owner, command);
}
}
}

View file

@ -1,4 +1,5 @@
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;
using FFXIVClassic_Map_Server.packets.send.actor;
using System;
@ -11,7 +12,7 @@ namespace FFXIVClassic_Map_Server.actors.director
{
class OpeningDirector : Director
{
public OpeningDirector(uint id) : base(id)
public OpeningDirector(Player player, uint id) : base(player, id)
{
this.displayNameId = 0;
this.customDisplayName = "openingDire";

View file

@ -15,8 +15,8 @@ namespace FFXIVClassic_Map_Server.Actors
{
private uint weatherId;
public WeatherDirector(uint weatherId)
: base(0x5FF80003)
public WeatherDirector(Player player, uint weatherId)
: base(player, 0x5FF80003)
{
this.weatherId = weatherId;

View file

@ -1,4 +1,5 @@
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;
using FFXIVClassic_Map_Server.packets.send.actor;
using System;
@ -11,7 +12,8 @@ namespace FFXIVClassic_Map_Server.actors.director
{
class QuestDirectorMan0l001 : Director
{
public QuestDirectorMan0l001(uint id) : base(id)
public QuestDirectorMan0l001(Player player, uint id)
: base(player, id)
{
this.displayNameId = 0;
this.customDisplayName = "questDirect_ocn0Btl02_01";

View file

@ -45,11 +45,21 @@ namespace FFXIVClassic_Map_Server.Actors
return null;
}
public void ClearQuestData()
{
questData.Clear();
}
public uint GetQuestId()
{
return actorId;
}
public void ClearQuestFlags()
{
questFlags = 0;
}
public void SetQuestFlag(int bitIndex, bool value)
{
if (bitIndex >= 32)