Add simple creature probe, fix current civ address on windows, update df2mc.

develop
Petr Mrázek 2011-11-02 00:26:45 +01:00
parent 6bbc27dbce
commit dcce48c243
3 changed files with 38 additions and 1 deletions

@ -2269,6 +2269,7 @@
<Address name="mouse_xy" value="0xb35084" /> <Address name="mouse_xy" value="0xb35084" />
</Group> </Group>
<Group name="Creatures"> <Group name="Creatures">
<Address name="current_civ" value="0x14F0C1C" />
<Address name="current_race" value="0x14F0C28" /> <Address name="current_race" value="0x14F0C28" />
<Group name="creature"> <Group name="creature">
<Offset name="flags3" value="0xE8"/> <Offset name="flags3" value="0xE8"/>

@ -1 +1 @@
Subproject commit 704705708861ebf46d2d8bea64d08cf3d4986eed Subproject commit 0f6389f4121d6cf3d447fb72a5b561d8d66b0de8

@ -15,6 +15,7 @@ using namespace std;
#include <dfhack/PluginManager.h> #include <dfhack/PluginManager.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <dfhack/modules/Creatures.h>
#include <dfhack/modules/Maps.h> #include <dfhack/modules/Maps.h>
#include <dfhack/modules/Gui.h> #include <dfhack/modules/Gui.h>
#include <dfhack/modules/Materials.h> #include <dfhack/modules/Materials.h>
@ -27,6 +28,7 @@ using std::string;
using namespace DFHack; using namespace DFHack;
DFhackCExport command_result df_probe (Core * c, vector <string> & parameters); DFhackCExport command_result df_probe (Core * c, vector <string> & parameters);
DFhackCExport command_result df_cprobe (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -39,6 +41,9 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
commands.push_back(PluginCommand("probe", commands.push_back(PluginCommand("probe",
"A tile probe", "A tile probe",
df_probe)); df_probe));
commands.push_back(PluginCommand("cprobe",
"A creature probe",
df_cprobe));
return CR_OK; return CR_OK;
} }
@ -47,6 +52,37 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_cprobe (Core * c, vector <string> & parameters)
{
Console & con = c->con;
BEGIN_PROBE:
c->Suspend();
DFHack::Gui *Gui = c->getGui();
DFHack::Creatures * cr = c->getCreatures();
int32_t cursorX, cursorY, cursorZ;
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX == -30000)
{
con.printerr("No cursor; place cursor over creature to probe.\n");
}
else
{
uint32_t ncr;
cr->Start(ncr);
for(auto i = 0; i < ncr; i++)
{
df_creature * unit = cr->GetCreature( i );
if(unit->x == cursorX && unit->y == cursorY && unit->z == cursorZ)
{
con.print("Creature %d, race %d (%x), civ %d (%x)\n", unit->id, unit->race, unit->race, unit->civ, unit->civ);
break;
}
}
}
c->Resume();
return CR_OK;
}
DFhackCExport command_result df_probe (Core * c, vector <string> & parameters) DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
{ {
//bool showBlock, showDesig, showOccup, showTile, showMisc; //bool showBlock, showDesig, showOccup, showTile, showMisc;