Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_worker_building_entry_handlers.cpp
Go to the documentation of this file.
4
5//FIXME
6bool buildingIsMaster(uint16_t building_type)
7{
8 if ((building_type == 0x18) || (building_type == 0x1f) || (building_type == 0x0b))
9 {
10 return true;
11 }
12 return false;
13}
14
15
16void __thiscall building_repair(SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
17{
18 uint16_t worker_building = toolboxAPI.getFigureXData(_this->CGdFigureToolBox, figure_id,
20 if (worker_building != 0)
21 {
22 buildingAPI.releaseWorkers(_this->CGdBuilding, building_id, 1);
23 uint16_t job_to = kGdJobBuilderSearchForWork;
24 uint16_t job_from = _this->CGdFigure->figures[figure_id].current_job.GdJobId;
25 figureAPI.prepareJobTransition(_this, figure_id, job_from, job_to);
26 figureAPI.onStartJob(_this, figure_id, kGdJobBuilderSearchForWork);
27 uint16_t spell_index = toolboxAPI.getSpellIndexOfType(_this->CGdFigureToolBox, figure_id,
29 if (spell_index == 0)
30 {
31 spell_index = toolboxAPI.getSpellIndexOfType(_this->CGdFigureToolBox, figure_id,
33 }
34 if (spell_index != 0)
35 {
36 sf_endspell_hook(_this->CGdSpell, spell_index);
37 }
38 }
39}
40typedef void (__thiscall *jobCriticalHit_ptr)(SF_CGdFigureJobs *_this,uint16_t figure_id);
41
42
43void __thiscall default_entry_handler(SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
44{
45 if (building_id != 0)
46 {
47 buildingAPI.freeAssignedWorker(_this->CGdBuildingToolBox, figure_id);
48 }
49 jobCriticalHit_ptr jobCriticalHit = (jobCriticalHit_ptr)(ASI::AddrOf(0x2df980));
50 jobCriticalHit(_this, figure_id);
51}
52
53void __thiscall hq_entry_handler(SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
54{
55 uint8_t good = _this->CGdFigure->figures[figure_id].good;
56 if (good != 0)
57 {
58 figureAPI.setJob(_this, figure_id, kGdJobCarrierCheckDrop);
59 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, EFFECT_ENTITY_INDEX2, building_id);
60 return;
61 }
62 if (building_id != 0)
63 {
64 buildingAPI.freeAssignedWorker(_this->CGdBuildingToolBox, figure_id);
65 }
66 jobCriticalHit_ptr jobCriticalHit = (jobCriticalHit_ptr)(ASI::AddrOf(0x2df980));
67 jobCriticalHit(_this, figure_id);
68}
69
70void __thiscall woodcutter_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
71{
72 uint8_t good = _this->CGdFigure->figures[figure_id].good;
73
74 if (good == 0)
75 {
76 figureAPI.setJob(_this, figure_id, kGdJobWoodCutterSearchTree);
77 }
78 else
79 {
80 figureAPI.setJob(_this, figure_id, kGdJobWoodCutterCheckDrop);
81 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, EFFECT_ENTITY_INDEX2, building_id);
82 }
83 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, WORKER_HOST_BUILDING_POS_X,
84 _this->CGdBuilding->buildings[building_id].position.X);
85 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, WORKER_HOST_BUILDING_POS_Y,
86 _this->CGdBuilding->buildings[building_id].position.Y);
87 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
89 if (buildingIsMaster(_this->CGdBuilding->buildings[building_id].type))
90 {
92 }
93 figureAPI.setTask(_this->CGdFigure, figure_id, task);
94 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 5, 0);
95 SF_SGtFigureAction action;
96 action.type = 0;
97 action.subtype = 1;
98 action.cooldown_action = 0;
99 action.cooldown_global = 0;
100 figureAPI.addAction(_this->CGdFigure, figure_id, &action);
101}
102
103void __thiscall sawmill_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
104{
105 figureAPI.setJob(_this, figure_id, kGdJobCarpenterSearchForWork);
106 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
107 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_CARPENTER);
108 uint8_t race = _this->CGdBuilding->buildings[building_id].race;
109 if (race == 2)
110 {
111 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 9, 17);
112 }
113 else
114 {
115 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0);
116 }
117}
118
119void __thiscall cattle_breeder_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
120{
121 figureAPI.setJob(_this, figure_id, kGdJobCattleBreederSearchForWork);
122 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
123 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_CATTLE_BREEDER);
124 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0);
125}
126
127void __thiscall quarry_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
128{
129 uint8_t good = _this->CGdFigure->figures[figure_id].good;
130 if (good == 0)
131 {
132 figureAPI.setJob(_this, figure_id, kGdJobStoneMinerSearchStone);
133 }
134 else
135 {
136 figureAPI.setJob(_this, figure_id, kGdJobStoneMinerCheckDrop);
137 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, EFFECT_ENTITY_INDEX2, building_id);
138 }
139 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, WORKER_HOST_BUILDING_POS_X,
140 _this->CGdBuilding->buildings[building_id].position.X);
141 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, WORKER_HOST_BUILDING_POS_Y,
142 _this->CGdBuilding->buildings[building_id].position.Y);
143 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
144 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_QUARRY);
145 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 6, 0);
146 SF_SGtFigureAction action;
147 action.type = 0;
148 action.subtype = 3;
149 action.cooldown_action = 0;
150 action.cooldown_global = 0;
151 figureAPI.addAction(_this->CGdFigure, figure_id, &action);
152}
153
154void __thiscall foodstore_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
155{
156 figureAPI.setJob(_this, figure_id, kGdJobFoodWorkerSearchForWork);
157 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
158 uint8_t race = _this->CGdBuilding->buildings[building_id].race;
159 if (race == 2 || race == 4 )
160 {
161 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0x12, 0);
162 }
163 else
164 {
165 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0);
166 }
167 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_STOREKEEPER);
168}
169
170typedef void (__thiscall *updateHunterList_ptr)(SF_CGdFigureJobs *_this,uint16_t figure_id);
171
172void __thiscall hunter_entry_handler (SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
173{
174 figureAPI.setJob(_this, figure_id, kGdJobHunterSearchForWork);
175 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
177 if (buildingIsMaster(_this->CGdBuilding->buildings[building_id].type))
178 {
180 }
181 figureAPI.setTask(_this->CGdFigure, figure_id, task);
182 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 8);
183 updateHunterList_ptr updateHunterList = (updateHunterList_ptr)ASI::AddrOf(0x2e1f40);
184 updateHunterList(_this, figure_id);
185}
186
187void __thiscall fisher_entry_handler (SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
188{
189 figureAPI.setJob(_this, figure_id, kGdJobFisherSearchForWork);
190 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
192 if (buildingIsMaster(_this->CGdBuilding->buildings[building_id].type))
193 {
195 }
196 figureAPI.setTask(_this->CGdFigure, figure_id, task);
197 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 3, 0);
198}
199
200void __thiscall farmer_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
201{
202 figureAPI.setJob(_this, figure_id, kGdJobFarmerWaitForWork);
203 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
204 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_FARMER);
205 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0);
206}
207
208void __thiscall miner_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
209{
210 figureAPI.setJob(_this, figure_id, kGdJobMinerSearchResource);
211 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, WORKER_HOST_BUILDING_POS_X,
212 _this->CGdBuilding->buildings[building_id].position.X);
213 toolboxAPI.setFigureXData(_this->CGdFigureToolBox, figure_id, WORKER_HOST_BUILDING_POS_Y,
214 _this->CGdBuilding->buildings[building_id].position.Y);
215 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
216 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_MINE);
217 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 6, 0);
218 SF_SGtFigureAction action;
219 action.type = 0;
220 action.subtype = 8;
221 if (buildingIsMoonsilverMine(_this->CGdBuilding, building_id))
222 {
223 action.subtype = 6;
224 }
225 action.cooldown_action = 0;
226 action.cooldown_global = 0;
227 figureAPI.addAction(_this->CGdFigure, figure_id, &action);
228}
229
230void __thiscall smelter_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
231{
232 figureAPI.setJob(_this, figure_id, kGdJobSmelterSearchForWork);
233 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
234 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_SMELTER);
235 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0xe, 0);
236}
237
238//aria and lenya
239void __thiscall shrine_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
240{
241 figureAPI.setJob(_this, figure_id, kGdJobShrineWorkerSearchForWork);
242 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
243 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_SHRINE);
244 uint8_t race = _this->CGdBuilding->buildings[building_id].race;
245 if (race == 1 || race == 6 )
246 {
247 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0x0f, 0);
248 }
249 else
250 {
251 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0);
252 }
253}
254
255void __thiscall temple_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
256{
257 figureAPI.setJob(_this, figure_id, kGdJobPriestSearchForWork);
258 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
259 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_PRIEST);
260 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0x0, 0);
261 uint8_t race = _this->CGdBuilding->buildings[building_id].race;
262 uint8_t bvar1 = 1;
263 uint16_t owner = _this->CGdBuilding->buildings[building_id].owner;
264 buildingAPI.updateProduction(_this->CGdPlayer, owner, race, bvar1, 1);
265}
266
267void __thiscall forester_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
268{
269 figureAPI.setJob(_this, figure_id, kGdJobForesterSearchForWork);
270 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
271 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_FORESTER);
272 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0);
273}
274
275void __thiscall gatherer_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
276{
277 figureAPI.setJob(_this, figure_id, kGdJobGathererSearchResource);
278 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
279 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_GATHERER);
280 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0x0b, 0);
281}
282
283void __thiscall forge_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
284{
285 figureAPI.setJob(_this, figure_id, kGdJobSmithSearchForWork);
286 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
287 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_FORGE);
288 uint8_t race = _this->CGdBuilding->buildings[building_id].race;
289 switch (race)
290 {
291 case 4:
292 {
293 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0x12);
294 break;
295 }
296 case 3:
297 {
298 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0x10, 0);
299 break;
300 }
301 default:
302 {
303 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 9, 0);
304 break;
305 }
306 }
307 uint8_t bvar1 = 0;
308 uint16_t owner = _this->CGdBuilding->buildings[building_id].owner;
309 buildingAPI.updateProduction(_this->CGdPlayer, owner, race, bvar1, 1);
310}
311
312void __thiscall mace_carver_entry_handler (SF_CGdFigureJobs *_this,uint16_t figure_id, uint16_t building_id)
313{
314 figureAPI.setJob(_this, figure_id, kGdJobClubMakerSearchForWork);
315 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
316 figureAPI.setTask(_this->CGdFigure, figure_id, CGdFigureTask::TASK_MACE_CARVER);
317 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 0x12);
318
319 uint8_t race = _this->CGdBuilding->buildings[building_id].race;
320 uint8_t bvar1 = 2;
321 uint16_t owner = _this->CGdBuilding->buildings[building_id].owner;
322 buildingAPI.updateProduction(_this->CGdPlayer, owner, race, bvar1, 1);
323}
324typedef void (__thiscall *updateScavengerList_ptr)(SF_CGdFigureJobs *_this,uint16_t figure_id);
325
326void __thiscall scavenger_entry_handler (SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
327{
328 figureAPI.setJob(_this, figure_id, kGdJobCorpseCollectorSearchForWork);
329 toolboxAPI.equipArtisanArmour(_this->CGdFigureToolBox, figure_id);
331 figureAPI.setTask(_this->CGdFigure, figure_id, task);
332 toolboxAPI.equipArtisanTools(_this->CGdFigureToolBox, figure_id, 0, 8);
333 updateScavengerList_ptr updateScavengerList = (updateScavengerList_ptr)ASI::AddrOf(0x2df340);
334 updateScavengerList(_this, figure_id);
335}
FigureFunctions * figureAPI
Definition TestMod.cpp:13
ToolboxFunctions * toolboxAPI
Definition TestMod.cpp:12
void __thiscall sf_endspell_hook(SF_CGdSpell *_this, uint16_t spell_index)
BuildingFunctions buildingAPI
Definition sf_hooks.c:47
bool __thiscall buildingIsMoonsilverMine(SF_CGdBuilding *_this, uint16_t building_index)
int AddrOf(int offset)
returns "real" virtual address of given memory offset
Definition sf_asi.h:135
@ kGdJobCarrierCheckDrop
@ kGdJobMinerSearchResource
@ kGdJobFisherSearchForWork
@ kGdJobSmithSearchForWork
@ kGdJobFarmerWaitForWork
@ kGdJobSmelterSearchForWork
@ kGdJobStoneMinerCheckDrop
@ kGdJobHunterSearchForWork
@ kGdJobClubMakerSearchForWork
@ kGdJobWoodCutterCheckDrop
@ kGdJobCarpenterSearchForWork
@ kGdJobBuilderSearchForWork
@ kGdJobFoodWorkerSearchForWork
@ kGdJobStoneMinerSearchStone
@ kGdJobCorpseCollectorSearchForWork
@ kGdJobPriestSearchForWork
@ kGdJobGathererSearchResource
@ kGdJobCattleBreederSearchForWork
@ kGdJobForesterSearchForWork
@ kGdJobShrineWorkerSearchForWork
@ kGdJobWoodCutterSearchTree
@ TASK_HUNTING_LODGE
@ TASK_MASTER_WOODCUTTER
@ TASK_MACE_CARVER
@ TASK_CATTLE_BREEDER
@ TASK_STOREKEEPER
@ TASK_MASTER_FISHER
@ TASK_WOODCUTTER
@ WORKER_HOST_BUILDING_POS_Y
@ EFFECT_ENTITY_INDEX2
@ SPELL_CONSERVATION_SHIELD
@ WORKER_HOST_BUILDING_POS_X
@ kGdSpellLineInvisibility
@ kGdSpellLineFeignDeath
void __thiscall foodstore_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall fisher_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void(__thiscall * updateHunterList_ptr)(SF_CGdFigureJobs *_this, uint16_t figure_id)
void __thiscall hq_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall scavenger_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall forge_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall gatherer_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall mace_carver_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall default_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall building_repair(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall forester_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall temple_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall miner_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void(__thiscall * updateScavengerList_ptr)(SF_CGdFigureJobs *_this, uint16_t figure_id)
void __thiscall quarry_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall farmer_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
bool buildingIsMaster(uint16_t building_type)
void __thiscall shrine_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall sawmill_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall hunter_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall smelter_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall woodcutter_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void(__thiscall * jobCriticalHit_ptr)(SF_CGdFigureJobs *_this, uint16_t figure_id)
void __thiscall cattle_breeder_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
FigureJobData current_job
GdBuilding buildings[1000]
GdFigure figures[2000]
SF_CGdBuilding * CGdBuilding
SF_CGdFigureToolbox * CGdFigureToolBox
SF_CGdBuildingToolbox * CGdBuildingToolBox