public Player_Magic spells; /* Magic spells */ public static Player_Class player_id2class(int id) { Player_Class c = null; for (c = Misc.classes; c != null; c = c.next) { if (c.cidx == id) { break; } } return(c); }
/* * 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; }
/* * 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; }
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; }
/* Parsing functions for pclass.txt */ public static Parser.Error parse_c_n(Parser p) { Player_Class h = p.priv as Player_Class; Player_Class c = new Player_Class(); c.cidx = p.getuint("index"); c.Name = p.getstr("name"); c.next = h; p.priv = c; return Parser.Error.NONE; }
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; }