private void maskCommand(BasePlayer player, string command, string[] args) { if (!hasPermission(player, permissions.mask)) { PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString)); return; } Hunt hunt = HuntData.getHuntByHunter(player); if (hunt == null) { player.ChatMessage("You're not hunting anyone!"); return; } if (config.maskNames.Count == 0) { player.ChatMessage("There aren't any masknames available."); return; } System.Random rand = new System.Random(); string maskName = config.maskNames[rand.Next(0, config.maskNames.Count - 1)]; rename(player, maskName); player.ChatMessage($"You've been renamed to <color=#00ff33><size=16>{maskName}</size></color>. Using global chat might give you away, so be careful..."); }
void OnPlayerKilled(BasePlayer victim, BasePlayer killer) { #if DEBUG PrintToChat($"{killer?.displayName ?? "null"} kills {victim?.displayName ?? "null"}"); #endif Hunt hunt = null; hunt = HuntData.getHuntByTarget(victim); if (hunt != null) //Hunter kills target { if (hunt.hunter == killer && hunt.target == victim) { hunt.end(hunt.hunter); } } else { hunt = HuntData.getHuntByHunter(victim); } if (hunt != null) //target kills hunter { if (hunt.target == killer && hunt.hunter == victim) { hunt.end(hunt.target); } } return; }
partial void initData() { BountyData.init(); HuntData.init(); HuntData.restartHunts(); CooldownData.init(); }
public void Setup(HuntData currentItem) { item = currentItem; PokemonName.text = PokedexManager.instance.GetPokemon(item.pokemonNumber); GameName.text = DataPkm.GetGameVersionString(item.Game); MethodName.text = DataPkm.GetHuntingModeString(item.Method); Counter.text = item.totalCount.ToString(); PokemonIcon.sprite = PokedexManager.instance.GetPokemonEntity(item.pokemonNumber).image; }
private void SetupButtons() { for (int i = 0; i < itemList.Count; i++) { HuntData item = itemList[i]; GameObject newButton = (GameObject)GameObject.Instantiate(prefabButton, contentPanel); ItemListHunt sampleButton = newButton.GetComponent <ItemListHunt>(); sampleButton.Setup(item); } }
public static void load() { try { instance = huntDataFile.ReadObject <HuntData>(); } catch (Exception E) { StringBuilder sb = new StringBuilder($"loading {typeof(HuntData).Name} failed. Make sure that all classes you're saving have a default constructor!\n"); sb.Append(E.Message); PluginInstance.Puts(sb.ToString()); } }
private object OnItemAction(Item item, string action) { if (action != "crush") { return(null); } if (item.info.shortname != "skull.human") { return(null); } string skullName = null; if (item.name != null) { skullName = item.name.Substring(10, item.name.Length - 11); } if (string.IsNullOrEmpty(skullName)) { return(null); } BasePlayer killer = item.GetOwnerPlayer(); BasePlayer victim = BasePlayer.Find(skullName); if (victim == null) { return(null); } #if DEBUG PrintToChat($"{killer} crushed {victim}'s skull!"); #endif Hunt hunt = null; hunt = HuntData.getHuntByTarget(victim); if (hunt == null) { hunt = HuntData.getHuntByHunter(victim); } if (hunt == null) { return(null); } if (hunt.hunter == killer || hunt.target == killer) { hunt.end(killer); return(null); } return(null); }
void OnPlayerDisconnected(BasePlayer player, string reason) { if (player == null) { return; } Hunt hunt = HuntData.getHuntByHunter(player); if (hunt == null) { return; } hunt.end(); CooldownData.removeCooldown(hunt.target); }
// Use this for initialization void Start() { HuntData d = PersistantData.instance.data.GetActiveHunt(); PokemonName.text = PokedexManager.instance.GetPokemon(d.pokemonNumber); GameName.text = DataPkm.GetGameVersionString(d.Game); MethodName.text = DataPkm.GetHuntingModeString(d.Method); Title.text = d.Name; float denom = 1f / d.prob; denom = Mathf.CeilToInt(denom); Proba.text = "1 / " + denom.ToString(); PokemonImage.sprite = PokedexManager.instance.GetPokemonEntity(d.pokemonNumber).image; }
public bool Load() { if (File.Exists(Application.persistentDataPath + "/game.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/game.dat", FileMode.Open); data = (GameData)bf.Deserialize(file); file.Close(); HuntData.ForceUpdateId(data.Hunts); LocalizationManager.Instance.currentLanguageID = data.Lang; return(true); } return(false); }
public void end(BasePlayer winner = null) { #if DEBUG PluginInstance.PrintToChat($"ending hunt {hunterName} -> {bounty.targetName}, winner: {winner?.displayName ?? "null"}"); #endif if (huntTimer != null) { huntTimer.Destroy(); } if (ticker != null) { ticker.Destroy(); } PluginInstance.rename(hunter, hunterName); if (winner == hunter) { Interface.Oxide.CallHook("OnBountyCompleted", winner, target); //msg PluginInstance.huntSuccessfullMsg(this); //payout hunter.GiveItem(bounty.reward); } else if (winner == target) { //msg PluginInstance.huntFailedMsg(this); //payout target.GiveItem(bounty.reward); } else { //msg PluginInstance.huntExpiredMsg(this); bounty.noteUid = bounty.giveNote(hunter); BountyData.AddBounty(bounty); } PluginInstance.closeIndicators(target); PluginInstance.closeIndicators(hunter); bounty.hunt = null; HuntData.removeHunt(this); CooldownData.addCooldown(target); }
void OnPlayerSleepEnded(BasePlayer player) { if (player == null) { return; } Hunt hunt = HuntData.getHuntByTarget(player); if (hunt == null) { hunt = HuntData.getHuntByHunter(player); } if (hunt == null) { return; } hunt.initTicker(); }
private void huntCommand(BasePlayer player, string command, string[] args) { if (!hasPermission(player, permissions.admin)) { PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString)); return; } if (args.Length == 0) { return; } switch (args[0]) { case "list": player.ChatMessage("Ongoing hunts:"); foreach (Hunt h in HuntData.instance.hunts) { player.ChatMessage($"{h.hunterName} hunts {h.bounty.targetName}"); } break; case "end": case "remove": if (args.Length < 2) { return; } BasePlayer target = findPlayer(args[1], player); Hunt hunt = HuntData.getHuntByHunter(target); if (hunt == null) { hunt = HuntData.getHuntByTarget(target); } if (hunt == null) { return; } hunt.end(); player.ChatMessage("removed hunt"); break; } }
public Hunt(Bounty bounty, BasePlayer hunter) { if (bounty.hunt != null) { PluginInstance.Puts($"Hunt Constructor: Bounty {bounty.placerName} -> {bounty.targetName} already has an ongoing hunt!"); } timestamp = DateTime.Now; this.bounty = bounty; hunterID = hunter.userID; hunterName = hunter.displayName; initTicker(); PluginInstance.sendHunterIndicator(hunter, this); PluginInstance.sendTargetIndicator(target, this); HuntData.addHunt(this); if (PluginInstance.hasPermission(hunter, permissions.mask)) { hunter.ChatMessage("<color=#00ff33>Hunt started!</color> Remember that you can use /mask and /unmask to randomize your name for some extra stealth!"); } PluginInstance.LogToFile(huntLogFileName, $"{DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")} Hunt started: {hunter.displayName}[{hunter.UserIDString}] hunting {target.displayName}[{target.UserIDString}], placed by {bounty.placerName}[{bounty.placerID}]", PluginInstance); }
private void unmaskCommand(BasePlayer player, string command, string[] args) { if (!hasPermission(player, permissions.mask)) { PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString)); return; } Hunt hunt = HuntData.getHuntByHunter(player); if (hunt == null) { player.ChatMessage("You're not hunting anyone!"); return; } if (player.displayName == hunt.hunterName) { player.ChatMessage("you're not masked!"); return; } rename(player, hunt.hunterName); player.ChatMessage("You've been unmasked!"); }
public void Validate() { HuntData hunt = null; if (data.data.HuntActive == -1) { hunt = new HuntData(); } else { hunt = data.data.GetActiveHunt(); } DataPkm.GameVersion CurrentVersion = TmpValueGame[GameVersionDD.options[GameVersionDD.value].text]; DataPkm.HuntingMode CurrentMethod = TmpValueHunt[MethodVersionDD.options[MethodVersionDD.value].text]; hunt.Game = CurrentVersion; hunt.Method = CurrentMethod; hunt.ShinyCharm = ShinyCharm; hunt.prob = prob; if (NameInput.text.Length > 0) { hunt.Name = NameInput.text; } hunt.pokemonNumber = PkmId; if (data.data.HuntActive == -1) { data.data.Hunts.Add(hunt); data.data.HuntActive = hunt.id; } data.Save(); Debug.Log("Hunt active is : " + data.data.HuntActive); manager.ShowHunt(); }
public void huntButton(BasePlayer player, Bounty bounty, huntErrorType error = huntErrorType.none) { GuiContainer c = new GuiContainer(this, "huntButton", "bountyPreview"); Rectangle ButtonPos = new Rectangle(710, 856, 500, 100, resX, resY, true); List <GuiText> textOptions = new List <GuiText> { new GuiText("Start Hunting", guiCreator.getFontsizeByFramesize(13, ButtonPos), lightGreen), new GuiText("You are already hunting", guiCreator.getFontsizeByFramesize(23, ButtonPos), lightRed), new GuiText("Target is already being hunted", guiCreator.getFontsizeByFramesize(30, ButtonPos), lightRed), new GuiText("Target can't be hunted yet", guiCreator.getFontsizeByFramesize(26, ButtonPos), lightRed), new GuiText("Hunt Active", guiCreator.getFontsizeByFramesize(11, ButtonPos), lightRed), new GuiText("You can't hunt yourself!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed), new GuiText("Target is offline", guiCreator.getFontsizeByFramesize(17, ButtonPos), lightRed), new GuiText("Too close to the target!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed), }; Action <BasePlayer, string[]> cb = (p, a) => { TimeSpan targetCooldown = TimeSpan.Zero; TimeSpan creationCooldown = new TimeSpan(0, 0, config.creationCooldown - (int)bounty.timeSinceCreation.TotalSeconds); if (error == huntErrorType.huntActive) { return; } else if (bounty.target == null) { Effect.server.Run(errorSound, player.transform.position); huntButton(player, bounty, huntErrorType.offline); } else if (bounty.target.IsSleeping()) { Effect.server.Run(errorSound, player.transform.position); huntButton(player, bounty, huntErrorType.offline); } else if (bounty.hunt != null || HuntData.getHuntByHunter(p) != null) { Effect.server.Run(errorSound, player.transform.position); huntButton(player, bounty, huntErrorType.hunterAlreadyHunting); } else if (HuntData.getHuntByTarget(bounty.target) != null) { Effect.server.Run(errorSound, player.transform.position); huntButton(player, bounty, huntErrorType.targetAlreadyHunted); } else if ((bounty.timeSinceCreation.TotalSeconds < config.creationCooldown || CooldownData.isOnCooldown(bounty.target, out targetCooldown)) && !hasPermission(player, permissions.admin)) { Effect.server.Run(errorSound, player.transform.position); huntButton(player, bounty, huntErrorType.targetCooldown); TimeSpan select = creationCooldown; if (targetCooldown > creationCooldown) { select = targetCooldown; } player.ChatMessage($"Cooldown: {select.ToString(@"hh\:mm\:ss")}"); } else if (bounty.target == player && !hasPermission(player, permissions.admin)) { Effect.server.Run(errorSound, player.transform.position); huntButton(player, bounty, huntErrorType.selfHunt); } else if (Vector3.Distance(player.transform.position, bounty.target.transform.position) < config.safeDistance && !hasPermission(player, permissions.admin)) { Effect.server.Run(errorSound, player.transform.position); huntButton(player, bounty, huntErrorType.tooClose); } else { Effect.server.Run(successSound, player.transform.position); bounty.startHunt(p); BountyData.removeBounty(bounty.noteUid); player.GetActiveItem()?.Remove(); closeBounty(player); } }; c.addPlainButton("button", ButtonPos, GuiContainer.Layer.hud, (error == huntErrorType.none)?darkGreen:darkRed, FadeIn, FadeOut, textOptions[(int)error], cb, blur: GuiContainer.Blur.medium); c.display(player); if (error != huntErrorType.none && error != huntErrorType.huntActive) { PluginInstance.timer.Once(2f, () => { if (GuiTracker.getGuiTracker(player).getContainer(this, "bountyPreview") != null) { huntButton(player, bounty); } }); } }