void make_corpse(struct char_data *ch) { char buf2[MAX_NAME_LENGTH + 64]; struct obj_data *corpse, *o; struct obj_data *money; int i; corpse = create_obj(); corpse->item_number = NOTHING; IN_ROOM(corpse) = NOWHERE; corpse->name = strdup("corpse"); snprintf(buf2, sizeof(buf2), "The corpse of %s is lying here.", GET_NAME(ch)); corpse->description = strdup(buf2); snprintf(buf2, sizeof(buf2), "the corpse of %s", GET_NAME(ch)); corpse->short_description = strdup(buf2); GET_OBJ_TYPE(corpse) = ITEM_CONTAINER; GET_OBJ_WEAR(corpse) = ITEM_WEAR_TAKE; GET_OBJ_EXTRA(corpse) = ITEM_NODONATE; GET_OBJ_VAL(corpse, 0) = 0; /* You can't store stuff in a corpse */ GET_OBJ_VAL(corpse, 3) = 1; /* corpse identifier */ GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch); GET_OBJ_RENT(corpse) = 100000; if (IS_NPC(ch)) GET_OBJ_TIMER(corpse) = CONFIG_MAX_NPC_CORPSE_TIME; else GET_OBJ_TIMER(corpse) = CONFIG_MAX_PC_CORPSE_TIME; /* transfer character's inventory to the corpse */ corpse->contains = ch->carrying; for (o = corpse->contains; o != NULL; o = o->next_content) o->in_obj = corpse; object_list_new_owner(corpse, NULL); /* transfer character's equipment to the corpse */ for (i = 0; i < NUM_WEARS; i++) if (GET_EQ(ch, i)) { script_remove_o_trigger(&GET_EQ(ch, i), &ch); if (GET_EQ(ch, i)) { obj_to_obj(unequip_char(ch, i), corpse); } } /* transfer gold */ if (GET_GOLD(ch) > 0) { /* * following 'if' clause added to fix gold duplication loophole * The above line apparently refers to the old "partially log in, * kill the game character, then finish login sequence" duping * bug. The duplication has been fixed (knock on wood) but the * test below shall live on, for a while. -gg 3/3/2002 */ if (IS_NPC(ch) || ch->desc) { money = create_money(GET_GOLD(ch)); obj_to_obj(money, corpse); } GET_GOLD(ch) = 0; } ch->carrying = NULL; IS_CARRYING_N(ch) = 0; IS_CARRYING_W(ch) = 0; obj_to_room(corpse, IN_ROOM(ch)); }
void shopping_buy( char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH], newarg[100]; int num = 1; struct obj_data *temp1; int i; float mult = 0; if(!(is_ok(keeper,ch,shop_nr))) return; if(keeper->generic != 0) for(i = 0; i <= MAX_TRADE; i++) { if(keeper->generic == FAMINE) if(shop_index[shop_nr].type[i] == ITEM_FOOD) { mult = shop_multiplier; /* we're in a famine, we sell food, so we */ break; /* our prices to hell ;-) -DM */ } if(keeper->generic == DWARVES_STRIKE) if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) { mult = shop_multiplier; break; } } only_argument(arg, argm); if(!(*argm)) { sprintf(buf, "%s what do you want to buy??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; }; if ((num = getabunch(argm,newarg))!=NULL) { strcpy(argm,newarg); } if (num == 0) num = 1; if(!( temp1 = get_obj_in_list_vis(ch,argm,keeper->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(temp1->obj_flags.cost <= 0) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); extract_obj(temp1); return; } if (GET_GOLD(ch) < (int) (num*(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost))) && GetMaxLevel(ch)<DEMIGOD) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper,buf,19); switch(shop_index[shop_nr].temper1) { case 0: do_action(keeper,GET_NAME(ch),30); return; case 1: do_emote(keeper,"grins happily",36); return; default: return; } } if ((IS_CARRYING_N(ch) + num) > (CAN_CARRY_N(ch))) { sprintf(buf,"%s : You can't carry that many items.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + (num * temp1->obj_flags.weight)) > CAN_CARRY_W(ch)) { sprintf(buf,"%s : You can't carry that much weight.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), (int) (num * (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)))); do_tell(keeper,buf,19); sprintf(buf,"You now have %s (*%d).\n\r", temp1->short_description,num); send_to_char(buf,ch); while (num-- > 0) { if (GetMaxLevel(ch)<DEMIGOD) GET_GOLD(ch) -= (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); GET_GOLD(keeper) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); /* Test if producing shop ! */ if (shop_producing(temp1,shop_nr)) temp1 = read_object(temp1->item_number, REAL); else { obj_from_char(temp1); if (temp1 == NULL) { send_to_char("Sorry, I just ran out of those.\n\r",ch); GET_GOLD(ch) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); return; } } obj_to_char(temp1,ch); } return; }
char* symname(int addr){ return(GET_NAME(addr)); }
void save_player_to_file(struct creature *ch, const char *path) { void expire_old_grievances(struct creature *); // Save vital statistics FILE *ouf; char *tmp_path; struct alias_data *cur_alias; int idx; int hit = GET_HIT(ch), mana = GET_MANA(ch), move = GET_MOVE(ch); tmp_path = tmp_sprintf("%s.tmp", path); ouf = fopen(tmp_path, "w"); if (!ouf) { fprintf(stderr, "Unable to open XML player file for save.[%s] (%s)\n", path, strerror(errno)); return; } struct aff_stash *aff_stash = stash_creature_affects(ch); expire_old_grievances(ch); fprintf(ouf, "<creature name=\"%s\" idnum=\"%ld\">\n", GET_NAME(ch), ch->char_specials.saved.idnum); fprintf(ouf, "<points hit=\"%d\" mana=\"%d\" move=\"%d\" maxhit=\"%d\" maxmana=\"%d\" maxmove=\"%d\"/>\n", ch->points.hit, ch->points.mana, ch->points.move, ch->points.max_hit, ch->points.max_mana, ch->points.max_move); fprintf(ouf, "<money gold=\"%" PRId64 "\" cash=\"%" PRId64 "\" xp=\"%d\"/>\n", ch->points.gold, ch->points.cash, ch->points.exp); fprintf(ouf, "<stats level=\"%d\" sex=\"%s\" race=\"%s\" height=\"%d\" weight=\"%f\" align=\"%d\"/>\n", GET_LEVEL(ch), genders[(int)GET_SEX(ch)], race_name_by_idnum(GET_RACE(ch)), GET_HEIGHT(ch), GET_WEIGHT(ch), GET_ALIGNMENT(ch)); fprintf(ouf, "<class name=\"%s\"", class_names[GET_CLASS(ch)]); if (GET_REMORT_CLASS(ch) != CLASS_UNDEFINED) fprintf(ouf, " remort=\"%s\"", class_names[GET_REMORT_CLASS(ch)]); if (GET_REMORT_GEN(ch) > 0) fprintf(ouf, " gen=\"%d\"", GET_REMORT_GEN(ch)); if (IS_CYBORG(ch)) { if (GET_OLD_CLASS(ch) != -1) fprintf(ouf, " subclass=\"%s\"", borg_subchar_class_names[GET_OLD_CLASS(ch)]); if (GET_TOT_DAM(ch)) fprintf(ouf, " total_dam=\"%d\"", GET_TOT_DAM(ch)); if (GET_BROKE(ch)) fprintf(ouf, " broken=\"%d\"", GET_BROKE(ch)); } if (GET_CLASS(ch) == CLASS_MAGE && GET_SKILL(ch, SPELL_MANA_SHIELD) > 0) { fprintf(ouf, " manash_low=\"%ld\" manash_pct=\"%ld\"", ch->player_specials->saved.mana_shield_low, ch->player_specials->saved.mana_shield_pct); } fprintf(ouf, "/>\n"); fprintf(ouf, "<time birth=\"%ld\" death=\"%ld\" played=\"%ld\" last=\"%ld\"/>\n", ch->player.time.birth, ch->player.time.death, ch->player.time.played, ch->player.time.logon); fprintf(ouf, "<carnage pkills=\"%d\" akills=\"%d\" mkills=\"%d\" deaths=\"%d\" reputation=\"%d\"", GET_PKILLS(ch), GET_ARENAKILLS(ch), GET_MOBKILLS(ch), GET_PC_DEATHS(ch), ch->player_specials->saved.reputation); fprintf(ouf, "/>\n"); fprintf(ouf, "<attr str=\"%d\" int=\"%d\" wis=\"%d\" dex=\"%d\" con=\"%d\" cha=\"%d\"/>\n", ch->real_abils.str, ch->real_abils.intel, ch->real_abils.wis, ch->real_abils.dex, ch->real_abils.con, ch->real_abils.cha); fprintf(ouf, "<condition hunger=\"%d\" thirst=\"%d\" drunk=\"%d\"/>\n", GET_COND(ch, FULL), GET_COND(ch, THIRST), GET_COND(ch, DRUNK)); fprintf(ouf, "<player wimpy=\"%d\" lp=\"%d\" clan=\"%d\"/>\n", GET_WIMP_LEV(ch), GET_LIFE_POINTS(ch), GET_CLAN(ch)); if (ch->desc) ch->player_specials->desc_mode = ch->desc->input_mode; if (ch->player_specials->rentcode == RENT_CREATING || ch->player_specials->rentcode == RENT_REMORTING) { fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" " "currency=\"%d\" state=\"%s\"/>\n", ch->player_specials->rentcode, ch->player_specials->rent_per_day, ch->player_specials->rent_currency, desc_modes[(int)ch->player_specials->desc_mode]); } else { fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" currency=\"%d\"/>\n", ch->player_specials->rentcode, ch->player_specials->rent_per_day, ch->player_specials->rent_currency); } fprintf(ouf, "<home town=\"%d\" homeroom=\"%d\" loadroom=\"%d\"/>\n", GET_HOME(ch), GET_HOMEROOM(ch), GET_LOADROOM(ch)); fprintf(ouf, "<quest"); if (GET_QUEST(ch)) fprintf(ouf, " current=\"%d\"", GET_QUEST(ch)); if (GET_LEVEL(ch) >= LVL_IMMORT) fprintf(ouf, " allowance=\"%d\"", GET_QUEST_ALLOWANCE(ch)); if (GET_IMMORT_QP(ch) != 0) fprintf(ouf, " points=\"%d\"", GET_IMMORT_QP(ch)); fprintf(ouf, "/>\n"); fprintf(ouf, "<bits flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\"/>\n", ch->char_specials.saved.act, ch->player_specials->saved.plr2_bits); if (PLR_FLAGGED(ch, PLR_FROZEN)) { fprintf(ouf, "<frozen thaw_time=\"%d\" freezer_id=\"%d\"/>\n", ch->player_specials->thaw_time, ch->player_specials->freezer_id); } fprintf(ouf, "<prefs flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" tongue=\"%s\"/>\n", ch->player_specials->saved.pref, ch->player_specials->saved.pref2, tongue_name(GET_TONGUE(ch))); fprintf(ouf, "<affects flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" flag3=\"%" PRIx32 "\"/>\n", ch->char_specials.saved.affected_by, ch->char_specials.saved.affected2_by, ch->char_specials.saved.affected3_by); for (idx = 0; idx < MAX_WEAPON_SPEC; idx++) { if (GET_WEAP_SPEC(ch, idx).level > 0) fprintf(ouf, "<weaponspec vnum=\"%d\" level=\"%d\"/>\n", GET_WEAP_SPEC(ch, idx).vnum, GET_WEAP_SPEC(ch, idx).level); } if (GET_TITLE(ch) && *GET_TITLE(ch)) { fprintf(ouf, "<title>%s</title>\n", xmlEncodeTmp(GET_TITLE(ch))); } if (GET_LEVEL(ch) >= 50) { fprintf(ouf, "<immort badge=\"%s\" qlog=\"%d\" invis=\"%d\"/>\n", xmlEncodeSpecialTmp(BADGE(ch)), GET_QLOG_LEVEL(ch), GET_INVIS_LVL(ch)); if (POOFIN(ch) && *POOFIN(ch)) fprintf(ouf, "<poofin>%s</poofin>\n", xmlEncodeTmp(POOFIN(ch))); if (POOFOUT(ch) && *POOFOUT(ch)) fprintf(ouf, "<poofout>%s</poofout>\n", xmlEncodeTmp(POOFOUT(ch))); } if (ch->player.description && *ch->player.description) { fprintf(ouf, "<description>%s</description>\n", xmlEncodeTmp(tmp_gsub(tmp_gsub(ch->player.description, "\r\n", "\n"), "\r", ""))); } for (cur_alias = ch->player_specials->aliases; cur_alias; cur_alias = cur_alias->next) fprintf(ouf, "<alias type=\"%d\" alias=\"%s\" replace=\"%s\"/>\n", cur_alias->type, xmlEncodeSpecialTmp(cur_alias->alias), xmlEncodeSpecialTmp(cur_alias->replacement)); for (struct affected_type *cur_aff = aff_stash->saved_affs; cur_aff; cur_aff = cur_aff->next) fprintf(ouf, "<affect type=\"%d\" duration=\"%d\" modifier=\"%d\" location=\"%d\" level=\"%d\" instant=\"%s\" affbits=\"%lx\" index=\"%d\" owner=\"%ld\"/>\n", cur_aff->type, cur_aff->duration, cur_aff->modifier, cur_aff->location, cur_aff->level, (cur_aff->is_instant) ? "yes" : "no", cur_aff->bitvector, cur_aff->aff_index, cur_aff->owner); if (!IS_IMMORT(ch)) { for (idx = 0; idx < MAX_SKILLS; idx++) if (ch->player_specials->saved.skills[idx] > 0) fprintf(ouf, "<skill name=\"%s\" level=\"%d\"/>\n", spell_to_str(idx), GET_SKILL(ch, idx)); write_tongue_xml(ch, ouf); for (GList * it = GET_RECENT_KILLS(ch); it; it = it->next) { struct kill_record *kill = it->data; fprintf(ouf, "<recentkill vnum=\"%d\" times=\"%d\"/>\n", kill->vnum, kill->times); } for (GList * it = GET_GRIEVANCES(ch); it; it = it->next) { struct grievance *grievance = it->data; fprintf(ouf, "<grievance time=\"%lu\" player=\"%d\" reputation=\"%d\" kind=\"%s\"/>\n", (long unsigned)grievance->time, grievance->player_id, grievance->rep, grievance_kind_descs[grievance->grievance]); } } if (IS_PC(ch) && ch->player_specials->tags) { GHashTableIter iter; char *key; g_hash_table_iter_init(&iter, ch->player_specials->tags); while (g_hash_table_iter_next(&iter, (gpointer *)&key, NULL)) { fprintf(ouf, "<tag tag=\"%s\"/>\n", key); } } fprintf(ouf, "</creature>\n"); fclose(ouf); // on success, move temp file on top of the old file rename(tmp_path, path); restore_creature_affects(ch, aff_stash); free(aff_stash); GET_HIT(ch) = MIN(GET_MAX_HIT(ch), hit); GET_MANA(ch) = MIN(GET_MAX_MANA(ch), mana); GET_MOVE(ch) = MIN(GET_MAX_MOVE(ch), move); }
std::string Note::getName() { return GET_NAME(name); }
void damage(struct char_data *ch, struct char_data *victim, int dam, int attacktype) { char buf[MAX_STRING_LENGTH]; struct message_type *messages; int i,j,nr,max_hit,exp; int hit_limit(struct char_data *ch); assert(GET_POS(victim) > POSITION_DEAD); if ((GET_LEVEL(victim)>20) && !IS_NPC(victim)) /* You can't damage an immortal! */ dam=0; if (victim != ch) { if (GET_POS(victim) > POSITION_STUNNED) { if (!(victim->specials.fighting)) set_fighting(victim, ch); GET_POS(victim) = POSITION_FIGHTING; } if (GET_POS(ch) > POSITION_STUNNED) { if (!(ch->specials.fighting)) set_fighting(ch, victim); if (IS_NPC(ch) && IS_NPC(victim) && victim->master && !number(0,10) && IS_AFFECTED(victim, AFF_CHARM) && (victim->master->in_room == ch->in_room)) { if (ch->specials.fighting) stop_fighting(ch); hit(ch, victim->master, TYPE_UNDEFINED); return; } } } if (victim->master == ch) stop_follower(victim); if (IS_AFFECTED(ch, AFF_INVISIBLE)) appear(ch); if (IS_AFFECTED(victim, AFF_SANCTUARY)) dam = MIN(dam, 18); /* Max 18 damage when sanctuary */ dam=MIN(dam,100); dam=MAX(dam,0); GET_HIT(victim)-=dam; if (ch != victim) gain_exp(ch,GET_LEVEL(victim)*dam); update_pos(victim); if ((attacktype >= TYPE_HIT) && (attacktype <= TYPE_SLASH)) { if (!ch->equipment[WIELD]) { dam_message(dam, ch, victim, TYPE_HIT); } else { dam_message(dam, ch, victim, attacktype); } } else { for(i = 0; i < MAX_MESSAGES; i++) { if (fight_messages[i].a_type == attacktype) { nr=dice(1,fight_messages[i].number_of_attacks); for(j=1,messages=fight_messages[i].msg;(j<nr)&&(messages);j++) messages=messages->next; if (!IS_NPC(victim) && (GET_LEVEL(victim) > 20)) { act(messages->god_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR); act(messages->god_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT); act(messages->god_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT); } else if (dam != 0) { if (GET_POS(victim) == POSITION_DEAD) { act(messages->die_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR); act(messages->die_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT); act(messages->die_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT); } else { act(messages->hit_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR); act(messages->hit_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT); act(messages->hit_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT); } } else { /* Dam == 0 */ act(messages->miss_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR); act(messages->miss_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT); act(messages->miss_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT); } } } } switch (GET_POS(victim)) { case POSITION_MORTALLYW: act("$n is mortally wounded, and will die soon, if not aided.", TRUE, victim, 0, 0, TO_ROOM); act("You are mortally wounded, and will die soon, if not aided.", FALSE, victim, 0, 0, TO_CHAR); break; case POSITION_INCAP: act("$n is incapacitated and will slowly die, if not aided.", TRUE, victim, 0, 0, TO_ROOM); act("You are incapacitated an will slowly die, if not aided.", FALSE, victim, 0, 0, TO_CHAR); break; case POSITION_STUNNED: act("$n is stunned, but will probably regain conscience again.", TRUE, victim, 0, 0, TO_ROOM); act("You're stunned, but will probably regain conscience again.", FALSE, victim, 0, 0, TO_CHAR); break; case POSITION_DEAD: act("$n is dead! R.I.P.", TRUE, victim, 0, 0, TO_ROOM); act("You are dead! Sorry...", FALSE, victim, 0, 0, TO_CHAR); break; default: /* >= POSITION SLEEPING */ max_hit=hit_limit(victim); if (dam > (max_hit/5)) act("That Really did HURT!",FALSE, victim, 0, 0, TO_CHAR); if (GET_HIT(victim) < (max_hit/5)) { act("You wish that your wounds would stop BLEEDING that much!",FALSE,victim,0,0,TO_CHAR); if (IS_NPC(victim)) if (IS_SET(victim->specials.act, ACT_WIMPY)) do_flee(victim, "", 0); } break; } if (!IS_NPC(victim) && !(victim->desc)) { do_flee(victim, "", 0); if (!victim->specials.fighting) { act("$n is rescued by divine forces.", FALSE, victim, 0, 0, TO_ROOM); victim->specials.was_in_room = victim->in_room; char_from_room(victim); char_to_room(victim, 0); } } if (GET_POS(victim) < POSITION_STUNNED) if (ch->specials.fighting == victim) stop_fighting(ch); if (!AWAKE(victim)) if (victim->specials.fighting) stop_fighting(victim); if (GET_POS(victim) == POSITION_DEAD) { if (IS_NPC(victim) || victim->desc) if (IS_AFFECTED(ch, AFF_GROUP)) { group_gain(ch, victim); } else { /* Calculate level-difference bonus */ exp = GET_EXP(victim)/3; if (IS_NPC(ch)) exp += (exp*MIN(4, (GET_LEVEL(victim) - GET_LEVEL(ch))))>>3; else exp += (exp*MIN(8, (GET_LEVEL(victim) - GET_LEVEL(ch))))>>3; exp = MAX(exp, 1); gain_exp(ch, exp); change_alignment(ch, victim); } if (!IS_NPC(victim)) { sprintf(buf, "%s killed by %s at %s", GET_NAME(victim), (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch)), world[victim->in_room].name); log(buf); } die(victim); }
void mob_char_indirect (CHAR_DATA * mob, char *token, int *value, int *type) { CHAR_DATA *ch; CHAR_DATA *person; int i; struct ind_data_t { int which_case; char ind[15]; int type; } ind_data[] = { { 0, "str", MP_TYPE_INTEGER}, { 1, "dex", MP_TYPE_INTEGER}, { 2, "int", MP_TYPE_INTEGER}, { 3, "con", MP_TYPE_INTEGER}, { 4, "wil", MP_TYPE_INTEGER}, { 5, "aur", MP_TYPE_INTEGER}, { 6, "hit", MP_TYPE_INTEGER}, { 7, "maxhit", MP_TYPE_INTEGER}, { 8, "moves", MP_TYPE_INTEGER}, { 9, "maxmoves", MP_TYPE_INTEGER}, { 10, "deity", MP_TYPE_INTEGER}, { 11, "circle", MP_TYPE_INTEGER}, { 12, "race", MP_TYPE_INTEGER}, { 13, "sex", MP_TYPE_INTEGER}, { 14, "clan_1", MP_TYPE_INTEGER}, { 15, "piety", MP_TYPE_INTEGER}, { 16, "offense", MP_TYPE_INTEGER}, { 17, "clan_2", MP_TYPE_INTEGER}, { 18, "fightmode", MP_TYPE_INTEGER}, { 19, "next_in_room", MP_TYPE_CHAR_DATA}, { 20, "name", MP_TYPE_STRING}, { 21, "level", MP_TYPE_INTEGER}, { 22, "fighting", MP_TYPE_CHAR_DATA}, { 23, "realname", MP_TYPE_STRING}, { 24, "in_room", MP_TYPE_INTEGER}, { 25, "equip", MP_TYPE_OBJ_DATA}, { 26, "inv", MP_TYPE_OBJ_DATA}, { 27, "reset_room", MP_TYPE_INTEGER}, { 28, "prisoner", MP_TYPE_CHAR_DATA}, { 0, "\0", 0} }; *type = -1; if (!*value) return; ch = (CHAR_DATA *) * value; for (i = 0; *ind_data[i].ind; i++) { if (!str_cmp (ind_data[i].ind, token)) break; } if (!*ind_data[i].ind) return; *type = ind_data[i].type; switch (ind_data[i].which_case) { case 0: *value = GET_STR (ch); break; case 1: *value = GET_DEX (ch); break; case 2: *value = GET_INT (ch); break; case 3: *value = GET_CON (ch); break; case 4: *value = GET_WIL (ch); break; case 5: *value = GET_AUR (ch); break; case 6: *value = GET_HIT (ch); break; case 7: *value = GET_MAX_HIT (ch); break; case 8: *value = GET_MOVE (ch); break; case 9: *value = GET_MAX_MOVE (ch); break; case 10: *value = ch->deity; break; case 11: *value = ch->circle; break; case 12: *value = ch->race; break; case 13: *value = ch->sex; break; case 14: *value = 0; /* ch->clan_1; */ break; case 15: *value = ch->ppoints; break; case 16: *value = ch->offense; break; case 17: *value = 0; /* ch->clan_2; */ break; case 18: *value = ch->fight_mode; break; case 19: if (!is_he_here (mob, ch, 0)) person = NULL; else { person = ch->next_in_room; while (person && !CAN_SEE (mob, person)) person = person->next_in_room; } *value = (long int) person; break; case 20: *value = (long int) ch->short_descr; break; case 21: *value = GET_TRUST (ch); break; case 22: *value = (long int) ch->fighting; break; case 23: *value = (long int) GET_NAME (ch); break; case 24: *value = ch->in_room; break; case 25: *value = (long int) ch->equip; break; case 26: if (ch->right_hand) *value = (long int) ch->right_hand; else *value = (long int) ch->left_hand; break; case 27: if (ch->pc) *value = 0; else if (ch->mob->reset_zone != 0 || ch->mob->reset_cmd != 0) *value = zone_table[ch->mob->reset_zone].cmd[ch->mob->reset_cmd].arg1; else *value = 0; break; case 28: *value = (long int) (IS_SUBDUER (ch) ? ch->subdue : NULL); break; } }
static void event_undead_invade_zone(struct char_data *ch, char *arg) { struct event_mob_set mobset[64] = { /* vnum, hp: xdy+z, exp: xdy+z, gold: xdy+z, object %, obj vnum */ {9002, 9, 8, 40, 7, 8, 6, 0, 0, 0, 0, -1}, /* ghoul */ {9002, 8, 8, 30, 5, 8, 6, 0, 0, 0, 0, -1}, /* ghoul */ {9001, 8, 8, 20, 3, 6, 4, 0, 0, 0, 0, -1}, /* juju zombie */ {9001, 7, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* juju zombie */ {9001, 7, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* juju zombie */ {9001, 6, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* juju zombie */ {9002, 5, 8, 20, 4, 8, 6, 0, 0, 0, 0, -1}, /* ghoul */ {9002, 5, 8, 0, 4, 8, 6, 0, 0, 0, 0, -1}, /* ghoul */ {9002, 4, 8, 20, 4, 8, 6, 0, 0, 0, 0, -1}, /* ghoul */ {9002, 4, 8, 20, 4, 8, 6, 0, 0, 0, 0, -1}, /* ghoul */ {4616, 7, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* banshee */ {4616, 6, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* banshee */ {4616, 6, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* banshee */ {4616, 5, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* banshee */ {4616, 5, 8, 20, 2, 6, 4, 0, 0, 0, 0, -1}, /* banshee */ {4615, 6, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* shadow */ {4615, 6, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* shadow */ {4615, 5, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* shadow */ {4615, 5, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* shadow */ {4615, 5, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* shadow */ {4615, 5, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* shadow */ {4615, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* shadow */ {4613, 6, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* poltergeist */ {4613, 5, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* poltergeist */ {4613, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* poltergeist */ {4613, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* poltergeist */ {4613, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* poltergeist */ {4613, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* poltergeist */ {4613, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* poltergeist */ {9003, 5, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* skeleton */ {9003, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* skeleton */ {9003, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* skeleton */ {9003, 4, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* skeleton */ {9003, 3, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* skeleton */ {9003, 3, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* skeleton */ {9003, 3, 8, 20, 1, 6, 4, 0, 0, 0, 0, -1}, /* skeleton */ {5300, 5, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 4, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 3, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 3, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {5300, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* sewer skeleton */ {4603, 5, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 4, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 3, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 2, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1}, /* small skeleton */ {4603, 1, 8, 5, 1, 6, 4, 0, 0, 0, 0, -1} /* small skeleton */ }; struct event_mob_in_zone mobs = { 0, 0, 50, 1, 3, 64, mobset }; int zone = 0; struct room_data *rp = NULL; if (DEBUG > 1) log_info("called %s with %s, %s", __PRETTY_FUNCTION__, SAFE_NAME(ch), VNULL(arg)); if ((rp = real_roomp(ch->in_room))) zone = rp->zone; else return; /* don't code things like this here.... if a whizz annoys people, it is his * job to make it up... but if there is a good reason, he should be able to * do ANYTHING. * * if((rp->zone == 10)||(rp->zone == 11)) { * cprintf(ch,"You may not load this event into the newbie area.\r\n"); * return; } * */ mobs.bottom = zone ? (zone_table[zone - 1].top + 1) : 0; mobs.top = zone_table[zone].top; if (IS_SET(ch->specials.act, PLR_STEALTH)) zprintf(zone, "\r\nSuddenly, the warmth is snatched from the air around you.\r\nYou feel the icy cold touch of the grave as you gasp in anticipation...\r\nThe wind begins to howl around you as things move about.\r\n\r\n"); else zprintf(zone, "\r\n%s's voice booms all around you, \"Go forth ancient ones!\r\nKill the puny mortals and feast on their bones!\"\r\nThe air grows still and cold as you feel... things... begin to move.\r\n", GET_NAME(ch)); mob_count = 0; hash_iterate(&room_db, (funcp)event_fill_zone_with_mobs, &mobs); cprintf(ch, "You just added %d undead spirits to %s [#%d].\r\n", mob_count, zone_table[zone].name, zone); log_info("%s added %d undead to %s [#%d].", GET_NAME(ch), mob_count, zone_table[zone].name, zone); }
void gain_exp(CHAR_DATA * ch, int gain) { int is_altered = FALSE; int num_levels = 0; char buf[128]; if (IS_NPC(ch)) { ch->set_exp(ch->get_exp() + gain); return; } else { ch->dps_add_exp(gain); ZoneExpStat::add(zone_table[world[IN_ROOM(ch)]->zone].number, gain); } if (!IS_NPC(ch) && ((GET_LEVEL(ch) < 1 || GET_LEVEL(ch) >= LVL_IMMORT))) return; if (gain > 0 && GET_LEVEL(ch) < LVL_IMMORT) { gain = MIN(max_exp_gain_pc(ch), gain); // put a cap on the max gain per kill ch->set_exp(ch->get_exp() + gain); if (GET_EXP(ch) >= level_exp(ch, LVL_IMMORT)) { if (!GET_GOD_FLAG(ch, GF_REMORT) && GET_REMORT(ch) < MAX_REMORT) { if (Remort::can_remort_now(ch)) { send_to_char(ch, "%sПоздравляем, вы получили право на перевоплощение!%s\r\n", CCIGRN(ch, C_NRM), CCNRM(ch, C_NRM)); } else { send_to_char(ch, "%sПоздравляем, вы набрали максимальное количество опыта!\r\n" "%s%s\r\n", CCIGRN(ch, C_NRM), Remort::WHERE_TO_REMORT_STR.c_str(), CCNRM(ch, C_NRM)); } SET_GOD_FLAG(ch, GF_REMORT); } } ch->set_exp(MIN(GET_EXP(ch), level_exp(ch, LVL_IMMORT) - 1)); while (GET_LEVEL(ch) < LVL_IMMORT && GET_EXP(ch) >= level_exp(ch, GET_LEVEL(ch) + 1)) { ch->set_level(ch->get_level() + 1); num_levels++; sprintf(buf, "%sВы достигли следующего уровня!%s\r\n", CCWHT(ch, C_NRM), CCNRM(ch, C_NRM)); send_to_char(buf, ch); advance_level(ch); is_altered = TRUE; } if (is_altered) { sprintf(buf, "%s advanced %d level%s to level %d.", GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s", GET_LEVEL(ch)); mudlog(buf, BRF, LVL_IMPL, SYSLOG, TRUE); } } else if (gain < 0 && GET_LEVEL(ch) < LVL_IMMORT) { gain = MAX(-max_exp_loss_pc(ch), gain); // Cap max exp lost per death ch->set_exp(ch->get_exp() + gain); while (GET_LEVEL(ch) > 1 && GET_EXP(ch) < level_exp(ch, GET_LEVEL(ch))) { ch->set_level(ch->get_level() - 1); num_levels++; sprintf(buf, "%sВы потеряли уровень. Вам должно быть стыдно!%s\r\n", CCIRED(ch, C_NRM), CCNRM(ch, C_NRM)); send_to_char(buf, ch); decrease_level(ch); is_altered = TRUE; } if (is_altered) { sprintf(buf, "%s decreases %d level%s to level %d.", GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s", GET_LEVEL(ch)); mudlog(buf, BRF, LVL_IMPL, SYSLOG, TRUE); } } if ((GET_EXP(ch) < level_exp(ch, LVL_IMMORT) - 1) && GET_GOD_FLAG(ch, GF_REMORT) && gain && (GET_LEVEL(ch) < LVL_IMMORT)) { if (Remort::can_remort_now(ch)) { send_to_char(ch, "%sВы потеряли право на перевоплощение!%s\r\n", CCIRED(ch, C_NRM), CCNRM(ch, C_NRM)); } CLR_GOD_FLAG(ch, GF_REMORT); } char_stat::add_class_exp(GET_CLASS(ch), gain); update_clan_exp(ch, gain); }
void zedit_parse(struct descriptor_data *d, char *arg) { int pos, i = 0; switch (OLC_MODE(d)) { /*-------------------------------------------------------------------*/ case ZEDIT_CONFIRM_SAVESTRING: switch (*arg) { case 'y': case 'Y': /* * Save the zone in memory, hiding invisible people. */ //SEND_TO_Q("Saving zone info in memory.\r\n", d); zedit_save_internally(d); SEND_TO_Q("Saving zone info to disk.\r\n", d); zedit_save_to_disk(OLC_ZNUM(d)); sprintf(buf, "OLC: %s edits zone info for room %d.", GET_NAME(d->character), OLC_NUM(d)); mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE); /* FALL THROUGH */ case 'n': case 'N': cleanup_olc(d, CLEANUP_ALL); break; default: SEND_TO_Q("Invalid choice!\r\nDo you wish to save your changes? : ", d); break; } break; /* End of ZEDIT_CONFIRM_SAVESTRING */ /*-------------------------------------------------------------------*/ case ZEDIT_MAIN_MENU: switch (*arg) { case 'q': case 'Q': if (OLC_ZONE(d)->age || OLC_ZONE(d)->number) { SEND_TO_Q("Do you wish to save your changes? : ", d); OLC_MODE(d) = ZEDIT_CONFIRM_SAVESTRING; } else { SEND_TO_Q("No changes made.\r\n", d); cleanup_olc(d, CLEANUP_ALL); } break; case 'n': case 'N': /* * New entry. */ SEND_TO_Q("What number in the list should the new command be? : ", d); OLC_MODE(d) = ZEDIT_NEW_ENTRY; break; case 'e': case 'E': /* * Change an entry. */ SEND_TO_Q("Which command do you wish to change? : ", d); OLC_MODE(d) = ZEDIT_CHANGE_ENTRY; break; case 'd': case 'D': /* * Delete an entry. */ SEND_TO_Q("Which command do you wish to delete? : ", d); OLC_MODE(d) = ZEDIT_DELETE_ENTRY; break; case 'z': case 'Z': /* * Edit zone name. */ SEND_TO_Q("Enter new zone name : ", d); OLC_MODE(d) = ZEDIT_ZONE_NAME; break; case 't': case 'T': /* * Edit top of zone. */ if (GET_LEVEL(d->character) < LVL_DEITY) zedit_disp_menu(d); else { SEND_TO_Q("Enter new top of zone : ", d); OLC_MODE(d) = ZEDIT_ZONE_TOP; } break; case 'l': case 'L': /* * Edit zone lifespan. */ SEND_TO_Q("Enter new zone lifespan : ", d); OLC_MODE(d) = ZEDIT_ZONE_LIFE; break; case 'r': case 'R': /* * Edit zone reset mode. */ SEND_TO_Q("\r\n" "0) Never reset\r\n" "1) Reset only when no players in zone\r\n" "2) Normal reset\r\n" "Enter new zone reset type : ", d); OLC_MODE(d) = ZEDIT_ZONE_RESET; break; case 'c': case 'C': /* * Change loadchance (percentages) */ send_to_char(" \r\nWhich command? ", d->character); OLC_MODE(d) = ZEDIT_PROB; break; case 'b': case 'B': if (GET_LEVEL(d->character) < LVL_DEITY) { send_to_char("Only Implementors can modify the builder list.\r\n", d->character); zedit_disp_menu(d); } else { /* * Edit zone builder list. */ send_to_char("Enter new zone builders : ", d->character); OLC_MODE(d) = ZEDIT_ZONE_BUILDERS; } break; default: zedit_disp_menu(d); break; } break; /* End of ZEDIT_MAIN_MENU */ /*-------------------------------------------------------------------*/ case ZEDIT_NEW_ENTRY: /* * Get the line number and insert the new line. */ pos = atoi(arg); if (isdigit(*arg) && new_command(OLC_ZONE(d), pos)) { if (start_change_command(d, pos)) { zedit_disp_comtype(d); OLC_ZONE(d)->age = 1; } } else zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_DELETE_ENTRY: /* * Get the line number and delete the line. */ pos = atoi(arg); if (isdigit(*arg)) { delete_command(OLC_ZONE(d), pos); OLC_ZONE(d)->age = 1; } zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_CHANGE_ENTRY: /* * Parse the input for which line to edit, and goto next quiz. */ pos = atoi(arg); if (isdigit(*arg) && start_change_command(d, pos)) { zedit_disp_comtype(d); OLC_ZONE(d)->age = 1; } else zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_COMMAND_TYPE: /* * Parse the input for which type of command this is, and goto next * quiz. */ OLC_CMD(d).command = toupper(*arg); if (!OLC_CMD(d).command || (strchr("MOPEDGR", OLC_CMD(d).command) == NULL)) { SEND_TO_Q("Invalid choice, try again : ", d); } else { if (OLC_VAL(d)) { /* If there was a previous command. */ SEND_TO_Q("Is this command dependent on the success of the previous one? (y/n)\r\n", d); OLC_MODE(d) = ZEDIT_IF_FLAG; } else { /* 'if-flag' not appropriate. */ OLC_CMD(d).if_flag = 0; zedit_disp_arg1(d); } } break; /*-------------------------------------------------------------------*/ case ZEDIT_IF_FLAG: /* * Parse the input for the if flag, and goto next quiz. */ switch (*arg) { case 'y': case 'Y': OLC_CMD(d).if_flag = 1; break; case 'n': case 'N': OLC_CMD(d).if_flag = 0; break; default: SEND_TO_Q("Try again : ", d); return; } zedit_disp_arg1(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_ARG1: /* * Parse the input for arg1, and goto next quiz. */ if (!isdigit(*arg)) { SEND_TO_Q("Must be a numeric value, try again : ", d); return; } switch (OLC_CMD(d).command) { case 'M': if ((pos = real_mobile(atoi(arg))) >= 0) { OLC_CMD(d).arg1 = pos; zedit_disp_arg2(d); } else SEND_TO_Q("That mobile does not exist, try again : ", d); break; case 'O': case 'P': case 'E': case 'G': if ((pos = real_object(atoi(arg))) >= 0) { OLC_CMD(d).arg1 = pos; zedit_disp_arg2(d); } else SEND_TO_Q("That object does not exist, try again : ", d); break; case 'D': case 'R': case 'T': case 'V': if (atoi(arg)<MOB_TRIGGER || atoi(arg)>WLD_TRIGGER) send_to_char("Invalid input.", d->character); else { OLC_CMD(d).arg1 = atoi(arg); zedit_disp_arg2(d); } break; default: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: zedit_parse(): case ARG1: Ack!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; } break; /*-------------------------------------------------------------------*/ case ZEDIT_ARG2: /* * Parse the input for arg2, and goto next quiz. */ if (!isdigit(*arg)) { SEND_TO_Q("Must be a numeric value, try again : ", d); return; } switch (OLC_CMD(d).command) { case 'M': case 'O': OLC_CMD(d).arg2 = atoi(arg); OLC_CMD(d).arg3 = real_room(OLC_NUM(d)); OLC_CMD(d).arg4 = 0; zedit_disp_menu(d); break; case 'G': OLC_CMD(d).arg2 = atoi(arg); OLC_CMD(d).arg4 = 0; zedit_disp_menu(d); break; case 'P': case 'E': OLC_CMD(d).arg2 = atoi(arg); OLC_CMD(d).arg4 = 0; zedit_disp_arg3(d); break; case 'V': OLC_CMD(d).arg2 = atoi(arg); if (OLC_CMD(d).arg1 == WLD_TRIGGER) OLC_CMD(d).arg3 = OLC_NUM(d); send_to_char("Enter the global name : ", d->character); OLC_MODE(d) = ZEDIT_SARG1; break; case 'T': if (real_trigger(atoi(arg)) >= 0) { OLC_CMD(d).arg2 = atoi(arg); zedit_disp_menu(d); } else send_to_char("That trigger does not exist, try again : ", d->character); break; case 'D': pos = atoi(arg); /* * Count directions. */ if (pos < 0 || pos > NUM_OF_DIRS) SEND_TO_Q("Try again : ", d); else { OLC_CMD(d).arg2 = pos; zedit_disp_arg3(d); } break; case 'R': if ((pos = real_object(atoi(arg))) >= 0) { OLC_CMD(d).arg2 = pos; zedit_disp_menu(d); } else SEND_TO_Q("That object does not exist, try again : ", d); break; default: /* * We should never get here, but just in case... */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: zedit_parse(): case ARG2: Ack!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; } break; /*-------------------------------------------------------------------*/ case ZEDIT_ARG3: /* * Parse the input for arg3, and go back to main menu. */ if (!isdigit(*arg)) { SEND_TO_Q("Must be a numeric value, try again : ", d); return; } switch (OLC_CMD(d).command) { case 'E': pos = atoi(arg); /* * Count number of wear positions. We could use NUM_WEARS, this is * more reliable. */ while (*equipment_types[i] != '\n') i++; if (pos < 0 || pos > i) SEND_TO_Q("Try again : ", d); else { OLC_CMD(d).arg3 = pos; zedit_disp_menu(d); } break; case 'P': if ((pos = real_object(atoi(arg))) >= 0) { OLC_CMD(d).arg3 = pos; zedit_disp_menu(d); } else SEND_TO_Q("That object does not exist, try again : ", d); break; case 'D': pos = atoi(arg); if (pos < 0 || pos > 2) SEND_TO_Q("Try again : ", d); else { OLC_CMD(d).arg3 = pos; zedit_disp_menu(d); } break; case 'M': case 'O': case 'G': case 'R': case 'T': case 'V': default: /* * We should never get here, but just in case... */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: zedit_parse(): case ARG3: Ack!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; } break; /*-------------------------------------------------------------------*/ case ZEDIT_SARG1: if (strlen(arg)) { OLC_CMD(d).sarg1 = str_dup(arg); OLC_MODE(d) = ZEDIT_SARG2; send_to_char("Enter the global value : ", d->character); } else send_to_char("Must have some name to assign : ", d->character); break; /*-------------------------------------------------------------------*/ case ZEDIT_SARG2: if (strlen(arg)) { OLC_CMD(d).sarg2 = str_dup(arg); zedit_disp_menu(d); } else send_to_char("Must have some value to set it to :", d->character); break; /*-------------------------------------------------------------------*/ case ZEDIT_ZONE_NAME: /* * Add new name and return to main menu. */ if (genolc_checkstring(d, arg)) { if (OLC_ZONE(d)->name) free(OLC_ZONE(d)->name); else log("SYSERR: OLC: ZEDIT_ZONE_NAME: no name to free!"); OLC_ZONE(d)->name = str_dup(arg); OLC_ZONE(d)->number = 1; zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_ZONE_BUILDERS: /* * Add new builders and return to main menu. */ if (OLC_ZONE(d)->builders) free(OLC_ZONE(d)->builders); OLC_ZONE(d)->builders = str_dup(arg); OLC_ZONE(d)->number = 1; } zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_ZONE_RESET: /* * Parse and add new reset_mode and return to main menu. */ pos = atoi(arg); if (!isdigit(*arg) || pos < 0 || pos > 2) SEND_TO_Q("Try again (0-2) : ", d); else { OLC_ZONE(d)->reset_mode = pos; OLC_ZONE(d)->number = 1; zedit_disp_menu(d); } break; /*-------------------------------------------------------------------*/ case ZEDIT_ZONE_LIFE: /* * Parse and add new lifespan and return to main menu. */ pos = atoi(arg); if (!isdigit(*arg) || pos < 0 || pos > 240) SEND_TO_Q("Try again (0-240) : ", d); else { OLC_ZONE(d)->lifespan = pos; OLC_ZONE(d)->number = 1; zedit_disp_menu(d); } break; /*-------------------------------------------------------------------*/ case ZEDIT_ZONE_TOP: /* * Parse and add new top room in zone and return to main menu. */ if (OLC_ZNUM(d) == top_of_zone_table) OLC_ZONE(d)->top = LIMIT(atoi(arg), OLC_ZNUM(d) * 100, 32000); else OLC_ZONE(d)->top = LIMIT(atoi(arg), OLC_ZNUM(d) * 100, zone_table[OLC_ZNUM(d) + 1].number * 100); zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_PROB: /* * Which command to change loadchance for? :/ */ pos = atoi(arg); if (isdigit(*arg) && start_change_command(d, pos)) { OLC_MODE(d) = ZEDIT_PROB2; OLC_ZONE(d)->age = 1; send_to_char("\r\nChance of NOT loading (0-100) (input 0 for 'always load'): ", d->character); break; } else send_to_char("\r\nInvalid choice.\r\n\r\n", d->character); zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ case ZEDIT_PROB2: /* * Change the loadchance */ OLC_CMD(d).arg4 = atoi(arg); OLC_MODE(d) = ZEDIT_MAIN_MENU; zedit_disp_menu(d); break; /*-------------------------------------------------------------------*/ default: /* * We should never get here, but just in case... */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: zedit_parse(): Reached default case!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; } }
/* This procedure frees up the strings and/or the structures attatched to a * descriptor, sets all flags back to how they should be. */ void cleanup_olc(struct descriptor_data *d, byte cleanup_type) { /* Clean up WHAT? */ if (d->olc == NULL) return; /* Check for a room. free_room doesn't perform sanity checks, we must be * careful here. */ if (OLC_ROOM(d)) { switch (cleanup_type) { case CLEANUP_ALL: /* free(OLC_SCRIPT(d)) equivalent */ free_proto_script(OLC_ROOM(d), WLD_TRIGGER); free_room(OLC_ROOM(d)); break; case CLEANUP_STRUCTS: free(OLC_ROOM(d)); break; case CLEANUP_CONFIG: free_config(OLC_CONFIG(d)); break; default: /* The caller has screwed up. */ log("SYSERR: cleanup_olc: Unknown type!"); break; } } /* Check for an existing object in the OLC. The strings aren't part of the * prototype any longer. They get added with strdup(). */ if (OLC_OBJ(d)) { free_object_strings(OLC_OBJ(d)); free(OLC_OBJ(d)); } /* Check for a mob. free_mobile() makes sure strings are not in the * prototype. */ if (OLC_MOB(d)) free_mobile(OLC_MOB(d)); /* Check for a zone. cleanup_type is irrelevant here, free() everything. */ if (OLC_ZONE(d)) { if (OLC_ZONE(d)->builders) free(OLC_ZONE(d)->builders); if (OLC_ZONE(d)->name) free(OLC_ZONE(d)->name); if (OLC_ZONE(d)->cmd) free(OLC_ZONE(d)->cmd); free(OLC_ZONE(d)); } /* Check for a shop. free_shop doesn't perform sanity checks, we must be * careful here. OLC_SHOP(d) is a _copy_ - no pointers to the original. Just * go ahead and free it all. */ if (OLC_SHOP(d)) free_shop(OLC_SHOP(d)); /* Check for a quest. */ if (OLC_QUEST(d)) { switch (cleanup_type) { case CLEANUP_ALL: free_quest(OLC_QUEST(d)); break; case CLEANUP_STRUCTS: free(OLC_QUEST(d)); break; default: break; } } /*. Check for a guild . */ if (OLC_GUILD(d)) { switch (cleanup_type) { case CLEANUP_ALL: free_guild(OLC_GUILD(d)); break; case CLEANUP_STRUCTS: free(OLC_GUILD(d)); break; default: break; } } /*. Check for aedit stuff -- M. Scott */ if (OLC_ACTION(d)) { switch(cleanup_type) { case CLEANUP_ALL: free_action(OLC_ACTION(d)); break; case CLEANUP_STRUCTS: free(OLC_ACTION(d)); break; default: /* Caller has screwed up */ break; } } /* Used for cleanup of Hedit */ if (OLC_HELP(d)) { switch(cleanup_type) { case CLEANUP_ALL: free_help(OLC_HELP(d)); break; case CLEANUP_STRUCTS: free(OLC_HELP(d)); break; default: break; } } if (OLC_IBT(d)) { free_olc_ibt(OLC_IBT(d)); OLC_IBT(d) = NULL; } if (OLC_MSG_LIST(d)) { free_message_list(OLC_MSG_LIST(d)); OLC_MSG_LIST(d) = NULL; OLC_MSG(d) = NULL; } /* Free storage if allocated (tedit, aedit, and trigedit). This is the command * list - it's been copied to disk already, so just free it -Welcor. */ if (OLC_STORAGE(d)) { free(OLC_STORAGE(d)); OLC_STORAGE(d) = NULL; } /* Free this one regardless. If we've left olc, we've either made a fresh * copy of it in the trig index, or we lost connection. Either way, we need * to get rid of this. */ if (OLC_TRIG(d)) { free_trigger(OLC_TRIG(d)); OLC_TRIG(d) = NULL; } /* Free this one regardless. If we've left olc, we've either copied the * * preferences to the player, or we lost connection. Either way, we need * * to get rid of this. */ if(OLC_PREFS(d)) { /*. There is nothing else really to free, except this... .*/ free(OLC_PREFS(d)); OLC_PREFS(d) = NULL; } /* OLC_SCRIPT is always set as trig_proto of OLC_OBJ/MOB/ROOM. Therefore it * should not be free'd here. */ /* Restore descriptor playing status. */ if (d->character) { REMOVE_BIT_AR(PLR_FLAGS(d->character), PLR_WRITING); act("$n stops using OLC.", TRUE, d->character, NULL, NULL, TO_ROOM); if (cleanup_type == CLEANUP_CONFIG) mudlog(BRF, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing the game configuration", GET_NAME(d->character)); else if (STATE(d) == CON_TEDIT) mudlog(BRF, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing text files.", GET_NAME(d->character)); else if (STATE(d) == CON_HEDIT) mudlog(CMP, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing help files.", GET_NAME(d->character)); else mudlog(CMP, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing zone %d allowed zone %d", GET_NAME(d->character), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(d->character)); STATE(d) = CON_PLAYING; } free(d->olc); d->olc = NULL; }
void JeditParse( Descriptor *d, const std::string &arg ) { // if( arg.empty() == true ) // return; char leadingChar = (arg.empty() ? '\0' : toupper(arg[0])); switch( OLC_MODE(d) ) { case JEDIT_MAIN_MENU: if( leadingChar == 'Q' ) { d->send("Do you wish to save the changes to this trigger (y/n)?\r\n"); OLC_MODE(d) = JEDIT_SAVE_CHANGES; } else if( leadingChar == 'D' ) { d->olc->jsTrig->deleted = !d->olc->jsTrig->deleted; if( d->olc->jsTrig->deleted ) d->send("This script will now be deleted over the next reboot.\r\n"); else d->send("This script will no longer be deleted over the next reboot.\r\n"); JeditDispMenu(d); } else if( atoi(arg.c_str()) == 1 ) { d->send("Enter a new name for this trigger: "); OLC_MODE(d) = JEDIT_NAME; } else if( atoi(arg.c_str()) == 2 ) { OLC_MODE(d) = JEDIT_OPTION_FLAGS; JeditDispOptionMenu(d); } else if( atoi(arg.c_str()) == 3 ) { OLC_MODE(d) = JEDIT_TRIGGER_TYPES; JeditDispTypesMenu(d); } else if( atoi(arg.c_str()) == 4 ) { OLC_MODE(d) = JEDIT_ALLOW_FLAGS; JeditDispAllowMenu(d); } else if( atoi(arg.c_str()) == 5 ) { d->send("Please enter the argument for the trigger: "); OLC_MODE(d) = JEDIT_ARGS; } else if( atoi(arg.c_str()) == 6 ) { d->send("Please enter the numerical argument for the trigger: "); OLC_MODE(d) = JEDIT_NARG; } else if( atoi(arg.c_str()) == 7 ) { OLC_MODE(d) = JEDIT_SCRIPT_ID; d->send("Enter the script ID to attach this trigger to: "); return; } else d->send("Invalid option.\r\nTry again: "); break; case JEDIT_TRIGGER_TYPES: { int nr = atoi( arg.c_str() ); if( leadingChar == 'Q' || nr == 0 ) { JeditDispMenu( d ); return; } else if( nr < 0 || nr > JS::NUM_JS_TRIG_TYPES ) { d->send("Invalid option.\r\nTry again: "); } else { //Input is valid. d->olc->jsTrig->toggleFlag(nr-1); JeditDispTypesMenu( d ); } break; } case JEDIT_OPTION_FLAGS: { int nr = atoi( arg.c_str() ); if( leadingChar == 'Q' || nr == 0 ) { JeditDispMenu( d ); return; } else if( nr < 0 || nr > JS::NUMBER_OPTIONS ) { d->send("Invalid option.\r\nTry again: "); } else { //Input is valid. d->olc->jsTrig->toggleOptionFlag(nr-1); JeditDispOptionMenu( d ); } break; } case JEDIT_ALLOW_FLAGS: { int nr = atoi( arg.c_str() ); if( leadingChar == 'Q' || nr == 0 ) { JeditDispMenu( d ); return; } else if( nr < 0 || nr > JS::NUM_JS_ALLOWS ) { d->send("Invalid option.\r\nTry again: "); } else { //Input is valid. d->olc->jsTrig->toggleAllowed(nr-1); JeditDispAllowMenu( d ); } break; } case JEDIT_NAME: d->olc->jsTrig->name = filter(arg); JeditDispMenu(d); break; case JEDIT_ARGS: d->olc->jsTrig->args = filter(arg); JeditDispMenu(d); break; case JEDIT_NARG: if( !MiscUtil::isNumber(arg.c_str()) ) { d->send("You must input a number.\r\nTry again: "); break; } d->olc->jsTrig->narg = atoi(arg.c_str()); JeditDispMenu(d); break; case JEDIT_SCRIPT_ID: { if(toupper(arg[0]) == 'Q') { d->send("No changes have been made to the script ID.\r\n"); JeditDispMenu(d); break; } if(!MiscUtil::isNumber(arg.c_str())) { d->send("You must input a number.\r\nTry again: "); break; } int scriptId = atoi(arg.c_str()); if(scriptId != -1 && JSManager::get()->getScript(scriptId) == NULL) { d->send("There is no script #%d in the game.\r\nTry another, enter -1 to detach the script, or 'Q' to exit: "); break; } d->olc->jsTrig->scriptId = scriptId; JeditDispMenu(d); break; } case JEDIT_SAVE_CHANGES: if( leadingChar == 'Y' ) { d->send("Saving changes...\r\n"); MudLog(NRM, MAX(LVL_APPR, GET_INVIS_LEV(d->character)), TRUE, "%s has edited jsTrigger #%d.", GET_NAME(d->character), d->olc->jsTrig->vnum); bool deleted = d->olc->jsTrig->deleted; int vnum = d->olc->jsTrig->vnum; if( deleted ) { MudLog(NRM, MAX(LVL_APPR, GET_INVIS_LEV(d->character)), TRUE, "This script is now set to delete."); } int code = JSManager::get()->saveTrigger(d->olc->jsTrig); if (code == -1) { d->send("Trigger compilation failed. You have a syntax error somewhere in your script.\r\n"); } //Yes, save the trigger(above) to keep it in sync. But we'll also delete from the db if needed. if( deleted ) { JSManager::get()->deleteTrigger( JSManager::get()->getTrigger( vnum ) ); } } else if( leadingChar == 'N' ) { d->send("Changes discarded.\r\n"); delete d->olc->jsTrig; // we're not using it, so nuke it. } else { d->send("Invalid option.\r\nTry again: "); return; } cleanup_olc(d, CLEANUP_ALL); break; default: d->send("Error! Please report this."); MudLog(BRF, MAX(GET_INVIS_LEV(d->character),LVL_APPR), TRUE, "%s reached invalid jedit state(%d).", d->character->player.name.c_str(), OLC_MODE(d)); break; } }
void internal_generic_output(FILE* fp, CELL cell, int strict, int tab) { switch(GET_TYPE(cell)) { case T_VOID: fputs("#<void>", fp); break; case T_NULL: fputs("()", fp); break; case T_UNDEFINED: fputs("#<undefined>", fp); break; case T_EMPTY: fputs("#<empty>", fp); break; case T_BOOL: fputs(GET_BOOL(cell) ? "#t" : "#f", fp); break; case T_CHAR: { CHAR ch = GET_CHAR(cell); if (strict) { switch(ch) { case ' ': fputs("#\\space", fp); break; case 0: fputs("#\\nul", fp); break; case 27: fputs("#\\escape", fp); break; case 127: fputs("#\\rubout", fp); break; case '\a': fputs("#\\alarm", fp); break; case '\b': fputs("#\\backspace", fp); break; case '\f': fputs("#\\page", fp); break; case '\n': fputs("#\\newline", fp); break; case '\r': fputs("#\\return", fp); break; case '\t': fputs("#\\tab", fp); break; case '\v': fputs("#\\vtab", fp); break; default: fprintf(fp, "#\\%c", ch); break; } } else { fputc(ch, fp); } } break; case T_INT: fprintf(fp, "%d", GET_INT(cell)); break; case T_BIGINT: fprintf(fp, "%lld", GET_BIGINT(cell)); break; case T_FLOAT: fprintf(fp, "%f", GET_FLOAT(cell)); break; case T_STRING: { STRING* p = GET_STRING(cell); size_t len = p->len; char* data = p->data; if (strict) { // FIXME -- make this more efficient, and escape other special chars? fputc('"', fp); while(len--) { char ch = *data++; if (ch == '"' || ch == '\\') { fputc('\\', fp); } fputc(ch, fp); } fputc('"', fp); } else { fwrite(data, 1, len, fp); } } break; case T_NAME: { NAME* p = GET_NAME(cell); if (p->gensym) { fprintf(fp, "#_%d", p->gensym); } else { fwrite(GET_NAME(cell)->data, 1, GET_NAME(cell)->len, fp); } } break; case T_KEYWORD: { KEYWORD* p = GET_KEYWORD(cell); fwrite(p->data, 1, p->len, fp); fputc(':', fp); } break; case T_SLOT: fprintf(fp, "#<slot:%d>", GET_SLOT(cell)); break; // FIXME - arbitrary recursion case T_CONS: fputc('(', fp); if (tab) ++tab; int did = 0; while(1) { int pair = CONSP(CAR(cell)); if (!did && tab && pair && !CONSP(CAR(CAR(cell)))) { fprintf(fp, "\n%*s", (tab-1)*2, ""); } internal_generic_output(fp, CAR(cell), strict, tab); cell = CDR(cell); if (NULLP(cell)) { break; } did = (tab && pair); if (did) { fprintf(fp, "\n%*s", (tab-1)*2, ""); } else fputc(' ', fp); if (!CONSP(cell)) { fputs(". ", fp); internal_generic_output(fp, cell, strict, tab); break; } } fputc(')', fp); break; // FIXME - arbitrary recursion case T_VECTOR: { VECTOR *vec = GET_VECTOR(cell); fputs("#(", fp); if (vec->len > 0) { int i = 0; internal_generic_output(fp, vec->data[i++], strict, tab); while(i < vec->len) { fputc(' ', fp); internal_generic_output(fp, vec->data[i++], strict, tab); } } fputc(')', fp); break; } case T_FUNC: fprintf(fp, "#<primitive:%s>", GET_FUNC(cell)->name); break; case T_COMPILED_LAMBDA: fprintf(fp, "#<compiled-lambda:0x%08x>", AS_LITERAL(cell)); break; { if (tab) ++tab; COMPILED_LAMBDA *l = GET_COMPILED_LAMBDA(cell); fprintf(fp, "#<%s %d%s:%d/%d", l->is_macro ? "macro" : "lambda", l->argc, l->rest ? "+" : "", l->depth, l->max_slot); if (tab) { fprintf(fp, "\n%*s", (tab-1)*2, ""); } else { fputc(' ', fp); } internal_generic_output(fp, l->body, strict, tab); fputc('>', fp); } break; case T_CLOSURE: fprintf(fp, "#<closure:0x%08x>", AS_LITERAL(cell)); break; { if (tab) ++tab; CLOSURE *c = GET_CLOSURE(cell); fprintf(fp, "#<closure "); if (tab) { fprintf(fp, "\n%*s", (tab-1)*2, ""); } internal_print_env(fp, c->env); if (tab) { fprintf(fp, "\n%*s", (tab-1)*2, ""); } fputc(' ', fp); internal_generic_output(fp, c->compiled_lambda, strict, tab); fputc('>', fp); } break; case T_EXCEPTION: fputs("#<exception:", fp); fwrite(GET_EXCEPTION(cell)->data, 1, GET_EXCEPTION(cell)->len, fp); fputc('>', fp); break; case T_REIFIED_CONTINUATION: fprintf(fp, "#<continuation:0x%08x>", (int)GET_REIFIED_CONTINUATION(cell)->cont); break; case T_STACK_FRAME: { STACK_FRAME* p = GET_STACK_FRAME(cell); fputs("#<stack-frame [", fp); int i; for(i = 0; i < p->len; ++i) { if (i) fputc(' ', fp); fprintf(fp, "0x%08x", (int)p->cells[i]); } fputs("]>", fp); } break; case T_ENV: fprintf(fp, "#<env:count=%d>", GET_ENV(cell)->count); break; case T_RELOC: fprintf(fp, "#<reloc:0x%08x>", (int)GET_RELOC(cell)); break; case T_PORT: fprintf(fp, "#<port:%s>", GET_PORT(cell)->data); break; case T_DB_CONNECTION: fprintf(fp, "#<db-connection>"); break; case T_DB_RESULT: fprintf(fp, "#<db-result>"); break; case T_RECORD: fprintf(fp, "#<record>"); break; default: fprintf(fp, "#<%s-%02x:%08x>", IS_LITERAL(cell) ? "literal" : "pointer", GET_TYPE(cell), AS_LITERAL(cell) ); break; } }
void init_player(int player, int option) { int i, num; struct action_node *next; if (option != INIT_PLAYER_INACTIVE) players[player].active = 1; else players[player].active = 0; if (option != INIT_PLAYER_RESET) { switch (option) { case INIT_PLAYER_HUMAN: sprintf(GET_NAME(player), "Player %d", get_active_players()); players[player].ai = 0; players[player].portrait = LEADER_RONNIE; break; case INIT_PLAYER_AI: players[player].ai = 1; while (1) { /* select a random leader but check so it doesn't exist already */ num = randomize(0, NUM_LEADERS - 1); if (player_name_available((char *)leader_names[num])) break; /* end while-loop */ } strcpy(GET_NAME(player), leader_names[num]); players[player].portrait = num; break; } memset(players[player].msg, 0, MAX_MESSAGE_LENGTH+1); players[player].msg_timer = 0; } /* population */ if (option != INIT_PLAYER_RESET || server) { for (i = 0; i < NUM_CITIES; i++) { if (option == INIT_PLAYER_INACTIVE) GET_POPULATION(player, i) = 0; else GET_POPULATION(player, i) = randomize(10, 35); GET_WORLD(player, i) = GET_POPULATION(player, i); /* world state */ } } /* weapons */ for (i = 0; i < NUM_WEAPONS; i++) GET_STOCK(player, i) = 0; GET_STOCK(player, WEAPON_MISSILE_10MT) = 1; GET_STOCK(player, WEAPON_WARHEAD_10MT) = 1; GET_STOCK(player, WEAPON_LNDS) = 1; /* free action list */ while (players[player].action_list != NULL) { next = players[player].action_list->next; free(players[player].action_list); players[player].action_list = next; } GET_PREVIOUS(player) = ACTION_NOTHING; GET_MISSILE(player) = -1; GET_BOMBER(player) = -1; GET_WORLD_MISSILE(player) = 0; GET_WORLD_BOMBER(player) = 0; }
sfnt_load_face( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES FT_Error psnames_error; #endif FT_Bool has_outline; FT_Bool is_apple_sbit; SFNT_Service sfnt = (SFNT_Service)face->sfnt; FT_UNUSED( face_index ); FT_UNUSED( num_params ); FT_UNUSED( params ); /* Load tables */ /* We now support two SFNT-based bitmapped font formats. They */ /* are recognized easily as they do not include a `glyf' */ /* table. */ /* */ /* The first format comes from Apple, and uses a table named */ /* `bhed' instead of `head' to store the font header (using */ /* the same format). It also doesn't include horizontal and */ /* vertical metrics tables (i.e. `hhea' and `vhea' tables are */ /* missing). */ /* */ /* The other format comes from Microsoft, and is used with */ /* WinCE/PocketPC. It looks like a standard TTF, except that */ /* it doesn't contain outlines. */ /* */ FT_TRACE2(( "sfnt_load_face: %08p\n\n", face )); /* do we have outlines in there? */ #ifdef FT_CONFIG_OPTION_INCREMENTAL has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 || tt_face_lookup_table( face, TTAG_glyf ) != 0 || tt_face_lookup_table( face, TTAG_CFF ) != 0 ); #else has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 || tt_face_lookup_table( face, TTAG_CFF ) != 0 ); #endif is_apple_sbit = 0; /* if this font doesn't contain outlines, we try to load */ /* a `bhed' table */ if ( !has_outline && sfnt->load_bhed ) { LOAD_( bhed ); is_apple_sbit = FT_BOOL( !error ); } /* load the font header (`head' table) if this isn't an Apple */ /* sbit font file */ if ( !is_apple_sbit ) { LOAD_( head ); if ( error ) goto Exit; } if ( face->header.Units_Per_EM == 0 ) { error = SFNT_Err_Invalid_Table; goto Exit; } /* the following tables are often not present in embedded TrueType */ /* fonts within PDF documents, so don't check for them. */ LOAD_( maxp ); LOAD_( cmap ); /* the following tables are optional in PCL fonts -- */ /* don't check for errors */ LOAD_( name ); LOAD_( post ); #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES psnames_error = error; #endif /* do not load the metrics headers and tables if this is an Apple */ /* sbit font file */ if ( !is_apple_sbit ) { /* load the `hhea' and `hmtx' tables */ LOADM_( hhea, 0 ); if ( !error ) { LOADM_( hmtx, 0 ); if ( error == SFNT_Err_Table_Missing ) { error = SFNT_Err_Hmtx_Table_Missing; #ifdef FT_CONFIG_OPTION_INCREMENTAL /* If this is an incrementally loaded font and there are */ /* overriding metrics, tolerate a missing `hmtx' table. */ if ( face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs-> get_glyph_metrics ) { face->horizontal.number_Of_HMetrics = 0; error = SFNT_Err_Ok; } #endif } } else if ( error == SFNT_Err_Table_Missing ) { /* No `hhea' table necessary for SFNT Mac fonts. */ if ( face->format_tag == TTAG_true ) { FT_TRACE2(( "This is an SFNT Mac font.\n" )); has_outline = 0; error = SFNT_Err_Ok; } else { error = SFNT_Err_Horiz_Header_Missing; #ifdef FT_CONFIG_OPTION_INCREMENTAL /* If this is an incrementally loaded font and there are */ /* overriding metrics, tolerate a missing `hhea' table. */ if ( face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs-> get_glyph_metrics ) { face->horizontal.number_Of_HMetrics = 0; error = SFNT_Err_Ok; } #endif } } if ( error ) goto Exit; /* try to load the `vhea' and `vmtx' tables */ LOADM_( hhea, 1 ); if ( !error ) { LOADM_( hmtx, 1 ); if ( !error ) face->vertical_info = 1; } if ( error && error != SFNT_Err_Table_Missing ) goto Exit; LOAD_( os2 ); if ( error ) { if ( error != SFNT_Err_Table_Missing ) goto Exit; face->os2.version = 0xFFFFU; } } /* the optional tables */ /* embedded bitmap support */ if ( sfnt->load_eblc ) { LOAD_( eblc ); if ( error ) { /* a font which contains neither bitmaps nor outlines is */ /* still valid (although rather useless in most cases); */ /* however, you can find such stripped fonts in PDFs */ if ( error == SFNT_Err_Table_Missing ) error = SFNT_Err_Ok; else goto Exit; } } LOAD_( pclt ); if ( error ) { if ( error != SFNT_Err_Table_Missing ) goto Exit; face->pclt.Version = 0; } /* consider the kerning and gasp tables as optional */ LOAD_( gasp ); LOAD_( kern ); face->root.num_glyphs = face->max_profile.numGlyphs; /* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */ /* a WWS-only font face. `WWS' stands for `weight', width', and */ /* `slope', a term used by Microsoft's Windows Presentation */ /* Foundation (WPF). This flag has been introduced in version */ /* 1.5 of the OpenType specification (May 2008). */ if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 ) { GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } else { GET_NAME( WWS_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); GET_NAME( WWS_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } /* now set up root fields */ { FT_Face root = &face->root; FT_Int32 flags = root->face_flags; /*********************************************************************/ /* */ /* Compute face flags. */ /* */ if ( has_outline == TRUE ) flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ /* The sfnt driver only supports bitmap fonts natively, thus we */ /* don't set FT_FACE_FLAG_HINTER. */ flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES if ( psnames_error == SFNT_Err_Ok && face->postscript.FormatType != 0x00030000L ) flags |= FT_FACE_FLAG_GLYPH_NAMES; #endif /* fixed width font? */ if ( face->postscript.isFixedPitch ) flags |= FT_FACE_FLAG_FIXED_WIDTH; /* vertical information? */ if ( face->vertical_info ) flags |= FT_FACE_FLAG_VERTICAL; /* kerning available ? */ if ( TT_FACE_HAS_KERNING( face ) ) flags |= FT_FACE_FLAG_KERNING; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* Don't bother to load the tables unless somebody asks for them. */ /* No need to do work which will (probably) not be used. */ if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 && tt_face_lookup_table( face, TTAG_fvar ) != 0 && tt_face_lookup_table( face, TTAG_gvar ) != 0 ) flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; #endif root->face_flags = flags; /*********************************************************************/ /* */ /* Compute style flags. */ /* */ flags = 0; if ( has_outline == TRUE && face->os2.version != 0xFFFFU ) { /* We have an OS/2 table; use the `fsSelection' field. Bit 9 */ /* indicates an oblique font face. This flag has been */ /* introduced in version 1.5 of the OpenType specification. */ if ( face->os2.fsSelection & 512 ) /* bit 9 */ flags |= FT_STYLE_FLAG_ITALIC; else if ( face->os2.fsSelection & 1 ) /* bit 0 */ flags |= FT_STYLE_FLAG_ITALIC; if ( face->os2.fsSelection & 32 ) /* bit 5 */ flags |= FT_STYLE_FLAG_BOLD; } else { /* this is an old Mac font, use the header field */ if ( face->header.Mac_Style & 1 ) flags |= FT_STYLE_FLAG_BOLD; if ( face->header.Mac_Style & 2 ) flags |= FT_STYLE_FLAG_ITALIC; } root->style_flags = flags; /*********************************************************************/ /* */ /* Polish the charmaps. */ /* */ /* Try to set the charmap encoding according to the platform & */ /* encoding ID of each charmap. */ /* */ tt_face_build_cmaps( face ); /* ignore errors */ /* set the encoding fields */ { FT_Int m; for ( m = 0; m < root->num_charmaps; m++ ) { FT_CharMap charmap = root->charmaps[m]; charmap->encoding = sfnt_find_encoding( charmap->platform_id, charmap->encoding_id ); #if 0 if ( root->charmap == NULL && charmap->encoding == FT_ENCODING_UNICODE ) { /* set 'root->charmap' to the first Unicode encoding we find */ root->charmap = charmap; } #endif } } #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* * Now allocate the root array of FT_Bitmap_Size records and * populate them. Unfortunately, it isn't possible to indicate bit * depths in the FT_Bitmap_Size record. This is a design error. */ { FT_UInt i, count; #ifndef FT_CONFIG_OPTION_OLD_INTERNALS count = face->sbit_num_strikes; #else count = (FT_UInt)face->num_sbit_strikes; #endif if ( count > 0 ) { FT_Memory memory = face->root.stream->memory; FT_UShort em_size = face->header.Units_Per_EM; FT_Short avgwidth = face->os2.xAvgCharWidth; FT_Size_Metrics metrics; if ( em_size == 0 || face->os2.version == 0xFFFFU ) { avgwidth = 0; em_size = 1; } if ( FT_NEW_ARRAY( root->available_sizes, count ) ) goto Exit; for ( i = 0; i < count; i++ ) { FT_Bitmap_Size* bsize = root->available_sizes + i; error = sfnt->load_strike_metrics( face, i, &metrics ); if ( error ) goto Exit; bsize->height = (FT_Short)( metrics.height >> 6 ); bsize->width = (FT_Short)( ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size ); bsize->x_ppem = metrics.x_ppem << 6; bsize->y_ppem = metrics.y_ppem << 6; /* assume 72dpi */ bsize->size = metrics.y_ppem << 6; } root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; root->num_fixed_sizes = (FT_Int)count; } } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ /* a font with no bitmaps and no outlines is scalable; */ /* it has only empty glyphs then */ if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) ) root->face_flags |= FT_FACE_FLAG_SCALABLE; /*********************************************************************/ /* */ /* Set up metrics. */ /* */ if ( FT_IS_SCALABLE( root ) ) { /* XXX What about if outline header is missing */ /* (e.g. sfnt wrapped bitmap)? */ root->bbox.xMin = face->header.xMin; root->bbox.yMin = face->header.yMin; root->bbox.xMax = face->header.xMax; root->bbox.yMax = face->header.yMax; root->units_per_EM = face->header.Units_Per_EM; /* XXX: Computing the ascender/descender/height is very different */ /* from what the specification tells you. Apparently, we */ /* must be careful because */ /* */ /* - not all fonts have an OS/2 table; in this case, we take */ /* the values in the horizontal header. However, these */ /* values very often are not reliable. */ /* */ /* - otherwise, the correct typographic values are in the */ /* sTypoAscender, sTypoDescender & sTypoLineGap fields. */ /* */ /* However, certain fonts have these fields set to 0. */ /* Rather, they have usWinAscent & usWinDescent correctly */ /* set (but with different values). */ /* */ /* As an example, Arial Narrow is implemented through four */ /* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */ /* */ /* Strangely, all fonts have the same values in their */ /* sTypoXXX fields, except ARIALNB which sets them to 0. */ /* */ /* On the other hand, they all have different */ /* usWinAscent/Descent values -- as a conclusion, the OS/2 */ /* table cannot be used to compute the text height reliably! */ /* */ /* The ascender/descender/height are computed from the OS/2 table */ /* when found. Otherwise, they're taken from the horizontal */ /* header. */ /* */ root->ascender = face->horizontal.Ascender; root->descender = face->horizontal.Descender; root->height = (FT_Short)( root->ascender - root->descender + face->horizontal.Line_Gap ); #if 0 /* if the line_gap is 0, we add an extra 15% to the text height -- */ /* this computation is based on various versions of Times New Roman */ if ( face->horizontal.Line_Gap == 0 ) root->height = (FT_Short)( ( root->height * 115 + 50 ) / 100 ); #endif /* 0 */ #if 0 /* some fonts have the OS/2 "sTypoAscender", "sTypoDescender" & */ /* "sTypoLineGap" fields set to 0, like ARIALNB.TTF */ if ( face->os2.version != 0xFFFFU && root->ascender ) { FT_Int height; root->ascender = face->os2.sTypoAscender; root->descender = -face->os2.sTypoDescender; height = root->ascender + root->descender + face->os2.sTypoLineGap; if ( height > root->height ) root->height = height; } #endif /* 0 */ root->max_advance_width = face->horizontal.advance_Width_Max; root->max_advance_height = (FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max : root->height ); /* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */ /* Adjust underline position from top edge to centre of */ /* stroke to convert TrueType meaning to FreeType meaning. */ root->underline_position = face->postscript.underlinePosition - face->postscript.underlineThickness / 2; root->underline_thickness = face->postscript.underlineThickness; } }
void trigedit_parse(struct descriptor_data *d, char *arg) { int i = 0; switch (OLC_MODE(d)) { case TRIGEDIT_MAIN_MENU: switch (tolower(*arg)) { case 'q': if (OLC_VAL(d)) { /* Anything been changed? */ if (!GET_TRIG_TYPE(OLC_TRIG(d))) { send_to_char("Invalid Trigger Type! Answer a to abort quit!\r\n", d->character); } send_to_char("Do you wish to save the changes to the trigger? (y/n): ", d->character); OLC_MODE(d) = TRIGEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = TRIGEDIT_NAME; send_to_char("Name: ", d->character); break; case '2': OLC_MODE(d) = TRIGEDIT_INTENDED; send_to_char("0: Mobiles, 1: Objects, 2: Rooms: ", d->character); break; case '3': OLC_MODE(d) = TRIGEDIT_TYPES; trigedit_disp_types(d); break; case '4': OLC_MODE(d) = TRIGEDIT_NARG; send_to_char("Numeric argument: ", d->character); break; case '5': OLC_MODE(d) = TRIGEDIT_ARGUMENT; send_to_char("Argument: ", d->character); break; case '6': OLC_MODE(d) = TRIGEDIT_COMMANDS; send_to_char( "Enter trigger commands: (/s saves /h for help)\r\n\r\n", d->character); d->backstr = NULL; if (OLC_STORAGE(d)) { send_to_char(OLC_STORAGE(d), d->character); d->backstr = str_dup(OLC_STORAGE(d)); } d->str = &OLC_STORAGE(d); d->max_str = MAX_CMD_LENGTH; d->mail_to = 0; OLC_VAL(d) = 1; break; default: trigedit_disp_menu(d); return; } return; case TRIGEDIT_CONFIRM_SAVESTRING: switch(tolower(*arg)) { case 'y': trigedit_save(d); sprintf(buf, "OLC: %s edits trigger %d", GET_NAME(d->character), OLC_NUM(d)); mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE); /* fall through */ case 'n': cleanup_olc(d, CLEANUP_ALL); return; case 'a': /* abort quitting */ break; default: send_to_char("Invalid choice!\r\n", d->character); send_to_char("Do you wish to save the trigger? : ", d->character); return; } break; case TRIGEDIT_NAME: if (OLC_TRIG(d)->name) free(OLC_TRIG(d)->name); OLC_TRIG(d)->name = str_dup((arg && *arg) ? arg : "undefined"); OLC_VAL(d)++; break; case TRIGEDIT_INTENDED: if ((atoi(arg)>=MOB_TRIGGER) || (atoi(arg)<=WLD_TRIGGER)) OLC_TRIG(d)->attach_type = atoi(arg); OLC_VAL(d)++; break; case TRIGEDIT_NARG: OLC_TRIG(d)->narg = atoi(arg); OLC_VAL(d)++; break; case TRIGEDIT_ARGUMENT: OLC_TRIG(d)->arglist = (*arg?str_dup(arg):NULL); OLC_VAL(d)++; break; case TRIGEDIT_TYPES: if ((i = atoi(arg)) == 0) break; else if (!((i < 0) || (i > NUM_TRIG_TYPE_FLAGS))) TOGGLE_BIT((GET_TRIG_TYPE(OLC_TRIG(d))), 1 << (i - 1)); OLC_VAL(d)++; trigedit_disp_types(d); return; case TRIGEDIT_COMMANDS: break; } OLC_MODE(d) = TRIGEDIT_MAIN_MENU; trigedit_disp_menu(d); }
void make_corpse(struct char_data *ch) { struct obj_data *corpse, *o; struct obj_data *money; char buf[MAX_STRING_LENGTH]; int i; char *strdup(char *source); struct obj_data *create_money( int amount ); CREATE(corpse, struct obj_data, 1); clear_object(corpse); corpse->item_number = NOWHERE; corpse->in_room = NOWHERE; corpse->name = strdup("corpse"); sprintf(buf, "Corpse of %s is lying here.", (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch))); corpse->description = strdup(buf); sprintf(buf, "Corpse of %s", (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch))); corpse->short_description = strdup(buf); corpse->contains = ch->carrying; if ( (GET_GOLD(ch)>0) && ( IS_NPC(ch) || (ch->desc) ) ) { money = create_money(GET_GOLD(ch)); GET_GOLD(ch)=0; obj_to_obj(money,corpse); } corpse->obj_flags.type_flag = ITEM_CONTAINER; corpse->obj_flags.wear_flags = ITEM_TAKE; corpse->obj_flags.value[0] = 0; /* You can't store stuff in a corpse */ corpse->obj_flags.value[3] = 1; /* corpse identifyer */ corpse->obj_flags.weight = GET_WEIGHT(ch)+IS_CARRYING_W(ch); corpse->obj_flags.cost_per_day = 100000; if (IS_NPC(ch)) corpse->obj_flags.timer = MAX_NPC_CORPSE_TIME; else corpse->obj_flags.timer = MAX_PC_CORPSE_TIME; for (i=0; i<MAX_WEAR; i++) if (ch->equipment[i]) obj_to_obj(unequip_char(ch, i), corpse); ch->carrying = 0; IS_CARRYING_N(ch) = 0; IS_CARRYING_W(ch) = 0; corpse->next = object_list; object_list = corpse; for(o = corpse->contains; o; o->in_obj = corpse, o = o->next_content); object_list_new_owner(corpse, 0); obj_to_room(corpse, ch->in_room); }
/* code for skill improvement through use */ void improve_skill(struct char_data *ch, int skill, int chance) { int percent = GET_SKILL(ch, skill); int newpercent, max; char skillbuf[MAX_STRING_LENGTH]; char mybuf[256]; max = max_lvl_skill[1][spells[find_skill_num_def(skill)].difficulty][(int) GET_LEVEL(ch)]; if (percent >= max || IS_NPC(ch)) return; if (number(1, (chance * 50)) > (GET_WIS(ch) + GET_INT(ch))) return; newpercent = 1; if (number(1, 120) <= GET_WIS(ch)) newpercent++; if (number(1, 120) <= GET_INT(ch)) newpercent++; percent += newpercent; percent = MIN(percent, max); SET_SKILL(ch, skill, percent); if (newpercent) { sprintf(mybuf, "SKILLIMPROVE: %s improved skill %s, int = %d, wis = %d, improved by = %d, now = %d", GET_NAME(ch), spells[find_skill_num_def(skill)].command, GET_INT(ch), GET_WIS(ch), newpercent, percent); mudlog(mybuf, 'D', COM_IMMORT, TRUE); sprintf(skillbuf, "{RYou feel your skill in {W%s {Rimproving.{x\r\n", spells[find_skill_num_def(skill)].command); send_to_char(skillbuf, ch); } }
/* * Alert: As of bpl14, this function returns the following codes: * < 0 Victim died. * = 0 No damage. * > 0 How much damage done. */ int damage(struct char_data * ch, struct char_data * victim, int dam, int attacktype) { if (GET_POS(victim) <= POS_DEAD) { log("SYSERR: Attempt to damage corpse '%s' in room #%d by '%s'.", GET_NAME(victim), GET_ROOM_VNUM(IN_ROOM(victim)), GET_NAME(ch)); die(victim, ch); return (0); /* -je, 7/7/92 */ } /* peaceful rooms */ if (ch->nr != real_mobile(DG_CASTER_PROXY) && ch != victim && ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) { send_to_char("This room just has such a peaceful, easy feeling...\r\n", ch); return (0); } /* shopkeeper protection */ if (!ok_damage_shopkeeper(ch, victim)) return (0); /* You can't damage an immortal! */ if (!IS_NPC(victim) && (GET_LEVEL(victim) >= LVL_IMMORT)) dam = 0; if (victim != ch) { /* Start the attacker fighting the victim */ if (char_within_range_of_vict(ch, victim) && GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL)) set_fighting(ch, victim); /* Start the victim fighting the attacker */ if (char_within_range_of_vict(victim, ch) && GET_POS(victim) > POS_STUNNED && (FIGHTING(victim) == NULL)) { set_fighting(victim, ch); if (MOB_FLAGGED(victim, MOB_MEMORY) && !IS_NPC(ch)) remember(victim, ch); } } /* If you attack a pet, it hates your guts */ if (victim->master == ch) stop_follower(victim); /* If the attacker is invisible, he becomes visible */ if (AFF_FLAGGED(ch, AFF_INVISIBLE | AFF_HIDE)) appear(ch); /* Cut damage in half if victim has sanct, to a minimum 1 */ if (AFF_FLAGGED(victim, AFF_SANCTUARY) && dam >= 2) dam /= 2; /* Check for PK if this is not a PK MUD */ if (!pk_allowed) { check_killer(ch, victim); if (PLR_FLAGGED(ch, PLR_KILLER) && (ch != victim)) dam = 0; } /* Set the maximum damage per round and subtract the hit points */ dam = MAX(MIN(dam, 900), 0); GET_HIT(victim) -= dam; /* Gain exp for the hit */ if (ch != victim) gain_exp(ch, GET_LEVEL(victim) * dam); update_pos(victim); /* * skill_message sends a message from the messages file in lib/misc. * dam_message just sends a generic "You hit $n extremely hard.". * skill_message is preferable to dam_message because it is more * descriptive. * * If we are _not_ attacking with a weapon (i.e. a spell), always use * skill_message. If we are attacking with a weapon: If this is a miss or a * death blow, send a skill_message if one exists; if not, default to a * dam_message. Otherwise, always send a dam_message. */ if (!IS_WEAPON(attacktype)) skill_message(dam, ch, victim, attacktype); else { if (GET_POS(victim) == POS_DEAD || dam == 0) { if (!skill_message(dam, ch, victim, attacktype)) dam_message(dam, ch, victim, attacktype); } else { dam_message(dam, ch, victim, attacktype); } } /* Use send_to_char -- act() doesn't send message if you are DEAD. */ switch (GET_POS(victim)) { case POS_MORTALLYW: act("$n is mortally wounded, and will die soon, if not aided.", TRUE, victim, 0, 0, TO_ROOM); send_to_char("You are mortally wounded, and will die soon, if not aided.\r\n", victim); break; case POS_INCAP: act("$n is incapacitated and will slowly die, if not aided.", TRUE, victim, 0, 0, TO_ROOM); send_to_char("You are incapacitated an will slowly die, if not aided.\r\n", victim); break; case POS_STUNNED: act("$n is stunned, but will probably regain consciousness again.", TRUE, victim, 0, 0, TO_ROOM); send_to_char("You're stunned, but will probably regain consciousness again.\r\n", victim); break; case POS_DEAD: act("$n is dead! R.I.P.", FALSE, victim, 0, 0, TO_ROOM); send_to_char("You are dead! Sorry...\r\n", victim); break; default: /* >= POSITION SLEEPING */ if (dam > (GET_MAX_HIT(victim) / 4)) send_to_char("That really did HURT!\r\n", victim); if (GET_HIT(victim) < (GET_MAX_HIT(victim) / 4)) { sprintf(buf2, "%sYou wish that your wounds would stop BLEEDING so much!%s\r\n", CCRED(victim, C_SPR), CCNRM(victim, C_SPR)); send_to_char(buf2, victim); if (ch != victim && MOB_FLAGGED(victim, MOB_WIMPY)) do_flee(victim, NULL, 0, 0); } if (!IS_NPC(victim) && GET_WIMP_LEV(victim) && (victim != ch) && GET_HIT(victim) < GET_WIMP_LEV(victim) && GET_HIT(victim) > 0) { send_to_char("You wimp out, and attempt to flee!\r\n", victim); do_flee(victim, NULL, 0, 0); } break; } /* Help out poor linkless people who are attacked */ if (!IS_NPC(victim) && !(victim->desc) && GET_POS(victim) > POS_STUNNED) { do_flee(victim, NULL, 0, 0); if (!FIGHTING(victim)) { act("$n is rescued by divine forces.", FALSE, victim, 0, 0, TO_ROOM); GET_WAS_IN(victim) = IN_ROOM(victim); char_from_room(victim); char_to_room(victim, 0); } } /* stop someone from fighting if they're stunned or worse */ if ((GET_POS(victim) <= POS_STUNNED) && (FIGHTING(victim) != NULL)) stop_fighting(victim); /* Uh oh. Victim died. */ if (GET_POS(victim) == POS_DEAD) { if ((ch != victim) && (IS_NPC(victim) || victim->desc)) { if (AFF_FLAGGED(ch, AFF_GROUP)) group_gain(ch, victim); else solo_gain(ch, victim); } if (!IS_NPC(victim)) { sprintf(buf2, "%s killed by %s at %s", GET_NAME(victim), GET_NAME(ch), world[IN_ROOM(victim)].name); mudlog(buf2, BRF, LVL_IMMORT, TRUE); if (MOB_FLAGGED(ch, MOB_MEMORY)) forget(ch, victim); } die(victim, ch); return (-1); } return (dam); }
int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd, char *arg, int mode) { int cost; const char *action_table[] = { "smile", "dance", "sigh", "blush", "burp", "cough", "fart", "twiddle", "yawn" }; if (!cmd && !rand_number(0, 5)) { do_action(recep, NULL, find_command(action_table[rand_number(0, 8)]), 0); return (FALSE); } if (!ch->desc || IS_NPC(ch)) return (FALSE); if (!CMD_IS("offer") && !CMD_IS("rent")) return (FALSE); if (!AWAKE(recep)) { send_to_char(ch, "%s is unable to talk to you...\r\n", HSSH(recep)); return (TRUE); } if (!CAN_SEE(recep, ch)) { act("$n says, 'I don't deal with people I can't see!'", FALSE, recep, 0, 0, TO_ROOM); return (TRUE); } if (free_rent) { act("$n tells you, 'Rent is free here. Just quit, and your objects will be saved!'", FALSE, recep, 0, ch, TO_VICT); return (1); } if (CMD_IS("rent")) { char buf[128]; if (!(cost = Crash_offer_rent(ch, recep, FALSE, mode))) return (TRUE); if (mode == RENT_FACTOR) snprintf(buf, sizeof(buf), "$n tells you, 'Rent will cost you %d gold coins per day.'", cost); else if (mode == CRYO_FACTOR) snprintf(buf, sizeof(buf), "$n tells you, 'It will cost you %d gold coins to be frozen.'", cost); act(buf, FALSE, recep, 0, ch, TO_VICT); if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) { act("$n tells you, '...which I see you can't afford.'", FALSE, recep, 0, ch, TO_VICT); return (TRUE); } if (cost && (mode == RENT_FACTOR)) Crash_rent_deadline(ch, recep, cost); if (mode == RENT_FACTOR) { act("$n stores your belongings and helps you into your private chamber.", FALSE, recep, 0, ch, TO_VICT); Crash_rentsave(ch, cost); mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s has rented (%d/day, %d tot.)", GET_NAME(ch), cost, GET_GOLD(ch) + GET_BANK_GOLD(ch)); } else { /* cryo */ act("$n stores your belongings and helps you into your private chamber.\r\n" "A white mist appears in the room, chilling you to the bone...\r\n" "You begin to lose consciousness...", FALSE, recep, 0, ch, TO_VICT); Crash_cryosave(ch, cost); mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s has cryo-rented.", GET_NAME(ch)); SET_BIT(PLR_FLAGS(ch), PLR_CRYO); } act("$n helps $N into $S private chamber.", FALSE, recep, 0, ch, TO_NOTVICT); GET_LOADROOM(ch) = GET_ROOM_VNUM(IN_ROOM(ch)); extract_char(ch); /* It saves. */ } else { Crash_offer_rent(ch, recep, TRUE, mode); act("$N gives $n an offer.", FALSE, ch, 0, recep, TO_ROOM); } return (TRUE); }
int cast_spell(struct char_data *ch, struct char_data *tch, struct obj_data *tobj, struct spell_info_type *sptr, char *tar_str) { if (!magic_enabled) return (0); if (!sptr) { extended_mudlog(NRM, SYSL_BUGS, TRUE, "cast_spell() called without a valid sptr: ch: %s, tch: %s", GET_NAME(ch), GET_NAME(tch)); return (0); } if (GET_POS(ch) < sptr->min_position) { switch (GET_POS(ch)) { case POS_SLEEPING: send_to_char("You dream about great magical powers.\r\n", ch); break; case POS_RESTING: send_to_char("You cannot concentrate while resting.\r\n", ch); break; case POS_SITTING: send_to_char("You can't do this sitting!\r\n", ch); break; case POS_FIGHTING: send_to_char("Impossible! You can't concentrate enough!\r\n", ch); break; default: send_to_char("You can't do much of anything like this!\r\n", ch); break; } return (0); } if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == tch)) { send_to_char("You are afraid you might hurt your master!\r\n", ch); return (0); } if ((tch != ch) && IS_SET(sptr->targets, TAR_SELF_ONLY)) { send_to_char("You can only cast this spell upon yourself!\r\n", ch); return (0); } if ((tch == ch) && IS_SET(sptr->targets, TAR_NOT_SELF)) { send_to_char("You cannot cast this spell upon yourself!\r\n", ch); return (0); } if (IS_SET(sptr->routines, MAG_GROUPS) && !AFF_FLAGGED(ch, AFF_GROUP)) { send_to_char("You can't cast this spell if you're not in a group!\r\n",ch); return (0); } if (cast_mtrigger(tch, ch, tar_str, sptr) == 0) return (0); if (cast_otrigger(tobj, ch, tar_str, sptr) == 0) return (0); if (cast_wtrigger(ch, tch, tobj, tar_str, sptr) == 0) return (0); send_to_char(OK, ch); say_spell(ch, sptr, tch, tobj); return (call_magic(ch, tch, tobj, sptr, (GET_SKILL(ch, sptr->skill)/100), CAST_SPELL, tar_str)); }
int Crash_load_objs(struct char_data *ch) { FILE *fl; char fname[MAX_STRING_LENGTH]; char line[256]; int t[10],i,num_of_days; int orig_rent_code; struct obj_data *temp; int locate=0, nr,cost,num_objs=0; struct obj_data *cont_row[MAX_BAG_ROWS]; int rentcode,timed,netcost,gold,account,nitems; if (!get_filename(fname, sizeof(fname), CRASH_FILE, GET_NAME(ch))) return 1; for (i = 0; i < MAX_BAG_ROWS; i++) cont_row[i] = NULL; if (!(fl = fopen(fname, "r"))) { if (errno != ENOENT) { /* if it fails, NOT because of no file */ char buf[MAX_STRING_LENGTH]; sprintf(buf, "SYSERR: READING OBJECT FILE %s (5)", fname); perror(buf); send_to_char(ch, "\r\n********************* NOTICE *********************\r\n" "There was a problem loading your objects from disk.\r\n" "Contact a God for assistance.\r\n"); } mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s entering game with no equipment.", GET_NAME(ch)); return 1; } if (get_line(fl, line)) sscanf(line,"%d %d %d %d %d %d",&rentcode, &timed, &netcost,&gold,&account,&nitems); if (rentcode == RENT_RENTED || rentcode == RENT_TIMEDOUT) { char str[64]; sprintf(str, "%d", SECS_PER_REAL_DAY); num_of_days = (int)((float) (time(0) - timed) / (float)atoi(str)); cost = (int) (netcost * num_of_days); if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) { fclose(fl); mudlog(BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s entering game, rented equipment lost (no $).", GET_NAME(ch)); Crash_crashsave(ch); return 2; } else { GET_BANK_GOLD(ch) -= MAX(cost - GET_GOLD(ch), 0); GET_GOLD(ch) = MAX(GET_GOLD(ch) - cost, 0); save_char(ch); } } switch (orig_rent_code = rentcode) { case RENT_RENTED: mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s un-renting and entering game.", GET_NAME(ch)); break; case RENT_CRASH: mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s retrieving crash-saved items and entering game.", GET_NAME(ch)); break; case RENT_CRYO: mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s un-cryo'ing and entering game.", GET_NAME(ch)); break; case RENT_FORCED: case RENT_TIMEDOUT: mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s retrieving force-saved items and entering game.", GET_NAME(ch)); break; default: mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "WARNING: %s entering game with undefined rent code.", GET_NAME(ch)); break; } temp = NULL; while (get_line(fl, line)) { char tag[6]; int num; /* first, we get the number. Not too hard. */ if(*line == '$' && line[1] == '~') { if (temp) num_objs += handle_obj(temp, ch, locate, cont_row); break; } if (*line == '#') { if (sscanf(line, "#%d", &nr) != 1) { continue; } else { if (temp) num_objs += handle_obj(temp, ch, locate, cont_row); temp = NULL; locate = 0; } /* we have the number, check it, load obj. */ if (nr == NOTHING) { /* then it is unique */ temp = create_obj(); temp->item_number=NOTHING; } else if (nr < 0) { continue; } else { if(nr >= 999999) continue; if(real_object(nr) != NOTHING) { temp=read_object(nr,VIRTUAL); if (!temp) { continue; } } else { log("Nonexistent object %d found in rent file.", nr); continue; } } } tag_argument(line, tag); num = atoi(line); switch(*tag) { case 'A': if (!strcmp(tag, "ADes")) { char error[40]; snprintf(error, sizeof(error)-1, "rent(Ades):%s", temp->name); temp->action_description = fread_string(fl, error); } else if (!strcmp(tag, "Aff ")) { sscanf(line, "%d %d %d", &t[0], &t[1], &t[2]); if (t[0] < MAX_OBJ_AFFECT) { temp->affected[t[0]].location = t[1]; temp->affected[t[0]].modifier = t[2]; } } break; case 'C': if (!strcmp(tag, "Cost")) GET_OBJ_COST(temp) = num; break; case 'D': if (!strcmp(tag, "Desc")) temp->description = strdup(line); break; case 'E': if(!strcmp(tag, "EDes")) { struct extra_descr_data *new_desc; char error[40]; snprintf(error, sizeof(error)-1, "rent(Edes): %s", temp->name); if (temp->item_number != NOTHING && /* Regular object */ temp->ex_description && /* with ex_desc == prototype */ (temp->ex_description == obj_proto[real_object(temp->item_number)].ex_description)) temp->ex_description = NULL; CREATE(new_desc, struct extra_descr_data, 1); new_desc->keyword = fread_string(fl, error); new_desc->description = fread_string(fl, error); new_desc->next = temp->ex_description; temp->ex_description = new_desc; } break; case 'F': if (!strcmp(tag, "Flag")) GET_OBJ_EXTRA(temp) = asciiflag_conv(line); break; case 'L': if(!strcmp(tag, "Loc ")) locate = num; break; case 'N': if (!strcmp(tag, "Name")) temp->name = strdup(line); break; case 'P': if (!strcmp(tag, "Perm")) temp->obj_flags.bitvector = asciiflag_conv(line); break; case 'R': if (!strcmp(tag, "Rent")) GET_OBJ_RENT(temp) = num; break; case 'S': if (!strcmp(tag, "Shrt")) temp->short_description = strdup(line); break; case 'T': if (!strcmp(tag, "Type")) GET_OBJ_TYPE(temp) = num; break; case 'W': if (!strcmp(tag, "Wear")) GET_OBJ_WEAR(temp) = asciiflag_conv(line); else if (!strcmp(tag, "Wght")) GET_OBJ_WEIGHT(temp) = num; break; case 'V': if (!strcmp(tag, "Vals")) { sscanf(line, "%d %d %d %d", &t[0], &t[1], &t[2], &t[3]); for (i = 0; i < 4; i++) GET_OBJ_VAL(temp, i) = t[i]; } break; } } /* Little hoarding check. -gg 3/1/98 */ mudlog(NRM, MAX(LVL_GOD, GET_INVIS_LEV(ch)), TRUE, "%s (level %d) has %d objects (max %d).", GET_NAME(ch), GET_LEVEL(ch), num_objs, max_obj_save); fclose(fl); if ((orig_rent_code == RENT_RENTED) || (orig_rent_code == RENT_CRYO)) return 0; else return 1; }
void mag_summons(int level, struct char_data *ch, struct obj_data *obj, int spellnum, int savetype) { struct char_data *mob = NULL; struct obj_data *tobj, *next_obj; int pfail = 0, msg = 0, fmsg = 0, num = 1, handle_corpse = FALSE, i; mob_vnum mob_num; if (ch == NULL) return; switch (spellnum) { case SPELL_CLONE: msg = 10; fmsg = rand_number(2, 6); /* Random fail message. */ mob_num = MOB_CLONE; pfail = 50; /* 50% failure, should be based on something later. */ break; case SPELL_ANIMATE_DEAD: if (obj == NULL || !IS_CORPSE(obj)) { act(mag_summon_fail_msgs[7], FALSE, ch, 0, 0, TO_CHAR); return; } handle_corpse = TRUE; msg = 11; fmsg = rand_number(2, 6); /* Random fail message. */ mob_num = MOB_ZOMBIE; pfail = 10; /* 10% failure, should vary in the future. */ break; default: return; } if (AFF_FLAGGED(ch, AFF_CHARM)) { send_to_char(ch, "You are too giddy to have any followers!\r\n"); return; } if (rand_number(0, 101) < pfail) { send_to_char(ch, "%s", mag_summon_fail_msgs[fmsg]); return; } for (i = 0; i < num; i++) { if (!(mob = read_mobile(mob_num, VIRTUAL))) { send_to_char(ch, "You don't quite remember how to make that creature.\r\n"); return; } char_to_room(mob, IN_ROOM(ch)); IS_CARRYING_W(mob) = 0; IS_CARRYING_N(mob) = 0; SET_BIT(AFF_FLAGS(mob), AFF_CHARM); if (spellnum == SPELL_CLONE) { /* Don't mess up the prototype; use new string copies. */ mob->player.name = strdup(GET_NAME(ch)); mob->player.short_descr = strdup(GET_NAME(ch)); } act(mag_summon_msgs[msg], FALSE, ch, 0, mob, TO_ROOM); load_mtrigger(mob); add_follower(mob, ch); } if (handle_corpse) { for (tobj = obj->contains; tobj; tobj = next_obj) { next_obj = tobj->next_content; obj_from_obj(tobj); obj_to_char(tobj, mob); } extract_obj(obj); } }
void auto_equip(struct char_data *ch, struct obj_data *obj, int location) { int j; /* Lots of checks... */ if (location > 0) { /* Was wearing it. */ switch (j = (location - 1)) { case WEAR_LIGHT: break; case WEAR_FINGER_R: case WEAR_FINGER_L: if (!CAN_WEAR(obj, ITEM_WEAR_FINGER)) /* not fitting :( */ location = LOC_INVENTORY; break; case WEAR_NECK_1: case WEAR_NECK_2: if (!CAN_WEAR(obj, ITEM_WEAR_NECK)) location = LOC_INVENTORY; break; case WEAR_BODY: if (!CAN_WEAR(obj, ITEM_WEAR_BODY)) location = LOC_INVENTORY; break; case WEAR_HEAD: if (!CAN_WEAR(obj, ITEM_WEAR_HEAD)) location = LOC_INVENTORY; break; case WEAR_LEGS: if (!CAN_WEAR(obj, ITEM_WEAR_LEGS)) location = LOC_INVENTORY; break; case WEAR_FEET: if (!CAN_WEAR(obj, ITEM_WEAR_FEET)) location = LOC_INVENTORY; break; case WEAR_HANDS: if (!CAN_WEAR(obj, ITEM_WEAR_HANDS)) location = LOC_INVENTORY; break; case WEAR_ARMS: if (!CAN_WEAR(obj, ITEM_WEAR_ARMS)) location = LOC_INVENTORY; break; case WEAR_SHIELD: if (!CAN_WEAR(obj, ITEM_WEAR_SHIELD)) location = LOC_INVENTORY; break; case WEAR_ABOUT: if (!CAN_WEAR(obj, ITEM_WEAR_ABOUT)) location = LOC_INVENTORY; break; case WEAR_WAIST: if (!CAN_WEAR(obj, ITEM_WEAR_WAIST)) location = LOC_INVENTORY; break; case WEAR_WRIST_R: case WEAR_WRIST_L: if (!CAN_WEAR(obj, ITEM_WEAR_WRIST)) location = LOC_INVENTORY; break; case WEAR_WIELD: if (!CAN_WEAR(obj, ITEM_WEAR_WIELD)) location = LOC_INVENTORY; break; case WEAR_HOLD: if (CAN_WEAR(obj, ITEM_WEAR_HOLD)) break; if (IS_WARRIOR(ch) && CAN_WEAR(obj, ITEM_WEAR_WIELD) && GET_OBJ_TYPE(obj) == ITEM_WEAPON) break; location = LOC_INVENTORY; break; default: location = LOC_INVENTORY; } if (location > 0) { /* Wearable. */ if (!GET_EQ(ch,j)) { /* * Check the characters's alignment to prevent them from being * zapped through the auto-equipping. */ if (invalid_align(ch, obj) || invalid_class(ch, obj)) location = LOC_INVENTORY; else equip_char(ch, obj, j); } else { /* Oops, saved a player with double equipment? */ mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: autoeq: '%s' already equipped in position %d.", GET_NAME(ch), location); location = LOC_INVENTORY; } } } if (location <= 0) /* Inventory */ obj_to_char(obj, ch); }
void auction_update(void) { long clanid, tax; if (auction.ticks == AUC_NONE) /* No auction */ return; /* Seller left! */ if (!get_ch_by_id_desc(auction.seller) && !get_ch_by_id(auction.seller)) { if (auction.obj) extract_obj(auction.obj); auction_reset(); return; } /* If there is an auction but it's not sold yet */ if (auction.ticks >= AUC_BID && auction.ticks <= AUC_SOLD) { struct char_data *bidder = get_ch_by_id(auction.bidder); struct char_data *seller = get_ch_by_id(auction.seller); /* If there is a bidder and it's not sold yet */ if (bidder && (auction.ticks < AUC_SOLD)) { /* Non colored message */ sprintf(buf, "%s all'asta %s%s%s a %s per %ld coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", GET_NAME(bidder), auction.bid, auction.bid != 1 ? "" : " "); /* Colored message */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m all'asta \x1B[1;37m%s%s%s\x1B[35m a \x1B[1;37m%s\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", GET_NAME(bidder), auction.bid, auction.bid != 1 ? "" : " "); /* send the output */ auction_output(buf2, buf); /* Increment timer */ auction.ticks++; return; } /* If there is no bidder and we ARE in the sold state */ if (!bidder && (auction.ticks == AUC_SOLD)) { /* Colored message */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m VENDUTO\x1B[35m a \x1B[1;37mnessuno\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description, auction.bid, auction.bid != 1 ? " " : " "); /* No color message */ sprintf(buf, "%s e' VENDUTO a nessuno per %ld coin%s.", auction.obj->short_description, auction.bid, auction.bid != 1 ? "s" : " "); /* Send the output away */ auction_output(buf2, buf); /* Give the poor fellow his unsold goods back */ if (seller) if ((IS_CARRYING_W(seller) + GET_OBJ_WEIGHT(auction.obj)) <= CAN_CARRY_W(seller)) { act("Nessuno ha comprato $p.", FALSE, seller, auction.obj, 0, TO_CHAR); obj_to_char(auction.obj, seller); } else { /* Cosi' si evitano le aste per diminuire il peso */ act("Nessuno ha comprato $p, ma hai troppo peso e lo devi lasciare per terra.", FALSE, seller, auction.obj, 0, TO_CHAR); obj_to_room(auction.obj, IN_ROOM(seller)); } /* He's not around to get it back, destroy the object */ else extract_obj(auction.obj); /* Reset the auction for next time */ auction_reset(); return; } /* If there is no bidder and we are not in the sold state */ if (!bidder && (auction.ticks < AUC_SOLD)) { /* Colored output message */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m all'asta \x1B[1;37m%s%s%s\x1B[35m a \x1B[1;37mnessuno\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", auction.bid, auction.bid != 1 ? "s" : ""); /* No color output message */ sprintf(buf, "%s all'asta %s%s%s a nessuno per %ld coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", auction.bid, auction.bid != 1 ? "s" : ""); /* Send output away */ auction_output(buf2, buf); /* Increment timer */ auction.ticks++; return; } /* Sold */ if (bidder && (auction.ticks >= AUC_SOLD)) { /* Colored output */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m VENDUTO\x1B[35m a \x1B[1;37m%s\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description ? auction.obj->short_description : "qualcosa", bidder->player.name ? bidder->player.name : "qualcuno", auction.bid, auction.bid != 1 ? " " : ""); /* Non color output */ sprintf(buf, "%s VENDUTO a %s per %ld coin%s.", auction.obj->short_description ? auction.obj->short_description : "something", bidder->player.name ? bidder->player.name : "someone", auction.bid, auction.bid != 1 ? "s" : ""); /* Send the output */ auction_output(buf2, buf); /* If the seller is still around we give him the money */ if (seller) { act("Congrats! Hai venduto $p!", FALSE, seller, auction.obj, 0, TO_CHAR); if ((clanid = find_clan_by_id(GET_CLAN(seller)))>=0) { tax = auction.bid * PERC_TAS_AUC/100; GET_GOLD(seller) += MAX(0,auction.bid - (auction.bid*PERC_TAS_AUC/100)); clan[clanid].economy.treasure += MAX(0,(auction.bid*PERC_TAS_AUC/100)); clan[clanid].economy.current_entrate += MAX(0,(auction.bid*PERC_TAS_AUC/100)); sprintf(buf,"Paghi %ld di tasse al tuo regno per la vendita.", tax); act(buf, FALSE, seller, auction.obj, 0, TO_CHAR); } else GET_GOLD(seller) += auction.bid; } /* If the bidder is here he gets the object */ if (bidder) { obj_to_char(auction.obj, bidder); act("Congrats! Ora hai $p!", FALSE, bidder, auction.obj, 0, TO_CHAR); } /* Restore the status of the auction */ auction_reset(); return; } } return; }
void Crash_idlesave(struct char_data *ch) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; int j; int cost, cost_eq; FILE *fp; if (IS_NPC(ch)) return; if (!get_filename(buf, sizeof(buf), CRASH_FILE, GET_NAME(ch))) return; if (!(fp = fopen(buf, "w"))) return; Crash_extract_norent_eq(ch); Crash_extract_norents(ch->carrying); cost = 0; Crash_calculate_rent(ch->carrying, &cost); cost_eq = 0; for (j = 0; j < NUM_WEARS; j++) Crash_calculate_rent(GET_EQ(ch, j), &cost_eq); cost += cost_eq; cost *= 2; /* forcerent cost is 2x normal rent */ if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) { for (j = 0; j < NUM_WEARS; j++) /* Unequip players with low gold. */ if (GET_EQ(ch, j)) obj_to_char(unequip_char(ch, j), ch); while ((cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) && ch->carrying) { Crash_extract_expensive(ch->carrying); cost = 0; Crash_calculate_rent(ch->carrying, &cost); cost *= 2; } } if (ch->carrying == NULL) { for (j = 0; j < NUM_WEARS && GET_EQ(ch, j) == NULL; j++) /* Nothing */ ; if (j == NUM_WEARS) { /* No equipment or inventory. */ fclose(fp); Crash_delete_file(GET_NAME(ch)); return; } } rent.net_cost_per_diem = cost; rent.rentcode = RENT_TIMEDOUT; rent.time = time(0); rent.gold = GET_GOLD(ch); rent.account = GET_BANK_GOLD(ch); fprintf(fp,"%d %d %d %d %d %d\r\n",rent.rentcode,rent.time, rent.net_cost_per_diem,rent.gold,rent.account,rent.nitems); for (j = 0; j < NUM_WEARS; j++) { if (GET_EQ(ch, j)) { if (!Crash_save(GET_EQ(ch, j), fp, j + 1)) { fclose(fp); return; } Crash_restore_weight(GET_EQ(ch, j)); Crash_extract_objs(GET_EQ(ch, j)); } } if (!Crash_save(ch->carrying, fp, 0)) { fclose(fp); return; } fprintf(fp, "$~\n"); fclose(fp); Crash_extract_objs(ch->carrying); }
void shopping_sell( char *arg, struct char_data *ch, struct char_data *keeper,int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH]; int cost,temp_cost, i; struct obj_data *temp1; float mult = 0; if(!(is_ok(keeper,ch,shop_nr))) return; if(keeper->generic != 0) for(i = 0; i <= MAX_TRADE; i++) { if(keeper->generic == FAMINE) if(shop_index[shop_nr].type[i] == ITEM_FOOD) { mult = shop_multiplier; /* we're in a famine, we sell food, so we */ break; /* our prices to hell ;-) -DM */ } if(keeper->generic == DWARVES_STRIKE) if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) { mult = shop_multiplier; break; } } only_argument(arg, argm); if(!(*argm)) { sprintf(buf, "%s What do you want to sell??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if (!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item2,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if (IS_OBJ_STAT(temp1, ITEM_NODROP)) { send_to_char ("You can't let go of it, it must be CURSED!\n\r", ch); return; } if (!(trade_with(temp1,shop_nr))||(temp1->obj_flags.cost<1)) { sprintf(buf,shop_index[shop_nr].do_not_buy, GET_NAME(ch)); do_tell(keeper,buf,19); return; } if (GET_GOLD(keeper)<(int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell + ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost))) { sprintf(buf,shop_index[shop_nr].missing_cash1,GET_NAME(ch)); do_tell(keeper,buf,19); return; } cost = temp1->obj_flags.cost; if ((ITEM_TYPE(temp1) == ITEM_WAND) || (ITEM_TYPE(temp1) == ITEM_STAFF)) { if (temp1->obj_flags.value[1]) { cost = (int)cost * (float)(temp1->obj_flags.value[2] / (float) temp1->obj_flags.value[1]); } else { cost = 0; } } else if (ITEM_TYPE(temp1) == ITEM_ARMOR) { if (temp1->obj_flags.value[1]) { cost = (int)cost * (float)(temp1->obj_flags.value[0] / (float)(temp1->obj_flags.value[1])); } else { cost = 0; } } temp1->obj_flags.cost = cost; act("$n sells $p.", FALSE, ch, temp1, 0, TO_ROOM); temp_cost = (int) (temp1->obj_flags.cost*shop_index[shop_nr].profit_sell + ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)); if(temp_cost < 0) temp_cost=0; sprintf(buf,shop_index[shop_nr].message_sell,GET_NAME(ch),temp_cost); /* (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell + ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100))) ; */ do_tell(keeper,buf,19); sprintf(buf,"The shopkeeper now has %s.\n\r", temp1->short_description); send_to_char(buf,ch); if (GET_GOLD(keeper)< temp_cost) { /* (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell + ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100))) { */ sprintf(buf,shop_index[shop_nr].missing_cash1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } GET_GOLD(ch) += temp_cost; /* (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell + ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)); */ GET_GOLD(keeper) -= temp_cost; /* (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell + ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)); */ obj_from_char(temp1); if (temp1 == NULL) { send_to_char("As far as I am concerned, you are out..\n\r",ch); return; } if ((get_obj_in_list(argm,keeper->carrying)) || (GET_ITEM_TYPE(temp1) == ITEM_TRASH)) { extract_obj(temp1); } else { obj_to_char(temp1,keeper); } return; }
void load_char_objs(struct char_data *ch) { FILE *fl; bool found = FALSE; float timegold; struct obj_file_u st; char buf[200]; /* load in aliases and poofs first */ load_char_extra(ch); sprintf(buf, "rent/%s", lower(ch->player.name)); /* r+b is for Binary Reading/Writing */ if (!(fl = fopen(buf, "r+b"))) { logE("Char has no equipment"); return; } rewind(fl); if (!ReadObjs(fl, &st)) { logE("No objects found"); return; } if (str_cmp(st.owner, GET_NAME(ch)) != 0) { logE("Hmm.. bad item-file write. someone is losing thier objects"); fclose(fl); return; } /* if the character has been out for 12 real hours, they are fully healed upon re-entry. if they stay out for 24 full hours, all affects are removed, including bad ones. */ if (st.last_update + 12*SECS_PER_REAL_HOUR < time(0)) RestoreChar(ch); if (st.last_update + 24*SECS_PER_REAL_HOUR < time(0)) RemAllAffects(ch); if (ch->in_room == NOWHERE && st.last_update + 1*SECS_PER_REAL_HOUR > time(0)) { /* you made it back from the crash in time, 1 hour grace period. */ logE("Character reconnecting."); found = TRUE; } else { #if defined(NO_RENT) found = TRUE; logE("No rent was charged."); #else char buf[MAX_STRING_LENGTH]; if (ch->in_room == NOWHERE) logE("Char reconnecting after autorent"); #if defined(NEW_RENT) timegold = (int) ((100*((float)time(0) - st.last_update)) / (SECS_PER_REAL_DAY)); #else timegold = (int) ((st.total_cost*((float)time(0) - st.last_update)) / (SECS_PER_REAL_DAY)); #endif sprintf(buf, "Char ran up charges of %g gold in rent", timegold); logE(buf); sprintf(buf, "You ran up charges of %g gold in rent.\n\r", timegold); send_to_char(buf, ch); GET_GOLD(ch) -= timegold; found = TRUE; if (GET_GOLD(ch) < 0) { logE("Char ran out of money in rent"); send_to_char("You ran out of money, you deadbeat.\n\r", ch); GET_GOLD(ch) = 0; found = FALSE; } #endif } fclose(fl); if (found) obj_store_to_char(ch, &st); else { ZeroRent(GET_NAME(ch)); } /* Save char, to avoid strange data if crashing */ save_char(ch, AUTO_RENT); }
void mobile_activity(void) { struct char_data *ch, *next_ch, *vict; struct obj_data *obj, *best_obj; int door, found, max; memory_rec *names; for (ch = character_list; ch; ch = next_ch) { next_ch = ch->next; if (!IS_MOB(ch)) continue; /* Examine call for special procedure */ if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) { if (mob_index[GET_MOB_RNUM(ch)].func == NULL) { log("SYSERR: %s (#%d): Attempting to call non-existing mob function.", GET_NAME(ch), GET_MOB_VNUM(ch)); REMOVE_BIT(MOB_FLAGS(ch), MOB_SPEC); } else { char actbuf[MAX_INPUT_LENGTH] = ""; if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, actbuf)) continue; /* go to next char */ } } /* If the mob has no specproc, do the default actions */ if (FIGHTING(ch) || !AWAKE(ch)) continue; /* hunt a victim, if applicable */ hunt_victim(ch); /* Scavenger (picking up objects) */ if (MOB_FLAGGED(ch, MOB_SCAVENGER)) if (world[IN_ROOM(ch)].contents && !rand_number(0, 10)) { max = 1; best_obj = NULL; for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj->next_content) if (CAN_GET_OBJ(ch, obj) && GET_OBJ_COST(obj) > max) { best_obj = obj; max = GET_OBJ_COST(obj); } if (best_obj != NULL) { obj_from_room(best_obj); obj_to_char(best_obj, ch); act("$n gets $p.", FALSE, ch, best_obj, 0, TO_ROOM); } } /* Mob Movement */ if (!MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) && ((door = rand_number(0, 18)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) && (!MOB_FLAGGED(ch, MOB_STAY_ZONE) || (world[EXIT(ch, door)->to_room].zone == world[IN_ROOM(ch)].zone))) { perform_move(ch, door, 1); } /* Aggressive Mobs */ if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) { found = FALSE; for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) { if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; if (MOB_FLAGGED(ch, MOB_WIMPY) && AWAKE(vict)) continue; if (MOB_FLAGGED(ch, MOB_AGGRESSIVE ) || (MOB_FLAGGED(ch, MOB_AGGR_EVIL ) && IS_EVIL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_GOOD ) && IS_GOOD(vict))) { /* Can a master successfully control the charmed monster? */ if (aggressive_mob_on_a_leash(ch, ch->master, vict)) continue; hit(ch, vict, TYPE_UNDEFINED); found = TRUE; } } } /* Mob Memory */ if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) { found = FALSE; for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) { if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; for (names = MEMORY(ch); names && !found; names = names->next) { if (names->id != GET_IDNUM(vict)) continue; /* Can a master successfully control the charmed monster? */ if (aggressive_mob_on_a_leash(ch, ch->master, vict)) continue; found = TRUE; act("'Hey! You're the fiend that attacked me!!!', exclaims $n.", FALSE, ch, 0, 0, TO_ROOM); hit(ch, vict, TYPE_UNDEFINED); } } } /* * Charmed Mob Rebellion * * In order to rebel, there need to be more charmed monsters * than the person can feasibly control at a time. Then the * mobiles have a chance based on the charisma of their leader. * * 1-4 = 0, 5-7 = 1, 8-10 = 2, 11-13 = 3, 14-16 = 4, 17-19 = 5, etc. */ if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && num_followers_charmed(ch->master) > (GET_CHA(ch->master) - 2) / 3) { if (!aggressive_mob_on_a_leash(ch, ch->master, ch->master)) { if (CAN_SEE(ch, ch->master) && !PRF_FLAGGED(ch->master, PRF_NOHASSLE)) hit(ch, ch->master, TYPE_UNDEFINED); stop_follower(ch); } } /* Helper Mobs */ if (MOB_FLAGGED(ch, MOB_HELPER) && !AFF_FLAGGED(ch, AFF_BLIND | AFF_CHARM)) { found = FALSE; for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) { if (ch == vict || !IS_NPC(vict) || !FIGHTING(vict)) continue; if (IS_NPC(FIGHTING(vict)) || ch == FIGHTING(vict)) continue; act("$n jumps to the aid of $N!", FALSE, ch, 0, vict, TO_ROOM); hit(ch, FIGHTING(vict), TYPE_UNDEFINED); found = TRUE; } } /* Add new mobile actions here */ } /* end for() */ }
int Board_remove_msg(int board_type, struct char_data *ch, char *arg) { int ind, msg, slot_num; char buf[256], number[MAX_STRING_LENGTH]; struct descriptor_data *d; one_argument(arg, number); if (!*number || !isdigit(*number)) return 0; if (!(msg = atoi(number))) return(0); if (!num_of_msgs[board_type]) { send_to_char("The board is empty!\n\r", ch); return 1; } if (msg < 1 || msg > num_of_msgs[board_type]) { send_to_char("That message exists only in your imagination..\n\r", ch); return 1; } ind = msg - 1; if (!MSG_HEADING(board_type, ind)) { send_to_char("That message appears to be screwed up.\n\r", ch); return 1; } sprintf(buf, "(%s)", GET_NAME(ch)); if (GET_LEVEL(ch) < REMOVE_LVL(board_type) && !(strstr(MSG_HEADING(board_type, ind), buf))) { send_to_char("You are not holy enough to remove other people's messages.\n\r", ch); return 1; } if (GET_LEVEL(ch) < MSG_LEVEL(board_type, ind)) { send_to_char("You can't remove a message holier than yourself.\n\r", ch); return 1; } slot_num = MSG_SLOTNUM(board_type, ind); if (slot_num < 0 || slot_num >= INDEX_SIZE) { log("The board is seriously screwed up."); send_to_char("That message is majorly screwed up.\n\r", ch); return 1; } for (d = descriptor_list; d; d = d->next) if (!d->connected && d->str == &(msg_storage[slot_num])) { send_to_char("At least wait until the author is finished before removing it!\n\r", ch); return 1; } if (msg_storage[slot_num]) free(msg_storage[slot_num]); msg_storage[slot_num] = 0; msg_storage_taken[slot_num] = 0; if (MSG_HEADING(board_type, ind)) free(MSG_HEADING(board_type, ind)); for (; ind < num_of_msgs[board_type] - 1; ind++) { MSG_HEADING(board_type, ind) = MSG_HEADING(board_type, ind+1); MSG_SLOTNUM(board_type, ind) = MSG_SLOTNUM(board_type, ind+1); MSG_LEVEL(board_type, ind) = MSG_LEVEL(board_type, ind+1); } num_of_msgs[board_type]--; send_to_char("Message removed.\n\r", ch); sprintf(buf, "$n just removed message %d.", msg); act(buf, FALSE, ch, 0, 0, TO_ROOM); Board_save_board(board_type); return 1; }