static struct obj * DROPPABLES(struct monst *mon) { struct obj *obj; struct obj *wep = MON_WEP(mon), *hwep = attacktype(mon->data, AT_WEAP) ? select_hwep(mon) : (struct obj *)0, *proj = attacktype(mon->data, AT_WEAP) ? select_rwep(mon) : (struct obj *)0, *rwep; boolean item1 = FALSE, item2 = FALSE; rwep = attacktype(mon->data, AT_WEAP) ? propellor : &zeroobj; if (is_animal(mon->data) || mindless(mon->data)) item1 = item2 = TRUE; if (!tunnels(mon->data) || !needspick(mon->data)) item1 = TRUE; for (obj = mon->minvent; obj; obj = obj->nobj) { if (!item1 && is_pick(obj) && (obj->otyp != DWARVISH_MATTOCK || !which_armor(mon, W_ARMS))) { item1 = TRUE; continue; } if (!item2 && obj->otyp == UNICORN_HORN && !obj->cursed) { item2 = TRUE; continue; } if (!obj->owornmask && obj != wep && obj != rwep && obj != proj && obj != hwep && !would_prefer_hwep(mon, obj) /* cursed item in hand? */ && !would_prefer_rwep(mon, obj) && ((rwep != &zeroobj) || (!is_ammo(obj) && !is_launcher(obj))) && (rwep == &zeroobj || !ammo_and_launcher(obj, rwep)) && !could_use_item(mon, obj)) return obj; } return NULL; }
static void make_player_info(struct nh_player_info *pi) { int cap, advskills, i; memset(pi, 0, sizeof (struct nh_player_info)); pi->moves = moves; strncpy(pi->plname, u.uplname, sizeof (pi->plname)); pi->align = u.ualign.type; /* This function could be called before the game is fully inited. Test youmonst.data as it is required for near_capacity(). program_state.game_running is no good, as we need this data before game_running is set. TODO: Wow this is hacky. */ if (!youmonst.data) return; API_ENTRY_CHECKPOINT_RETURN_VOID_ON_ERROR(); pi->x = youmonst.mx; pi->y = youmonst.my; pi->z = u.uz.dlevel; if (Upolyd) { strncpy(pi->rank, msgtitlecase(mons[u.umonnum].mname), sizeof (pi->rank)); } else strncpy(pi->rank, rank(), sizeof (pi->rank)); strncpy(pi->rolename, (u.ufemale && urole.name.f) ? urole.name.f : urole.name.m, sizeof (pi->rolename)); strncpy(pi->racename, urace.noun, sizeof (pi->racename)); strncpy(pi->gendername, genders[u.ufemale].adj, sizeof(pi->gendername)); pi->max_rank_sz = mrank_sz; /* abilities */ pi->st = ACURR(A_STR); pi->st_extra = 0; if (pi->st > 118) { pi->st = pi->st - 100; pi->st_extra = 0; } else if (pi->st > 18) { pi->st_extra = pi->st - 18; pi->st = 18; } pi->dx = ACURR(A_DEX); pi->co = ACURR(A_CON); pi->in = ACURR(A_INT); pi->wi = ACURR(A_WIS); pi->ch = ACURR(A_CHA); pi->score = botl_score(); /* hp and energy */ pi->hp = Upolyd ? u.mh : u.uhp; pi->hpmax = Upolyd ? u.mhmax : u.uhpmax; if (pi->hp < 0) pi->hp = 0; pi->en = u.uen; pi->enmax = u.uenmax; pi->ac = find_mac(&youmonst); pi->gold = money_cnt(invent); pi->coinsym = def_oc_syms[COIN_CLASS]; describe_level(pi->level_desc); pi->monnum = u.umonster; pi->cur_monnum = u.umonnum; /* level and exp points */ if (Upolyd) pi->level = mons[u.umonnum].mlevel; else pi->level = youmonst.m_lev; pi->xp = youmonst.exp; cap = near_capacity(); /* check if any skills could be anhanced */ advskills = 0; for (i = 0; i < P_NUM_SKILLS; i++) { if (P_RESTRICTED(i)) continue; if (can_advance(i, FALSE)) advskills++; } pi->can_enhance = advskills > 0; /* add status items for various problems there can be at most 24 items here at any one time or we overflow the buffer */ if (hu_stat[u.uhs]) /* 1 */ strncpy(pi->statusitems[pi->nr_items++], hu_stat[u.uhs], ITEMLEN); if (Confusion) /* 2 */ strncpy(pi->statusitems[pi->nr_items++], "Conf", ITEMLEN); if (sick(&youmonst)) { /* 3 */ if (u.usick_type & SICK_VOMITABLE) strncpy(pi->statusitems[pi->nr_items++], "FoodPois", ITEMLEN); if (u.usick_type & SICK_NONVOMITABLE) strncpy(pi->statusitems[pi->nr_items++], "Ill", ITEMLEN); } if (Blind) /* 4 */ strncpy(pi->statusitems[pi->nr_items++], "Blind", ITEMLEN); if (slippery_fingers(&youmonst)) /* 5 */ strncpy(pi->statusitems[pi->nr_items++], "Greasy", ITEMLEN); if (leg_hurt(&youmonst)) /* 6 */ strncpy(pi->statusitems[pi->nr_items++], "Lame", ITEMLEN); if (stunned(&youmonst)) /* 7 */ strncpy(pi->statusitems[pi->nr_items++], "Stun", ITEMLEN); if (hallucinating(&youmonst)) /* 8 */ strncpy(pi->statusitems[pi->nr_items++], "Hallu", ITEMLEN); if (strangled(&youmonst)) /* 9 */ strncpy(pi->statusitems[pi->nr_items++], "Strangle", ITEMLEN); if (sliming(&youmonst)) /* 10 */ strncpy(pi->statusitems[pi->nr_items++], "Slime", ITEMLEN); if (petrifying(&youmonst)) /* 11 */ strncpy(pi->statusitems[pi->nr_items++], "Petrify", ITEMLEN); if (u.ustuck && !Engulfed && !sticks(youmonst.data)) /* 12 */ strncpy(pi->statusitems[pi->nr_items++], "Held", ITEMLEN); if (enc_stat[cap] ) /* 13 */ strncpy(pi->statusitems[pi->nr_items++], enc_stat[cap], ITEMLEN); if (cancelled(&youmonst)) strncpy(pi->statusitems[pi->nr_items++], "Cancelled", ITEMLEN); if (slow(&youmonst)) strncpy(pi->statusitems[pi->nr_items++], "Slow", ITEMLEN); if (Levitation) /* 14 */ strncpy(pi->statusitems[pi->nr_items++], "Lev", ITEMLEN); else if (Flying) strncpy(pi->statusitems[pi->nr_items++], "Fly", ITEMLEN); if (uwep && is_pick(uwep)) /* 15 (first case) */ strncpy(pi->statusitems[pi->nr_items++], "Dig", ITEMLEN); else if (uwep && is_launcher(uwep)) strncpy(pi->statusitems[pi->nr_items++], "Ranged", ITEMLEN); else if (uwep && (uwep->otyp == CORPSE) && (touch_petrifies(&mons[uwep->corpsenm]))) strncpy(pi->statusitems[pi->nr_items++], "cWielded", ITEMLEN); else if (!uwep) strncpy(pi->statusitems[pi->nr_items++], "Unarmed", ITEMLEN); else if (!is_wep(uwep)) strncpy(pi->statusitems[pi->nr_items++], "NonWeap", ITEMLEN); else { /* strncpy(pi->statusitems[pi->nr_items++], "Melee", ITEMLEN); */ /* Don't show the default Melee status light, as that's the most common case. */ /* 15 (last case) */ } if (u.utrap) /* 16 */ strncpy(pi->statusitems[pi->nr_items++], trap_stat[u.utraptype], ITEMLEN); API_EXIT(); }