int d_dispel_abil(struct command *c) { int target = c->a; struct char_magic *p; p = rp_magic(target); if (p && p->ability_shroud > 0) { if (!charge_aura(c->who, 3)) return FALSE; wout(c->who, "Dispeled an aura %s ability shroud from %s.", nice_num(p->ability_shroud), box_name(target)); p->ability_shroud = 0; wout(target, "The magical ability shroud has dissipated."); } else { wout(c->who, "%s had no ability shroud.", box_name(target)); } return TRUE; }
int d_shroud_abil(struct command *c) { int aura = c->a; struct char_magic *p; if (!charge_aura(c->who, aura)) return FALSE; p = p_magic(c->who); p->ability_shroud += aura; wout(c->who, "Now cloaked in an aura %s ability shroud.", nice_num(p->ability_shroud)); return TRUE; }
_TCHAR * get_nice_number( __int64 num, size_t width ) { size_t len, i; _TCHAR * pb1 = get_next_buffer(); _TCHAR * pb2 = get_next_buffer(); SPRINTF(pb1, "%lld", num); nice_num( pb2, pb1 ); len = STRLEN(pb2); if( len < width ) { *pb1 = 0; i = width - len; // get pad while(i--) STRCAT(pb1, " "); STRCAT(pb1,pb2); pb2 = pb1; } return pb2; }
char * box_name_qty(int item, int qty) { return sout("%s~%s", nice_num(qty), plural_item_box(item, qty)); }
void location_production() { int where; int i, enclosed; int terr, encl_terr; int has_city; float pop_grow = 0.0; int pop_limit = 200, pop, dpop = 0; loop_loc(where) { terr = subkind(where); has_city = 0; for (i = 0; terr_prod[i].terr; i++) if (terr_prod[i].terr == terr) { replenish(where, terr_prod[i].item, terr_prod[i].qty, terr_prod[i].max); } /* * Mon Sep 16 11:42:22 1996 -- Scott Turner * * Now check for production from enclosed locations... * */ loop_here(where, enclosed) { encl_terr = subkind(enclosed); if (encl_terr == sub_city) has_city = 1; for (i = 0; terr_prod2[i].terr; i++) if (terr_prod2[i].terr == encl_terr) { replenish(where, terr_prod2[i].item, terr_prod2[i].qty, terr_prod2[i].max); }; } next_here; /* * First limit poppy fields to normal production level. * Then double opium if poppy field was specially tended. */ if (terr == sub_poppy_field) { int n; n = has_item(where, item_opium); if (n > POPPY_OPIUM) consume_item(where, item_opium, n - POPPY_OPIUM); if (rp_misc(where) && rp_misc(where)->opium_double) { rp_misc(where)->opium_double = FALSE; gen_item(where, item_opium, has_item(where, item_opium)); } } if (terr == sub_island || (loc_depth(where) == LOC_province && has_ocean_access(where))) replenish(where, item_flotsam, 30, 30); /* * Sun Dec 1 10:34:41 1996 -- Scott Turner * * Peasant production. Depends upon the location (and * whether it contains a city). * * Has_city is set up above... * * Tue Sep 22 13:20:18 1998 -- Scott Turner * * Faery ought not have peasants. It should have (I guess) * elf peasants, although what you can do with those is * open to conjecture :-) * */ if (pop = has_item(where, item_peasant)) { if (has_city) { pop_grow = 0.03; pop_limit = 10000; } else { switch (terr) { case sub_plain: case sub_forest: pop_grow = 0.01; pop_limit = 1000; break; case sub_mountain: case sub_swamp: pop_grow = 0.005; pop_limit = 1000; break; default: pop_grow = 0.000; pop_limit = 500; break; }; }; /* * Might be an effect here. * */ if (get_effect(where, ef_grow, 0, 0)) { wout(where, "The peasants seem particularly happy this month."); pop_grow += 0.02; }; dpop = pop * pop_grow; if (pop_grow > 0.0 && dpop < 1) dpop = 1; /* * Lose population at a reasonable rate. * */ if (pop > pop_limit) dpop = -(pop - pop_limit) / 10; if (p_subloc(province(where))->loot && dpop > 0) { wout(where, "Pillaging traumatizes the population and no growth occurs."); } else if (dpop > 0) { if (pop > 100) wout(where, "The population grows by %s peasant%s.", nice_num(dpop), add_s(dpop)); gen_item(where, item_peasant, dpop); } else { if (pop > 100) wout(where, "Overcrowding causes %s peasant death%s.", nice_num(-dpop), add_s(-dpop)); consume_item(where, item_peasant, -dpop); }; }; /* * Sat Apr 18 16:57:53 1998 -- Scott Turner * * Special case for gold production from peasants. * They generate 1 gold per 20 peasants (1/10 in cities) * which accumulates to be removed by various means. * * Only in civilized (> 100) provinces */ if ((pop = has_item(where, item_peasant)) > 100) { if (has_city) { dpop = pop * 0.10; } else { dpop = pop * 0.05; }; gen_item(where, item_gold, dpop); }; }