mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-21 20:27:47 +00:00
Cleaned up the lua calls and renamed "onInstantiation" to "init". Added a "onSpawn" callback but still working on it. Added the "ActorSpecialGraphicPacket" and functions to use it.
This commit is contained in:
parent
4c391f64bc
commit
b68d13ea7f
7 changed files with 108 additions and 42 deletions
|
@ -134,6 +134,7 @@
|
||||||
<Compile Include="packets\receive\_0x07Packet.cs" />
|
<Compile Include="packets\receive\_0x07Packet.cs" />
|
||||||
<Compile Include="packets\send\actor\ActorDoEmotePacket.cs" />
|
<Compile Include="packets\send\actor\ActorDoEmotePacket.cs" />
|
||||||
<Compile Include="packets\send\actor\ActorInstantiatePacket.cs" />
|
<Compile Include="packets\send\actor\ActorInstantiatePacket.cs" />
|
||||||
|
<Compile Include="packets\send\actor\ActorSpecialGraphicPacket.cs" />
|
||||||
<Compile Include="packets\send\actor\BattleAction1Packet.cs" />
|
<Compile Include="packets\send\actor\BattleAction1Packet.cs" />
|
||||||
<Compile Include="packets\send\actor\battle\BattleAction.cs" />
|
<Compile Include="packets\send\actor\battle\BattleAction.cs" />
|
||||||
<Compile Include="packets\send\actor\battle\BattleActionX00Packet.cs" />
|
<Compile Include="packets\send\actor\battle\BattleActionX00Packet.cs" />
|
||||||
|
|
|
@ -81,6 +81,13 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
return SetActorIdleAnimationPacket.buildPacket(actorId, playerActorId, animationId);
|
return SetActorIdleAnimationPacket.buildPacket(actorId, playerActorId, animationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setQuestIcon(Player player, bool hasIcon)
|
||||||
|
{
|
||||||
|
ActorSpecialGraphicPacket.buildPacket(player.actorId, actorId, hasIcon ? ActorSpecialGraphicPacket.QUEST : 0x0).debugPrintSubPacket();
|
||||||
|
//player.queuePacket(ActorSpecialGraphicPacket.buildPacket(player.actorId, actorId, hasIcon ? ActorSpecialGraphicPacket.QUEST : 0x0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
List<LuaParam> lParams;
|
List<LuaParam> lParams;
|
||||||
|
|
||||||
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
|
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
|
||||||
lParams = LuaEngine.doActorOnInstantiate(player, this);
|
lParams = LuaEngine.doActorInstantiate(player, this);
|
||||||
|
|
||||||
if (lParams == null)
|
if (lParams == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -965,6 +965,17 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Quest getQuest(string name)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < questScenario.Length; i++)
|
||||||
|
{
|
||||||
|
if (questScenario[i] != null && questScenario[i].actorName.Equals(name))
|
||||||
|
return questScenario[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public bool hasQuest(uint id)
|
public bool hasQuest(uint id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < questScenario.Length; i++)
|
for (int i = 0; i < questScenario.Length; i++)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using FFXIVClassic_Lobby_Server.common;
|
using FFXIVClassic_Lobby_Server.common;
|
||||||
using FFXIVClassic_Lobby_Server.packets;
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
using FFXIVClassic_Map_Server.Actors;
|
using FFXIVClassic_Map_Server.Actors;
|
||||||
|
using FFXIVClassic_Map_Server.lua;
|
||||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic;
|
UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<LuaParam> doActorOnInstantiate(Player player, Actor target)
|
public static List<LuaParam> doActorInstantiate(Player player, Actor target)
|
||||||
{
|
{
|
||||||
string luaPath;
|
string luaPath;
|
||||||
|
|
||||||
|
@ -39,14 +39,10 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
{
|
{
|
||||||
luaPath = String.Format(FILEPATH_NPCS, target.zoneId, target.getName());
|
luaPath = String.Format(FILEPATH_NPCS, target.zoneId, target.getName());
|
||||||
if (File.Exists(luaPath))
|
if (File.Exists(luaPath))
|
||||||
{
|
{
|
||||||
Script script = new Script();
|
Script script = loadScript(luaPath);
|
||||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
|
||||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
DynValue result = script.Call(script.Globals["init"], target);
|
||||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
|
||||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
|
||||||
script.DoFile(luaPath);
|
|
||||||
DynValue result = script.Call(script.Globals["onInstantiate"], target);
|
|
||||||
List<LuaParam> lparams = LuaUtils.createLuaParamList(result);
|
List<LuaParam> lparams = LuaUtils.createLuaParamList(result);
|
||||||
return lparams;
|
return lparams;
|
||||||
}
|
}
|
||||||
|
@ -80,13 +76,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
if (File.Exists(luaPath))
|
if (File.Exists(luaPath))
|
||||||
{
|
{
|
||||||
Script script = new Script();
|
Script script = loadScript(luaPath);
|
||||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
|
||||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
|
||||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
|
||||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
|
||||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
|
||||||
script.DoFile(luaPath);
|
|
||||||
|
|
||||||
//Have to do this to combine LuaParams
|
//Have to do this to combine LuaParams
|
||||||
List<Object> objects = new List<Object>();
|
List<Object> objects = new List<Object>();
|
||||||
|
@ -98,7 +88,8 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
objects.AddRange(LuaUtils.createLuaParamObjectList(eventStart.luaParams));
|
objects.AddRange(LuaUtils.createLuaParamObjectList(eventStart.luaParams));
|
||||||
|
|
||||||
//Run Script
|
//Run Script
|
||||||
DynValue result = script.Call(script.Globals["onEventStarted"], objects.ToArray());
|
if (!script.Globals.Get("onEventStarted").IsNil())
|
||||||
|
script.Call(script.Globals["onEventStarted"], objects.ToArray());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -110,6 +101,28 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void doActorOnSpawn(Player player, Npc target)
|
||||||
|
{
|
||||||
|
string luaPath = String.Format(FILEPATH_NPCS, target.zoneId, target.getName());
|
||||||
|
|
||||||
|
if (File.Exists(luaPath))
|
||||||
|
{
|
||||||
|
Script script = loadScript(luaPath);
|
||||||
|
|
||||||
|
//Run Script
|
||||||
|
if (!script.Globals.Get("onSpawn").IsNil())
|
||||||
|
script.Call(script.Globals["onSpawn"], player, target);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<SubPacket> sendError = new List<SubPacket>();
|
||||||
|
sendError.Add(EndEventPacket.buildPacket(player.actorId, player.eventCurrentOwner, player.eventCurrentStarter));
|
||||||
|
player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName()));
|
||||||
|
player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void doActorOnEventUpdated(Player player, Actor target, EventUpdatePacket eventUpdate)
|
public static void doActorOnEventUpdated(Player player, Actor target, EventUpdatePacket eventUpdate)
|
||||||
{
|
{
|
||||||
string luaPath;
|
string luaPath;
|
||||||
|
@ -123,13 +136,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
if (File.Exists(luaPath))
|
if (File.Exists(luaPath))
|
||||||
{
|
{
|
||||||
Script script = new Script();
|
Script script = loadScript(luaPath);
|
||||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
|
||||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
|
||||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
|
||||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
|
||||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
|
||||||
script.DoFile(luaPath);
|
|
||||||
|
|
||||||
//Have to do this to combine LuaParams
|
//Have to do this to combine LuaParams
|
||||||
List<Object> objects = new List<Object>();
|
List<Object> objects = new List<Object>();
|
||||||
|
@ -139,7 +146,8 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
objects.AddRange(LuaUtils.createLuaParamObjectList(eventUpdate.luaParams));
|
objects.AddRange(LuaUtils.createLuaParamObjectList(eventUpdate.luaParams));
|
||||||
|
|
||||||
//Run Script
|
//Run Script
|
||||||
DynValue result = script.Call(script.Globals["onEventUpdate"], objects.ToArray());
|
if (!script.Globals.Get("onEventUpdate").IsNil())
|
||||||
|
script.Call(script.Globals["onEventUpdate"], objects.ToArray());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -156,16 +164,11 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
if (File.Exists(luaPath))
|
if (File.Exists(luaPath))
|
||||||
{
|
{
|
||||||
Script script = new Script();
|
Script script = loadScript(luaPath);
|
||||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
|
||||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
|
||||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
|
||||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
|
||||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
|
||||||
script.DoFile(luaPath);
|
|
||||||
|
|
||||||
//Run Script
|
//Run Script
|
||||||
DynValue result = script.Call(script.Globals["onZoneIn"], player);
|
if (!script.Globals.Get("onZoneIn").IsNil())
|
||||||
|
script.Call(script.Globals["onZoneIn"], player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,18 +176,25 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
{
|
{
|
||||||
if (File.Exists(FILEPATH_PLAYER))
|
if (File.Exists(FILEPATH_PLAYER))
|
||||||
{
|
{
|
||||||
Script script = new Script();
|
Script script = loadScript(FILEPATH_PLAYER);
|
||||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
|
||||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
|
||||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
|
||||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
|
||||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
|
||||||
script.DoFile(FILEPATH_PLAYER);
|
|
||||||
|
|
||||||
//Run Script
|
//Run Script
|
||||||
DynValue result = script.Call(script.Globals["onLogin"], player);
|
if (!script.Globals.Get("onZoneIn").IsNil())
|
||||||
|
script.Call(script.Globals["onZoneIn"], player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Script loadScript(string filename)
|
||||||
|
{
|
||||||
|
Script script = new Script();
|
||||||
|
((FileSystemScriptLoader)script.Options.ScriptLoader).ModulePaths = FileSystemScriptLoader.UnpackStringPaths("./scripts/?;./scripts/?.lua");
|
||||||
|
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||||
|
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||||
|
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||||
|
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||||
|
script.DoFile(filename);
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_Map_Server.packets.send.actor
|
||||||
|
{
|
||||||
|
class ActorSpecialGraphicPacket
|
||||||
|
{
|
||||||
|
public const int NONE = 0x0;
|
||||||
|
public const int QUEST = 0x2;
|
||||||
|
public const int NOGRAPHIC = 0x3;
|
||||||
|
public const int QUEST_IMPORTANT = 0x4;
|
||||||
|
|
||||||
|
public const ushort OPCODE = 0x00E3;
|
||||||
|
public const uint PACKET_SIZE = 0x28;
|
||||||
|
|
||||||
|
public static SubPacket buildPacket(uint playerActorID, uint targetActorID, int iconCode)
|
||||||
|
{
|
||||||
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
|
|
||||||
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
|
{
|
||||||
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
|
{
|
||||||
|
binWriter.Write((Int32)iconCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SubPacket(OPCODE, targetActorID, playerActorID, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue