1332
|
1
|
|
2 #include "MM7.h"
|
|
3 #include "mm7_data.h"
|
|
4 #include "Actor.h"
|
|
5 #include "Player.h"
|
|
6 #include "Party.h"
|
|
7 #include "AudioPlayer.h"
|
|
8 #include "SpriteObject.h"
|
|
9 #include "Time.h"
|
|
10 #include "stru298.h"
|
|
11 #include "IconFrameTable.h"
|
|
12 #include "Viewport.h"
|
|
13 #include "FactionTable.h"
|
|
14
|
|
15 #include "TurnEngine.h"
|
|
16
|
|
17
|
|
18 #include "TurnEngine.h"
|
|
19 struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased;
|
|
20
|
|
21
|
|
22 //----- (00404544) --------------------------------------------------------
|
|
23 void stru262_TurnBased::SortTurnQueue()
|
|
24 {
|
|
25
|
|
26 int active_actors;
|
|
27 TurnBased_QueueElem *v7; // eax@16
|
|
28 TurnBased_QueueElem *v8; // ecx@18
|
|
29 TurnBased_QueueElem temp_elem;
|
|
30 int i,j;
|
|
31 unsigned int p_type;
|
|
32 unsigned int p_id;
|
|
33
|
|
34 active_actors = this->uActorQueueSize;
|
|
35
|
|
36 for( i=0; i<uActorQueueSize; ++i)
|
|
37 {
|
|
38 p_type = PID_TYPE(pQueue[i].uPackedID);
|
|
39 p_id = PID_ID(pQueue[i].uPackedID);
|
|
40
|
|
41 if ( p_type == OBJECT_Actor )
|
|
42 {
|
|
43 pActors[p_id].uAttributes |= 0x80u;
|
|
44 if ( !pActors[p_id].CanAct() )
|
|
45 {
|
|
46 --active_actors;
|
|
47 pQueue[i].field_4 = 1001;
|
|
48 pActors[p_id].uAttributes &= ~0x80;
|
|
49 }
|
|
50 }
|
|
51 else if ( p_type == OBJECT_Player)
|
|
52 {
|
|
53 if ( !pParty->pPlayers[p_id].CanAct() )
|
|
54 {
|
|
55 --active_actors;
|
|
56 pQueue[i].field_4 = 1001;
|
|
57 }
|
|
58 }
|
|
59 }
|
|
60 //sort
|
|
61 if (uActorQueueSize>0)
|
|
62 {
|
|
63
|
|
64 for( i=0; i<uActorQueueSize-1; ++i)
|
|
65 {
|
|
66 v7=&pQueue[i];
|
|
67 for(j=i+1; j<uActorQueueSize;++j )
|
|
68 {
|
|
69 v8=&pQueue[j];
|
|
70 if ( v8->field_4 < v7->field_4 ||
|
|
71 ((v8->field_4 == v7->field_4) &&
|
|
72 (
|
|
73 ((PID_TYPE(v8->uPackedID) == OBJECT_Player) && (PID_TYPE(v7->uPackedID) == OBJECT_Actor)) ||
|
|
74 ((PID_TYPE(v8->uPackedID) == PID_TYPE(v7->uPackedID)) && (PID_ID(v8->uPackedID) < PID_ID(v7->uPackedID)))
|
|
75 )
|
|
76 )
|
|
77 )
|
|
78 {
|
|
79 memcpy(&temp_elem,v7,sizeof(TurnBased_QueueElem));
|
|
80 memcpy(v7,v8, sizeof(TurnBased_QueueElem));
|
|
81 memcpy(v8, &temp_elem, sizeof(TurnBased_QueueElem));
|
|
82 }
|
|
83 }
|
|
84 }
|
|
85 }
|
|
86
|
|
87 uActorQueueSize = active_actors;
|
|
88
|
|
89 if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
|
|
90 {
|
|
91 uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1;
|
|
92 field_18 |= TE_PLAYER_TURN;
|
|
93 }
|
|
94 else
|
|
95 {
|
|
96 uActiveCharacter = 0;
|
|
97 field_18 &= ~TE_PLAYER_TURN;
|
|
98 }
|
|
99
|
|
100 for(i=0; i<uActorQueueSize; ++i)
|
|
101 {
|
|
102 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)
|
|
103 pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875);
|
|
104 }
|
|
105
|
|
106
|
|
107 }
|
|
108
|
|
109 //----- (0040471C) --------------------------------------------------------
|
|
110 void stru262_TurnBased::_40471C()
|
|
111 {
|
|
112 if ( pParty->bTurnBasedModeOn == 1 )
|
|
113 {
|
|
114 if ( pTurnEngine->field_4 == 2 )
|
|
115 _406457(0);
|
|
116 }
|
|
117 }
|
|
118
|
|
119 //----- (004059DB) --------------------------------------------------------
|
|
120 void stru262_TurnBased::Start()
|
|
121 {
|
|
122 //stru262_TurnBased *v1; // ebx@1
|
|
123 int v3; // esi@1
|
|
124 int v4; // eax@5
|
|
125 unsigned int actor_id; // esi@7
|
|
126 Actor *pActor; // edi@7
|
|
127 unsigned int v7; // eax@9
|
|
128 unsigned int v8; // edx@10
|
|
129 //unsigned __int8 v9; // zf@14
|
|
130 //unsigned __int8 v10; // sf@14
|
|
131 //unsigned __int8 v11; // of@14
|
|
132 //char *v12; // esi@15
|
|
133 //int v13; // ecx@16
|
|
134 //unsigned __int16 v14; // ax@17
|
|
135 int v15; // ecx@18
|
|
136 signed __int64 v16; // qax@19
|
|
137 int v17; // edx@22
|
|
138 unsigned int v18; // esi@27
|
|
139 char *v19; // esi@32
|
|
140 int v20; // edx@33
|
|
141 char *v21; // eax@33
|
|
142 int v22; // ecx@33
|
|
143 int v23; // eax@34
|
|
144 char *v24; // eax@34
|
|
145 char *v25; // ecx@34
|
|
146 int v26; // edx@34
|
|
147 int v27; // eax@38
|
|
148 int v28; // ecx@38
|
|
149 AIDirection v30; // [sp+Ch] [bp-68h]@10
|
|
150 AIDirection v31; // [sp+28h] [bp-4Ch]@10
|
|
151 AIDirection a3; // [sp+44h] [bp-30h]@10
|
|
152 //int v33; // [sp+60h] [bp-14h]@10
|
|
153 int *v34; // [sp+64h] [bp-10h]@6
|
|
154 int v35; // [sp+68h] [bp-Ch]@5
|
|
155 Player *pPlayer; // [sp+6Ch] [bp-8h]@1
|
|
156 int v40b;
|
|
157 unsigned int v37; // [sp+70h] [bp-4h]@7
|
|
158 int activ_players[4];
|
|
159 int players_recovery_time[4];
|
|
160 int a_players_count;
|
|
161 int i,j;
|
|
162 int temp;
|
|
163
|
|
164
|
|
165 pTurnEngine->field_18 &= ~TE_FLAG_2;
|
|
166 //v1 = this;
|
|
167 pEventTimer->TrackGameTime();
|
|
168 pAudioPlayer->StopChannels(-1, -1);
|
|
169 pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0);
|
|
170 pPlayer = pParty->pPlayers;
|
|
171 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength;
|
|
172 dword_50C994 = 0;
|
|
173
|
|
174 this->field_10 = 100;
|
|
175 this->field_0 = 0;
|
|
176 this->field_8 = 64;
|
|
177 this->field_4 = 1;
|
|
178 this->uActorQueueSize = 0;
|
|
179
|
|
180 for ( v3 = 0; v3 < 4 ; ++v3 )
|
|
181 {
|
|
182 if ( pParty->pPlayers[v3].CanAct() )
|
|
183 {
|
|
184 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,v3);
|
|
185 this->pQueue[this->uActorQueueSize].field_C = 2;
|
|
186 this->pQueue[this->uActorQueueSize].uActionLength = 0;
|
|
187 pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0;
|
|
188 ++this->uActorQueueSize;
|
|
189 }
|
|
190 }
|
|
191
|
|
192 for ( v3 = 0; v3 < ai_arrays_size ; ++v3 )
|
|
193 {
|
|
194 actor_id = ai_near_actors_ids[v3];
|
|
195 if (actor_id == 10)
|
|
196 continue;
|
|
197 if ( pActors[actor_id].CanAct() )
|
|
198 {
|
|
199 if ( pActors[actor_id].uAttributes & 0x8000 )
|
|
200 {
|
|
201 v8 = ai_near_actors_targets_pid[actor_id];
|
|
202 pActors[actor_id].uAttributes |= 0x80;
|
|
203 memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v8, &a3, 0), sizeof(AIDirection));
|
|
204 memcpy(&v30, &v31, sizeof(AIDirection));
|
|
205 Actor::AI_StandOrBored(actor_id, 4, 32, &v30);
|
|
206 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,actor_id);
|
|
207 this->pQueue[this->uActorQueueSize].field_C = 2;
|
|
208 this->pQueue[this->uActorQueueSize].uActionLength = 0;
|
|
209 ++this->uActorQueueSize;
|
|
210 }
|
|
211 }
|
|
212 }
|
|
213
|
|
214 a_players_count=0;
|
|
215 for ( v40b = 0; v40b < this->uActorQueueSize; ++v40b )
|
|
216 {
|
|
217 //v13 = PID_TYPE(this->pQueue[0].uPackedID);
|
|
218 if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Player )
|
|
219 {
|
|
220 if ( pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery != 0 )
|
|
221 {
|
|
222 //v33 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery;
|
|
223 v16 = (signed int)((double)pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery * 0.46875);
|
|
224 this->pQueue[v40b].field_4 = v16;
|
|
225 }
|
|
226 else
|
|
227 {
|
|
228 activ_players[a_players_count] = v40b;
|
|
229 ++a_players_count;
|
|
230 }
|
|
231 }
|
|
232 else if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Actor )
|
|
233 {
|
|
234 v17 = rand() % 99;
|
|
235 if ( v17 < 33 )
|
|
236 this->pQueue[v40b].field_4 = 1;
|
|
237 else
|
|
238 this->pQueue[v40b].field_4= (v17 >= 66)? 5 : 3;
|
|
239 }
|
|
240 else
|
|
241 {
|
|
242 this->pQueue[v40b].field_4 = 666;
|
|
243 }
|
|
244 this->pQueue[v40b].field_4 += 16;
|
|
245 }
|
|
246
|
|
247
|
|
248 if ( a_players_count > 0 )
|
|
249 {
|
|
250 for (i=0; i<a_players_count; ++i)
|
|
251 players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0);
|
|
252 //sort players by recovery time
|
|
253 for (i=0; i < a_players_count-1; ++i)
|
|
254 {
|
|
255 for(j=i+1; j<a_players_count;++j )
|
|
256 {
|
|
257 if (players_recovery_time[j] < players_recovery_time[i]) //swap values
|
|
258 {
|
|
259 temp = players_recovery_time[i];
|
|
260 players_recovery_time[i] = players_recovery_time[j];
|
|
261 players_recovery_time[j] = temp;
|
|
262
|
|
263 temp = activ_players[i];
|
|
264 activ_players[i] = activ_players[j];
|
|
265 activ_players[j] = temp;
|
|
266 }
|
|
267 }
|
|
268 }
|
|
269
|
|
270 for (i=0; i<a_players_count; ++i)
|
|
271 {
|
|
272 this->pQueue[activ_players[i]].field_4 = i+2;
|
|
273 }
|
|
274 }
|
|
275 this->SortTurnQueue();
|
|
276 }
|
|
277
|
|
278
|
|
279
|
|
280 //----- (00405CFF) --------------------------------------------------------
|
|
281 void stru262_TurnBased::End(bool bPlaySound)
|
|
282 {
|
|
283
|
|
284 ObjectType objType; // eax@13
|
|
285 int objID; // esi@13
|
|
286 int i;
|
|
287
|
|
288 this->field_4 = 0;
|
|
289
|
|
290 for( i=0; i<uActorQueueSize; ++i)
|
|
291 {
|
|
292 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor )
|
|
293 pActors[PID_ID(pQueue[i].uPackedID)].uAttributes &= ~0x80;
|
|
294 }
|
|
295
|
|
296 for( i=0; i<uNumSpriteObjects; ++i)
|
|
297 {
|
|
298 if (pSpriteObjects[i].uAttributes & 4)
|
|
299 pSpriteObjects[i].uAttributes &= ~0x04;
|
|
300 }
|
|
301
|
|
302 for( i=0; i<uActorQueueSize; ++i)
|
|
303 {
|
|
304 objType = (ObjectType)PID_TYPE(pQueue[i].uPackedID);
|
|
305 objID = PID_ID(pQueue[i].uPackedID);
|
|
306 if ( objType == OBJECT_Player )
|
|
307 {
|
|
308 pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333);
|
|
309 }
|
|
310 else if ( objType == OBJECT_Actor )
|
|
311 {
|
|
312 pActors[objID].pMonsterInfo.uRecoveryTime = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333);
|
|
313 }
|
|
314 }
|
|
315
|
|
316 pAudioPlayer->StopChannels(-1, -1);
|
|
317 if ( bPlaySound != 0 )
|
|
318 pAudioPlayer->PlaySound(SOUND_206, 0, 0, -1, 0, 0, 0, 0);
|
|
319 pTurnEngine->field_18 &= ~TE_FLAG_2;
|
|
320 pEventTimer->StopGameTime();
|
|
321 dword_50C994 = 0;
|
|
322 dword_50C998_turnbased_icon_1A = 0;
|
|
323 }
|
|
324 // 50C994: using guessed type int dword_50C994;
|
|
325 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
|
|
326
|
|
327 //----- (00405E14) --------------------------------------------------------
|
|
328 void stru262_TurnBased::_405E14()
|
|
329 {
|
|
330 stru262_TurnBased *v1; // esi@1
|
|
331 int v2; // ecx@1
|
|
332 SpellBuff *v3; // edi@2
|
|
333 Actor *v4; // ebx@3
|
|
334 signed int v5; // edx@20
|
|
335 AIDirection *v6; // esi@21
|
|
336 int v7; // eax@21
|
|
337 int v8; // eax@21
|
|
338 int v9; // eax@22
|
|
339 int v10; // eax@23
|
|
340 int v11; // eax@37
|
|
341 int v12; // eax@44
|
|
342 AIDirection a3; // [sp+4h] [bp-68h]@21
|
|
343 AIDirection v14; // [sp+20h] [bp-4Ch]@21
|
|
344 AIDirection v15; // [sp+3Ch] [bp-30h]@21
|
|
345 Actor *v16; // [sp+58h] [bp-14h]@2
|
|
346 int v17; // [sp+5Ch] [bp-10h]@6
|
|
347 stru262_TurnBased *v18; // [sp+60h] [bp-Ch]@1
|
|
348 int v19; // [sp+64h] [bp-8h]@8
|
|
349 unsigned int v20; // [sp+68h] [bp-4h]@1
|
|
350
|
|
351 v1 = this;
|
|
352 v2 = 0;
|
|
353 v18 = v1;
|
|
354 v20 = 0;
|
|
355 if ( (signed int)uNumActors > 0 )
|
|
356 {
|
|
357 //v3 = pActors;//[0].pActorBuffs;
|
|
358 v16 = pActors.data();//[0].pActorBuffs;
|
|
359 v3 = v16->pActorBuffs;
|
|
360 do
|
|
361 {
|
|
362 v4 = v16;
|
|
363 if ( SHIDWORD(v3[3].uExpireTime) < v2 || SHIDWORD(v3[3].uExpireTime) <= v2 && LODWORD(v3[3].uExpireTime) <= v2 )
|
|
364 v17 = v2;
|
|
365 else
|
|
366 v17 = 1;
|
|
367 v19 = v2;
|
|
368 do
|
|
369 {
|
|
370 if ( v19 != 10 )
|
|
371 {
|
|
372 v3->_4585CA(pParty->uTimePlayed);
|
|
373 v2 = 0;
|
|
374 }
|
|
375 ++v19;
|
|
376 ++v3;
|
|
377 }
|
|
378 while ( v19 < 22 );
|
|
379 if ( v17 != 0
|
|
380 && SHIDWORD(v4->pActorBuffs[3].uExpireTime) <= 0
|
|
381 && (SHIDWORD(v4->pActorBuffs[3].uExpireTime) < 0 || LODWORD(v4->pActorBuffs[3].uExpireTime) <= 0) )
|
|
382 v4->uActorHeight = pMonsterList->pMonsters[v4->pMonsterInfo.uID - 1].uMonsterHeight;
|
|
383 if ( !(v4->uAttributes & 0x80) )
|
|
384 {
|
|
385 if ( !v4->pActorBuffs[5].uExpireTime )
|
|
386 {
|
|
387 if ( !v4->pActorBuffs[6].uExpireTime )
|
|
388 {
|
|
389 v5 = v4->uCurrentActionLength;
|
|
390 v4->uCurrentActionTime += pMiscTimer->uTimeElapsed;
|
|
391 if ( (signed int)v4->uCurrentActionTime >= v5 )
|
|
392 {
|
|
393 v17 = ai_near_actors_targets_pid[v20];
|
|
394 v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v20), v17, &a3, 0);
|
|
395 v7 = v4->uAIState;
|
|
396 memcpy(&v15, v6, sizeof(v15));
|
|
397 v8 = v7 - 4;
|
|
398 memcpy(&v14, &v15, sizeof(v14));
|
|
399 if ( v8 )
|
|
400 {
|
|
401 v9 = v8 - 1;
|
|
402 if ( v9 )
|
|
403 {
|
|
404 v10 = v9 - 6;
|
|
405 if ( v10 )
|
|
406 {
|
|
407 if ( v10 != 8 )
|
|
408 Actor::AI_StandOrBored(v20, v17, 32, &v14);
|
|
409 }
|
|
410 }
|
|
411 }
|
|
412 else
|
|
413 {
|
|
414 v4->uCurrentActionTime = 0;
|
|
415 v4->uCurrentActionLength = 0;
|
|
416 v4->uAIState = Dead;
|
|
417 v4->UpdateAnimation();
|
|
418 }
|
|
419 v1 = v18;
|
|
420 v2 = 0;
|
|
421 }
|
|
422 }
|
|
423 }
|
|
424 }
|
|
425 ++v20;
|
|
426 v3 = v16[1].pActorBuffs;
|
|
427 ++v16;
|
|
428 }
|
|
429 while ( (signed int)v20 < (signed int)uNumActors );
|
|
430 }
|
|
431 if ( v1->field_4 == 1 )
|
|
432 {
|
|
433 v12 = v1->field_8;
|
|
434 if ( v12 == 64 )
|
|
435 {
|
|
436 v1->_406A63();
|
|
437 }
|
|
438 else
|
|
439 {
|
|
440 if ( v12 > 0 )
|
|
441 {
|
|
442 v1->_406B9F();
|
|
443 }
|
|
444 else
|
|
445 {
|
|
446 v1->_406AFE();
|
|
447 v1->field_10 = 100;
|
|
448 }
|
|
449 }
|
|
450 v1->field_8 -= pEventTimer->uTimeElapsed;
|
|
451 return;
|
|
452 }
|
|
453 if ( v1->field_4 == 2 )
|
|
454 {
|
|
455 if ( !(v1->field_18 & TE_FLAG_1) )
|
|
456 {
|
|
457 v11 = v1->field_10;
|
|
458 if ( v11 == 100 )
|
|
459 {
|
|
460 v1->StartTurn();
|
|
461 LABEL_39:
|
|
462 v1->_40652A();
|
|
463 return;
|
|
464 }
|
|
465 if ( v11 > 0 || v1->pQueue[0].field_4 <= 0 )
|
|
466 {
|
|
467 v1->_4065B0();
|
|
468 goto LABEL_39;
|
|
469 }
|
|
470 }
|
|
471 v1->NextTurn();
|
|
472 return;
|
|
473 }
|
|
474 if ( v1->field_4 == 3 )
|
|
475 {
|
|
476 if ( v1->uActionPointsLeft <= 0 || v1->field_18 & TE_FLAG_8 )
|
|
477 {
|
|
478 v1->field_18 &= ~TE_FLAG_8;
|
|
479 v1->field_4 = 1;
|
|
480 v1->field_8 = 64;
|
|
481 }
|
|
482 else
|
|
483 {
|
|
484 v1->_406FA8();
|
|
485 }
|
|
486 }
|
|
487 }
|
|
488
|
|
489
|
|
490 //----- (00406051) --------------------------------------------------------
|
|
491 __int16 stru262_TurnBased::StartTurn()
|
|
492 {
|
|
493 stru262_TurnBased *v1; // esi@1
|
|
494 int v2; // ecx@1
|
|
495 int v3; // ebx@1
|
|
496 char *v4; // edi@1
|
|
497 int v5; // eax@4
|
|
498 int v6; // eax@12
|
|
499 char *v7; // eax@15
|
|
500 TurnBased_QueueElem *v8; // edi@17
|
|
501 unsigned int v9; // edx@23
|
|
502 char *v10; // eax@26
|
|
503 int v11; // eax@30
|
|
504 int v12; // ebx@30
|
|
505 char *v13; // edi@31
|
|
506 int v15; // [sp+Ch] [bp-10h]@5
|
|
507 TurnBased_QueueElem *v16; // [sp+10h] [bp-Ch]@3
|
|
508 int v17; // [sp+14h] [bp-8h]@2
|
|
509 int v18; // [sp+14h] [bp-8h]@16
|
|
510 signed int v19; // [sp+18h] [bp-4h]@1
|
|
511 int v20; // [sp+18h] [bp-4h]@14
|
|
512
|
|
513 v1 = this;
|
|
514 v2 = 0;
|
|
515 v19 = 0;
|
|
516 v3 = v1->uActorQueueSize;
|
|
517 v1->field_1C = 0;
|
|
518 v4 = (char *)&v1->pQueue[v3].field_4;
|
|
519 do
|
|
520 {
|
|
521 v17 = v2;
|
|
522 if ( v1->uActorQueueSize <= v2 )
|
|
523 goto LABEL_11;
|
|
524 v16 = v1->pQueue;
|
|
525 while ( 1 )
|
|
526 {
|
|
527 v5 = v16->uPackedID;
|
|
528 if ( PID_TYPE(v16->uPackedID) == OBJECT_Player)
|
|
529 break;
|
|
530 LABEL_8:
|
|
531 ++v17;
|
|
532 ++v16;
|
|
533 if ( v17 >= v1->uActorQueueSize )
|
|
534 goto LABEL_11;
|
|
535 }
|
|
536 v15 = PID_ID(v5);
|
|
537 if ( !pPlayers[(PID_ID(v5)) + 1]->CanAct() || v19 != v15 )
|
|
538 {
|
|
539 v2 = 0;
|
|
540 goto LABEL_8;
|
|
541 }
|
|
542 v2 = 0;
|
|
543 LABEL_11:
|
|
544 if ( v17 == v1->uActorQueueSize )
|
|
545 {
|
|
546 *(int *)v4 = 100;
|
|
547 v6 = 8 * v19;
|
|
548 LOBYTE(v6) = PID(OBJECT_Player,v19);
|
|
549 *((int *)v4 + 2) = v2;
|
|
550 *((int *)v4 - 1) = v6;
|
|
551 *((int *)v4 + 1) = v2;
|
|
552 ++v3;
|
|
553 v4 += 16;
|
|
554 }
|
|
555 ++v19;
|
|
556 }
|
|
557 while ( v19 < 4 );
|
|
558 v1->uActorQueueSize = v3;
|
|
559 v20 = v2;
|
|
560 if ( ai_arrays_size > v2 )
|
|
561 {
|
|
562 v7 = (char *)&v1->pQueue[v3].field_4;
|
|
563 do
|
|
564 {
|
|
565 v18 = v2;
|
|
566 if ( v1->uActorQueueSize > v2 )
|
|
567 {
|
|
568 v8 = v1->pQueue;
|
|
569 do
|
|
570 {
|
|
571 if ( PID_TYPE(v8->uPackedID) == OBJECT_Actor && ai_near_actors_ids[v20] == PID_ID(v8->uPackedID) )
|
|
572 break;
|
|
573 ++v18;
|
|
574 ++v8;
|
|
575 }
|
|
576 while ( v18 < v1->uActorQueueSize );
|
|
577 v2 = 0;
|
|
578 }
|
|
579 if ( v18 == v1->uActorQueueSize )
|
|
580 {
|
|
581 v9 = ai_near_actors_ids[v20];
|
|
582 *(int *)v7 = 1;
|
|
583 *((int *)v7 + 2) = v2;
|
|
584 *((int *)v7 - 1) = PID(OBJECT_Actor,v9);
|
|
585 *((int *)v7 + 1) = v2;
|
|
586 ++v3;
|
|
587 v7 += 16;
|
|
588 }
|
|
589 ++v20;
|
|
590 }
|
|
591 while ( v20 < ai_arrays_size );
|
|
592 }
|
|
593 ++v1->field_0;
|
|
594 v1->uActorQueueSize = v3;
|
|
595 v1->field_10 = 100;
|
|
596 if ( v3 > 0 )
|
|
597 {
|
|
598 v10 = (char *)&v1->pQueue[0].field_4;
|
|
599 do
|
|
600 {
|
|
601 if ( *(int *)v10 <= 0 )
|
|
602 *(int *)v10 = 100;
|
|
603 ++v2;
|
|
604 v10 += 16;
|
|
605 }
|
|
606 while ( v2 < v1->uActorQueueSize );
|
|
607 }
|
|
608 LOWORD(v11) = v1->_4063A1();
|
|
609 v12 = 0;
|
|
610 if ( v1->uActorQueueSize > 0 )
|
|
611 {
|
|
612 v13 = (char *)&v1->pQueue[0].field_4;
|
|
613 do
|
|
614 {
|
|
615 v11 = PID_TYPE(*((int *)v13 - 1));
|
|
616 if ( (char)v11 == 4 )
|
|
617 break;
|
|
618 if ( *(int *)v13 > 0 )
|
|
619 break;
|
|
620 LOWORD(v11) = v1->_40680F(v12++);
|
|
621 v13 += 16;
|
|
622 }
|
|
623 while ( v12 < v1->uActorQueueSize );
|
|
624 }
|
|
625 return v11;
|
|
626 }
|
|
627 // 4F75D8: using guessed type int ai_arrays_size;
|
|
628
|
|
629 //----- (004061CA) --------------------------------------------------------
|
|
630 void stru262_TurnBased::NextTurn()
|
|
631 {
|
|
632 stru262_TurnBased *v1; // esi@1
|
|
633 TurnBased_QueueElem *v2; // ebp@1
|
|
634 int v3; // ebx@1
|
|
635 int v4; // edi@7
|
|
636 Actor *v5; // eax@9
|
|
637 int v6; // ecx@9
|
|
638 signed int v7; // ebx@17
|
|
639 int v8; // ebp@27
|
|
640 TurnBased_QueueElem *v9; // edi@28
|
|
641 int v10; // ecx@30
|
|
642 unsigned __int16 v11; // ax@30
|
|
643 signed int v12; // edx@35
|
|
644 signed int v13; // [sp+10h] [bp-4h]@7
|
|
645
|
|
646 v1 = this;
|
|
647 SortTurnQueue();
|
|
648 v2 = v1->pQueue;
|
|
649 v3 = 0;
|
|
650 if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player)
|
|
651 uActiveCharacter = PID_ID(v1->pQueue[0].uPackedID) + 1;
|
|
652 else
|
|
653 uActiveCharacter = 0;
|
|
654 viewparams->bRedrawGameUI = 1;
|
|
655 if ( v1->field_1C )
|
|
656 {
|
|
657 pTurnEngine->field_18 |= TE_FLAG_2;
|
|
658 return;
|
|
659 }
|
|
660 pTurnEngine->field_18 &= ~TE_FLAG_2;
|
|
661 if ( v1->pQueue[0].field_4 <= 0 )
|
|
662 return;
|
|
663 v4 = 0;
|
|
664 v13 = 0;
|
|
665 if ( v1->uActorQueueSize <= 0 )
|
|
666 goto LABEL_27;
|
|
667 do
|
|
668 {
|
|
669 if (PID_TYPE(v2->uPackedID) != OBJECT_Player)
|
|
670 {
|
|
671 v5 = &pActors[PID_ID(v2->uPackedID)];
|
|
672 LOWORD(v6) = v5->uAIState;
|
|
673 if ( (short)v6 == 4
|
|
674 || (short)v6 == 8
|
|
675 || (short)v6 == 2
|
|
676 || (short)v6 == 3
|
|
677 || (short)v6 == 12
|
|
678 || (short)v6 == 13
|
|
679 || (short)v6 == 18
|
|
680 || (short)v6 == 17 )
|
|
681 {
|
|
682 v7 = v5->uCurrentActionLength;
|
|
683 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
|
|
684 if ( (signed int)v5->uCurrentActionTime < v7 )
|
|
685 {
|
|
686 v13 = 1;
|
|
687 LABEL_19:
|
|
688 v3 = 0;
|
|
689 goto LABEL_20;
|
|
690 }
|
|
691 v6 = (signed __int16)v6;
|
|
692 if ( (signed __int16)v6 == 4 )
|
|
693 {
|
|
694 v3 = 0;
|
|
695 v5->uAIState = Dead;
|
|
696 v5->uCurrentActionTime = 0;
|
|
697 v5->uCurrentActionLength = 0;
|
|
698 v5->UpdateAnimation();
|
|
699 }
|
|
700 else
|
|
701 {
|
|
702 if ( v6 != 8 )
|
|
703 goto LABEL_19;
|
|
704 v3 = 0;
|
|
705 Actor::AI_StandOrBored(PID_ID(v2->uPackedID), ai_near_actors_targets_pid[PID_ID(v2->uPackedID)], 32, 0);
|
|
706 }
|
|
707 }
|
|
708 }
|
|
709 LABEL_20:
|
|
710 ++v4;
|
|
711 ++v2;
|
|
712 }
|
|
713 while ( v4 < v1->uActorQueueSize );
|
|
714
|
|
715 if ( v13 != v3 )
|
|
716 {
|
|
717 v1->field_18 |= TE_FLAG_1;
|
|
718 return;
|
|
719 }
|
|
720 LABEL_27:
|
|
721 v1->field_18 &= ~TE_FLAG_1;
|
|
722 v8 = 0;
|
|
723 if ( v1->uActorQueueSize > v3 )
|
|
724 {
|
|
725 v9 = v1->pQueue;
|
|
726 do
|
|
727 {
|
|
728 if (PID_TYPE(v9->uPackedID) != OBJECT_Player)
|
|
729 {
|
|
730 v10 = PID_ID(v9->uPackedID);
|
|
731 v11 = pActors[v10].uAIState;
|
|
732 if ( v11 != 5 )
|
|
733 {
|
|
734 if ( v11 != 4 && v11 != 11 && v11 != 19 )
|
|
735 {
|
|
736 if ( v11 != 17 )
|
|
737 {
|
|
738 v12 = ai_near_actors_targets_pid[v10];
|
|
739 v9->uActionLength = v3;
|
|
740 Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3);
|
|
741 }
|
|
742 }
|
|
743 }
|
|
744 }
|
|
745 ++v8;
|
|
746 ++v9;
|
|
747 }
|
|
748 while ( v8 < v1->uActorQueueSize );
|
|
749 }
|
|
750 v1->field_4 = 3;
|
|
751 pParty->uTimePlayed += __PAIR__(v3, 213);
|
|
752 _494035_timed_effects__water_walking_damage__etc();
|
|
753 v1->uActionPointsLeft = 130;
|
|
754 }
|
|
755
|
|
756 //----- (004063A1) --------------------------------------------------------
|
|
757 int stru262_TurnBased::_4063A1()
|
|
758 {
|
|
759 stru262_TurnBased *v1; // esi@1
|
|
760 int v2; // ebp@1
|
|
761 signed int result; // eax@1
|
|
762 int v4; // edx@1
|
|
763 int v5; // edx@3
|
|
764 int v6; // edi@4
|
|
765 int v7; // ecx@5
|
|
766 Actor *v8; // ecx@11
|
|
767 unsigned __int16 v9; // dx@12
|
|
768 int v10; // edi@16
|
|
769 int v11; // edx@17
|
|
770 char v12; // zf@18
|
|
771
|
|
772 v1 = this;
|
|
773 SortTurnQueue();
|
|
774 v2 = (int)&v1->pQueue[0].field_4;
|
|
775 result = 1;
|
|
776 viewparams->bRedrawGameUI = 1;
|
|
777 v4 = v1->pQueue[0].field_4;
|
|
778 if ( v4 )
|
|
779 {
|
|
780 if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player)
|
|
781 {
|
|
782 v5 = v1->uActorQueueSize;
|
|
783 while ( 1 )
|
|
784 {
|
|
785 v6 = 0;
|
|
786 if ( v5 > 0 )
|
|
787 {
|
|
788 v7 = (int)&v1->pQueue[0].field_4;
|
|
789 do
|
|
790 {
|
|
791 --*(int *)v7;
|
|
792 v5 = v1->uActorQueueSize;
|
|
793 ++v6;
|
|
794 v7 += 16;
|
|
795 }
|
|
796 while ( v6 < v5 );
|
|
797 }
|
|
798 --v1->field_10;
|
|
799 if ( v1->field_10 <= 0 )
|
|
800 break;
|
|
801 if ( !*(int *)v2 )
|
|
802 goto LABEL_9;
|
|
803 }
|
|
804 LABEL_24:
|
|
805 result = 1;
|
|
806 }
|
|
807 else
|
|
808 {
|
|
809 v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)];
|
|
810 if ( v4 > 0 )
|
|
811 {
|
|
812 do
|
|
813 {
|
|
814 v9 = v8->uAIState;
|
|
815 if ( v9 == 5 )
|
|
816 break;
|
|
817 if ( v9 == 4 || v9 == 19 || v9 == 11 )
|
|
818 break;
|
|
819 v10 = 0;
|
|
820 if ( v1->uActorQueueSize > 0 )
|
|
821 {
|
|
822 v11 = (int)&v1->pQueue[0].field_4;
|
|
823 do
|
|
824 {
|
|
825 v12 = (*(int *)v11)-- == 1;
|
|
826 if ( v12 )
|
|
827 *(int *)(v11 + 4) = 0;
|
|
828 ++v10;
|
|
829 v11 += 16;
|
|
830 }
|
|
831 while ( v10 < v1->uActorQueueSize );
|
|
832 }
|
|
833 --v1->field_10;
|
|
834 if ( v1->field_10 <= 0 )
|
|
835 goto LABEL_24;
|
|
836 }
|
|
837 while ( *(int *)v2 > 0 );
|
|
838 }
|
|
839 LABEL_9:
|
|
840 result = 0;
|
|
841 }
|
|
842 }
|
|
843 return result;
|
|
844 }
|
|
845
|
|
846 //----- (00406457) --------------------------------------------------------
|
|
847 int stru262_TurnBased::_406457(int a2)
|
|
848 {
|
|
849 stru262_TurnBased *v2; // esi@1
|
|
850 signed int v3; // eax@1
|
|
851 signed int v4; // ecx@2
|
|
852 char *v5; // edx@2
|
|
853 signed int v6; // eax@2
|
|
854 int result; // eax@11
|
|
855 int v8; // edx@13
|
|
856 int v9; // ecx@14
|
|
857 char v10; // zf@15
|
|
858
|
|
859 v2 = this;
|
|
860 v3 = *(&this->field_0 + 4 * (a2 + 2));
|
|
861 if ( (*((char *)&this->field_0 + 16 * PID_TYPE(a2 + 2))) == OBJECT_Player)
|
|
862 {
|
|
863 v4 = PID_ID(v3);
|
|
864 v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[PID_ID(v3)];
|
|
865 v6 = *(int *)v5;
|
|
866 if ( *(int *)v5 )
|
|
867 *(int *)v5 = 0;
|
|
868 else
|
|
869 v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0);
|
|
870 if ( v6 < 30 )
|
|
871 v6 = 30;
|
|
872 }
|
|
873 else
|
|
874 {
|
|
875 v6 = pMonsterStats->pInfos[pActors[PID_ID(v3)].pMonsterInfo.uID].uRecoveryTime;
|
|
876 }
|
|
877 v2->pQueue[a2].field_4 = v6;
|
|
878 v2->SortTurnQueue();
|
|
879 if (PID_TYPE(v2->pQueue[0].uPackedID) == OBJECT_Player)
|
|
880 uActiveCharacter = PID_ID(v2->pQueue[0].uPackedID) + 1;
|
|
881 else
|
|
882 uActiveCharacter = 0;
|
|
883 result = (int)&v2->pQueue[0].field_4;
|
|
884 viewparams->bRedrawGameUI = 1;
|
|
885 while ( *(int *)result > 0 )
|
|
886 {
|
|
887 if ( v2->field_10 <= 0 )
|
|
888 break;
|
|
889 v8 = 0;
|
|
890 if ( v2->uActorQueueSize > 0 )
|
|
891 {
|
|
892 v9 = (int)&v2->pQueue[0].field_4;
|
|
893 do
|
|
894 {
|
|
895 v10 = (*(int *)v9)-- == 1;
|
|
896 if ( v10 )
|
|
897 *(int *)(v9 + 4) = 0;
|
|
898 ++v8;
|
|
899 v9 += 16;
|
|
900 }
|
|
901 while ( v8 < v2->uActorQueueSize );
|
|
902 }
|
|
903 --v2->field_10;
|
|
904 if ( v2->field_10 <= 0 )
|
|
905 break;
|
|
906 }
|
|
907 return result;
|
|
908 }
|
|
909
|
|
910 //----- (0040652A) --------------------------------------------------------
|
|
911 void stru262_TurnBased::_40652A()
|
1333
|
912 {
|
|
913 int i;
|
|
914 int monster_ai_state;
|
|
915 Actor *monster; // eax@5
|
1332
|
916
|
1333
|
917 for (i=0; i<uActorQueueSize; ++i )
|
1332
|
918 {
|
1333
|
919 if (pQueue[i].field_4 == 0)
|
1332
|
920 {
|
1333
|
921 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)
|
|
922 break;
|
|
923 monster=&pActors[PID_ID(pQueue[i].uPackedID)];
|
|
924 monster_ai_state=monster->uAIState;
|
|
925 if (monster_ai_state == Standing ||
|
|
926 monster_ai_state == Fleeing ||
|
|
927 monster_ai_state == Fidgeting)
|
1332
|
928 {
|
1333
|
929 pQueue[i].field_4 == pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime;
|
|
930 if (monster->pActorBuffs[7].uExpireTime > 0)
|
|
931 pQueue[i].field_4*=2;
|
|
932
|
1332
|
933 }
|
|
934 }
|
|
935 }
|
1333
|
936 }
|
1332
|
937
|
|
938 //----- (004065B0) --------------------------------------------------------
|
|
939 void stru262_TurnBased::_4065B0()
|
1333
|
940 {
|
|
941 int i;
|
1332
|
942
|
|
943 SortTurnQueue();
|
1333
|
944 if (pQueue[0].field_4 <= 0)
|
|
945 {
|
|
946 for (i=0; i<uActorQueueSize; ++i )
|
1332
|
947 {
|
1333
|
948 if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)|| (pQueue[i].field_4 > 0) )
|
|
949 break;
|
|
950 if ((pQueue[i].uActionLength<=0) && (PID_TYPE(pQueue[i].uPackedID)==OBJECT_Actor))
|
|
951 _40680F(i);
|
1332
|
952 }
|
|
953 }
|
1333
|
954 else
|
1332
|
955 {
|
1333
|
956 _4063A1();
|
|
957 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
|
|
958 uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1;
|
|
959 else
|
|
960 uActiveCharacter = 0;
|
|
961 viewparams->bRedrawGameUI = 1;
|
1332
|
962 }
|
1333
|
963
|
|
964 for (i=0; i<uActorQueueSize; ++i )
|
|
965 _406648(i);
|
|
966 }
|
1332
|
967
|
|
968 //----- (00406648) --------------------------------------------------------
|
|
969 void stru262_TurnBased::_406648(unsigned int a2)
|
|
970 {
|
|
971 TurnBased_QueueElem *v1; // ecx@1
|
|
972 int v3; // eax@1
|
|
973 unsigned int v4; // ebx@2
|
|
974 Actor *v5; // esi@2
|
|
975 signed int v6; // edi@5
|
|
976 int v7; // ecx@6
|
|
977 int v8; // eax@6
|
|
978 int v9; // eax@7
|
|
979 int v10; // eax@8
|
|
980 int v11; // eax@9
|
|
981 int v12; // eax@10
|
|
982 int v13; // eax@11
|
|
983 int v14; // eax@14
|
|
984 unsigned int v15; // ecx@14
|
|
985 unsigned int v16; // edx@14
|
|
986 int v17; // eax@17
|
|
987 int v18; // eax@20
|
|
988 char v19; // al@24
|
|
989 unsigned int v21; // [sp-8h] [bp-50h]@16
|
|
990 int v22; // [sp-8h] [bp-50h]@17
|
|
991 AIDirection *v23; // [sp-4h] [bp-4Ch]@14
|
|
992 unsigned int v24; // [sp-4h] [bp-4Ch]@17
|
|
993 char v25; // [sp-4h] [bp-4Ch]@20
|
|
994 AIDirection a3; // [sp+Ch] [bp-3Ch]@2
|
|
995 AIDirection a4; // [sp+28h] [bp-20h]@2
|
|
996 TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
|
|
997 unsigned int a2a; // [sp+50h] [bp+8h]@2
|
|
998
|
|
999 v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
|
|
1000 v28 = v1;
|
|
1001 v3 = v1->uPackedID;
|
|
1002 if (PID_TYPE(v1->uPackedID) != OBJECT_Player)
|
|
1003 {
|
|
1004 v4 = PID_ID(v3);
|
|
1005 a2a = ai_near_actors_targets_pid[PID_ID(v3)];
|
|
1006 memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3));
|
|
1007 memcpy(&a4, &a3, sizeof(a4));
|
|
1008 v5 = &pActors[PID_ID(v3)];
|
|
1009 LOWORD(v3) = v5->uAIState;
|
|
1010 if ( (short)v3 != Dead )
|
|
1011 {
|
|
1012 if ( (short)v3 != Disabled )
|
|
1013 {
|
|
1014 if ( (short)v3 != Removed )
|
|
1015 {
|
|
1016 v6 = v5->uCurrentActionLength;
|
|
1017 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
|
|
1018 if ( (signed int)v5->uCurrentActionTime >= v6 )
|
|
1019 {
|
|
1020 v7 = (signed __int16)v3;
|
|
1021 v8 = (signed __int16)v3 - 2;
|
|
1022 if ( !v8 )
|
|
1023 {
|
|
1024 v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4);
|
|
1025 stru_50FE08.Add(
|
|
1026 v28->uPackedID,
|
|
1027 5120,
|
|
1028 v5->vPosition.x,
|
|
1029 v5->vPosition.y,
|
|
1030 v5->vPosition.z + ((signed int)v5->uActorHeight >> 1),
|
|
1031 v19,
|
|
1032 1);
|
|
1033 goto LABEL_25;
|
|
1034 }
|
|
1035 v9 = v8 - 1;
|
|
1036 if ( v9 )
|
|
1037 {
|
|
1038 v10 = v9 - 1;
|
|
1039 if ( !v10 )
|
|
1040 goto LABEL_21;
|
|
1041 v11 = v10 - 4;
|
|
1042 if ( !v11 )
|
|
1043 goto LABEL_25;
|
|
1044 v12 = v11 - 4;
|
|
1045 if ( v12 )
|
|
1046 {
|
|
1047 v13 = v12 - 1;
|
|
1048 if ( v13 )
|
|
1049 {
|
|
1050 if ( v13 != Dead )
|
|
1051 {
|
|
1052 if ( v7 != 4 )
|
|
1053 {
|
|
1054 v14 = rand();
|
|
1055 v15 = v4;
|
|
1056 v23 = &a4;
|
|
1057 v16 = a2a;
|
|
1058 if ( !(v14 % 2) )
|
|
1059 {
|
|
1060 Actor::AI_Bored(v4, a2a, &a4);
|
|
1061 return;
|
|
1062 }
|
|
1063 v21 = 64;
|
|
1064 LABEL_26:
|
|
1065 Actor::AI_Stand(v15, v16, v21, v23);
|
|
1066 return;
|
|
1067 }
|
|
1068 LABEL_21:
|
|
1069 v5->uCurrentActionTime = 0;
|
|
1070 v5->uCurrentActionLength = 0;
|
|
1071 v5->uAIState = Dead;
|
|
1072 pActors[v4].UpdateAnimation();
|
|
1073 return;
|
|
1074 }
|
|
1075 v24 = v5->pMonsterInfo.uSpellSkillAndMastery2;
|
|
1076 v22 = 3;
|
|
1077 v17 = v5->pMonsterInfo.uSpell2ID;
|
|
1078 }
|
|
1079 else
|
|
1080 {
|
|
1081 v24 = v5->pMonsterInfo.uSpellSkillAndMastery1;
|
|
1082 v22 = 2;
|
|
1083 v17 = v5->pMonsterInfo.uSpell1ID;
|
|
1084 }
|
|
1085 Actor::AI_SpellAttack(v4, &a4, v17, v22, v24);
|
|
1086 LABEL_25:
|
|
1087 v16 = a2a;
|
|
1088 v23 = &a4;
|
|
1089 v21 = 0;
|
|
1090 v15 = v4;
|
|
1091 goto LABEL_26;
|
|
1092 }
|
|
1093 v18 = v5->pMonsterInfo.uMissleAttack2Type;
|
|
1094 v25 = 1;
|
|
1095 }
|
|
1096 else
|
|
1097 {
|
|
1098 v18 = v5->pMonsterInfo.uMissleAttack1Type;
|
|
1099 v25 = 0;
|
|
1100 }
|
|
1101 Actor::AI_RangedAttack(v4, &a4, v18, v25);
|
|
1102 goto LABEL_25;
|
|
1103 }
|
|
1104 }
|
|
1105 }
|
|
1106 }
|
|
1107 }
|
|
1108 }
|
|
1109 // 50FE08: using guessed type stru298 stru_50FE08;
|
|
1110
|
|
1111 //----- (0040680F) --------------------------------------------------------
|
|
1112 __int16 stru262_TurnBased::_40680F(int a2)
|
|
1113 {
|
|
1114 TurnBased_QueueElem *v2; // eax@1
|
|
1115 unsigned int v3; // eax@1
|
|
1116 unsigned int v4; // edi@2
|
|
1117 Actor *v5; // ebx@2
|
|
1118 unsigned int *v6; // esi@7
|
|
1119 AIDirection *v7; // esi@10
|
|
1120 int v8; // eax@10
|
|
1121 unsigned int v9; // ecx@10
|
|
1122 signed int v10; // eax@13
|
|
1123 unsigned __int8 v11; // sf@19
|
|
1124 unsigned __int8 v12; // of@19
|
|
1125 int v13; // esi@29
|
|
1126 bool v14; // eax@29
|
|
1127 unsigned __int8 v15; // cl@33
|
|
1128 AIDirection a3; // [sp+Ch] [bp-44h]@10
|
|
1129 AIDirection v18; // [sp+28h] [bp-28h]@10
|
|
1130 int a2a; // [sp+44h] [bp-Ch]@2
|
|
1131 unsigned int v20; // [sp+48h] [bp-8h]@10
|
|
1132 TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1
|
|
1133 signed int v22; // [sp+58h] [bp+8h]@10
|
|
1134
|
|
1135 v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
|
|
1136 v21 = v2;
|
|
1137 v2->uActionLength = 0;
|
|
1138 v3 = v2->uPackedID;
|
|
1139 if ( (unsigned __int8)v3 & 3 )
|
|
1140 {
|
|
1141 v3 = PID_ID(v3);
|
|
1142 v4 = v3;
|
|
1143 a2a = v3;
|
|
1144 v5 = &pActors[v3];
|
|
1145 LOWORD(v3) = v5->uAIState;
|
|
1146 if ( (short)v3 != 5 )
|
|
1147 {
|
|
1148 if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 )
|
|
1149 {
|
|
1150 v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4];
|
|
1151 Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true);
|
|
1152 if ( v5->pMonsterInfo.uHostilityType && !*v6 )
|
|
1153 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
|
|
1154 v22 = *v6;
|
|
1155 v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,(int)v4), *v6, &a3, 0);
|
|
1156 v8 = v5->uActorRadius;
|
|
1157 memcpy(&a3, v7, sizeof(a3));
|
|
1158 memcpy(&v18, &a3, sizeof(v18));
|
|
1159 v9 = a3.uDistance - v8;
|
|
1160 v20 = a3.uDistance - v8;
|
|
1161 if ( ((a3.uDistance - v8) & 0x80000000u) != 0 )
|
|
1162 {
|
|
1163 v9 = 0;
|
|
1164 v20 = 0;
|
|
1165 }
|
|
1166 if (PID_TYPE(v22) == OBJECT_Actor)
|
|
1167 //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3);
|
|
1168 v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(v5->pMonsterInfo.uID - 1) / 3 + 1];
|
|
1169 else
|
|
1170 v10 = 4;
|
|
1171 if ( v10 == 1 )
|
|
1172 {
|
|
1173 if ( (double)(signed int)v20 < 307.2 )
|
|
1174 goto LABEL_25;
|
|
1175 }
|
|
1176 else
|
|
1177 {
|
|
1178 if ( v10 == 2 )
|
|
1179 {
|
|
1180 v12 = __OFSUB__(v9, 1024);
|
|
1181 v11 = ((v9 - 1024) & 0x80000000u) != 0;
|
|
1182 }
|
|
1183 else
|
|
1184 {
|
|
1185 if ( v10 == 3 )
|
|
1186 {
|
|
1187 v12 = __OFSUB__(v9, 2560);
|
|
1188 v11 = ((v9 - 2560) & 0x80000000u) != 0;
|
|
1189 }
|
|
1190 else
|
|
1191 {
|
|
1192 if ( v10 != 4 )
|
|
1193 goto LABEL_26;
|
|
1194 v12 = __OFSUB__(v9, 5120);
|
|
1195 v11 = ((v9 - 5120) & 0x80000000u) != 0;
|
|
1196 }
|
|
1197 }
|
|
1198 if ( v11 ^ v12 )
|
|
1199 {
|
|
1200 LABEL_25:
|
|
1201 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
|
|
1202 goto LABEL_26;
|
|
1203 }
|
|
1204 }
|
|
1205 LABEL_26:
|
|
1206 if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 )
|
|
1207 {
|
|
1208 v13 = a2a;
|
|
1209 goto LABEL_47;
|
|
1210 }
|
|
1211 v13 = a2a;
|
|
1212 v14 = stru_50C198.special_ability_use_check(v5, a2a);
|
|
1213 if ( v14 == 1 )
|
|
1214 {
|
|
1215 if ( v5->pMonsterInfo.uMissleAttack2Type )
|
|
1216 {
|
|
1217 Actor::AI_MissileAttack2(v13, v22, &v18);
|
|
1218 goto LABEL_43;
|
|
1219 }
|
|
1220 }
|
|
1221 else
|
|
1222 {
|
|
1223 if ( v14 > 1 && v14 <= 3 )
|
|
1224 {
|
|
1225 if ( v14 == 2 )
|
|
1226 v15 = v5->pMonsterInfo.uSpell1ID;
|
|
1227 else
|
|
1228 v15 = v5->pMonsterInfo.uSpell2ID;
|
|
1229 if ( v15 )
|
|
1230 {
|
|
1231 if ( v14 == 2 )
|
|
1232 Actor::AI_SpellAttack1(v13, v22, &v18);
|
|
1233 else
|
|
1234 Actor::AI_SpellAttack2(v13, v22, &v18);
|
|
1235 goto LABEL_43;
|
|
1236 }
|
|
1237 goto LABEL_44;
|
|
1238 }
|
|
1239 if ( v5->pMonsterInfo.uMissleAttack1Type )
|
|
1240 {
|
|
1241 Actor::AI_MissileAttack1(v13, v22, &v18);
|
|
1242 LABEL_43:
|
|
1243 //v3 = v21;
|
|
1244 v21->field_C = 1;
|
|
1245 LABEL_48:
|
|
1246 v21->uActionLength = v5->uCurrentActionLength;
|
|
1247 //return (signed __int16)v3;
|
|
1248 return (signed __int16)&v21;
|
|
1249 }
|
|
1250 }
|
|
1251 LABEL_44:
|
|
1252 if ( (double)(signed int)v20 < 307.2 )
|
|
1253 {
|
|
1254 Actor::AI_MeleeAttack(v13, v22, &v18);
|
|
1255 //v3 = v21;
|
|
1256 v21->field_C = 3;
|
|
1257 goto LABEL_48;
|
|
1258 }
|
|
1259 LABEL_47:
|
|
1260 Actor::AI_Stand(v13, v22, 0x40u, &v18);
|
|
1261 //v3 = v21;
|
|
1262 v21->field_C = 0;
|
|
1263 goto LABEL_48;
|
|
1264 }
|
|
1265 }
|
|
1266 }
|
|
1267 return (signed __int16)v3;
|
|
1268 }
|
|
1269
|
|
1270 //----- (00406A63) --------------------------------------------------------
|
|
1271 void stru262_TurnBased::_406A63()
|
|
1272 {
|
|
1273 stru262_TurnBased *v1; // ebx@1
|
|
1274 int v2; // esi@1
|
|
1275 unsigned __int8 v3; // zf@1
|
|
1276 unsigned __int8 v4; // sf@1
|
|
1277 signed int v5; // ecx@4
|
|
1278 AIDirection a3; // [sp+8h] [bp-44h]@5
|
|
1279 AIDirection v7; // [sp+24h] [bp-28h]@5
|
|
1280 unsigned int v8; // [sp+40h] [bp-Ch]@5
|
|
1281 signed int a2; // [sp+44h] [bp-8h]@1
|
|
1282 TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2
|
|
1283
|
|
1284 v1 = this;
|
|
1285 v2 = 0;
|
|
1286 this->field_8 = 64;
|
|
1287 dword_50C994 = 0;
|
|
1288 uActiveCharacter = 0;
|
|
1289 v3 = this->uActorQueueSize == 0;
|
|
1290 v4 = this->uActorQueueSize < 0;
|
|
1291 a2 = 0;
|
|
1292 if ( !(v4 | v3) )
|
|
1293 {
|
|
1294 v10 = this->pQueue;
|
|
1295 while ( 1 )
|
|
1296 {
|
|
1297 v5 = v10->uPackedID;
|
|
1298 if (PID_TYPE(v10->uPackedID) == OBJECT_Actor)
|
|
1299 {
|
|
1300 v8 = ai_near_actors_targets_pid[PID_ID(v5)];
|
1333
|
1301 memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, 0), sizeof(v7));
|
1332
|
1302 if ( !v1->ActorTurn(a2) )
|
|
1303 Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 32, &v7);
|
|
1304 }
|
|
1305 ++a2;
|
|
1306 ++v10;
|
|
1307 if ( a2 >= v1->uActorQueueSize )
|
|
1308 break;
|
|
1309 v2 = 0;
|
|
1310 }
|
|
1311 }
|
|
1312 }
|
|
1313 // 50C994: using guessed type int dword_50C994;
|
|
1314
|
|
1315 //----- (00406AFE) --------------------------------------------------------
|
|
1316 void stru262_TurnBased::_406AFE()
|
|
1317 {
|
|
1318 stru262_TurnBased *v1; // edi@1
|
|
1319 TurnBased_QueueElem *v2; // ebx@2
|
|
1320 int v3; // esi@4
|
|
1321 int v4; // ecx@5
|
|
1322 AIDirection a3; // [sp+4h] [bp-48h]@5
|
|
1323 AIDirection v6; // [sp+20h] [bp-2Ch]@5
|
|
1324 stru262_TurnBased *v7; // [sp+3Ch] [bp-10h]@1
|
|
1325 unsigned int v8; // [sp+40h] [bp-Ch]@4
|
|
1326 unsigned int v9; // [sp+44h] [bp-8h]@5
|
|
1327 int v10; // [sp+48h] [bp-4h]@1
|
|
1328
|
|
1329 v10 = 0;
|
|
1330 v1 = this;
|
|
1331 v7 = this;
|
|
1332 if ( this->uActorQueueSize > 0 )
|
|
1333 {
|
|
1334 v2 = this->pQueue;
|
|
1335 do
|
|
1336 {
|
|
1337 if (PID_TYPE(v2->uPackedID) == OBJECT_Actor)
|
|
1338 {
|
|
1339 v3 = PID_ID(v2->uPackedID);
|
|
1340 v8 = v3;
|
|
1341 if ( pActors[v3].CanAct() )
|
|
1342 {
|
|
1343 v4 = v2->uPackedID;
|
|
1344 v9 = ai_near_actors_targets_pid[v3];
|
|
1345 memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6));
|
|
1346 Actor::AI_Stand(v8, v9, 32, &v6);
|
|
1347 v2->field_C = 0;
|
|
1348 v2->uActionLength = 0;
|
|
1349 v1 = v7;
|
|
1350 }
|
|
1351 }
|
|
1352 ++v10;
|
|
1353 ++v2;
|
|
1354 }
|
|
1355 while ( v10 < v1->uActorQueueSize );
|
|
1356 }
|
|
1357 v1->field_4 = 2;
|
|
1358 v1->field_8 = 100;
|
|
1359 }
|
|
1360
|
|
1361 //----- (00406B9F) --------------------------------------------------------
|
|
1362 int stru262_TurnBased::_406B9F()
|
|
1363 {
|
|
1364 signed int result; // eax@1
|
|
1365 unsigned __int8 v2; // zf@1
|
|
1366 unsigned __int8 v3; // sf@1
|
|
1367 int v4; // esi@4
|
|
1368 unsigned int v5; // esi@5
|
|
1369 Actor *v6; // ebx@5
|
|
1370 unsigned __int16 v7; // cx@15
|
|
1371 AIDirection a3; // [sp+0h] [bp-50h]@15
|
|
1372 AIDirection v9; // [sp+1Ch] [bp-34h]@15
|
|
1373 signed int a1; // [sp+38h] [bp-18h]@4
|
|
1374 stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1
|
|
1375 unsigned int v12; // [sp+40h] [bp-10h]@5
|
|
1376 unsigned int v13; // [sp+44h] [bp-Ch]@8
|
|
1377 TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2
|
|
1378 signed int a2; // [sp+4Ch] [bp-4h]@1
|
|
1379
|
|
1380 result = 0;
|
|
1381 thisa = this;
|
|
1382 v2 = this->uActorQueueSize == 0;
|
|
1383 v3 = this->uActorQueueSize < 0;
|
|
1384 a2 = 0;
|
|
1385 if ( !(v3 | v2) )
|
|
1386 {
|
|
1387 v14 = this->pQueue;
|
|
1388 while ( 1 )
|
|
1389 {
|
|
1390 v4 = v14->uPackedID;
|
|
1391 a1 = v14->uPackedID;
|
|
1392 if (PID_TYPE(a1) != OBJECT_Player)
|
|
1393 {
|
|
1394 v5 = PID_ID(v4);
|
|
1395 v12 = v5;
|
|
1396 v6 = &pActors[v5];
|
|
1397 if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
|
|
1398 || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result )
|
|
1399 v13 = result;
|
|
1400 else
|
|
1401 v13 = 1;
|
|
1402 if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result
|
|
1403 && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) )
|
|
1404 result = 1;
|
|
1405 if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) )
|
|
1406 {
|
|
1407 v13 = ai_near_actors_targets_pid[v5];
|
|
1408 memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
|
|
1409 v7 = v6->uAIState;
|
|
1410 if ( v7 == 6 || v7 == 1 )
|
|
1411 {
|
|
1412 if ( (double)(signed int)v9.uDistance < 307.2 )
|
|
1413 goto LABEL_26;
|
|
1414 }
|
|
1415 v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
|
|
1416 if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength )
|
|
1417 {
|
|
1418 if ( v7 == 4 )
|
|
1419 {
|
|
1420 v6->uCurrentActionTime = 0;
|
|
1421 v6->uCurrentActionLength = 0;
|
|
1422 v6->uAIState = Dead;
|
|
1423 v6->UpdateAnimation();
|
|
1424 }
|
|
1425 if ( !thisa->ActorTurn(a2) )
|
|
1426 LABEL_26:
|
|
1427 Actor::AI_Stand(v12, v13, 32, &v9);
|
|
1428 }
|
|
1429 }
|
|
1430 }
|
|
1431 ++a2;
|
|
1432 result = (signed int)thisa;
|
|
1433 ++v14;
|
|
1434 if ( a2 >= thisa->uActorQueueSize )
|
|
1435 break;
|
|
1436 result = 0;
|
|
1437 }
|
|
1438 }
|
|
1439 return result;
|
|
1440 }
|
|
1441
|
|
1442 //----- (00406D10) --------------------------------------------------------
|
|
1443 bool stru262_TurnBased::ActorTurn(signed int a2)
|
|
1444 {
|
|
1445 int v2; // ecx@1
|
|
1446 //int v3; // ecx@2
|
|
1447 Actor *actor; // ebx@2
|
|
1448 //unsigned __int16 v5; // dx@2
|
|
1449 int *v6; // esi@7
|
|
1450 TurnBased_QueueElem *v7; // edi@7
|
|
1451 int v8; // eax@7
|
|
1452 AIDirection *v9; // esi@10
|
|
1453 int v10; // eax@10
|
|
1454 unsigned int v11; // ecx@10
|
|
1455 unsigned __int8 pHostileType; // al@12
|
|
1456 unsigned __int8 v13; // sf@16
|
|
1457 unsigned __int8 v14; // of@16
|
|
1458 unsigned int v15; // edx@22
|
|
1459 unsigned int v16; // ecx@23
|
|
1460 TurnBased_QueueElem *v17; // eax@25
|
|
1461 double v18; // st7@33
|
|
1462 double v19; // st6@33
|
|
1463 int v21; // [sp-8h] [bp-5Ch]@23
|
|
1464 int v22; // [sp-8h] [bp-5Ch]@26
|
|
1465 AIDirection *v23; // [sp-4h] [bp-58h]@23
|
|
1466 int v24; // [sp-4h] [bp-58h]@26
|
|
1467 AIDirection a3; // [sp+Ch] [bp-48h]@10
|
|
1468 AIDirection pDir; // [sp+28h] [bp-2Ch]@10
|
|
1469 int v27; // [sp+44h] [bp-10h]@33
|
|
1470 unsigned int v28; // [sp+48h] [bp-Ch]@10
|
|
1471 TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7
|
|
1472 unsigned int uActorID; // [sp+50h] [bp-4h]@2
|
|
1473 unsigned int a2a; // [sp+5Ch] [bp+8h]@7
|
|
1474
|
|
1475 // __debugbreak();//ñðàáàòûâàåò ïðè ïîøàãîâîì ðåæèìå ïîñëå ïÿòè øàãîâ
|
|
1476 v2 = *(&this->field_0 + 4 * (a2 + 2));
|
|
1477 if (PID_TYPE(v2) == OBJECT_Player)
|
|
1478 return 0;
|
|
1479 uActorID = PID_ID(v2);
|
|
1480 //uActorID = v3;
|
|
1481 actor = &pActors[uActorID];
|
|
1482 //v5 = v4->uAIState;
|
|
1483 if ( actor->uAIState == 5 || actor->uAIState == 4 || actor->uAIState == 11 || actor->uAIState == 19 || actor->uAIState == 17 )
|
|
1484 return 1;
|
|
1485 v6 = &ai_near_actors_targets_pid[uActorID];
|
|
1486 v7 = &pTurnEngine->pQueue[a2];
|
|
1487 v8 = *v6;
|
|
1488 v29 = &pTurnEngine->pQueue[a2];
|
|
1489 a2a = v8;
|
|
1490 Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true);
|
|
1491 if ( actor->pMonsterInfo.uHostilityType && !*v6 )
|
|
1492 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
|
|
1493 v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
|
|
1494 v10 = actor->uActorRadius;
|
|
1495 memcpy(&a3, v9, sizeof(a3));
|
|
1496 memcpy(&pDir, &a3, sizeof(pDir));
|
|
1497 v11 = a3.uDistance - v10;
|
|
1498 v28 = a3.uDistance - v10;
|
|
1499 if ( ((a3.uDistance - v10) & 0x80000000u) != 0 )
|
|
1500 {
|
|
1501 v11 = 0;
|
|
1502 v28 = 0;
|
|
1503 }
|
|
1504 pHostileType = actor->pMonsterInfo.uHostilityType;
|
|
1505 if ( pHostileType == 1 )
|
|
1506 {
|
|
1507 if ( (double)(signed int)v28 >= 307.2 )
|
|
1508 goto LABEL_21;
|
|
1509 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
|
|
1510 goto LABEL_21;
|
|
1511 }
|
|
1512 if ( pHostileType == 2 )
|
|
1513 {
|
|
1514 v14 = __OFSUB__(v11, 1024);
|
|
1515 v13 = ((v11 - 1024) & 0x80000000u) != 0;
|
|
1516 }
|
|
1517 else
|
|
1518 {
|
|
1519 if ( pHostileType != 3 )
|
|
1520 goto LABEL_21;
|
|
1521 v14 = __OFSUB__(v11, 2560);
|
|
1522 v13 = ((v11 - 2560) & 0x80000000u) != 0;
|
|
1523 }
|
|
1524 if ( v13 ^ v14 )
|
|
1525 {
|
|
1526 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
|
|
1527 }
|
|
1528 LABEL_21:
|
|
1529 if ( (signed __int64)actor->pActorBuffs[4].uExpireTime > 0 )
|
|
1530 {
|
|
1531 if ( (signed int)v11 < 10240 )
|
|
1532 {
|
|
1533 Actor::AI_Flee(uActorID, a2a, 0, &pDir);
|
|
1534 v29->field_C = 4;
|
|
1535 v29->uActionLength = actor->uCurrentActionLength;
|
|
1536 return 1;
|
|
1537 }
|
|
1538 Actor::AI_4032B2(uActorID, a2a, 1024, 0);
|
|
1539 v29->field_C = 2;
|
|
1540 v29->uActionLength = actor->uCurrentActionLength;
|
|
1541 return 1;
|
|
1542 }
|
|
1543 if ( actor->pMonsterInfo.uHostilityType != 4 )
|
|
1544 goto LABEL_46;
|
|
1545 if ( !(actor->uAttributes & 0x020000) || actor->pMonsterInfo.uAIType == 1 )
|
|
1546 {
|
|
1547 if ( actor->pMonsterInfo.uAIType == 1 )
|
|
1548 {
|
|
1549 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1550 {
|
|
1551 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1552 v29->field_C = 4;
|
|
1553 v29->uActionLength = actor->uCurrentActionLength;
|
|
1554 return 1;
|
|
1555 }
|
|
1556 Actor::AI_Flee(uActorID, a2a, 32, 0);
|
|
1557 v29->field_C = 4;
|
|
1558 v29->uActionLength = actor->uCurrentActionLength;
|
|
1559 return 1;
|
|
1560 }
|
|
1561 if ( actor->pMonsterInfo.uAIType == 2 )
|
|
1562 {
|
|
1563 v27 = actor->sCurrentHP;
|
|
1564 v18 = (double)v27;
|
|
1565 v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.2;
|
|
1566 if ( v19 > v18 && (signed int)v11 < 10240 )
|
|
1567 {
|
|
1568 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1569 {
|
|
1570 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1571 v29->field_C = 4;
|
|
1572 v29->uActionLength = actor->uCurrentActionLength;
|
|
1573 return 1;
|
|
1574 }
|
|
1575 Actor::AI_Flee(uActorID, a2a, 32, 0);
|
|
1576 v29->field_C = 4;
|
|
1577 v29->uActionLength = actor->uCurrentActionLength;
|
|
1578 return 1;
|
|
1579 }
|
|
1580 goto LABEL_39;
|
|
1581 }
|
|
1582 if ( actor->pMonsterInfo.uAIType == 3 )
|
|
1583 {
|
|
1584 v27 = actor->sCurrentHP;
|
|
1585 v18 = (double)v27;
|
|
1586 v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.1;
|
|
1587 if ( v19 > v18 && (signed int)v11 < 10240 )
|
|
1588 {
|
|
1589 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1590 {
|
|
1591 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1592 v29->field_C = 4;
|
|
1593 v29->uActionLength = actor->uCurrentActionLength;
|
|
1594 return 1;
|
|
1595 }
|
|
1596 Actor::AI_Flee(uActorID, a2a, 32, 0);
|
|
1597 v29->field_C = 4;
|
|
1598 v29->uActionLength = actor->uCurrentActionLength;
|
|
1599 return 1;
|
|
1600 }
|
|
1601 goto LABEL_39;
|
|
1602 }
|
|
1603 }
|
|
1604 LABEL_39:
|
|
1605 if ( (double)(signed int)v28 < 307.2 )
|
|
1606 return 0;
|
|
1607 if ( (signed int)v11 < 5120 )
|
|
1608 {
|
|
1609 if ( actor->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
|
|
1610 Actor::AI_Pursue1(uActorID, a2a, uActorID, 32, &pDir);
|
|
1611 else
|
|
1612 Actor::AI_Pursue2(uActorID, a2a, 32, &pDir, 307);
|
|
1613 v29->field_C = 2;
|
|
1614 v29->uActionLength = actor->uCurrentActionLength;
|
|
1615 return 1;
|
|
1616 }
|
|
1617 LABEL_46:
|
|
1618 if ( actor->pMonsterInfo.uMovementType == 0 )
|
|
1619 {
|
|
1620 Actor::AI_4032B2(uActorID, a2a, 1024, 32);
|
|
1621 v29->field_C = 2;
|
|
1622 v29->uActionLength = actor->uCurrentActionLength;
|
|
1623 return 1;
|
|
1624 }
|
|
1625 if ( actor->pMonsterInfo.uMovementType == 1 )
|
|
1626 {
|
|
1627 Actor::AI_4032B2(uActorID, a2a, 2560, 32);
|
|
1628 v29->field_C = 2;
|
|
1629 v29->uActionLength = actor->uCurrentActionLength;
|
|
1630 return 1;
|
|
1631 }
|
|
1632 if ( actor->pMonsterInfo.uMovementType == 2 )
|
|
1633 {
|
|
1634 Actor::AI_4032B2(uActorID, a2a, 5120, 32);
|
|
1635 v29->field_C = 2;
|
|
1636 v29->uActionLength = actor->uCurrentActionLength;
|
|
1637 return 1;
|
|
1638 }
|
|
1639 if ( actor->pMonsterInfo.uMovementType == 4 )
|
|
1640 {
|
|
1641 Actor::AI_4032B2(uActorID, a2a, 10240, 32);
|
|
1642 v29->field_C = 2;
|
|
1643 v29->uActionLength = actor->uCurrentActionLength;
|
|
1644 return 1;
|
|
1645 }
|
|
1646 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1647 {
|
|
1648 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1649 v29->field_C = 2;
|
|
1650 v29->uActionLength = actor->uCurrentActionLength;
|
|
1651 return 1;
|
|
1652 }
|
|
1653 return 1;
|
|
1654 }
|
|
1655
|
|
1656 //----- (00406FA8) --------------------------------------------------------
|
|
1657 void stru262_TurnBased::_406FA8()
|
|
1658 {
|
|
1659 unsigned __int8 v1; // zf@1
|
|
1660 unsigned __int8 v2; // sf@1
|
|
1661 TurnBased_QueueElem *v3; // edi@2
|
|
1662 int v4; // eax@4
|
|
1663 Actor *v5; // ebx@4
|
|
1664 unsigned __int16 v6; // cx@4
|
|
1665 unsigned int *v7; // edx@8
|
|
1666 unsigned int v8; // esi@8
|
|
1667 unsigned __int8 v9; // of@13
|
|
1668 AIDirection a3; // [sp+Ch] [bp-6Ch]@8
|
|
1669 AIDirection v11; // [sp+28h] [bp-50h]@8
|
|
1670 AIDirection a4; // [sp+44h] [bp-34h]@8
|
|
1671 stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1
|
|
1672 TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2
|
|
1673 int uActorID; // [sp+68h] [bp-10h]@4
|
|
1674 unsigned int a2; // [sp+6Ch] [bp-Ch]@8
|
|
1675 int v17; // [sp+70h] [bp-8h]@1
|
|
1676 unsigned int v18; // [sp+74h] [bp-4h]@2
|
|
1677
|
|
1678 v17 = 0;
|
|
1679 v1 = this->uActorQueueSize == 0;
|
|
1680 v2 = this->uActorQueueSize < 0;
|
|
1681 v13 = this;
|
|
1682 if ( !(v2 | v1) )
|
|
1683 {
|
|
1684 v3 = this->pQueue;
|
|
1685 v18 = (char *)&pTurnEngine - (char *)this;
|
|
1686 v14 = this->pQueue;
|
|
1687 do
|
|
1688 {
|
|
1689 if (PID_TYPE(v3->uPackedID) != OBJECT_Player)
|
|
1690 {
|
|
1691 v4 = PID_ID(v3->uPackedID);
|
|
1692 uActorID = v4;
|
|
1693 v5 = &pActors[v4];
|
|
1694 v6 = v5->uAIState;
|
|
1695 if ( v6 != 5 )
|
|
1696 {
|
|
1697 if ( v6 != 11 )
|
|
1698 {
|
|
1699 if ( v6 != 19 )
|
|
1700 {
|
|
1701 if ( v6 != 17 )
|
|
1702 {
|
|
1703 v7 = (unsigned int *)&ai_near_actors_targets_pid[v4];
|
|
1704 a2 = *v7;
|
|
1705 v8 = a2;
|
|
1706 Actor::_SelectTarget(v4, (int *)v7, true);
|
|
1707 memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11));
|
|
1708 memcpy(&a4, &v11, sizeof(a4));
|
|
1709 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
|
|
1710 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
|
|
1711 {
|
|
1712 if (v5->uAIState == Dying)
|
|
1713 {
|
|
1714 v5->uCurrentActionTime = 0;
|
|
1715 v5->uCurrentActionLength = 0;
|
|
1716 v5->uAIState = Dead;
|
|
1717 v5->UpdateAnimation();
|
|
1718 return;
|
|
1719 }
|
|
1720 if ( rand() % 2 )
|
|
1721 Actor::AI_Stand(uActorID, a2, 64, &a4);
|
|
1722 else
|
|
1723 Actor::AI_Bored(uActorID, a2, &a4);
|
|
1724 }
|
|
1725 }
|
|
1726 }
|
|
1727 }
|
|
1728 }
|
|
1729 }
|
|
1730 ++v17;
|
|
1731 v3 = v14 + 1;
|
|
1732 v9 = __OFSUB__(v17, v13->uActorQueueSize);
|
|
1733 v2 = v17 - v13->uActorQueueSize < 0;
|
|
1734 ++v14;
|
|
1735 }
|
|
1736 while ( v2 ^ v9 );
|
|
1737 }
|
|
1738 }
|
|
1739
|