1
Fork 0
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:
Filip Maj 2016-04-02 17:56:01 -04:00
parent 4c391f64bc
commit b68d13ea7f
7 changed files with 108 additions and 42 deletions

View file

@ -134,6 +134,7 @@
<Compile Include="packets\receive\_0x07Packet.cs" />
<Compile Include="packets\send\actor\ActorDoEmotePacket.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\battle\BattleAction.cs" />
<Compile Include="packets\send\actor\battle\BattleActionX00Packet.cs" />

View file

@ -81,6 +81,13 @@ namespace FFXIVClassic_Map_Server.Actors
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));
}
}
}

View file

@ -50,7 +50,7 @@ namespace FFXIVClassic_Map_Server.Actors
List<LuaParam> lParams;
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
lParams = LuaEngine.doActorOnInstantiate(player, this);
lParams = LuaEngine.doActorInstantiate(player, this);
if (lParams == null)
{

View file

@ -965,6 +965,17 @@ namespace FFXIVClassic_Map_Server.Actors
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)
{
for (int i = 0; i < questScenario.Length; i++)

View file

@ -2,6 +2,7 @@
using FFXIVClassic_Lobby_Server.common;
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;

View file

@ -31,7 +31,7 @@ namespace FFXIVClassic_Map_Server.lua
UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic;
}
public static List<LuaParam> doActorOnInstantiate(Player player, Actor target)
public static List<LuaParam> doActorInstantiate(Player player, Actor target)
{
string luaPath;
@ -40,13 +40,9 @@ namespace FFXIVClassic_Map_Server.lua
luaPath = String.Format(FILEPATH_NPCS, target.zoneId, target.getName());
if (File.Exists(luaPath))
{
Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
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);
DynValue result = script.Call(script.Globals["onInstantiate"], target);
Script script = loadScript(luaPath);
DynValue result = script.Call(script.Globals["init"], target);
List<LuaParam> lparams = LuaUtils.createLuaParamList(result);
return lparams;
}
@ -80,13 +76,7 @@ namespace FFXIVClassic_Map_Server.lua
if (File.Exists(luaPath))
{
Script script = new Script();
((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);
Script script = loadScript(luaPath);
//Have to do this to combine LuaParams
List<Object> objects = new List<Object>();
@ -98,7 +88,30 @@ namespace FFXIVClassic_Map_Server.lua
objects.AddRange(LuaUtils.createLuaParamObjectList(eventStart.luaParams));
//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
{
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 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
{
@ -123,13 +136,7 @@ namespace FFXIVClassic_Map_Server.lua
if (File.Exists(luaPath))
{
Script script = new Script();
((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);
Script script = loadScript(luaPath);
//Have to do this to combine LuaParams
List<Object> objects = new List<Object>();
@ -139,7 +146,8 @@ namespace FFXIVClassic_Map_Server.lua
objects.AddRange(LuaUtils.createLuaParamObjectList(eventUpdate.luaParams));
//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
{
@ -156,16 +164,11 @@ namespace FFXIVClassic_Map_Server.lua
if (File.Exists(luaPath))
{
Script script = new Script();
((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);
Script script = loadScript(luaPath);
//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))
{
Script script = new Script();
((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);
Script script = loadScript(FILEPATH_PLAYER);
//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;
}
}
}

View file

@ -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);
}
}
}