Beispiel #1
0
        public void Use(Character character, Token item, bool noConfirm = false)
        {
            var boardchar   = NoxicoGame.Me.CurrentBoard.Entities.OfType <BoardChar>().First(x => x.Character == character);
            var runningDesc = string.Empty;

            Action <string> showDesc = new Action <string>(d =>
            {
                NoxicoGame.DrawStatus();
                if (d.Contains('\n'))
                {
                    MessageBox.Notice(runningDesc.Viewpoint(boardchar.Character, null));
                }
                else
                {
                    NoxicoGame.AddMessage(runningDesc.Viewpoint(boardchar.Character, null));
                }
            });

            #region Books
            if (this.ID == "book")
            {
                TextScroller.ReadBook(item.GetToken("id").Text);
                return;
            }
            #endregion

            #region Equipment
            if (this.HasToken("equipable"))
            {
                if (item == null)
                {
                    var items = character.GetToken("items");
                    item = items.Tokens.Find(x => x.Name == this.ID);
                }

                if (!item.HasToken("equipped"))
                {
                    //TODO: only ask if it's the player?
                    //Not wearing it
                    MessageBox.Ask(runningDesc + i18n.Format("inventory_equip_x", this.ToString(item, true)), () =>
                    {
                        try
                        {
                            if (this.Equip(character, item))
                            {
                                runningDesc += i18n.Format("x_equiped_y", this.ToString(item, true));
                            }
                        }
                        catch (ItemException c)
                        {
                            runningDesc += c.Message;
                        }
                        if (!runningDesc.IsBlank())
                        {
                            showDesc(runningDesc.Viewpoint(boardchar.Character));
                        }
                        return;
                    },
                                   null);
                }
                else
                {
                    //Wearing/wielding it
                    if (item.HasToken("cursed") && item.GetToken("cursed").HasToken("known"))
                    {
                        runningDesc += item.GetToken("cursed").Text.IsBlank(i18n.Format("inventory_cursed_" + (this.HasToken("plural") ? "plural" : "singular"), this.ToString(item, true)), item.GetToken("cursed").Text);
                        showDesc(runningDesc.Viewpoint(boardchar.Character));
                        return;
                    }
                    MessageBox.Ask(i18n.Format("inventory_unequip_x", this.ToString(item, true)), () =>
                    {
                        try
                        {
                            if (this.Unequip(character))
                            {
                                runningDesc += i18n.Format("x_unequiped_y", this.ToString(item, true));
                            }
                        }
                        catch (ItemException x)
                        {
                            runningDesc += x.Message;
                        }
                        if (!runningDesc.IsBlank())
                        {
                            showDesc(runningDesc.Viewpoint(boardchar.Character));
                        }
                        return;
                    },
                                   null);
                }
                return;
            }
            #endregion

            if (this.HasToken("ammo"))
            {
                MessageBox.Notice(i18n.GetString("thisisammo"));
                return;
            }

            if (this.HasToken("quest") || this.HasToken("nouse"))
            {
                if (this.HasToken("description"))
                {
                    runningDesc = this.GetToken("description").Text + "\n\n";
                }
                showDesc(runningDesc + i18n.GetString("noeffect"));
                return;
            }

            //Confirm use of potentially hazardous items
            if (!noConfirm)
            {
                var name = new StringBuilder();
                if (this.IsProperNamed)
                {
                    name.Append(this.Definite.IsBlank(string.Empty, this.Definite + ' '));
                }
                else
                {
                    name.Append(this.Indefinite.IsBlank(string.Empty, this.Indefinite + ' '));
                }
                name.Append(this.Name);
                if (item.HasToken("unidentified") && !this.UnknownName.IsBlank())
                {
                    runningDesc = i18n.GetString("unidentified_warning");
                }
                else
                {
                    if (this.HasToken("description"))
                    {
                        //No need to check for "worn" or "examined" here...
                        runningDesc = this.GetDescription(item) + "\n\n";                         //this.GetToken("description").Text + "\n\n";
                    }
                    runningDesc += i18n.Format("use_x_confirm", this.ToString(item, true));
                }
                MessageBox.Ask(runningDesc, () => { this.Use(character, item, true); }, null);
                return;
            }

            var statBonus = this.GetToken("statbonus");
            if (statBonus != null)
            {
                foreach (var bonus in statBonus.Tokens)
                {
                    if (bonus.Name == "health")
                    {
                        character.Health += bonus.Value;
                        if (character.Health > character.MaximumHealth)
                        {
                            character.Health = character.MaximumHealth;
                        }
                    }
                }
            }

            var food = this.GetToken("food");
            if (food != null)
            {
                Eat(character, food);
            }

            if (!this.OnUse.IsBlank())
            {
                RunScript(item, this.OnUse, character, boardchar, (x => runningDesc += x));
            }
            else
            {
                this.Consume(character, item);
            }

            if (!runningDesc.IsBlank())
            {
                showDesc(runningDesc.Viewpoint(boardchar.Character));
            }
        }
Beispiel #2
0
        public override void Update()
        {
            base.Update();
            NoxicoGame.ContextMessage = i18n.GetString("context_interactmode");
            if (this.ParentBoard == null)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                return;
            }
            //this.ParentBoard.Draw(true);

            if (NoxicoGame.IsKeyDown(KeyBinding.Interact) || NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                NoxicoGame.ClearKeys();
                NoxicoGame.ContextMessage = string.Empty;
                Hide();
                return;
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.TabFocus) || Vista.Triggers == XInputButtons.RightShoulder)
            {
                NoxicoGame.ClearKeys();
                Tabstop++;
                if (Tabstop >= Tabstops.Count)
                {
                    Tabstop = 0;
                }
                XPosition = Tabstops[Tabstop].X;
                YPosition = Tabstops[Tabstop].Y;
                Point();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Accept) || Vista.Triggers == XInputButtons.A)
            {
                Subscreens.PreviousScreen.Clear();
                NoxicoGame.ClearKeys();
                var player = NoxicoGame.Me.Player;
#if DEBUG
                if (PointingAt == null)
                {
                    ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY,
                                    new Dictionary <object, string>()
                    {
                        { "teleport", "Teleport" },
                        { "spawn", "Spawn character" },
                    },
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            NoxicoGame.Mode = UserMode.Walkabout;
                            Hide();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "teleport":
                            player.XPosition = this.XPosition;
                            player.YPosition = this.YPosition;
                            ParentBoard.AimCamera();
                            ParentBoard.Redraw();
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;

                        case "spawn":
                            var spawnOptions = new Dictionary <object, string>();
                            foreach (var bp in Character.Bodyplans)
                            {
                                spawnOptions[bp.Text] = bp.Text;
                            }
                            var uniques = Mix.GetTokenTree("uniques.tml", true);
                            foreach (var bp in uniques)
                            {
                                spawnOptions['!' + bp.Text] = bp.Text;
                            }
                            ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY, spawnOptions,
                                            () =>
                            {
                                if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                                {
                                    NoxicoGame.Mode = UserMode.Aiming;
                                    Point();
                                    return;
                                }
                                Character newChar = null;
                                if (ActionList.Answer is string && ((string)ActionList.Answer).StartsWith('!'))
                                {
                                    newChar = Character.GetUnique(((string)ActionList.Answer).Substring(1));
                                }
                                else
                                {
                                    newChar = Character.Generate((string)ActionList.Answer, Gender.RollDice);
                                }
                                var newBoardChar = new BoardChar(newChar)
                                {
                                    XPosition   = this.XPosition,
                                    YPosition   = this.YPosition,
                                    ParentBoard = this.ParentBoard
                                };
                                newBoardChar.AdjustView();
                                ParentBoard.EntitiesToAdd.Add(newBoardChar);
                                ParentBoard.Redraw();
                                NoxicoGame.Mode = UserMode.Walkabout;
                                Hide();
                                return;
                            }
                                            );
                            break;
                        }
                    }
                                    );
                }
#endif
                if (PointingAt != null)
                {
                    LastTarget = PointingAt;
                    var distance = player.DistanceFrom(PointingAt);
                    var canSee   = player.CanSee(PointingAt);

                    var options     = new Dictionary <object, string>();
                    var description = "something";

                    options["look"] = i18n.GetString("action_lookatit");

                    if (PointingAt is Player)
                    {
                        description     = i18n.Format("action_descyou", player.Character.Name);
                        options["look"] = i18n.GetString("action_lookatyou");
                        if (player.Character.GetStat("excitement") >= 30)
                        {
                            options["f**k"] = i18n.GetString("action_masturbate");
                        }

                        if (player.Character.HasToken("copier") && player.Character.GetToken("copier").Value == 1)
                        {
                            if (player.Character.Path("copier/backup") != null || player.Character.Path("copier/full") == null)
                            {
                                options["revert"] = i18n.GetString("action_revert");
                            }
                        }
                    }
                    else if (PointingAt is DroppedItem)
                    {
                        var drop  = PointingAt as DroppedItem;
                        var item  = drop.Item;
                        var token = drop.Token;
                        description = item.ToString(token);
                        if (distance <= 1)
                        {
                            options["take"] = i18n.GetString("action_pickup");
                        }
                    }
                    else if (PointingAt is Container)
                    {
                        var container = PointingAt as Container;
                        description = container.Name ?? "container";
                    }
                    else if (PointingAt is Clutter)
                    {
                        var clutter = PointingAt as Clutter;
                        description = clutter.Name ?? "something";
                        if (clutter.ID == "craftstation")
                        {
                            options["craft"] = i18n.GetString("action_craft");
                        }
                    }
                    else if (PointingAt is BoardChar)
                    {
                        var boardChar = PointingAt as BoardChar;
                        description     = boardChar.Character.GetKnownName(true);
                        options["look"] = i18n.Format("action_lookathim", boardChar.Character.HimHerIt(true));

                        if (canSee && distance <= 2 && !boardChar.Character.HasToken("beast") && !boardChar.Character.HasToken("sleeping"))
                        {
                            options["talk"] = i18n.Format("action_talktohim", boardChar.Character.HimHerIt(true));
                            if (boardChar.Character.Path("role/vendor") != null && boardChar.Character.Path("role/vendor/class").Text != "carpenter")
                            {
                                options["trade"] = i18n.Format("action_trade", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.GetStat("excitement") >= 30 && distance <= 1)
                        {
                            var mayFuck  = boardChar.Character.HasToken("willing");
                            var willRape = boardChar.Character.HasToken("helpless");

                            if (!IniFile.GetValue("misc", "allowrape", false) && willRape)
                            {
                                mayFuck = false;
                            }
                            //but DO allow it if they're helpless but willing
                            if (boardChar.Character.HasToken("willing") && willRape)
                            {
                                mayFuck  = true;
                                willRape = false;
                            }
                            if (boardChar.Character.HasToken("beast"))
                            {
                                mayFuck = false;
                            }

                            if (mayFuck)
                            {
                                options["f**k"] = i18n.Format(willRape ? "action_rapehim" : "action_fuckhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && !boardChar.Character.HasToken("beast") && player.Character.HasToken("copier") && player.Character.Path("copier/timeout") == null)
                        {
                            //if (player.Character.UpdateCopier())
                            if (player.Character.HasToken("fullCopy") || player.Character.HasToken("sexCopy"))
                            {
                                options["copy"] = i18n.Format("action_copyhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.CanShoot() != null && player.ParentBoard.HasToken("combat"))
                        {
                            options["shoot"] = i18n.Format("action_shoothim", boardChar.Character.HimHerIt(true));
                        }
                    }

#if DEBUG
                    if (PointingAt is BoardChar)
                    {
                        options["mutate"] = "(debug) Random mutate";
                    }
                    if (PointingAt is BoardChar)
                    {
                        options["turbomutate"] = "(debug) Apply LOTS of mutations!";
                    }
#endif

                    ActionList.Show(description, PointingAt.XPosition - NoxicoGame.CameraX, PointingAt.YPosition - NoxicoGame.CameraY, options,
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            //NoxicoGame.Messages.Add("[Aim message]");
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "look":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                var text  = (item.HasToken("description") && !token.HasToken("unidentified") ? item.GetToken("description").Text : i18n.Format("thisis_x", item.ToString(token))).Trim();
                                MessageBox.Notice(text, true);
                            }
                            else if (PointingAt is Clutter && !((Clutter)PointingAt).Description.IsBlank())
                            {
                                MessageBox.Notice(((Clutter)PointingAt).Description.Trim(), true, ((Clutter)PointingAt).Name ?? "something");
                            }
                            else if (PointingAt is Container)
                            {
                                MessageBox.Notice(((Container)PointingAt).Description.Trim(), true, ((Container)PointingAt).Name ?? "container");
                            }
                            else if (PointingAt is BoardChar)
                            {
                                if (((BoardChar)PointingAt).Character.HasToken("beast"))
                                {
                                    MessageBox.Notice(((BoardChar)PointingAt).Character.LookAt(PointingAt), true, ((BoardChar)PointingAt).Character.GetKnownName(true));
                                }
                                else
                                {
                                    TextScroller.LookAt((BoardChar)PointingAt);
                                }
                            }
                            break;

                        case "talk":
                            if (PointingAt is Player)
                            {
                                //if (Culture.CheckSummoningDay()) return;
                                if (player.Character.Path("mind").Value >= 10)
                                {
                                    MessageBox.Notice(i18n.GetString("talkingotyourself"), true);
                                }
                                else
                                {
                                    MessageBox.Notice(i18n.GetString("talkingtoyourself_nutso"), true);
                                }
                            }
                            else if (PointingAt is BoardChar)
                            {
                                var boardChar = PointingAt as BoardChar;
                                if (boardChar.Character.HasToken("hostile") && !boardChar.Character.HasToken("helpless"))
                                {
                                    MessageBox.Notice(i18n.Format("nothingtosay", boardChar.Character.GetKnownName(false, false, true, true)), true);
                                }
                                else
                                {
                                    SceneSystem.Engage(player.Character, boardChar.Character);
                                }
                            }
                            break;

                        case "trade":
                            ContainerMan.Setup(((BoardChar)PointingAt).Character);
                            break;

                        case "f**k":
                            if (PointingAt is BoardChar)
                            {
                                SexManager.Engage(player.Character, ((BoardChar)PointingAt).Character);
                            }
                            break;

                        case "shoot":
                            player.AimShot(PointingAt);
                            break;

                        case "copy":
                            player.Character.Copy(((BoardChar)PointingAt).Character);
                            player.AdjustView();
                            //NoxicoGame.AddMessage(i18n.Format((player.Character.Path("copier/full") == null) ? "youimitate_x" : "become_x", ((BoardChar)PointingAt).Character.GetKnownName(false, false, true)));
                            NoxicoGame.AddMessage(i18n.Format(player.Character.HasToken("fullCopy") ? "x_becomes_y" : "x_imitates_y").Viewpoint(player.Character, ((BoardChar)PointingAt).Character));
                            player.Energy -= 2000;
                            break;

                        case "revert":
                            player.Character.Copy(null);
                            player.AdjustView();
                            NoxicoGame.AddMessage(i18n.GetString((player.Character.HasToken("fullCopy")) ? "youmelt" : "yourevert"));
                            player.Energy -= 1000;
                            break;

                        case "take":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                drop.Take(player.Character, ParentBoard);
                                player.Energy -= 1000;
                                NoxicoGame.AddMessage(i18n.Format("youpickup_x", item.ToString(token, true)), drop.ForegroundColor);
                                NoxicoGame.Sound.PlaySound("set://GetItem");
                                ParentBoard.Redraw();
                            }
                            break;

                        case "craft":
                            Crafting.Open(player.Character);
                            break;

#if DEBUG
                        case "edit":
                            TokenCarrier tc = null;
                            if (PointingAt is DroppedItem)
                            {
                                tc = ((DroppedItem)PointingAt).Token;
                            }
                            else if (PointingAt is BoardChar)
                            {
                                tc = ((BoardChar)PointingAt).Character;
                            }

                            NoxicoGame.HostForm.Write("TOKEN EDIT ENGAGED. Waiting for editor process to exit.", Color.Black, Color.White, 0, 0);
                            NoxicoGame.HostForm.Draw();
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = false;
                            var dump = "-- WARNING! Many things may cause strange behavior or crashes. WATCH YOUR F*****G STEP.\r\n" + tc.DumpTokens(tc.Tokens, 0);
                            var temp = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString() + ".txt");
                            File.WriteAllText(temp, dump);
                            var process = System.Diagnostics.Process.Start(temp);
                            process.WaitForExit();
                            var newDump = File.ReadAllText(temp);
                            File.Delete(temp);
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = true;
                            ParentBoard.Redraw();
                            if (newDump == dump)
                            {
                                break;
                            }
                            tc.Tokenize(newDump);
                            ((BoardChar)PointingAt).AdjustView();
                            ((BoardChar)PointingAt).Character.RecalculateStatBonuses();
                            ((BoardChar)PointingAt).Character.CheckHasteSlow();
                            break;

                        case "mutate":
                            var result = ((BoardChar)PointingAt).Character.Mutate(1, 30);
                            NoxicoGame.AddMessage(result);
                            break;

                        case "turbomutate":
                            result = ((BoardChar)PointingAt).Character.Mutate(2500, 30);
                            NoxicoGame.AddMessage(result);
                            break;
#endif

                        default:
                            MessageBox.Notice("Unknown action handler \"" + ActionList.Answer.ToString() + "\".", true);
                            break;
                        }
                    }
                                    );             //	true, true);
                    return;
                }
                else
                {
                    /*
                     * var tSD = this.ParentBoard.GetDescription(YPosition, XPosition);
                     * if (!string.IsNullOrWhiteSpace(tSD))
                     * {
                     *      PointingAt = null;
                     *      MessageBox.ScriptPauseHandler = () =>
                     *      {
                     *              NoxicoGame.Mode = UserMode.Aiming;
                     *              Point();
                     *      };
                     *      MessageBox.Notice(tSD, true);
                     *      return;
                     * }
                     */
                }
            }

#if DEBUG
            if (NoxicoGame.KeyMap[Keys.D])
            {
                NoxicoGame.ClearKeys();
                if (PointingAt != null && PointingAt is BoardChar)
                {
                    ((BoardChar)PointingAt).Character.CreateInfoDump();
                    NoxicoGame.AddMessage("Info for " + ((BoardChar)PointingAt).Character.GetKnownName(true, true, true) + " dumped.", Color.Red);
                }
            }
#endif

            if (NoxicoGame.IsKeyDown(KeyBinding.Left) || Vista.DPad == XInputButtons.Left)
            {
                this.Move(Direction.West);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Right) || Vista.DPad == XInputButtons.Right)
            {
                this.Move(Direction.East);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Up) || Vista.DPad == XInputButtons.Up)
            {
                this.Move(Direction.North);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Down) || Vista.DPad == XInputButtons.Down)
            {
                this.Move(Direction.South);
            }
        }
Beispiel #3
0
        public static void Handler()
        {
            var host = NoxicoGame.HostForm;

            if (Subscreens.FirstDraw)
            {
                Subscreens.FirstDraw = false;
                UIManager.Initialize();
                UIManager.Elements.Add(new UIWindow(i18n.GetString("pause_title"))
                {
                    Left = 3, Top = 1, Width = 22, Height = pages.Count + 2
                });
                UIManager.Elements.Add(new UIWindow(string.Empty)
                {
                    Left = 28, Top = 1, Width = 49, Height = 23
                });
                list = new UIList()
                {
                    Width = 20, Height = pages.Count, Left = 4, Top = 2, Background = UIColors.WindowBackground
                };
                list.Items.AddRange(pages.Keys);
                list.Change += (s, e) =>
                {
                    page      = list.Index;
                    text.Text = pages.Values.ElementAt(page);
                    UIManager.Draw();
                };
                list.Enter += (s, e) =>
                {
                    if (list.Index == list.Items.Count - 1)                     //can't use absolute index because Debug might be missing.
                    {
                        host.Close();
                    }
                    else if (list.Index == list.Items.Count - 2)                     //same
                    {
                        //System.Diagnostics.Process.Start(host.IniPath);
                        Options.Open();
                    }
                    else if (list.Index == 4)
                    {
                        TextScroller.Plain(Mix.GetString("credits.txt"), i18n.GetString("pause_credits"), false);
                    }
                };
                text = new UILabel("...")
                {
                    Left = 30, Top = 2
                };
                UIManager.Elements.Add(list);
                UIManager.Elements.Add(text);
                list.Index          = IniFile.GetValue("misc", "rememberpause", true) ? page : 0;
                UIManager.Highlight = list;

                Subscreens.Redraw = true;
            }
            if (Subscreens.Redraw)
            {
                Subscreens.Redraw = false;
                UIManager.Draw();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.ClearKeys();
                NoxicoGame.Immediate = true;
                NoxicoGame.Me.CurrentBoard.Redraw();
                NoxicoGame.Me.CurrentBoard.Draw(true);
                NoxicoGame.Mode      = UserMode.Walkabout;
                Subscreens.FirstDraw = true;
            }
            else
            {
                UIManager.CheckKeys();
            }
        }