· 9 years ago · Jan 31, 2017, 03:10 PM
1roleplaymanager.cs
2using System;
3using System.Collections;
4using System.Collections.Generic;
5using System.Data;
6using System.IO;
7using System.Text;
8using System.Threading.Tasks;
9using System.Linq;
10using Plus.HabboHotel.GameClients;
11using Plus.HabboHotel.Items;
12using Plus.HabboHotel.Rooms;
13using Plus.HabboHotel.Rooms.RoomInvokedItems;
14using Plus.HabboHotel.Users;
15using Plus.HabboHotel.PathFinding;
16using Plus.HabboHotel.RoomBots;
17using Plus.HabboHotel.Pets;
18using Plus.Messages;
19using Plus.Messages.Parsers;
20using Plus.HabboHotel.Roleplay.Bots;
21using Plus.HabboHotel.Roleplay.Combat;
22using Plus.Database;
23using System.Drawing;
24using Plus.Util;
25using System.Threading;
26using Plus.HabboHotel.Rooms.Games;
27using Plus.HabboHotel.Groups;
28using Plus.HabboHotel.Roleplay;
29using Plus.HabboHotel.Roleplay.Timers;
30using Plus.HabboHotel.Roleplay.Radio;
31using System.Text.RegularExpressions;
32using System.Net;
33using Plus.Database.Manager.Database.Session_Details.Interfaces;
34using System.Collections.Concurrent;
35using Plus.HabboHotel.Roleplay.Misc;
36
37namespace Plus.HabboHotel.Roleplay.Misc
38{
39 public class RoleplayManager
40 {
41 public static int GlobalWorkSecondsInterval = 60;
42 public static bool GlobalChargeForTaxi = false;
43 public static int GlobalTaxiWaitTime = 25;
44 public static int VaultRobbery = 5000;
45 public static int NukesOccurred = 0;
46 public static int SlotsMachineCost = 50;
47 public static int SlotsMachinePrizeDivider = 8;
48 public static int SlotsMachineJackpotDivider = 3;
49
50 public static ConcurrentDictionary<uint, DateTime> EmptyTrashCans = new ConcurrentDictionary<uint, DateTime>();
51 internal static ConcurrentDictionary<RoomBot, RoomUser> ParamedicBots = new ConcurrentDictionary<RoomBot, RoomUser>();
52 public static ConcurrentDictionary<string, int> TimeIntensities = new ConcurrentDictionary<string, int>();
53 public static ConcurrentDictionary<string, string> WantedListData = new ConcurrentDictionary<string, string>();
54 public static bool PurgeTime = false;
55 public static bool ZombieInfection = false;
56 public static bool GVIPAlertsDisabled = false;
57
58
59 public static void saveAllStats()
60 {
61 lock (Plus.GetGame().GetClientManager().Clients.Values)
62 {
63 foreach (GameClient mClient in Plus.GetGame().GetClientManager().Clients.Values)
64 {
65 if (mClient == null)
66 continue;
67 if (mClient.GetHabbo() == null)
68 continue;
69 if (mClient.GetRoleplay() == null)
70 continue;
71
72 mClient.GetRoleplay().SaveStats();
73 }
74 }
75 }
76
77 public static bool WithinAttackDistance(RoomUser roomUser, RoomUser TargetroomUser)
78 {
79 if (roomUser.X + 1 == TargetroomUser.X && roomUser.Y == TargetroomUser.Y
80 || roomUser.X == TargetroomUser.X - 1 && roomUser.Y == TargetroomUser.Y + 1
81 || roomUser.X == TargetroomUser.X + 1 && roomUser.Y == TargetroomUser.Y - 1
82 || roomUser.X - 1 == TargetroomUser.X && roomUser.Y == TargetroomUser.Y ||
83 roomUser.Y + 1 == TargetroomUser.Y && roomUser.X == TargetroomUser.X ||
84 roomUser.Y - 1 == TargetroomUser.Y && roomUser.X == TargetroomUser.X ||
85 roomUser.X == TargetroomUser.X && roomUser.Y == TargetroomUser.Y)
86 {
87 return true;
88
89 }
90
91 return false;
92 }
93
94 public static bool isOnMoon(RoomItem item, RoomUser roomuser, GameClient session, uint BaseID = 1638)
95 {
96 uint baseItemID = BaseID;
97 if (item != null && roomuser != null && session != null)
98 {
99 if (item.BaseItem == baseItemID)
100 {
101 if (item.X == roomuser.X && item.Y == roomuser.Y || item.X == roomuser.X && item.Y + 1 == roomuser.Y ||
102 item.X + 1 == roomuser.X && item.Y + 1 == roomuser.Y ||
103 item.X + 1 == roomuser.X && item.Y == roomuser.Y)
104 {
105 return true;
106 }
107 else
108 return false;
109 }
110 else
111 return false;
112 }
113 else
114 return false;
115 }
116
117 public static bool isOnMine(RoomItem item, RoomUser roomuser, GameClient session)
118 {
119 uint baseItemID = 555444;
120 if (item != null && roomuser != null && session != null)
121 {
122 if (item.BaseItem == baseItemID)
123 {
124 if (item.X == roomuser.X && item.Y == roomuser.Y)
125 {
126 return true;
127 }
128 else
129 return false;
130 }
131 else
132 return false;
133 }
134 else
135 return false;
136 }
137
138 public static void init()
139 {
140 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
141 {
142 dbClient.RunFastQuery("UPDATE rp_stats SET last_cw_team = '" + String.Empty + "' WHERE last_cw_team != '" + String.Empty + "'");
143 }
144
145 FightPetManager.load();
146 Substances.load();
147 Bounties.LoadBounty();
148 }
149 public static Point GetPosSquare(string pos, RoomUser User)
150 {
151
152 Point Sq = new Point(User.X, User.Y);
153 int Rot = User.RotBody;
154
155 switch(pos)
156 {
157 case "behind":
158
159 if (Rot == 0)
160 {
161 Sq.Y++;
162 }
163 else if (Rot == 2)
164 {
165 Sq.X--;
166 }
167 else if (Rot == 4)
168 {
169 Sq.Y--;
170 }
171 else if (Rot == 6)
172 {
173 Sq.X++;
174 }
175 break;
176
177 case "infront":
178
179
180 if (Rot == 0)
181 {
182 Sq.Y--;
183 }
184 else if (Rot == 2)
185 {
186 Sq.X++;
187 }
188 else if (Rot == 4)
189 {
190 Sq.Y++;
191 }
192 else if (Rot == 6)
193 {
194 Sq.X--;
195 }
196
197 break;
198 }
199
200 return Sq;
201 }
202
203 public static int Distance(Vector2D Pos1, Vector2D Pos2)
204 {
205 return Math.Abs(Pos1.X - Pos2.X) + Math.Abs(Pos1.Y - Pos2.Y);
206 }
207
208 public static int UserDistance(GameClient User1, GameClient User2)
209 {
210 RoomUser one = null;
211 RoomUser two = null;
212 one = User1.GetHabbo().GetRoomUser();
213 two = User2.GetHabbo().GetRoomUser();
214
215 Vector2D Pos1 = new Vector2D(one.X,one.Y);
216 Vector2D Pos2 = new Vector2D(two.X,two.Y);
217
218 return Math.Abs(Pos1.X - Pos2.X) + Math.Abs(Pos1.Y - Pos2.Y);
219 }
220
221 public static int UserDistance(RoomUser one, RoomUser two)
222 {
223 Vector2D Pos1 = new Vector2D(one.X, one.Y);
224 Vector2D Pos2 = new Vector2D(two.X, two.Y);
225
226 return Math.Abs(Pos1.X - Pos2.X) + Math.Abs(Pos1.Y - Pos2.Y);
227 }
228
229 public static bool BypassRights(GameClient Session)
230 {
231 DataRow Row = null;
232
233 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
234 {
235 dbClient.SetQuery("SELECT * FROM rp_special_rights WHERE userid = " + Session.GetHabbo().Id + "");
236 Row = dbClient.GetRow();
237 if(Row != null)
238 {
239 return true;
240 }
241 }
242 return false;
243 }
244
245 public static bool PetExists(string PetName)
246 {
247 Dictionary<string, uint> TPets = new Dictionary<string, uint>();
248 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
249 {
250 dbClient.SetQuery("SELECT * FROM bots");
251 DataTable TData = dbClient.GetTable();
252
253 foreach (DataRow TPetRow in TData.Rows)
254 {
255 if (!TPets.ContainsKey(Convert.ToString(TPetRow["name"]).ToLower()))
256 {
257 TPets.Add(Convert.ToString(TPetRow["name"]).ToLower(), Convert.ToUInt32(TPetRow["id"]));
258 }
259 }
260 }
261
262 if (TPets.ContainsKey(PetName.ToLower()))
263 {
264 return true;
265 }
266
267 return false;
268 }
269
270 public static bool CreateQuickPet(GameClient Session, string PetType, string PetName)
271 {
272 string ExtraData = null;
273 string Itemname = "a0 pet0";
274 var petId = int.Parse(Itemname.Replace("a0 pet", string.Empty));
275 var PetData = ":1:D98961";
276
277 Itemname = FightPetManager.PetData[PetType.ToLower()].Data1;
278 petId = int.Parse(Itemname.Replace("a0 pet", string.Empty));
279 PetData = FightPetManager.PetData[PetType.ToLower()].Data2;
280
281 //
282
283 ExtraData = PetName + PetData;
284
285 #region Check if pet exists
286 if (PetExists(PetName.ToLower()))
287 {
288 return false;
289 }
290 #endregion
291
292 #region Create pet
293
294 var petData = PetData.Split(':');
295
296 Session.SendWhisper("PETID: " + petId + " ;; PETDATA1: " + petData[1] + " ;; PETDATA2: " + petData[2]);
297
298
299 var generatedPet = Catalogs.Catalog.CreatePet(Session.GetHabbo().Id, PetName, petId, petData[1], petData[2], 0);
300
301 var list = new List<UserItem>();
302
303 //
304 // BOOKMARK TODO: REDO PET LOADING @ LOGIN
305 Session.GetHabbo().GetInventoryComponent().AddPet(generatedPet);
306 // BOOKMARK
307 list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", 0u, true, false, 0, 0, string.Empty));
308
309
310 #endregion
311
312 #region Refresh roleplay pets
313 Dictionary<string, uint> Pets = new Dictionary<string, uint>();
314
315 try
316 {
317 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
318 {
319 dbClient.SetQuery("SELECT * FROM bots WHERE user_id = '" + Session.GetHabbo().Id + "'");
320 DataTable Data = dbClient.GetTable();
321
322
323 foreach (DataRow PetRow in Data.Rows)
324 {
325 if (!Pets.ContainsKey(Convert.ToString(PetRow["name"]).ToLower()))
326 Pets.Add(Convert.ToString(PetRow["name"]).ToLower(), Convert.ToUInt32(PetRow["id"]));
327 }
328
329 dbClient.RunFastQuery("UPDATE bots SET ai_type = 'fightpet', rp_str='35',rp_maxhealth='50', rp_type='" + PetType.ToLower() + "' WHERE id = " + generatedPet.PetId + "");
330
331
332 }
333
334 lock (Session.GetRoleplay().MyPets)
335 {
336 Session.GetRoleplay().MyPets.Clear();
337 Session.GetRoleplay().MyPets = Pets;
338 }
339 }
340 catch (Exception)
341 {
342
343 }
344
345 #endregion
346
347 #region Final changes
348
349 Session.GetMessageHandler().GetResponse().AppendInteger(list.Count);
350 foreach (var current3 in list) Session.GetMessageHandler().GetResponse().AppendInteger(current3.Id);
351 Session.GetMessageHandler().SendResponse();
352 Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
353 Session.GetHabbo().GetInventoryComponent().SerializePetInventory();
354
355
356 #endregion
357
358 #region Bring out pet
359 uint PetId = Session.GetRoleplay().MyPets[PetName.ToLower()];
360
361 FightPetManager Manager = new FightPetManager();
362
363 RoomBot Pet = Manager.DeployBotToRoom(Session, PetName.ToLower(), Session.GetHabbo().CurrentRoomId);
364
365
366 if (Pet == null)
367 {
368 return true;
369 }
370
371
372 Pet.RoomUser.Chat(null, "Thank you for adopting me master!! I will serve you forever and always!", true, 0, 0);
373 #endregion
374
375
376 return true;
377 }
378
379 public static bool SendParamedicBot(GameClient Session)
380 {
381
382 #region Null Checks
383 if (Session == null)
384 return false;
385 if (Session.GetHabbo() == null)
386 return false;
387 if (Session.GetHabbo().CurrentRoom == null)
388 return false;
389 if (Session.GetHabbo().CurrentRoom.GetGameMap() == null)
390 return false;
391 if (Session.GetHabbo().CurrentRoom.GetGameMap().Model == null)
392 return false;
393 #endregion
394
395 int ParaMedic = new Random().Next(1, 3);
396 string Name = "Kayaba";
397 string Figure = "sh-290-92.hr-3322-32.ea-3170-63.fa-1212-63.lg-280-82.ch-225-82.hd-615-10.ca-1819-63";
398
399 if (RoleplayData.Data.ContainsKey("paramedic_name" + ParaMedic) && RoleplayData.Data.ContainsKey("paramedic_figure" + ParaMedic))
400 {
401 Name = Convert.ToString(RoleplayData.Data["paramedic_name" + ParaMedic]);
402 Figure = Convert.ToString(RoleplayData.Data["paramedic_figure" + ParaMedic]);
403 }
404
405 RoomBot NewParamedic = MakeQuickBot("[Paramedic] " + Name,
406 AIType.HospitalBot,
407 Session.GetHabbo().CurrentRoomId,
408 Figure,
409 Session.GetHabbo().CurrentRoom.GetGameMap().Model.DoorX,
410 Session.GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
411
412 NewParamedic.InteractingWith = Session.GetHabbo().GetRoomUser();
413 NewParamedic.HospBotType = "paramedic_bot";
414 SendBotToRoom(NewParamedic, Session.GetHabbo().CurrentRoomId);
415
416 return true;
417 }
418
419 public static bool SendSwatBot(GameClient Session)
420 {
421
422 #region Null Checks
423 if (Session == null)
424 return false;
425 if (Session.GetHabbo() == null)
426 return false;
427 if (Session.GetHabbo().CurrentRoom == null)
428 return false;
429 if (Session.GetHabbo().CurrentRoom.GetGameMap() == null)
430 return false;
431 if (Session.GetHabbo().CurrentRoom.GetGameMap().Model == null)
432 return false;
433 #endregion
434
435 int ParaMedic = new Random().Next(1, 3);
436 string Name = "Rila-Kuma";
437 string Figure = "ea-3388-1189-1191.lg-270-110.ch-215-1189.wa-3263-110-1408.sh-300-110.cc-3420-110.ca-3085-62.ha-3173-1193";
438
439 if (RoleplayData.Data.ContainsKey("paramedic_name" + ParaMedic) && RoleplayData.Data.ContainsKey("paramedic_figure" + ParaMedic))
440 {
441 Name = Convert.ToString(RoleplayData.Data["paramedic_name" + ParaMedic]);
442 Figure = Convert.ToString(RoleplayData.Data["paramedic_figure" + ParaMedic]);
443 }
444
445 RoomBot NewParamedic = MakeQuickBot("[Swat] " + Name,
446 AIType.HospitalBot,
447 Session.GetHabbo().CurrentRoomId,
448 Figure,
449 Session.GetHabbo().CurrentRoom.GetGameMap().Model.DoorX,
450 Session.GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
451
452 NewParamedic.InteractingWith = Session.GetHabbo().GetRoomUser();
453 NewParamedic.HospBotType = "swat_bot";
454 SendBotToRoom(NewParamedic, Session.GetHabbo().CurrentRoomId);
455
456 return true;
457 }
458
459 public static void HandleDeath(GameClient TargetSession, string msg = "")
460 {
461 if(msg.Length > 3)
462 {
463 TargetSession.SendNotif(msg);
464 }
465 RoomUser User = null;
466
467 if (TargetSession.GetHabbo() != null)
468 {
469 if (TargetSession.GetHabbo().GetRoomUser() != null)
470 {
471 User = TargetSession.GetHabbo().GetRoomUser();
472 }
473 }
474
475 if (User != null || TargetSession != null)
476 {
477
478 if (TargetSession.GetRoleplay().Equiped != null)
479 {
480 TargetSession.GetRoleplay().Equiped = null;
481 User.ApplyEffect(0);
482 }
483
484
485 if (User == null)
486 return;
487
488
489 RoleplayManager.MakeLay(User);
490
491 User.Frozen = true;
492 TargetSession.GetRoleplay().SaveStatusComponents("dead");
493 HabboHotel.RoomBots.RoomBot NewParamedic = RoleplayManager.MakeQuickBot("[Paramedic] Kayaba", AIType.HospitalBot, TargetSession.GetHabbo().CurrentRoomId, "sh-290-92.hr-3322-32.ea-3170-63.fa-1212-63.lg-280-82.ch-225-82.hd-615-10.ca-1819-63", User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorX, User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
494 NewParamedic.InteractingWith = User;
495 NewParamedic.HospBotType = "paramedic_bot";
496 RoleplayManager.SendBotToRoom(NewParamedic, User.GetClient().GetHabbo().CurrentRoomId);
497
498 if (TargetSession == null)
499 {
500 //int lol = 1;
501 }
502 else
503 {
504 if (TargetSession.GetHabbo().CurrentRoom != null)
505 {
506 RoleplayManager.Shout(TargetSession, "*Passes out and wait for the ambulance to arives*", 10);
507 }
508 }
509
510
511 }
512 else
513 {
514
515 if (User == null)
516 return;
517
518 RoleplayManager.MakeLay(User);
519 User.Frozen = true;
520 TargetSession.GetRoleplay().SaveStatusComponents("dead");
521 HabboHotel.RoomBots.RoomBot NewParamedic = RoleplayManager.MakeQuickBot("[Paramedic] Kayaba", AIType.HospitalBot, TargetSession.GetHabbo().CurrentRoomId, "sh-290-92.hr-3322-32.ea-3170-63.fa-1212-63.lg-280-82.ch-225-82.hd-615-10.ca-1819-63", User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorX, User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
522 NewParamedic.InteractingWith = User;
523 NewParamedic.HospBotType = "paramedic_bot";
524 RoleplayManager.SendBotToRoom(NewParamedic, User.GetClient().GetHabbo().CurrentRoomId);
525 if (TargetSession.GetHabbo().CurrentRoom != null)
526 {
527 RoleplayManager.Shout(TargetSession, "*Passes out and wait for the ambulance to arives*", 10);
528 }
529 }
530 }
531
532 public static void Handleswatjail(GameClient TargetSession, string msg = "")
533 {
534 if (msg.Length > 3)
535 {
536 TargetSession.SendNotif(msg);
537 }
538 RoomUser User = null;
539
540 if (TargetSession.GetHabbo() != null)
541 {
542 if (TargetSession.GetHabbo().GetRoomUser() != null)
543 {
544 User = TargetSession.GetHabbo().GetRoomUser();
545 }
546 }
547
548 if (User != null || TargetSession != null)
549 {
550
551 if (User == null)
552 return;
553
554
555 HabboHotel.RoomBots.RoomBot NewParamedic = RoleplayManager.MakeQuickBot("[Swat] Rila-Kuma", AIType.HospitalBot, TargetSession.GetHabbo().CurrentRoomId, "ea-3388-1189-1191.lg-270-110.ch-215-1189.wa-3263-110-1408.sh-300-110.cc-3420-110.ca-3085-62.ha-3173-1193", User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorX, User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
556 NewParamedic.InteractingWith = User;
557 NewParamedic.HospBotType = "swat_bot";
558 RoleplayManager.SendBotToRoom(NewParamedic, User.GetClient().GetHabbo().CurrentRoomId);
559
560 if (TargetSession == null)
561 {
562 //int lol = 1;
563 }
564 else
565 {
566 if (TargetSession.GetHabbo().CurrentRoom != null)
567 {
568 RoleplayManager.Shout(TargetSession, "*Call the agent swat for help!*", 4);
569 }
570 }
571
572 // TargetSession.GetRoleplay().Transport(1, 1);
573
574 }
575 else
576 {
577
578 if (User == null)
579 return;
580
581 HabboHotel.RoomBots.RoomBot NewParamedic = RoleplayManager.MakeQuickBot("[Swat] Rila-Kuma", AIType.HospitalBot, TargetSession.GetHabbo().CurrentRoomId, "ea-3388-1189-1191.lg-270-110.ch-215-1189.wa-3263-110-1408.sh-300-110.cc-3420-110.ca-3085-62.ha-3173-1193", User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorX, User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
582 NewParamedic.InteractingWith = User;
583 NewParamedic.HospBotType = "swat_bot";
584 RoleplayManager.SendBotToRoom(NewParamedic, User.GetClient().GetHabbo().CurrentRoomId);
585 if (TargetSession.GetHabbo().CurrentRoom != null)
586 {
587 RoleplayManager.Shout(TargetSession, "*Call the agent swat for help!*", 4);
588 }
589 }
590 }
591
592 public static void HandlePizza(GameClient TargetSession, string msg = "")
593 {
594 if (msg.Length > 3)
595 {
596 TargetSession.SendNotif(msg);
597 }
598 RoomUser User = null;
599
600 if (TargetSession.GetHabbo() != null)
601 {
602 if (TargetSession.GetHabbo().GetRoomUser() != null)
603 {
604 User = TargetSession.GetHabbo().GetRoomUser();
605 }
606 }
607
608 if (User != null || TargetSession != null)
609 {
610 if (User == null)
611 return;
612
613
614 HabboHotel.RoomBots.RoomBot NewParamedic = RoleplayManager.MakeQuickBot("[CORP] Den", AIType.MiscBot, TargetSession.GetHabbo().CurrentRoomId, "ha-1002-1228.hd-208-1.lg-3407-1228-1322.hr-3090-45.ch-806-1228.fa-1201-62.ca-3414-1228.he-1607-62", User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorX, User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
615 NewParamedic.InteractingWith = User;
616 RoleplayManager.SendBotToRoom(NewParamedic, User.GetClient().GetHabbo().CurrentRoomId);
617
618 if (TargetSession == null)
619 {
620 //int lol = 1;
621 }
622 else
623 {
624 if (TargetSession.GetHabbo().CurrentRoom != null)
625 {
626 RoleplayManager.Shout(TargetSession, "*Call the pizza delivery, order Hawaiian Chicken and Wait the Pizza delivery arrives*", 5);
627
628 }
629 }
630
631
632 }
633 else
634 {
635
636 if (User == null)
637 return;
638
639 HabboHotel.RoomBots.RoomBot NewParamedic = RoleplayManager.MakeQuickBot("[CORP] Den", AIType.MiscBot, TargetSession.GetHabbo().CurrentRoomId, "ha-1002-1228.hd-208-1.lg-3407-1228-1322.hr-3090-45.ch-806-1228.fa-1201-62.ca-3414-1228.he-1607-62", User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorX, User.GetClient().GetHabbo().CurrentRoom.GetGameMap().Model.DoorY);
640 NewParamedic.InteractingWith = User;
641 RoleplayManager.SendBotToRoom(NewParamedic, User.GetClient().GetHabbo().CurrentRoomId);
642 if (TargetSession.GetHabbo().CurrentRoom != null)
643 {
644 RoleplayManager.Shout(TargetSession, "*Call the pizza delivery, order Hawaiian Chicken and Wait the Pizza delivery arrives*", 5);
645 }
646 }
647 }
648
649 public static RoomUser GetBot(string Name, Room Room)
650 {
651 RoomUser Targ = null;
652
653 foreach (RoomUser User in Room.GetRoomUserManager().GetBots())
654 {
655 if (User == null)
656 continue;
657 if (!User.IsBot)
658 continue;
659 if (User.BotData == null)
660 continue;
661 if (User.BotData.Name.ToLower() == Name.ToLower())
662 Targ = User;
663 }
664
665
666 return Targ;
667 }
668
669 public static bool ParamsMet(string[] Params, int LengthNeeded)
670 {
671 if (Params == null)
672 return false;
673
674 if(Params.Length < LengthNeeded + 1)
675 {
676 return false;
677 }
678 return true;
679 }
680
681 public static void Shout(GameClient Session, string Speech, int Bubble = 0)
682 {
683 if (Speech == null)
684 return;
685
686 if (Session == null)
687 return;
688
689 if (Session.GetHabbo() == null)
690 return;
691
692 if (Session.GetHabbo().CurrentRoom == null)
693 return;
694
695 Room Room = GenerateRoom(Session.GetHabbo().CurrentRoomId);
696
697 if (Room == null)
698 return;
699
700 RoomUser RoomUser = Session.GetHabbo().GetRoomUser();
701
702 if (RoomUser == null)
703 return;
704
705 if (!RoomUser.IsBot && RoomUser.IsFlooded && RoomUser.FloodExpiryTime <= Plus.GetUnixTimeStamp())
706 RoomUser.IsFlooded = false;
707 else if (!RoomUser.IsBot && RoomUser.IsFlooded)
708 return; // ciao flooders!
709
710 if (!RoomUser.IsBot && RoomUser.IsGunReloaded && RoomUser.ReloadExpiryTime <= Plus.GetUnixTimeStamp())
711 {
712 RoomUser.IsGunReloaded = false;
713 }
714 else if (!RoomUser.IsBot && RoomUser.IsGunReloaded)
715 return; // ciao flooders!
716
717 RoomUser.Chat(Session, Speech, true, -1, Bubble);
718 }
719
720 public static void commandShout(GameClient Session, string Speech, int Bubble = 0)
721 {
722 if (Speech == null)
723 return;
724
725 if (Session == null)
726 return;
727
728 if (Session.GetHabbo() == null)
729 return;
730
731 if (Session.GetHabbo().CurrentRoom == null)
732 return;
733
734 Room Room = GenerateRoom(Session.GetHabbo().CurrentRoomId);
735
736 if (Room == null)
737 return;
738
739 RoomUser RoomUser = Session.GetHabbo().GetRoomUser();
740
741 if (RoomUser == null)
742 return;
743
744 RoomUser.commandChat(Session, Speech, true, -1, RoomUser.LastBubble);
745 }
746
747
748 public static GameClient GenerateSession(string Username)
749 {
750 GameClient Client = null;
751 try
752 {
753 Client = Plus.GetGame().GetClientManager().GetClientByUserName(Username);
754 }
755 catch(Exception)
756 {
757 Client = null;
758 }
759
760 return Client;
761 }
762 public static GameClient GenerateSession(uint Id)
763 {
764 GameClient Client = null;
765 Client = Plus.GetGame().GetClientManager().GetClientByUserId(Id);
766 return Client;
767 }
768 public static Room GenerateRoom(uint RoomId)
769 {
770 Room Room = Plus.GetGame().GetRoomManager().LoadRoom(RoomId);
771 return Room;
772 }
773 public static string GetStatByID(int userid, string inf)
774 {
775 DataRow Row = null;
776 string ret = "";
777
778 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
779 {
780 dbClient.SetQuery("SELECT * FROM users WHERE id = '" + userid + "'");
781 Row = dbClient.GetRow();
782 ret = (string)Row[inf];
783 if (Row != null)
784 {
785 return ret;
786 }
787 }
788 return ret;
789 }
790
791 public static bool CanInteract(GameClient Me, GameClient TargetSession, bool SameRoom = false)
792 {
793 if (TargetSession == null)
794 return false;
795
796 if (TargetSession.GetHabbo() == null)
797 return false;
798
799 if (TargetSession.GetHabbo().GetRoomUser() == null)
800 return false;
801
802 if (TargetSession.GetHabbo().CurrentRoom == null)
803 return false;
804
805
806 if(SameRoom)
807 {
808 if(TargetSession.GetHabbo().CurrentRoom != Me.GetHabbo().CurrentRoom)
809 {
810 return false;
811 }
812 }
813
814 return true;
815 }
816
817 public static string SplitFigure(string _Figure)
818 {
819 string _Uni;
820 string FigurePartHair = _Figure;
821 string GetHairPart;
822
823 if (_Figure.ToLower().Contains("hr"))
824 {
825 GetHairPart = Regex.Split(_Figure, "hr")[1];
826 FigurePartHair = GetHairPart.Split('.')[0];
827 }
828 string FigurePartHead = _Figure;
829 string GetHeadPart;
830
831 if (_Figure.ToLower().Contains("hd"))
832 {
833 GetHeadPart = Regex.Split(_Figure, "hd")[1];
834 FigurePartHead = GetHeadPart.Split('.')[0];
835 }
836 string FigurePartHeadAcc = _Figure;
837 string GetHeadAccPart;
838
839 if (_Figure.ToLower().Contains("he"))
840 {
841 GetHeadAccPart = Regex.Split(_Figure, "he")[1];
842 FigurePartHeadAcc = GetHeadAccPart.Split('.')[0];
843 }
844 string FigurePartHat = _Figure;
845 string GetHatPart;
846
847 if (_Figure.ToLower().Contains("ha"))
848 {
849 GetHatPart = Regex.Split(_Figure, "ha")[1];
850 FigurePartHat = GetHatPart.Split('.')[0];
851 }
852 string FigurePartGlasses = _Figure;
853 string GetGlassesPart;
854
855 if (_Figure.ToLower().Contains("ea"))
856 {
857 GetGlassesPart = Regex.Split(_Figure, "ea")[1];
858 FigurePartHead = GetGlassesPart.Split('.')[0];
859 }
860 string FigurePartBeard = _Figure;
861 string GetBeardPart;
862
863 if (_Figure.ToLower().Contains("fa"))
864 {
865 GetBeardPart = Regex.Split(_Figure, "fa")[1];
866 FigurePartBeard = GetBeardPart.Split('.')[0];
867 }
868 string FigurePartShirt = _Figure;
869 string GetShirtPart;
870
871 if (_Figure.ToLower().Contains("ch"))
872 {
873 GetShirtPart = Regex.Split(_Figure, "ch")[1];
874 FigurePartShirt = GetShirtPart.Split('.')[0];
875 }
876 string FigurePartJacket = _Figure;
877 string GetJacketPart;
878
879 if (_Figure.ToLower().Contains("cc"))
880 {
881 GetJacketPart = Regex.Split(_Figure, "cc")[1];
882 FigurePartJacket = GetJacketPart.Split('.')[0];
883 }
884 string FigurePartNecklace = _Figure;
885 string GetNecklacePart;
886
887 if (_Figure.ToLower().Contains("ca"))
888 {
889 GetNecklacePart = Regex.Split(_Figure, "ca")[1];
890 FigurePartNecklace = GetNecklacePart.Split('.')[0];
891 }
892 string FigurePartPants = _Figure;
893 string GetPantsPart;
894
895 if (_Figure.ToLower().Contains("lg"))
896 {
897 GetPantsPart = Regex.Split(_Figure, "lg")[1];
898 FigurePartPants = GetPantsPart.Split('.')[0];
899 }
900 string FigurePartBelt = _Figure;
901 string GetBeltPart;
902
903 if (_Figure.ToLower().Contains("wa"))
904 {
905 GetBeltPart = Regex.Split(_Figure, "wa")[1];
906 FigurePartBelt = GetBeltPart.Split('.')[0];
907 }
908 string FigurePartShoes = _Figure;
909 string GetShoesPart;
910
911 if (_Figure.ToLower().Contains("sh"))
912 {
913 GetShoesPart = Regex.Split(_Figure, "sh")[1];
914 FigurePartShoes = GetShoesPart.Split('.')[0];
915 }
916
917 _Uni = Convert.ToString("ha" + FigurePartHat + "." + "he" + FigurePartHeadAcc + "." + "hr" + FigurePartHair + "." + "hd" + FigurePartHead + "." + "ea" + FigurePartGlasses + "." + "fa" + FigurePartBeard + "." + "ch" + FigurePartShirt + "." + "cc" + FigurePartJacket + "." + "ca" + FigurePartNecklace + "." + "lg" + FigurePartPants + "." + "wa" + FigurePartBelt + "." + "sh" + FigurePartShoes + ".");
918
919 return _Uni;
920 }
921
922 public static string getSkinColor(string figure)
923 {
924 string Skin = "-180-1";
925 string GetSkin = null;
926 if (figure.Contains("hd"))
927 {
928 GetSkin = Regex.Split(figure, "hd")[1];
929 Skin = GetSkin.Split('.')[0];
930 }
931 else
932 {
933 Skin = "-180-1";
934 }
935 string[] SkinColor = Skin.Split('-');
936
937 return SkinColor[2];
938 }
939
940 public static bool isBlack(string color)
941 {
942 string[] Blacks = new string[17] { "1370", "19", "20", "1371", "30", "1001", "1002", "1003", "6", "1372", "1373", "21", "1374", "1385", "1386", "1387", "5" };
943 if (Blacks.Contains(color))
944 {
945 return true;
946 }
947 return false;
948 }
949
950
951
952 public static void GiveCredit(GameClient TargetClient, int credit)
953 {
954 if (TargetClient != null)
955 {
956 TargetClient.GetHabbo().ActivityPoints = TargetClient.GetHabbo().ActivityPoints + credit;
957
958 TargetClient.GetHabbo().UpdateActivityPointsBalance();
959 TargetClient.GetHabbo().NotifyNewPixels(credit);
960 }
961 }
962
963 public static int GetDrinkFromOffer(string Offer)
964 {
965 string[] Texts = Offer.Split('_');
966
967 return Convert.ToInt32(Texts[1]);
968
969 }
970
971 public static void GenerateWantedList()
972 {
973 DataTable Table = null;
974
975 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
976 {
977
978 DataRow User = null;
979
980 dbClient.SetQuery("SELECT id,wanted FROM rp_stats WHERE wanted > 0");
981 Table = dbClient.GetTable();
982
983
984 foreach(DataRow Row in Table.Rows)
985 {
986
987 dbClient.SetQuery("SELECT username, home_room FROM users WHERE id = '" + Convert.ToInt32(Row["id"]) + "'");
988 User = dbClient.GetRow();
989
990 string Username = User["username"].ToString();
991 int Time = Convert.ToInt32(Row["wanted"]);
992 int Homeroom = Convert.ToInt32(User["home_room"]);
993
994 RoleplayManager.WantedListData.TryAdd(Username, Time + "|" + Homeroom);
995 }
996
997
998 }
999
1000
1001 }
1002
1003
1004 public static bool BotWithinAttackDistance(RoomUser roomUser, RoomUser TargetroomUser)
1005 {
1006 if (roomUser.X + 1 == TargetroomUser.X && roomUser.Y == TargetroomUser.Y
1007 || roomUser.X == TargetroomUser.X - 1 && roomUser.Y == TargetroomUser.Y + 1
1008 || roomUser.X == TargetroomUser.X + 1 && roomUser.Y == TargetroomUser.Y - 1
1009 || roomUser.X - 1 == TargetroomUser.X && roomUser.Y == TargetroomUser.Y ||
1010 roomUser.Y + 1 == TargetroomUser.Y && roomUser.X == TargetroomUser.X ||
1011 roomUser.Y - 1 == TargetroomUser.Y && roomUser.X == TargetroomUser.X ||
1012 roomUser.X == TargetroomUser.X && roomUser.Y == TargetroomUser.Y)
1013 {
1014 return true;
1015 }
1016
1017 return false;
1018 }
1019
1020
1021 public static void GiveMoney(GameClient TargetClient, int credits)
1022 {
1023 if (TargetClient != null)
1024 {
1025 TargetClient.GetHabbo().Credits = TargetClient.GetHabbo().Credits + credits;
1026
1027 TargetClient.GetHabbo().UpdateCreditsBalance();
1028 }
1029 }
1030
1031 public static void KickBotFromRoom(string Name, uint RoomId)
1032 {
1033 lock (Plus.GetGame().GetRoomManager().GetRoom(RoomId).GetRoomUserManager().GetBots())
1034 {
1035 foreach (RoomUser User in Plus.GetGame().GetRoomManager().GetRoom(RoomId).GetRoomUserManager().GetBots())
1036 {
1037 if (User == null)
1038 continue;
1039 if (User.BotData == null)
1040 continue;
1041 if (User.BotData.Name.ToLower() != Name.ToLower())
1042 continue;
1043
1044 Plus.GetGame().GetRoomManager().GetRoom(RoomId).GetRoomUserManager().RemoveBot(User.VirtualId, true);
1045 }
1046 }
1047 }
1048
1049 internal static RoomBot MakeQuickBot(string Name = "Undefined", AIType BotAI = AIType.HospitalBot, uint RoomId = 1, string Figure = "hr-3020-34.hd-3091-2.ch-225-92.lg-3058-100.sh-3089-1338.ca-3084-78-108.wa-2005", int X = 0, int Y = 0, int Rot = 0, string Gender = "M", int RP_Roam = 5, int RP_Attack = 3, int RP_Follow = 5, int RP_TryAction = 5, int RP_Type = 1)
1050 {
1051 Random rand = new Random();
1052 uint id = Convert.ToUInt32(rand.Next(28374, 294857));
1053 double Double = 0;
1054 RoomBot Botz = new RoomBot(id, 0, RoomId, BotAI, "freeroam", Name, "", Figure, X, Y, Double, Rot, 0, 0, 0, 0, null, null, Gender, 0, false);
1055 return Botz;
1056 }
1057
1058 public static RoomItem GetNearItem(RoomUser User , string Item, int MaxDistance)
1059 {
1060 RoomItem Inter = null;
1061 lock (Plus.GetGame().GetRoomManager().GetRoom(User.RoomId).GetRoomItemHandler().FloorItems.Values)
1062 {
1063 foreach (RoomItem item in Plus.GetGame().GetRoomManager().GetRoom(User.RoomId).GetRoomItemHandler().FloorItems.Values)
1064 {
1065
1066 if (item == null)
1067 continue;
1068
1069 HabboHotel.PathFinding.Vector2D Pos1 = new HabboHotel.PathFinding.Vector2D(item.X, item.Y);
1070 HabboHotel.PathFinding.Vector2D Pos2 = new HabboHotel.PathFinding.Vector2D(User.X, User.Y);
1071
1072 if (item.GetBaseItem() == null)
1073 continue;
1074
1075 if (RoleplayManager.Distance(Pos1, Pos2) <= MaxDistance)
1076 {
1077 if (!item.GetBaseItem().Name.Contains(Item))
1078 {
1079 continue;
1080 }
1081
1082
1083 Inter = item;
1084 }
1085 }
1086 }
1087
1088 return Inter;
1089 }
1090
1091 public static RoomItem GetNearItem(string Item, Room MRoom)
1092 {
1093 RoomItem Inter = null;
1094 lock (MRoom.GetRoomItemHandler().FloorItems.Values)
1095 {
1096 foreach (RoomItem item in MRoom.GetRoomItemHandler().FloorItems.Values)
1097 {
1098
1099 if (item == null)
1100 continue;
1101
1102 if (item.GetBaseItem() == null)
1103 continue;
1104
1105 if (!item.GetBaseItem().Name.Contains(Item))
1106 {
1107 continue;
1108 }
1109
1110
1111 Inter = item;
1112 }
1113 }
1114
1115 return Inter;
1116 }
1117
1118 internal static void SendBotToRoom(RoomBot Bot, uint room)
1119 {
1120 Plus.GetGame().GetRoomManager().GetRoom(room).GetRoomUserManager().DeployBot(Bot, null);
1121 }
1122
1123 public static Room GetRandomHospital()
1124 {
1125 Room Place = null;
1126
1127 lock (Plus.GetGame().GetRoomManager().ReturnRooms())
1128 {
1129 foreach (Room Room in Plus.GetGame().GetRoomManager().ReturnRooms())
1130 {
1131 if (Room == null)
1132 continue;
1133 if (Room.RoomData == null)
1134 continue;
1135
1136 if (Room.RoomData.Description.Contains("HOSP"))
1137 {
1138 Place = Room;
1139 }
1140 }
1141 }
1142
1143 return Place;
1144 }
1145 public static Room GetRandomJail()
1146 {
1147 Room Place = null;
1148
1149 lock (Plus.GetGame().GetRoomManager().ReturnRooms())
1150 {
1151 foreach (Room Room in Plus.GetGame().GetRoomManager().ReturnRooms())
1152 {
1153 if (Room == null)
1154 continue;
1155 if (Room.RoomData == null)
1156 continue;
1157
1158 if (!Room.RoomData.Description.Contains("JAIL") || Room.RoomId == 9)
1159 continue;
1160
1161 Place = Room;
1162 }
1163 }
1164
1165 return Place;
1166 }
1167
1168 public static void AlertGang(string Msg, int Gang, bool DeleteGang = false)
1169 {
1170 lock (Plus.GetGame().GetClientManager().Clients.Values)
1171 {
1172 foreach (GameClient client in Plus.GetGame().GetClientManager().Clients.Values)
1173 {
1174 if (client == null)
1175 continue;
1176 if (client.GetRoleplay() == null)
1177 continue;
1178 if (client.GetRoleplay().GangId != Gang)
1179 continue;
1180
1181 client.SendWhisper(Msg);
1182
1183 if (DeleteGang)
1184 {
1185 client.GetRoleplay().GangId = 0;
1186 client.GetRoleplay().GangRank = 0;
1187 client.GetRoleplay().SaveGangComponents();
1188 }
1189 }
1190 }
1191 }
1192 public static void MakeLay(RoomUser user)
1193 {
1194 if (user == null)
1195 return;
1196
1197 if (user.Statusses == null)
1198 return;
1199
1200 if (!user.Statusses.ContainsKey("lay"))
1201 {
1202 if ((user.RotBody % 2) == 0)
1203 {
1204 if (user == null)
1205 return;
1206
1207 try
1208 {
1209 user.Statusses.Add("lay", "1.0 null");
1210 user.Z -= 0.35;
1211 user.IsLyingDown = true;
1212 user.UpdateNeeded = true;
1213 }
1214 catch { }
1215 }
1216 else
1217 {
1218 user.RotBody--;
1219 user.Statusses.Add("lay", "1.0 null");
1220 user.Z -= 0.35;
1221 user.IsLyingDown = true;
1222 user.UpdateNeeded = true;
1223 }
1224
1225 }
1226 else
1227 {
1228 user.Z += 0.35;
1229 user.Statusses.Remove("lay");
1230 user.Statusses.Remove("1.0");
1231 user.IsLyingDown = false;
1232 user.UpdateNeeded = true;
1233 }
1234
1235 }
1236 public static void ActiveNight(int Intensity = 76)
1237 {
1238
1239 foreach (Room Room in Plus.GetGame().GetRoomManager().ReturnRooms())
1240 {
1241
1242 #region Manage Landscape
1243 DateTime date1 = DateTime.Now;
1244 string time = date1.ToString("h tt");
1245 string data = "1.1";
1246
1247 if (time == "7 PM") { data = "5.1"; }
1248 else if (time == "8 PM") { data = "5.1"; }
1249 else if (time == "9 PM") { data = "6.1"; }
1250 else if (time == "10 PM") { data = "6.1"; }
1251 else if (time == "11 PM") { data = "6.1"; }
1252 else if (time == "12 AM") { data = "6.1"; }
1253 else if (time == "1 AM") { data = "6.1"; }
1254 else if (time == "2 AM") { data = "6.1"; }
1255 else if (time == "3 AM") { data = "6.1"; }
1256 else if (time == "4 AM") { data = "6.1"; }
1257 else if (time == "5 AM") { data = "1.1"; }
1258 else if (time == "6 AM") { data = "1.1"; }
1259 else if (time == "7 AM") { data = "5.1"; }
1260 else if (time == "8 AM") { data = "5.1"; }
1261 else if (time == "9 AM") { data = "5.1"; }
1262 else if (time == "10 AM") { data = "4.1"; }
1263 else if (time == "11 AM") { data = "4.1"; }
1264 else if (time == "12 PM") { data = "4.1"; }
1265 else if (time == "1 PM") { data = "2.1"; }
1266 else if (time == "2 PM") { data = "2.1"; }
1267 else if (time == "3 PM") { data = "2.1"; }
1268 else if (time == "4 PM") { data = "2.1"; }
1269 else if (time == "5 PM") { data = "2.1"; }
1270 else if (time == "6 PM") { data = "2.1"; }
1271 Room.RoomData.LandScape = data;
1272
1273 ServerMessage Message = new ServerMessage(LibraryParser.OutgoingRequest("RoomSpacesMessageComposer"));
1274 Message.AppendString("landscape");
1275 Message.AppendString(data);
1276 Room.SendMessage(Message);
1277 #endregion
1278 if (Room.RoomData.Description.Contains("STREET"))
1279 {
1280 foreach (RoomItem item in Room.GetRoomItemHandler().WallItems.Values)
1281 {
1282 if (item.GetBaseItem().InteractionType == Interaction.Dimmer)
1283 {
1284 //Console.WriteLine(Intensity);
1285 Room.MoodlightData = new MoodlightData(item.Id);
1286 Intensity = 76;
1287 Room.MoodlightData.UpdatePreset(1, "#000000", Intensity, false, true);
1288 Room.MoodlightData.Enabled = true;
1289 item.ExtraData = Room.MoodlightData.GenerateExtraData();
1290 item.UpdateState();
1291 Room.MoodlightData.Enable();
1292 item.ExtraData = Room.MoodlightData.GenerateExtraData();
1293 item.UpdateState();
1294 //Room.MoodlightData.UpdatePreset();
1295 }
1296 }
1297 }
1298 }
1299 }
1300
1301 internal static void AddItem(GameClient Session, Item Item)
1302 {
1303 Plus.GetGame().GetCatalog().DeliverItems(Session, Item, 1, "0", 0, 0, "");
1304 Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
1305 }
1306
1307 public static void PickRock(RoomItem Item, uint roomid)
1308 {
1309 Room Room = GenerateRoom(roomid);
1310
1311 Room.GetRoomItemHandler().RemoveRock(Item.Id, false);
1312
1313 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1314 {
1315 dbClient.RunFastQuery("DELETE FROM items_rooms WHERE id = '" + Item.Id + "'");
1316 }
1317 }
1318 public static void PickFarmingSpot(RoomItem Item, uint roomid)
1319 {
1320 Room Room = GenerateRoom(roomid);
1321
1322 Room.GetRoomItemHandler().RemoveFarmingSpot(Item.Id, false);
1323
1324 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1325 {
1326 dbClient.RunFastQuery("DELETE FROM items_rooms WHERE id = '" + Item.Id + "'");
1327 }
1328 }
1329
1330 public static void PickSlotTilePrize(RoomItem Item, uint roomid)
1331 {
1332 Room Room = GenerateRoom(roomid);
1333
1334 Room.GetRoomItemHandler().RemoveSlotSpot(Item.Id, false);
1335
1336 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1337 {
1338 dbClient.RunFastQuery("DELETE FROM items_rooms WHERE id = '" + Item.Id + "'");
1339 }
1340 }
1341
1342
1343 public static RoomItem PlaceItemToRoomReturn(uint BaseId, int X, int Y, double Z, int Rot, bool FromInventory, uint roomid, bool ToDB = true)
1344 {
1345
1346 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1347 {
1348 Room Room = GenerateRoom(roomid);
1349 int ItDemId = 0;
1350 uint ItemId = 0;
1351
1352 if (ToDB)
1353 {
1354 dbClient.SetQuery("INSERT INTO items_rooms (user_id,base_item) VALUES (1, " + BaseId + ")");
1355 dbClient.RunQuery();
1356 dbClient.SetQuery("SELECT id FROM items_rooms WHERE user_id = '1' AND room_id = 0 AND base_item = '" + BaseId + "' ORDER BY id DESC LIMIT 1");
1357 ItDemId = dbClient.GetInteger();
1358 ItemId = Convert.ToUInt32(ItDemId);
1359 }
1360 else
1361 {
1362 dbClient.SetQuery("SELECT id FROM items_rooms WHERE user_id = '1' AND room_id = 0 ORDER BY id DESC LIMIT 1");
1363 ItDemId = dbClient.GetInteger();
1364 ItemId = Convert.ToUInt32(ItDemId) + 1;
1365 }
1366
1367
1368 RoomItem RoomItem = new RoomItem(ItemId, Room.RoomId, BaseId, "", X, Y, Z, Rot, Room, Convert.ToUInt32(Room.RoomData.OwnerId), 0, 3537, "", false);
1369
1370
1371 Room.GetRoomItemHandler().SetRockItem(RoomItem, X, Y, Rot, true, false, true, false, false);
1372
1373 return RoomItem;
1374 }
1375
1376 }
1377
1378 public static void PickItem(GameClient Session, RoomItem Item, bool toinv = false, Room Ruum = null)
1379 {
1380 if (Session != null)
1381 {
1382 Room Room = GenerateRoom(Session.GetHabbo().CurrentRoomId);
1383
1384 Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id,false);
1385
1386 if (Item.GetBaseItem().InteractionType != Interaction.Teleport)
1387 {
1388 if (toinv)
1389 {
1390 // Session.GetHabbo().GetInventoryComponent().AddNewItem(Item.Id, Item.BaseItem, Item.ExtraData, Item.GroupId, true, true, 0, 0, 0);
1391
1392 //Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
1393 }
1394 }
1395
1396 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1397 {
1398 dbClient.RunFastQuery("DELETE FROM items_rooms WHERE id = '" + Item.Id + "'");
1399 Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
1400 }
1401 }
1402 else if(Session == null)
1403 {
1404 Ruum.GetRoomItemHandler().RemoveFurniture(Session, Item.Id, false);
1405 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1406 {
1407 dbClient.RunFastQuery("DELETE FROM items_rooms WHERE id = '" + Item.Id + "'");
1408 }
1409 }
1410 }
1411
1412 public static void ReplaceItem(GameClient Session, RoomItem Item, string newitemname)
1413 {
1414 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1415 {
1416
1417 dbClient.SetQuery("SELECT id FROM catalog_furnis WHERE item_name = '" + newitemname + "'");
1418 int newitemid = dbClient.GetInteger();
1419 uint itemid = Convert.ToUInt32(newitemid);
1420 PlaceItemToCord(Session, itemid, Item.X, Item.Y, Item.Z, Item.Rot, false);
1421 PickItem(Session, Item, false);
1422
1423 }
1424 }
1425
1426
1427
1428 public static void PlaceItemToCord(GameClient Session, uint BaseId, int X, int Y, double Z, int Rot = 0, bool FromInventory = false)
1429 {
1430
1431 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1432 {
1433 Session.GetRoleplay().DebugStacking = true;
1434 Room Room = GenerateRoom(Session.GetHabbo().CurrentRoomId);
1435
1436 dbClient.SetQuery("INSERT INTO items_rooms (user_id,base_item) VALUES ( " + Session.GetHabbo().Id + " , " + BaseId + ")");
1437 dbClient.RunQuery();
1438 Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
1439 dbClient.SetQuery("SELECT id FROM items_rooms WHERE user_id = '" + Session.GetHabbo().Id + "' AND room_id = 0 AND base_item = '" + BaseId + "' ORDER BY id DESC LIMIT 1");
1440 int ItDemId = dbClient.GetInteger();
1441 uint ItemId = Convert.ToUInt32(ItDemId);
1442
1443 Session.GetRoleplay().DebugStack = Z;
1444 UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);
1445
1446 if (Item == null)
1447 {
1448 Session.SendWhisperBubble("An error occured and this operation was unable to continue!");
1449 return;
1450 }
1451
1452 if (Room == null)
1453 {
1454 Session.SendWhisperBubble("An error occured and this operation was unable to continue!");
1455 return;
1456 }
1457
1458 if(Item.BaseItem == null)
1459 {
1460 Session.SendWhisperBubble("An error occured and this operation was unable to continue!");
1461 return;
1462 }
1463
1464 if(Room.RoomData == null)
1465 {
1466 Session.SendWhisperBubble("An error occured and this operation was unable to continue!");
1467 return;
1468 }
1469
1470 RoomItem RoomItem = new RoomItem(Item.Id, Room.RoomId, Item.BaseItemId, Item.ExtraData, X, Y, Z, Rot, Room, Convert.ToUInt32(Room.RoomData.OwnerId), Item.GroupId, Item.BaseItem.FlatId, "", false);
1471
1472 if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rot, true, false, true))
1473 {
1474 Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, true);
1475
1476 } Session.GetRoleplay().DebugStacking = false;
1477
1478 Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
1479 }
1480
1481 }
1482
1483 public static object ReturnOfflineInfo(uint UserId, string Info)
1484 {
1485 object info = null;
1486
1487 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1488 {
1489 dbClient.SetQuery("SELECT " + Info + " FROM users WHERE id = '" + UserId + "'");
1490 info = dbClient.GetString();
1491 }
1492
1493 return info;
1494 }
1495
1496
1497 /*public static void ActiveDay(int intensity = 0)
1498 {
1499 foreach (Room Room in Plus.GetGame().GetRoomManager().ReturnRooms())
1500 {
1501
1502 #region Manage Landscape
1503 DateTime date1 = DateTime.Now;
1504 string time = date1.ToString("h tt");
1505 string data = "1.1";
1506
1507 if (time == "7 PM") { data = "5.1"; }
1508 else if (time == "8 PM") { data = "5.1"; }
1509 else if (time == "9 PM") { data = "6.1"; }
1510 else if (time == "10 PM") { data = "6.1"; }
1511 else if (time == "11 PM") { data = "6.1"; }
1512 else if (time == "12 AM") { data = "6.1"; }
1513 else if (time == "1 AM") { data = "6.1"; }
1514 else if (time == "2 AM") { data = "6.1"; }
1515 else if (time == "3 AM") { data = "6.1"; }
1516 else if (time == "4 AM") { data = "6.1"; }
1517 else if (time == "5 AM") { data = "1.1"; }
1518 else if (time == "6 AM") { data = "1.1"; }
1519 else if (time == "7 AM") { data = "5.1"; }
1520 else if (time == "8 AM") { data = "5.1"; }
1521 else if (time == "9 AM") { data = "5.1"; }
1522 else if (time == "10 AM") { data = "4.1"; }
1523 else if (time == "11 AM") { data = "4.1"; }
1524 else if (time == "12 PM") { data = "4.1"; }
1525 else if (time == "1 PM") { data = "2.1"; }
1526 else if (time == "2 PM") { data = "2.1"; }
1527 else if (time == "3 PM") { data = "2.1"; }
1528 else if (time == "4 PM") { data = "2.1"; }
1529 else if (time == "5 PM") { data = "2.1"; }
1530 else if (time == "6 PM") { data = "2.1"; }
1531 //Room.RoomData.LandScape = data;
1532 Room.RoomData.LandScape = data;
1533
1534 ServerMessage Message = new ServerMessage(LibraryParser.OutgoingRequest("RoomSpacesMessageComposer"));
1535 Message.AppendString("landscape");
1536 Message.AppendString(data);
1537 Room.SendMessage(Message);
1538 #endregion
1539 foreach (RoomItem item in Room.GetRoomItemHandler().WallItems.Values)
1540 {
1541 if (Room.RoomData.Description.Contains("STREET"))
1542 {
1543 if (item.GetBaseItem().InteractionType == Interaction.Dimmer)
1544 {
1545 Room.MoodlightData = new MoodlightData(item.Id);
1546 Room.MoodlightData.UpdatePreset(1, "#000000", intensity, false, true);
1547 Room.MoodlightData.Enabled = true;
1548 item.ExtraData = Room.MoodlightData.GenerateExtraData();
1549 item.UpdateState();
1550 Room.MoodlightData.Enable();
1551 item.ExtraData = Room.MoodlightData.GenerateExtraData();
1552 item.UpdateState();
1553 //Room.MoodlightData.UpdatePreset();
1554 }
1555 }
1556 }
1557 }
1558 }*/
1559
1560 public static void saveSlotLook(GameClient Session, int slotid, string newfig)
1561 {
1562 DataRow check;
1563 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1564 {
1565 dbClient.SetQuery("SELECT * FROM user_slots WHERE userid = '" + Session.GetHabbo().Id + "'");
1566 check = dbClient.GetRow();
1567
1568 if (check == null)
1569 {
1570 dbClient.RunFastQuery("INSERT INTO user_slots(userid,slot1,slot2,slot3,slot4,slot5) VALUES('" + Session.GetHabbo().Id + "','','','','','')");
1571 }
1572
1573 dbClient.RunFastQuery("UPDATE user_slots SET slot" + slotid + " = '" + newfig + "' WHERE userid = '" + Session.GetHabbo().Id + "' ");
1574 }
1575 }
1576
1577 public static void useSlotLook(GameClient Session, int slotid)
1578 {
1579
1580 string slot = "slot" + slotid;
1581 DataRow check;
1582 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1583 {
1584 dbClient.SetQuery("SELECT * FROM user_slots WHERE userid = '" + Session.GetHabbo().Id + "'");
1585 check = dbClient.GetRow();
1586
1587 if (check == null)
1588 {
1589 dbClient.RunFastQuery("INSERT INTO user_slots(userid,slot1,slot2,slot3,slot4,slot5) VALUES('" + Session.GetHabbo().Id + "','','','','','')");
1590 }
1591
1592 if (Convert.ToString(check[slot]) == null || Convert.ToString(check[slot]) == "")
1593 {
1594 Session.SendWhisper("The selected slot " + slotid + " is empty!");
1595 }
1596 else
1597 {
1598 string figure = Convert.ToString(check[slot]);
1599 savePermLook(Session, figure);
1600 }
1601 }
1602 }
1603
1604 public static void savePermLook(GameClient Session, string NewFigure, string NewGender = "")
1605 {
1606 if (NewGender == "")
1607 {
1608 NewGender = Session.GetHabbo().Gender.ToString().Substring(0, 1).ToUpper();
1609 }
1610
1611 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1612 {
1613 dbClient.SetQuery("UPDATE users SET look = @look, gender = @gender WHERE id = " + Session.GetHabbo().Id);
1614 dbClient.AddParameter("look", NewFigure);
1615 dbClient.AddParameter("gender", NewGender);
1616 dbClient.RunQuery();
1617 }
1618
1619 DataRow User = null;
1620
1621 using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
1622 {
1623 dbClient.SetQuery("SELECT look,gender FROM users WHERE id = '" + Session.GetHabbo().Id + "'");
1624 User = dbClient.GetRow();
1625 }
1626
1627 Session.GetHabbo().Look = Convert.ToString(User["look"]);
1628 Session.GetHabbo().Gender = Convert.ToString(User["gender"]);
1629 Session.GetRoleplay().RefreshVals();
1630 }
1631
1632 public static void EjectBot(GameClient Me, GameClient Session, uint BotId)
1633 {
1634 var room =
1635 Plus.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
1636 if (Session == null || Session.GetHabbo() == null ||
1637 Session.GetHabbo().GetInventoryComponent() == null)
1638 return;
1639 if (room == null)
1640 return;
1641 var petId = BotId;
1642 var pet = room.GetRoomUserManager().GetPet(petId);
1643 if (pet == null)
1644 return;
1645 if (Session.GetRoleplay() != null && Session.GetHabbo().GetRoomUser() != null)
1646 {
1647 Session.GetRoleplay().UsingPet = false;
1648 Session.GetHabbo().GetRoomUser().MyPet = null;
1649 }
1650
1651 if (pet.RidingHorse)
1652 {
1653 var roomUserByVirtualId =
1654 room.GetRoomUserManager().GetRoomUserByVirtualId(Convert.ToInt32(pet.HorseId));
1655 if (roomUserByVirtualId != null)
1656 {
1657 roomUserByVirtualId.RidingHorse = false;
1658 roomUserByVirtualId.ApplyEffect(-1);
1659 roomUserByVirtualId.MoveTo((new Point(roomUserByVirtualId.X + 1, roomUserByVirtualId.Y + 1)));
1660 }
1661 }
1662 if (pet.PetData.DbState != DatabaseUpdateState.NeedsInsert)
1663 pet.PetData.DbState = DatabaseUpdateState.NeedsUpdate;
1664 pet.PetData.RoomId = 0u;
1665 Session.GetHabbo().GetInventoryComponent().AddPet(pet.PetData);
1666 using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
1667 room.GetRoomUserManager().SavePets(queryReactor);
1668 room.GetRoomUserManager().RemoveBot(pet.VirtualId, false);
1669 Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
1670 Session.GetHabbo().GetRoomUser().MyPet = null;
1671 Session.GetRoleplay().UsingPet = false;
1672 Session.SendWhisper(Me.GetHabbo().UserName + " has ejected your pet " + Session.GetHabbo().GetRoomUser().MyPet);
1673
1674 }
1675
1676 public static void sendVIPAlert(GameClient Session, string msg, bool StaffMSG = false)
1677 {
1678 lock (Plus.GetGame().GetClientManager().Clients.Values)
1679 {
1680 foreach (GameClient client in Plus.GetGame().GetClientManager().Clients.Values)
1681 {
1682
1683 if (client == null)
1684 continue;
1685 if (client.GetHabbo() == null)
1686 continue;
1687 if (!client.GetHabbo().VIP)
1688 continue;
1689 if (client.GetHabbo().vipAlertsOff)
1690 continue;
1691 //Misc.GenerateRoomUser(client).LastBubble = 1;
1692 if (!StaffMSG)
1693 {
1694 client.GetHabbo().GetRoomUser().LastBubble = 11;
1695 client.SendWhisper("[VIP Alert][" + Session.GetHabbo().UserName + "]: " + msg);
1696 client.GetHabbo().GetRoomUser().LastBubble = 0;
1697 }
1698 else
1699 {
1700 client.GetHabbo().GetRoomUser().LastBubble = 11;
1701 client.SendWhisper("[VIP Alert]*" + msg + "*");
1702 client.GetHabbo().GetRoomUser().LastBubble = 0;
1703 }
1704 //Misc.GenerateRoomUser(client).LastBubble = 0;
1705 }
1706 }
1707 }
1708 public static void sendStaffAlert(string msg, bool ondutyonly = false)
1709 {
1710 lock (Plus.GetGame().GetClientManager().Clients.Values)
1711 {
1712 foreach (GameClient client in Plus.GetGame().GetClientManager().Clients.Values)
1713 {
1714 if (client == null)
1715 continue;
1716 if (client.GetHabbo() == null)
1717 continue;
1718 if (client.GetHabbo().GetRoomUser() == null)
1719 continue;
1720 if (client.GetRoleplay() == null)
1721 continue;
1722
1723 if (ondutyonly)
1724 {
1725 if (client.GetHabbo().HasFuse("fuse_events") && client.GetRoleplay().StaffDuty)
1726 {
1727 client.GetHabbo().GetRoomUser().LastBubble = 23;
1728 client.SendWhisper("[Staff Alert] " + msg);
1729 client.GetHabbo().GetRoomUser().LastBubble = 0;
1730 }
1731 }
1732 else
1733 {
1734 if (client.GetHabbo().HasFuse("fuse_events"))
1735 {
1736 client.GetHabbo().GetRoomUser().LastBubble = 23;
1737 client.SendWhisper("[Staff Alert] " + msg);
1738 client.GetHabbo().GetRoomUser().LastBubble = 0;
1739 }
1740 }
1741 }
1742 }
1743 }
1744 }
1745}
1746
1747
1748
1749hospitalbot.cs
1750using System;
1751using System.Linq;
1752using System.Threading;
1753using Plus.HabboHotel.GameClients;
1754using Plus.HabboHotel.Rooms;
1755using System.Collections.Generic;
1756using System.Drawing;
1757using Plus.HabboHotel.Roleplay.Timers;
1758using Plus.HabboHotel.Roleplay.Misc;
1759
1760namespace Plus.HabboHotel.RoomBots
1761{
1762 class HospitalBot : BotAI
1763 {
1764 private static readonly Random Random = new Random();
1765
1766 private readonly int _id;
1767 private readonly int _virtualId;
1768 private readonly bool _isBartender;
1769
1770 private int _actionCount = 30;
1771 private int _speechInterval = 7;
1772 private Timer _chatTimer;
1773
1774 private string HospBotType = "heal_bot";
1775
1776 #region Normal Hospital Bot
1777 public int HospStaffOn_LastCheck = 0;
1778 #endregion
1779
1780 #region Paramedic Bot
1781 internal RoomUser InteractingWith;
1782 bool LoadedUser;
1783 bool TransferedUser;
1784 int LActionTimer;
1785 #endregion
1786
1787 internal HospitalBot(RoomBot roomBot, int virtualId, int botId, AIType type, bool isBartender, int speechInterval)
1788 {
1789 _id = botId;
1790 _virtualId = virtualId;
1791 _isBartender = isBartender;
1792 _speechInterval = speechInterval < 2 ? 2000 : speechInterval * 1000;
1793
1794 // Get random speach
1795 if (roomBot.AutomaticChat && roomBot.RandomSpeech != null && roomBot.RandomSpeech.Any()) _chatTimer = new Timer(ChatTimerTick, null, _speechInterval, _speechInterval);
1796 _actionCount = Random.Next(10, 30 + virtualId);
1797 }
1798
1799 internal override void Modified()
1800 {
1801 if (GetBotData() == null) return;
1802 if (!GetBotData().AutomaticChat || GetBotData().RandomSpeech == null || !GetBotData().RandomSpeech.Any())
1803 {
1804 StopTimerTick();
1805 return;
1806 }
1807 _speechInterval = GetBotData().SpeechInterval < 2 ? 2000 : GetBotData().SpeechInterval * 1000;
1808
1809 if (_chatTimer == null)
1810 {
1811 _chatTimer = new Timer(ChatTimerTick, null, _speechInterval, _speechInterval);
1812 return;
1813 }
1814 _chatTimer.Change(_speechInterval, _speechInterval);
1815 }
1816
1817 internal override void OnSelfEnterRoom()
1818 {
1819
1820 }
1821
1822 internal override void OnSelfLeaveRoom(bool Kicked)
1823 {
1824
1825 }
1826
1827 internal override void OnUserEnterRoom(Rooms.RoomUser User)
1828 {
1829
1830 }
1831
1832 internal override void OnUserLeaveRoom(GameClients.GameClient Client)
1833 {
1834
1835 }
1836
1837 internal override void OnUserSay(Rooms.RoomUser User, string Message)
1838 {
1839 if (User.IsBot || User.GetClient() == null)
1840 {
1841 return;
1842 }
1843 if (User.GetClient().GetHabbo() == null)
1844 {
1845 return;
1846 }
1847
1848 if (!User.GetClient().GetHabbo().CurrentRoom.RoomData.Description.Contains("HOSP"))
1849 {
1850 return;
1851 }
1852
1853 if (Message != "heal" && Message != "medical aid" && Message != "aid")
1854 {
1855 return;
1856 }
1857
1858 GameClients.GameClient Session = User.GetClient();
1859
1860 if (Session.GetRoleplay().CurHealth < Session.GetRoleplay().MaxHealth || Session.GetRoleplay().Dead)
1861 {
1862 if (!Session.GetRoleplay().Dead)
1863 {
1864 if (Session.GetRoleplay().BeingHealed)
1865 {
1866 Session.SendWhisper("You are already being healed!");
1867 return;
1868 }
1869 else
1870 base.GetRoomUser().Chat(null, "*Applies some bandages to " + User.GetClient().GetHabbo().UserName + "'s wounds*", true, 1);
1871 }
1872 else
1873 {
1874 int yolo = (RoleplayManager.PurgeTime == true) ? 2 : 1;
1875 if (Session.GetRoleplay().DeadTimer <= yolo)
1876 {
1877 base.GetRoomUser().Chat(null, "*Discharges " + Session.GetHabbo().UserName + " from the hospital*", true, 1);
1878 Session.GetRoleplay().DeadTimer = 0;
1879 Session.GetRoleplay().DeadSeconds = 0;
1880 Session.GetRoleplay().SaveStatusComponents("dead");
1881 Session.GetRoleplay().healTimer = new healTimer(Session);
1882 Session.GetRoleplay().BeingHealed = true;
1883 User.ApplyEffect(23);
1884 return;
1885 }
1886 else
1887 {
1888 Session.SendWhisper("You must wait at least 1 minute before you can request to be released from the hospital!");
1889 return;
1890 }
1891 }
1892
1893 Session.GetRoleplay().healTimer = new healTimer(Session);
1894 Session.GetRoleplay().BeingHealed = true;
1895 User.ApplyEffect(23);
1896 return;
1897 }
1898 else
1899 User.GetClient().SendWhisper("Your health is already full!");
1900 return;
1901
1902
1903
1904 /*
1905 if (Gamemap.TileDistance(GetRoomUser().X, GetRoomUser().Y, User.X, User.Y) > 8)
1906 {
1907 return;
1908 }
1909
1910 BotResponse Response = GetBotData().GetResponse(Message);
1911
1912 if (Response == null)
1913 {
1914 return;
1915 }
1916
1917 switch (Response.ResponseType.ToLower())
1918 {
1919 case "say":
1920
1921 GetRoomUser().Chat(null, Response.ResponseText, false, 0);
1922 break;
1923
1924 case "shout":
1925
1926 GetRoomUser().Chat(null, Response.ResponseText, true, 0);
1927 break;
1928
1929 case "whisper":
1930
1931 User.GetClient().SendMessage(new WhisperComposer(GetRoomUser(), Response.ResponseText, 0, 0));
1932 break;
1933 }
1934
1935 if (Response.ServeId >= 1)
1936 {
1937 User.CarryItem(Response.ServeId);
1938 }*/
1939
1940 }
1941
1942 internal override void OnUserShout(Rooms.RoomUser User, string Message)
1943 {
1944 /*
1945 if (PlusEnvironment.GetRandomNumber(0, 10) >= 5)
1946 {
1947 GetRoomUser().Chat(null, LanguageLocale.GetValue("onusershout"), true); // shout nag
1948 }*/
1949 }
1950
1951 internal override void OnTimerTick()
1952 {
1953 if (base.GetBotData() != null)
1954 {
1955
1956 if (base.GetBotData().Name.ToLower().Contains("doctor"))
1957 {
1958
1959 if (base.GetRoomUser().RotBody != 4)
1960 {
1961 base.GetRoomUser().RotBody = 4;
1962 base.GetRoomUser().RotHead = 4;
1963
1964 }
1965
1966 if (!base.GetRoomUser().Statusses.ContainsKey("sit"))
1967 {
1968 base.GetRoomUser().Statusses.Add("sit", "1.0");
1969 base.GetRoomUser().Z = 0.00;
1970 base.GetRoomUser().IsSitting = true;
1971 base.GetRoomUser().UpdateNeeded = true;
1972 }
1973 }
1974
1975 switch (base.GetBotData().HospBotType)
1976 {
1977
1978 #region Paramedic Bot
1979 case "paramedic_bot":
1980 {
1981
1982 bool LeaveRoom = false;
1983
1984 if (base.GetBotData().InteractingWith == null)
1985 {
1986 LeaveRoom = true;
1987 }
1988
1989 if (!base.GetBotData().InteractingWith.GetClient().GetRoleplay().Dead)
1990 {
1991 LeaveRoom = true;
1992 }
1993
1994 if (base.GetBotData() != null)
1995 {
1996 if (base.GetBotData().InteractingWith != null)
1997 {
1998 if (base.GetBotData().InteractingWith.GetClient() != null)
1999 {
2000 if (base.GetBotData().InteractingWith.GetClient().GetHabbo() != null)
2001 {
2002 if (base.GetBotData().InteractingWith.GetClient().GetHabbo().CurrentRoomId != base.GetBotData().RoomId)
2003 {
2004 LeaveRoom = true;
2005 }
2006 }
2007 }
2008 }
2009 }
2010
2011 if(base.GetRoom() == null)
2012 {
2013 LeaveRoom = true;
2014 }
2015
2016 #region Leaveroom
2017 if (LeaveRoom)
2018 {
2019
2020 if (LActionTimer < 20)
2021 {
2022 base.GetRoomUser().ApplyEffect(20);
2023 List<Point> list = base.GetRoom().GetGameMap().getWalkableList();
2024 if (list.Count == 0)
2025 return;
2026 int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
2027
2028 base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y);
2029 LActionTimer++;
2030 }
2031 else
2032 {
2033
2034 RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
2035 }
2036
2037
2038 }
2039 #endregion
2040
2041
2042 if (!LeaveRoom)
2043 {
2044 base.GetRoomUser().ApplyEffect(20);
2045
2046
2047 HabboHotel.PathFinding.Vector2D Pos1 = new HabboHotel.PathFinding.Vector2D(base.GetRoomUser().X, base.GetRoomUser().Y);
2048 HabboHotel.PathFinding.Vector2D Pos2 = new HabboHotel.PathFinding.Vector2D(base.GetBotData().InteractingWith.X, base.GetBotData().InteractingWith.Y);
2049
2050 if (RoleplayManager.Distance(Pos1, Pos2) > 3)
2051 {
2052
2053 if (!base.GetRoomUser().IsWalking)
2054 {
2055 base.GetBotData().TimesTried++;
2056 }
2057
2058 base.GetRoomUser().MoveTo(Pos2.X, Pos2.Y + 1, true);
2059
2060 if (base.GetBotData().TimesTried >= 7)
2061 {
2062 base.GetRoomUser().SetPos(Pos2.X, Pos2.Y, 0);
2063 base.GetRoomUser().UpdateNeeded = true;
2064 }
2065
2066 }
2067 else
2068 {
2069 if (LActionTimer < 5)
2070 {
2071 LActionTimer++;
2072 }
2073 else
2074 {
2075 if (!LoadedUser)
2076 {
2077 base.GetRoomUser().Chat(null, "Omg look at you , You're so poor", true, 1);
2078 base.GetRoomUser().Chat(null, "*Takes " + base.GetBotData().InteractingWith.GetClient().GetHabbo().UserName + " into the ambulance strecher*", true, 1);
2079 base.GetBotData().InteractingWith.ApplyEffect(23);
2080 LoadedUser = true;
2081 }
2082 else
2083 {
2084 if (LActionTimer < 10)
2085 {
2086 LActionTimer++;
2087 }
2088 else
2089 {
2090 if (!TransferedUser)
2091 {
2092 base.GetBotData().InteractingWith.GetClient().GetMessageHandler().PrepareRoomForUser(1, null);
2093 base.GetRoomUser().Chat(null, "*Takes " + base.GetBotData().InteractingWith.GetClient().GetHabbo().UserName + " to the hospital in their ambulance*", true, 1);
2094 base.GetRoomUser().ApplyEffect(3);
2095 TransferedUser = true;
2096 }
2097 else
2098 {
2099 if (LActionTimer < 15)
2100 {
2101 if (LActionTimer == 13)
2102 {
2103 List<Point> list = base.GetRoom().GetGameMap().getWalkableList();
2104 if (list.Count == 0)
2105 return;
2106 int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
2107
2108 base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y, true);
2109 }
2110 LActionTimer++;
2111 }
2112 else
2113 {
2114 if (LActionTimer < 20)
2115 {
2116 base.GetRoomUser().ApplyEffect(20);
2117 List<Point> list = base.GetRoom().GetGameMap().getWalkableList();
2118 if (list.Count == 0)
2119 return;
2120 int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
2121
2122 base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y);
2123 LActionTimer++;
2124 }
2125 else
2126 {
2127 RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
2128 }
2129 }
2130 }
2131 }
2132 }
2133
2134 }
2135 }
2136 }
2137
2138 }
2139
2140
2141 break;
2142
2143 #endregion
2144 #region swat Bot
2145 case "swat_bot":
2146 {
2147
2148 bool LeaveRoom = false;
2149
2150 if (base.GetBotData().InteractingWith == null)
2151 {
2152 LeaveRoom = true;
2153 }
2154
2155 if (!base.GetBotData().InteractingWith.GetClient().GetRoleplay().Dead)
2156 {
2157 LeaveRoom = true;
2158 }
2159
2160 if (base.GetBotData() != null)
2161 {
2162 if (base.GetBotData().InteractingWith != null)
2163 {
2164 if (base.GetBotData().InteractingWith.GetClient() != null)
2165 {
2166 if (base.GetBotData().InteractingWith.GetClient().GetHabbo() != null)
2167 {
2168 if (base.GetBotData().InteractingWith.GetClient().GetHabbo().CurrentRoomId != base.GetBotData().RoomId)
2169 {
2170 LeaveRoom = true;
2171 }
2172 }
2173 }
2174 }
2175 }
2176
2177 if (base.GetRoom() == null)
2178 {
2179 LeaveRoom = true;
2180 }
2181
2182 #region Leaveroom
2183 if (LeaveRoom)
2184 {
2185
2186 if (LActionTimer < 20)
2187 {
2188 base.GetRoomUser().ApplyEffect(19);
2189 List<Point> list = base.GetRoom().GetGameMap().getWalkableList();
2190 if (list.Count == 0)
2191 return;
2192 int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
2193
2194 base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y);
2195 LActionTimer++;
2196 }
2197 else
2198 {
2199
2200 RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
2201 }
2202
2203
2204 }
2205 #endregion
2206
2207
2208 if (!LeaveRoom)
2209 {
2210 base.GetRoomUser().ApplyEffect(19);
2211
2212
2213 HabboHotel.PathFinding.Vector2D Pos1 = new HabboHotel.PathFinding.Vector2D(base.GetRoomUser().X, base.GetRoomUser().Y);
2214 HabboHotel.PathFinding.Vector2D Pos2 = new HabboHotel.PathFinding.Vector2D(base.GetBotData().InteractingWith.X, base.GetBotData().InteractingWith.Y);
2215
2216 if (RoleplayManager.Distance(Pos1, Pos2) > 3)
2217 {
2218
2219 if (!base.GetRoomUser().IsWalking)
2220 {
2221 base.GetBotData().TimesTried++;
2222 }
2223
2224 base.GetRoomUser().MoveTo(Pos2.X, Pos2.Y + 1, true);
2225
2226 if (base.GetBotData().TimesTried >= 7)
2227 {
2228 base.GetRoomUser().SetPos(Pos2.X, Pos2.Y, 0);
2229 base.GetRoomUser().UpdateNeeded = true;
2230 }
2231
2232 }
2233 else
2234 {
2235 if (LActionTimer < 5)
2236 {
2237 LActionTimer++;
2238 }
2239 else
2240 {
2241 if (!LoadedUser)
2242 {
2243 base.GetRoomUser().Chat(null, "*Shoot their taser-gun bursting " + base.GetBotData().InteractingWith.GetClient().GetHabbo().UserName + "'s flesh, causing them stop**", true, 1);
2244 base.GetRoomUser().Chat(null, "You're under arrest sir", true, 1);
2245 base.GetBotData().InteractingWith.ApplyEffect(23);
2246 LoadedUser = true;
2247 }
2248 else
2249 {
2250 if (LActionTimer < 10)
2251 {
2252 LActionTimer++;
2253 }
2254 else
2255 {
2256 if (!TransferedUser)
2257 {
2258 base.GetRoomUser().Chat(null, "*Places their hand-cuffs on " + base.GetBotData().InteractingWith.GetClient().GetHabbo().UserName + "'s wrists*", true, 1);
2259 base.GetRoomUser().Chat(null, "*Arrests " + base.GetBotData().InteractingWith.GetClient().GetHabbo().UserName + "'s for 20 minutes *", true, 1);
2260 base.GetBotData().InteractingWith.GetClient().SendNotif("You have been arrested by Rila-Kuma for 20 minute(s)");
2261 base.GetBotData().InteractingWith.GetClient().GetRoleplay().JailFigSet = false;
2262 base.GetBotData().InteractingWith.GetClient().GetRoleplay().JailedSeconds = 60;
2263 base.GetBotData().InteractingWith.GetClient().GetRoleplay().JailTimer = 20;
2264 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Jailed = true;
2265 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Arrested++;
2266 base.GetBotData().InteractingWith.GetClient().GetRoleplay().UpdateStats++;
2267
2268 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Weed = 0;
2269 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("weed", "0");
2270 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Atropine = 0;
2271 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("atropine", "0");
2272 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Cyanide = 0;
2273 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("cyanide", "0");
2274 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Glucagon = 0;
2275 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("glucagon", "0");
2276 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Glybera = 0;
2277 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("glybera", "0");
2278 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Lyrica = 0;
2279 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("lyrica", "0");
2280 base.GetBotData().InteractingWith.GetClient().GetRoleplay().Taltz = 0;
2281 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("taltz", "0");
2282
2283 if (base.GetBotData().InteractingWith.GetClient().GetRoleplay().Working)
2284 {
2285 base.GetBotData().InteractingWith.GetClient().GetRoleplay().StopWork();
2286 }
2287 base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveStatusComponents("jailed");
2288 base.GetBotData().InteractingWith.GetClient().GetMessageHandler().PrepareRoomForUser(9, null);
2289 TransferedUser = true;
2290 }
2291 else
2292 {
2293 if (LActionTimer < 15)
2294 {
2295 if (LActionTimer == 13)
2296 {
2297 base.GetRoomUser().ApplyEffect(19);
2298 List<Point> list = base.GetRoom().GetGameMap().getWalkableList();
2299 if (list.Count == 0)
2300 return;
2301 int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
2302
2303 base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y, true);
2304 }
2305 LActionTimer++;
2306 }
2307 else
2308 {
2309 if (LActionTimer < 20)
2310 {
2311 base.GetRoomUser().ApplyEffect(19);
2312 List<Point> list = base.GetRoom().GetGameMap().getWalkableList();
2313 if (list.Count == 0)
2314 return;
2315 int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
2316
2317 base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y);
2318 LActionTimer++;
2319 }
2320 else
2321 {
2322 RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
2323 }
2324 }
2325 }
2326 }
2327 }
2328
2329 }
2330 }
2331 }
2332
2333 }
2334
2335
2336 break;
2337
2338 #endregion
2339
2340 }
2341 }
2342 }
2343
2344 private void StopTimerTick()
2345 {
2346 if (_chatTimer == null) return;
2347 _chatTimer.Change(Timeout.Infinite, Timeout.Infinite);
2348 _chatTimer.Dispose();
2349 _chatTimer = null;
2350 }
2351
2352 /// <summary>
2353 /// Chats the timer tick.
2354 /// </summary>
2355 /// <param name="o">The o.</param>
2356 private void ChatTimerTick(object o)
2357 {
2358 if (GetBotData() == null || GetRoomUser() == null || GetBotData().WasPicked || GetBotData().RandomSpeech == null ||
2359 !GetBotData().RandomSpeech.Any())
2360 {
2361 StopTimerTick();
2362 return;
2363 }
2364
2365 if (GetRoom() != null && GetRoom().MutedBots)
2366 return;
2367
2368 var randomSpeech = GetBotData().GetRandomSpeech(GetBotData().MixPhrases);
2369
2370 try
2371 {
2372 switch (randomSpeech)
2373 {
2374 case ":sit":
2375 {
2376 var user = GetRoomUser();
2377 if (user.RotBody % 2 != 0) user.RotBody--;
2378
2379 user.Z = GetRoom().GetGameMap().SqAbsoluteHeight(user.X, user.Y);
2380 if (!user.Statusses.ContainsKey("sit"))
2381 {
2382 user.UpdateNeeded = true;
2383 user.Statusses.Add("sit", "0.55");
2384 }
2385 user.IsSitting = true;
2386 return;
2387 }
2388 case ":stand":
2389 {
2390 var user = GetRoomUser();
2391 if (user.IsSitting)
2392 {
2393 user.Statusses.Remove("sit");
2394 user.IsSitting = false;
2395 user.UpdateNeeded = true;
2396 }
2397 else if (user.IsLyingDown)
2398 {
2399 user.Statusses.Remove("lay");
2400 user.IsLyingDown = false;
2401 user.UpdateNeeded = true;
2402 }
2403 return;
2404 }
2405 }
2406
2407 if (GetRoom() != null)
2408 {
2409 randomSpeech = randomSpeech.Replace("%user_count%",
2410 GetRoom().GetRoomUserManager().GetRoomUserCount().ToString());
2411 randomSpeech = randomSpeech.Replace("%item_count%",
2412 GetRoom().GetRoomItemHandler().TotalItems.ToString());
2413 randomSpeech = randomSpeech.Replace("%floor_item_count%",
2414 GetRoom().GetRoomItemHandler().FloorItems.Keys.Count.ToString());
2415 randomSpeech = randomSpeech.Replace("%wall_item_count%",
2416 GetRoom().GetRoomItemHandler().WallItems.Keys.Count.ToString());
2417
2418 if (GetRoom().RoomData != null)
2419 {
2420 randomSpeech = randomSpeech.Replace("%roomname%", GetRoom().RoomData.Name);
2421 randomSpeech = randomSpeech.Replace("%owner%", GetRoom().RoomData.Owner);
2422 }
2423 }
2424 if (GetBotData() != null) randomSpeech = randomSpeech.Replace("%name%", GetBotData().Name);
2425
2426 GetRoomUser().Chat(null, randomSpeech, false, 0, 0);
2427 }
2428 catch (Exception e)
2429 {
2430 Writer.Writer.LogException(e.ToString());
2431 }
2432 }
2433 }
2434}
2435
2436chatcommandshandlers.cs
2437 #region :callswat x
2438 case "callswat":
2439 case "helpswat":
2440 case "swathelp":
2441 {
2442
2443 #region Generate Instances / Sessions
2444 if (!RoleplayManager.ParamsMet(Params, 1))
2445 {
2446 Session.SendWhisper("Invalid command syntax: :rape <user>");
2447 return true;
2448 }
2449 string Target = Convert.ToString(Params[1]);
2450 GameClient TargetSession = null;
2451 TargetSession = RoleplayManager.GenerateSession(Target);
2452
2453 if (TargetSession == null)
2454 {
2455 Session.SendWhisper("This user was not found in this room.");
2456 return true;
2457 }
2458 #endregion
2459
2460 #region Conditions
2461 if (!Session.GetRoleplay().JobHasRights("police")
2462 && !Session.GetRoleplay().JobHasRights("gov")
2463 && !Session.GetRoleplay().JobHasRights("swat"))
2464 {
2465 Session.SendWhisper("Your job cannot do this!");
2466 return true;
2467 }
2468 if (!Session.GetRoleplay().Working)
2469 {
2470 Session.SendWhisper("You must be working to do this!");
2471 return true;
2472 }
2473 if (Session.GetRoleplay().Jailed)
2474 {
2475 Session.SendWhisper("You cannot do this while jailed!");
2476 return true;
2477 }
2478 if (RoleplayManager.UserDistance(Session, TargetSession) > 3)
2479 {
2480 Session.SendWhisper("You must be closer to do this!");
2481 return true;
2482 }
2483 if (!Session.GetRoleplay().MultiCoolDown.ContainsKey("helpswat_cooldown"))
2484 {
2485 Session.GetRoleplay().MultiCoolDown.Add("helpswat_cooldown", 0);
2486 }
2487 if (Session.GetRoleplay().MultiCoolDown["helpswat_cooldown"] > 0)
2488 {
2489 Session.SendWhisper("Cooldown [" + Session.GetRoleplay().MultiCoolDown["helpswat_cooldown"] + "/30]");
2490 return true;
2491 }
2492 #endregion
2493
2494 #region Execute
2495 Session.GetRoleplay().MultiCoolDown["helpswat_cooldown"] = 30;
2496 Session.GetRoleplay().CheckingMultiCooldown = true;
2497 RoleplayManager.Handleswatjail(TargetSession);
2498 RoomUser u = Session.GetHabbo().GetRoomUser();
2499 Session.GetRoleplay().EffectSeconds = 6;
2500 u.ApplyEffect(65);
2501 return true;
2502
2503 #endregion
2504
2505 return true;
2506 }
2507 #endregion