mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Implemented actor instancing, as well as automatic name generation for NPCs.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using FFXIVClassic_Lobby_Server.common;
|
||||
using FFXIVClassic_Lobby_Server;
|
||||
using FFXIVClassic_Lobby_Server.common;
|
||||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using FFXIVClassic_Map_Server.actors.area;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
using FFXIVClassic_Map_Server.dataobjects;
|
||||
using FFXIVClassic_Map_Server.dataobjects.chara;
|
||||
using FFXIVClassic_Map_Server.lua;
|
||||
@@ -21,15 +24,16 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
public ushort weatherNormal, weatherCommon, weatherRare;
|
||||
public ushort bgmDay, bgmNight, bgmBattle;
|
||||
|
||||
private string classPath;
|
||||
protected string classPath;
|
||||
|
||||
public int boundingGridSize = 50;
|
||||
public int minX = -1000, minY = -1000, maxX = 1000, maxY = 1000;
|
||||
private int numXBlocks, numYBlocks;
|
||||
private int halfWidth, halfHeight;
|
||||
protected int numXBlocks, numYBlocks;
|
||||
protected int halfWidth, halfHeight;
|
||||
|
||||
private Dictionary<uint, Actor> mActorList = new Dictionary<uint,Actor>();
|
||||
private List<Actor>[,] mActorBlock;
|
||||
protected List<SpawnLocation> mSpawnLocations = new List<SpawnLocation>();
|
||||
protected Dictionary<uint, Actor> mActorList = new Dictionary<uint, Actor>();
|
||||
protected List<Actor>[,] mActorBlock;
|
||||
|
||||
Script areaScript;
|
||||
|
||||
@@ -335,5 +339,18 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnActor(SpawnLocation location)
|
||||
{
|
||||
ActorClass actorClass = Server.GetWorldManager().GetActorClass(location.classId);
|
||||
|
||||
if (actorClass == null)
|
||||
return;
|
||||
|
||||
Npc npc = new Npc(mActorList.Count + 1, actorClass.actorClassId, actorId, location.x, location.y, location.z, location.rot, location.state, location.animId, actorClass.displayNameId, null, actorClass.classPath);
|
||||
npc.loadEventConditions(actorClass.eventConditions);
|
||||
|
||||
addActorToZone(npc);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -14,12 +14,14 @@ namespace FFXIVClassic_Map_Server.actors.area
|
||||
{
|
||||
private Zone parentZone;
|
||||
private string privateAreaName;
|
||||
private uint privateAreaLevel;
|
||||
|
||||
public PrivateArea(Zone parent, uint id, string className, string privateAreaName,ushort bgmDay, ushort bgmNight, ushort bgmBattle)
|
||||
public PrivateArea(Zone parent, uint id, string className, string privateAreaName, uint privateAreaLevel, ushort bgmDay, ushort bgmNight, ushort bgmBattle)
|
||||
: base(id, parent.zoneName, parent.regionId, className, bgmDay, bgmNight, bgmBattle, parent.isIsolated, parent.isInn, parent.canRideChocobo, parent.canStealth, true)
|
||||
{
|
||||
this.parentZone = parent;
|
||||
this.privateAreaName = privateAreaName;
|
||||
this.privateAreaLevel = privateAreaLevel;
|
||||
}
|
||||
|
||||
public string getPrivateAreaName()
|
||||
@@ -27,6 +29,11 @@ namespace FFXIVClassic_Map_Server.actors.area
|
||||
return privateAreaName;
|
||||
}
|
||||
|
||||
public uint getPrivateAreaLevel()
|
||||
{
|
||||
return privateAreaLevel;
|
||||
}
|
||||
|
||||
public Zone getParentZone()
|
||||
{
|
||||
return parentZone;
|
||||
@@ -45,6 +52,17 @@ namespace FFXIVClassic_Map_Server.actors.area
|
||||
ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams).debugPrintSubPacket();
|
||||
return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addSpawnLocation(SpawnLocation spawn)
|
||||
{
|
||||
mSpawnLocations.Add(spawn);
|
||||
}
|
||||
|
||||
public void spawnAllActors()
|
||||
{
|
||||
foreach (SpawnLocation spawn in mSpawnLocations)
|
||||
spawnActor(spawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
36
FFXIVClassic Map Server/actors/area/SpawnLocation.cs
Normal file
36
FFXIVClassic Map Server/actors/area/SpawnLocation.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.area
|
||||
{
|
||||
class SpawnLocation
|
||||
{
|
||||
public uint classId;
|
||||
public uint zoneId;
|
||||
public string privAreaName;
|
||||
public uint privAreaLevel;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
public float rot;
|
||||
public ushort state;
|
||||
public uint animId;
|
||||
|
||||
public SpawnLocation(uint classId, uint zoneId, string privAreaName, uint privAreaLevel, float x, float y, float z, float rot, ushort state, uint animId)
|
||||
{
|
||||
this.classId = classId;
|
||||
this.zoneId = zoneId;
|
||||
this.privAreaName = privAreaName;
|
||||
this.privAreaLevel = privAreaLevel;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.rot = rot;
|
||||
this.state = state;
|
||||
this.animId = animId;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,7 @@
|
||||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using FFXIVClassic_Lobby_Server;
|
||||
using FFXIVClassic_Lobby_Server.common;
|
||||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.lua;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
@@ -11,7 +14,7 @@ using System.Threading.Tasks;
|
||||
namespace FFXIVClassic_Map_Server.actors.area
|
||||
{
|
||||
class Zone : Area
|
||||
{
|
||||
{
|
||||
Dictionary<string, Dictionary<uint, PrivateArea>> privateAreas = new Dictionary<string, Dictionary<uint, PrivateArea>>();
|
||||
|
||||
public Zone(uint id, string zoneName, ushort regionId, string className, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool isIsolated, bool isInn, bool canRideChocobo, bool canStealth, bool isInstanceRaid)
|
||||
@@ -54,5 +57,40 @@ namespace FFXIVClassic_Map_Server.actors.area
|
||||
return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams);
|
||||
}
|
||||
|
||||
public void addSpawnLocation(SpawnLocation spawn)
|
||||
{
|
||||
//Is it in a private area?
|
||||
if (!spawn.privAreaName.Equals(""))
|
||||
{
|
||||
if (privateAreas.ContainsKey(spawn.privAreaName))
|
||||
{
|
||||
Dictionary<uint, PrivateArea> levels = privateAreas[spawn.privAreaName];
|
||||
if (levels.ContainsKey(spawn.privAreaLevel))
|
||||
levels[spawn.privAreaLevel].addSpawnLocation(spawn);
|
||||
else
|
||||
Log.error(String.Format("Tried to add a spawn location to non-existing private area level \"{0}\" in area {1} in zone {2}", spawn.privAreaName, spawn.privAreaLevel, zoneName));
|
||||
}
|
||||
else
|
||||
Log.error(String.Format("Tried to add a spawn location to non-existing private area \"{0}\" in zone {1}", spawn.privAreaName, zoneName));
|
||||
}
|
||||
else
|
||||
mSpawnLocations.Add(spawn);
|
||||
}
|
||||
|
||||
public void spawnAllActors(bool doPrivAreas)
|
||||
{
|
||||
foreach (SpawnLocation spawn in mSpawnLocations)
|
||||
spawnActor(spawn);
|
||||
|
||||
if (doPrivAreas)
|
||||
{
|
||||
foreach (Dictionary<uint, PrivateArea> areas in privateAreas.Values)
|
||||
{
|
||||
foreach (PrivateArea pa in areas.Values)
|
||||
pa.spawnAllActors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user