|
|
@ -26,11 +26,11 @@ distribution.
|
|
|
|
#ifndef CL_MOD_CREATURES
|
|
|
|
#ifndef CL_MOD_CREATURES
|
|
|
|
#define CL_MOD_CREATURES
|
|
|
|
#define CL_MOD_CREATURES
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Creatures
|
|
|
|
* Creatures
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#include "Export.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "Module.h"
|
|
|
|
|
|
|
|
#include "modules/Items.h"
|
|
|
|
#include "modules/Items.h"
|
|
|
|
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "df/unit.h"
|
|
|
|
#include "df/unit.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -39,234 +39,161 @@ distribution.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
namespace DFHack
|
|
|
|
namespace DFHack
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// FIXME: WTF IS THIS SHIT?
|
|
|
|
namespace Simple
|
|
|
|
/*
|
|
|
|
{
|
|
|
|
struct t_labor
|
|
|
|
namespace Units
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string name;
|
|
|
|
/**
|
|
|
|
uint8_t value;
|
|
|
|
* \ingroup grp_units
|
|
|
|
t_labor() {
|
|
|
|
*/
|
|
|
|
value =0;
|
|
|
|
struct t_skill
|
|
|
|
}
|
|
|
|
{
|
|
|
|
t_labor(const t_labor & b){
|
|
|
|
uint32_t id;
|
|
|
|
name=b.name;
|
|
|
|
uint32_t rating;
|
|
|
|
value=b.value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
t_labor & operator=(const t_labor &b){
|
|
|
|
|
|
|
|
name=b.name;
|
|
|
|
|
|
|
|
value=b.value;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct t_skill
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string name;
|
|
|
|
|
|
|
|
uint16_t id;
|
|
|
|
|
|
|
|
uint32_t experience;
|
|
|
|
uint32_t experience;
|
|
|
|
uint16_t rating;
|
|
|
|
};
|
|
|
|
t_skill(){
|
|
|
|
/**
|
|
|
|
id=rating=0;
|
|
|
|
* \ingroup grp_units
|
|
|
|
experience=0;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
struct t_job
|
|
|
|
t_skill(const t_skill & b)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool active;
|
|
|
|
name=b.name;
|
|
|
|
uint32_t jobId;
|
|
|
|
id=b.id;
|
|
|
|
uint8_t jobType;
|
|
|
|
experience=b.experience;
|
|
|
|
uint32_t occupationPtr;
|
|
|
|
rating=b.rating;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
t_skill & operator=(const t_skill &b)
|
|
|
|
* \ingroup grp_units
|
|
|
|
{
|
|
|
|
*/
|
|
|
|
name=b.name;
|
|
|
|
struct t_like
|
|
|
|
id=b.id;
|
|
|
|
{
|
|
|
|
experience=b.experience;
|
|
|
|
int16_t type;
|
|
|
|
rating=b.rating;
|
|
|
|
int16_t itemClass;
|
|
|
|
return *this;
|
|
|
|
int16_t itemIndex;
|
|
|
|
}
|
|
|
|
t_matglossPair material;
|
|
|
|
};
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
uint32_t mystery;
|
|
|
|
struct t_trait
|
|
|
|
};
|
|
|
|
{
|
|
|
|
|
|
|
|
uint16_t value;
|
|
|
|
// FIXME: THIS IS VERY, VERY BAD.
|
|
|
|
string displayTxt;
|
|
|
|
#define NUM_CREATURE_LABORS 96
|
|
|
|
string name;
|
|
|
|
#define NUM_CREATURE_TRAITS 30
|
|
|
|
t_trait(){
|
|
|
|
#define NUM_CREATURE_MENTAL_ATTRIBUTES 13
|
|
|
|
value=0;
|
|
|
|
#define NUM_CREATURE_PHYSICAL_ATTRIBUTES 6
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
t_trait(const t_trait &b)
|
|
|
|
* Structure for holding a copy of a DF unit's soul
|
|
|
|
{
|
|
|
|
* \ingroup grp_units
|
|
|
|
name=b.name;
|
|
|
|
*/
|
|
|
|
displayTxt=b.displayTxt;
|
|
|
|
struct t_soul
|
|
|
|
value=b.value;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
uint8_t numSkills;
|
|
|
|
t_trait & operator=(const t_trait &b)
|
|
|
|
t_skill skills[256];
|
|
|
|
{
|
|
|
|
//uint8_t numLikes;
|
|
|
|
name=b.name;
|
|
|
|
//t_like likes[32];
|
|
|
|
displayTxt=b.displayTxt;
|
|
|
|
uint16_t traits[NUM_CREATURE_TRAITS];
|
|
|
|
value=b.value;
|
|
|
|
t_attrib analytical_ability;
|
|
|
|
return *this;
|
|
|
|
t_attrib focus;
|
|
|
|
}
|
|
|
|
t_attrib willpower;
|
|
|
|
};
|
|
|
|
t_attrib creativity;
|
|
|
|
*/
|
|
|
|
t_attrib intuition;
|
|
|
|
/**
|
|
|
|
t_attrib patience;
|
|
|
|
* \ingroup grp_units
|
|
|
|
t_attrib memory;
|
|
|
|
*/
|
|
|
|
t_attrib linguistic_ability;
|
|
|
|
struct t_skill
|
|
|
|
t_attrib spatial_sense;
|
|
|
|
{
|
|
|
|
t_attrib musicality;
|
|
|
|
uint32_t id;
|
|
|
|
t_attrib kinesthetic_sense;
|
|
|
|
uint32_t rating;
|
|
|
|
t_attrib empathy;
|
|
|
|
uint32_t experience;
|
|
|
|
t_attrib social_awareness;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
#define MAX_COLORS 15
|
|
|
|
* \ingroup grp_units
|
|
|
|
struct df_unit;
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
struct t_job
|
|
|
|
* Structure for holding a limited copy of a DF unit
|
|
|
|
{
|
|
|
|
* \ingroup grp_units
|
|
|
|
bool active;
|
|
|
|
*/
|
|
|
|
uint32_t jobId;
|
|
|
|
struct t_unit
|
|
|
|
uint8_t jobType;
|
|
|
|
{
|
|
|
|
uint32_t occupationPtr;
|
|
|
|
df::unit * origin;
|
|
|
|
};
|
|
|
|
uint16_t x;
|
|
|
|
/**
|
|
|
|
uint16_t y;
|
|
|
|
* \ingroup grp_units
|
|
|
|
uint16_t z;
|
|
|
|
*/
|
|
|
|
uint32_t race;
|
|
|
|
struct t_like
|
|
|
|
int32_t civ;
|
|
|
|
{
|
|
|
|
|
|
|
|
int16_t type;
|
|
|
|
df::unit_flags1 flags1;
|
|
|
|
int16_t itemClass;
|
|
|
|
df::unit_flags2 flags2;
|
|
|
|
int16_t itemIndex;
|
|
|
|
df::unit_flags3 flags3;
|
|
|
|
t_matglossPair material;
|
|
|
|
|
|
|
|
bool active;
|
|
|
|
t_name name;
|
|
|
|
uint32_t mystery;
|
|
|
|
|
|
|
|
};
|
|
|
|
int16_t mood;
|
|
|
|
|
|
|
|
int16_t mood_skill;
|
|
|
|
// FIXME: THIS IS VERY, VERY BAD.
|
|
|
|
t_name artifact_name;
|
|
|
|
#define NUM_CREATURE_LABORS 96
|
|
|
|
|
|
|
|
#define NUM_CREATURE_TRAITS 30
|
|
|
|
uint8_t profession;
|
|
|
|
#define NUM_CREATURE_MENTAL_ATTRIBUTES 13
|
|
|
|
std::string custom_profession;
|
|
|
|
#define NUM_CREATURE_PHYSICAL_ATTRIBUTES 6
|
|
|
|
|
|
|
|
/**
|
|
|
|
// enabled labors
|
|
|
|
* Structure for holding a copy of a DF unit's soul
|
|
|
|
uint8_t labors[NUM_CREATURE_LABORS];
|
|
|
|
* \ingroup grp_units
|
|
|
|
t_job current_job;
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct t_soul
|
|
|
|
uint32_t happiness;
|
|
|
|
{
|
|
|
|
uint32_t id;
|
|
|
|
uint8_t numSkills;
|
|
|
|
t_attrib strength;
|
|
|
|
t_skill skills[256];
|
|
|
|
t_attrib agility;
|
|
|
|
//uint8_t numLikes;
|
|
|
|
t_attrib toughness;
|
|
|
|
//t_like likes[32];
|
|
|
|
t_attrib endurance;
|
|
|
|
uint16_t traits[NUM_CREATURE_TRAITS];
|
|
|
|
t_attrib recuperation;
|
|
|
|
t_attrib analytical_ability;
|
|
|
|
t_attrib disease_resistance;
|
|
|
|
t_attrib focus;
|
|
|
|
int32_t squad_leader_id;
|
|
|
|
t_attrib willpower;
|
|
|
|
uint8_t sex;
|
|
|
|
t_attrib creativity;
|
|
|
|
uint16_t caste;
|
|
|
|
t_attrib intuition;
|
|
|
|
uint32_t pregnancy_timer; //Countdown timer to giving birth
|
|
|
|
t_attrib patience;
|
|
|
|
//bool has_default_soul;
|
|
|
|
t_attrib memory;
|
|
|
|
//t_soul defaultSoul;
|
|
|
|
t_attrib linguistic_ability;
|
|
|
|
uint32_t nbcolors;
|
|
|
|
t_attrib spatial_sense;
|
|
|
|
uint32_t color[MAX_COLORS];
|
|
|
|
t_attrib musicality;
|
|
|
|
|
|
|
|
t_attrib kinesthetic_sense;
|
|
|
|
int32_t birth_year;
|
|
|
|
t_attrib empathy;
|
|
|
|
uint32_t birth_time;
|
|
|
|
t_attrib social_awareness;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_COLORS 15
|
|
|
|
|
|
|
|
struct df_unit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Structure for holding a limited copy of a DF unit
|
|
|
|
|
|
|
|
* \ingroup grp_units
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct t_unit
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
df::unit * origin;
|
|
|
|
|
|
|
|
uint16_t x;
|
|
|
|
|
|
|
|
uint16_t y;
|
|
|
|
|
|
|
|
uint16_t z;
|
|
|
|
|
|
|
|
uint32_t race;
|
|
|
|
|
|
|
|
int32_t civ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
df::unit_flags1 flags1;
|
|
|
|
|
|
|
|
df::unit_flags2 flags2;
|
|
|
|
|
|
|
|
df::unit_flags3 flags3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t_name name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int16_t mood;
|
|
|
|
|
|
|
|
int16_t mood_skill;
|
|
|
|
|
|
|
|
t_name artifact_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t profession;
|
|
|
|
|
|
|
|
std::string custom_profession;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// enabled labors
|
|
|
|
|
|
|
|
uint8_t labors[NUM_CREATURE_LABORS];
|
|
|
|
|
|
|
|
t_job current_job;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t happiness;
|
|
|
|
|
|
|
|
uint32_t id;
|
|
|
|
|
|
|
|
t_attrib strength;
|
|
|
|
|
|
|
|
t_attrib agility;
|
|
|
|
|
|
|
|
t_attrib toughness;
|
|
|
|
|
|
|
|
t_attrib endurance;
|
|
|
|
|
|
|
|
t_attrib recuperation;
|
|
|
|
|
|
|
|
t_attrib disease_resistance;
|
|
|
|
|
|
|
|
int32_t squad_leader_id;
|
|
|
|
|
|
|
|
uint8_t sex;
|
|
|
|
|
|
|
|
uint16_t caste;
|
|
|
|
|
|
|
|
uint32_t pregnancy_timer; //Countdown timer to giving birth
|
|
|
|
|
|
|
|
//bool has_default_soul;
|
|
|
|
|
|
|
|
//t_soul defaultSoul;
|
|
|
|
|
|
|
|
uint32_t nbcolors;
|
|
|
|
|
|
|
|
uint32_t color[MAX_COLORS];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t birth_year;
|
|
|
|
|
|
|
|
uint32_t birth_time;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The Creatures module - allows reading all non-vermin creatures and their properties
|
|
|
|
* The Creatures module - allows reading all non-vermin creatures and their properties
|
|
|
|
* \ingroup grp_modules
|
|
|
|
* \ingroup grp_modules
|
|
|
|
* \ingroup grp_units
|
|
|
|
* \ingroup grp_units
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class DFHACK_EXPORT Units : public Module
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Units();
|
|
|
|
|
|
|
|
~Units();
|
|
|
|
|
|
|
|
bool Start( uint32_t & numCreatures );
|
|
|
|
|
|
|
|
bool Finish();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Read Functions */
|
|
|
|
DFHACK_EXPORT bool isValid();
|
|
|
|
// Read creatures in a box, starting with index. Returns -1 if no more creatures
|
|
|
|
|
|
|
|
// found. Call repeatedly do get all creatures in a specified box (uses tile coords)
|
|
|
|
|
|
|
|
int32_t GetCreatureInBox(const int32_t index, df::unit ** furball,
|
|
|
|
|
|
|
|
const uint16_t x1, const uint16_t y1,const uint16_t z1,
|
|
|
|
|
|
|
|
const uint16_t x2, const uint16_t y2,const uint16_t z2);
|
|
|
|
|
|
|
|
df::unit * GetCreature(const int32_t index);
|
|
|
|
|
|
|
|
void CopyCreature(df::unit * source, t_unit & target);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ReadJob(const df::unit * unit, std::vector<t_material> & mat);
|
|
|
|
/* Read Functions */
|
|
|
|
|
|
|
|
// Read creatures in a box, starting with index. Returns -1 if no more creatures
|
|
|
|
|
|
|
|
// found. Call repeatedly do get all creatures in a specified box (uses tile coords)
|
|
|
|
|
|
|
|
DFHACK_EXPORT int32_t GetCreatureInBox(const int32_t index, df::unit ** furball,
|
|
|
|
|
|
|
|
const uint16_t x1, const uint16_t y1,const uint16_t z1,
|
|
|
|
|
|
|
|
const uint16_t x2, const uint16_t y2,const uint16_t z2);
|
|
|
|
|
|
|
|
DFHACK_EXPORT df::unit * GetCreature(const int32_t index);
|
|
|
|
|
|
|
|
DFHACK_EXPORT void CopyCreature(df::unit * source, t_unit & target);
|
|
|
|
|
|
|
|
|
|
|
|
bool ReadInventoryByIdx(const uint32_t index, std::vector<df::item *> & item);
|
|
|
|
DFHACK_EXPORT bool ReadJob(const df::unit * unit, std::vector<t_material> & mat);
|
|
|
|
bool ReadInventoryByPtr(const df::unit * unit, std::vector<df::item *> & item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ReadOwnedItemsByIdx(const uint32_t index, std::vector<int32_t> & item);
|
|
|
|
DFHACK_EXPORT bool ReadInventoryByIdx(const uint32_t index, std::vector<df::item *> & item);
|
|
|
|
bool ReadOwnedItemsByPtr(const df::unit * unit, std::vector<int32_t> & item);
|
|
|
|
DFHACK_EXPORT bool ReadInventoryByPtr(const df::unit * unit, std::vector<df::item *> & item);
|
|
|
|
|
|
|
|
|
|
|
|
int32_t FindIndexById(int32_t id);
|
|
|
|
DFHACK_EXPORT bool ReadOwnedItemsByIdx(const uint32_t index, std::vector<int32_t> & item);
|
|
|
|
|
|
|
|
DFHACK_EXPORT bool ReadOwnedItemsByPtr(const df::unit * unit, std::vector<int32_t> & item);
|
|
|
|
|
|
|
|
|
|
|
|
/* Getters */
|
|
|
|
DFHACK_EXPORT int32_t FindIndexById(int32_t id);
|
|
|
|
uint32_t GetDwarfRaceIndex ( void );
|
|
|
|
|
|
|
|
int32_t GetDwarfCivId ( void );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CopyNameTo(df::unit *creature, df::language_name * target);
|
|
|
|
/* Getters */
|
|
|
|
|
|
|
|
DFHACK_EXPORT uint32_t GetDwarfRaceIndex ( void );
|
|
|
|
|
|
|
|
DFHACK_EXPORT int32_t GetDwarfCivId ( void );
|
|
|
|
|
|
|
|
|
|
|
|
bool RemoveOwnedItemByIdx(const uint32_t index, int32_t id);
|
|
|
|
DFHACK_EXPORT void CopyNameTo(df::unit *creature, df::language_name * target);
|
|
|
|
bool RemoveOwnedItemByPtr(df::unit * unit, int32_t id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
DFHACK_EXPORT bool RemoveOwnedItemByIdx(const uint32_t index, int32_t id);
|
|
|
|
struct Private;
|
|
|
|
DFHACK_EXPORT bool RemoveOwnedItemByPtr(df::unit * unit, int32_t id);
|
|
|
|
Private *d;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|