Beispiel #1
0
        public static MabiPacket StatUpdate(MabiCreature creature, StatUpdateType type, params Stat[] stats)
        {
            var packet = new MabiPacket((type & StatUpdateType.Public) != 0 ? Op.StatUpdatePublic : Op.StatUpdatePrivate, creature.Id);

            packet.PutByte((byte)type);

            // Stats
            packet.PutSInt(stats.Length);
            foreach (var stat in stats)
            {
                packet.PutInt((uint)stat);
                switch (stat)
                {
                    case Stat.Height: packet.PutFloat(creature.Height); break;
                    case Stat.Weight: packet.PutFloat(creature.Weight); break;
                    case Stat.Upper: packet.PutFloat(creature.Upper); break;
                    case Stat.Lower: packet.PutFloat(creature.Lower); break;

                    case Stat.CombatPower: packet.PutFloat(creature.CombatPower); break;
                    case Stat.Level: packet.PutShort(creature.Level); break;
                    case Stat.AbilityPoints: packet.PutShort(creature.AbilityPoints); break;
                    case Stat.Experience: packet.PutLong(MabiData.ExpDb.CalculateRemaining(creature.Level, creature.Experience) * 1000); break;

                    case Stat.Life: packet.PutFloat(creature.Life); break;
                    case Stat.LifeMax: packet.PutFloat(creature.LifeMaxBaseTotal); break;
                    case Stat.LifeMaxMod: packet.PutFloat(creature.StatMods.GetMod(Stat.LifeMaxMod)); break;
                    case Stat.LifeInjured: packet.PutFloat(creature.LifeInjured); break;
                    case Stat.Mana: packet.PutFloat(creature.Mana); break;
                    case Stat.ManaMax: packet.PutFloat(creature.ManaMaxBaseTotal); break;
                    case Stat.ManaMaxMod: packet.PutFloat(creature.StatMods.GetMod(Stat.ManaMaxMod)); break;
                    case Stat.Stamina: packet.PutFloat(creature.Stamina); break;
                    case Stat.Food: packet.PutFloat(creature.StaminaHunger); break;
                    case Stat.StaminaMax: packet.PutFloat(creature.StaminaMaxBaseTotal); break;
                    case Stat.StaminaMaxMod: packet.PutFloat(creature.StatMods.GetMod(Stat.StaminaMaxMod)); break;

                    case Stat.StrMod: packet.PutFloat(creature.StatMods.GetMod(Stat.StrMod)); break;
                    case Stat.DexMod: packet.PutFloat(creature.StatMods.GetMod(Stat.DexMod)); break;
                    case Stat.IntMod: packet.PutFloat(creature.StatMods.GetMod(Stat.IntMod)); break;
                    case Stat.LuckMod: packet.PutFloat(creature.StatMods.GetMod(Stat.LuckMod)); break;
                    case Stat.WillMod: packet.PutFloat(creature.StatMods.GetMod(Stat.WillMod)); break;
                    case Stat.Str: packet.PutFloat(creature.StrBaseTotal); break;
                    case Stat.Int: packet.PutFloat(creature.IntBaseTotal); break;
                    case Stat.Dex: packet.PutFloat(creature.DexBaseTotal); break;
                    case Stat.Will: packet.PutFloat(creature.WillBaseTotal); break;
                    case Stat.Luck: packet.PutFloat(creature.LuckBaseTotal); break;

                    case Stat.DefenseBaseMod: packet.PutShort((ushort)creature.DefensePassive); break;
                    case Stat.ProtectBaseMod: packet.PutFloat(creature.ProtectionPassive * 100); break;

                    case Stat.DefenseMod: packet.PutShort((ushort)creature.StatMods.GetMod(Stat.DefenseMod)); break;
                    case Stat.ProtectMod: packet.PutFloat(creature.StatMods.GetMod(Stat.ProtectMod)); break;

                    // Client might crash with a mismatching value,
                    // take a chance and put an int by default.
                    default: packet.PutInt(1); break;
                }
            }

            // (New?) Stat regens
            packet.PutSInt(creature.StatRegens.Count);
            foreach (var mod in creature.StatRegens)
                mod.AddToPacket(packet);

            // Stat mod ids to remove?
            packet.PutInt(0);

            packet.PutInt(0);					 // ?

            if (type == StatUpdateType.Public)
            {
                packet.PutInt(0);  				 // ?

                // Stat mod ids to remove?
                packet.PutInt(0);

                packet.PutInt(0);				 // ?
            }

            return packet;
        }
Beispiel #2
0
        // tmp
        public static MabiPacket StatRegenStop(MabiCreature creature, StatUpdateType type, params MabiStatRegen[] stats)
        {
            var packet = new MabiPacket((type & StatUpdateType.Public) != 0 ? Op.StatUpdatePublic : Op.StatUpdatePrivate, creature.Id);

            packet.PutByte((byte)type);
            packet.PutSInt(0); // Stats
            packet.PutInt(0); // Regens

            // Stat mod ids to remove
            packet.PutSInt(stats.Count());
            foreach (var mod in stats)
                packet.PutInt(mod.ModId);

            packet.PutInt(0);

            if (type == StatUpdateType.Public)
            {
                packet.PutInt(0);

                // Stat mod ids to remove
                packet.PutSInt(stats.Count());
                foreach (var mod in stats)
                    packet.PutInt(mod.ModId);

                packet.PutInt(0);
            }

            return packet;
        }
Beispiel #3
0
        public static void CutsceneStart(WorldClient client, MabiCutscene cutscene)
        {
            var p = new MabiPacket(Op.CutsceneStart, Id.World);
            p.PutLongs(client.Character.Id, cutscene.Leader.Id);
            p.PutString(cutscene.Name);
            p.PutSInt(cutscene.Actors.Count);
            foreach (var a in cutscene.Actors)
            {
                p.PutString(a.Item1);
                p.PutShort((ushort)a.Item2.Length);
                p.PutBin(a.Item2);
            }
            p.PutInt(1);
            p.PutLong(client.Character.Id);

            client.Send(p);
        }
Beispiel #4
0
        public static void SystemMessage(Client client, MabiCreature target, string from, string format, params object[] args)
        {
            var packet = new MabiPacket(Op.Chat, target.Id);
            packet.PutByte(0);
            packet.PutString(from);
            packet.PutString(format, args);
            packet.PutByte(1);
            packet.PutSInt(-32640);
            packet.PutInt(0);
            packet.PutByte(0);

            client.Send(packet);
        }
Beispiel #5
0
        public MabiPacket GetPacket()
        {
            var p = new MabiPacket(Op.CombatActionBundle, Id.Broadcast);
            p.PutInt(this.CombatActionId);
            p.PutInt(this.PrevCombatActionId);
            p.PutByte(this.Hit);
            p.PutByte(this.HitsMax);
            p.PutByte(0);

            p.PutSInt(this.Actions.Count);
            foreach (var action in this.Actions)
            {
                p.PutIntBin(action.GetPacket(this.CombatActionId).Build(false));
            }

            return p;
        }
Beispiel #6
0
        /// <summary>
        /// Sends character info. 
        /// </summary>
        /// <param name="client"></param>
        /// <param name="character"></param>
        public static void CharacterInfo(LoginClient client, uint op, Character character, IEnumerable<Item> items)
        {
            var packet = new MabiPacket(op, Id.Login);
            if (character != null)
            {
                packet.PutByte(true);
                packet.PutString(character.Server);
                packet.PutLong(character.Id);
                packet.PutByte(1);
                packet.PutString(character.Name);
                packet.PutString("");
                packet.PutString("");
                packet.PutInt(character.Race);
                packet.PutByte(character.SkinColor);
                packet.PutByte(character.Eye);
                packet.PutByte(character.EyeColor);
                packet.PutByte(character.Mouth);
                packet.PutInt(0);
                packet.PutFloat(character.Height);
                packet.PutFloat(character.Weight);
                packet.PutFloat(character.Upper);
                packet.PutFloat(character.Lower);
                packet.PutInt(0);
                packet.PutInt(0);
                packet.PutInt(0);
                packet.PutByte(0);
                packet.PutInt(0);
                packet.PutByte(0);
                packet.PutInt(character.Color1);
                packet.PutInt(character.Color2);
                packet.PutInt(character.Color3);
                packet.PutFloat(0.0f);
                packet.PutString("");
                packet.PutFloat(49.0f);
                packet.PutFloat(49.0f);
                packet.PutFloat(0.0f);
                packet.PutFloat(49.0f);
                packet.PutInt(0);
                packet.PutInt(0);
                packet.PutShort(0);
                packet.PutLong(0);
                packet.PutString("");
                packet.PutByte(0);

                packet.PutSInt(items.Count());
                foreach (var item in items)
                {
                    packet.PutLong(item.Id);
                    packet.PutBin(item.Info);
                }

                packet.PutInt(0);  // PetRemainingTime
                packet.PutLong(0); // PetLastTime
                packet.PutLong(0); // PetExpireTime
            }
            else
            {
                packet.PutByte(false);
            }

            client.Send(packet);
        }