/* * Fri Oct 11 13:29:43 1996 -- Scott Turner * * Select a random beast (type) to steal from the target. * */ int get_random_beast(int target, int *from) { int i, choice = 0; int sum = 0; struct item_ent *e; /* * Select (in one pass!) a random beast. * */ loop_stack(target, i) { if (subkind(i) == sub_ni && item_animal(noble_item(i))) { sum++; if (rnd(1,sum) == 1) { choice = noble_item(i); *from = i; }; }; loop_inv(i, e) { if (item_animal(e->item)) { sum += e->qty; if (rnd(1,sum) <= e->qty) { choice = e->item; *from = i; }; }; } next_inv; } next_stack; return choice; };
char * display_name(int n) { char *s; int i; if (!valid_box(n)) return ""; s = name(n); if (s && *s) return s; switch (kind(n)) { case T_player: return "Player"; case T_gate: return "Gate"; case T_post: return "Sign"; } if (i = noble_item(n)) return cap(plural_item_name(i, 1)); return cap(subkind_s[subkind(n)]); }
static char * with_inventory_string(int who) { char with[LEN]; struct item_ent *e; int mk; mk = noble_item(who); with[0] = '\0'; loop_inv(who, e) { if (mk == e->item || !item_prominent(e->item)) continue; if (with[0]) strcat(with, ", "); else strcpy(with, ", with "); strcat(with, just_name_qty(e->item, e->qty)); } next_inv; return sout("%s", with); }
/* * Fri Oct 9 18:19:22 1998 -- Scott Turner * * Destroying monster. * */ int v_art_destroy(struct command *c) { int item = c->use_skill; int where = province(subloc(c->who)); int num; struct item_ent *t; int kind; assert(rp_item_artifact(item)); kind = rp_item_artifact(item)->param1; if (rp_item_artifact(item)->uses < 1) { wout(c->who, "Nothing happens."); wout(c->who, "%s vanishes!", box_name(item)); destroy_unique_item(c->who, item); return TRUE; }; log_write(LOG_SPECIAL, "Destroy monster artifact %s used by %s", box_code_less(item), box_code_less(player(c->who))); wout(c->who, "A golden glow suffuses the province."); wout(where, "A golden glow suffuses the province."); loop_all_here(where, num) { wout(num, "A golden glow suffuses the province."); loop_inv(num, t) { if (t->item == kind) { wout(num, "%s vanished!", box_name_qty(t->item, t->qty)); consume_item(num, t->item, t->qty); } } next_inv; if (subkind(num) == sub_ni && noble_item(num) == kind) { kill_char(num, MATES, S_body); } }
static char * liner_desc_char(int n) { char buf[LEN]; extern int show_combat_flag; char *s; int sk; strcpy(buf, box_name(n)); sk = subkind(n); if (sk == sub_ni) { int mk = noble_item(n); int num = has_item(n, mk) + 1; if (num == 1) strcat(buf, sout(", %s", plural_item_name(mk, num))); else strcat(buf, sout(", %s, number:~%s", plural_item_name(mk, num), comma_num(num))); } else if (sk) { if (sk == sub_temple) { if (is_temple(n)) { strcat(buf, sout(", Temple of %s", god_name(is_temple(n)))); } else { strcat(buf, sout(", undedicated temple")); }; } else if (sk == sub_guild) { strcat(buf, sout(", %s Guild", box_name(is_guild(n)))); } else { strcat(buf, sout(", %s", subkind_s[sk])); }; } strcat(buf, nation_s(n)); strcat(buf, deserted_s(n)); strcat(buf, rank_s(n)); strcat(buf, mage_s(n)); strcat(buf, priest_s(n)); #if 0 strcat(buf, wield_s(n)); #endif if (show_combat_flag) { if (char_behind(n)) strcat(buf, sout(", behind~%d%s", char_behind(n), combat_ally)); else strcat(buf, combat_ally); } else if (char_guard(n) && stack_leader(n) == n && subkind(n) != sub_garrison) strcat(buf, ", on guard"); #if 0 if (subkind(n) == 0) { /* only show lord for regular players */ int sp = lord(n); if (sp != indep_player && !cloak_lord(n)) strcat(buf, sout(", of~%s", box_code_less(sp))); } #endif if (show_display_string) { s = banner(n); if (s && *s) strcat(buf, sout(", \"%s\"", s)); } strcat(buf, with_inventory_string(n)); if (is_prisoner(n)) strcat(buf, ", prisoner"); return sout("%s", buf); }
int d_capture_beasts(struct command *c) { int type, piety, from = 0; int target = c->a; if (!has_holy_symbol(c->who)) { wout(c->who, "You must have a holy symbol to capture wild beasts."); return FALSE; }; if (!has_holy_plant(c->who)) { wout(c->who, "Capturing wild beasts requires a holy plant."); return FALSE; }; /* * Target should be a character (oddly enough) * */ if (kind(target) != T_char) { wout(c->who, "You cannot capture beasts from %s.",box_name(target)); return FALSE; }; /* * In same location. * */ if (!check_char_here(c->who, target)) { wout(c->who, "%s is not here.",box_name(c->a)); return FALSE; }; if (is_prisoner(target)) { wout(c->who, "Cannot capture beasts from prisoners."); return FALSE; }; if (c->who == target) { wout(c->who, "Can't capture beasts from oneself."); return FALSE; }; if (stack_leader(c->who) == stack_leader(target)) { wout(c->who, "Can't capture beasts from a member of the same stack."); return FALSE; }; /* * Now select a random beast from the target. That can be either the * target itself, or one of the beasts in the target's inventory. In * any case, the beast's statistics determine the piety cost of the * spell. * * Note that who the beast is "from" is also returned. * */ type = get_random_beast(target, &from); if (!type || !item_animal(type)) { wout(c->who, "%s has no beasts that you can capture.", box_name(target)); return FALSE; }; piety = ((item_attack(type) + item_defense(type)) / 50.0) + 1.5; /* * Perhaps he hasn't the piety. * */ if (!has_piety(c->who, piety)) { wout(c->who, "You lack the piety to lure a beast from %s.", box_name(target)); return FALSE; }; /* * Lure the beast away. * */ if (!move_item(from, c->who, type, 1)) { /* * Possibly it is "from" himself who we are capturing. * */ if (subkind(from) == sub_ni && item_animal(noble_item(from))) { wout(c->who, "You capture %s!",box_name(target)); use_piety(c->who, piety); take_prisoner(c->who, from); /* * Fri Mar 24 06:56:46 2000 -- Scott Turner * * Take prisoner doesn't actually transfer the animal into your * inventory, so we'll have to "create" one. * */ gen_item(c->who, type, 1); return TRUE; }; wout(c->who,"For some reason, you capture no beast."); return FALSE; }; wout(c->who, "You capture a %s from %s!",box_name(type), box_name(target)); use_piety(c->who, piety); return TRUE; };