Guest User

Tutorial Flood para Power Pixel ~ xNectar

a guest
Dec 1st, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.55 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using Plus.Communication.Packets.Outgoing;
  8. using Plus.Communication.Packets.Outgoing.Rooms.Avatar;
  9. using Plus.Communication.Packets.Outgoing.Rooms.Chat;
  10. using Plus.Core;
  11. using Plus.HabboHotel.GameClients;
  12. using Plus.HabboHotel.Groups;
  13. using Plus.HabboHotel.Items;
  14. using Plus.HabboHotel.Pathfinding;
  15. using Plus.HabboHotel.Rooms.AI;
  16. using Plus.HabboHotel.Rooms.Games;
  17.  
  18. using Plus.HabboHotel.Users;
  19. using Plus.Communication.Packets.Incoming;
  20.  
  21. using Plus.HabboHotel.Rooms.Games.Freeze;
  22. using Plus.HabboHotel.Rooms.Games.Teams;
  23.  
  24. namespace Plus.HabboHotel.Rooms
  25. {
  26. public class RoomUser
  27. {
  28. public bool AllowOverride;
  29. public BotAI BotAI;
  30. public RoomBot BotData;
  31. public bool CanWalk;
  32. public int CarryItemID; //byte
  33. public int CarryTimer; //byte
  34. public int ChatSpamCount = 0;
  35. public int ChatSpamTicks = 16;
  36. public ItemEffectType CurrentItemEffect;
  37. public int DanceId;
  38. public bool FastWalking = false;
  39. public bool SuperFastWalking = false;
  40. public int FreezeCounter;
  41. public int FreezeLives;
  42. public bool Freezed;
  43. public bool Frozen;
  44. public int GateId;
  45.  
  46. public int GoalX; //byte
  47. public int GoalY; //byte
  48. public int HabboId;
  49. public int HorseID = 0;
  50. public int IdleTime; //byte
  51. public bool InteractingGate;
  52. public int InternalRoomID;
  53. public bool IsAsleep;
  54. public bool IsWalking;
  55. public int LastBubble = 0;
  56. public double LastInteraction;
  57. public Item LastItem = null;
  58. public int LockedTilesCount;
  59.  
  60. public List<Vector2D> Path = new List<Vector2D>();
  61. public bool PathRecalcNeeded = false;
  62. public int PathStep = 1;
  63. public Pet PetData;
  64.  
  65. public int PrevTime;
  66. public bool RidingHorse = false;
  67. public int RoomId;
  68. public int RotBody; //byte
  69. public int RotHead; //byte
  70.  
  71. public bool SetStep;
  72. public int SetX; //byte
  73. public int SetY; //byte
  74. public double SetZ;
  75. public double SignTime;
  76. public byte SqState;
  77. public Dictionary<string, string> Statusses;
  78. public int TeleDelay; //byte
  79. public bool TeleportEnabled;
  80. public bool UpdateNeeded;
  81. public int VirtualId;
  82.  
  83. public int X; //byte
  84. public int Y; //byte
  85. public double Z;
  86.  
  87. public FreezePowerUp banzaiPowerUp;
  88. public bool isLying = false;
  89. public bool isSitting = false;
  90. private GameClient mClient;
  91. private Room mRoom;
  92. public bool moonwalkEnabled = false;
  93. public bool shieldActive;
  94. public int shieldCounter;
  95. public TEAM Team;
  96. public bool FreezeInteracting;
  97. public int UserId;
  98. public bool IsJumping;
  99.  
  100. public bool isRolling = false;
  101. public int rollerDelay = 0;
  102.  
  103. public int LLPartner = 0;
  104. public double TimeInRoom = 0;
  105.  
  106. public RoomUser(int HabboId, int RoomId, int VirtualId, Room room)
  107. {
  108. this.Freezed = false;
  109. this.HabboId = HabboId;
  110. this.RoomId = RoomId;
  111. this.VirtualId = VirtualId;
  112. this.IdleTime = 0;
  113.  
  114. this.X = 0;
  115. this.Y = 0;
  116. this.Z = 0;
  117. this.PrevTime = 0;
  118. this.RotHead = 0;
  119. this.RotBody = 0;
  120. this.UpdateNeeded = true;
  121. this.Statusses = new Dictionary<string, string>();
  122.  
  123. this.TeleDelay = -1;
  124. this.mRoom = room;
  125.  
  126. this.AllowOverride = false;
  127. this.CanWalk = true;
  128.  
  129.  
  130. this.SqState = 3;
  131.  
  132. this.InternalRoomID = 0;
  133. this.CurrentItemEffect = ItemEffectType.NONE;
  134.  
  135. this.FreezeLives = 0;
  136. this.InteractingGate = false;
  137. this.GateId = 0;
  138. this.LastInteraction = 0;
  139. this.LockedTilesCount = 0;
  140.  
  141. this.IsJumping = false;
  142. this.TimeInRoom = 0;
  143. }
  144.  
  145.  
  146. public Point Coordinate
  147. {
  148. get { return new Point(X, Y); }
  149. }
  150.  
  151. public bool IsPet
  152. {
  153. get { return (IsBot && BotData.IsPet); }
  154. }
  155.  
  156. public int CurrentEffect
  157. {
  158. get { return GetClient().GetHabbo().Effects().CurrentEffect; }
  159. }
  160.  
  161.  
  162. public bool IsDancing
  163. {
  164. get
  165. {
  166. if (DanceId >= 1)
  167. {
  168. return true;
  169. }
  170.  
  171. return false;
  172. }
  173. }
  174.  
  175. public bool NeedsAutokick
  176. {
  177. get
  178. {
  179. if (IsBot)
  180. return false;
  181.  
  182. if (GetClient() == null || GetClient().GetHabbo() == null)
  183. return true;
  184.  
  185. if (GetClient().GetHabbo().GetPermissions().HasRight("mod_tool") || GetRoom().OwnerId == HabboId)
  186. return false;
  187.  
  188. if (GetRoom().Id == 1649919)
  189. return false;
  190.  
  191. if (IdleTime >= 7200)
  192. return true;
  193.  
  194. return false;
  195. }
  196. }
  197.  
  198. public bool IsTrading
  199. {
  200. get
  201. {
  202. if (IsBot)
  203. return false;
  204.  
  205. if (Statusses.ContainsKey("trd"))
  206. return true;
  207.  
  208. return false;
  209. }
  210. }
  211.  
  212. public bool IsBot
  213. {
  214. get
  215. {
  216. if (BotData != null)
  217. return true;
  218.  
  219. return false;
  220. }
  221. }
  222.  
  223. public string GetUsername()
  224. {
  225. if (IsBot)
  226. return string.Empty;
  227.  
  228. if (GetClient() != null)
  229. {
  230. if (GetClient().GetHabbo() != null)
  231. {
  232. return GetClient().GetHabbo().Username;
  233. }
  234. else
  235. return PlusEnvironment.GetUsernameById(HabboId);
  236.  
  237. }
  238. else
  239. return PlusEnvironment.GetUsernameById(HabboId);
  240. }
  241.  
  242. public void UnIdle()
  243. {
  244. if (!IsBot)
  245. {
  246. if (GetClient() != null && GetClient().GetHabbo() != null)
  247. GetClient().GetHabbo().TimeAFK = 0;
  248. }
  249.  
  250. IdleTime = 0;
  251.  
  252. if (IsAsleep)
  253. {
  254. IsAsleep = false;
  255. GetRoom().SendMessage(new SleepComposer(this, false));
  256. }
  257. }
  258.  
  259. public void Dispose()
  260. {
  261. Statusses.Clear();
  262. mRoom = null;
  263. mClient = null;
  264. }
  265.  
  266. public void Chat(string Message, bool Shout, int colour = 0)
  267. {
  268. if (GetRoom() == null)
  269. return;
  270.  
  271. if (!IsBot)
  272. return;
  273.  
  274.  
  275. if (IsPet)
  276. {
  277. foreach (RoomUser User in GetRoom().GetRoomUserManager().GetUserList().ToList())
  278. {
  279. if (User == null || User.IsBot)
  280. continue;
  281.  
  282. if (User.GetClient() == null || User.GetClient().GetHabbo() == null)
  283. return;
  284.  
  285. if (!User.GetClient().GetHabbo().AllowPetSpeech)
  286. User.GetClient().SendMessage(new ChatComposer(VirtualId, Message, 0, 0));
  287. }
  288. }
  289. else
  290. {
  291. foreach (RoomUser User in GetRoom().GetRoomUserManager().GetUserList().ToList())
  292. {
  293. if (User == null || User.IsBot)
  294. continue;
  295.  
  296. if (User.GetClient() == null || User.GetClient().GetHabbo() == null)
  297. return;
  298.  
  299. if (!User.GetClient().GetHabbo().AllowBotSpeech)
  300. User.GetClient().SendMessage(new ChatComposer(VirtualId, Message, 0, (colour == 0 ? 2 : colour)));
  301. }
  302. }
  303. }
  304.  
  305. public void HandleSpamTicks()
  306. {
  307. if (ChatSpamTicks >= 0)
  308. {
  309. ChatSpamTicks--;
  310.  
  311. if (ChatSpamTicks == -1)
  312. {
  313. ChatSpamCount = 0;
  314. }
  315. }
  316. }
  317.  
  318. public bool IncrementAndCheckFlood(out int MuteTime)
  319. {
  320. MuteTime = 0;
  321.  
  322. ChatSpamCount++;
  323. if (ChatSpamTicks == -1)
  324. ChatSpamTicks = 8;
  325. else if (ChatSpamCount >= 6)
  326. {
  327. if (GetClient().GetHabbo().GetPermissions().HasRight("events_staff"))
  328. MuteTime = 20;
  329. else if (GetClient().GetHabbo().GetPermissions().HasRight("gold_vip"))
  330. MuteTime = 1;
  331. else if (GetClient().GetHabbo().GetPermissions().HasRight("silver_vip"))
  332. MuteTime = 1;
  333. else
  334. MuteTime = 30;
  335.  
  336. GetClient().GetHabbo().FloodTime = PlusEnvironment.GetUnixTimestamp() + MuteTime;
  337.  
  338. ChatSpamCount = 0;
  339. return true;
  340. }
  341. return false;
  342. }
  343.  
  344. public void OnChat(int Colour, string Message, bool Shout)
  345. {
  346. if (GetClient() == null || GetClient().GetHabbo() == null || mRoom == null)
  347. return;
  348.  
  349. if (mRoom.GetWired().TriggerEvent(Items.Wired.WiredBoxType.TriggerUserSays, GetClient().GetHabbo(), Message))
  350. return;
  351.  
  352.  
  353. GetClient().GetHabbo().HasSpoken = true;
  354.  
  355. if (mRoom.WordFilterList.Count > 0 && !GetClient().GetHabbo().GetPermissions().HasRight("word_filter_override"))
  356. {
  357. Message = mRoom.GetFilter().CheckMessage(Message);
  358. }
  359.  
  360. ServerPacket Packet = null;
  361. if (Shout)
  362. Packet = new ShoutComposer(VirtualId, Message, PlusEnvironment.GetGame().GetChatManager().GetEmotions().GetEmotionsForText(Message), Colour);
  363. else
  364. Packet = new ChatComposer(VirtualId, Message, PlusEnvironment.GetGame().GetChatManager().GetEmotions().GetEmotionsForText(Message), Colour);
  365.  
  366.  
  367. if (GetClient().GetHabbo().TentId > 0)
  368. {
  369. mRoom.SendToTent(GetClient().GetHabbo().Id, GetClient().GetHabbo().TentId, Packet);
  370.  
  371. Packet = new WhisperComposer(this.VirtualId, "[Tent Chat] " + Message, 0, Colour);
  372.  
  373. List<RoomUser> ToNotify = mRoom.GetRoomUserManager().GetRoomUserByRank(2);
  374.  
  375. if (ToNotify.Count > 0)
  376. {
  377. foreach (RoomUser user in ToNotify)
  378. {
  379. if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null ||
  380. user.GetClient().GetHabbo().TentId == GetClient().GetHabbo().TentId)
  381. {
  382. continue;
  383. }
  384.  
  385. user.GetClient().SendMessage(Packet);
  386. }
  387. }
  388. }
  389. else
  390. {
  391. foreach (RoomUser User in mRoom.GetRoomUserManager().GetRoomUsers().ToList())
  392. {
  393. if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null || User.GetClient().GetHabbo().MutedUsers.Contains(mClient.GetHabbo().Id))
  394. continue;
  395.  
  396. if (mRoom.chatDistance > 0 && Gamemap.TileDistance(this.X, this.Y, User.X, User.Y) > mRoom.chatDistance)
  397. continue;
  398.  
  399. User.GetClient().SendMessage(Packet);
  400. }
  401. }
  402.  
  403. #region Pets/Bots responces
  404. if (Shout)
  405. {
  406. foreach (RoomUser User in mRoom.GetRoomUserManager().GetUserList().ToList())
  407. {
  408. if (!User.IsBot)
  409. continue;
  410.  
  411. if (User.IsBot)
  412. User.BotAI.OnUserShout(this, Message);
  413. }
  414. }
  415. else
  416. {
  417. foreach (RoomUser User in mRoom.GetRoomUserManager().GetUserList().ToList())
  418. {
  419. if (!User.IsBot)
  420. continue;
  421.  
  422. if (User.IsBot)
  423. User.BotAI.OnUserSay(this, Message);
  424. }
  425. }
  426. #endregion
  427.  
  428. }
  429.  
  430. public void ClearMovement(bool Update)
  431. {
  432. IsWalking = false;
  433. Statusses.Remove("mv");
  434. GoalX = 0;
  435. GoalY = 0;
  436. SetStep = false;
  437. SetX = 0;
  438. SetY = 0;
  439. SetZ = 0;
  440.  
  441. if (Update)
  442. {
  443. UpdateNeeded = true;
  444. }
  445. }
  446.  
  447. public void MoveTo(Point c)
  448. {
  449. MoveTo(c.X, c.Y);
  450. }
  451.  
  452. public void MoveTo(int pX, int pY, bool pOverride)
  453. {
  454. if (TeleportEnabled)
  455. {
  456. UnIdle();
  457. GetRoom().SendMessage(GetRoom().GetRoomItemHandler().UpdateUserOnRoller(this, new Point(pX, pY), 0, GetRoom().GetGameMap().SqAbsoluteHeight(GoalX, GoalY)));
  458. if (Statusses.ContainsKey("sit"))
  459. Z -= 0.3;
  460. UpdateNeeded = true;
  461. return;
  462. }
  463.  
  464. if ((GetRoom().GetGameMap().SquareHasUsers(pX, pY) && !pOverride) || Frozen)
  465. return;
  466.  
  467. UnIdle();
  468.  
  469. GoalX = pX;
  470. GoalY = pY;
  471. PathRecalcNeeded = true;
  472. FreezeInteracting = false;
  473. }
  474.  
  475. public void MoveTo(int pX, int pY)
  476. {
  477. MoveTo(pX, pY, false);
  478. }
  479.  
  480. public void UnlockWalking()
  481. {
  482. AllowOverride = false;
  483. CanWalk = true;
  484. }
  485.  
  486.  
  487. public void SetPos(int pX, int pY, double pZ)
  488. {
  489. X = pX;
  490. Y = pY;
  491. Z = pZ;
  492. }
  493.  
  494. public void CarryItem(int Item)
  495. {
  496. CarryItemID = Item;
  497.  
  498. if (Item > 0)
  499. CarryTimer = 1111240000;
  500. else
  501. CarryTimer = 0;
  502.  
  503. GetRoom().SendMessage(new CarryObjectComposer(VirtualId, Item));
  504. }
  505.  
  506.  
  507. public void SetRot(int Rotation, bool HeadOnly)
  508. {
  509. if (Statusses.ContainsKey("lay") || IsWalking)
  510. {
  511. return;
  512. }
  513.  
  514. int diff = RotBody - Rotation;
  515.  
  516. RotHead = RotBody;
  517.  
  518. if (Statusses.ContainsKey("sit") || HeadOnly)
  519. {
  520. if (RotBody == 2 || RotBody == 4)
  521. {
  522. if (diff > 0)
  523. {
  524. RotHead = RotBody - 1;
  525. }
  526. else if (diff < 0)
  527. {
  528. RotHead = RotBody + 1;
  529. }
  530. }
  531. else if (RotBody == 0 || RotBody == 6)
  532. {
  533. if (diff > 0)
  534. {
  535. RotHead = RotBody - 1;
  536. }
  537. else if (diff < 0)
  538. {
  539. RotHead = RotBody + 1;
  540. }
  541. }
  542. }
  543. else if (diff <= -2 || diff >= 2)
  544. {
  545. RotHead = Rotation;
  546. RotBody = Rotation;
  547. }
  548. else
  549. {
  550. RotHead = Rotation;
  551. }
  552.  
  553. UpdateNeeded = true;
  554. }
  555.  
  556. public void SetStatus(string Key, string Value)
  557. {
  558. if (Statusses.ContainsKey(Key))
  559. {
  560. Statusses[Key] = Value;
  561. }
  562. else
  563. {
  564. AddStatus(Key, Value);
  565. }
  566. }
  567.  
  568. public void AddStatus(string Key, string Value)
  569. {
  570. Statusses[Key] = Value;
  571. }
  572.  
  573. public void RemoveStatus(string Key)
  574. {
  575. if (Statusses.ContainsKey(Key))
  576. {
  577. Statusses.Remove(Key);
  578. }
  579. }
  580.  
  581. public void ApplyEffect(int effectID)
  582. {
  583. if (IsBot)
  584. {
  585. this.mRoom.SendMessage(new AvatarEffectComposer(VirtualId, effectID));
  586. return;
  587. }
  588.  
  589. if (IsBot || GetClient() == null || GetClient().GetHabbo() == null || GetClient().GetHabbo().Effects() == null)
  590. return;
  591.  
  592. GetClient().GetHabbo().Effects().ApplyEffect(effectID);
  593. }
  594.  
  595. public Point SquareInFront
  596. {
  597. get
  598. {
  599. var Sq = new Point(this.X, this.Y);
  600.  
  601. if (RotBody == 0)
  602. {
  603. Sq.Y--;
  604. }
  605. else if (RotBody == 2)
  606. {
  607. Sq.X++;
  608. }
  609. else if (RotBody == 4)
  610. {
  611. Sq.Y++;
  612. }
  613. else if (RotBody == 6)
  614. {
  615. Sq.X--;
  616. }
  617.  
  618. return Sq;
  619. }
  620. }
  621.  
  622. public Point SquareBehind
  623. {
  624. get
  625. {
  626. var Sq = new Point(this.X, this.Y);
  627.  
  628. if (RotBody == 0)
  629. {
  630. Sq.Y++;
  631. }
  632. else if (RotBody == 2)
  633. {
  634. Sq.X--;
  635. }
  636. else if (RotBody == 4)
  637. {
  638. Sq.Y--;
  639. }
  640. else if (RotBody == 6)
  641. {
  642. Sq.X++;
  643. }
  644.  
  645. return Sq;
  646. }
  647. }
  648.  
  649. public Point SquareLeft
  650. {
  651. get
  652. {
  653. var Sq = new Point(this.X, this.Y);
  654.  
  655. if (RotBody == 0)
  656. {
  657. Sq.X++;
  658. }
  659. else if (RotBody == 2)
  660. {
  661. Sq.Y--;
  662. }
  663. else if (RotBody == 4)
  664. {
  665. Sq.X--;
  666. }
  667. else if (RotBody == 6)
  668. {
  669. Sq.Y++;
  670. }
  671.  
  672. return Sq;
  673. }
  674. }
  675.  
  676. public Point SquareRight
  677. {
  678. get
  679. {
  680. var Sq = new Point(this.X, this.Y);
  681.  
  682. if (RotBody == 0)
  683. {
  684. Sq.X--;
  685. }
  686. else if (RotBody == 2)
  687. {
  688. Sq.Y++;
  689. }
  690. else if (RotBody == 4)
  691. {
  692. Sq.X++;
  693. }
  694. else if (RotBody == 6)
  695. {
  696. Sq.Y--;
  697. }
  698. return Sq;
  699. }
  700. }
  701.  
  702.  
  703. public GameClient GetClient()
  704. {
  705. if (IsBot)
  706. {
  707. return null;
  708. }
  709. if (mClient == null)
  710. mClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(HabboId);
  711. return mClient;
  712. }
  713.  
  714. private Room GetRoom()
  715. {
  716. if (mRoom == null)
  717. if (PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(RoomId, out mRoom))
  718. return mRoom;
  719.  
  720. return mRoom;
  721. }
  722. }
  723.  
  724. public enum ItemEffectType
  725. {
  726. NONE,
  727. SWIM,
  728. SwimLow,
  729. SwimHalloween,
  730. Iceskates,
  731. Normalskates,
  732. PublicPool,
  733. cross,
  734. trainer,
  735. jump,
  736. snow,
  737. faketile,
  738. //Skateboard?
  739. }
  740.  
  741. public static class ByteToItemEffectEnum
  742. {
  743. public static ItemEffectType Parse(byte pByte)
  744. {
  745. switch (pByte)
  746. {
  747. case 0:
  748. return ItemEffectType.NONE;
  749. case 1:
  750. return ItemEffectType.SWIM;
  751. case 2:
  752. return ItemEffectType.Normalskates;
  753. case 3:
  754. return ItemEffectType.Iceskates;
  755. case 4:
  756. return ItemEffectType.SwimLow;
  757. case 5:
  758. return ItemEffectType.SwimHalloween;
  759. case 6:
  760. return ItemEffectType.PublicPool;
  761. case 7:
  762. return ItemEffectType.cross;
  763. case 8:
  764. return ItemEffectType.trainer;
  765. case 9:
  766. return ItemEffectType.jump;
  767. case 10:
  768. return ItemEffectType.snow;
  769. case 11:
  770. return ItemEffectType.faketile;
  771. //case 7:
  772. //return ItemEffectType.Custom;
  773. default:
  774. return ItemEffectType.NONE;
  775. }
  776. }
  777. }
  778.  
  779. //0 = none
  780. //1 = pool
  781. //2 = normal skates
  782. //3 = ice skates
  783. }
Advertisement
Add Comment
Please, Sign In to add comment