Skill writing added

develop
Simon Jackson 2010-06-16 05:23:24 +08:00 committed by Petr Mrázek
parent 2254f3dfe5
commit 8fb05f24db
2 changed files with 25 additions and 0 deletions

@ -381,6 +381,7 @@ namespace DFHack
bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
bool WriteHappiness(const uint32_t index, const uint32_t happinessValue);
bool WriteFlags(const uint32_t index, const uint32_t flags1, const uint32_t flags2);
bool WriteSkills(const uint32_t index, t_soul &soul);
private:
struct Private;

@ -385,6 +385,30 @@ bool Creatures::WriteFlags(const uint32_t index,
return true;
}
bool Creatures::WriteSkills(const uint32_t index, t_soul &soul)
{
if(!d->Started)
return false;
uint32_t temp = d->p_cre->at (index);
Process * p = d->owner;
uint32_t souloff = p->readDWord(temp + d->creatures.default_soul_offset);
if(!souloff)
return false;
DfVector<uint32_t> skills(p, souloff + d->creatures.soul_skills_vector_offset);
for (uint32_t i=0; i<soul.numSkills; i++)
{
uint32_t temp2 = skills[i];
p->writeByte(temp2 + 4, soul.skills[i].rating);
p->writeWord(temp2 + 8, soul.skills[i].experience);
}
return true;
}
uint32_t Creatures::GetDwarfRaceIndex()
{
if(!d->Inited) return 0;