Reading creature skills

develop
Petr Mrázek 2010-04-07 02:46:46 +02:00
parent 5ee584b372
commit f81c66d9ea
4 changed files with 33 additions and 7 deletions

@ -77,6 +77,10 @@ Creatures::Creatures(APIPrivate* _d)
creatures.creature_labors_offset = minfo->getOffset ("creature_labors");
creatures.creature_happiness_offset = minfo->getOffset ("creature_happiness");
creatures.creature_artifact_name_offset = minfo->getOffset("creature_artifact_name");
creatures.creature_soul_vector_offset = minfo->getOffset("creature_soul_vector");
// soul offsets
creatures.soul_skills_vector_offset = minfo->getOffset("soul_skills_vector");
// name offsets for the creature module
creatures.name_firstname_offset = minfo->getOffset("name_firstname");
@ -220,6 +224,20 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
g_pProcess->readDWord(temp + offs.creature_bleed_offset, furball.bleed_rate);
*/
// enum soul pointer vector
DfVector souls(g_pProcess,temp + offs.creature_soul_vector_offset,4);
// get first soul's skills
DfVector skills(g_pProcess, *(uint32_t *)souls.at(0) + offs.soul_skills_vector_offset,4 );
furball.numSkills = skills.getSize();
for (uint32_t i = 0; i < furball.numSkills;i++)
{
uint32_t temp2 = * (uint32_t *) skills[i];
//skills.read(i, (uint8_t *) &temp2);
// 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);
}
return true;
}

@ -47,6 +47,9 @@ typedef struct
uint32_t creature_labors_offset;
uint32_t creature_happiness_offset;
uint32_t creature_artifact_name_offset;
uint32_t creature_soul_vector_offset;
// soul offsets
uint32_t soul_skills_vector_offset;
// name offsets (needed for reading creature names)
uint32_t name_firstname_offset;
uint32_t name_nickname_offset;

@ -168,6 +168,7 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
}
DFHack::Translation *Tran = DF.getTranslation();
DFHack::memory_info *mem = DF.getMemoryInfo();
string transName = Tran->TranslateName(creature.name,false);
if(!transName.empty())
@ -231,15 +232,18 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
*/
cout << endl;
/*
//skills
for(unsigned int i = 0; i < creature.skills.size();i++){
if(i > 0){
for(unsigned int i = 0; i < creature.numSkills;i++)
{
if(i > 0)
{
cout << ", ";
}
cout << creature.skills[i].name << ": " << creature.skills[i].rating;
cout << mem->getSkill(creature.skills[i].id) << ": " << creature.skills[i].rating;
}
*/
cout << endl;
/*
* FLAGS 1
*/
@ -301,7 +305,6 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
cout << "from the underworld, ";
}
cout << endl;
#include <modules/Translation.h>
/*
if(creature.flags1.bits.had_mood && (creature.mood == -1 || creature.mood == 8 ) )
{

@ -2973,7 +2973,9 @@ map_data_1b60_offset 0x1B9c
<Offset name="creature_artifact_name">0x6D0</Offset>
<Offset name="creature_labors">0x770</Offset>
<Offset name="creature_happiness">0x830</Offset>
<Offset name="creature_skills">0x1FC</Offset>
<Offset name="creature_soul_vector">0x073C</Offset>
<Offset name="soul_skills_vector">0x1F4</Offset>
<!-- from DT -->
<Address name="dwarf_race_index">0x01470fbc</Address>DWORD, OK