예제 #1
0
        /*
         * Init players with some belongings
         *
         * Having an item identifies it and makes the player "aware" of its purpose.
         */
        static void player_outfit(Player.Player p)
        {
            //Object.Object object_type_body = new Object.Object();

            /* Give the player starting equipment */
            for (Start_Item si = Player.Player.instance.Class.start_items; si != null; si = si.next)
            {
                /* Get local object */
                Object.Object i_ptr = new Object.Object();

                /* Prepare the item */
                i_ptr.prep(si.kind, 0, aspect.MINIMISE);
                i_ptr.number = (byte)Random.rand_range(si.min, si.max);
                i_ptr.origin = Origin.BIRTH;

                i_ptr.flavor_aware();
                i_ptr.notice_everything();

                i_ptr.inven_carry(p);
                si.kind.everseen = true;

                /* Deduct the cost of the item from starting cash */
                p.au -= i_ptr.value(i_ptr.number, false);
            }

            /* Sanity check */
            if (p.au < 0)
            {
                p.au = 0;
            }

            /* Now try wielding everything */
            wield_all(p);
        }
예제 #2
0
        /*
         * Equippy chars
         */
        static void display_player_equippy(int y, int x)
        {
            Player.Player p_ptr = Player.Player.instance;

            ConsoleColor a;
            char         c;

            Object.Object o_ptr;


            /* Dump equippy chars */
            for (int i = Misc.INVEN_WIELD; i < Misc.INVEN_TOTAL; ++i)
            {
                /* Object */
                o_ptr = p_ptr.inventory[i];

                /* Skip empty objects */
                if (o_ptr.kind == null)
                {
                    continue;
                }

                /* Get attr/char for display */
                a = o_ptr.object_attr();
                c = o_ptr.object_char();

                /* Dump */
                if ((Term.tile_width == 1) && (Term.tile_height == 1))
                {
                    Term.putch(x + i - Misc.INVEN_WIELD, y, a, c);
                }
            }
        }
예제 #3
0
        /*** Code ***/

        /*
         * The mousebutton code. Buttons should be created when neccessary and
         * destroyed when no longer necessary.  By default, buttons occupy the section
         * of the bottom line between the status display and the location display
         * in normal screen mode, and the bottom line after any prompt in alternate
         * screen mode.
         *
         * Individual ports may (and preferably will) handle this differently using
         * button_add_gui and button_kill_gui.
         */

        /*
         * Add a button
         */
        public static int add_text(string label, char keypress)
        {
            Player.Player p_ptr  = Player.Player.instance;
            int           length = label.Length;

            /* Check the label length */
            if (length > MAX_MOUSE_LABEL)
            {
                Utilities.bell("Label too long - button abandoned!");
                return(0);
            }

            /* Check we haven't already got a button for this keypress */
            for (int i = 0; i < button_num; i++)
            {
                if (button_mse[i].key == keypress)
                {
                    return(0);
                }
            }

            /* Make the button */
            button_length += length;
            button_mse[button_num].label = label;
            button_mse[button_num].left  = button_length - length + 1;
            button_mse[button_num].right = button_length;
            button_mse[button_num++].key = keypress;

            /* Redraw */
            p_ptr.redraw |= (Misc.PR_BUTTONS);

            /* Return the size of the button */
            return(length);
        }
예제 #4
0
        static string show_depth()
        {
            Player.Player p_ptr = Player.Player.instance;

            if (p_ptr.max_depth == 0)
            {
                return("Town");
            }

            return((p_ptr.max_depth * 50) + "' (" + p_ptr.max_depth + ")");
        }
예제 #5
0
        static string show_missile_weapon(Object.Object o_ptr)
        {
            Player.Player p_ptr = Player.Player.instance;
            int           hit   = p_ptr.state.dis_to_h;
            int           dam   = 0;

            if (o_ptr.attack_plusses_are_visible())
            {
                hit += o_ptr.to_h;
                dam += o_ptr.to_d;
            }
            return("(" + hit + "," + dam + ")");;
        }
예제 #6
0
 static string show_adv_exp()
 {
     Player.Player p_ptr = Player.Player.instance;
     if (p_ptr.lev < Misc.PY_MAX_LEVEL)
     {
         long advance = (Player.Player.player_exp[p_ptr.lev - 1] * p_ptr.expfact / 100L);
         return(advance.ToString());
     }
     else
     {
         return("********");
     }
 }
예제 #7
0
        /* ------------------------------------------------------------------------
         * Final confirmation of character.
         * ------------------------------------------------------------------------ */
        static birth_stage get_confirm_command()
        {
            Player.Player p_ptr = Player.Player.instance;

            string   prompt = "['ESC' to step back, 'S' to start over, or any other key to continue]";
            keypress ke;

            birth_stage next;

            /* Prompt for it */
            Utilities.prt(prompt, Term.instance.hgt - 1, Term.instance.wid / 2 - (prompt.Length / 2));

            /* Buttons */
            Button.button_kill_all();
            Button.button_add("[Continue]", 'q');
            Button.button_add("[ESC]", (char)keycode_t.ESCAPE);
            Button.button_add("[S]", 'S');
            p_ptr.redraw_stuff();

            /* Get a key */
            ke = Utilities.inkey();

            /* Start over */
            if (ke.code == (keycode_t)'S' || ke.code == (keycode_t)'s')
            {
                next = birth_stage.BIRTH_RESET;
            }
            else if (ke.code == (keycode_t)UIEvent.KTRL('X'))
            {
                Game_Command.insert(Command_Code.QUIT);
                next = birth_stage.BIRTH_COMPLETE;
            }
            else if (ke.code == keycode_t.ESCAPE)
            {
                next = birth_stage.BIRTH_BACK;
            }
            else
            {
                Game_Command.insert(Command_Code.ACCEPT_CHARACTER);
                next = birth_stage.BIRTH_COMPLETE;
            }

            /* Buttons */
            Button.button_kill_all();
            p_ptr.redraw_stuff();

            /* Clear prompt */
            Utilities.clear_from(23);

            return(next);
        }
예제 #8
0
        static string show_status()
        {
            Player.Player p_ptr = Player.Player.instance;
            int           sc    = p_ptr.sc;

            sc /= 10;

            switch (sc)
            {
            case 0:
            case 1:
                return("Pariah");

            case 2:
                return("Outcast");

            case 3:
            case 4:
                return("Unknown");

            case 5:
                return("Known");

            case 6:
            /* Maximum status by birth 75 = 7 */
            case 7:
                return("Liked");

            case 8:
                return("Well-liked");

            case 9:
            case 10:
                return("Respected");

            case 11:
            case 12:
                return("Role model");

            case 13:
                return("Feared");

            case 14:
            case 15:
                return("Lordly");
            }

            return(sc.ToString());

            ;
        }
예제 #9
0
        /**
         * Adjust damage according to resistance or vulnerability.
         *
         * \param type is the attack type we are checking.
         * \param dam is the unadjusted damage.
         * \param dam_aspect is the calc we want (min, avg, max, random).
         * \param resist is the degree of resistance (-1 = vuln, 3 = immune).
         */
        public static int adjust_dam(Player.Player p, GF type, int dam, aspect dam_aspect, int resist)
        {
            GF  gf_ptr = type;
            int i, denom;

            if (resist == 3)             /* immune */
            {
                return(0);
            }

            /* Hack - acid damage is halved by armour, holy orb is halved */
            if ((type == GF.ACID && minus_ac(p)) || type == GF.HOLY_ORB)
            {
                dam = (dam + 1) / 2;
            }

            if (resist == -1)             /* vulnerable */
            {
                return(dam * 4 / 3);
            }

            /* Variable resists vary the denominator, so we need to invert the logic
             * of dam_aspect. (m_bonus is unused) */
            switch (dam_aspect)
            {
            case aspect.MINIMISE:
                denom = Random.randcalc(gf_ptr.denom, 0, aspect.MAXIMISE);
                break;

            case aspect.MAXIMISE:
                denom = Random.randcalc(gf_ptr.denom, 0, aspect.MINIMISE);
                break;

            default:
                denom = Random.randcalc(gf_ptr.denom, 0, dam_aspect);
                break;
            }

            for (i = resist; i > 0; i--)
            {
                if (denom != 0)
                {
                    dam = dam * gf_ptr.num / denom;
                }
            }

            return(dam);
        }
예제 #10
0
        /*
         * Remove a button
         */
        public static int kill_text(char keypress)
        {
            Player.Player p_ptr = Player.Player.instance;

            int i, j, length;

            /* Find the button */
            for (i = 0; i < button_num; i++)
            {
                if (button_mse[i].key == keypress)
                {
                    break;
                }
            }

            /* No such button */
            if (i == button_num)
            {
                return(0);
            }

            /* Find the length */
            length         = button_mse[i].right - button_mse[i].left + 1;
            button_length -= length;

            /* Move each button up one */
            for (j = i; j < button_num - 1; j++)
            {
                button_mse[j] = button_mse[j + 1];

                /* Adjust length */
                button_mse[j].left  -= length;
                button_mse[j].right -= length;
            }

            /* Wipe the data */
            button_mse[button_num].label = "";
            button_mse[button_num].left  = 0;
            button_mse[button_num].right = 0;
            button_mse[button_num--].key = (char)0;

            /* Redraw */
            p_ptr.redraw |= (Misc.PR_BUTTONS);
            p_ptr.redraw_stuff();

            /* Return the size of the button */
            return(length);
        }
예제 #11
0
        /**
         * Check for resistance to a GF_ attack type. Return codes:
         * -1 = vulnerability
         * 0 = no resistance (or resistance plus vulnerability)
         * 1 = single resistance or opposition (or double resist plus vulnerability)
         * 2 = double resistance (including opposition)
         * 3 = total immunity
         *
         * \param type is the attack type we are trying to resist
         * \param flags is the set of flags we're checking
         * \param real is whether this is a real attack
         */
        public static int check_for_resist(Player.Player p, GF type, Bitflag flags, bool real)
        {
            //GF gf_ptr = &gf_table[type];
            GF gf_ptr = type;

            int result = 0;

            if (gf_ptr.vuln != Object.Object_Flag.NONE && flags.has(gf_ptr.vuln.value))
            {
                result--;
            }

            /* If it's not a real attack, we don't check timed status explicitly */
            if (real && (int)gf_ptr.opp != 0 && p.timed[(int)gf_ptr.opp] != 0)
            {
                result++;
            }

            if (gf_ptr.resist != Object.Object_Flag.NONE && flags.has(gf_ptr.resist.value))
            {
                result++;
            }

            if (gf_ptr.immunity != Object.Object_Flag.NONE && flags.has(gf_ptr.immunity.value))
            {
                result = 3;
            }

            /* Notice flags, if it's a real attack */
            if (real && gf_ptr.immunity.value != 0)
            {
                Object.Object.wieldeds_notice_flag(p, gf_ptr.immunity.value);
            }
            if (real && gf_ptr.resist.value != 0)
            {
                Object.Object.wieldeds_notice_flag(p, gf_ptr.resist.value);
            }
            if (real && gf_ptr.vuln.value != 0)
            {
                Object.Object.wieldeds_notice_flag(p, gf_ptr.vuln.value);
            }

            return(result);
        }
예제 #12
0
        static string show_speed()
        {
            Player.Player p_ptr = Player.Player.instance;
            int           tmp   = p_ptr.state.speed;

            if (p_ptr.timed[(int)Timed_Effect.FAST] > 0)
            {
                tmp -= 10;
            }
            if (p_ptr.timed[(int)Timed_Effect.SLOW] > 0)
            {
                tmp += 10;
            }
            if (p_ptr.searching != 0)
            {
                tmp += 10;
            }
            if (tmp == 110)
            {
                return("Normal");
            }
            return("" + (tmp - 110));
        }
예제 #13
0
        /**
         * Try to wield everything wieldable in the inventory.
         */
        static void wield_all(Player.Player p)
        {
            Object.Object o_ptr;
            Object.Object i_ptr;
            //Object.Object object_type_body;

            int slot;
            int item;
            int num;
            bool is_ammo;

            /* Scan through the slots backwards */
            for (item = Misc.INVEN_PACK - 1; item >= 0; item--)
            {
                o_ptr = p.inventory[item];
                is_ammo = o_ptr.is_ammo();

                /* Skip non-objects */
                if (o_ptr.kind == null) continue;

                /* Make sure we can wield it */
                slot = o_ptr.wield_slot();
                if (slot < Misc.INVEN_WIELD) continue;

                i_ptr = p.inventory[slot];
                if (i_ptr.kind != null && (!is_ammo ||(is_ammo && !o_ptr.similar(i_ptr, Object.Object.object_stack_t.OSTACK_PACK))))
                    continue;

                /* Figure out how much of the item we'll be wielding */
                num = is_ammo ? o_ptr.number : 1;

                /* Get local object */
                i_ptr = new Object.Object();
                i_ptr = o_ptr.copy();
                //This entire bit was uber shadey... Rewrote above
                ////i_ptr = object_type_body;
                //p.inventory[slot] = o_ptr; //object_copy(i_ptr, o_ptr); //This might not work...
                //i_ptr = o_ptr;  //If wonky equips happen, check here

                /* Modify quantity */
                i_ptr.number = (byte)num;

                /* Decrease the item (from the pack) */
                Object.Object.inven_item_increase(item, -num);
                Object.Object.inven_item_optimize(item);

                /* Get the wield slot */
                //o_ptr = p.inventory[slot];

                /* Wear the new stuff */
                //object_copy(o_ptr, i_ptr);
                p.inventory[slot] = i_ptr;

                /* Increase the weight */
                p.total_weight += i_ptr.weight * i_ptr.number;

                /* Increment the equip counter by hand */
                p.equip_cnt++;
            }

            Object.Object.save_quiver_size(p);

            return;
        }
예제 #14
0
        /*
         * Init players with some belongings
         *
         * Having an item identifies it and makes the player "aware" of its purpose.
         */
        static void player_outfit(Player.Player p)
        {
            //Object.Object object_type_body = new Object.Object();

            /* Give the player starting equipment */
            for (Start_Item si = Player.Player.instance.Class.start_items; si != null; si = si.next)
            {
                /* Get local object */
                Object.Object i_ptr = new Object.Object();

                /* Prepare the item */
                i_ptr.prep(si.kind, 0, aspect.MINIMISE);
                i_ptr.number = (byte)Random.rand_range(si.min, si.max);
                i_ptr.origin = Origin.BIRTH;

                i_ptr.flavor_aware();
                i_ptr.notice_everything();

                i_ptr.inven_carry(p);
                si.kind.everseen = true;

                /* Deduct the cost of the item from starting cash */
                p.au -= i_ptr.value(i_ptr.number, false);
            }

            /* Sanity check */
            if (p.au < 0)
                p.au = 0;

            /* Now try wielding everything */
            wield_all(p);
        }
예제 #15
0
파일: Cave.cs 프로젝트: jobjingjo/csangband
 public static void health_track(Player.Player p, int m_idx)
 {
     p.health_who = (short)m_idx;
     p.redraw |= Misc.PR_HEALTH;
 }
예제 #16
0
파일: Cave.cs 프로젝트: jobjingjo/csangband
        /*
         * Something has happened to disturb the player.
         *
         * The first arg indicates a major disturbance, which affects search.
         *
         * The second arg is currently unused, but could induce output flush.
         *
         * All disturbance cancels repeated commands, resting, and running.
         */
        public static void disturb(Player.Player p, int stop_search, int unused_flag)
        {
            /* Unused parameter */
            //(void)unused_flag;

            /* Cancel repeated commands */
            Game_Command.cancel_repeat();

            /* Cancel Resting */
            if (p.resting != 0) {
                p.resting = 0;
                p.redraw |= Misc.PR_STATE;
            }

            /* Cancel running */
            if (p.running != 0) {
                Misc.p_ptr.running = 0;

                /* Check for new panel if appropriate */
                if (Option.center_player.value) Xtra2.verify_panel();
                p.update |= Misc.PU_TORCH;
            }

            /* Cancel searching if requested */
            if (stop_search != 0 && p.searching != 0)
            {
                p.searching = 0; //false
                p.update |= Misc.PU_BONUS;
                p.redraw |= Misc.PR_STATE;
            }

            /* Flush input */
            Utilities.flush();
        }
예제 #17
0
        /**
         * Try to wield everything wieldable in the inventory.
         */
        static void wield_all(Player.Player p)
        {
            Object.Object o_ptr;
            Object.Object i_ptr;
            //Object.Object object_type_body;

            int  slot;
            int  item;
            int  num;
            bool is_ammo;

            /* Scan through the slots backwards */
            for (item = Misc.INVEN_PACK - 1; item >= 0; item--)
            {
                o_ptr   = p.inventory[item];
                is_ammo = o_ptr.is_ammo();

                /* Skip non-objects */
                if (o_ptr.kind == null)
                {
                    continue;
                }

                /* Make sure we can wield it */
                slot = o_ptr.wield_slot();
                if (slot < Misc.INVEN_WIELD)
                {
                    continue;
                }

                i_ptr = p.inventory[slot];
                if (i_ptr.kind != null && (!is_ammo || (is_ammo && !o_ptr.similar(i_ptr, Object.Object.object_stack_t.OSTACK_PACK))))
                {
                    continue;
                }

                /* Figure out how much of the item we'll be wielding */
                num = is_ammo ? o_ptr.number : 1;

                /* Get local object */
                i_ptr = new Object.Object();
                i_ptr = o_ptr.copy();
                //This entire bit was uber shadey... Rewrote above
                ////i_ptr = object_type_body;
                //p.inventory[slot] = o_ptr; //object_copy(i_ptr, o_ptr); //This might not work...
                //i_ptr = o_ptr;  //If wonky equips happen, check here

                /* Modify quantity */
                i_ptr.number = (byte)num;

                /* Decrease the item (from the pack) */
                Object.Object.inven_item_increase(item, -num);
                Object.Object.inven_item_optimize(item);

                /* Get the wield slot */
                //o_ptr = p.inventory[slot];

                /* Wear the new stuff */
                //object_copy(o_ptr, i_ptr);
                p.inventory[slot] = i_ptr;

                /* Increase the weight */
                p.total_weight += i_ptr.weight * i_ptr.number;

                /* Increment the equip counter by hand */
                p.equip_cnt++;
            }

            Object.Object.save_quiver_size(p);

            return;
        }
예제 #18
0
        //size = panel.Length
        static int get_panel(int oid, ref Data_Panel[] panel)
        {
            int        size = panel.Length;
            int        ret  = panel.Length;
            Type_Union END  = new Type_Union();

            Player.Player p_ptr  = Player.Player.instance;
            Player_Other  op_ptr = Player_Other.instance;

            switch (oid)
            {
            case 1: {
                int i = 0;
                Misc.assert(size >= (uint)boundaries[1].page_rows);
                ret = boundaries[1].page_rows;
                P_I(ConsoleColor.Cyan, "Name", "{0}", new Type_Union(op_ptr.full_name), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Sex", "{0}", new Type_Union(p_ptr.Sex.Title), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Race", "{0}", new Type_Union(p_ptr.Race.Name), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Class", "{0}", new Type_Union(p_ptr.Class.Name), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Title", "{0}", new Type_Union(show_title()), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "HP", "{0}/{1}", new Type_Union(p_ptr.chp), new Type_Union(p_ptr.mhp), panel, ref i);
                P_I(ConsoleColor.Cyan, "SP", "{0}/{1}", new Type_Union(p_ptr.csp), new Type_Union(p_ptr.msp), panel, ref i);
                P_I(ConsoleColor.Cyan, "Level", "{0}", new Type_Union(p_ptr.lev), END, panel, ref i);
                Misc.assert(i == boundaries[1].page_rows);
                return(ret);
            }

            case 2: {
                int i = 0;
                Misc.assert(ret >= boundaries[2].page_rows);
                ret = boundaries[2].page_rows;
                P_I(max_color(p_ptr.lev, p_ptr.max_lev), "Level", "{0}", new Type_Union(p_ptr.lev), END, panel, ref i);
                P_I(max_color(p_ptr.exp, p_ptr.max_exp), "Cur Exp", "{0}", new Type_Union(p_ptr.exp), END, panel, ref i);
                P_I(ConsoleColor.Green, "Max Exp", "{0}", new Type_Union(p_ptr.max_exp), END, panel, ref i);
                P_I(ConsoleColor.Green, "Adv Exp", "{0}", new Type_Union(show_adv_exp()), END, panel, ref i);
                P_I(ConsoleColor.Green, "MaxDepth", "{0}", new Type_Union(show_depth()), END, panel, ref i);
                P_I(ConsoleColor.Green, "Game Turns", "{0}", new Type_Union(Misc.turn), END, panel, ref i);
                P_I(ConsoleColor.Green, "Standard Turns", "{0}", new Type_Union((int)(p_ptr.total_energy / 100)), END, panel, ref i);
                P_I(ConsoleColor.Green, "Resting Turns", "{0}", new Type_Union((int)(p_ptr.resting_turn)), END, panel, ref i);
                P_I(ConsoleColor.Green, "Gold", "{0}", new Type_Union(p_ptr.au), END, panel, ref i);
                Misc.assert(i == boundaries[2].page_rows);
                return(ret);
            }

            case 3: {
                int i = 0;
                Misc.assert(ret >= boundaries[3].page_rows);
                ret = boundaries[3].page_rows;
                P_I(ConsoleColor.Cyan, "Armor", "[{0},%+y]", new Type_Union(p_ptr.state.dis_ac),
                    new Type_Union(p_ptr.state.dis_to_a), panel, ref i);
                P_I(ConsoleColor.Cyan, "Fight", "(%+y,%+y)", new Type_Union(p_ptr.state.dis_to_h),
                    new Type_Union(p_ptr.state.dis_to_d), panel, ref i);
                P_I(ConsoleColor.Cyan, "Melee", "{0}", new Type_Union(show_melee_weapon(p_ptr.inventory[Misc.INVEN_WIELD])), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Shoot", "{0}", new Type_Union(show_missile_weapon(p_ptr.inventory[Misc.INVEN_BOW])), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Blows", "{0}.%y/turn", new Type_Union(p_ptr.state.num_blows / 100),
                    new Type_Union((p_ptr.state.num_blows / 10) % 10), panel, ref i);
                P_I(ConsoleColor.Cyan, "Shots", "{0}/turn", new Type_Union(p_ptr.state.num_shots), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Infra", "{0} ft", new Type_Union(p_ptr.state.see_infra * 10), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Speed", "{0}", new Type_Union(show_speed()), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Burden", "%.1y lbs", new Type_Union(p_ptr.total_weight / 10.0f), END, panel, ref i);
                Misc.assert(i == boundaries[3].page_rows);
                return(ret);
            }

            case 4: {
                temp_skills[] skills =
                {
                    new temp_skills("Saving Throw", Skill.SAVE,              6),
                    new temp_skills("Stealth",      Skill.STEALTH,           1),
                    new temp_skills("Fighting",     Skill.TO_HIT_MELEE,     12),
                    new temp_skills("Shooting",     Skill.TO_HIT_BOW,       12),
                    new temp_skills("Disarming",    Skill.DISARM,            8),
                    new temp_skills("Magic Device", Skill.DEVICE,            6),
                    new temp_skills("Perception",   Skill.SEARCH_FREQUENCY,  6),
                    new temp_skills("Searching",    Skill.SEARCH, 6)
                };
                int i;
                Misc.assert(skills.Length == boundaries[4].page_rows);
                ret = skills.Length;
                if (ret > size)
                {
                    ret = size;
                }
                for (i = 0; i < ret; i++)
                {
                    short skill = p_ptr.state.skills[(int)skills[i].skill];
                    panel[i].color = ConsoleColor.Cyan;
                    panel[i].label = skills[i].name;
                    if (skills[i].skill == Skill.SAVE || skills[i].skill == Skill.SEARCH)
                    {
                        if (skill < 0)
                        {
                            skill = 0;
                        }
                        if (skill > 100)
                        {
                            skill = 100;
                        }
                        panel[i].fmt      = "{0}%";
                        panel[i].value[0] = new Type_Union(skill);
                        panel[i].color    = colour_table[skill / 10];
                    }
                    else if (skills[i].skill == Skill.DEVICE)
                    {
                        panel[i].fmt      = "{0}";
                        panel[i].value[0] = new Type_Union(skill);
                        panel[i].color    = colour_table[skill / 13];
                    }
                    else if (skills[i].skill == Skill.SEARCH_FREQUENCY)
                    {
                        if (skill <= 0)
                        {
                            skill = 1;
                        }
                        if (skill >= 50)
                        {
                            panel[i].fmt   = "1 in 1";
                            panel[i].color = colour_table[10];
                        }
                        else
                        {
                            /* convert to % chance of searching */
                            skill             = (short)(50 - skill);
                            panel[i].fmt      = "1 in {0}";
                            panel[i].value[0] = new Type_Union(skill);
                            panel[i].color    = colour_table[(100 - skill * 2) / 10];
                        }
                    }
                    else if (skills[i].skill == Skill.DISARM)
                    {
                        /* assume disarming a dungeon trap */
                        skill -= 5;
                        if (skill > 100)
                        {
                            skill = 100;
                        }
                        if (skill < 2)
                        {
                            skill = 2;
                        }
                        panel[i].fmt      = "{0}%";
                        panel[i].value[0] = new Type_Union(skill);
                        panel[i].color    = colour_table[skill / 10];
                    }
                    else
                    {
                        panel[i].fmt = "{0}";
                        //last argument for likert was "panel[i].color"...
                        ConsoleColor c = ConsoleColor.DarkMagenta;                                         //Random color...
                        panel[i].value[0] = new Type_Union(likert(skill, skills[i].div, ref c));
                    }
                }
                return(ret);
            }

            case 5: {
                int i = 0;
                Misc.assert(ret >= boundaries[5].page_rows);
                ret = boundaries[5].page_rows;
                P_I(ConsoleColor.Cyan, "Age", "{0}", new Type_Union(p_ptr.age), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Height", "{0}", new Type_Union(p_ptr.ht), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Weight", "{0}", new Type_Union(p_ptr.wt), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Social", "{0}", new Type_Union(show_status()), END, panel, ref i);
                P_I(ConsoleColor.Cyan, "Maximize", "{0}", new Type_Union(Option.birth_maximize.value ? 'Y' : 'N'), END, panel, ref i);
                //#if 0
                //    /* Preserve mode deleted */
                //    P_I(ConsoleColor.Cyan, "Preserve",	"{0}",	c2u(birth_preserve ? 'Y' : 'N'), END);
                //#endif
                Misc.assert(i == boundaries[5].page_rows);
                return(ret);
            }
            }
            /* hopefully not reached */
            return(0);
        }
예제 #19
0
 /*
  * Add an entry with text `event` to the history list, with type `type`
  * ("HISTORY_xxx" in defines.h), and artifact number `id` (0 for everything
  * else).
  *
  * Returne true on success.
  */
 public static bool add(string evt, ushort type, Artifact artifact)
 {
     Player.Player p_ptr = Player.Player.instance;
     return(add_full(type, artifact, p_ptr.depth, p_ptr.lev, Misc.turn, evt));
 }
예제 #20
0
        /*
         * Special display, part 2b
         */
        public static void display_player_stat_info()
        {
            /* Row */
            int row = 2;

            /* Column */
            int col = 42;

            /* Player Pointer */
            Player.Player p_ptr = Player.Player.instance;

            /* Print out the labels for the columns */
            Utilities.c_put_str(ConsoleColor.White, "  Self", row - 1, col + 5);
            Utilities.c_put_str(ConsoleColor.White, " RB", row - 1, col + 12);
            Utilities.c_put_str(ConsoleColor.White, " CB", row - 1, col + 16);
            Utilities.c_put_str(ConsoleColor.White, " EB", row - 1, col + 20);
            Utilities.c_put_str(ConsoleColor.White, "  Best", row - 1, col + 24);

            /* Display the stats */
            for (int i = 0; i < (int)Stat.Max; i++)
            {
                /* Reduced */
                if (p_ptr.stat_cur[i] < p_ptr.stat_max[i])
                {
                    /* Use lowercase stat name */
                    Utilities.put_str(Stat_Names.Reduced[i], row + i, col);
                }

                /* Normal */
                else
                {
                    /* Assume uppercase stat name */
                    Utilities.put_str(Stat_Names.Normal[i], row + i, col);
                }

                /* Indicate natural maximum */
                if (p_ptr.stat_max[i] == 18 + 100)
                {
                    Utilities.put_str("!", row + i, col + 3);
                }

                string buf;

                /* Internal "natural" maximum value */
                cnv_stat(p_ptr.stat_max[i], out buf);
                Utilities.c_put_str(ConsoleColor.Green, buf, row + i, col + 5);

                /* Race Bonus */
                buf = p_ptr.Race.r_adj[i].ToString().PadLeft(3, ' ');
                Utilities.c_put_str(ConsoleColor.Cyan, buf, row + i, col + 12);

                /* Class Bonus */
                buf = p_ptr.Class.c_adj[i].ToString().PadLeft(3, ' ');
                Utilities.c_put_str(ConsoleColor.Cyan, buf, row + i, col + 16);

                /* Equipment Bonus */
                buf = p_ptr.state.stat_add[i].ToString().PadLeft(3, ' ');
                Utilities.c_put_str(ConsoleColor.Cyan, buf, row + i, col + 20);

                /* Resulting "modified" maximum value */
                cnv_stat(p_ptr.state.stat_top[i], out buf);
                Utilities.c_put_str(ConsoleColor.Green, buf, row + i, col + 24);

                /* Only display stat_use if there has been draining */
                if (p_ptr.stat_cur[i] < p_ptr.stat_max[i])
                {
                    cnv_stat(p_ptr.state.stat_use[i], out buf);
                    Utilities.c_put_str(ConsoleColor.Yellow, buf, row + i, col + 31);
                }
            }
        }
예제 #21
0
        /*
         * Set "p_ptr.timed[TMD_CUT]", notice observable changes
         *
         * Note the special code to only notice "range" changes.
         */
        static bool set_cut(Player p, int v)
        {
            throw new NotImplementedException();
            //int old_aux, new_aux;

            //bool notice = false;

            ///* Hack -- Force good values */
            //v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;

            ///* Mortal wound */
            //if (p.timed[TMD_CUT] > 1000)
            //{
            //    old_aux = 7;
            //}

            ///* Deep gash */
            //else if (p.timed[TMD_CUT] > 200)
            //{
            //    old_aux = 6;
            //}

            ///* Severe cut */
            //else if (p.timed[TMD_CUT] > 100)
            //{
            //    old_aux = 5;
            //}

            ///* Nasty cut */
            //else if (p.timed[TMD_CUT] > 50)
            //{
            //    old_aux = 4;
            //}

            ///* Bad cut */
            //else if (p.timed[TMD_CUT] > 25)
            //{
            //    old_aux = 3;
            //}

            ///* Light cut */
            //else if (p.timed[TMD_CUT] > 10)
            //{
            //    old_aux = 2;
            //}

            ///* Graze */
            //else if (p.timed[TMD_CUT] > 0)
            //{
            //    old_aux = 1;
            //}

            ///* None */
            //else
            //{
            //    old_aux = 0;
            //}

            ///* Mortal wound */
            //if (v > 1000)
            //{
            //    new_aux = 7;
            //}

            ///* Deep gash */
            //else if (v > 200)
            //{
            //    new_aux = 6;
            //}

            ///* Severe cut */
            //else if (v > 100)
            //{
            //    new_aux = 5;
            //}

            ///* Nasty cut */
            //else if (v > 50)
            //{
            //    new_aux = 4;
            //}

            ///* Bad cut */
            //else if (v > 25)
            //{
            //    new_aux = 3;
            //}

            ///* Light cut */
            //else if (v > 10)
            //{
            //    new_aux = 2;
            //}

            ///* Graze */
            //else if (v > 0)
            //{
            //    new_aux = 1;
            //}

            ///* None */
            //else
            //{
            //    new_aux = 0;
            //}

            ///* Increase cut */
            //if (new_aux > old_aux)
            //{
            //    /* Describe the state */
            //    switch (new_aux)
            //    {
            //        /* Graze */
            //        case 1:
            //        {
            //            msgt(MSG_CUT, "You have been given a graze.");
            //            break;
            //        }

            //        /* Light cut */
            //        case 2:
            //        {
            //            msgt(MSG_CUT, "You have been given a light cut.");
            //            break;
            //        }

            //        /* Bad cut */
            //        case 3:
            //        {
            //            msgt(MSG_CUT, "You have been given a bad cut.");
            //            break;
            //        }

            //        /* Nasty cut */
            //        case 4:
            //        {
            //            msgt(MSG_CUT, "You have been given a nasty cut.");
            //            break;
            //        }

            //        /* Severe cut */
            //        case 5:
            //        {
            //            msgt(MSG_CUT, "You have been given a severe cut.");
            //            break;
            //        }

            //        /* Deep gash */
            //        case 6:
            //        {
            //            msgt(MSG_CUT, "You have been given a deep gash.");
            //            break;
            //        }

            //        /* Mortal wound */
            //        case 7:
            //        {
            //            msgt(MSG_CUT, "You have been given a mortal wound.");
            //            break;
            //        }
            //    }

            //    /* Notice */
            //    notice = true;
            //}

            ///* Decrease cut */
            //else if (new_aux < old_aux)
            //{
            //    /* Describe the state */
            //    switch (new_aux)
            //    {
            //        /* None */
            //        case 0:
            //        {
            //            msgt(MSG_RECOVER, "You are no longer bleeding.");
            //            if (OPT(disturb_state)) disturb(p_ptr, 0, 0);
            //            break;
            //        }
            //    }

            //    /* Notice */
            //    notice = true;
            //}

            ///* Use the value */
            //p.timed[TMD_CUT] = v;

            ///* No change */
            //if (!notice) return (false);

            ///* Disturb */
            //if (OPT(disturb_state)) disturb(p_ptr, 0, 0);

            ///* Recalculate bonuses */
            //p.update |= (PU_BONUS);

            ///* Redraw the "cut" */
            //p.redraw |= (PR_STATUS);

            ///* Handle stuff */
            //handle_stuff(p_ptr);

            ///* Result */
            //return (true);
        }
예제 #22
0
        /*
         * Decreases players hit points and sets death flag if necessary
         *
         * Invulnerability needs to be changed into a "shield" XXX XXX XXX
         *
         * Hack -- this function allows the user to save (or quit) the game
         * when he dies, since the "You die." message is shown before setting
         * the player to "dead".
         */
        public static void take_hit(Player.Player p, int dam, string kb_str)
        {
            int old_chp = p.chp;

            int warning = (p.mhp * Player.Player_Other.instance.hitpoint_warn / 10);


            /* Paranoia */
            if (p.is_dead)
            {
                return;
            }


            /* Disturb */
            Cave.disturb(p, 1, 0);

            /* Mega-Hack -- Apply "invulnerability" */
            if (p.timed[(int)Timed_Effect.INVULN] != 0 && (dam < 9000))
            {
                return;
            }

            /* Hurt the player */
            p.chp -= (short)dam;

            /* Display the hitpoints */
            p.redraw |= (Misc.PR_HP);

            /* Dead player */
            if (p.chp < 0)
            {
                /* Hack -- Note death */
                Utilities.msgt(Message_Type.MSG_DEATH, "You die.");
                Utilities.message_flush();

                /* Note cause of death */
                p.died_from = kb_str;

                /* No longer a winner */
                p.total_winner = 0;

                /* Note death */
                p.is_dead = true;

                /* Leaving */
                p.leaving = true;

                /* Dead */
                return;
            }

            /* Hitpoint warning */
            if (p.chp < warning)
            {
                /* Hack -- bell on first notice */
                if (old_chp > warning)
                {
                    Utilities.bell("Low hitpoint warning!");
                }

                /* Message */
                Utilities.msgt(Message_Type.MSG_HITPOINT_WARN, "*** LOW HITPOINT WARNING! ***");
                Utilities.message_flush();
            }
        }
예제 #23
0
        /*
         * Acid has hit the player, attempt to affect some armor.
         *
         * Note that the "base armor" of an object never changes.
         *
         * If any armor is damaged (or resists), the player takes less damage.
         */
        static bool minus_ac(Player.Player p)
        {
            Object.Object o_ptr = null;

            Bitflag f = new Bitflag(Object.Object_Flag.SIZE);

            //char o_name[80];
            string o_name;

            /* Avoid crash during monster power calculations */
            if (p.inventory == null)
            {
                return(false);
            }

            /* Pick a (possibly empty) inventory slot */
            switch (Random.randint1(6))
            {
            case 1: o_ptr = p.inventory[Misc.INVEN_BODY]; break;

            case 2: o_ptr = p.inventory[Misc.INVEN_ARM]; break;

            case 3: o_ptr = p.inventory[Misc.INVEN_OUTER]; break;

            case 4: o_ptr = p.inventory[Misc.INVEN_HANDS]; break;

            case 5: o_ptr = p.inventory[Misc.INVEN_HEAD]; break;

            case 6: o_ptr = p.inventory[Misc.INVEN_FEET]; break;
                //default: Misc.assert(0); //Nick: DA FUQ is this doing here C???
            }

            /* Nothing to damage */
            if (o_ptr.kind == null)
            {
                return(false);
            }

            /* No damage left to be done */
            if (o_ptr.ac + o_ptr.to_a <= 0)
            {
                return(false);
            }

            /* Describe */
            o_name = o_ptr.object_desc(Object.Object.Detail.BASE);
            //object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE);

            /* Extract the flags */
            o_ptr.object_flags(ref f);

            /* Object resists */
            if (f.has(Object.Object_Flag.IGNORE_ACID.value))
            {
                Utilities.msg("Your %s is unaffected!", o_name);

                return(true);
            }

            /* Message */
            Utilities.msg("Your %s is damaged!", o_name);

            /* Damage the item */
            o_ptr.to_a--;

            p.update |= Misc.PU_BONUS;
            p.redraw |= (Misc.PR_EQUIP);

            /* Item was damaged */
            return(true);
        }
예제 #24
0
        /*
         * Special display, part 2c
         *
         * How to print out the modifications and sustains.
         * Positive mods with no sustain will be light green.
         * Positive mods with a sustain will be dark green.
         * Sustains (with no modification) will be a dark green 's'.
         * Negative mods (from a curse) will be red.
         * Huge mods (>9), like from MICoMorgoth, will be a '*'
         * No mod, no sustain, will be a slate '.'
         */
        static void display_player_sust_info()
        {
            int j, stat;

            Player.Player p_ptr = Player.Player.instance;

            Bitflag f = new Bitflag(Object_Flag.SIZE);

            Object_Flag[] stat_flags    = new Object_Flag[(int)Stat.Max];
            Object_Flag[] sustain_flags = new Object_Flag[(int)Stat.Max];

            ConsoleColor a;
            char         c;


            /* Row */
            int row = 2;

            /* Column */
            int col = 26;

            /* Build the stat flags tables */
            stat_flags[(int)Stat.Str]    = Object_Flag.STR;
            stat_flags[(int)Stat.Int]    = Object_Flag.INT;
            stat_flags[(int)Stat.Wis]    = Object_Flag.WIS;
            stat_flags[(int)Stat.Dex]    = Object_Flag.DEX;
            stat_flags[(int)Stat.Con]    = Object_Flag.CON;
            stat_flags[(int)Stat.Chr]    = Object_Flag.CHR;
            sustain_flags[(int)Stat.Str] = Object_Flag.SUST_STR;
            sustain_flags[(int)Stat.Int] = Object_Flag.SUST_INT;
            sustain_flags[(int)Stat.Wis] = Object_Flag.SUST_WIS;
            sustain_flags[(int)Stat.Dex] = Object_Flag.SUST_DEX;
            sustain_flags[(int)Stat.Con] = Object_Flag.SUST_CON;
            sustain_flags[(int)Stat.Chr] = Object_Flag.SUST_CHR;

            /* Header */
            Utilities.c_put_str(ConsoleColor.White, "abcdefghijkl@", row - 1, col);

            /* Process equipment */
            for (int i = Misc.INVEN_WIELD; i < Misc.INVEN_TOTAL; ++i)
            {
                /* Get the object */
                Object.Object o_ptr = p_ptr.inventory[i];

                if (o_ptr.kind == null)
                {
                    col++;
                    continue;
                }

                /* Get the "known" flags */
                o_ptr.object_flags_known(ref f);

                /* Initialize color based of sign of pval. */
                for (stat = 0; stat < (int)Stat.Max; stat++)
                {
                    /* Default */
                    a = ConsoleColor.Gray;
                    c = '.';

                    /* Boost */
                    if (f.has(stat_flags[stat].value))
                    {
                        /* Default */
                        c = '*';

                        /* Work out which pval we're talking about */
                        j = o_ptr.which_pval(stat_flags[stat].value);

                        /* Good */
                        if (o_ptr.pval[j] > 0)
                        {
                            /* Good */
                            a = ConsoleColor.Green;

                            /* Label boost */
                            if (o_ptr.pval[j] < 10)
                            {
                                c = (char)Basic.I2D((char)o_ptr.pval[j]);
                            }
                        }

                        /* Bad */
                        if (o_ptr.pval[j] < 0)
                        {
                            /* Bad */
                            a = ConsoleColor.Red;

                            /* Label boost */
                            if (o_ptr.pval[j] > -10)
                            {
                                c = (char)Basic.I2D((char)-(o_ptr.pval[j]));
                            }
                        }
                    }

                    /* Sustain */
                    if (f.has(sustain_flags[stat].value))
                    {
                        /* Dark green */
                        a = ConsoleColor.DarkGreen;

                        /* Convert '.' to 's' */
                        if (c == '.')
                        {
                            c = 's';
                        }
                    }

                    if ((c == '.') && o_ptr.kind != null && !o_ptr.object_flag_is_known(sustain_flags[stat].value))
                    {
                        c = '?';
                    }

                    /* Dump proper character */
                    Term.putch(col, row + stat, a, c);
                }

                /* Advance */
                col++;
            }

            /* Player flags */
            Player.Player.player_flags(ref f);

            /* Check stats */
            for (stat = 0; stat < (int)Stat.Max; ++stat)
            {
                /* Default */
                a = ConsoleColor.Gray;
                c = '.';

                /* Sustain */
                if (f.has(sustain_flags[stat].value))
                {
                    /* Dark green "s" */
                    a = ConsoleColor.DarkGreen;
                    c = 's';
                }

                /* Dump */
                Term.putch(col, row + stat, a, c);
            }

            /* Column */
            col = 26;

            /* Footer */
            Utilities.c_put_str(ConsoleColor.White, "abcdefghijkl@", row + 6, col);

            /* Equippy */
            display_player_equippy(row + 7, col);
        }
예제 #25
0
        /*
         * The "stun" and "cut" statuses need to be handled by special functions of
         * their own, as they are more complex than the ones handled by the generic
         * code.
         */
        /*
         * Set "p_ptr.timed[TMD_STUN]", notice observable changes
         *
         * Note the special code to only notice "range" changes.
         */
        static bool set_stun(Player p, int v)
        {
            throw new NotImplementedException();
            //int old_aux, new_aux;

            //bool notice = false;

            ///* Hack -- Force good values */
            //v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;

            ///* Knocked out */
            //if (p.timed[TMD_STUN] > 100)
            //{
            //    old_aux = 3;
            //}

            ///* Heavy stun */
            //else if (p.timed[TMD_STUN] > 50)
            //{
            //    old_aux = 2;
            //}

            ///* Stun */
            //else if (p.timed[TMD_STUN] > 0)
            //{
            //    old_aux = 1;
            //}

            ///* None */
            //else
            //{
            //    old_aux = 0;
            //}

            ///* Knocked out */
            //if (v > 100)
            //{
            //    new_aux = 3;
            //}

            ///* Heavy stun */
            //else if (v > 50)
            //{
            //    new_aux = 2;
            //}

            ///* Stun */
            //else if (v > 0)
            //{
            //    new_aux = 1;
            //}

            ///* None */
            //else
            //{
            //    new_aux = 0;
            //}

            ///* Increase cut */
            //if (new_aux > old_aux)
            //{
            //    /* Describe the state */
            //    switch (new_aux)
            //    {
            //        /* Stun */
            //        case 1:
            //        {
            //            msgt(MSG_STUN, "You have been stunned.");
            //            break;
            //        }

            //        /* Heavy stun */
            //        case 2:
            //        {
            //            msgt(MSG_STUN, "You have been heavily stunned.");
            //            break;
            //        }

            //        /* Knocked out */
            //        case 3:
            //        {
            //            msgt(MSG_STUN, "You have been knocked out.");
            //            break;
            //        }
            //    }

            //    /* Notice */
            //    notice = true;
            //}

            ///* Decrease cut */
            //else if (new_aux < old_aux)
            //{
            //    /* Describe the state */
            //    switch (new_aux)
            //    {
            //        /* None */
            //        case 0:
            //        {
            //            msgt(MSG_RECOVER, "You are no longer stunned.");
            //            if (OPT(disturb_state)) disturb(p_ptr, 0, 0);
            //            break;
            //        }
            //    }

            //    /* Notice */
            //    notice = true;
            //}

            ///* Use the value */
            //p.timed[TMD_STUN] = v;

            ///* No change */
            //if (!notice) return (false);

            ///* Disturb */
            //if (OPT(disturb_state)) disturb(p_ptr, 0, 0);

            ///* Recalculate bonuses */
            //p.update |= (PU_BONUS);

            ///* Redraw the "stun" */
            //p.redraw |= (PR_STATUS);

            ///* Handle stuff */
            //handle_stuff(p_ptr);

            ///* Result */
            //return (true);
        }
예제 #26
0
        static void display_resistance_panel(player_flag_record[] resists, int size, Region bounds)
        {
            Player.Player p_ptr = Player.Player.instance;
            int           col   = bounds.col;
            int           row   = bounds.row;

            Term.putstr(col, row++, RES_COLS, ConsoleColor.White, "      abcdefghijkl@");
            for (int i = 0; i < size - 3; i++, row++)
            {
                ConsoleColor name_attr = ConsoleColor.White;
                Term.gotoxy(col + 6, row);
                /* repeated extraction of flags is inefficient but more natural */
                for (int j = Misc.INVEN_WIELD; j <= Misc.INVEN_TOTAL; j++)
                {
                    Object.Object o_ptr = p_ptr.inventory[j];
                    Bitflag       f     = new Bitflag(Object_Flag.SIZE);

                    ConsoleColor[] alternatingcols = new ConsoleColor[] { ConsoleColor.Gray, ConsoleColor.DarkGray };
                    ConsoleColor   attr            = alternatingcols[j % 2];        /* alternating columns */
                    char           sym             = '.';

                    bool res, imm, vuln;

                    /* Wipe flagset */
                    f.wipe();

                    if (j < Misc.INVEN_TOTAL && o_ptr.kind != null)
                    {
                        o_ptr.object_flags_known(ref f);
                    }
                    else if (j == Misc.INVEN_TOTAL)
                    {
                        Player.Player.player_flags(ref f);

                        /* If the race has innate infravision/digging, force the corresponding flag
                         * here.  If we set it in player_flags(), then all callers of that
                         * function will think the infravision is caused by equipment. */
                        if (p_ptr.Race.infra > 0)
                        {
                            f.on(Object_Flag.INFRA.value);
                        }
                        if (p_ptr.Race.r_skills[(int)Skill.DIGGING] > 0)
                        {
                            f.on(Object_Flag.TUNNEL.value);
                        }
                    }

                    res  = f.has(resists[i].res_flag.value);
                    imm  = f.has(resists[i].im_flag.value);
                    vuln = f.has(resists[i].vuln_flag.value);

                    if (imm)
                    {
                        name_attr = ConsoleColor.DarkGreen;
                    }
                    else if (res && name_attr == ConsoleColor.White)
                    {
                        name_attr = ConsoleColor.Cyan;
                    }

                    if (vuln)
                    {
                        sym = '-';
                    }
                    else if (imm)
                    {
                        sym = '*';
                    }
                    else if (res)
                    {
                        sym = '+';
                    }
                    else if ((j < Misc.INVEN_TOTAL) && o_ptr.kind != null &&
                             !o_ptr.object_flag_is_known(resists[i].res_flag.value))
                    {
                        sym = '?';
                    }
                    Term.addch(attr, sym);
                }
                Term.putstr(col, row, 6, name_attr, resists[i].name.ToString());
            }
            Term.putstr(col, row++, RES_COLS, ConsoleColor.White, "      abcdefghijkl@");
            /* Equippy */
            display_player_equippy(row++, col + 6);
        }