2010-03-21 15:22:02 -06:00
|
|
|
// Catsplosion
|
|
|
|
// By Zhentar
|
2010-03-26 06:01:46 -06:00
|
|
|
// This work of evil makes every cat, male or female, grown or kitten, pregnant
|
|
|
|
// and due within 2 in-game hours...
|
2010-03-21 15:22:02 -06:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <climits>
|
|
|
|
#include <integers.h>
|
|
|
|
#include <vector>
|
2010-03-25 19:40:17 -06:00
|
|
|
#include <stdlib.h> // for rand()
|
2010-03-21 15:22:02 -06:00
|
|
|
using namespace std;
|
|
|
|
|
2010-03-26 06:01:46 -06:00
|
|
|
#include <DFError.h>
|
2010-03-21 15:22:02 -06:00
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <DFHackAPI.h>
|
|
|
|
#include <DFMemInfo.h>
|
|
|
|
#include <DFProcess.h>
|
|
|
|
|
|
|
|
|
|
|
|
vector<DFHack::t_matgloss> creaturestypes;
|
|
|
|
DFHack::memory_info *mem;
|
|
|
|
DFHack::Process *proc;
|
|
|
|
uint32_t creature_pregnancy_offset;
|
|
|
|
|
|
|
|
int fertilizeCat(DFHack::API & DF, const DFHack::t_creature & creature)
|
|
|
|
{
|
2010-03-26 06:01:46 -06:00
|
|
|
if(string(creaturestypes[creature.type].id) == "CAT")
|
|
|
|
{
|
|
|
|
proc->writeDWord(creature.origin + creature_pregnancy_offset, rand() % 100 + 1);
|
|
|
|
return 1;
|
2010-03-21 15:22:02 -06:00
|
|
|
}
|
2010-03-26 06:01:46 -06:00
|
|
|
return 0;
|
2010-03-21 15:22:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
DFHack::API DF("Memory.xml");
|
2010-03-26 06:01:46 -06:00
|
|
|
try
|
|
|
|
{
|
|
|
|
DF.Attach();
|
|
|
|
}
|
|
|
|
catch (exception& e)
|
2010-03-21 15:22:02 -06:00
|
|
|
{
|
2010-03-26 06:01:46 -06:00
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
2010-03-21 15:22:02 -06:00
|
|
|
return 1;
|
2010-03-26 06:01:46 -06:00
|
|
|
}
|
2010-03-21 15:22:02 -06:00
|
|
|
|
|
|
|
proc = DF.getProcess();
|
|
|
|
mem = DF.getMemoryInfo();
|
2010-03-26 06:01:46 -06:00
|
|
|
creature_pregnancy_offset = mem->getOffset("creature_pregnancy");
|
2010-03-21 15:22:02 -06:00
|
|
|
|
|
|
|
if(!DF.ReadCreatureMatgloss(creaturestypes))
|
|
|
|
{
|
|
|
|
cerr << "Can't get the creature types." << endl;
|
2010-03-26 06:01:46 -06:00
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
2010-03-21 15:22:02 -06:00
|
|
|
return 1;
|
|
|
|
}
|
2010-03-26 06:01:46 -06:00
|
|
|
|
2010-03-21 15:22:02 -06:00
|
|
|
uint32_t numCreatures;
|
|
|
|
if(!DF.InitReadCreatures(numCreatures))
|
|
|
|
{
|
|
|
|
cerr << "Can't get creatures" << endl;
|
2010-03-26 06:01:46 -06:00
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
2010-03-21 15:22:02 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-03-26 06:01:46 -06:00
|
|
|
int cats=0;
|
2010-03-21 15:22:02 -06:00
|
|
|
|
|
|
|
for(uint32_t i = 0; i < numCreatures; i++)
|
|
|
|
{
|
|
|
|
DFHack::t_creature temp;
|
|
|
|
DF.ReadCreature(i,temp);
|
|
|
|
cats+=fertilizeCat(DF,temp);
|
|
|
|
}
|
|
|
|
|
2010-03-26 06:01:46 -06:00
|
|
|
cout << cats << " cats impregnated." << endl;
|
2010-03-21 15:22:02 -06:00
|
|
|
|
|
|
|
DF.FinishReadCreatures();
|
|
|
|
DF.Detach();
|
|
|
|
#ifndef LINUX_BUILD
|
2010-03-26 06:01:46 -06:00
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
2010-03-21 15:22:02 -06:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|