Example #1
0
        public Bitflag pflags = new Bitflag(Misc.PF_SIZE);            /* Racial (player) flags */

        public static Player_Race player_id2race(int id)
        {
            Player_Race r = null;

            for (r = Misc.races; r != null; r = r.Next)
            {
                if (r.ridx == id)
                {
                    break;
                }
            }
            return(r);
        }
Example #2
0
        /*
         * This fleshes out a full player based on the choices currently made,
         * and so is called whenever things like race or class are chosen.
         */
        public void generate(Player_Sex s, Player_Race r, Player_Class c)
        {
            if (s == null)
            {
                s = Misc.sex_info[psex];
            }
            if (c == null)
            {
                c = Class;
            }
            if (r == null)
            {
                r = Race;
            }

            Sex   = s;
            Class = c;
            Race  = r;

            // Level 1
            max_lev = lev = 1;

            // Experience factor
            expfact = (byte)(Race.r_exp + Class.c_exp);

            // Hitdice
            hitdie = (byte)(Race.r_mhp + Class.c_mhp);

            // Initial hitpoints
            mhp = hitdie;

            // Pre-calculate level 1 hitdice
            player_hp[0] = hitdie;

            // Roll for age/height/weight
            get_ahw();

            //HACK - get_history relies on a pointer, so we have to pack and unpack SC...
            if (Race.history != null)
            {
                history = Race.history.get_history(out sc);
            }
            else
            {
                history = "";
            }

            sc_birth = sc;
        }
Example #3
0
        /*
         * This fleshes out a full player based on the choices currently made,
         * and so is called whenever things like race or class are chosen.
         */
        public void generate(Player_Sex s, Player_Race r, Player_Class c)
        {
            if (s == null) s = Misc.sex_info[psex];
            if (c == null) c = Class;
            if (r == null) r = Race;

            Sex = s;
            Class = c;
            Race = r;

            // Level 1
            max_lev = lev = 1;

            // Experience factor
            expfact = (byte)(Race.r_exp + Class.c_exp);

            // Hitdice
            hitdie = (byte)(Race.r_mhp + Class.c_mhp);

            // Initial hitpoints
            mhp = hitdie;

            // Pre-calculate level 1 hitdice
            player_hp[0] = hitdie;

            // Roll for age/height/weight
            get_ahw();

            //HACK - get_history relies on a pointer, so we have to pack and unpack SC...
            if(Race.history != null) {
                history = Race.history.get_history(out sc);
            } else {
                history = "";
            }

            sc_birth = sc;
        }
Example #4
0
        public Player()
        {
            instance = this;
            bool keep_randarts = false;

            inventory = null;

            /* Preserve p_ptr.randarts so that players can use loaded randarts even
             * if they create a completely different character */
            if (randarts)
                keep_randarts = true;

            /* Wipe the player */
            //(void)WIPE(p, struct player); //Already have a clean slate

            randarts = keep_randarts;

            //Enable below else later

            /* Start with no artifacts made yet */
            for (int i = 0; Misc.z_info != null && i < Misc.z_info.a_max; i++)
            {
                Artifact a_ptr = Misc.a_info[i];
                if(a_ptr == null)
                    continue;
                a_ptr.created = false;
                a_ptr.seen = false;
            }

            /* Start with no quests */
            for (int i = 0; Misc.q_list != null && i < Misc.MAX_Q_IDX; i++)
            {
                if(Misc.q_list[i] == null)
                    Misc.q_list[i] = new Quest();
                Misc.q_list[i].level = 0;
            }

            if (Misc.q_list != null) {
                Misc.q_list[0].level = 99;
                Misc.q_list[1].level = 100;
            }

            for (int i = 1; Misc.z_info != null && i < Misc.z_info.k_max; i++) {
                Object.Object_Kind k_ptr = Misc.k_info[i];
                if(k_ptr == null)
                    continue;
                k_ptr.tried = false;
                k_ptr.aware = false;
            }

            for (int i = 1; Misc.z_info != null && i < Misc.z_info.r_max; i++)
            {
                Monster_Race r_ptr = Misc.r_info[i];
                Monster_Lore l_ptr = Misc.l_list[i];
                if(r_ptr == null || l_ptr == null)
                    continue;
                r_ptr.cur_num = 0;
                r_ptr.max_num = 100;
                if (r_ptr.flags.has(Monster_Flag.UNIQUE.value))
                    r_ptr.max_num = 1;
                l_ptr.pkills = 0;
            }

            /* Hack -- no ghosts */
            if (Misc.z_info != null && Misc.r_info[Misc.z_info.r_max-1] != null)
                Misc.r_info[Misc.z_info.r_max-1].max_num = 0;

            /* Always start with a well fed player (this is surely in the wrong fn) */
            food = Misc.PY_FOOD_FULL - 1;

            /* None of the spells have been learned yet */
            for (int i = 0; i < Misc.PY_MAX_SPELLS; i++)
                spell_order[i] = 99;

            inventory = new Object.Object[Misc.ALL_INVEN_TOTAL];
            for(int i = 0; i < Misc.ALL_INVEN_TOTAL; i++) {
                inventory[i] = new Object.Object();
            }

            /* First turn. */
            Misc.turn = 1;
            total_energy = 0;
            resting_turn = 0;
            /* XXX default race/class */
            Race = Misc.races;
            Class = Misc.classes;
        }
Example #5
0
        /* Parsing functions for prace.txt */
        public static Parser.Error parse_p_n(Parser p)
        {
            Player_Race h = p.priv as Player_Race;
            Player_Race r = new Player_Race();

            r.Next = h;
            r.ridx = p.getuint("index");
            r.Name = p.getstr("name");
            p.priv = r;
            return Parser.Error.NONE;
        }
Example #6
0
        public Player()
        {
            instance = this;
            bool keep_randarts = false;

            inventory = null;

            /* Preserve p_ptr.randarts so that players can use loaded randarts even
             * if they create a completely different character */
            if (randarts)
            {
                keep_randarts = true;
            }

            /* Wipe the player */
            //(void)WIPE(p, struct player); //Already have a clean slate

            randarts = keep_randarts;

            //Enable below else later

            /* Start with no artifacts made yet */
            for (int i = 0; Misc.z_info != null && i < Misc.z_info.a_max; i++)
            {
                Artifact a_ptr = Misc.a_info[i];
                if (a_ptr == null)
                {
                    continue;
                }
                a_ptr.created = false;
                a_ptr.seen    = false;
            }


            /* Start with no quests */
            for (int i = 0; Misc.q_list != null && i < Misc.MAX_Q_IDX; i++)
            {
                if (Misc.q_list[i] == null)
                {
                    Misc.q_list[i] = new Quest();
                }
                Misc.q_list[i].level = 0;
            }

            if (Misc.q_list != null)
            {
                Misc.q_list[0].level = 99;
                Misc.q_list[1].level = 100;
            }

            for (int i = 1; Misc.z_info != null && i < Misc.z_info.k_max; i++)
            {
                Object.Object_Kind k_ptr = Misc.k_info[i];
                if (k_ptr == null)
                {
                    continue;
                }
                k_ptr.tried = false;
                k_ptr.aware = false;
            }

            for (int i = 1; Misc.z_info != null && i < Misc.z_info.r_max; i++)
            {
                Monster_Race r_ptr = Misc.r_info[i];
                Monster_Lore l_ptr = Misc.l_list[i];
                if (r_ptr == null || l_ptr == null)
                {
                    continue;
                }
                r_ptr.cur_num = 0;
                r_ptr.max_num = 100;
                if (r_ptr.flags.has(Monster_Flag.UNIQUE.value))
                {
                    r_ptr.max_num = 1;
                }
                l_ptr.pkills = 0;
            }


            /* Hack -- no ghosts */
            if (Misc.z_info != null && Misc.r_info[Misc.z_info.r_max - 1] != null)
            {
                Misc.r_info[Misc.z_info.r_max - 1].max_num = 0;
            }


            /* Always start with a well fed player (this is surely in the wrong fn) */
            food = Misc.PY_FOOD_FULL - 1;


            /* None of the spells have been learned yet */
            for (int i = 0; i < Misc.PY_MAX_SPELLS; i++)
            {
                spell_order[i] = 99;
            }

            inventory = new Object.Object[Misc.ALL_INVEN_TOTAL];
            for (int i = 0; i < Misc.ALL_INVEN_TOTAL; i++)
            {
                inventory[i] = new Object.Object();
            }

            /* First turn. */
            Misc.turn    = 1;
            total_energy = 0;
            resting_turn = 0;
            /* XXX default race/class */
            Race  = Misc.races;
            Class = Misc.classes;
        }