mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Added things for testing mapobjs.
This commit is contained in:
		| @@ -182,6 +182,7 @@ | ||||
|     <Compile Include="packets\send\actor\inventory\InventoryListX64Packet.cs" /> | ||||
|     <Compile Include="packets\send\actor\inventory\InventoryListX32Packet.cs" /> | ||||
|     <Compile Include="packets\send\actor\PlayAnimationOnActorPacket.cs" /> | ||||
|     <Compile Include="packets\send\actor\PlayBGAnimation.cs" /> | ||||
|     <Compile Include="packets\send\actor\_0x132Packet.cs" /> | ||||
|     <Compile Include="packets\send\actor\SetActorIsZoningPacket.cs" /> | ||||
|     <Compile Include="packets\send\actor\battle\BattleActionX01Packet.cs" /> | ||||
|   | ||||
| @@ -407,6 +407,34 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|             return npc; | ||||
|         } | ||||
|  | ||||
|         public Npc SpawnActor(uint classId, string uniqueId, float x, float y, float z, uint regionId, uint layoutId) | ||||
|         { | ||||
|             ActorClass actorClass = Server.GetWorldManager().GetActorClass(classId); | ||||
|  | ||||
|             if (actorClass == null) | ||||
|                 return null; | ||||
|  | ||||
|             uint zoneId; | ||||
|  | ||||
|             if (this is PrivateArea) | ||||
|                 zoneId = ((PrivateArea)this).GetParentZone().actorId; | ||||
|             else | ||||
|                 zoneId = actorId; | ||||
|  | ||||
|             Npc npc = new Npc(mActorList.Count + 1, actorClass, uniqueId, this, x, y, z, 0, regionId, layoutId); | ||||
|  | ||||
|             npc.LoadEventConditions(actorClass.eventConditions); | ||||
|  | ||||
|             AddActorToZone(npc); | ||||
|  | ||||
|             return npc; | ||||
|         } | ||||
|  | ||||
|         public void DespawnActor(string uniqueId) | ||||
|         { | ||||
|             RemoveActorFromZone(FindActorInZoneByUniqueID(uniqueId)); | ||||
|         } | ||||
|  | ||||
|         public Director GetWeatherDirector() | ||||
|         { | ||||
|             return mWeatherDirector; | ||||
|   | ||||
| @@ -24,6 +24,7 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|     { | ||||
|         private uint actorClassId; | ||||
|         private string uniqueIdentifier; | ||||
|         private uint regionId, layoutId; | ||||
|  | ||||
|         public NpcWork npcWork = new NpcWork(); | ||||
|  | ||||
| @@ -71,6 +72,43 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|             GenerateActorName((int)actorNumber);             | ||||
|         } | ||||
|  | ||||
|         public Npc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot, uint region, uint layout) | ||||
|             : base((4 << 28 | spawnedArea.actorId << 19 | (uint)actorNumber)) | ||||
|         { | ||||
|             this.positionX = posX; | ||||
|             this.positionY = posY; | ||||
|             this.positionZ = posZ; | ||||
|             this.rotation = rot; | ||||
|             this.currentMainState = 0; | ||||
|             this.animationId = 0; | ||||
|  | ||||
|             this.displayNameId = actorClass.displayNameId; | ||||
|  | ||||
|             this.uniqueIdentifier = uniqueId; | ||||
|  | ||||
|             this.zoneId = spawnedArea.actorId; | ||||
|             this.zone = spawnedArea; | ||||
|  | ||||
|             this.actorClassId = actorClass.actorClassId; | ||||
|  | ||||
|             LoadNpcAppearance(actorClass.actorClassId); | ||||
|  | ||||
|             this.classPath = actorClass.classPath; | ||||
|             className = classPath.Substring(classPath.LastIndexOf("/") + 1); | ||||
|  | ||||
|             for (int i = 0; i < 32; i++) | ||||
|                 charaWork.property[i] = (byte)(((int)actorClass.propertyFlags >> i) & 1); | ||||
|  | ||||
|             npcWork.pushCommand = actorClass.pushCommand; | ||||
|             npcWork.pushCommandSub = actorClass.pushCommandSub; | ||||
|             npcWork.pushCommandPriority = actorClass.pushCommandPriority; | ||||
|  | ||||
|             this.regionId = region; | ||||
|             this.layoutId = layout; | ||||
|  | ||||
|             GenerateActorName((int)actorNumber); | ||||
|         } | ||||
|  | ||||
|         public SubPacket CreateAddActorPacket(uint playerActorId) | ||||
|         { | ||||
|             return AddActorPacket.BuildPacket(actorId, playerActorId, 8); | ||||
| @@ -100,7 +138,16 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|              //   npcWork.hateType = 1; | ||||
|             } | ||||
|  | ||||
|             if (lParams == null) | ||||
|             if (regionId != 0 && layoutId != 0) | ||||
|             { | ||||
|                 string classPathFake = "/Chara/Npc/MapObj/MapObjStandard"; | ||||
|                 string classNameFake = "MapObjStandard"; | ||||
|                 lParams = LuaUtils.CreateLuaParamList(classPathFake, false, false, false, false, false, actorClassId, false, false, 0, 0, regionId, layoutId); | ||||
|                 isStatic = true; | ||||
|                 //ActorInstantiatePacket.BuildPacket(actorId, playerActorId, actorName, classNameFake, lParams).DebugPrintSubPacket(); | ||||
|                 return ActorInstantiatePacket.BuildPacket(actorId, playerActorId, actorName, classNameFake, lParams);                 | ||||
|             } | ||||
|             else if (lParams == null) | ||||
|             { | ||||
|                 string classPathFake = "/Chara/Npc/Populace/PopulaceStandard"; | ||||
|                 string classNameFake = "PopulaceStandard"; | ||||
| @@ -132,7 +179,11 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|             subpackets.Add(CreateSpeedPacket(playerActorId));             | ||||
|             subpackets.Add(CreateSpawnPositonPacket(playerActorId, 0x0)); | ||||
|  | ||||
|             if (uniqueIdentifier.Equals("door1")) | ||||
|             if (regionId != 0 && layoutId != 0) | ||||
|             { | ||||
|                 subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, layoutId, regionId)); | ||||
|             } | ||||
|             else if (uniqueIdentifier.Equals("door1")) | ||||
|             { | ||||
|                 subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, 0xB0D, 0x1af)); | ||||
|             } | ||||
| @@ -384,6 +435,11 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|             LuaEngine.GetInstance().CallLuaFunction(player, this, "onSpawn", true);            | ||||
|         } | ||||
|  | ||||
|         public void PlayMapObjAnimation(Player player, string animationName) | ||||
|         { | ||||
|             player.QueuePacket(PlayBGAnimation.BuildPacket(actorId, player.actorId, animationName)); | ||||
|         } | ||||
|  | ||||
|         public void Update(double deltaTime) | ||||
|         { | ||||
|             LuaEngine.GetInstance().CallLuaFunction(null, this, "onUpdate", true, deltaTime);          | ||||
|   | ||||
| @@ -0,0 +1,31 @@ | ||||
| using FFXIVClassic.Common; | ||||
| using System; | ||||
| using System.IO; | ||||
|  | ||||
| using FFXIVClassic.Common; | ||||
| using System.Text; | ||||
|  | ||||
| namespace  FFXIVClassic_Map_Server.packets.send.actor | ||||
| { | ||||
|     class PlayBGAnimation | ||||
|     { | ||||
|         public const ushort OPCODE = 0x00D9; | ||||
|         public const uint PACKET_SIZE = 0x28; | ||||
|  | ||||
|         public static SubPacket BuildPacket(uint playerActorID, uint targetActorID, string animName) | ||||
|         { | ||||
|             byte[] data = new byte[PACKET_SIZE - 0x20]; | ||||
|            | ||||
|             using (MemoryStream mem = new MemoryStream(data)) | ||||
|             { | ||||
|                 using (BinaryWriter binWriter = new BinaryWriter(mem)) | ||||
|                 { | ||||
|                     binWriter.Write(Encoding.ASCII.GetBytes(animName), 0, Encoding.ASCII.GetByteCount(animName) > 0x8 ? 0x8 : Encoding.ASCII.GetByteCount(animName)); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return new SubPacket(OPCODE, playerActorID, targetActorID, data);             | ||||
|         } | ||||
|  | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user