/// <summary> /// Lets the creature face the target. /// </summary> /// <param name="creature"></param> /// <param name="target"></param> /// <returns></returns> public static MabiPacket TurnTo(MabiEntity creature, MabiEntity target) { var cpos = creature.GetPosition(); var tpos = target.GetPosition(); var p = new MabiPacket(Op.TurnTo, creature.Id); p.PutFloat((float)tpos.X - (float)cpos.X); p.PutFloat((float)tpos.Y - (float)cpos.Y); return p; }
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; }
public MabiPacket GetWeatherPacket(uint region, float from, float to, uint transitionTime = Transition) { var p = new MabiPacket(Op.Weather, Id.Broadcast); p.PutByte(0); p.PutInt(region); p.PutByte(2); p.PutByte(0); p.PutByte(1); p.PutString("constant_smooth"); p.PutFloat(to); p.PutLong(DateTime.Now); p.PutLong(DateTime.MinValue); p.PutFloat(from); p.PutFloat(from); p.PutLong(transitionTime); p.PutByte(false); p.PutLong(DateTime.MinValue); p.PutInt(2); p.PutByte(0); return p; }
public static void SkillRankUp(Client client, MabiCreature creature, MabiSkill skill) { var packet = new MabiPacket(Op.SkillRankUp, creature.Id); packet.PutByte(1); packet.PutBin(skill.Info); packet.PutFloat(0); client.Send(packet); }
public void AddToPacket(MabiPacket packet) { packet.PutInt(this.ModId); packet.PutFloat(this.ChangePerSecond); packet.PutInt(this.TimeLeft); packet.PutInt((uint)this.Stat); packet.PutByte(0); // ? packet.PutFloat(this.MaxValue); }
/// <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); }