Started implementing retainers. Added a instanced retainer spawn. Documented retainer scripts.

This commit is contained in:
Filip Maj
2017-09-05 12:37:23 -04:00
parent b5054debea
commit f437b36f5a
19 changed files with 313 additions and 34 deletions

View 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);
}
}
}

View File

@@ -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

View File

@@ -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;
}
}
}
}