mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-02 19:42:05 -04:00
Modified scripts to work with new system.
This commit is contained in:
parent
62ed9b22f1
commit
fc51b7f564
@ -38,6 +38,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
|
|
||||||
public bool spawnedFirstTime = false;
|
public bool spawnedFirstTime = false;
|
||||||
|
|
||||||
|
public string classPath;
|
||||||
public string className;
|
public string className;
|
||||||
public List<LuaParam> classParams;
|
public List<LuaParam> classParams;
|
||||||
|
|
||||||
|
@ -5,12 +5,15 @@ using FFXIVClassic_Map_Server.actors;
|
|||||||
using FFXIVClassic_Map_Server.Actors.Chara;
|
using FFXIVClassic_Map_Server.Actors.Chara;
|
||||||
using FFXIVClassic_Map_Server.dataobjects;
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
using FFXIVClassic_Map_Server.lua;
|
using FFXIVClassic_Map_Server.lua;
|
||||||
|
using FFXIVClassic_Map_Server.packets.receive.events;
|
||||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||||
using FFXIVClassic_Map_Server.utils;
|
using FFXIVClassic_Map_Server.utils;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -19,6 +22,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
{
|
{
|
||||||
class Npc : Character
|
class Npc : Character
|
||||||
{
|
{
|
||||||
|
private Script actorScript;
|
||||||
private uint actorClassId;
|
private uint actorClassId;
|
||||||
|
|
||||||
public NpcWork npcWork = new NpcWork();
|
public NpcWork npcWork = new NpcWork();
|
||||||
@ -31,7 +35,6 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
this.positionZ = posZ;
|
this.positionZ = posZ;
|
||||||
this.rotation = rot;
|
this.rotation = rot;
|
||||||
this.animationId = animationId;
|
this.animationId = animationId;
|
||||||
this.className = className;
|
|
||||||
|
|
||||||
this.displayNameId = displayNameId;
|
this.displayNameId = displayNameId;
|
||||||
this.customDisplayName = customDisplayName;
|
this.customDisplayName = customDisplayName;
|
||||||
@ -41,6 +44,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
|
|
||||||
loadNpcAppearance(classId);
|
loadNpcAppearance(classId);
|
||||||
|
|
||||||
|
this.classPath = classPath;
|
||||||
className = classPath.Substring(classPath.LastIndexOf("/")+1);
|
className = classPath.Substring(classPath.LastIndexOf("/")+1);
|
||||||
|
|
||||||
charaWork.battleSave.potencial = 1.0f;
|
charaWork.battleSave.potencial = 1.0f;
|
||||||
@ -63,7 +67,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
charaWork.property[3] = 1;
|
charaWork.property[3] = 1;
|
||||||
charaWork.property[4] = 1;
|
charaWork.property[4] = 1;
|
||||||
|
|
||||||
generateActorName((int)actorNumber);
|
generateActorName((int)actorNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubPacket createAddActorPacket(uint playerActorId)
|
public SubPacket createAddActorPacket(uint playerActorId)
|
||||||
@ -73,17 +77,8 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
|
|
||||||
public override SubPacket createScriptBindPacket(uint playerActorId)
|
public override SubPacket createScriptBindPacket(uint playerActorId)
|
||||||
{
|
{
|
||||||
List<LuaParam> lParams;
|
List<LuaParam> lParams = LuaUtils.createLuaParamList(classPath, false, false, false, false, false, actorClassId, false, false, 0, 1, "TEST");
|
||||||
|
|
||||||
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
|
|
||||||
lParams = LuaEngine.doActorInstantiate(player, this);
|
|
||||||
|
|
||||||
if (lParams == null)
|
|
||||||
{
|
|
||||||
className = "PopulaceStandard";
|
|
||||||
lParams = LuaUtils.createLuaParamList("/Chara/Npc/Populace/PopulaceStandard", false, false, false, false, false, 0xF47F6, false, false, 0, 1, "TEST");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams);
|
return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,5 +253,70 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||||||
EventList conditions = JsonConvert.DeserializeObject<EventList>(eventConditions);
|
EventList conditions = JsonConvert.DeserializeObject<EventList>(eventConditions);
|
||||||
this.eventConditions = conditions;
|
this.eventConditions = conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DoEventStart(Player player, EventStartPacket eventStart)
|
||||||
|
{
|
||||||
|
if (File.Exists("./scripts" + classPath + ".lua"))
|
||||||
|
actorScript = LuaEngine.loadScript("./scripts" + classPath + ".lua");
|
||||||
|
|
||||||
|
if (actorScript == null)
|
||||||
|
{
|
||||||
|
LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Have to do this to combine LuaParams
|
||||||
|
List<Object> objects = new List<Object>();
|
||||||
|
objects.Add(player);
|
||||||
|
objects.Add(this);
|
||||||
|
objects.Add(eventStart.triggerName);
|
||||||
|
|
||||||
|
if (eventStart.luaParams != null)
|
||||||
|
objects.AddRange(LuaUtils.createLuaParamObjectList(eventStart.luaParams));
|
||||||
|
|
||||||
|
//Run Script
|
||||||
|
if (!actorScript.Globals.Get("onEventStarted").IsNil())
|
||||||
|
actorScript.Call(actorScript.Globals["onEventStarted"], objects.ToArray());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DoEventUpdate(Player player, EventUpdatePacket eventUpdate)
|
||||||
|
{
|
||||||
|
if (File.Exists("./scripts" + classPath + ".lua"))
|
||||||
|
actorScript = LuaEngine.loadScript("./scripts" + classPath + ".lua");
|
||||||
|
|
||||||
|
if (actorScript == null)
|
||||||
|
{
|
||||||
|
LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Have to do this to combine LuaParams
|
||||||
|
List<Object> objects = new List<Object>();
|
||||||
|
objects.Add(player);
|
||||||
|
objects.Add(this);
|
||||||
|
objects.Add(eventUpdate.val2);
|
||||||
|
objects.AddRange(LuaUtils.createLuaParamObjectList(eventUpdate.luaParams));
|
||||||
|
|
||||||
|
//Run Script
|
||||||
|
if (!actorScript.Globals.Get("onEventUpdate").IsNil())
|
||||||
|
actorScript.Call(actorScript.Globals["onEventUpdate"], objects.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void DoOnActorSpawn(Player player)
|
||||||
|
{
|
||||||
|
if (File.Exists("./scripts" + classPath + ".lua"))
|
||||||
|
actorScript = LuaEngine.loadScript("./scripts" + classPath + ".lua");
|
||||||
|
|
||||||
|
if (actorScript == null)
|
||||||
|
{
|
||||||
|
LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Run Script
|
||||||
|
if (!actorScript.Globals.Get("onSpawn").IsNil())
|
||||||
|
actorScript.Call(actorScript.Globals["onSpawn"], player, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||||||
|
|
||||||
if (actor is Npc)
|
if (actor is Npc)
|
||||||
{
|
{
|
||||||
LuaEngine.doActorOnSpawn(getActor(), (Npc)actor);
|
((Npc)actor).DoOnActorSpawn(playerActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,12 @@ namespace FFXIVClassic_Map_Server.lua
|
|||||||
|
|
||||||
public static void doActorOnEventStarted(Player player, Actor target, EventStartPacket eventStart)
|
public static void doActorOnEventStarted(Player player, Actor target, EventStartPacket eventStart)
|
||||||
{
|
{
|
||||||
|
if (target is Npc)
|
||||||
|
{
|
||||||
|
((Npc)target).DoEventStart(player, eventStart);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string luaPath;
|
string luaPath;
|
||||||
|
|
||||||
if (target is Command)
|
if (target is Command)
|
||||||
@ -126,6 +132,12 @@ namespace FFXIVClassic_Map_Server.lua
|
|||||||
|
|
||||||
public static void doActorOnEventUpdated(Player player, Actor target, EventUpdatePacket eventUpdate)
|
public static void doActorOnEventUpdated(Player player, Actor target, EventUpdatePacket eventUpdate)
|
||||||
{
|
{
|
||||||
|
if (target is Npc)
|
||||||
|
{
|
||||||
|
((Npc)target).DoEventUpdate(player, eventUpdate);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string luaPath;
|
string luaPath;
|
||||||
|
|
||||||
if (target is Command)
|
if (target is Command)
|
||||||
@ -206,7 +218,7 @@ namespace FFXIVClassic_Map_Server.lua
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Script loadScript(string filename)
|
public static Script loadScript(string filename)
|
||||||
{
|
{
|
||||||
Script script = new Script();
|
Script script = new Script();
|
||||||
((FileSystemScriptLoader)script.Options.ScriptLoader).ModulePaths = FileSystemScriptLoader.UnpackStringPaths("./scripts/?;./scripts/?.lua");
|
((FileSystemScriptLoader)script.Options.ScriptLoader).ModulePaths = FileSystemScriptLoader.UnpackStringPaths("./scripts/?;./scripts/?.lua");
|
||||||
@ -227,7 +239,7 @@ namespace FFXIVClassic_Map_Server.lua
|
|||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SendError(Player player, string message)
|
public static void SendError(Player player, string message)
|
||||||
{
|
{
|
||||||
List<SubPacket> sendError = new List<SubPacket>();
|
List<SubPacket> sendError = new List<SubPacket>();
|
||||||
sendError.Add(EndEventPacket.buildPacket(player.actorId, player.currentEventOwner, player.currentEventName));
|
sendError.Add(EndEventPacket.buildPacket(player.actorId, player.currentEventOwner, player.currentEventName));
|
||||||
|
Loading…
Reference in New Issue
Block a user