Creatures colors are now decodable !

develop
simon 2010-05-05 14:08:18 +02:00
parent d435313632
commit a6dc645f48
5 changed files with 43 additions and 13 deletions

@ -314,7 +314,9 @@ namespace DFHack
t_attrib empathy; t_attrib empathy;
t_attrib social_awareness; t_attrib social_awareness;
}; };
#define MAX_COLORS 15
struct t_creature struct t_creature
{ {
uint32_t origin; uint32_t origin;
@ -349,10 +351,13 @@ namespace DFHack
t_attrib recuperation; t_attrib recuperation;
t_attrib disease_resistance; t_attrib disease_resistance;
int32_t squad_leader_id; int32_t squad_leader_id;
uint8_t sex; // really a caste uint8_t sex;
uint16_t caste;
uint32_t pregnancy_timer; //Countdown timer to giving birth uint32_t pregnancy_timer; //Countdown timer to giving birth
bool has_default_soul; bool has_default_soul;
t_soul defaultSoul; t_soul defaultSoul;
uint32_t nbcolors;
uint32_t color[MAX_COLORS];
}; };
class APIPrivate; class APIPrivate;

@ -81,6 +81,7 @@ Creatures::Creatures(APIPrivate* _d)
creatures.flags2_offset = minfo->getOffset ("creature_flags2"); creatures.flags2_offset = minfo->getOffset ("creature_flags2");
creatures.name_offset = minfo->getOffset ("creature_name"); creatures.name_offset = minfo->getOffset ("creature_name");
creatures.sex_offset = minfo->getOffset ("creature_sex"); creatures.sex_offset = minfo->getOffset ("creature_sex");
creatures.caste_offset = minfo->getOffset ("creature_caste");
creatures.id_offset = minfo->getOffset ("creature_id"); creatures.id_offset = minfo->getOffset ("creature_id");
creatures.labors_offset = minfo->getOffset ("creature_labors"); creatures.labors_offset = minfo->getOffset ("creature_labors");
creatures.happiness_offset = minfo->getOffset ("creature_happiness"); creatures.happiness_offset = minfo->getOffset ("creature_happiness");
@ -97,6 +98,9 @@ Creatures::Creatures(APIPrivate* _d)
creatures.soul_mental_offset = minfo->getOffset("soul_mental"); creatures.soul_mental_offset = minfo->getOffset("soul_mental");
creatures.soul_traits_offset = minfo->getOffset("soul_traits"); creatures.soul_traits_offset = minfo->getOffset("soul_traits");
// appearance
creatures.appearance_vector_offset = minfo->getOffset("creature_appearance_vector");
// name offsets for the creature module // name offsets for the creature module
creatures.name_firstname_offset = minfo->getOffset("name_firstname"); creatures.name_firstname_offset = minfo->getOffset("name_firstname");
creatures.name_nickname_offset = minfo->getOffset("name_nickname"); creatures.name_nickname_offset = minfo->getOffset("name_nickname");
@ -179,6 +183,7 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
p->readDWord (temp + offs.race_offset, furball.race); p->readDWord (temp + offs.race_offset, furball.race);
furball.civ = p->readDWord (temp + offs.civ_offset); furball.civ = p->readDWord (temp + offs.civ_offset);
p->readByte (temp + offs.sex_offset, furball.sex); p->readByte (temp + offs.sex_offset, furball.sex);
p->readWord (temp + offs.caste_offset, furball.caste);
p->readDWord (temp + offs.flags1_offset, furball.flags1.whole); p->readDWord (temp + offs.flags1_offset, furball.flags1.whole);
p->readDWord (temp + offs.flags2_offset, furball.flags2.whole); p->readDWord (temp + offs.flags2_offset, furball.flags2.whole);
@ -258,6 +263,15 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
// traits as well // traits as well
p->read(soul + offs.soul_traits_offset, sizeof (uint16_t) * NUM_CREATURE_TRAITS, (uint8_t *) &furball.defaultSoul.traits); p->read(soul + offs.soul_traits_offset, sizeof (uint16_t) * NUM_CREATURE_TRAITS, (uint8_t *) &furball.defaultSoul.traits);
} }
DfVector <uint32_t> app(p, temp + offs.appearance_vector_offset);
furball.nbcolors = app.size();
if(furball.nbcolors>MAX_COLORS)
furball.nbcolors = MAX_COLORS;
for(uint32_t i = 0; i < furball.nbcolors; i++)
{
furball.color[i] = app[i];
}
//likes //likes
/* /*
DfVector <uint32_t> likes(d->p, temp + offs.creature_likes_offset); DfVector <uint32_t> likes(d->p, temp + offs.creature_likes_offset);

@ -44,6 +44,7 @@ typedef struct
uint32_t flags2_offset; uint32_t flags2_offset;
uint32_t name_offset; uint32_t name_offset;
uint32_t sex_offset; uint32_t sex_offset;
uint32_t caste_offset;
uint32_t id_offset; uint32_t id_offset;
uint32_t labors_offset; uint32_t labors_offset;
uint32_t happiness_offset; uint32_t happiness_offset;
@ -63,6 +64,7 @@ typedef struct
uint32_t name_words_offset; uint32_t name_words_offset;
uint32_t soul_mental_offset; uint32_t soul_mental_offset;
uint32_t soul_traits_offset; uint32_t soul_traits_offset;
uint32_t appearance_vector_offset;
} creature_offsets; } creature_offsets;
typedef struct typedef struct

@ -204,6 +204,22 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
} }
*/ */
cout << endl; cout << endl;
cout << "Appearance : ";
for(unsigned int i = 0; i<creature.nbcolors ; i++)
{
cout << Materials->raceEx[creature.race].castes[creature.caste].ColorModifier[i].part << " ";
uint32_t color = Materials->raceEx[creature.race].castes[creature.caste].ColorModifier[i].colorlist[creature.color[i]];
if(color<Materials->color.size())
cout << Materials->color[color].name << "["
<< (unsigned int) (Materials->color[color].r*255) << ":"
<< (unsigned int) (Materials->color[color].v*255) << ":"
<< (unsigned int) (Materials->color[color].b*255) << "]";
else
cout << Materials->alldesc[color].id;
cout << " - ";
}
cout << endl;
cout << "happiness: " << creature.happiness cout << "happiness: " << creature.happiness
<< ", strength: " << creature.strength.level << ", strength: " << creature.strength.level
<< ", agility: " << creature.agility.level << ", agility: " << creature.agility.level
@ -359,6 +375,8 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
string artifact_name = Tran->TranslateName(creature.artifact_name,false); string artifact_name = Tran->TranslateName(creature.artifact_name,false);
cout << "artifact: " << artifact_name << endl; cout << "artifact: " << artifact_name << endl;
} }
cout << endl; cout << endl;
} }
@ -405,16 +423,7 @@ int main (int numargs, char ** args)
} }
mem = DF.getMemoryInfo(); mem = DF.getMemoryInfo();
if(!Materials->ReadInorganicMaterials()) Materials->ReadAllMaterials();
{
cerr << "Can't get the inorganics types." << endl;
return 1;
}
if(!Materials->ReadCreatureTypesEx())
{
cerr << "Can't get the creature types." << endl;
return 1;
}
if(!Tran->Start()) if(!Tran->Start())
{ {

@ -74,7 +74,7 @@ int main (int numargs, const char ** args)
cout << i << ": " << Materials->color[i].id << " - " << Materials->color[i].name << "[" cout << i << ": " << Materials->color[i].id << " - " << Materials->color[i].name << "["
<< (unsigned int) (Materials->color[i].r*255) << ":" << (unsigned int) (Materials->color[i].r*255) << ":"
<< (unsigned int) (Materials->color[i].v*255) << ":" << (unsigned int) (Materials->color[i].v*255) << ":"
<< (unsigned int) (Materials->color[i].b*255) << ":" << (unsigned int) (Materials->color[i].b*255)
<< "]" << endl; << "]" << endl;
} }
cout << endl << "----==== All descriptors ====----" << endl; cout << endl << "----==== All descriptors ====----" << endl;