void cTownperson::import_legacy(legacy::creature_start_type old){ number = old.number; start_attitude = eAttitude(old.start_attitude); start_loc.x = old.start_loc.x; start_loc.y = old.start_loc.y; mobility = old.mobile; switch(old.time_flag) { case 0: time_flag = eMonstTime::ALWAYS; break; case 1: time_flag = eMonstTime::APPEAR_ON_DAY; break; case 2: time_flag = eMonstTime::DISAPPEAR_ON_DAY; break; case 4: time_flag = eMonstTime::SOMETIMES_A; break; case 5: time_flag = eMonstTime::SOMETIMES_B; break; case 6: time_flag = eMonstTime::SOMETIMES_C; break; case 7: time_flag = eMonstTime::APPEAR_WHEN_EVENT; break; case 8: time_flag = eMonstTime::DISAPPEAR_WHEN_EVENT; break; } spec1 = old.spec1; spec2 = old.spec2; spec_enc_code = old.spec_enc_code; time_code = old.time_code; monster_time = old.monster_time; personality = old.personality; special_on_kill = old.special_on_kill; facial_pic = old.facial_pic; if(facial_pic == 0) facial_pic = NO_PIC; else facial_pic--; }
void cCreature::append(legacy::creature_data_type old){ active = old.active; attitude = eAttitude(old.attitude); number = old.number; cur_loc.x = old.m_loc.x; cur_loc.y = old.m_loc.y; cMonster::append(old.m_d); mobility = old.mobile; summon_time = old.summoned; if(summon_time >= 100) { party_summoned = false; summon_time -= 100; } else party_summoned = true; number = old.monst_start.number; start_attitude = eAttitude(old.monst_start.start_attitude); start_loc.x = old.monst_start.start_loc.x; start_loc.y = old.monst_start.start_loc.y; mobility = old.monst_start.mobile; switch(old.monst_start.time_flag) { case 0: time_flag = eMonstTime::ALWAYS; break; case 1: time_flag = eMonstTime::APPEAR_ON_DAY; break; case 2: time_flag = eMonstTime::DISAPPEAR_ON_DAY; break; case 4: time_flag = eMonstTime::SOMETIMES_A; break; case 5: time_flag = eMonstTime::SOMETIMES_B; break; case 6: time_flag = eMonstTime::SOMETIMES_C; break; case 7: time_flag = eMonstTime::APPEAR_WHEN_EVENT; break; case 8: time_flag = eMonstTime::DISAPPEAR_WHEN_EVENT; break; } spec1 = old.monst_start.spec1; spec2 = old.monst_start.spec2; spec_enc_code = old.monst_start.spec_enc_code; time_code = old.monst_start.time_code; monster_time = old.monst_start.monster_time; personality = old.monst_start.personality; special_on_kill = old.monst_start.special_on_kill; facial_pic = old.monst_start.facial_pic; health = old.m_d.health; mp = old.m_d.mp; max_mp = old.m_d.max_mp; ap = old.m_d.ap; morale = old.m_d.morale; m_morale = old.m_d.m_morale; for(int i = 0; i < 15; i++) status[(eStatus) i] = old.m_d.status[i]; direction = eDirection(old.m_d.direction); }
// For charm, amount is the resulting attitude of the charmed monster; if 0, attitude is 2. void cCreature::sleep(eStatus which_status,int amount,int penalty) { if(which_status != eStatus::CHARM && amount < 0) { status[which_status] -= amount; if(which_status != eStatus::ASLEEP) status[which_status] = max(0, status[which_status]); return; } if((which_status == eStatus::ASLEEP) && (m_type == eRace::UNDEAD || m_type == eRace::SKELETAL || m_type == eRace::SLIME || m_type == eRace::STONE || m_type == eRace::PLANT)) return; short r1 = get_ran(1,1,100); if(magic_res > 0) { r1 *= 100; r1 /= magic_res; } else r1 = 200; r1 += penalty; if(which_status == eStatus::FORCECAGE && (mu > 0 || cl > 0)) r1 += 5; if(which_status == eStatus::ASLEEP) r1 -= 25; if(which_status == eStatus::PARALYZED) r1 -= 15; if(which_status == eStatus::ASLEEP && abil[eMonstAbil::FIELD].active && abil[eMonstAbil::FIELD].gen.fld == eFieldType::CLOUD_SLEEP) return; if(r1 > charm_odds[level / 2]) { //one_sound(68); spell_note(10); } else { if(which_status == eStatus::CHARM) { if(amount <= 0 || amount > 3) amount = 2; attitude = eAttitude(amount); spell_note(23); } else if(which_status == eStatus::FORCECAGE) { status[eStatus::FORCECAGE] = amount; spell_note(52); } else { status[which_status] = amount; if(which_status == eStatus::ASLEEP && (amount >= 0)) spell_note(28); if(which_status == eStatus::PARALYZED && (amount >= 0)) spell_note(30); if(amount < 0) spell_note(40); } //one_sound(53); } }
void cMonster::import_legacy(legacy::monster_record_type& old){ level = old.level; m_name = std::string((char*) old.m_name, 26); m_name.erase(m_name.begin() + m_name.find_first_of('\0'), m_name.end()); m_health = old.m_health; armor = old.armor; skill = old.skill; for(int i = 0; i < 3; i++) { a[i].dice = old.a[i] / 100; a[i].sides = old.a[i] % 100; } a[0].type = eMonstMelee(old.a1_type); a[1].type = a[2].type = eMonstMelee(old.a23_type); // Unless human, add 3 to the monster's type to get its race // This is because nephil, slith, and vahnatai were inserted if(old.m_type) m_type = eRace(old.m_type + 3); else m_type = eRace::HUMAN; speed = old.speed; mu = old.mu; cl = old.cl; treasure = old.treasure; invisible = mindless = invuln = guard = false; abil.clear(); switch(old.spec_skill) { case 1: addAbil(eMonstAbilTemplate::THROWS_DARTS); break; case 2: addAbil(eMonstAbilTemplate::SHOOTS_ARROWS); break; case 3: addAbil(eMonstAbilTemplate::THROWS_SPEARS); break; case 4: addAbil(eMonstAbilTemplate::THROWS_ROCKS1); break; case 5: addAbil(eMonstAbilTemplate::THROWS_ROCKS2); break; case 6: addAbil(eMonstAbilTemplate::THROWS_ROCKS3); break; case 7: addAbil(eMonstAbilTemplate::THROWS_RAZORDISKS); break; case 8: addAbil(eMonstAbilTemplate::RAY_PETRIFY); break; case 9: addAbil(eMonstAbilTemplate::RAY_SP_DRAIN); break; case 10: addAbil(eMonstAbilTemplate::RAY_HEAT); break; case 11: invisible = true; break; case 12: addAbil(eMonstAbilTemplate::SPLITS); break; case 13: mindless = true; break; case 14: addAbil(eMonstAbilTemplate::BREATH_FOUL); break; case 15: addAbil(eMonstAbilTemplate::TOUCH_ICY); break; case 17: addAbil(eMonstAbilTemplate::TOUCH_ICY_DRAINING); break; case 16: addAbil(eMonstAbilTemplate::TOUCH_XP_DRAIN); break; case 18: addAbil(eMonstAbilTemplate::TOUCH_STUN); break; case 19: addAbil(eMonstAbilTemplate::SHOOTS_WEB); break; case 20: addAbil(eMonstAbilTemplate::GOOD_ARCHER); break; case 21: addAbil(eMonstAbilTemplate::TOUCH_STEAL_FOOD); break; case 22: addAbil(eMonstAbilTemplate::MARTYRS_SHIELD); break; case 23: addAbil(eMonstAbilTemplate::RAY_PARALYSIS); break; case 24: addAbil(eMonstAbilTemplate::TOUCH_DUMB); break; case 25: addAbil(eMonstAbilTemplate::TOUCH_DISEASE); break; case 26: addAbil(eMonstAbilTemplate::ABSORB_SPELLS); break; case 27: addAbil(eMonstAbilTemplate::TOUCH_WEB); break; case 28: addAbil(eMonstAbilTemplate::TOUCH_SLEEP); break; case 29: addAbil(eMonstAbilTemplate::TOUCH_PARALYSIS); break; case 30: addAbil(eMonstAbilTemplate::TOUCH_PETRIFY); break; case 31: addAbil(eMonstAbilTemplate::TOUCH_ACID); break; case 32: addAbil(eMonstAbilTemplate::BREATH_SLEEP); break; case 33: addAbil(eMonstAbilTemplate::SPIT_ACID); break; case 34: addAbil(eMonstAbilTemplate::SHOOTS_SPINES); break; case 35: addAbil(eMonstAbilTemplate::TOUCH_DEATH); break; case 36: invuln = true; break; case 37: guard = true; break; } switch(old.radiate_1) { case 1: addAbil(eMonstAbilTemplate::RADIATE_FIRE, old.radiate_2); break; case 2: addAbil(eMonstAbilTemplate::RADIATE_ICE, old.radiate_2); break; case 3: addAbil(eMonstAbilTemplate::RADIATE_SHOCK, old.radiate_2); break; case 4: addAbil(eMonstAbilTemplate::RADIATE_ANTIMAGIC, old.radiate_2); break; case 5: addAbil(eMonstAbilTemplate::RADIATE_SLEEP, old.radiate_2); break; case 6: addAbil(eMonstAbilTemplate::RADIATE_STINK, old.radiate_2); break; case 10: addAbil(eMonstAbilTemplate::SUMMON_5, old.radiate_2); break; case 11: addAbil(eMonstAbilTemplate::SUMMON_20, old.radiate_2); break; case 12: addAbil(eMonstAbilTemplate::SUMMON_50, old.radiate_2); break; case 15: addAbil(eMonstAbilTemplate::DEATH_TRIGGERS, old.radiate_2); break; } if(old.poison > 0) addAbil(eMonstAbilTemplate::TOUCH_POISON, old.poison); if(old.breath > 0) { switch(old.breath_type) { case 0: addAbil(eMonstAbilTemplate::BREATH_FIRE, old.breath); break; case 1: addAbil(eMonstAbilTemplate::BREATH_FROST, old.breath); break; case 2: addAbil(eMonstAbilTemplate::BREATH_ELECTRICITY, old.breath); break; case 3: addAbil(eMonstAbilTemplate::BREATH_DARKNESS, old.breath); break; } } corpse_item = old.corpse_item; corpse_item_chance = old.corpse_item_chance; if(old.immunities & 2) resist[eDamageType::MAGIC] = 0; else if(old.immunities & 1) resist[eDamageType::MAGIC] = 50; else resist[eDamageType::MAGIC] = 100; if(old.immunities & 8) resist[eDamageType::FIRE] = 0; else if(old.immunities & 4) resist[eDamageType::FIRE] = 50; else resist[eDamageType::FIRE] = 100; if(old.immunities & 32) resist[eDamageType::COLD] = 0; else if(old.immunities & 16) resist[eDamageType::COLD] = 50; else resist[eDamageType::COLD] = 100; if(old.immunities & 128) resist[eDamageType::POISON] = 0; else if(old.immunities & 64) resist[eDamageType::POISON] = 50; else resist[eDamageType::POISON] = 100; x_width = old.x_width; y_width = old.y_width; default_attitude = eAttitude(old.default_attitude); summon_type = old.summon_type; default_facial_pic = old.default_facial_pic; if(default_facial_pic == 0) default_facial_pic = NO_PIC; else default_facial_pic--; picture_num = old.picture_num; if(picture_num == 122) picture_num = 119; see_spec = -1; }