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 social_awareness;
};
#define MAX_COLORS 15
struct t_creature
{
uint32_t origin;
@ -349,10 +351,13 @@ namespace DFHack
t_attrib recuperation;
t_attrib disease_resistance;
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
bool has_default_soul;
t_soul defaultSoul;
uint32_t nbcolors;
uint32_t color[MAX_COLORS];
};
class APIPrivate;

@ -81,6 +81,7 @@ Creatures::Creatures(APIPrivate* _d)
creatures.flags2_offset = minfo->getOffset ("creature_flags2");
creatures.name_offset = minfo->getOffset ("creature_name");
creatures.sex_offset = minfo->getOffset ("creature_sex");
creatures.caste_offset = minfo->getOffset ("creature_caste");
creatures.id_offset = minfo->getOffset ("creature_id");
creatures.labors_offset = minfo->getOffset ("creature_labors");
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_traits_offset = minfo->getOffset("soul_traits");
// appearance
creatures.appearance_vector_offset = minfo->getOffset("creature_appearance_vector");
// name offsets for the creature module
creatures.name_firstname_offset = minfo->getOffset("name_firstname");
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);
furball.civ = p->readDWord (temp + offs.civ_offset);
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.flags2_offset, furball.flags2.whole);
@ -258,6 +263,15 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
// traits as well
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
/*
DfVector <uint32_t> likes(d->p, temp + offs.creature_likes_offset);

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

@ -204,6 +204,22 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
}
*/
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
<< ", strength: " << creature.strength.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);
cout << "artifact: " << artifact_name << endl;
}
cout << endl;
}
@ -405,16 +423,7 @@ int main (int numargs, char ** args)
}
mem = DF.getMemoryInfo();
if(!Materials->ReadInorganicMaterials())
{
cerr << "Can't get the inorganics types." << endl;
return 1;
}
if(!Materials->ReadCreatureTypesEx())
{
cerr << "Can't get the creature types." << endl;
return 1;
}
Materials->ReadAllMaterials();
if(!Tran->Start())
{

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