Implemented the player portion of the new actor system.

This commit is contained in:
Filip Maj 2016-01-02 18:17:03 -05:00
parent 93a42c1ba3
commit 360d72b376
9 changed files with 117 additions and 44 deletions

View file

@ -24,7 +24,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
public uint displayNameId = 0xFFFFFFFF;
public string customDisplayName;
public uint animationId;
public uint currentMainState = SetActorStatePacket.MAIN_STATE_PASSIVE;
public uint currentSubState = SetActorStatePacket.SUB_STATE_NONE;
public float positionX, positionY, positionZ, rotation;
public float oldPositionX, oldPositionY, oldPositionZ, oldRotation;
@ -32,6 +33,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
public uint currentZoneId;
public bool isZoning = false;
public string className;
public List<LuaParam> classParams;
@ -40,6 +43,11 @@ namespace FFXIVClassic_Map_Server.dataobjects
actorId = Id;
}
public SubPacket createAddActorPacket(uint playerActorId)
{
return AddActorPacket.buildPacket(actorId, playerActorId, 0);
}
public SubPacket createNamePacket(uint playerActorId)
{
return SetActorNamePacket.buildPacket(actorId, playerActorId, displayNameId, displayNameId == 0xFFFFFFFF ? customDisplayName : "");
@ -59,19 +67,33 @@ namespace FFXIVClassic_Map_Server.dataobjects
public SubPacket createPositionUpdatePacket(uint playerActorId)
{
return MoveActorToPositionPacket.buildPacket(actorId, playerActorId, positionX, positionY, positionZ, rotation, moveState);
}
}
public SubPacket createScriptBindPacket(uint playerActorId)
public SubPacket createStatePacket(uint playerActorID)
{
return SetActorStatePacket.buildPacket(actorId, playerActorID, currentMainState, currentSubState);
}
public SubPacket createIsZoneingPacket(uint playerActorId)
{
return SetActorIsZoningPacket.buildPacket(actorId, playerActorId, false);
}
public virtual SubPacket createScriptBindPacket(uint playerActorId)
{
return null;
}
public BasePacket createActorSpawnPackets(uint playerActorId)
public virtual BasePacket getInitPackets(uint playerActorId)
{
if (this is Character)
return ((Character)this).createActorSpawnPackets(playerActorId);
else
return null;
List<SubPacket> subpackets = new List<SubPacket>();
subpackets.Add(createAddActorPacket(playerActorId));
subpackets.Add(createSpeedPacket(playerActorId));
subpackets.Add(createSpawnPositonPacket(playerActorId, 0xFF));
subpackets.Add(createNamePacket(playerActorId));
subpackets.Add(createStatePacket(playerActorId));
subpackets.Add(createIsZoneingPacket(playerActorId));
return BasePacket.createPacket(subpackets, true, false);
}
public override bool Equals(Object obj)

View file

@ -8,6 +8,9 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
{
class CharaWork
{
public uint PROPERTY_NAMEPLATE_VISIBLE = 1;
public uint PROPERTY_NAMEPLATE_VISIBLE2 = 5;
public ParameterSave parameterSave = new ParameterSave();
public ParameterTemp parameterTemp = new ParameterTemp();
public BattleSave battleSave = new BattleSave();
@ -15,8 +18,9 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
public EventSave eventSave = new EventSave();
public EventTemp eventTemp = new EventTemp();
public byte[] property = new byte[32];
public byte[] property = new byte[32];
public ushort[] status = new ushort[20];
public uint[] statusShownTime = new uint[20];
public int[] command = new int[64];

View file

@ -39,12 +39,13 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
public uint modelID;
public uint[] appearanceIDs = new uint[0x1D];
public uint animationId = 0;
public uint currentTarget = 0xC0000000;
public uint currentLockedTarget = 0xC0000000;
public uint currentMainState = SetActorStatePacket.MAIN_STATE_PASSIVE;
public uint currentSubState = SetActorStatePacket.SUB_STATE_PLAYER;
public uint currentActorIcon = 0;
public CharaWork charaWork = new CharaWork();
public PlayerWork playerWork = new PlayerWork();
@ -52,27 +53,25 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
{
}
public SubPacket createAppearancePacket(uint playerActorID)
public SubPacket createAppearancePacket(uint playerActorId)
{
SetActorAppearancePacket setappearance = new SetActorAppearancePacket(modelID, appearanceIDs);
return setappearance.buildPacket(actorId, playerActorID);
return setappearance.buildPacket(actorId, playerActorId);
}
public SubPacket createStatePacket(uint playerActorID)
public SubPacket createInitStatusPacket(uint playerActorId)
{
return SetActorStatePacket.buildPacket(actorId, playerActorID, currentMainState, currentSubState);
return (SetActorStatusAllPacket.buildPacket(actorId, playerActorId, charaWork.status));
}
public BasePacket createActorSpawnPackets(uint playerActorID)
public SubPacket createSetActorIconPacket(uint playerActorId)
{
List<SubPacket> subpackets = new List<SubPacket>();
subpackets.Add(createSpeedPacket(playerActorID));
subpackets.Add(createSpawnPositonPacket(playerActorID, 0xFF));
subpackets.Add(createAppearancePacket(playerActorID));
subpackets.Add(createNamePacket(playerActorID));
subpackets.Add(_0xFPacket.buildPacket(playerActorID, playerActorID));
subpackets.Add(createStatePacket(playerActorID));
return BasePacket.createPacket(subpackets, true, false);
return SetActorIconPacket.buildPacket(actorId, playerActorId, currentActorIcon);
}
public SubPacket createIdleAnimationPacket(uint playerActorId)
{
return SetActorIdleAnimationPacket.buildPacket(actorId, playerActorId, animationId);
}
}

View file

@ -1,7 +1,10 @@
using FFXIVClassic_Lobby_Server;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic_Lobby_Server.dataobjects;
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Map_Server.dataobjects.database;
using FFXIVClassic_Map_Server.lua;
using FFXIVClassic_Map_Server.packets.send.actor;
using System;
using System.Collections.Generic;
using System.Linq;
@ -12,6 +15,8 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
{
class Player : Character
{
PlayerWork playerWork = new PlayerWork();
public Player(uint actorID) : base(actorID)
{
actorName = String.Format("_player{0:00000000}", actorID);
@ -66,7 +71,59 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
appearanceIDs[L_EAR] = appearance.leftEar;
appearanceIDs[R_FINGER] = appearance.rightFinger;
appearanceIDs[L_FINGER] = appearance.leftFinger;
}
public List<SubPacket> create0x132Packets(uint playerActorId)
{
List<SubPacket> packets = new List<SubPacket>();
packets.Add(_0x132Packet.buildPacket(playerActorId, 0xB, "commandForced"));
packets.Add(_0x132Packet.buildPacket(playerActorId, 0xA, "commandDefault"));
packets.Add(_0x132Packet.buildPacket(playerActorId, 0x6, "commandWeak"));
packets.Add(_0x132Packet.buildPacket(playerActorId, 0x4, "commandContent"));
packets.Add(_0x132Packet.buildPacket(playerActorId, 0x6, "commandJudgeMode"));
packets.Add(_0x132Packet.buildPacket(playerActorId, 0x100, "commandRequest"));
packets.Add(_0x132Packet.buildPacket(playerActorId, 0x100, "widgetCreate"));
packets.Add(_0x132Packet.buildPacket(playerActorId, 0x100, "macroRequest"));
return packets;
}
public override SubPacket createScriptBindPacket(uint playerActorId)
{
List<LuaParam> lParams;
if (isMyPlayer(playerActorId))
{
lParams = LuaUtils.createLuaParamList("/Chara/Player/Player_work", false, false, false, false, false, true);
}
else
lParams = LuaUtils.createLuaParamList("/Chara/Player/Player_work", false, false, false, false, false, true);
return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams);
}
public override BasePacket getInitPackets(uint playerActorId)
{
List<SubPacket> subpackets = new List<SubPacket>();
subpackets.Add(createAddActorPacket(playerActorId));
if (isMyPlayer(playerActorId))
subpackets.AddRange(create0x132Packets(playerActorId));
subpackets.Add(createSpeedPacket(playerActorId));
subpackets.Add(createSpawnPositonPacket(playerActorId, 0xFF));
subpackets.Add(createAppearancePacket(playerActorId));
subpackets.Add(createNamePacket(playerActorId));
subpackets.Add(_0xFPacket.buildPacket(playerActorId, playerActorId));
subpackets.Add(createStatePacket(playerActorId));
subpackets.Add(createIdleAnimationPacket(playerActorId));
subpackets.Add(createInitStatusPacket(playerActorId));
subpackets.Add(createSetActorIconPacket(playerActorId));
subpackets.Add(createIsZoneingPacket(playerActorId));
//subpackets.Add(createScriptBindPacket(playerActorId));
return BasePacket.createPacket(subpackets, true, false);
}
public bool isMyPlayer(uint otherActorId)
{
return actorId == otherActorId;
}
}
}