Creature mental attributes

develop
Petr Mrázek 2010-04-09 03:21:42 +02:00
parent aa32e79fea
commit c08d696d56
5 changed files with 52 additions and 14 deletions

@ -287,6 +287,30 @@ namespace DFHack
// FIXME: define in Memory.xml instead?
#define NUM_CREATURE_TRAITS 30
#define NUM_CREATURE_LABORS 102
struct t_soul
{
uint8_t numSkills;
t_skill skills[256];
/*
uint8_t numLikes;
t_like likes[32];
*/
t_attrib analytical_ability;
t_attrib focus;
t_attrib willpower;
t_attrib creativity;
t_attrib intuition;
t_attrib patience;
t_attrib memory;
t_attrib linguistic_ability;
t_attrib spatial_sense;
t_attrib musicality;
t_attrib kinesthetic_sense;
t_attrib empathy;
t_attrib social_awareness;
};
struct t_creature
{
uint32_t origin;
@ -308,13 +332,6 @@ namespace DFHack
// enabled labors
uint8_t labors[NUM_CREATURE_LABORS];
uint8_t numSkills;
t_skill skills[256];
/*
uint8_t numLikes;
t_like likes[32];
*/
t_job current_job;
uint32_t happiness;
@ -328,6 +345,8 @@ namespace DFHack
int32_t squad_leader_id;
uint8_t sex;
uint32_t pregnancy_timer; //Countdown timer to giving birth
t_soul defaultSoul;
};
class APIPrivate;

@ -85,6 +85,7 @@ Creatures::Creatures(APIPrivate* _d)
creatures.mood_offset = minfo->getOffset("creature_mood");
// soul offsets
creatures.soul_skills_vector_offset = minfo->getOffset("soul_skills_vector");
creatures.soul_mental_offset = minfo->getOffset("soul_mental");
// name offsets for the creature module
creatures.name_firstname_offset = minfo->getOffset("name_firstname");
@ -209,15 +210,16 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
uint32_t soul = g_pProcess->readDWord(temp + offs.default_soul_offset);
// get first soul's skills
DfVector skills(g_pProcess, soul + offs.soul_skills_vector_offset, 4 );
furball.numSkills = skills.getSize();
for (uint32_t i = 0; i < furball.numSkills;i++)
furball.defaultSoul.numSkills = skills.getSize();
for (uint32_t i = 0; i < furball.defaultSoul.numSkills;i++)
{
uint32_t temp2 = * (uint32_t *) skills[i];
// a byte: this gives us 256 skills maximum.
furball.skills[i].id = g_pProcess->readByte (temp2);
furball.skills[i].rating = g_pProcess->readByte (temp2 + 4);
furball.skills[i].experience = g_pProcess->readWord (temp2 + 8);
furball.defaultSoul.skills[i].id = g_pProcess->readByte (temp2);
furball.defaultSoul.skills[i].rating = g_pProcess->readByte (temp2 + 4);
furball.defaultSoul.skills[i].experience = g_pProcess->readWord (temp2 + 8);
}
g_pProcess->read(temp + offs.soul_mental_offset, sizeof(t_attrib) * 13, (uint8_t *)&furball.defaultSoul.analytical_ability);
// traits
//g_pProcess->read (temp + offs.creature_traits_offset, sizeof (uint16_t) * NUM_CREATURE_TRAITS, (uint8_t *) &furball.traits);

@ -57,6 +57,7 @@ typedef struct
uint32_t name_firstname_offset;
uint32_t name_nickname_offset;
uint32_t name_words_offset;
uint32_t soul_mental_offset;
} creature_offsets;
typedef struct

@ -242,13 +242,13 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
//skills
cout << "Skills" << endl;
for(unsigned int i = 0; i < creature.numSkills;i++)
for(unsigned int i = 0; i < creature.defaultSoul.numSkills;i++)
{
if(i > 0)
{
cout << ", ";
}
cout << mem->getSkill(creature.skills[i].id) << ": " << creature.skills[i].rating;
cout << mem->getSkill(creature.defaultSoul.skills[i].id) << ": " << creature.defaultSoul.skills[i].rating;
}
cout << endl;

@ -3003,6 +3003,22 @@ map_data_1b60_offset 0x1B9c
=====
<Offset name="soul_name">0x0</Offset>
<Offset name="soul_skills_vector">0x1F4</Offset>
<Offset name="soul_mental">0x88</Offset>
<!--
mid = AddStrucMember(id,"analytical_ability", 0X88, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"focus", 0XA4, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"willpower", 0XC0, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"creativity", 0XDC, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"intuition", 0XF8, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"patience", 0X114, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"memory", 0X130, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"linguistic_ability", 0X14C, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"spatial_sense", 0X168, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"musicality", 0X184, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"kinesthetic_sense", 0X1A0, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"empathy", 0X1BC, 0x60000400, GetStrucIdByName("s_attrib"), 28);
mid = AddStrucMember(id,"social_awareness", 0X1D8, 0x60000400, GetStrucIdByName("s_attrib"), 28);
-->
Materials
=========