/* 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); } }
void gain_skill_prof(struct creature *ch, int skl) { int learned; if (skl == SKILL_READ_SCROLLS || skl == SKILL_USE_WANDS) learned = 10; else learned = LEARNED(ch); // NPCs don't learn if (IS_NPC(ch)) return; // You can't gain in a skill that you don't really know if (GET_LEVEL(ch) < SPELL_LEVEL(skl, GET_CLASS(ch))) { if (!IS_REMORT(ch)) return; if (GET_LEVEL(ch) < SPELL_LEVEL(skl, GET_REMORT_CLASS(ch))) return; } // Check for remort classes too if (SPELL_GEN(skl, GET_CLASS(ch)) > 0 && GET_REMORT_GEN(ch) < SPELL_GEN(skl, GET_CLASS(ch))) return; if (GET_SKILL(ch, skl) >= (learned - 10)) if ((GET_SKILL(ch, skl) - GET_LEVEL(ch)) <= 66) SET_SKILL(ch, skl, GET_SKILL(ch, skl) + 1); }
void perform_net_load(struct descriptor_data *d, char *arg) { int skill_num, percent; long int cost; skip_spaces(&arg); if (!*arg) { d_printf(d, "Usage: load <program>\r\n"); return; } skill_num = find_skill_num(arg); if (skill_num < 1) { d_printf(d, "Error: program '%s' not found\r\n", arg); return; } if ((SPELL_GEN(skill_num, CLASS_CYBORG) > 0 && GET_CLASS(d->creature) != CLASS_CYBORG) || (GET_REMORT_GEN(d->creature) < SPELL_GEN(skill_num, CLASS_CYBORG)) || (GET_LEVEL(d->creature) < SPELL_LEVEL(skill_num, CLASS_CYBORG))) { d_printf(d, "Error: resources unavailable to load '%s'\r\n", arg); return; } if (GET_SKILL(d->creature, skill_num) >= LEARNED(d->creature)) { d_printf(d, "Program fully installed on local system.\r\n"); return; } cost = GET_SKILL_COST(d->creature, skill_num); d_printf(d, "Program cost: %10ld Account balance; %'" PRId64 "\r\n", cost, d->account->bank_future); if (d->account->bank_future < cost) { d_printf(d, "Error: insufficient funds in your account\r\n"); return; } withdraw_future_bank(d->account, cost); percent = MIN(MAXGAIN(d->creature), MAX(MINGAIN(d->creature), GET_INT(d->creature) * 2)); percent = MIN(LEARNED(d->creature) - GET_SKILL(d->creature, skill_num), percent); SET_SKILL(d->creature, skill_num, GET_SKILL(d->creature, skill_num) + percent); d_printf(d, "Program download: %s terminating, %d percent transfer.\r\n", spell_to_str(skill_num), percent); if (GET_SKILL(d->creature, skill_num) >= LEARNED(d->creature)) d_printf(d, "Program fully installed on local system.\r\n"); else d_printf(d, "Program %d%% installed on local system.\r\n", GET_SKILL(d->creature, skill_num)); }
//Sets a character's default skills, such as languages. void Character::SetSkillDefaults() { if( IS_NPC(this) || IS_HUMAN(this) || IS_DREADLORD(this) || IS_DREADGUARD(this) || IS_FADE(this) || IS_GREYMAN(this) || IS_SEANCHAN(this) || IS_AIEL(this)) SET_SKILL(this, SKILL_NEW_TONGUE, 100); if(IS_NPC(this) || IS_TROLLOC(this) || PLR_FLAGGED(this, PLR_DARKFRIEND)) SET_SKILL(this, SKILL_TROLL_TONGUE, 100); SET_SKILL(this, SKILL_BAREHANDS, 100); if( !IS_NPC(this) && !this->userClans.empty() ) { Clan *clan; for(auto userClanIter = userClans.begin();userClanIter != userClans.end();++userClanIter) { UserClan *userClan = (*userClanIter); clan = ClanUtil::getClan(userClan->getClanId()); if(userClan->getRank() >= clan->bonus_skill_rank) SET_SKILL(this, clan->bonus_skill, clan->bonus_skill_val); } } }
int do_pass_remort_test(struct creature *ch) { int i; // Wipe thier skills for (i = 1; i <= MAX_SKILLS; i++) SET_SKILL(ch, i, 0); do_start(ch, false); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOPROJECT | PRF_ROOMFLAGS | PRF_HOLYLIGHT | PRF_NOHASSLE | PRF_LOG1 | PRF_LOG2 | PRF_NOWIZ); REMOVE_BIT(PLR_FLAGS(ch), PLR_HALT | PLR_INVSTART | PLR_MORTALIZED | PLR_OLCGOD); GET_INVIS_LVL(ch) = 0; GET_COND(ch, DRUNK) = 0; GET_COND(ch, FULL) = 0; GET_COND(ch, THIRST) = 0; // Give em another gen if (GET_REMORT_GEN(ch) == 10) account_set_quest_points(ch->account, ch->account->quest_points + 1); else GET_REMORT_GEN(ch)++; // At gen 1 they enter the world of pk, like it or not if (GET_REMORT_GEN(ch) >= 1 && RAW_REPUTATION_OF(ch) <= 0) gain_reputation(ch, 5); // Whack thier remort invis GET_WIMP_LEV(ch) = 0; // wimpy GET_TOT_DAM(ch) = 0; // cyborg damage // Tell everyone that they remorted char *msg = tmp_sprintf("%s completed gen %d remort test", GET_NAME(ch), GET_REMORT_GEN(ch)); mudlog(LVL_IMMORT, BRF, false, "%s", msg); REMOVE_BIT(ch->in_room->room_flags, ROOM_NORECALL); // Save the char and its implants but not its eq creature_remort(ch); return 1; }
/* Some initializations for characters, including initial skills */ void do_start(struct char_data *ch) { GET_LEVEL(ch) = 1; GET_TOT_LEVEL(ch) = 1; GET_EXP(ch) = 1; GET_CLASS_1(ch) = GET_CLASS(ch); GET_MULTIS(ch) = 1; set_title(ch, NULL); roll_real_abils(ch); GET_MAX_HIT(ch) = 10; GET_MAX_MANA(ch) = 100; GET_MAX_MOVE(ch) = 100; switch (GET_CLASS(ch)) { case CLASS_ADEPT: break; case CLASS_MEDIC: break; case CLASS_BANDIT: SET_SKILL(ch, SKILL_SNEAK, 10); SET_SKILL(ch, SKILL_HIDE, 5); SET_SKILL(ch, SKILL_STEAL, 15); SET_SKILL(ch, SKILL_BACKSTAB, 10); SET_SKILL(ch, SKILL_PICK_LOCK, 10); SET_SKILL(ch, SKILL_TRACK, 10); break; case CLASS_SOLDIER: break; } advance_level(ch); GET_HIT(ch) = GET_MAX_HIT(ch); GET_MANA(ch) = GET_MAX_MANA(ch); GET_MOVE(ch) = GET_MAX_MOVE(ch); GET_COND(ch, THIRST) = 24; GET_COND(ch, HUNGER) = 24; GET_COND(ch, DRUNK) = 0; if (CONFIG_SITEOK_ALL) SET_BIT_AR(PLR_FLAGS(ch), PLR_SITEOK); }
void medit_parse(struct descriptor_data *d, char *arg) { int number; int mob_number; // the RNUM switch(d->edit_mode) { case MEDIT_CONFIRM_EDIT: /* if player hits 'Y' then edit mob */ switch (*arg) { case 'y': case 'Y': medit_disp_menu(d); break; case 'n': case 'N': STATE(d) = CON_PLAYING; /* free up the editing mob */ if (d->edit_mob) Mem->DeleteCh(d->edit_mob); d->edit_mob = NULL; d->edit_number = 0; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("That's not a valid choice!\r\n", CH); send_to_char("Do you wish to edit it?\r\n", CH); break; } break; /* end of MEDIT_CONFIRM_EDIT */ case MEDIT_CONFIRM_SAVESTRING: switch(*arg) { case 'y': case 'Y': // first write to the internal tables if (!from_ip_zone(d->edit_number)) { sprintf(buf,"%s wrote new mob #%ld", GET_CHAR_NAME(d->character), d->edit_number); mudlog(buf, d->character, LOG_WIZLOG, TRUE); } mob_number = real_mobile(d->edit_number); if (mob_number > 0) { // first we go through the entire list of mobs to find out // which are pointing to this prototype; if it is, it gets // replaced struct char_data *i, *temp; int c; for (i = character_list; i; i = i->next) { if (mob_number == i->nr) { // alloc a temp mobile temp = Mem->GetCh(); *temp = *i; *i = *d->edit_mob; /* copy game-time dependent vars over */ i->in_room = temp->in_room; i->nr = mob_number; i->affected = temp->affected; i->carrying = temp->carrying; i->cyberware = temp->cyberware; i->bioware = temp->bioware; // any eq worn for (c = 0; c < NUM_WEARS; ++c) i->equipment[c] = temp->equipment[c]; i->next_in_room = temp->next_in_room; i->next = temp->next; i->next_fighting = temp->next_fighting; i->followers = temp->followers; i->master = temp->master; i->char_specials.fighting = temp->char_specials.fighting; i->char_specials.hunting = temp->char_specials.hunting; i->mob_specials.last_direction = temp->mob_specials.last_direction; i->mob_specials.memory = temp->mob_specials.memory; i->mob_specials.wait_state = temp->mob_specials.wait_state; Mem->ClearCh(temp); } // end if statement } // end for loop // now you can free the old prototype and put in the new one if (mob_proto[mob_number].player.physical_text.keywords) delete [] mob_proto[mob_number].player.physical_text.keywords; if (mob_proto[mob_number].player.title) delete [] mob_proto[mob_number].player.title; if (mob_proto[mob_number].player.physical_text.name) delete [] mob_proto[mob_number].player.physical_text.name; if (mob_proto[mob_number].player.physical_text.room_desc) delete [] mob_proto[mob_number].player.physical_text.room_desc; if (mob_proto[mob_number].player.physical_text.look_desc) delete [] mob_proto[mob_number].player.physical_text.look_desc; if (mob_proto[mob_number].mob_specials.arrive) delete [] mob_proto[mob_number].mob_specials.arrive; if (mob_proto[mob_number].mob_specials.leave) delete [] mob_proto[mob_number].mob_specials.leave; mob_proto[mob_number] = *d->edit_mob; mob_proto[mob_number].nr = mob_number; } else { // if not, we need to make a new spot in the list int counter; int found = FALSE; struct char_data *new_mob_proto; struct index_data *new_mob_index; struct char_data *temp_mob; // two because you are adding one and you need one over new_mob_index = new struct index_data[top_of_mobt + 2]; new_mob_proto = new struct char_data[top_of_mobt + 2]; // count through the tables for (counter = 0; counter < top_of_mobt + 1; counter++) { /* if we haven't found it */ if (!found) { /* check if current virtual is bigger than our virtual */ if (MOB_VNUM_RNUM(counter) > d->edit_number) { /* eureka. insert now */ /*---------*/ new_mob_index[counter].vnum = d->edit_number; new_mob_index[counter].number = 0; new_mob_index[counter].func = NULL; /*---------*/ new_mob_proto[counter] = *(d->edit_mob); new_mob_proto[counter].in_room = NOWHERE; /* it is now safe (and necessary!) to assign real number to * the edit_mob, which has been -1 all this time */ d->edit_mob->nr = counter; /* and assign to prototype as well */ new_mob_proto[counter].nr = counter; found = TRUE; /* insert the other proto at this point */ new_mob_index[counter + 1] = mob_index[counter]; new_mob_proto[counter + 1] = mob_proto[counter]; new_mob_proto[counter + 1].nr = counter + 1; } else { /* just copy from old to new, no num change */ new_mob_proto[counter] = mob_proto[counter]; new_mob_index[counter] = mob_index[counter]; } } else { // if !found else /* we HAVE already found it.. therefore copy to mobile + 1 */ new_mob_index[counter + 1] = mob_index[counter]; new_mob_proto[counter + 1] = mob_proto[counter]; new_mob_proto[counter + 1].nr = counter + 1; } } // for loop through list /* if we STILL haven't found it, means the mobile was > than all * the other mobs.. so insert at end */ if (!found) { new_mob_index[top_of_mobt + 1].vnum = d->edit_number; new_mob_index[top_of_mobt + 1].number = 0; new_mob_index[top_of_mobt + 1].func = NULL; clear_char(new_mob_proto + top_of_mobt + 1); new_mob_proto[top_of_mobt + 1] = *(d->edit_mob); new_mob_proto[top_of_mobt + 1].in_room = NOWHERE; new_mob_proto[top_of_mobt + 1].nr = top_of_mobt + 1; /* it is now safe (and necessary!) to assign real number to * the edit_mob, which has been -1 all this time */ d->edit_mob->nr = top_of_mobt + 1; } top_of_mobt++; /* we also have to renumber all the mobiles currently * * existing in the world. This is because when I start * * extracting mobiles, bad things will happen! */ for (temp_mob = character_list; temp_mob; temp_mob = temp_mob->next) if (GET_MOB_RNUM (temp_mob) >= d->edit_mob->nr) GET_MOB_RNUM (temp_mob)++; /* free and replace old tables */ delete [] mob_proto; delete [] mob_index; mob_proto = new_mob_proto; mob_index = new_mob_index; /* RENUMBER ZONE TABLES HERE, only * * because I ADDED a mobile! * * This code shamelessly ripped off from db.c */ int zone, cmd_no; for (zone = 0; zone <= top_of_zone_table; zone++) for (cmd_no = 0; cmd_no < zone_table[zone].num_cmds; cmd_no++) { switch (ZCMD.command) { case 'M': ZCMD.arg1 = (ZCMD.arg1 >= d->edit_mob->nr ? ZCMD.arg1 + 1 : ZCMD.arg1); break; } } } // finally done putting the mobile into memory send_to_char("Writing mobile to disk...", CH); write_mobs_to_disk(d->character->player_specials->saved.zonenum); // again, here we don't delete it cause we don't want to end up // deleting the strings from the prototypes if (d->edit_mob) Mem->ClearCh(d->edit_mob); d->edit_mob = NULL; STATE(d) = CON_PLAYING; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); send_to_char("Done.\r\n", d->character); break; case 'n': case 'N': send_to_char("Mobile not saved, aborting.\r\n", d->character); STATE(d) = CON_PLAYING; // complete nuke if (d->edit_mob) Mem->DeleteCh(d->edit_mob); d->edit_mob = NULL; d->edit_number = 0; d->edit_zone = 0; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("Invalid choice!\r\n", d->character); send_to_char("Do you wish to save this mobile internally?\r\n", d->character); break; } break; case MEDIT_MAIN_MENU: switch (*arg) { case 'q': case 'Q': d->edit_mode = MEDIT_CONFIRM_SAVESTRING; medit_parse(d, "y"); break; case 'x': case 'X': d->edit_mode = MEDIT_CONFIRM_SAVESTRING; medit_parse(d, "n"); break; case '1': send_to_char("Enter keywords:", CH); d->edit_mode = MEDIT_EDIT_NAMELIST; break; case '2': send_to_char("Enter name:", CH); d->edit_mode = MEDIT_SHORT_DESCR; break; case '3': send_to_char("Enter room description:", CH); d->edit_mode = MEDIT_REG_DESCR; d->str = new (char *); if (!d->str) { mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE); shutdown(); } *(d->str) = NULL; d->max_str = MAX_REG_DESC_LENGTH; d->mail_to = 0; break; case '4': // go to modify.cc send_to_char("Enter look description:\r\n", CH); d->edit_mode = MEDIT_LONG_DESCR; d->str = new (char *); if (!d->str) { mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE); shutdown(); } *(d->str) = NULL; d->max_str = MAX_MESSAGE_LENGTH; d->mail_to = 0; break; case '5': medit_disp_mobflags_menu(d); d->edit_mode = MEDIT_MOB_FLAGS; break; case '6': medit_disp_affected_menu(d); d->edit_mode = MEDIT_AFF_FLAGS; break; case '8': send_to_char("Enter average nuyen: ", CH); d->edit_mode = MEDIT_NUYEN; break; case '9': send_to_char("Enter bonus karma points: ", CH); d->edit_mode = MEDIT_EXPERIENCE; break; case 'a': medit_disp_att_menu(d); d->edit_mode = MEDIT_ATTRIBUTES; break; case 'b': send_to_char("Enter level: ", CH); d->edit_mode = MEDIT_LEVEL; break; case 'c': send_to_char("Enter ballistic armor points: ", CH); d->edit_mode = MEDIT_BALLISTIC; break; case 'd': send_to_char("Enter impact armor points: ", CH); d->edit_mode = MEDIT_IMPACT; break; case 'e': send_to_char("Enter max physical points: ", CH); d->edit_mode = MEDIT_PHYSICAL; break; case 'f': send_to_char("Enter max mental points: ", CH); d->edit_mode = MEDIT_MENTAL; break; case 'g': medit_disp_pos_menu(d); send_to_char("Enter position: ", CH); d->edit_mode = MEDIT_POSITION; break; case 'h': medit_disp_pos_menu(d); send_to_char("Enter default position: ", CH); d->edit_mode = MEDIT_DEFAULT_POSITION; break; case 'i': medit_disp_gender_menu(d); d->edit_mode = MEDIT_GENDER; break; case 'j': send_to_char("Enter weight (in kilograms): ", CH); d->edit_mode = MEDIT_WEIGHT; break; case 'k': send_to_char("Enter height (in centimeters): ", CH); d->edit_mode = MEDIT_HEIGHT; break; case 'l': medit_disp_class_menu(d); d->edit_mode = MEDIT_CLASS; break; case 'm': medit_disp_attack_menu(d); d->edit_mode = MEDIT_ATTACK_TYPE; break; case 'n': medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; break; case 'o': send_to_char("Enter arrive text: ", CH); d->edit_mode = MEDIT_ARRIVE_MSG; break; case 'p': send_to_char("Enter leave text: ", CH); d->edit_mode = MEDIT_LEAVE_MSG; break; default: medit_disp_menu(d); break; } break; case MEDIT_EDIT_NAMELIST: if (MOB->player.physical_text.keywords) delete [] MOB->player.physical_text.keywords; MOB->player.physical_text.keywords = str_dup(arg); medit_disp_menu(d); break; case MEDIT_SHORT_DESCR: if (MOB->player.physical_text.name) delete [] MOB->player.physical_text.name; MOB->player.physical_text.name = str_dup(arg); medit_disp_menu(d); break; case MEDIT_ARRIVE_MSG: if (MOB->mob_specials.arrive) delete [] MOB->mob_specials.arrive; MOB->mob_specials.arrive = str_dup(arg); medit_disp_menu(d); break; case MEDIT_LEAVE_MSG: if (MOB->mob_specials.leave) delete [] MOB->mob_specials.leave; MOB->mob_specials.leave = str_dup(arg); medit_disp_menu(d); break; case MEDIT_REG_DESCR: // you should not come here break; case MEDIT_LONG_DESCR: // you should not come here break; case MEDIT_MOB_FLAGS: number = atoi(arg); if ((number < 0) || (number > MOB_MAX)) medit_disp_mobflags_menu(d); else { if (number == 0) // 0 = quit medit_disp_menu(d); else { MOB_FLAGS(MOB).ToggleBit(number-1); medit_disp_mobflags_menu(d); } } break; case MEDIT_AFF_FLAGS: number = atoi(arg); if ((number < 0) || (number > AFF_MAX)) medit_disp_affected_menu(d); else { if (number == 0) // 0 = quit medit_disp_menu(d); else { AFF_FLAGS(MOB).ToggleBit(number - 1); medit_disp_affected_menu(d); } } break; case MEDIT_NUYEN: number = atoi(arg); if ((number < 0) || (number > 999999)) { send_to_char("Value must range between 0 and 999999.\r\n", CH); send_to_char("Enter average nuyen: ", CH); } else { GET_NUYEN(MOB) = number; send_to_char("Enter average credstick value: ", CH); d->edit_mode = MEDIT_CREDSTICK; } break; case MEDIT_CREDSTICK: number = atoi(arg); if ((number < 0) || (number > 999999)) { send_to_char("Value must range between 0 and 999999.\r\n", CH); send_to_char("Enter average credstick value: ", CH); } else { GET_BANK(MOB) = number; medit_disp_menu(d); } break; case MEDIT_EXPERIENCE: number = atoi(arg); if ((number < 0) || (number > 7500)) { send_to_char("Value must range between 0 and 7500.\r\n", CH); send_to_char("Enter bonus karma points: ", CH); } else { int karma; if (number > (karma=calc_karma(NULL, MOB))) { send_to_char("Bonus karma may not be higher than actual karma. Lowering.\r\n", CH); number = karma; } GET_KARMA(MOB) = number; medit_disp_menu(d); } break; case MEDIT_SKILLS: switch (*arg) { case '0': medit_disp_menu(d); break; case '1': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL1; break; case '2': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL2; break; case '3': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL3; break; case '4': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL4; break; case '5': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL5; break; default: medit_disp_skill_menu(d); break; } break; // end of MEDIT_SKILLS case MEDIT_SKILL1: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL1_VAL; } break; case MEDIT_SKILL2: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL2_VAL; } break; case MEDIT_SKILL3: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL3_VAL; } break; case MEDIT_SKILL4: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL4_VAL; } break; case MEDIT_SKILL5: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL5_VAL; } break; case MEDIT_SKILL1_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[0] = 0; MOB->mob_specials.mob_skills[1] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[1] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[0]) = MOB->mob_specials.mob_skills[1]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], MOB->mob_specials.mob_skills[1]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL2_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[2] = 0; MOB->mob_specials.mob_skills[3] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[3] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[2]) = MOB->mob_specials.mob_skills[3]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[2], MOB->mob_specials.mob_skills[3]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL3_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[4] = 0; MOB->mob_specials.mob_skills[5] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[5] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[4]) = MOB->mob_specials.mob_skills[5]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[4], MOB->mob_specials.mob_skills[5]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL4_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[6] = 0; MOB->mob_specials.mob_skills[7] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[7] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[6]) = MOB->mob_specials.mob_skills[7]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[6], MOB->mob_specials.mob_skills[7]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL5_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[8] = 0; MOB->mob_specials.mob_skills[9] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[9] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[8]) = MOB->mob_specials.mob_skills[9]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[8], MOB->mob_specials.mob_skills[9]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_ATTRIBUTES: switch (*arg) { case '1': send_to_char("Enter body attribute: ", CH); d->edit_mode = MEDIT_BOD; break; case '2': send_to_char("Enter quickness attribute: ", CH); d->edit_mode = MEDIT_QUI; break; case '3': send_to_char("Enter strength attribute: ", CH); d->edit_mode = MEDIT_STR; break; case '4': send_to_char("Enter charisma attribute: ", CH); d->edit_mode = MEDIT_CHA; break; case '5': send_to_char("Enter intelligence attribute: ", CH); d->edit_mode = MEDIT_INT; break; case '6': send_to_char("Enter willpower attribute: ", CH); d->edit_mode = MEDIT_WIL; break; case '7': send_to_char("Enter magic attribute: ", CH); d->edit_mode = MEDIT_MAG; break; case 'q': case 'Q': // back to main menu medit_disp_menu(d); break; default: medit_disp_att_menu(d); break; } break; case MEDIT_BOD: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter body attribute: ", CH); } else { GET_REAL_BOD(MOB) = number; MOB->real_abils.bod_index = number * 100; medit_disp_att_menu(d); } break; case MEDIT_QUI: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter quickness attribute: ", CH); } else { GET_REAL_QUI(MOB) = number; GET_REAL_REA(MOB) = (number + GET_REAL_INT(MOB)) >> 1; medit_disp_att_menu(d); } break; case MEDIT_STR: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter strength attribute: ", CH); } else { GET_REAL_STR(MOB) = number; medit_disp_att_menu(d); } break; case MEDIT_CHA: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter charisma attribute: ", CH); } else { GET_REAL_CHA(MOB) = number; medit_disp_att_menu(d); } break; case MEDIT_INT: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter intelligence attribute: ", CH); } else { GET_REAL_INT(MOB) = number; GET_REAL_REA(MOB) = (number + GET_REAL_QUI(MOB)) >> 1; medit_disp_att_menu(d); } break; case MEDIT_WIL: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter willpower attribute: ", CH); } else { GET_REAL_WIL(MOB) = number; medit_disp_att_menu(d); } break; case MEDIT_MAG: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Value must range between 0 and 50.\r\n", CH); send_to_char("Enter magic attribute: ", CH); } else { MOB->real_abils.mag = number * 100; medit_disp_att_menu(d); } break; case MEDIT_LEVEL: number = atoi(arg); if (number < 0) { send_to_char("Invalid choice.\r\n", CH); send_to_char("Enter level: ", CH); } else { GET_LEVEL(MOB) = number; medit_disp_menu(d); } break; case MEDIT_BALLISTIC: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter ballistic armor points: ", CH); } else { GET_BALLISTIC(MOB) = number; medit_disp_menu(d); } break; case MEDIT_IMPACT: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter impact armor points: ", CH); } else { GET_IMPACT(MOB) = number; medit_disp_menu(d); } break; case MEDIT_PHYSICAL: number = atoi(arg); if ((number < 0) || (number > 10)) { send_to_char("Value must range between 0 and 10.\r\n", CH); send_to_char("Enter max physical points: ", CH); } else { GET_MAX_PHYSICAL(MOB) = number * 100; GET_PHYSICAL(MOB) = number * 100; medit_disp_menu(d); } break; case MEDIT_MENTAL: number = atoi(arg); if ((number < 0) || (number > 10)) { send_to_char("Value must range between 0 and 10.\r\n", CH); send_to_char("Enter max mental points: ", CH); } else { GET_MAX_MENTAL(MOB) = number * 100; GET_MENTAL(MOB) = number * 100; medit_disp_menu(d); } break; case MEDIT_WEIGHT: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter weight (in kilograms): ", CH); } else { GET_WEIGHT(MOB) = number; medit_disp_menu(d); } break; case MEDIT_HEIGHT: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter height (in centimeters): ", CH); } else { GET_HEIGHT(MOB) = number; medit_disp_menu(d); } break; case MEDIT_CLASS: number = atoi(arg); if ((number < 1) || (number > NUM_MOB_CLASSES)) medit_disp_class_menu(d); else { GET_RACE(MOB) = (number - 1); medit_disp_menu(d); } break; case MEDIT_POSITION: number = atoi(arg); if ((number < POS_MORTALLYW) || (number > POS_STANDING)) { send_to_char("Invalid choice.\r\nEnter position: ", CH); medit_disp_pos_menu(d); } else { GET_POS(MOB) = number; medit_disp_menu(d); } break; case MEDIT_DEFAULT_POSITION: number = atoi(arg); if ((number < POS_MORTALLYW) || (number > POS_STANDING)) { send_to_char("Invalid choice.\r\nEnter default position: ", CH); medit_disp_pos_menu(d); } else { GET_DEFAULT_POS(MOB) = number; medit_disp_menu(d); } break; case MEDIT_GENDER: number = atoi(arg); if ((number < 0) || (number > 3)) { send_to_char("Invalid choice.\r\n", CH); medit_disp_gender_menu(d); } else if (number != 0) // 0 = quit GET_SEX(MOB) = (number - 1); medit_disp_menu(d); break; case MEDIT_ATTACK_TYPE: number = atoi(arg); if ((number < 0) || (number > NUM_ATTACK_TYPES)) { send_to_char("Invalid choice.\r\n", CH); medit_disp_attack_menu(d); } else if (number != 0) // 0 = quit MOB->mob_specials.attack_type = number-1 + TYPE_HIT; medit_disp_menu(d); break; } }
void race_affects(struct char_data *ch) { int race; struct affected_type af; extern void affect_join(struct char_data *c, struct affected_type *a, bool ad, bool avg, bool mod, bool avgmod); race = GET_RACE(ch); switch(race) { case RACE_HYLAR: case RACE_DAEWAR: case RACE_NEIDAR: af.type = SPELL_INFRAVISION; af.duration = -1; af.modifier = 0; af.location = APPLY_NONE; af.bitvector = AFF_INFRAVISION; affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE); if ( GET_SKILL(ch, SKILL_NATURAL_HARDINESS) < 60 ) { SET_SKILL(ch, SKILL_NATURAL_HARDINESS, 60); } break; case RACE_SILVANESTI: case RACE_QUALINESTI: case RACE_KAGONESTI: case RACE_HALFELVEN: case RACE_GNOME: af.type = SPELL_INFRAVISION; af.duration = -1; af.modifier = 0; af.location = APPLY_NONE; af.bitvector = AFF_INFRAVISION; affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE); break; case RACE_MINOTAUR: if ( GET_SKILL(ch, SKILL_GORE) < 60 ) { SET_SKILL(ch, SKILL_GORE, 60); } // GET_AC(ch) -= 12; break; case RACE_KENDER: af.type = SPELL_INFRAVISION; af.duration = -1; af.modifier = 0; af.location = APPLY_NONE; af.bitvector = AFF_INFRAVISION; affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE); if ( GET_SKILL(ch, SKILL_HIDE) < 60 ) { SET_SKILL(ch, SKILL_HIDE, 60); } if ( GET_SKILL(ch, SKILL_SNEAK) < 60 ) { SET_SKILL(ch, SKILL_SNEAK, 60); } if ( GET_SKILL(ch, SKILL_PICK_LOCK) < 60 ) { SET_SKILL(ch, SKILL_PICK_LOCK, 60); } if ( GET_SKILL(ch, SKILL_STEAL) < 60 ) { SET_SKILL(ch, SKILL_STEAL, 60); } break; default: break; } }
struct creature * load_player_from_file(const char *path) { struct creature *ch = NULL; char *txt; if (access(path, W_OK)) { errlog("Unable to open xml player file '%s': %s", path, strerror(errno)); return NULL; } xmlDocPtr doc = xmlParseFile(path); if (!doc) { errlog("XML parse error while loading %s", path); return NULL; } xmlNodePtr root = xmlDocGetRootElement(doc); if (!root) { xmlFreeDoc(doc); errlog("XML file %s is empty", path); return NULL; } /* to save memory, only PC's -- not MOB's -- have player_specials */ ch = make_creature(true); ch->player.name = (char *)xmlGetProp(root, (xmlChar *) "name"); ch->char_specials.saved.idnum = xmlGetIntProp(root, "idnum", 0); set_title(ch, ""); ch->player.short_descr = NULL; ch->player.long_descr = NULL; if (ch->points.max_mana < 100) ch->points.max_mana = 100; ch->char_specials.carry_weight = 0; ch->char_specials.carry_items = 0; ch->char_specials.worn_weight = 0; ch->points.armor = 100; ch->points.hitroll = 0; ch->points.damroll = 0; ch->player_specials->saved.speed = 0; // Read in the subnodes for (xmlNodePtr node = root->xmlChildrenNode; node; node = node->next) { if (xmlMatches(node->name, "points")) { ch->points.mana = xmlGetIntProp(node, "mana", 100); ch->points.max_mana = xmlGetIntProp(node, "maxmana", 100); ch->points.hit = xmlGetIntProp(node, "hit", 100); ch->points.max_hit = xmlGetIntProp(node, "maxhit", 100); ch->points.move = xmlGetIntProp(node, "move", 100); ch->points.max_move = xmlGetIntProp(node, "maxmove", 100); } else if (xmlMatches(node->name, "money")) { ch->points.gold = xmlGetIntProp(node, "gold", 0); ch->points.cash = xmlGetIntProp(node, "cash", 0); ch->points.exp = xmlGetIntProp(node, "xp", 0); } else if (xmlMatches(node->name, "stats")) { ch->player.level = xmlGetIntProp(node, "level", 0); ch->player.height = xmlGetIntProp(node, "height", 0); ch->player.weight = xmlGetIntProp(node, "weight", 0); GET_ALIGNMENT(ch) = xmlGetIntProp(node, "align", 0); /*** Temp fix for negative weights ***/ if (ch->player.weight < 0) { calculate_height_weight(ch); } GET_SEX(ch) = 0; char *sex = (char *)xmlGetProp(node, (xmlChar *) "sex"); if (sex != NULL) GET_SEX(ch) = search_block(sex, genders, false); free(sex); GET_RACE(ch) = 0; char *race_name = (char *)xmlGetProp(node, (xmlChar *) "race"); if (race_name != NULL) { struct race *race = race_by_name(race_name, true); if (race != NULL) { GET_RACE(ch) = race->idnum; } } free(race_name); } else if (xmlMatches(node->name, "class")) { GET_OLD_CLASS(ch) = GET_REMORT_CLASS(ch) = GET_CLASS(ch) = -1; char *trade = (char *)xmlGetProp(node, (xmlChar *) "name"); if (trade != NULL) { GET_CLASS(ch) = search_block(trade, class_names, false); free(trade); } trade = (char *)xmlGetProp(node, (xmlChar *) "remort"); if (trade != NULL) { GET_REMORT_CLASS(ch) = search_block(trade, class_names, false); free(trade); } if (IS_CYBORG(ch)) { char *subclass = (char *)xmlGetProp(node, (xmlChar *) "subclass"); if (subclass != NULL) { GET_OLD_CLASS(ch) = search_block(subclass, borg_subchar_class_names, false); free(subclass); } } if (GET_CLASS(ch) == CLASS_MAGE) { ch->player_specials->saved.mana_shield_low = xmlGetLongProp(node, "manash_low", 0); ch->player_specials->saved.mana_shield_pct = xmlGetLongProp(node, "manash_pct", 0); } GET_REMORT_GEN(ch) = xmlGetIntProp(node, "gen", 0); GET_TOT_DAM(ch) = xmlGetIntProp(node, "total_dam", 0); GET_BROKE(ch) = xmlGetIntProp(node, "broken", 0); } else if (xmlMatches(node->name, "time")) { ch->player.time.birth = xmlGetLongProp(node, "birth", 0); ch->player.time.death = xmlGetLongProp(node, "death", 0); ch->player.time.played = xmlGetLongProp(node, "played", 0); ch->player.time.logon = xmlGetLongProp(node, "last", 0); } else if (xmlMatches(node->name, "carnage")) { GET_PKILLS(ch) = xmlGetIntProp(node, "pkills", 0); GET_ARENAKILLS(ch) = xmlGetIntProp(node, "akills", 0); GET_MOBKILLS(ch) = xmlGetIntProp(node, "mkills", 0); GET_PC_DEATHS(ch) = xmlGetIntProp(node, "deaths", 0); RAW_REPUTATION_OF(ch) = xmlGetIntProp(node, "reputation", 0); GET_SEVERITY(ch) = xmlGetIntProp(node, "severity", 0); } else if (xmlMatches(node->name, "attr")) { ch->aff_abils.str = ch->real_abils.str = xmlGetIntProp(node, "str", 0); ch->aff_abils.str = ch->real_abils.str += xmlGetIntProp(node, "stradd", 0) / 10; ch->aff_abils.intel = ch->real_abils.intel = xmlGetIntProp(node, "int", 0); ch->aff_abils.wis = ch->real_abils.wis = xmlGetIntProp(node, "wis", 0); ch->aff_abils.dex = ch->real_abils.dex = xmlGetIntProp(node, "dex", 0); ch->aff_abils.con = ch->real_abils.con = xmlGetIntProp(node, "con", 0); ch->aff_abils.cha = ch->real_abils.cha = xmlGetIntProp(node, "cha", 0); } else if (xmlMatches(node->name, "condition")) { GET_COND(ch, THIRST) = xmlGetIntProp(node, "thirst", 0); GET_COND(ch, FULL) = xmlGetIntProp(node, "hunger", 0); GET_COND(ch, DRUNK) = xmlGetIntProp(node, "drunk", 0); } else if (xmlMatches(node->name, "player")) { GET_WIMP_LEV(ch) = xmlGetIntProp(node, "wimpy", 0); GET_LIFE_POINTS(ch) = xmlGetIntProp(node, "lp", 0); GET_CLAN(ch) = xmlGetIntProp(node, "clan", 0); } else if (xmlMatches(node->name, "home")) { GET_HOME(ch) = xmlGetIntProp(node, "town", 0); GET_HOMEROOM(ch) = xmlGetIntProp(node, "homeroom", 0); GET_LOADROOM(ch) = xmlGetIntProp(node, "loadroom", 0); } else if (xmlMatches(node->name, "quest")) { GET_QUEST(ch) = xmlGetIntProp(node, "current", 0); GET_IMMORT_QP(ch) = xmlGetIntProp(node, "points", 0); GET_QUEST_ALLOWANCE(ch) = xmlGetIntProp(node, "allowance", 0); } else if (xmlMatches(node->name, "bits")) { char *flag = (char *)xmlGetProp(node, (xmlChar *) "flag1"); ch->char_specials.saved.act = hex2dec(flag); free(flag); flag = (char *)xmlGetProp(node, (xmlChar *) "flag2"); ch->player_specials->saved.plr2_bits = hex2dec(flag); free(flag); } else if (xmlMatches(node->name, "frozen")) { ch->player_specials->thaw_time = xmlGetIntProp(node, "thaw_time", 0); ch->player_specials->freezer_id = xmlGetIntProp(node, "freezer_id", 0); } else if (xmlMatches(node->name, "prefs")) { char *flag = (char *)xmlGetProp(node, (xmlChar *) "flag1"); ch->player_specials->saved.pref = hex2dec(flag); free(flag); flag = (char *)xmlGetProp(node, (xmlChar *) "flag2"); ch->player_specials->saved.pref2 = hex2dec(flag); free(flag); flag = (char *)xmlGetProp(node, (xmlChar *) "tongue"); if (flag) GET_TONGUE(ch) = find_tongue_idx_by_name(flag); free(flag); } else if (xmlMatches(node->name, "weaponspec")) { int vnum = xmlGetIntProp(node, "vnum", -1); int level = xmlGetIntProp(node, "level", 0); if (vnum > 0 && level > 0) { for (int i = 0; i < MAX_WEAPON_SPEC; i++) { if (GET_WEAP_SPEC(ch, i).level <= 0) { GET_WEAP_SPEC(ch, i).vnum = vnum; GET_WEAP_SPEC(ch, i).level = level; break; } } } } else if (xmlMatches(node->name, "title")) { char *txt; txt = (char *)xmlNodeGetContent(node); set_title(ch, txt); free(txt); } else if (xmlMatches(node->name, "affect")) { struct affected_type af; init_affect(&af); af.type = xmlGetIntProp(node, "type", 0); af.duration = xmlGetIntProp(node, "duration", 0); af.modifier = xmlGetIntProp(node, "modifier", 0); af.location = xmlGetIntProp(node, "location", 0); af.level = xmlGetIntProp(node, "level", 0); af.aff_index = xmlGetIntProp(node, "index", 0); af.owner = xmlGetIntProp(node, "owner", 0); af.next = NULL; char *instant = (char *)xmlGetProp(node, (xmlChar *) "instant"); if (instant != NULL && strcmp(instant, "yes") == 0) { af.is_instant = 1; } free(instant); char *bits = (char *)xmlGetProp(node, (xmlChar *) "affbits"); af.bitvector = hex2dec(bits); free(bits); affect_to_char(ch, &af); } else if (xmlMatches(node->name, "affects")) { // PCs shouldn't have ANY perm affects if (IS_NPC(ch)) { char *flag = (char *)xmlGetProp(node, (xmlChar *) "flag1"); AFF_FLAGS(ch) = hex2dec(flag); free(flag); flag = (char *)xmlGetProp(node, (xmlChar *) "flag2"); AFF2_FLAGS(ch) = hex2dec(flag); free(flag); flag = (char *)xmlGetProp(node, (xmlChar *) "flag3"); AFF3_FLAGS(ch) = hex2dec(flag); free(flag); } else { AFF_FLAGS(ch) = 0; AFF2_FLAGS(ch) = 0; AFF3_FLAGS(ch) = 0; } } else if (xmlMatches(node->name, "skill")) { char *spellName = (char *)xmlGetProp(node, (xmlChar *) "name"); int index = str_to_spell(spellName); if (index >= 0) { SET_SKILL(ch, index, xmlGetIntProp(node, "level", 0)); } free(spellName); } else if (xmlMatches(node->name, "tongue")) { char *tongue = (char *)xmlGetProp(node, (xmlChar *) "name"); int index = find_tongue_idx_by_name(tongue); if (index >= 0) SET_TONGUE(ch, index, MIN(100, xmlGetIntProp(node, "level", 0))); free(tongue); } else if (xmlMatches(node->name, "alias")) { struct alias_data *alias; CREATE(alias, struct alias_data, 1); alias->type = xmlGetIntProp(node, "type", 0); alias->alias = (char *)xmlGetProp(node, (xmlChar *) "alias"); alias->replacement = (char *)xmlGetProp(node, (xmlChar *) "replace"); if (alias->alias == NULL || alias->replacement == NULL) { free(alias); } else { add_alias(ch, alias); } } else if (xmlMatches(node->name, "description")) { txt = (char *)xmlNodeGetContent(node); ch->player.description = strdup(tmp_gsub(txt, "\n", "\r\n")); free(txt); } else if (xmlMatches(node->name, "poofin")) { POOFIN(ch) = (char *)xmlNodeGetContent(node); } else if (xmlMatches(node->name, "poofout")) { POOFOUT(ch) = (char *)xmlNodeGetContent(node); } else if (xmlMatches(node->name, "immort")) { txt = (char *)xmlGetProp(node, (xmlChar *) "badge"); strncpy(BADGE(ch), txt, 7); BADGE(ch)[7] = '\0'; free(txt); GET_QLOG_LEVEL(ch) = xmlGetIntProp(node, "qlog", 0); GET_INVIS_LVL(ch) = xmlGetIntProp(node, "invis", 0); } else if (xmlMatches(node->name, "rent")) { char *txt; ch->player_specials->rentcode = xmlGetIntProp(node, "code", 0); ch->player_specials->rent_per_day = xmlGetIntProp(node, "perdiem", 0); ch->player_specials->rent_currency = xmlGetIntProp(node, "currency", 0); txt = (char *)xmlGetProp(node, (xmlChar *) "state"); if (txt) ch->player_specials->desc_mode = (enum cxn_state)search_block(txt, desc_modes, false); free(txt); } else if (xmlMatches(node->name, "recentkill")) { struct kill_record *kill; CREATE(kill, struct kill_record, 1); kill->vnum = xmlGetIntProp(node, "vnum", 0); kill->times = xmlGetIntProp(node, "times", 0); GET_RECENT_KILLS(ch) = g_list_prepend(GET_RECENT_KILLS(ch), kill); } else if (xmlMatches(node->name, "grievance")) {
void mag_objectmagic(struct char_data *ch, struct obj_data *obj, char *argument) { int i, k; struct char_data *tch = NULL, *next_tch; struct obj_data *tobj = NULL; if (!magic_enabled) return; one_argument(argument, arg); k = generic_find(arg, FIND_CHAR_ROOM | FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_OBJ_EQUIP, ch, &tch, &tobj); switch (GET_OBJ_TYPE(obj)) { case ITEM_STAFF: act("You tap $p three times on the ground.", FALSE, ch, obj, 0, TO_CHAR); if (obj->action_description) act(obj->action_description, FALSE, ch, obj, 0, TO_ROOM); else act("$n taps $p three times on the ground.", FALSE, ch, obj, 0, TO_ROOM); if (GET_OBJ_VAL(obj, 2) <= 0) { send_to_char("It seems powerless.\r\n", ch); act("Nothing seems to happen.", FALSE, ch, obj, 0, TO_ROOM); } else { GET_OBJ_VAL(obj, 2)--; WAIT_STATE(ch, PULSE_VIOLENCE); /* Level to cast spell at. */ k = GET_OBJ_VAL(obj, 0) ? GET_OBJ_VAL(obj, 0) : DEFAULT_STAFF_LVL; /* * Problem : Area/mass spells on staves can cause crashes. * Solution: Remove the special nature of area/mass spells on staves. * Problem : People like that behavior. * Solution: We special case the area/mass spells here. */ if (HAS_SPELL_ROUTINE(get_spell(GET_OBJ_VAL(obj, 3), __FILE__, __FUNCTION__), MAG_MASSES | MAG_AREAS)) { for (i = 0, tch = world[IN_ROOM(ch)].people; tch; tch = tch->next_in_room) i++; while (i-- > 0) call_magic(ch, NULL, NULL, get_spell(GET_OBJ_VAL(obj, 3), __FILE__, __FUNCTION__), k, CAST_STAFF, 0); } else { for (tch = world[IN_ROOM(ch)].people; tch; tch = next_tch) { next_tch = tch->next_in_room; if (ch != tch) call_magic(ch, tch, NULL, get_spell(GET_OBJ_VAL(obj, 3), __FILE__, __FUNCTION__), k, CAST_STAFF, 0); } } } break; case ITEM_WAND: if (k == FIND_CHAR_ROOM) { if (tch == ch) { act("You point $p at yourself.", FALSE, ch, obj, 0, TO_CHAR); act("$n points $p at $mself.", FALSE, ch, obj, 0, TO_ROOM); } else { act("You point $p at $N.", FALSE, ch, obj, tch, TO_CHAR); if (obj->action_description) act(obj->action_description, FALSE, ch, obj, tch, TO_ROOM); else act("$n points $p at $N.", TRUE, ch, obj, tch, TO_ROOM); } } else if (tobj != NULL) { act("You point $p at $P.", FALSE, ch, obj, tobj, TO_CHAR); if (obj->action_description) act(obj->action_description, FALSE, ch, obj, tobj, TO_ROOM); else act("$n points $p at $P.", TRUE, ch, obj, tobj, TO_ROOM); } else if (IS_SET(get_spell(GET_OBJ_VAL(obj, 3), __FILE__, __FUNCTION__)->routines, MAG_AREAS | MAG_MASSES)) { /* Wands with area spells don't need to be pointed. */ act("You point $p outward.", FALSE, ch, obj, NULL, TO_CHAR); act("$n points $p outward.", TRUE, ch, obj, NULL, TO_ROOM); } else { act("At what should $p be pointed?", FALSE, ch, obj, NULL, TO_CHAR); return; } if (GET_OBJ_VAL(obj, 2) <= 0) { send_to_char("It seems powerless.\r\n", ch); act("Nothing seems to happen.", FALSE, ch, obj, 0, TO_ROOM); return; } GET_OBJ_VAL(obj, 2)--; WAIT_STATE(ch, PULSE_VIOLENCE); if (GET_OBJ_VAL(obj, 0)) call_magic(ch, tch, tobj, get_spell(GET_OBJ_VAL(obj, 3), __FILE__, __FUNCTION__), GET_OBJ_VAL(obj, 0), CAST_WAND, 0); else call_magic(ch, tch, tobj, get_spell(GET_OBJ_VAL(obj, 3), __FILE__, __FUNCTION__), DEFAULT_WAND_LVL, CAST_WAND, 0); break; case ITEM_SCROLL: if (*arg) { if (!k) { act("There is nothing to here to affect with $p.", FALSE, ch, obj, NULL, TO_CHAR); return; } } else tch = ch; act("You recite $p which dissolves.", TRUE, ch, obj, 0, TO_CHAR); if (obj->action_description) act(obj->action_description, FALSE, ch, obj, NULL, TO_ROOM); else act("$n recites $p.", FALSE, ch, obj, NULL, TO_ROOM); WAIT_STATE(ch, PULSE_VIOLENCE); for (i = 1; i <= 3; i++) if (call_magic(ch, tch, tobj, get_spell(GET_OBJ_VAL(obj, i), __FILE__, __FUNCTION__), GET_OBJ_VAL(obj, 0), CAST_SCROLL, 0) <= 0) break; if (obj != NULL) extract_obj(obj); break; case ITEM_POTION: tch = ch; act("You quaff $p.", FALSE, ch, obj, NULL, TO_CHAR); if (obj->action_description) act(obj->action_description, FALSE, ch, obj, NULL, TO_ROOM); else act("$n quaffs $p.", TRUE, ch, obj, NULL, TO_ROOM); WAIT_STATE(ch, PULSE_VIOLENCE); for (i = 1; i <= 3; i++) if (call_magic(ch, ch, NULL, get_spell(GET_OBJ_VAL(obj, i), __FILE__, __FUNCTION__), GET_OBJ_VAL(obj, 0), CAST_POTION, 0) <= 0) break; if (obj != NULL) extract_obj(obj); break; case ITEM_SPELLBOOK: tch = ch; act("You study $p.", FALSE, ch, obj, NULL, TO_CHAR); if (obj->action_description) act(obj->action_description, FALSE, ch, obj, NULL, TO_ROOM); else act("$n studies $p.", TRUE, ch, obj, NULL, TO_ROOM); WAIT_STATE(ch, PULSE_VIOLENCE); for (i = 1; i <= 3; i++) { if (GET_OBJ_VAL(obj, i) < 0) break; if (GET_SKILL(ch, GET_OBJ_VAL(obj, i)) < 1) SET_SKILL(ch, GET_OBJ_VAL(obj, i), GET_OBJ_VAL(obj, 0)); } if (obj != NULL) extract_obj(obj); break; default: extended_mudlog(NRM, SYSL_BUGS, TRUE, "Unknown object_type %d in mag_objectmagic.", GET_OBJ_TYPE(obj)); break; } }
/* Some initializations for characters, including initial skills If mode == 0, then act as though the character was entering the game for the first time. Otherwise, act as though the character is being set to that level. */ void do_start(struct creature *ch, int mode) { void advance_level(struct creature *ch, int8_t keep_internal); int8_t new_player = 0; int i; struct obj_data *implant_save[NUM_WEARS]; struct obj_data *tattoo_save[NUM_WEARS]; // remove implant affects for (i = 0; i < NUM_WEARS; i++) { if (GET_IMPLANT(ch, i)) implant_save[i] = raw_unequip_char(ch, i, EQUIP_IMPLANT); else implant_save[i] = NULL; if (GET_TATTOO(ch, i)) tattoo_save[i] = raw_unequip_char(ch, i, EQUIP_TATTOO); else tattoo_save[i] = NULL; } if (GET_EXP(ch) == 0 && !IS_REMORT(ch) && !IS_VAMPIRE(ch)) new_player = true; GET_LEVEL(ch) = 1; GET_EXP(ch) = 1; if (mode) roll_real_abils(ch); for (i = 1; i <= MAX_SKILLS; i++) SET_SKILL(ch, i, 0); if (IS_VAMPIRE(ch)) GET_LIFE_POINTS(ch) = 1; else GET_LIFE_POINTS(ch) = 3 * (GET_WIS(ch) + GET_CON(ch)) / 40; ch->points.max_hit = 20; ch->points.max_mana = 100; ch->points.max_move = 82; if (IS_TABAXI(ch)) { SET_SKILL(ch, SKILL_CLAW, LEARNED(ch)); SET_SKILL(ch, SKILL_BITE, LEARNED(ch)); } if (IS_ELF(ch)) { SET_SKILL(ch, SKILL_ARCHERY, LEARNED(ch)); } switch (GET_CLASS(ch)) { case CLASS_MAGIC_USER: SET_SKILL(ch, SKILL_PUNCH, 10); break; case CLASS_CLERIC: SET_SKILL(ch, SKILL_PUNCH, 10); break; case CLASS_THIEF: SET_SKILL(ch, SKILL_PUNCH, 15); SET_SKILL(ch, SKILL_SNEAK, 10); SET_SKILL(ch, SKILL_HIDE, 5); SET_SKILL(ch, SKILL_STEAL, 15); break; case CLASS_WARRIOR: SET_SKILL(ch, SKILL_PUNCH, 20); break; case CLASS_BARB: SET_SKILL(ch, SKILL_PUNCH, 15); break; case CLASS_PSIONIC: SET_SKILL(ch, SKILL_PUNCH, 10); break; case CLASS_PHYSIC: SET_SKILL(ch, SKILL_PUNCH, 10); break; case CLASS_CYBORG: SET_SKILL(ch, SKILL_PUNCH, 10); break; case CLASS_KNIGHT: SET_SKILL(ch, SKILL_PUNCH, 20); break; case CLASS_RANGER: SET_SKILL(ch, SKILL_PUNCH, 15); GET_MAX_MOVE(ch) += dice(4, 9); break; case CLASS_MONK: SET_SKILL(ch, SKILL_PUNCH, 20); break; case CLASS_MERCENARY: SET_SKILL(ch, SKILL_PUNCH, 20); case CLASS_BARD: SET_SKILL(ch, SKILL_PUNCH, 25); SET_SKILL(ch, SKILL_ARCHERY, 25); break; } if (new_player) { if (PAST_CLASS(GET_CLASS(ch))) { deposit_past_bank(ch->desc->account, 8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch)); ch->points.gold = 8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch); } else if (FUTURE_CLASS(GET_CLASS(ch))) { deposit_future_bank(ch->desc->account, 8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch)); ch->points.cash = 8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch); } // New players do not start with the gown at this point // This has been left in for reference for generic newbie starting gear for the future. // New players start with a hospital gown and items most dear to them /* struct obj_data *gown = read_object(33800); if (gown != NULL) { equip_char(ch, gown, WEAR_ABOUT, EQUIP_WORN); } */ // Good clerics start with a holy symbol on neck if ((GET_CLASS(ch) == CLASS_CLERIC) && IS_GOOD(ch)) { struct obj_data *talisman = read_object(1280); if (talisman != NULL) { equip_char(ch, talisman, WEAR_NECK_1, EQUIP_WORN); } } // Evil clerics start with a holy symbol on hold if ((GET_CLASS(ch) == CLASS_CLERIC) && IS_EVIL(ch)) { struct obj_data *symbol = read_object(1260); if (symbol != NULL) { equip_char(ch, symbol, WEAR_HOLD, EQUIP_WORN); } } // Good knights start with a holy symbol on finger if ((GET_CLASS(ch) == CLASS_KNIGHT) && IS_GOOD(ch)) { struct obj_data *ring = read_object(1287); if (ring != NULL) { equip_char(ch, ring, WEAR_FINGER_L, EQUIP_WORN); } } // Evil knights start with a holy symbol on neck if ((GET_CLASS(ch) == CLASS_KNIGHT) && IS_EVIL(ch)) { struct obj_data *pendant = read_object(1270); if (pendant != NULL) { equip_char(ch, pendant, WEAR_NECK_1, EQUIP_WORN); } } // Bards start with a percussion instrument held, and stringed in inventory if (GET_CLASS(ch) == CLASS_BARD) { struct obj_data *lute = read_object(3218); if (lute != NULL) { obj_to_char(lute, ch); } } set_title(ch, "the complete newbie"); } advance_level(ch, 0); GET_MAX_MOVE(ch) += GET_CON(ch); GET_HIT(ch) = GET_MAX_HIT(ch); GET_MANA(ch) = GET_MAX_MANA(ch); GET_MOVE(ch) = GET_MAX_MOVE(ch); GET_COND(ch, THIRST) = 24; GET_COND(ch, FULL) = 24; GET_COND(ch, DRUNK) = 0; if (new_player) { ch->player.time.played = 0; ch->player.time.logon = time(NULL); } for (i = 0; i < NUM_WEARS; i++) { if (implant_save[i]) equip_char(ch, implant_save[i], i, EQUIP_IMPLANT); if (tattoo_save[i]) equip_char(ch, tattoo_save[i], i, EQUIP_TATTOO); } }
/* * This function controls the change to maxmove, maxmana, and maxhp for * each char_class every time they gain a level. */ void advance_level(struct creature *ch, int8_t keep_internal) { int add_hp[2], add_mana[2], add_move[2], i, char_class; char *msg; add_hp[0] = add_hp[1] = constitution_hitpoint_bonus(GET_CON(ch)); add_mana[0] = add_mana[1] = wisdom_mana_bonus(GET_WIS(ch)); add_move[0] = add_move[1] = MAX(0, GET_CON(ch) - 15); for (i = 0; i < 2; i++) { if (i == 0) char_class = MIN(GET_CLASS(ch), NUM_CLASSES - 1); else char_class = MIN(GET_REMORT_CLASS(ch), NUM_CLASSES - 1); if (char_class < 0) continue; switch (char_class) { case CLASS_MAGIC_USER: add_hp[i] /= 5; add_hp[i] += number(3, 10); add_mana[i] += number(1, 11) + (GET_LEVEL(ch) / 3); add_move[i] += number(1, 3); break; case CLASS_CLERIC: add_hp[i] /= 2; add_hp[i] += number(5, 11); add_mana[i] += number(1, 10) + (GET_LEVEL(ch) / 5); add_move[i] += number(1, 4); break; case CLASS_BARD: add_hp[i] = add_hp[i] / 3; add_hp[i] += number(5, 10); add_mana[i] += number(1, 4) + (GET_LEVEL(ch) / 10); add_move[i] += number(10, 18); break; case CLASS_THIEF: add_hp[i] /= 3; add_hp[i] += number(4, 10); add_mana[i] = add_mana[i] * 3 / 10; add_move[i] += number(2, 6); break; case CLASS_MERCENARY: add_hp[i] += number(6, 14); add_mana[i] = add_mana[i] * 5 / 10; add_mana[i] += number(1, 5) + GET_LEVEL(ch) / 10; add_move[i] += number(3, 9); break; case CLASS_WARRIOR: add_hp[i] += number(10, 15); add_mana[i] = add_mana[i] * 4 / 10; add_mana[i] += number(1, 5); add_move[i] += number(5, 10); break; case CLASS_BARB: add_hp[i] += number(13, 18); add_mana[i] = add_mana[i] * 3 / 10; add_mana[i] += number(0, 3); add_move[i] += number(5, 10); break; case CLASS_KNIGHT: add_hp[i] += number(7, 13); add_mana[i] = add_mana[i] * 7 / 10; add_mana[i] += number(1, 4) + (GET_LEVEL(ch) / 15); add_move[i] += number(3, 8); break; case CLASS_RANGER: add_hp[i] += number(4, 11); add_mana[i] = add_mana[i] * 6 / 10; add_mana[i] += number(1, 6) + (GET_LEVEL(ch) / 8); add_move[i] += number(6, 14); break; case CLASS_PSIONIC: add_hp[i] /= 3; add_hp[i] += number(3, 8); add_mana[i] = add_mana[i] * 6 / 10; add_mana[i] += number(1, 7) + (GET_LEVEL(ch) / 5); add_move[i] += number(2, 6); break; case CLASS_PHYSIC: add_hp[i] /= 4; add_hp[i] += number(4, 9); add_mana[i] = add_mana[i] * 6 / 10; add_mana[i] += number(1, 6) + (GET_LEVEL(ch) / 3); add_move[i] += number(2, 10); break; case CLASS_CYBORG: add_hp[i] /= 2; add_hp[i] += number(6, 14); add_mana[i] = add_mana[i] * 3 / 10; add_mana[i] += number(1, 2) + (GET_LEVEL(ch) / 15); add_move[i] += number(5, 8); break; case CLASS_MONK: add_hp[i] /= 3; add_hp[i] += number(6, 12); add_mana[i] = add_mana[i] * 3 / 10; add_mana[i] += number(1, 2) + (GET_LEVEL(ch) / 22); add_move[i] += number(6, 9); break; default: add_hp[i] /= 2; add_hp[i] += number(5, 16); add_mana[i] = add_mana[i] * 5 / 10; add_mana[i] += number(1, 13) + (GET_LEVEL(ch) / 4); add_move[i] += number(7, 15); break; } } if (IS_RACE(ch, RACE_HALF_ORC) || IS_RACE(ch, RACE_ORC)) { add_move[0] *= 2; add_move[1] *= 2; } ch->points.max_hit += MAX(1, add_hp[0]); ch->points.max_move += MAX(1, add_move[0]); if (GET_LEVEL(ch) > 1) ch->points.max_mana += add_mana[0]; GET_LIFE_POINTS(ch) += (GET_LEVEL(ch) * (GET_WIS(ch) + GET_CON(ch))) / 300; if (PLR_FLAGGED(ch, PLR_HARDCORE)) GET_LIFE_POINTS(ch) += 1; if (IS_REMORT(ch) && GET_REMORT_GEN(ch)) { if (add_hp[0] < 0 || add_hp[1] < 0) { errlog("remort level (%s) add_hp: [0]=%d,[1]=%d", GET_NAME(ch), add_hp[0], add_hp[1]); } ch->points.max_hit += add_hp[1] / 4; ch->points.max_mana += add_mana[1] / 2; ch->points.max_move += add_move[1] / 4; } if (GET_LEVEL(ch) >= LVL_AMBASSADOR) { for (i = 0; i < 3; i++) GET_COND(ch, i) = -1; SET_BIT(PRF_FLAGS(ch), PRF_HOLYLIGHT); SET_BIT(PRF_FLAGS(ch), PRF_NOHASSLE); } if (GET_LEVEL(ch) == 10) SET_BIT(PRF2_FLAGS(ch), PRF2_NEWBIE_HELPER); // special section for improving read_scrolls and use_wands if (CHECK_SKILL(ch, SKILL_READ_SCROLLS) > 10) SET_SKILL(ch, SKILL_READ_SCROLLS, MIN(100, CHECK_SKILL(ch, SKILL_READ_SCROLLS) + MIN(10, number(1, GET_INT(ch) / 2)))); if (CHECK_SKILL(ch, SKILL_USE_WANDS) > 10) SET_SKILL(ch, SKILL_USE_WANDS, MIN(100, CHECK_SKILL(ch, SKILL_USE_WANDS) + MIN(10, number(1, GET_INT(ch) / 2)))); crashsave(ch); int rid = -1; if (ch->in_room != NULL) rid = ch->in_room->number; msg = tmp_sprintf("%s advanced to level %d in room %d%s", GET_NAME(ch), GET_LEVEL(ch), rid, is_tester(ch) ? " <TESTER>" : ""); if (keep_internal) slog("%s", msg); else mudlog(GET_INVIS_LVL(ch), BRF, true, "%s", msg); }