Ejemplo n.º 1
0
        /// <summary>
        /// Sends CutsceneEnd to cutscene's leader.
        /// </summary>
        /// <param name="cutscene"></param>
        public static void CutsceneEnd(Cutscene cutscene)
        {
            var packet = new Packet(Op.CutsceneEnd, MabiId.Channel);
            packet.PutLong(cutscene.Leader.EntityId);

            // TODO: Send to whole party?
            cutscene.Leader.Client.Send(packet);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Creates cutscene and fills actor list as specified in the data.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="creature"></param>
		/// <returns></returns>
		public static Cutscene FromData(string name, Creature creature)
		{
			var result = new Cutscene(name, creature);

			var partyMembers = creature.Party.GetSortedMembers();
			var dummy = new NPC();

			foreach (var actorName in result.Data.Actors)
			{
				Creature actor = null;

				// Retrieve actor
				if (actorName.StartsWith("#"))
				{
					var actorData = AuraData.ActorDb.Find(actorName);
					if (actorData == null)
						Log.Warning("Unknown actor '{0}'.", actorName);
					else
						actor = new NPC(actorData);
				}
				else if (actorName == "me")
				{
					actor = creature;
				}
				else if (actorName == "leader")
				{
					actor = creature.Party.Leader;
				}
				else if (actorName.StartsWith("player"))
				{
					int idx;
					if (!int.TryParse(actorName.Substring("player".Length), out idx))
						Log.Warning("Cutscene.FromData: Invalid party member actor name '{0}'.", actorName);
					else if (idx > partyMembers.Length - 1)
						Log.Warning("Cutscene.FromData: Index out of party member range '{0}/{1}'.", idx, partyMembers.Length);
					else
						actor = partyMembers[idx];
				}
				else
					Log.Warning("Cutscene.FromData: Unknown kind of actor ({0}).", actorName);

				if (actor == null)
					actor = dummy;

				result.AddActor(actorName, actor);
			}

			return result;
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Sends PlayCutscene to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="cutscene"></param>
		public static void PlayCutscene(Creature creature, Cutscene cutscene)
		{
			var packet = new Packet(Op.PlayCutscene, MabiId.Channel);
			packet.PutLong(creature.EntityId);
			packet.PutLong(cutscene.Leader.EntityId);
			packet.PutString(cutscene.Name);

			packet.PutInt(cutscene.Actors.Count);
			foreach (var actor in cutscene.Actors)
			{
				var subPacket = Packet.Empty();
				subPacket.AddCreatureInfo(actor.Value, CreaturePacketType.Public);
				var bArr = subPacket.Build();

				packet.PutString(actor.Key);
				packet.PutShort((short)bArr.Length);
				packet.PutBin(bArr);
			}

			packet.PutInt(1); // count?
			packet.PutLong(creature.EntityId);

			// TODO: Send to whole party?
			creature.Client.Send(packet);
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Creates cutscene and fills actor list as specified in the data.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="creature"></param>
        /// <returns></returns>
        public static Cutscene FromData(string name, Creature creature)
        {
            var result = new Cutscene(name, creature);

            var partyMembers = creature.Party.GetSortedMembers();
            var dummy        = new NPC();

            foreach (var actorName in result.Data.Actors)
            {
                Creature actor = null;

                // Retrieve actor
                if (actorName.StartsWith("#"))
                {
                    var actorData = AuraData.ActorDb.Find(actorName);
                    if (actorData == null)
                    {
                        Log.Warning("Unknown actor '{0}'.", actorName);
                    }
                    else
                    {
                        actor = new NPC(actorData);
                    }
                }
                else if (actorName == "me")
                {
                    actor = creature;
                }
                else if (actorName == "leader")
                {
                    actor = creature.Party.Leader;
                }
                else if (actorName.StartsWith("player"))
                {
                    int idx;
                    if (!int.TryParse(actorName.Substring("player".Length), out idx))
                    {
                        Log.Warning("Cutscene.FromData: Invalid party member actor name '{0}'.", actorName);
                    }
                    else if (idx > partyMembers.Length - 1)
                    {
                        Log.Warning("Cutscene.FromData: Index out of party member range '{0}/{1}'.", idx, partyMembers.Length);
                    }
                    else
                    {
                        actor = partyMembers[idx];
                    }
                }
                else
                {
                    Log.Warning("Cutscene.FromData: Unknown kind of actor ({0}).", actorName);
                }

                if (actor == null)
                {
                    actor = dummy;
                }

                result.AddActor(actorName, actor);
            }

            return(result);
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Loads cutscene from data and plays it.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="leader"></param>
		/// <param name="onFinish"></param>
		/// <param name="viewers"></param>
		public static void Play(string name, Creature leader, Action<Cutscene> onFinish, params Creature[] viewers)
		{
			var cutscene = new Cutscene(name, leader, viewers);
			cutscene.LoadActorsFromData();
			cutscene.Play(onFinish);
		}
Ejemplo n.º 6
0
        /// <summary>
        /// Sends CutsceneUnk to cutscene's leader.
        /// </summary>
        /// <remarks>
        /// Doesn't seem to be required, but it's usually sent after unlocking
        /// the character after watching the cutscene.
        /// </remarks>
        /// <param name="cutscene"></param>
        public static void CutsceneUnk(Cutscene cutscene)
        {
            var packet = new Packet(Op.CutsceneUnk, MabiId.Channel);
            packet.PutLong(cutscene.Leader.EntityId);

            cutscene.Leader.Client.Send(packet);
        }