mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-20 11:47:48 +00:00
Modified how directors work to allow for persistence. Implemented GuildleveDirector object and it's work values.
This commit is contained in:
parent
2d7d10a417
commit
eb17da1c89
7 changed files with 155 additions and 44 deletions
|
@ -490,15 +490,11 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Director CreateDirector(string path)
|
public Director CreateDirector(string path, params object[] args)
|
||||||
{
|
{
|
||||||
lock (directorLock)
|
lock (directorLock)
|
||||||
{
|
{
|
||||||
Director director = new Director(directorIdCount, this, path);
|
Director director = new Director(directorIdCount, this, path, args);
|
||||||
|
|
||||||
if (!director.IsCreated())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
currentDirectors.Add(directorIdCount, director);
|
currentDirectors.Add(directorIdCount, director);
|
||||||
directorIdCount++;
|
directorIdCount++;
|
||||||
return director;
|
return director;
|
||||||
|
@ -511,7 +507,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
{
|
{
|
||||||
if (currentDirectors.ContainsKey(id))
|
if (currentDirectors.ContainsKey(id))
|
||||||
{
|
{
|
||||||
currentDirectors[id].RemoveChildren();
|
currentDirectors[id].RemoveMembers();
|
||||||
currentDirectors.Remove(id);
|
currentDirectors.Remove(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1420,14 +1420,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
if (!ownedDirectors.Contains(director))
|
if (!ownedDirectors.Contains(director))
|
||||||
{
|
{
|
||||||
ownedDirectors.Add(director);
|
ownedDirectors.Add(director);
|
||||||
director.AddChild(this);
|
director.AddMember(this);
|
||||||
|
|
||||||
if (spawnImmediatly)
|
|
||||||
{
|
|
||||||
director.GetSpawnPackets(actorId).DebugPrintPacket();
|
|
||||||
QueuePacket(director.GetSpawnPackets(actorId));
|
|
||||||
QueuePacket(director.GetInitPackets(actorId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1443,7 +1436,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
if (!ownedDirectors.Contains(director))
|
if (!ownedDirectors.Contains(director))
|
||||||
{
|
{
|
||||||
ownedDirectors.Remove(director);
|
ownedDirectors.Remove(director);
|
||||||
director.RemoveChild(this);
|
director.RemoveMember(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,23 +15,26 @@ namespace FFXIVClassic_Map_Server.actors.director
|
||||||
{
|
{
|
||||||
private uint directorId;
|
private uint directorId;
|
||||||
private string directorScriptPath;
|
private string directorScriptPath;
|
||||||
private List<Actor> childrenOwners = new List<Actor>();
|
private List<Actor> members = new List<Actor>();
|
||||||
private bool isCreated = false;
|
private bool isCreated = false;
|
||||||
|
|
||||||
public Director(uint id, Area zone, string directorPath)
|
private Script directorScript;
|
||||||
|
private Coroutine currentCoroutine;
|
||||||
|
|
||||||
|
public Director(uint id, Area zone, string directorPath, params object[] args)
|
||||||
: base((6 << 28 | zone.actorId << 19 | (uint)id))
|
: base((6 << 28 | zone.actorId << 19 | (uint)id))
|
||||||
{
|
{
|
||||||
directorId = id;
|
directorId = id;
|
||||||
this.zone = zone;
|
this.zone = zone;
|
||||||
directorScriptPath = directorPath;
|
directorScriptPath = directorPath;
|
||||||
DoActorInit(directorScriptPath);
|
|
||||||
GenerateActorName((int)id);
|
LoadLuaScript();
|
||||||
|
|
||||||
eventConditions = new EventList();
|
eventConditions = new EventList();
|
||||||
eventConditions.noticeEventConditions = new List<EventList.NoticeEventCondition>();
|
eventConditions.noticeEventConditions = new List<EventList.NoticeEventCondition>();
|
||||||
eventConditions.noticeEventConditions.Add(new EventList.NoticeEventCondition("noticeEvent", 0xE,0x0));
|
eventConditions.noticeEventConditions.Add(new EventList.NoticeEventCondition("noticeEvent", 0xE,0x0));
|
||||||
eventConditions.noticeEventConditions.Add(new EventList.NoticeEventCondition("noticeRequest", 0x0, 0x1));
|
eventConditions.noticeEventConditions.Add(new EventList.NoticeEventCondition("noticeRequest", 0x0, 0x1));
|
||||||
eventConditions.noticeEventConditions.Add(new EventList.NoticeEventCondition("reqForChild", 0x0, 0x1));
|
eventConditions.noticeEventConditions.Add(new EventList.NoticeEventCondition("reqForChild", 0x0, 0x1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SubPacket CreateScriptBindPacket(uint playerActorId)
|
public override SubPacket CreateScriptBindPacket(uint playerActorId)
|
||||||
|
@ -80,40 +83,70 @@ namespace FFXIVClassic_Map_Server.actors.director
|
||||||
public void OnCommandEvent(Player player, Command command)
|
public void OnCommandEvent(Player player, Command command)
|
||||||
{
|
{
|
||||||
LuaEngine.GetInstance().CallLuaFunction(player, this, "onCommandEvent", false, command);
|
LuaEngine.GetInstance().CallLuaFunction(player, this, "onCommandEvent", false, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoActorInit(string directorPath)
|
public void StartDirector(bool spawnImmediate, params object[] args)
|
||||||
{
|
{
|
||||||
List<LuaParam> lparams = LuaEngine.GetInstance().CallLuaFunctionForReturn(null, this, "init", false);
|
object[] args2 = new object[args.Length + 1];
|
||||||
|
args2[0] = this;
|
||||||
|
Array.Copy(args, 0, args2, 1, args.Length);
|
||||||
|
|
||||||
|
List<LuaParam> lparams = CallLuaScript("init", args2);
|
||||||
|
|
||||||
if (lparams.Count >= 1 && lparams[0].value is string)
|
if (lparams.Count >= 1 && lparams[0].value is string)
|
||||||
{
|
{
|
||||||
classPath = (string)lparams[0].value;
|
classPath = (string)lparams[0].value;
|
||||||
className = classPath.Substring(classPath.LastIndexOf("/") + 1);
|
className = classPath.Substring(classPath.LastIndexOf("/") + 1);
|
||||||
|
GenerateActorName((int)directorId);
|
||||||
isCreated = true;
|
isCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCreated && spawnImmediate)
|
||||||
|
{
|
||||||
|
foreach (Player p in GetPlayerMembers())
|
||||||
|
{
|
||||||
|
GetSpawnPackets(actorId).DebugPrintPacket();
|
||||||
|
p.QueuePacket(GetSpawnPackets(actorId));
|
||||||
|
p.QueuePacket(GetInitPackets(actorId));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddChild(Actor actor)
|
public void AddMember(Actor actor)
|
||||||
{
|
{
|
||||||
if (!childrenOwners.Contains(actor))
|
if (!members.Contains(actor))
|
||||||
childrenOwners.Add(actor);
|
members.Add(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveChild(Actor actor)
|
public void RemoveMember(Actor actor)
|
||||||
{
|
{
|
||||||
if (childrenOwners.Contains(actor))
|
if (members.Contains(actor))
|
||||||
childrenOwners.Remove(actor);
|
members.Remove(actor);
|
||||||
if (childrenOwners.Count == 0)
|
if (members.Count == 0)
|
||||||
Server.GetWorldManager().GetZone(zoneId).DeleteDirector(actorId);
|
Server.GetWorldManager().GetZone(zoneId).DeleteDirector(actorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveChildren()
|
public void RemoveMembers()
|
||||||
{
|
{
|
||||||
childrenOwners.Clear();
|
members.Clear();
|
||||||
Server.GetWorldManager().GetZone(zoneId).DeleteDirector(actorId);
|
Server.GetWorldManager().GetZone(zoneId).DeleteDirector(actorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Actor> GetMembers()
|
||||||
|
{
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Actor> GetPlayerMembers()
|
||||||
|
{
|
||||||
|
return members.FindAll(s => s is Player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Actor> GetNpcMembers()
|
||||||
|
{
|
||||||
|
return members.FindAll(s => s is Npc);
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsCreated()
|
public bool IsCreated()
|
||||||
{
|
{
|
||||||
return isCreated;
|
return isCreated;
|
||||||
|
@ -166,5 +199,29 @@ namespace FFXIVClassic_Map_Server.actors.director
|
||||||
return directorScriptPath;
|
return directorScriptPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadLuaScript()
|
||||||
|
{
|
||||||
|
string luaPath = String.Format(LuaEngine.FILEPATH_DIRECTORS, GetScriptPath());
|
||||||
|
directorScript = LuaEngine.LoadScript(luaPath);
|
||||||
|
if (directorScript == null)
|
||||||
|
Program.Log.Error("Could not find script for director {0}.", GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LuaParam> CallLuaScript(string funcName, params object[] args)
|
||||||
|
{
|
||||||
|
if (directorScript != null)
|
||||||
|
{
|
||||||
|
if (!directorScript.Globals.Get(funcName).IsNil())
|
||||||
|
{
|
||||||
|
DynValue result = directorScript.Call(directorScript.Globals[funcName], args);
|
||||||
|
List<LuaParam> lparams = LuaUtils.CreateLuaParamList(result);
|
||||||
|
return lparams;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Program.Log.Error("Could not find script for director {0}.", GetName());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
43
FFXIVClassic Map Server/actors/director/GuildleveDirector.cs
Normal file
43
FFXIVClassic Map Server/actors/director/GuildleveDirector.cs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
using FFXIVClassic_Map_Server.actors.director.Work;
|
||||||
|
using FFXIVClassic_Map_Server.Actors;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_Map_Server.actors.director
|
||||||
|
{
|
||||||
|
class GuildleveDirector : Director
|
||||||
|
{
|
||||||
|
public uint guildleveId;
|
||||||
|
public GuildleveData guildleveData;
|
||||||
|
public GuildleveWork guildleveWork = new GuildleveWork();
|
||||||
|
|
||||||
|
public GuildleveDirector(uint id, Area zone, string directorPath, uint guildleveId, params object[] args)
|
||||||
|
: base(id, zone, directorPath, args)
|
||||||
|
{
|
||||||
|
this.guildleveId = guildleveId;
|
||||||
|
this.guildleveData = Server.GetGuildleveGamedata(guildleveId);
|
||||||
|
|
||||||
|
guildleveWork.aimNum[0] = guildleveData.aimNum[0];
|
||||||
|
guildleveWork.aimNum[1] = guildleveData.aimNum[1];
|
||||||
|
guildleveWork.aimNum[2] = guildleveData.aimNum[2];
|
||||||
|
guildleveWork.aimNum[3] = guildleveData.aimNum[3];
|
||||||
|
|
||||||
|
guildleveWork.aimNumNow[0] = guildleveWork.aimNumNow[1] = guildleveWork.aimNumNow[2] = guildleveWork.aimNumNow[3] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAimNum(int index, sbyte value)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateUiState(int index, sbyte value)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_Map_Server.actors.director.Work
|
||||||
|
{
|
||||||
|
|
||||||
|
class GuildleveWork
|
||||||
|
{
|
||||||
|
public uint startTime = 0;
|
||||||
|
public sbyte[] aimNum = new sbyte[4];
|
||||||
|
public sbyte[] aimNumNow = new sbyte[4];
|
||||||
|
public sbyte[] uiState = new sbyte[4];
|
||||||
|
public float[] markerX = new float[3];
|
||||||
|
public float[] markerY = new float[3];
|
||||||
|
public float[] markerZ = new float[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -31,8 +31,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||||
id = reader.GetUInt32("id");
|
id = reader.GetUInt32("id");
|
||||||
classType = reader.GetUInt32("classType");
|
classType = reader.GetUInt32("classType");
|
||||||
location = reader.GetUInt32("location");
|
location = reader.GetUInt32("location");
|
||||||
factionCreditRequired = reader.GetByte("factionCreditRequired");
|
factionCreditRequired = reader.GetUInt16("factionCreditRequired");
|
||||||
level = reader.GetByte("level");
|
level = reader.GetUInt16("level");
|
||||||
aetheryte = reader.GetUInt32("aetheryte");
|
aetheryte = reader.GetUInt32("aetheryte");
|
||||||
plateId = reader.GetUInt32("plateId");
|
plateId = reader.GetUInt32("plateId");
|
||||||
borderId = reader.GetUInt32("borderId");
|
borderId = reader.GetUInt32("borderId");
|
||||||
|
|
|
@ -21,13 +21,13 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
{
|
{
|
||||||
class LuaEngine
|
class LuaEngine
|
||||||
{
|
{
|
||||||
const string FILEPATH_PLAYER = "./scripts/player.lua";
|
public const string FILEPATH_PLAYER = "./scripts/player.lua";
|
||||||
const string FILEPATH_ZONE = "./scripts/unique/{0}/zone.lua";
|
public const string FILEPATH_ZONE = "./scripts/unique/{0}/zone.lua";
|
||||||
const string FILEPATH_CONTENT = "./scripts/content/{0}.lua";
|
public const string FILEPATH_CONTENT = "./scripts/content/{0}.lua";
|
||||||
const string FILEPATH_COMMANDS = "./scripts/commands/{0}.lua";
|
public const string FILEPATH_COMMANDS = "./scripts/commands/{0}.lua";
|
||||||
const string FILEPATH_DIRECTORS = "./scripts/directors/{0}.lua";
|
public const string FILEPATH_DIRECTORS = "./scripts/directors/{0}.lua";
|
||||||
const string FILEPATH_NPCS = "./scripts/unique/{0}/{1}/{2}.lua";
|
public const string FILEPATH_NPCS = "./scripts/unique/{0}/{1}/{2}.lua";
|
||||||
const string FILEPATH_QUEST = "./scripts/quests/{0}/{1}.lua";
|
public const string FILEPATH_QUEST = "./scripts/quests/{0}/{1}.lua";
|
||||||
|
|
||||||
private static LuaEngine mThisEngine;
|
private static LuaEngine mThisEngine;
|
||||||
private Dictionary<Coroutine, ulong> mSleepingOnTime = new Dictionary<Coroutine, ulong>();
|
private Dictionary<Coroutine, ulong> mSleepingOnTime = new Dictionary<Coroutine, ulong>();
|
||||||
|
@ -576,13 +576,14 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
script.Globals["GetStaticActorById"] = (Func<uint, Actor>)Server.GetStaticActors;
|
script.Globals["GetStaticActorById"] = (Func<uint, Actor>)Server.GetStaticActors;
|
||||||
script.Globals["GetWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
script.Globals["GetWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||||
script.Globals["GetItemGamedata"] = (Func<uint, ItemData>)Server.GetItemGamedata;
|
script.Globals["GetItemGamedata"] = (Func<uint, ItemData>)Server.GetItemGamedata;
|
||||||
|
script.Globals["GetGuildleveGamedata"] = (Func<uint, GuildleveData>)Server.GetGuildleveGamedata;
|
||||||
script.Globals["GetLuaInstance"] = (Func<LuaEngine>)LuaEngine.GetInstance;
|
script.Globals["GetLuaInstance"] = (Func<LuaEngine>)LuaEngine.GetInstance;
|
||||||
|
|
||||||
script.Options.DebugPrint = s => { Program.Log.Debug(s); };
|
script.Options.DebugPrint = s => { Program.Log.Debug(s); };
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SendError(Player player, string message)
|
public static void SendError(Player player, string message)
|
||||||
{
|
{
|
||||||
message = "[LuaError] " + message;
|
message = "[LuaError] " + message;
|
||||||
if (player == null)
|
if (player == null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue