More tweaks related to creatures, murder implication flag for items/corpse pieces.

develop
Petr Mrázek 2011-09-21 13:47:12 +02:00
parent dca4c43b0b
commit 1df71d2b7a
4 changed files with 44 additions and 74 deletions

@ -73,7 +73,7 @@ union t_itemflags
unsigned int unk3 : 1; ///< 0000 0800 unknown, unseen, unusable unsigned int unk3 : 1; ///< 0000 0800 unknown, unseen, unusable
unsigned int unk4 : 1; ///< 0000 1000 unknown, unseen unsigned int unk4 : 1; ///< 0000 1000 unknown, unseen
unsigned int unk5 : 1; ///< 0000 2000 unknown, unseen unsigned int murder : 1; ///< 0000 2000 Implies murder - used in fell moods
unsigned int foreign : 1; ///< 0000 4000 Item is imported unsigned int foreign : 1; ///< 0000 4000 Item is imported
unsigned int trader : 1; ///< 0000 8000 Item ownwed by trader unsigned int trader : 1; ///< 0000 8000 Item ownwed by trader

@ -53,73 +53,12 @@ struct Creatures::Private
{ {
bool Inited; bool Inited;
bool Started; bool Started;
/*
bool Ft_basic;
bool Ft_advanced;
bool Ft_jobs;
bool Ft_job_materials;
bool Ft_soul;
bool Ft_inventory;
bool Ft_owned_items;
struct t_offsets
{
// creature offsets
uint32_t vector;
uint32_t pos_offset;
uint32_t profession_offset;
uint32_t custom_profession_offset;
uint32_t race_offset;
int32_t civ_offset;
uint32_t flags1_offset;
uint32_t flags2_offset;
uint32_t flags3_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;
uint32_t artifact_name_offset;
uint32_t physical_offset;
uint32_t mood_offset;
uint32_t pregnancy_offset;
uint32_t pregnancy_ptr_offset;
uint32_t mood_skill_offset;
uint32_t pickup_equipment_bit;
uint32_t soul_vector_offset;
uint32_t default_soul_offset;
uint32_t current_job_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;
uint32_t name_words_offset;
uint32_t soul_mental_offset;
uint32_t soul_traits_offset;
uint32_t appearance_vector_offset;
uint32_t birth_year_offset;
uint32_t birth_time_offset;
uint32_t inventory_offset;
uint32_t owned_items_offset;
// creature job stuff
int32_t job_type_offset;
int32_t job_id_offset;
int32_t job_materials_vector;
int32_t job_material_itemtype_o;
int32_t job_material_subtype_o;
int32_t job_material_subindex_o;
int32_t job_material_index_o;
int32_t job_material_flags_o;
// creature job material stuff
} creatures;
*/
uint32_t creature_module;
uint32_t dwarf_race_index_addr; uint32_t dwarf_race_index_addr;
uint32_t dwarf_civ_id_addr; uint32_t dwarf_civ_id_addr;
bool IdMapReady; bool IdMapReady;
std::map<int32_t, int32_t> IdMap; std::map<int32_t, int32_t> IdMap;
//DfVector <uint32_t> *p_cre;
Process *owner; Process *owner;
Translation * trans; Translation * trans;
}; };
@ -132,7 +71,6 @@ Module* DFHack::createCreatures()
Creatures::Creatures() Creatures::Creatures()
{ {
Core & c = Core::getInstance(); Core & c = Core::getInstance();
creatures = 0;
d = new Private; d = new Private;
d->owner = c.p; d->owner = c.p;
VersionInfo * minfo = c.vinfo; VersionInfo * minfo = c.vinfo;
@ -140,16 +78,11 @@ Creatures::Creatures()
d->Started = false; d->Started = false;
d->IdMapReady = false; d->IdMapReady = false;
d->trans = c.getTranslation(); d->trans = c.getTranslation();
d->trans->InitReadNames(); // throws on error d->trans->InitReadNames(); // FIXME: throws on error
OffsetGroup *OG_Creatures = minfo->getGroup("Creatures"); OffsetGroup *OG_Creatures = minfo->getGroup("Creatures");
OffsetGroup *OG_creature = OG_Creatures->getGroup("creature");
OffsetGroup *OG_creature_ex = OG_creature->getGroup("advanced");
OffsetGroup *OG_soul = OG_Creatures->getGroup("soul");
OffsetGroup * OG_name = minfo->getGroup("name");
OffsetGroup * OG_jobs = OG_Creatures->getGroup("job");
OffsetGroup * OG_job_mats = OG_jobs->getGroup("material");
creatures = 0;
try try
{ {
creatures = (vector <df_creature *> *) OG_Creatures->getAddress ("vector"); creatures = (vector <df_creature *> *) OG_Creatures->getAddress ("vector");
@ -172,6 +105,7 @@ bool Creatures::Start( uint32_t &numcreatures )
{ {
d->Started = true; d->Started = true;
numcreatures = creatures->size(); numcreatures = creatures->size();
d->IdMap.clear();
d->IdMapReady = false; d->IdMapReady = false;
return true; return true;
} }

@ -67,7 +67,7 @@ public:
t_itemflags &f = itm->base->flags; t_itemflags &f = itm->base->flags;
return (f.unk1 || f.unk2 || f.unk3 || f.unk4 || f.unk5 || return (f.unk1 || f.unk2 || f.unk3 || f.unk4 || /*f.unk5 ||*/
f.unk6 || f.unk7 || f.unk6 || f.unk7 ||
// f.unk8 || f.unk9 || /* Too common */ // f.unk8 || f.unk9 || /* Too common */
f.unk10 || f.unk11); f.unk10 || f.unk11);
@ -100,7 +100,7 @@ public:
if (f.unk2) flags.push_back("unk2"); if (f.unk2) flags.push_back("unk2");
if (f.unk3) flags.push_back("unk3"); if (f.unk3) flags.push_back("unk3");
if (f.unk4) flags.push_back("unk4"); if (f.unk4) flags.push_back("unk4");
if (f.unk5) flags.push_back("unk5"); //if (f.unk5) flags.push_back("unk5");
if (f.unk6) flags.push_back("unk6"); if (f.unk6) flags.push_back("unk6");
if (f.unk7) flags.push_back("unk7"); if (f.unk7) flags.push_back("unk7");
if (f.unk8) flags.push_back("unk8"); if (f.unk8) flags.push_back("unk8");

@ -26,6 +26,7 @@ DFhackCExport command_result bflags (Core * c, vector <string> & parameters);
DFhackCExport command_result trackmenu (Core * c, vector <string> & parameters); DFhackCExport command_result trackmenu (Core * c, vector <string> & parameters);
DFhackCExport command_result mapitems (Core * c, vector <string> & parameters); DFhackCExport command_result mapitems (Core * c, vector <string> & parameters);
DFhackCExport command_result test_creature_offsets (Core * c, vector <string> & parameters); DFhackCExport command_result test_creature_offsets (Core * c, vector <string> & parameters);
DFhackCExport command_result creat_job (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -41,6 +42,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
commands.push_back(PluginCommand("trackmenu","Track menu ID changes (toggle).",trackmenu)); commands.push_back(PluginCommand("trackmenu","Track menu ID changes (toggle).",trackmenu));
commands.push_back(PluginCommand("mapitems","Check item ids under cursor against item ids in map block.",mapitems)); commands.push_back(PluginCommand("mapitems","Check item ids under cursor against item ids in map block.",mapitems));
commands.push_back(PluginCommand("test_creature_offsets","Bleh.",test_creature_offsets)); commands.push_back(PluginCommand("test_creature_offsets","Bleh.",test_creature_offsets));
commands.push_back(PluginCommand("creat_job","Bleh.",creat_job));
return CR_OK; return CR_OK;
} }
@ -301,3 +303,37 @@ command_result test_creature_offsets(Core* c, vector< string >& parameters)
c->con.print("Struct 0x%x, vinfo 0x%x\n", off_struct, off_vinfo); c->con.print("Struct 0x%x, vinfo 0x%x\n", off_struct, off_vinfo);
return CR_OK; return CR_OK;
}; };
command_result creat_job (Core * c, vector< string >& parameters)
{
c->Suspend();
Creatures * cr = c->getCreatures();
Gui * g = c-> getGui();
uint32_t num_cr = 0;
int32_t cx,cy,cz;
g->getCursorCoords(cx,cy,cz);
if(cx == -30000)
{
c->con.printerr("No cursor.\n");
c->Resume();
return CR_FAILURE;
}
if(!cr->Start(num_cr) || num_cr == 0)
{
c->con.printerr("No creatures.\n");
c->Resume();
return CR_FAILURE;
}
auto iter = cr->creatures->begin();
while (iter != cr->creatures->end())
{
df_creature * unit = *iter;
if(cx == unit->x && cy == unit->y && cz == unit->z)
{
c->con.print("%d:%s - address 0x%x - job 0x%x\n", unit->id, unit->name.first_name.c_str(), unit, uint32_t(unit) + offsetof(df_creature,current_job));
}
iter++;
}
c->Resume();
return CR_OK;
};