public void PetEnergy(bool Add) { int MaxE; if (Add) { if (Energy == 100) // If Energy is 100, no point. { return; } if (Energy > 85) { MaxE = MaxEnergy - Energy; } else { MaxE = 10; } } else { MaxE = 15; // Remove Max Energy as 15 } if (MaxE <= 4) { MaxE = 15; } int r = QuasarEnvironment.GetRandomNumber(4, MaxE); if (!Add) { Energy = Energy - r; if (Energy < 0) { Energy = 1; r = 1; } } else { Energy = Energy + r; } if (DBState != DatabaseUpdateState.NeedsInsert) { DBState = DatabaseUpdateState.NeedsUpdate; } }
public override void OnTimerTick() { RoomUser Pet = GetRoomUser(); if (Pet == null) { return; } #region Speech if (SpeechTimer <= 0) { if (Pet.PetData.DBState != DatabaseUpdateState.NeedsInsert) { Pet.PetData.DBState = DatabaseUpdateState.NeedsUpdate; } if (Pet != null) { var RandomSpeech = new Random(); RemovePetStatus(); string[] Speech = QuasarEnvironment.GetGame().GetChatManager().GetPetLocale().GetValue("speech.pet" + Pet.PetData.Type); string rSpeech = Speech[RandomNumber.GenerateRandom(0, Speech.Length - 1)]; if (rSpeech.Length != 3) { Pet.Chat(rSpeech, false); } else { Pet.Statusses.Add(rSpeech, TextHandling.GetString(Pet.Z)); } } SpeechTimer = QuasarEnvironment.GetRandomNumber(20, 120); } else { SpeechTimer--; } #endregion #region Actions if (ActionTimer <= 0) { try { RemovePetStatus(); ActionTimer = RandomNumber.GenerateRandom(15, 40 + GetRoomUser().PetData.VirtualId); if (!GetRoomUser().RidingHorse) { // Remove Status RemovePetStatus(); Point nextCoord = GetRoom().GetGameMap().getRandomWalkableSquare(); if (GetRoomUser().CanWalk) { GetRoomUser().MoveTo(nextCoord.X, nextCoord.Y); } } } catch (Exception e) { Logging.HandleException(e, "PetBot.OnTimerTick"); } } else { ActionTimer--; } #endregion #region Energy if (EnergyTimer <= 0) { RemovePetStatus(); // Remove Status Pet.PetData.PetEnergy(true); // Add Energy EnergyTimer = RandomNumber.GenerateRandom(30, 120); // 2 Min Max } else { EnergyTimer--; } #endregion }
public bool Execute(params object[] Params) { if (Params == null || Params.Length == 0) { return(false); } Habbo Owner = QuasarEnvironment.GetHabboById(Item.UserID); if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards")) { return(false); } Habbo Player = (Habbo)Params[0]; if (Player == null || Player.GetClient() == null) { return(false); } RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username); if (User == null) { return(false); } if (String.IsNullOrEmpty(StringData)) { return(false); } int amountLeft = int.Parse(this.StringData.Split('-')[2]); int often = int.Parse(this.StringData.Split('-')[1]); bool unique = this.BoolData; bool premied = false; if (amountLeft == 1) { Player.GetClient().SendNotification("Ya no hay mas premios, vuelve mas tarde."); return(true); } foreach (var dataStr in (this.StringData.Split('-')[0]).Split(';')) { var dataArray = dataStr.Split(','); var isbadge = dataArray[0] == "0"; var code = dataArray[1]; var percentage = int.Parse(dataArray[2]); var random = QuasarEnvironment.GetRandomNumber(0, 100); if (!unique && percentage < random) { continue; } premied = true; if (isbadge) { if (Player.GetBadgeComponent().HasBadge(code)) { Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Je hebt een Badge ontvangen die je al eerder in je inventaris had staan!", 0, User.LastBubble)); } else { Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient()); Player.GetClient().SendNotification("Je hebt een Badge ontvangen!"); } } else { ItemData ItemData = null; if (!QuasarEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData)) { Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Kon item niet laden: " + code, 0, User.LastBubble)); return(false); } Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0); if (Item != null) { Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item); Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1)); Player.GetClient().SendMessage(new PurchaseOKComposer()); Player.GetClient().SendMessage(new FurniListAddComposer(Item)); Player.GetClient().SendMessage(new FurniListUpdateComposer()); Player.GetClient().SendNotification("¡Has recibido un regalo! Revisa tu inventario."); } } } if (!premied) { Player.GetClient().SendNotification("Mweh, volgende keer weer een kans."); } else if (amountLeft > 1) { amountLeft--; this.StringData.Split('-')[2] = amountLeft.ToString(); } return(true); }
public Item GetRandomExitTile() { return(ExitTeleports.Values.ToList()[QuasarEnvironment.GetRandomNumber(0, ExitTeleports.Count - 1)]); }