/// <summary> /// </summary> /// <param name="charID"> /// </param> /// <param name="client"> /// </param> public void Read(int charID, Client client) { // Don't edit anything in this region // unless you are 300% sure you know what you're doing // Character is created and read when Client connects in Client.cs->CreateCharacter // client.CreateCharacter(charID); client.Server.Info( client, "Client connected. ID: {0} IP: {1} Character name: {2}", client.Character.Identity.Instance, client.ClientAddress, client.Character.Name); // now we have to start sending packets like // character stats, inventory, playfield info // and so on. I will put some packets here just // to get us in game. We have to start moving // these packets somewhere else and make packet // builders instead of sending (half) hardcoded // packets. /* send chat server info to client */ ChatServerInfo.Send(client); /* send playfield info to client */ PlayfieldAnarchyF.Send(client); var sendSCFUs = new IMSendPlayerSCFUs { toClient = client }; client.Playfield.SendSCFUsToClient(sendSCFUs); /* set SocialStatus to 0 */ client.Character.Stats[521].BaseValue = 0; Stat.Send(client, 521, 0, false); var identity = new Identity { Type = IdentityType.CanbeAffected, Instance = charID }; /* Action 167 Animation and Stance Data maybe? */ var message = new CharacterActionMessage { Identity = identity, Action = CharacterActionType.ChangeAnimationAndStance, Target = Identity.None, Parameter1 = 0x00000000, Parameter2 = 0x00000001 }; client.SendCompressed(message); var gameTimeMessage = new GameTimeMessage { Identity = identity, Unknown1 = 30024.0f, Unknown3 = 185408, Unknown4 = 80183.3125f }; client.SendCompressed(gameTimeMessage); /* set SocialStatus to 0 */ Stat.Set(client, 521, 0, false); /* again */ Stat.Set(client, 521, 0, false); /* visual */ SimpleCharFullUpdate.SendToPlayfield(client); /* inventory, items and all that */ FullCharacter.Send(client); var specials = new[] { new SpecialAttackInfo { Unknown1 = 0x0000AAC0, Unknown2 = 0x00023569, Unknown3 = 0x00000064, Unknown4 = "MAAT" }, new SpecialAttackInfo { Unknown1 = 0x0000A431, Unknown2 = 0x0000A430, Unknown3 = 0x00000090, Unknown4 = "DIIT" }, new SpecialAttackInfo { Unknown1 = 0x00011294, Unknown2 = 0x00011295, Unknown3 = 0x0000008E, Unknown4 = "BRAW" } }; var specialAttackWeaponMessage = new SpecialAttackWeaponMessage { Identity = identity, Specials = specials }; client.SendCompressed(specialAttackWeaponMessage); // done // Timers are allowed to update client stats now. client.Character.DoNotDoTimers = false; // spawn all active monsters to client // TODO: Implement NonPlayerCharacterHandler // NonPlayerCharacterHandler.SpawnMonstersInPlayfieldToClient(client, client.Character.PlayField); // TODO: Implement VendorHandler // if (VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField) > 0) // { // Shops // VendorHandler.GetVendorsInPF(client); // } // WeaponItemFullCharUpdate Maybe the right location , First Check if weapons present usually in equipment // Packets.WeaponItemFullUpdate.Send(client, client.Character); // TODO: create a better alternative to ProcessTimers // client.Character.ProcessTimers(DateTime.Now + TimeSpan.FromMilliseconds(200)); client.Character.CalculateSkills(); AppearanceUpdate.AnnounceAppearanceUpdate(client.Character); // done, so we call a hook. // Call all OnConnect script Methods Program.csc.CallMethod("OnConnect", client.Character); }
/// <summary> /// </summary> /// <param name="sendSCFUs"> /// </param> public void SendSCFUsToClient(IMSendPlayerSCFUs sendSCFUs) { Identity dontSendTo = sendSCFUs.toClient.Character.Identity; foreach (IEntity entity in this.Entities) { if (entity.Identity != dontSendTo) { if (entity.Identity.Type == IdentityType.CanbeAffected) { var temp = entity as INamedEntity; if (temp != null) { // TODO: make it NPC-safe SimpleCharFullUpdateMessage simpleCharFullUpdate = SimpleCharFullUpdate.ConstructMessage((Character)temp); sendSCFUs.toClient.SendCompressed(simpleCharFullUpdate); var charInPlay = new CharInPlayMessage { Identity = temp.Identity, Unknown = 0x00 }; sendSCFUs.toClient.SendCompressed(charInPlay); } } } } }