/* Proper usage includes: * 1. Initializing the slot during character generation or a * restore. * 2. Setting the slot due to a player's actions. * 3. If one of the objects in the slot are split off, these * functions can be used to put the remainder back in the slot. * 4. Putting an item that was thrown and returned back into the slot. * 5. Emptying the slot, by passing a null object. NEVER pass * zeroobj! * * If the item is being moved from another slot, it is the caller's * responsibility to handle that. It's also the caller's responsibility * to print the appropriate messages. */ void setuwep(struct obj *obj) { struct obj *olduwep = uwep; if (obj == uwep) return; /* necessary to not set unweapon */ /* This message isn't printed in the caller because it happens * *whenever* Sunsword is unwielded, from whatever cause. */ setworn(obj, W_WEP); if (uwep == obj && artifact_light(olduwep) && olduwep->lamplit) { end_burn(olduwep, FALSE); if (!Blind) pline("%s glowing.", Tobjnam(olduwep, "stop")); } /* Note: Explicitly wielding a pick-axe will not give a "bashing" * message. Wielding one via 'a'pplying it will. * 3.2.2: Wielding arbitrary objects will give bashing message too. */ if (obj) { unweapon = (obj->oclass == WEAPON_CLASS) ? is_launcher(obj) || is_ammo(obj) || is_missile(obj) || (is_pole(obj) && !u.usteed) : !is_weptool(obj); } else unweapon = TRUE; /* for "bare hands" message */ update_inventory(); }
/* release the objects the creature is carrying */ void relobj(struct monst *mtmp, int show, boolean is_pet) { /* If true, pet should keep wielded/worn items */ struct obj *otmp; int omx = mtmp->mx, omy = mtmp->my; struct obj *keepobj = 0; struct obj *wep = MON_WEP(mtmp), *hwep = attacktype(mtmp->data, AT_WEAP) ? select_hwep(mtmp) : (struct obj *)0, *proj = attacktype(mtmp->data, AT_WEAP) ? select_rwep(mtmp) : (struct obj *)0, *rwep; boolean item1 = FALSE, item2 = FALSE; rwep = attacktype(mtmp->data, AT_WEAP) ? propellor : &zeroobj; if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data)) item1 = item2 = TRUE; if (!tunnels(mtmp->data) || !needspick(mtmp->data)) item1 = TRUE; while ((otmp = mtmp->minvent) != 0) { obj_extract_self(otmp); /* special case: pick-axe and unicorn horn are non-worn */ /* items that we also want pets to keep 1 of */ /* (It is a coincidence that these can also be wielded.) */ if (otmp->owornmask || otmp == wep || otmp == hwep || otmp == rwep || otmp == proj || would_prefer_hwep(mtmp, otmp) || /* cursed item in hand? */ would_prefer_rwep(mtmp, otmp) || could_use_item(mtmp, otmp) || ((!rwep || rwep == &zeroobj) && (is_ammo(otmp) || is_launcher(otmp))) || (rwep && rwep != &zeroobj && ammo_and_launcher(otmp, rwep)) || ((!item1 && otmp->otyp == PICK_AXE) || (!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) { if (is_pet) { /* dont drop worn/wielded item */ if (otmp->otyp == PICK_AXE) item1 = TRUE; if (otmp->otyp == UNICORN_HORN && !otmp->cursed) item2 = TRUE; otmp->nobj = keepobj; keepobj = otmp; continue; } } if (otmp == wep) setmnotwielded(mtmp, otmp); mdrop_obj(mtmp, otmp, is_pet && flags.verbose); } /* put kept objects back */ while ((otmp = keepobj) != NULL) { keepobj = otmp->nobj; add_to_minv(mtmp, otmp); } if (show & cansee(omx, omy)) newsym(omx, omy); }
void CUIWeaponCellItem::OnAfterChild(CUIDragDropListEx* parent_list) { if(is_silencer() && GetIcon(eSilencer)) InitAddon (GetIcon(eSilencer), *object()->GetSilencerName(), m_addon_offset[eSilencer], parent_list->GetVerticalPlacement()); if(is_scope() && GetIcon(eScope)) InitAddon (GetIcon(eScope), *object()->GetScopeName(), m_addon_offset[eScope], parent_list->GetVerticalPlacement()); if(is_launcher() && GetIcon(eLauncher)) InitAddon (GetIcon(eLauncher), *object()->GetGrenadeLauncherName(),m_addon_offset[eLauncher], parent_list->GetVerticalPlacement()); }
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(); }