2016-01-02 14:04:45 -05:00
|
|
|
|
using FFXIVClassic_Lobby_Server;
|
|
|
|
|
using FFXIVClassic_Lobby_Server.common;
|
|
|
|
|
using FFXIVClassic_Lobby_Server.packets;
|
2016-01-23 22:11:45 -05:00
|
|
|
|
using FFXIVClassic_Map_Server.actors;
|
2016-01-02 14:04:45 -05:00
|
|
|
|
using FFXIVClassic_Map_Server.dataobjects.chara;
|
|
|
|
|
using FFXIVClassic_Map_Server.lua;
|
|
|
|
|
using FFXIVClassic_Map_Server.packets.send.actor;
|
2016-01-23 22:11:45 -05:00
|
|
|
|
using FFXIVClassic_Map_Server.packets.send.actor.events;
|
2016-01-02 14:04:45 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2016-01-20 23:18:10 -05:00
|
|
|
|
namespace FFXIVClassic_Map_Server.Actors
|
2016-01-02 14:04:45 -05:00
|
|
|
|
{
|
|
|
|
|
class Actor
|
|
|
|
|
{
|
|
|
|
|
public uint actorId;
|
|
|
|
|
public string actorName;
|
|
|
|
|
|
|
|
|
|
public uint displayNameId = 0xFFFFFFFF;
|
|
|
|
|
public string customDisplayName;
|
|
|
|
|
|
2016-01-09 23:22:10 -05:00
|
|
|
|
public ushort currentMainState = SetActorStatePacket.MAIN_STATE_PASSIVE;
|
|
|
|
|
public ushort currentSubState = SetActorStatePacket.SUB_STATE_NONE;
|
2016-01-16 23:03:04 -05:00
|
|
|
|
public float positionX, positionY, positionZ, rotation;
|
2016-01-02 14:04:45 -05:00
|
|
|
|
public float oldPositionX, oldPositionY, oldPositionZ, oldRotation;
|
|
|
|
|
public ushort moveState, oldMoveState;
|
|
|
|
|
|
2016-01-17 11:48:55 -05:00
|
|
|
|
public uint zoneId;
|
|
|
|
|
public Zone zone = null;
|
2016-01-02 18:17:03 -05:00
|
|
|
|
public bool isZoning = false;
|
|
|
|
|
|
2016-01-08 21:37:09 -05:00
|
|
|
|
public bool spawnedFirstTime = false;
|
|
|
|
|
|
2016-01-02 14:04:45 -05:00
|
|
|
|
public string className;
|
|
|
|
|
public List<LuaParam> classParams;
|
|
|
|
|
|
2016-01-23 22:11:45 -05:00
|
|
|
|
public EventList eventConditions;
|
|
|
|
|
|
2016-01-09 21:35:45 -05:00
|
|
|
|
public Actor(uint actorId)
|
2016-01-02 14:04:45 -05:00
|
|
|
|
{
|
2016-01-09 21:35:45 -05:00
|
|
|
|
this.actorId = actorId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Actor(uint actorId, string actorName, string className, List<LuaParam> classParams)
|
|
|
|
|
{
|
|
|
|
|
this.actorId = actorId;
|
|
|
|
|
this.actorName = actorName;
|
|
|
|
|
this.className = className;
|
|
|
|
|
this.classParams = classParams;
|
2016-01-02 14:04:45 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-25 01:10:43 -05:00
|
|
|
|
public SubPacket createAddActorPacket(uint playerActorId, byte val)
|
2016-01-02 18:17:03 -05:00
|
|
|
|
{
|
2016-01-25 01:10:43 -05:00
|
|
|
|
return AddActorPacket.buildPacket(actorId, playerActorId, val);
|
2016-01-02 18:17:03 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-02 14:04:45 -05:00
|
|
|
|
public SubPacket createNamePacket(uint playerActorId)
|
|
|
|
|
{
|
|
|
|
|
return SetActorNamePacket.buildPacket(actorId, playerActorId, displayNameId, displayNameId == 0xFFFFFFFF ? customDisplayName : "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SubPacket createSpeedPacket(uint playerActorId)
|
|
|
|
|
{
|
|
|
|
|
return SetActorSpeedPacket.buildPacket(actorId, playerActorId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SubPacket createSpawnPositonPacket(uint playerActorId, uint spawnType)
|
|
|
|
|
{
|
2016-01-09 18:52:23 -05:00
|
|
|
|
SubPacket spawnPacket;
|
|
|
|
|
if (!spawnedFirstTime && playerActorId == actorId)
|
2016-01-20 00:02:57 -05:00
|
|
|
|
spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, 0, positionX, positionY, positionZ, rotation, 0x1, false);
|
2016-01-09 18:52:23 -05:00
|
|
|
|
else if (playerActorId == actorId)
|
|
|
|
|
spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, 0xFFFFFFFF, positionX, positionY, positionZ, rotation, spawnType, true);
|
|
|
|
|
else
|
2016-01-25 01:10:43 -05:00
|
|
|
|
{
|
|
|
|
|
if (this is Player)
|
|
|
|
|
spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, 0, positionX, positionY, positionZ, rotation, spawnType, false);
|
|
|
|
|
else
|
|
|
|
|
spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, actorId, positionX, positionY, positionZ, rotation, spawnType, false);
|
|
|
|
|
}
|
2016-01-09 18:52:23 -05:00
|
|
|
|
|
2016-01-02 14:04:45 -05:00
|
|
|
|
//return SetActorPositionPacket.buildPacket(actorId, playerActorId, -211.895477f, 190.000000f, 29.651011f, 2.674819f, SetActorPositionPacket.SPAWNTYPE_PLAYERWAKE);
|
2016-01-09 18:52:23 -05:00
|
|
|
|
spawnedFirstTime = true;
|
|
|
|
|
return spawnPacket;
|
2016-01-02 14:04:45 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SubPacket createPositionUpdatePacket(uint playerActorId)
|
|
|
|
|
{
|
|
|
|
|
return MoveActorToPositionPacket.buildPacket(actorId, playerActorId, positionX, positionY, positionZ, rotation, moveState);
|
2016-01-02 18:17:03 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SubPacket createStatePacket(uint playerActorID)
|
|
|
|
|
{
|
|
|
|
|
return SetActorStatePacket.buildPacket(actorId, playerActorID, currentMainState, currentSubState);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-23 22:11:45 -05:00
|
|
|
|
public List<SubPacket> getEventConditionPackets(uint playerActorId)
|
|
|
|
|
{
|
|
|
|
|
List<SubPacket> subpackets = new List<SubPacket>();
|
|
|
|
|
|
|
|
|
|
//Return empty list
|
|
|
|
|
if (eventConditions == null)
|
|
|
|
|
return subpackets;
|
|
|
|
|
|
|
|
|
|
if (eventConditions.talkEventConditions != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (EventList.TalkEventCondition condition in eventConditions.talkEventConditions)
|
|
|
|
|
subpackets.Add(SetTalkEventCondition.buildPacket(playerActorId, actorId, condition.unknown1, condition.unknown2, condition.conditionName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (eventConditions.noticeEventConditions != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (EventList.NoticeEventCondition condition in eventConditions.noticeEventConditions)
|
|
|
|
|
subpackets.Add(SetNoticeEventCondition.buildPacket(playerActorId, actorId, condition.unknown1, condition.unknown2, condition.conditionName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (eventConditions.emoteEventConditions != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (EventList.EmoteEventCondition condition in eventConditions.emoteEventConditions)
|
|
|
|
|
subpackets.Add(SetEmoteEventCondition.buildPacket(playerActorId, actorId, condition.unknown1, condition.unknown2, condition.emoteId, condition.conditionName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return subpackets;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePacket getSetEventStatusPackets(uint playerActorId)
|
|
|
|
|
{
|
|
|
|
|
List<SubPacket> subpackets = new List<SubPacket>();
|
|
|
|
|
|
|
|
|
|
//Return empty list
|
|
|
|
|
if (eventConditions == null)
|
|
|
|
|
return BasePacket.createPacket(subpackets, true, false);
|
|
|
|
|
|
|
|
|
|
if (eventConditions.talkEventConditions != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (EventList.TalkEventCondition condition in eventConditions.talkEventConditions)
|
|
|
|
|
subpackets.Add(SetEventStatus.buildPacket(playerActorId, actorId, 1, 1, condition.conditionName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (eventConditions.noticeEventConditions != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (EventList.NoticeEventCondition condition in eventConditions.noticeEventConditions)
|
|
|
|
|
subpackets.Add(SetEventStatus.buildPacket(playerActorId, actorId, 1, 1, condition.conditionName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (eventConditions.emoteEventConditions != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (EventList.EmoteEventCondition condition in eventConditions.emoteEventConditions)
|
|
|
|
|
subpackets.Add(SetEventStatus.buildPacket(playerActorId, actorId, 1, 1, condition.conditionName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return BasePacket.createPacket(subpackets, true, false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-02 18:17:03 -05:00
|
|
|
|
public SubPacket createIsZoneingPacket(uint playerActorId)
|
|
|
|
|
{
|
|
|
|
|
return SetActorIsZoningPacket.buildPacket(actorId, playerActorId, false);
|
|
|
|
|
}
|
2016-01-02 14:04:45 -05:00
|
|
|
|
|
2016-01-02 18:17:03 -05:00
|
|
|
|
public virtual SubPacket createScriptBindPacket(uint playerActorId)
|
2016-01-02 14:04:45 -05:00
|
|
|
|
{
|
2016-01-09 21:35:45 -05:00
|
|
|
|
return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, classParams);
|
2016-01-02 14:04:45 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-10 02:44:32 -05:00
|
|
|
|
public virtual BasePacket getSpawnPackets(uint playerActorId)
|
2016-01-20 00:02:57 -05:00
|
|
|
|
{
|
|
|
|
|
return getSpawnPackets(playerActorId, 0x1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BasePacket getSpawnPackets(uint playerActorId, uint spawnType)
|
2016-01-02 14:04:45 -05:00
|
|
|
|
{
|
2016-01-02 18:17:03 -05:00
|
|
|
|
List<SubPacket> subpackets = new List<SubPacket>();
|
2016-01-25 01:10:43 -05:00
|
|
|
|
subpackets.Add(createAddActorPacket(playerActorId, 8));
|
2016-01-23 22:11:45 -05:00
|
|
|
|
subpackets.AddRange(getEventConditionPackets(playerActorId));
|
2016-01-02 18:17:03 -05:00
|
|
|
|
subpackets.Add(createSpeedPacket(playerActorId));
|
2016-01-20 00:02:57 -05:00
|
|
|
|
subpackets.Add(createSpawnPositonPacket(playerActorId, spawnType));
|
2016-01-02 18:17:03 -05:00
|
|
|
|
subpackets.Add(createNamePacket(playerActorId));
|
|
|
|
|
subpackets.Add(createStatePacket(playerActorId));
|
|
|
|
|
subpackets.Add(createIsZoneingPacket(playerActorId));
|
2016-01-09 21:35:45 -05:00
|
|
|
|
subpackets.Add(createScriptBindPacket(playerActorId));
|
2016-01-02 18:17:03 -05:00
|
|
|
|
return BasePacket.createPacket(subpackets, true, false);
|
2016-01-23 22:11:45 -05:00
|
|
|
|
}
|
2016-01-10 02:44:32 -05:00
|
|
|
|
|
|
|
|
|
public virtual BasePacket getInitPackets(uint playerActorId)
|
|
|
|
|
{
|
|
|
|
|
SetActorPropetyPacket initProperties = new SetActorPropetyPacket("/_init");
|
2016-01-20 23:18:10 -05:00
|
|
|
|
initProperties.addByte(0xE14B0CA8, 1);
|
|
|
|
|
initProperties.addByte(0x2138FD71, 1);
|
|
|
|
|
initProperties.addByte(0xFBFBCFB1, 1);
|
2016-01-10 02:44:32 -05:00
|
|
|
|
initProperties.addTarget();
|
|
|
|
|
return BasePacket.createPacket(initProperties.buildPacket(playerActorId, actorId), true, false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-02 14:04:45 -05:00
|
|
|
|
public override bool Equals(Object obj)
|
|
|
|
|
{
|
|
|
|
|
Actor actorObj = obj as Actor;
|
|
|
|
|
if (actorObj == null)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return actorId == actorObj.actorId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string getName()
|
|
|
|
|
{
|
|
|
|
|
return actorName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string getClassName()
|
|
|
|
|
{
|
|
|
|
|
return className;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<LuaParam> getLuaParams()
|
|
|
|
|
{
|
|
|
|
|
return classParams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-08 21:37:09 -05:00
|
|
|
|
|