private static Packet ConstructBroadcastPacket(ChatType type, Boolean isGm, String sender, Int64 sendercoid, String msg) { var msglen = (Int16) msg.Length; var p = new Packet(Opcode.Broadcast); p.WriteInteger((UInt32) type); p.WriteLong(sendercoid); p.WriteBoolean(isGm); p.WritePadding(1).WriteShort(msglen); p.WriteUtf8StringOn(sender, 17); p.WriteUtf8StringOn(msg, msglen); p.WriteByte(0); return p; }
public static void RequestInfo(TNLConnection conn) { var resp = new Packet(Opcode.RequestClanInfoResponse); // todo: No response, if the character has no clan? resp.WriteInteger(-1); // Clan Id resp.WriteUtf8StringOn("", 51); // Clan Name resp.WriteUtf8StringOn("", 251); // Clan Motd resp.WriteUtf8StringOn("", 51); // Rank One resp.WriteUtf8StringOn("", 51); // Rank Two resp.WriteUtf8StringOn("", 51); // Rank Three resp.WritePadding(1); resp.WriteInteger(-1); // Monthly Dues resp.WriteInteger(-1); // Monthly Upkeep resp.WriteLong(-1L); // Clan Owner resp.WriteInteger(0); // Num members resp.WritePadding(4); for (var i = 0; i < 0; ++i) { resp.WriteLong(-1L); // Member Coid resp.WriteUtf8StringOn("", 17); // Character Name resp.WritePadding(3); resp.WriteInteger(0); // Continent Id resp.WriteInteger(0); // Xp resp.WriteInteger(0); // Clan Rank resp.WriteLong(0); // Last Paid Dues resp.WriteInteger(-1); // Cbid resp.WriteBoolean(false); // Online resp.WritePadding(3); resp.WriteLong(0); // Last Online resp.WriteLong(0); // Join Date } conn.SendPacket(resp, RPCGuaranteeType.RPCGuaranteedOrdered); }
public static void GetEnemies(TNLConnection session) { //return; var coid = session.CurrentCharacter.GetCOID(); CheckCache(coid); var packet = new Packet(Opcode.GetEnemiesResponse); var t = Cache[coid]; var enemyEntries = t.Item2.Where(e => e.Type == SocialType.Enemy).ToList(); var count = enemyEntries.Count; packet.WriteInteger(count >= 20 ? 20 : count); var j = 0; foreach (var se in enemyEntries) { if (!(se is EnemyEntry)) // should never happen continue; packet.WriteLong(se.Character); packet.WriteLong(se.OtherCharacter); packet.WriteInteger(se.Level); packet.WriteInteger(se.LastContinentId); packet.WriteInteger((se as EnemyEntry).TimesKilled); packet.WriteInteger((se as EnemyEntry).TimesKilledBy); packet.WriteByte((se as EnemyEntry).Race); packet.WriteByte(se.Class); packet.WriteBoolean(se.Online); packet.WriteUtf8StringOn(se.Name, 17); packet.WritePadding(4); if (++j == 20) break; } for (var i = 0; i < 20 - j; ++i) packet.WritePadding(56); session.SendPacket(packet, RPCGuaranteeType.RPCGuaranteedOrdered); }
public override void WriteToCreatePacket(Packet packet, Boolean extended = false) { base.WriteToCreatePacket(packet, extended); #region Create Armor ArmorSpecific.WriteToPacket(packet); packet.WriteSingle(CloneBaseObject.SimpleObjectSpecific.Mass); packet.WriteUtf8StringOn(MangledName, 100); packet.WriteShort(_varianceDefenseBonus); packet.WritePadding(2); #endregion Create Armor }
public override void WriteToCreatePacket(Packet packet, Boolean extended = false) { base.WriteToCreatePacket(packet, extended); #region Create Wheel Set packet.WriteSingle(_frictionGravel); // friction gravel packet.WriteSingle(_frictionIce); // friction ice packet.WriteSingle(_frictionMud); // friction mud packet.WriteSingle(_frictionPaved); // friction paved packet.WriteSingle(_frictionPlains); // friction plains packet.WriteSingle(_frictionSand); // friction sand packet.WriteBoolean(_isDefault); // is default packet.WriteUtf8StringOn(MangledName, 100); // name packet.WritePadding(3); #endregion Create Wheel Set }
public static void GetFriends(TNLConnection session) { //return; var coid = session.CurrentCharacter.GetCOID(); CheckCache(coid); var packet = new Packet(Opcode.GetFriendsResponse); var t = Cache[coid]; var friendEntries = t.Item2.Where(e => e.Type == SocialType.Friend).ToList(); var count = friendEntries.Count; packet.WriteInteger(count >= 20 ? 20 : count); var j = 0; foreach (var se in friendEntries) { packet.WriteLong(se.Character); packet.WriteLong(se.OtherCharacter); packet.WriteInteger(se.Level); packet.WriteInteger(se.LastContinentId); packet.WriteByte(se.Class); packet.WriteBoolean(se.Online); packet.WriteUtf8StringOn(se.Name, 17); packet.WritePadding(5); if (++j == 20) break; } for (var i = 0; i < 20 - j; ++i) packet.WritePadding(48); session.SendPacket(packet, RPCGuaranteeType.RPCGuaranteedOrdered); }
public static void GetIgnored(TNLConnection session) { //return; var coid = session.CurrentCharacter.GetCOID(); CheckCache(coid); var packet = new Packet(Opcode.GetIgnoredResponse); var t = Cache[coid]; var ignoredEntries = t.Item2.Where(e => e.Type == SocialType.Ignore).ToList(); var count = ignoredEntries.Count; packet.WriteInteger(count >= 20 ? 20 : count); var j = 0; foreach (var se in ignoredEntries) { packet.WriteLong(se.OtherCharacter); if (++j == 20) break; } for (var i = 0; i < 20 - j; ++i) packet.WritePadding(8); packet.WriteUtf8StringOn("", 17); packet.WritePadding(7); session.SendPacket(packet, RPCGuaranteeType.RPCGuaranteedOrdered); }
private static Packet ConstructChatPacket(ChatType type, Boolean isGm, String recipient, String sender, String msg) { var msglen = (Int16) msg.Length; var p = new Packet(Opcode.Chat); p.WriteInteger((UInt32) type); p.WriteBoolean(isGm); p.WriteUtf8StringOn(recipient, 17); p.WriteUtf8StringOn(sender, 17); p.WritePadding(1).WriteShort(msglen); p.WriteUtf8StringOn(msg, msglen); p.WriteByte(0); return p; }
public override void WriteToCreatePacket(Packet packet, Boolean extended = false) { base.WriteToCreatePacket(packet, extended); #region Create Weapon packet.WriteSingle(_varianceRange); packet.WriteSingle(_varianceRefireRate); packet.WriteSingle(_varianceDamageMinimum); packet.WriteSingle(_varianceDamageMaximum); packet.WriteShort(_varianceOffensiveBonus); packet.WritePadding(2); packet.WriteSingle(_prefixAccurayBonus); packet.WriteShort(_prefixPenetrationBonus); packet.WritePadding(2); packet.WriteInteger(_rechargeInterval); packet.WriteSingle(CloneBaseObject.SimpleObjectSpecific.Mass); packet.WriteSingle(_rangeMinimum); packet.WriteSingle(_rangeMaximum); packet.WriteSingle(_validArc); _dmgMinimum.WriteToPacket(packet); _dmgMaximum.WriteToPacket(packet); packet.WriteUtf8StringOn("", 100); packet.WritePadding(4); #endregion Create Weapon }
public void WritePacket(Packet packet) { //packet.WritePadding(4); // SVOG header begin --> packet.WriteInteger(0); // Region Id packet.WriteInteger(0); // Region Type packet.WriteByte(1); // Region Level packet.WritePadding(3); packet.WriteInteger(0); // Layer Id packet.WriteInteger(_continentObject.Objective); // Objective Index packet.WriteUtf8StringOn(String.Format("{0}.fam", _continentObject.MapFileName), 65); // Map Name packet.WriteBoolean(_continentObject.IsTown); // Is Town packet.WriteBoolean(_continentObject.IsArena); // Is Arena packet.WritePadding(1); packet.WriteInteger(_continentObject.OwningFaction); // Race Faction packet.WriteInteger(ContinentId); // Continent Object ID packet.WriteBoolean(_continentObject.IsPersistent); // Is Persistent packet.WritePadding(3); packet.WriteInteger(MapEntry.IterationVersion); // Map Iteration Version packet.WriteInteger(_continentObject.ContestedMission); // Contested Mission Id packet.WritePadding(4); packet.WriteLong(ContinentId); // COID Map // SVOG header end <-- packet.WriteInteger(123456789); // Temporal Random Seed packet.WriteLong(ContinentId); // COID Map packet.WriteShort(0); // Number of Module Selections // for NumberOfModuleSelections { 24 byte } // CND Unaligned Vector 3 begin --> packet.WriteSingle(0.0f); packet.WriteSingle(0.0f); packet.WriteSingle(0.0f); // CND Unaligned Vector 3 end <-- packet.WriteShort(0); /*packet.WriteShort(36); // Weather Count // Weather Update begin --> packet.WriteInteger(0x2069); packet.WriteLong(0); packet.WriteLong(0); packet.WriteLong(0); packet.WriteLong(0);*/ // Weather Update end <-- }
public override void WriteToCreatePacket(Packet packet, Boolean extended = false) { base.WriteToCreatePacket(packet, extended); #region Create Vehicle packet.WriteLong(CoidCurrentOwner); // current owner coid packet.WriteInteger(SpawnOwnerCoid); // spawn owner coid for (var i = 0; i < 8; ++i) // arr id tricks packet.WriteInteger(TrickIds[i]); packet.WriteInteger(PrimaryColor); // color primary packet.WriteInteger(SecondaryColor); // color secondary packet.WriteShort(_armorAdd); // armor add packet.WritePadding(2); packet.WriteInteger(_powerMaxAdd); // power max add packet.WriteInteger(_heatMaxAdd); // heat max add packet.WriteShort(_cooldownAdd); // cooldownadd packet.WriteShort(_inventorySlots); // inventoryslots packet.WriteSingle(_maxWtWeaponFront); // max wt weapon front packet.WriteSingle(_maxWtWeaponTurret); // max wt weapon turret packet.WriteSingle(_maxWtWeaponRear); // max wt weapon rear packet.WriteSingle(_maxWtArmor); // max wt armor packet.WriteSingle(_maxWtPowerPlant); // max wt power plant packet.WriteSingle(SpeedAdd); // speed add packet.WriteSingle(BrakesMaxTorqueFrontMultiplier); // brakes max torque front multiplier packet.WriteSingle(BrakesMaxTorqueRearAdjustMultiplier); // brakes max torque rear adjust multiplies packet.WriteSingle(SteeringMaxAngleMultiplier); // steering max angle multiplier packet.WriteSingle(SteeringFullSpeedLimitMultiplier); // steering full speed limit multiplier packet.WriteSingle(AVDNormalSpinDampeningMultiplier); // AVD normal spin dampening multiplier packet.WriteSingle(AVDCollisionSpinDampeningAdjust); // AVD collision spin dampening multiplier packet.WriteSingle(_kmTravelled); // km travelled packet.WriteBoolean(IsTrailer); // is trailer packet.WriteBoolean(false); // is in inventory packet.WriteBoolean(VehicleIsActive); // is active packet.WriteByte(Trim); // trim packet.WritePadding(4); #region Ornament packet.WriteOpcode(Opcode.CreateSimpleObject); if (_ornament != null) // Ornament _ornament.WriteToCreatePacket(packet, extended); else WriteEmptyObjectToPacket(packet); #endregion #region Race Item packet.WriteOpcode(Opcode.CreateSimpleObject); if (_raceItem != null && !TNLInterface.Instance.Adaptive) // Race Item _raceItem.WriteToCreatePacket(packet, extended); else WriteEmptyObjectToPacket(packet); #endregion #region Power Plant packet.WriteOpcode(Opcode.CreatePowerPlant); if (_powerPlant != null) // Power Plant _powerPlant.WriteToCreatePacket(packet); else PowerPlant.WriteEmptyObjectToPacket(packet); #endregion #region Wheel Set packet.WriteOpcode(Opcode.CreateWheelSet); if (_wheelSet != null) // Wheel set _wheelSet.WriteToCreatePacket(packet); else Debug.Assert(false, "WHEELSETNEK KELL LENNIE!"); #endregion #region Armor packet.WriteOpcode(Opcode.CreateArmor); if (_armor != null) // Armor _armor.WriteToCreatePacket(packet); else Armor.WriteEmptyObjectToPacket(packet); #endregion #region Melee Weapon packet.WriteOpcode(Opcode.CreateWeapon); if (_meleeWeapon != null) // Weapon Melee _meleeWeapon.WriteToCreatePacket(packet); else Weapon.WriteEmptyObjectToPacket(packet); #endregion #region Front Weapon packet.WriteOpcode(Opcode.CreateWeapon); if (_weapons[0] != null) // Weapon Front _weapons[0].WriteToCreatePacket(packet); else Weapon.WriteEmptyObjectToPacket(packet); #endregion #region Turret Weapon packet.WriteOpcode(Opcode.CreateWeapon); if (_weapons[1] != null) // Weapon Turret _weapons[1].WriteToCreatePacket(packet); else Weapon.WriteEmptyObjectToPacket(packet); #endregion #region Rear Weapon packet.WriteOpcode(Opcode.CreateWeapon); if (_weapons[2] != null) // Weapon Rear _weapons[2].WriteToCreatePacket(packet); else Weapon.WriteEmptyObjectToPacket(packet); #endregion packet.WriteInteger(CurrentPathId); // current path id packet.WriteInteger(ExtraPathId); // extra path id packet.WriteSingle(PatrolDistance); // patrol distance packet.WriteBoolean(PathReversing); // path reversing packet.WriteBoolean(PathIsRoad); // path is road packet.WritePadding(2); packet.WriteInteger(VehicleTemplateId); packet.WritePadding(4); packet.WriteLong(GetTFIDMurderer().Coid); if (_weapons[0] != null) packet.WriteInteger(_weapons[0].GetCBID()); else packet.WriteInteger(-1); // front weapon cbid if (_weapons[1] != null) packet.WriteInteger(_weapons[1].GetCBID()); else packet.WriteInteger(-1); // turret weapon cbid if (_weapons[2] != null) packet.WriteInteger(_weapons[2].GetCBID()); else packet.WriteInteger(-1); // rear weapon cbid packet.WriteUtf8StringOn(VehicleName, 33); packet.WritePadding(3); #endregion Create Vehicle if (!extended) return; #region Create Vehicle Extended packet.WriteShort(0); // num inventory slots packet.WriteShort(0); // inventory size packet.WritePadding(4); for (var i = 0; i < 512; ++i) packet.WriteLong(0); #endregion Create Vehicle Extended }
public override void WriteToCreatePacket(Packet packet, Boolean extended = false) { packet.WriteInteger(CBID); packet.WriteLong(-1L); // coid Store packet.WriteInteger(GetCurrentHP() + 100); packet.WriteInteger(GetMaximumHP() + 100); packet.WriteInteger(GetValue()); packet.WriteInteger(GetIDFaction()); packet.WriteInteger(TeamFaction); packet.WriteInteger(CustomValue); for (var i = 0; i < 5; ++i) // prefix id packet.WriteInteger(-1); for (var i = 0; i < 5; ++i) // gadget id packet.WriteInteger(-1); for (var i = 0; i < 5; ++i) // prefix level packet.WriteShort(0); for (var i = 0; i < 5; ++i) // gadget level packet.WriteShort(0); packet.WriteSingle(Position.X); packet.WriteSingle(Position.Y); packet.WriteSingle(Position.Z); packet.WriteSingle(Rotation.X); packet.WriteSingle(Rotation.Y); packet.WriteSingle(Rotation.Z); packet.WriteSingle(Rotation.W); packet.WriteSingle(Scale); packet.WriteInteger(GetQuantity()); packet.WriteByte(InventoryPositionX); packet.WriteByte(InventoryPositionY); packet.WriteBoolean(GetIsCorpse()); // is corpse packet.WritePadding(5); packet.WriteTFID(COID); packet.WriteBoolean(false); // will equip packet.WriteBoolean(false); // is item link packet.WriteBoolean(false); // is in inventory packet.WriteByte(SkillLevel1); packet.WriteByte(SkillLevel2); packet.WriteByte(SkillLevel3); packet.WriteBoolean(false); // is identified packet.WriteBoolean(false); // possible mission item packet.WriteBoolean(false); // tempitem packet.WriteBoolean((UnkFlags & UnkFlags.IsKit) != 0); packet.WriteBoolean(false); // isinfinite packet.WriteBoolean((UnkFlags & UnkFlags.IsBound) != 0); packet.WriteShort(UsesLeft); packet.WriteUtf8StringOn(CustomizedName, 17); packet.WriteBoolean(MadeFromMemory); packet.WriteBoolean(false); // is mail packet.WritePadding(1); packet.WriteShort((Int16)MaxGadgets); packet.WriteShort((Int16)RequiredLevel); packet.WriteShort((Int16)RequiredCombat); packet.WriteShort((Int16)RequiredPerception); packet.WriteShort((Int16)RequiredTech); packet.WriteShort((Int16)RequiredTheory); packet.WritePadding(2); packet.WriteInteger(ItemTemplateId); packet.WritePadding(4); }