Restore the use of a separate class for town preset creatures
This commit is contained in:
@@ -1360,7 +1360,7 @@ void activate_monsters(short code,short /*attitude*/) {
|
||||
return;
|
||||
for(i = 0; i < univ.town->max_monst(); i++)
|
||||
if(univ.town.monst[i].spec_enc_code == code) {
|
||||
cCreature& monst = univ.town->creatures(i);
|
||||
cTownperson& monst = univ.town->creatures(i);
|
||||
univ.town.monst.assign(i, monst, univ.scenario.scen_monsters[monst.number], PSD[SDF_EASY_MODE], univ.difficulty_adjust());
|
||||
univ.town.monst[i].spec_enc_code = 0;
|
||||
univ.town.monst[i].active = 2;
|
||||
|
@@ -1505,20 +1505,8 @@ bool damage_monst(short which_m, short who_hit, short how_much, short how_much_s
|
||||
if(where_put.x > 0)
|
||||
if((which_spot = place_monster(victim->number,where_put)) < 90) {
|
||||
// TODO: Why so many assignments? Windows only assigns health and monst_start (start_loc I assume)
|
||||
static_cast<cTownperson&>(univ.town.monst[which_spot]) = *victim;
|
||||
univ.town.monst[which_spot].health = victim->health;
|
||||
univ.town.monst[which_spot].number = victim->number;
|
||||
univ.town.monst[which_spot].start_attitude = victim->start_attitude;
|
||||
univ.town.monst[which_spot].start_loc = victim->start_loc;
|
||||
univ.town.monst[which_spot].mobility = victim->mobility;
|
||||
univ.town.monst[which_spot].time_flag = victim->time_flag;
|
||||
univ.town.monst[which_spot].spec1 = victim->spec1;
|
||||
univ.town.monst[which_spot].spec2 = victim->spec2;
|
||||
univ.town.monst[which_spot].spec_enc_code = victim->spec_enc_code;
|
||||
univ.town.monst[which_spot].time_code = victim->time_code;
|
||||
univ.town.monst[which_spot].monster_time = victim->monster_time;
|
||||
univ.town.monst[which_spot].personality = victim->personality;
|
||||
univ.town.monst[which_spot].special_on_kill = victim->special_on_kill;
|
||||
univ.town.monst[which_spot].facial_pic = victim->facial_pic;
|
||||
monst_spell_note(victim->number,27);
|
||||
}
|
||||
}
|
||||
|
@@ -264,7 +264,7 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
}
|
||||
else {
|
||||
// First set up the values.
|
||||
cCreature& preset = univ.town->creatures(i);
|
||||
cTownperson& preset = univ.town->creatures(i);
|
||||
univ.town.monst.assign(i, preset, univ.scenario.scen_monsters[preset.number], PSD[SDF_EASY_MODE], univ.difficulty_adjust());
|
||||
|
||||
if(univ.town.monst[i].spec_enc_code > 0)
|
||||
|
@@ -29,13 +29,12 @@ cCreature& cPopulation::operator[](size_t n){
|
||||
return dudes[n];
|
||||
}
|
||||
|
||||
// This function takes a preset cCreature from a scenario town record and prepares it for use in-game.
|
||||
// It's needed because in the town record, many fields are ignored, including all the superclass fields.
|
||||
// This function combines a cTownperson from a scenario town record with a cMonster from the scenario record
|
||||
// into a cCreature, and prepares it for use in-game according to the user's preferences and party strength
|
||||
// replaces return_monster_template() from boe.monsters.cpp
|
||||
void cPopulation::assign(size_t n, const cCreature& other, const cMonster& base, bool easy, int difficulty_adjust){
|
||||
// First do a basic assign
|
||||
dudes[n] = other;
|
||||
// And make sure the superclass fields are correctly populated
|
||||
void cPopulation::assign(size_t n, const cTownperson& other, const cMonster& base, bool easy, int difficulty_adjust){
|
||||
// First copy over the superclass fields
|
||||
static_cast<cTownperson&>(dudes[n]) = other;
|
||||
static_cast<cMonster&>(dudes[n]) = base;
|
||||
// Now set up extra stuff
|
||||
dudes[n].active = 1; // TODO: Is this right?
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
short friendly;
|
||||
|
||||
void append(legacy::creature_list_type old);
|
||||
void assign(size_t n, const cCreature& other, const cMonster& base, bool easy, int difficulty_adjust);
|
||||
void assign(size_t n, const cTownperson& other, const cMonster& base, bool easy, int difficulty_adjust);
|
||||
cCreature& operator[](size_t n);
|
||||
const cCreature& operator[](size_t n) const;
|
||||
cPopulation() : which_town(200) {}
|
||||
|
@@ -384,7 +384,7 @@ cMonster::cMonster(){
|
||||
}
|
||||
|
||||
cCreature::cCreature(){
|
||||
id = number = active = attitude = start_attitude = 0;
|
||||
number = active = attitude = start_attitude = 0;
|
||||
start_loc.x = start_loc.y = cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
|
||||
mobility = 1;
|
||||
summoned = 0;
|
||||
@@ -398,7 +398,7 @@ cCreature::cCreature(int num) : cCreature() {
|
||||
number = num;
|
||||
}
|
||||
|
||||
void cCreature::append(legacy::creature_start_type old){
|
||||
void cTownperson::append(legacy::creature_start_type old){
|
||||
number = old.number;
|
||||
start_attitude = old.start_attitude;
|
||||
start_loc.x = old.start_loc.x;
|
||||
|
@@ -163,20 +163,27 @@ enum class eMonstTime {
|
||||
APPEAR_AFTER_CHOP,
|
||||
};
|
||||
|
||||
class cCreature : public cMonster {
|
||||
class cTownperson {
|
||||
public:
|
||||
unsigned long id;
|
||||
mon_num_t number;
|
||||
short active, attitude;
|
||||
unsigned int start_attitude;
|
||||
location start_loc, cur_loc;
|
||||
location start_loc;
|
||||
unsigned short mobility;
|
||||
eMonstTime time_flag;
|
||||
short summoned;
|
||||
short spec1, spec2;
|
||||
char spec_enc_code, time_code;
|
||||
short spec_enc_code, time_code;
|
||||
short monster_time, personality;
|
||||
short special_on_kill, facial_pic;
|
||||
short special_on_kill;
|
||||
pic_num_t facial_pic;
|
||||
|
||||
void append(legacy::creature_start_type old);
|
||||
};
|
||||
|
||||
class cCreature : public cMonster, public cTownperson {
|
||||
public:
|
||||
short active, attitude;
|
||||
location cur_loc;
|
||||
short summoned;
|
||||
short target;
|
||||
location targ_loc;
|
||||
short health;
|
||||
@@ -192,7 +199,6 @@ public:
|
||||
cCreature(int num);
|
||||
|
||||
void append(legacy::creature_data_type old);
|
||||
void append(legacy::creature_start_type old);
|
||||
void writeTo(std::ostream& file) const;
|
||||
void readFrom(std::istream& file);
|
||||
};
|
||||
|
@@ -220,7 +220,7 @@ void cTinyTown::readTerrainFrom(std::istream& file) {
|
||||
readArray(file, _terrain, 32, 32);
|
||||
}
|
||||
|
||||
cCreature& cTinyTown::creatures(size_t i){
|
||||
cTownperson& cTinyTown::creatures(size_t i){
|
||||
return _creatures[i];
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ void cMedTown::readTerrainFrom(std::istream& file) {
|
||||
readArray(file, _terrain, 48, 48);
|
||||
}
|
||||
|
||||
cCreature& cMedTown::creatures(size_t i){
|
||||
cTownperson& cMedTown::creatures(size_t i){
|
||||
return _creatures[i];
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ void cBigTown::readTerrainFrom(std::istream& file) {
|
||||
readArray(file, _terrain, 64, 64);
|
||||
}
|
||||
|
||||
cCreature& cBigTown::creatures(size_t i){
|
||||
cTownperson& cBigTown::creatures(size_t i){
|
||||
return _creatures[i];
|
||||
}
|
||||
|
||||
|
@@ -25,12 +25,12 @@ namespace legacy {
|
||||
class cBigTown : public cTown { // formerly big_tr_type
|
||||
protected:
|
||||
ter_num_t _terrain[64][64];
|
||||
cCreature _creatures[60];
|
||||
cTownperson _creatures[60];
|
||||
unsigned char _lighting[8][64];
|
||||
public:
|
||||
void append(legacy::big_tr_type& old, int town_num);
|
||||
ter_num_t& terrain(size_t x, size_t y);
|
||||
cCreature& creatures(size_t i);
|
||||
cTownperson& creatures(size_t i);
|
||||
unsigned char& lighting(size_t i, size_t r);
|
||||
size_t max_dim() const;
|
||||
size_t max_monst() const;
|
||||
@@ -44,12 +44,12 @@ public:
|
||||
class cMedTown : public cTown { // formerly ave_tr_type
|
||||
protected:
|
||||
ter_num_t _terrain[48][48];
|
||||
cCreature _creatures[40];
|
||||
cTownperson _creatures[40];
|
||||
unsigned char _lighting[6][48];
|
||||
public:
|
||||
void append(legacy::ave_tr_type& old, int town_num);
|
||||
ter_num_t& terrain(size_t x, size_t y);
|
||||
cCreature& creatures(size_t i);
|
||||
cTownperson& creatures(size_t i);
|
||||
unsigned char& lighting(size_t i, size_t r);
|
||||
size_t max_dim() const;
|
||||
size_t max_monst() const;
|
||||
@@ -63,12 +63,12 @@ public:
|
||||
class cTinyTown : public cTown { // formerly tiny_tr_type
|
||||
protected:
|
||||
ter_num_t _terrain[32][32];
|
||||
cCreature _creatures[30];
|
||||
cTownperson _creatures[30];
|
||||
unsigned char _lighting[4][32];
|
||||
public:
|
||||
void append(legacy::tiny_tr_type& old, int town_num);
|
||||
ter_num_t& terrain(size_t x, size_t y);
|
||||
cCreature& creatures(size_t i);
|
||||
cTownperson& creatures(size_t i);
|
||||
unsigned char& lighting(size_t i, size_t r);
|
||||
size_t max_dim() const;
|
||||
size_t max_monst() const;
|
||||
|
@@ -25,7 +25,7 @@ void cBigTemplTown::readTerrainFrom(std::istream& /*file*/) {
|
||||
// TODO: Read in the terrain somehow
|
||||
}
|
||||
|
||||
cCreature& cBigTemplTown::creatures(size_t i){
|
||||
cTownperson& cBigTemplTown::creatures(size_t i){
|
||||
return _creatures[i];
|
||||
}
|
||||
|
||||
|
@@ -38,12 +38,12 @@ public:
|
||||
|
||||
class cBigTemplTown : public cBigTown, cTemplTown {
|
||||
private:
|
||||
//cCreature _creatures[60];
|
||||
//cTownperson _creatures[60];
|
||||
//ter_num_t _terrain[64][64];
|
||||
//unsigned char _lighting[4][32];
|
||||
public:
|
||||
ter_num_t& terrain(size_t x, size_t y);
|
||||
cCreature& creatures(size_t i);
|
||||
cTownperson& creatures(size_t i);
|
||||
unsigned char& lighting(size_t i, size_t r);
|
||||
size_t max_dim() const;
|
||||
size_t max_monst() const;
|
||||
@@ -55,12 +55,12 @@ public:
|
||||
|
||||
class cMedTemplTown : public cMedTown, cTemplTown {
|
||||
private:
|
||||
//cCreature _creatures[40];
|
||||
//cTownperson _creatures[40];
|
||||
//ter_num_t _terrain[48][48];
|
||||
//unsigned char _lighting[4][32];
|
||||
public:
|
||||
ter_num_t& terrain(size_t x, size_t y);
|
||||
cCreature& creatures(size_t i);
|
||||
cTownperson& creatures(size_t i);
|
||||
unsigned char& lighting(size_t i, size_t r);
|
||||
size_t max_dim() const;
|
||||
size_t max_monst() const;
|
||||
@@ -72,12 +72,12 @@ public:
|
||||
|
||||
class cTinyTemplTown : public cTinyTown, cTemplTown {
|
||||
private:
|
||||
//cCreature _creatures[30];
|
||||
//cTownperson _creatures[30];
|
||||
//ter_num_t _terrain[32][32];
|
||||
//unsigned char _lighting[4][32];
|
||||
public:
|
||||
ter_num_t& terrain(size_t x, size_t y);
|
||||
cCreature& creatures(size_t i);
|
||||
cTownperson& creatures(size_t i);
|
||||
unsigned char& lighting(size_t i, size_t r);
|
||||
size_t max_dim() const;
|
||||
size_t max_monst() const;
|
||||
|
@@ -105,7 +105,7 @@ public:
|
||||
virtual void append(legacy::ave_tr_type& old, int town_num);
|
||||
virtual void append(legacy::tiny_tr_type& old, int town_num);
|
||||
virtual ter_num_t& terrain(size_t x, size_t y) = 0;
|
||||
virtual cCreature& creatures(size_t i) = 0;
|
||||
virtual cTownperson& creatures(size_t i) = 0;
|
||||
virtual unsigned char& lighting(size_t i, size_t r) = 0;
|
||||
virtual size_t max_dim() const = 0;
|
||||
virtual size_t max_monst() const = 0;
|
||||
|
@@ -98,7 +98,7 @@ short town_buttons[6][10] = {
|
||||
{50,51,52,53,54,55,56,57,-1,69},
|
||||
};
|
||||
|
||||
cCreature last_placed_monst;
|
||||
cTownperson last_placed_monst;
|
||||
|
||||
rectangle working_rect;
|
||||
location last_space_hit;
|
||||
|
@@ -611,7 +611,7 @@ void writeTownToXml(ticpp::Printer&& data, cTown& town) {
|
||||
for(size_t i = 0; i < town.max_monst(); i++) {
|
||||
data.OpenElement("creature");
|
||||
data.PushAttribute("id", i);
|
||||
cCreature& preset = town.creatures(i);
|
||||
cTownperson& preset = town.creatures(i);
|
||||
data.PushElement("type", preset.number);
|
||||
data.PushElement("attitude", preset.start_attitude);
|
||||
data.PushElement("mobility", preset.mobility);
|
||||
|
@@ -30,7 +30,7 @@ extern cSpeech::cNode null_talk_node;
|
||||
extern cOutdoors* current_terrain;
|
||||
extern location cur_out;
|
||||
|
||||
cCreature store_placed_monst,store_placed_monst2;
|
||||
cTownperson store_placed_monst,store_placed_monst2;
|
||||
short store_which_placed_monst;
|
||||
|
||||
const char *day_str_1[] = {"Unused","Day creature appears","Day creature disappears","",
|
||||
@@ -67,7 +67,7 @@ static bool get_placed_monst_in_dlog(cDialog& me) {
|
||||
|
||||
static bool edit_placed_monst_event_filter(cDialog& me, std::string item_hit, eKeyMod) {
|
||||
short i;
|
||||
cCreature store_m;
|
||||
cTownperson store_m;
|
||||
|
||||
if(item_hit == "okay") {
|
||||
if(!get_placed_monst_in_dlog(me)) return true;
|
||||
@@ -189,7 +189,7 @@ static bool edit_placed_monst_adv_time_flag(cDialog& me, std::string id, bool lo
|
||||
return true;
|
||||
}
|
||||
|
||||
cCreature edit_placed_monst_adv(cCreature monst_record, cDialog& parent) {
|
||||
cTownperson edit_placed_monst_adv(cTownperson monst_record, cDialog& parent) {
|
||||
store_placed_monst2 = monst_record;
|
||||
|
||||
cDialog edit("edit-townperson-advanced", &parent);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
void edit_placed_monst(short which_m);
|
||||
cCreature edit_placed_monst_adv(cCreature monst_record, class cDialog& parent);
|
||||
cTownperson edit_placed_monst_adv(cTownperson monst_record, class cDialog& parent);
|
||||
void edit_sign(short which_sign,short picture);
|
||||
void edit_roomdescs(bool town);
|
||||
short pick_town_num(std::string which_dlog,short def,cScenario& scenario);
|
||||
|
Reference in New Issue
Block a user