mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-10 14:34:32 +02:00
Started implementing retainers. Added a instanced retainer spawn. Documented retainer scripts.
This commit is contained in:
parent
b5054debea
commit
f437b36f5a
19 changed files with 313 additions and 34 deletions
|
@ -76,7 +76,7 @@ namespace FFXIVClassic_Map_Server
|
|||
using (var conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
||||
{
|
||||
Dictionary<uint, ItemData> gamedataItems = new Dictionary<uint, ItemData>();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
|
@ -611,7 +611,7 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool IsQuestCompleted(Player player, uint questId)
|
||||
{
|
||||
bool isCompleted = false;
|
||||
|
@ -677,7 +677,7 @@ namespace FFXIVClassic_Map_Server
|
|||
currentPrivateAreaType,
|
||||
homepoint,
|
||||
homepointInn
|
||||
FROM characters WHERE id = @charId";
|
||||
FROM characters WHERE id = @charId";
|
||||
|
||||
cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@charId", player.actorId);
|
||||
|
@ -693,7 +693,7 @@ namespace FFXIVClassic_Map_Server
|
|||
player.oldRotation = player.rotation = reader.GetFloat(4);
|
||||
player.currentMainState = reader.GetUInt16(5);
|
||||
player.zoneId = reader.GetUInt32(6);
|
||||
player.isZoning = true;
|
||||
player.isZoning = true;
|
||||
player.gcCurrent = reader.GetByte(7);
|
||||
player.gcRankLimsa = reader.GetByte(8);
|
||||
player.gcRankGridania = reader.GetByte(9);
|
||||
|
@ -718,7 +718,7 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
if (player.destinationZone != 0)
|
||||
player.zoneId = player.destinationZone;
|
||||
|
||||
|
||||
if (player.privateArea != null && !player.privateArea.Equals(""))
|
||||
player.zone = Server.GetWorldManager().GetPrivateArea(player.zoneId, player.privateArea, player.privateAreaType);
|
||||
else
|
||||
|
@ -888,8 +888,8 @@ namespace FFXIVClassic_Map_Server
|
|||
int count = 0;
|
||||
while (reader.Read())
|
||||
{
|
||||
player.charaWork.status[count] = reader.GetUInt16(0);
|
||||
player.charaWork.statusShownTime[count] = reader.GetUInt32(1);
|
||||
player.charaWork.status[count] = reader.GetUInt16("statusId");
|
||||
player.charaWork.statusShownTime[count] = reader.GetUInt32("expireTime");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1690,7 +1690,7 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1905,7 +1905,7 @@ namespace FFXIVClassic_Map_Server
|
|||
SET
|
||||
chocoboAppearance=@chocoboAppearance
|
||||
WHERE
|
||||
characterId = @characterId";
|
||||
characterId = @characterId";
|
||||
|
||||
cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@characterId", player.actorId);
|
||||
|
@ -1924,6 +1924,53 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Tuple<uint, uint, string> GetRetainer(Player player, int retainerIndex)
|
||||
{
|
||||
Tuple<uint, uint, string> data = null;
|
||||
|
||||
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
string query = @"
|
||||
SELECT server_retainers.id as retainerId, server_retainers.name as name, actorClassId FROM characters_retainers
|
||||
INNER JOIN server_retainers ON characters_retainers.retainerId = server_retainers.id
|
||||
WHERE characterId = @charaId
|
||||
ORDER BY id
|
||||
LIMIT 1 OFFSET @retainerIndex
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@charaId", player.actorId);
|
||||
cmd.Parameters.AddWithValue("@retainerIndex", retainerIndex-1);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
uint retainerId = reader.GetUInt32("retainerId");
|
||||
string name = reader.GetString("name");
|
||||
uint actorClassId = reader.GetUInt32("actorClassId");
|
||||
data = new Tuple<uint, uint, string>(retainerId, actorClassId, name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
<Compile Include="actors\chara\npc\ActorClass.cs" />
|
||||
<Compile Include="actors\chara\npc\NpcWork.cs" />
|
||||
<Compile Include="actors\chara\AetheryteWork.cs" />
|
||||
<Compile Include="actors\chara\npc\Retainer.cs" />
|
||||
<Compile Include="actors\chara\player\Equipment.cs" />
|
||||
<Compile Include="actors\chara\player\Inventory.cs" />
|
||||
<Compile Include="actors\chara\Work.cs" />
|
||||
|
@ -92,6 +93,7 @@
|
|||
<Compile Include="actors\EventList.cs" />
|
||||
<Compile Include="actors\group\GLContentGroup.cs" />
|
||||
<Compile Include="actors\group\ContentGroup.cs" />
|
||||
<Compile Include="actors\group\RetainerMeetingRelationGroup.cs" />
|
||||
<Compile Include="actors\group\Work\ContentGroupWork.cs" />
|
||||
<Compile Include="actors\group\Work\GlobalTemp.cs" />
|
||||
<Compile Include="actors\group\Group.cs" />
|
||||
|
@ -260,6 +262,10 @@
|
|||
<Compile Include="packets\send\recruitment\EndRecruitmentPacket.cs" />
|
||||
<Compile Include="packets\send\recruitment\RecruiterStatePacket.cs" />
|
||||
<Compile Include="packets\send\recruitment\StartRecruitingResponse.cs" />
|
||||
<Compile Include="packets\send\search\ItemSearchResult.cs" />
|
||||
<Compile Include="packets\send\search\ItemSearchResultsEndPacket.cs" />
|
||||
<Compile Include="packets\send\search\ItemSearchResultsBodyPacket.cs" />
|
||||
<Compile Include="packets\send\search\ItemSearchResultsBeginPacket.cs" />
|
||||
<Compile Include="packets\send\SendMessagePacket.cs" />
|
||||
<Compile Include="packets\send\SetMapPacket.cs" />
|
||||
<Compile Include="packets\send\SetMusicPacket.cs" />
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
public SubPacket CreateNamePacket()
|
||||
{
|
||||
return SetActorNamePacket.BuildPacket(actorId, displayNameId, displayNameId == 0xFFFFFFFF | displayNameId == 0x0 ? customDisplayName : "");
|
||||
return SetActorNamePacket.BuildPacket(actorId, customDisplayName != null ? 0 : displayNameId, displayNameId == 0xFFFFFFFF | displayNameId == 0x0 | customDisplayName != null ? customDisplayName : "");
|
||||
}
|
||||
|
||||
public SubPacket CreateSpeedPacket()
|
||||
|
|
31
FFXIVClassic Map Server/actors/chara/npc/Retainer.cs
Normal file
31
FFXIVClassic Map Server/actors/chara/npc/Retainer.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using FFXIVClassic_Map_Server.actors.chara.player;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.npc
|
||||
{
|
||||
class Retainer : Npc
|
||||
{
|
||||
public Retainer(uint id, string retainerName, ActorClass actorClass, Player player, float posX, float posY, float posZ, float rot)
|
||||
: base(0, actorClass, String.Format("_rtnre{0:x7}", id), player.GetZone(), posX, posY, posZ, rot, 0, 0, retainerName)
|
||||
{
|
||||
this.actorId = 0xD0000000 | id;
|
||||
}
|
||||
|
||||
public void SendBazaarItems(Player player)
|
||||
{
|
||||
Inventory bazaar = new Inventory(this, 4, Inventory.RETAINER_BAZAAR);
|
||||
bazaar.SendFullInventory(player);
|
||||
}
|
||||
|
||||
public void SendStorageItems(Player player)
|
||||
{
|
||||
Inventory storage = new Inventory(this, 4, 1);
|
||||
storage.SendFullInventory(player);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,10 +11,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
{
|
||||
class Inventory
|
||||
{
|
||||
public const ushort NORMAL = 0x0000; //Max 0xC8
|
||||
public const ushort NORMAL = 0x0000; //Max 0xC8
|
||||
public const ushort TRADE = 0x0001; //Max 0x96
|
||||
public const ushort LOOT = 0x0004; //Max 0xA
|
||||
public const ushort MELDREQUEST = 0x0005; //Max 0x04
|
||||
public const ushort BAZAAR = 0x0007; //Max 0x0A
|
||||
public const ushort MELDREQUEST = 0x0005; //Max 0x04
|
||||
public const ushort BAZAAR = 0x0007; //Max 0x0A
|
||||
public const ushort RETAINER_BAZAAR = 0x0008; //????
|
||||
public const ushort CURRENCY = 0x0063; //Max 0x140
|
||||
public const ushort KEYITEMS = 0x0064; //Max 0x500
|
||||
public const ushort EQUIPMENT = 0x00FE; //Max 0x23
|
||||
|
|
|
@ -20,6 +20,7 @@ using FFXIVClassic_Map_Server.packets.send.actor.inventory;
|
|||
using FFXIVClassic_Map_Server.actors.group;
|
||||
using FFXIVClassic_Map_Server.packets.send.group;
|
||||
using FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
|
@ -134,6 +135,10 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
public uint homepoint = 0;
|
||||
public byte homepointInn = 0;
|
||||
|
||||
//Instancing
|
||||
public Retainer currentSpawnedRetainer = null;
|
||||
public bool sentRetainerSpawn = false;
|
||||
|
||||
private List<Director> ownedDirectors = new List<Director>();
|
||||
private Director loginInitDirector = null;
|
||||
|
||||
|
@ -1558,6 +1563,12 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
QueuePacket(InventoryEndChangePacket.BuildPacket(toBeExamined.actorId));
|
||||
}
|
||||
|
||||
public void SendMyTradeToPlayer(Player player)
|
||||
{
|
||||
Inventory tradeInventory = new Inventory(this, 4, Inventory.TRADE);
|
||||
tradeInventory.SendFullInventory(player);
|
||||
}
|
||||
|
||||
public void SendDataPacket(params object[] parameters)
|
||||
{
|
||||
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
||||
|
@ -1730,5 +1741,40 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
Database.ChangePlayerChocoboAppearance(this, appearanceId);
|
||||
chocoboAppearance = appearanceId;
|
||||
}
|
||||
|
||||
public bool SpawnMyRetainer(Npc bell, int retainerIndex)
|
||||
{
|
||||
Tuple<uint, uint, string> retainerData = Database.GetRetainer(this, retainerIndex);
|
||||
|
||||
ActorClass actorClass = Server.GetWorldManager().GetActorClass(retainerData.Item2);
|
||||
|
||||
if (actorClass == null)
|
||||
return false;
|
||||
|
||||
float distance = (float)Math.Sqrt(((positionX - bell.positionX) * (positionX - bell.positionX)) + ((positionZ - bell.positionZ) * (positionZ - bell.positionZ)));
|
||||
float posX = bell.positionX - ((-1.0f * (bell.positionX - positionX)) / distance);
|
||||
float posZ = bell.positionZ - ((-1.0f * (bell.positionZ - positionZ)) / distance);
|
||||
|
||||
Retainer retainer = new Retainer(retainerData.Item1, retainerData.Item3, actorClass, this, posX, bell.positionY, positionZ, (float)Math.Atan2(positionX - posX, positionZ - posZ));
|
||||
|
||||
retainer.LoadEventConditions(actorClass.eventConditions);
|
||||
|
||||
//RetainerMeetingRelationGroup group = new RetainerMeetingRelationGroup(5555, this, retainer);
|
||||
//group.SendGroupPackets(playerSession);
|
||||
|
||||
currentSpawnedRetainer = retainer;
|
||||
sentRetainerSpawn = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DespawnMyRetainer()
|
||||
{
|
||||
if (currentSpawnedRetainer != null)
|
||||
{
|
||||
currentSpawnedRetainer = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace FFXIVClassic_Map_Server.actors.group
|
|||
groupWork.addByte(Utils.MurmurHash2("contentGroupWork.property[0]", 0), 1);
|
||||
groupWork.setTarget("/_init");
|
||||
|
||||
SubPacket test = groupWork.buildPacket(session.id, session.id);
|
||||
SubPacket test = groupWork.buildPacket(session.id);
|
||||
test.DebugPrintSubPacket();
|
||||
session.QueuePacket(test);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace FFXIVClassic_Map_Server.actors.group
|
|||
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
|
||||
groupWork.setTarget("/_init");
|
||||
|
||||
SubPacket test = groupWork.buildPacket(session.id, session.id);
|
||||
SubPacket test = groupWork.buildPacket(session.id);
|
||||
session.QueuePacket(test);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace FFXIVClassic_Map_Server.actors.group
|
|||
groupWork.addProperty(this, "work._globalTemp.variableCommand");
|
||||
groupWork.setTarget("/_init");
|
||||
|
||||
SubPacket test = groupWork.buildPacket(session.id, session.id);
|
||||
SubPacket test = groupWork.buildPacket(session.id);
|
||||
test.DebugPrintSubPacket();
|
||||
session.QueuePacket(test);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.dataobjects;
|
||||
using FFXIVClassic_Map_Server.packets.send.group;
|
||||
using FFXIVClassic_Map_Server.packets.send.groups;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.group
|
||||
{
|
||||
class RetainerMeetingRelationGroup : Group
|
||||
{
|
||||
Player player;
|
||||
Retainer retainer;
|
||||
|
||||
public RetainerMeetingRelationGroup(ulong groupIndex, Player player, Retainer retainer)
|
||||
: base(groupIndex)
|
||||
{
|
||||
this.player = player;
|
||||
this.retainer = retainer;
|
||||
}
|
||||
|
||||
public override int GetMemberCount()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public override List<GroupMember> BuildMemberList(uint id)
|
||||
{
|
||||
List<GroupMember> groupMembers = new List<GroupMember>();
|
||||
|
||||
groupMembers.Add(new GroupMember(player.actorId, -1, 0x83, false, true, player.customDisplayName));
|
||||
groupMembers.Add(new GroupMember(retainer.actorId, -1, 0x83, false, true, retainer.customDisplayName));
|
||||
|
||||
return groupMembers;
|
||||
}
|
||||
|
||||
public override uint GetTypeId()
|
||||
{
|
||||
return 50003;
|
||||
}
|
||||
|
||||
public override void SendInitWorkValues(Session session)
|
||||
{
|
||||
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
|
||||
groupWork.setTarget("/_init");
|
||||
|
||||
SubPacket test = groupWork.buildPacket(session.id);
|
||||
test.DebugPrintSubPacket();
|
||||
session.QueuePacket(test);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.dataobjects
|
||||
{
|
||||
|
@ -96,13 +97,30 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
//Remove missing actors
|
||||
for (int i = 0; i < actorInstanceList.Count; i++)
|
||||
{
|
||||
if (!list.Contains(actorInstanceList[i]))
|
||||
//Retainer Instance
|
||||
if (actorInstanceList[i] is Retainer && playerActor.currentSpawnedRetainer == null)
|
||||
{
|
||||
QueuePacket(RemoveActorPacket.BuildPacket(actorInstanceList[i].actorId));
|
||||
actorInstanceList.RemoveAt(i);
|
||||
}
|
||||
else if (!list.Contains(actorInstanceList[i]) && !(actorInstanceList[i] is Retainer))
|
||||
{
|
||||
QueuePacket(RemoveActorPacket.BuildPacket(actorInstanceList[i].actorId));
|
||||
actorInstanceList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
//Retainer Instance
|
||||
if (playerActor.currentSpawnedRetainer != null && !playerActor.sentRetainerSpawn)
|
||||
{
|
||||
Actor actor = playerActor.currentSpawnedRetainer;
|
||||
QueuePacket(actor.GetSpawnPackets(playerActor, 1));
|
||||
QueuePacket(actor.GetInitPackets());
|
||||
QueuePacket(actor.GetSetEventStatusPackets());
|
||||
actorInstanceList.Add(actor);
|
||||
playerActor.sentRetainerSpawn = true;
|
||||
}
|
||||
|
||||
//Add new actors or move
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace FFXIVClassic_Map_Server.packets.send.groups
|
|||
|
||||
}
|
||||
|
||||
public SubPacket buildPacket(uint playerActorID, uint actorID)
|
||||
public SubPacket buildPacket(uint actorID)
|
||||
{
|
||||
binWriter.Seek(0x8, SeekOrigin.Begin);
|
||||
binWriter.Write((byte)runningByteTotal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue