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()
|
|
912 {
|
|
913 int *v1; // edx@2
|
|
914 Actor *v2; // eax@5
|
|
915 unsigned __int16 v3; // si@5
|
|
916 unsigned int v4; // esi@8
|
|
917 int v5; // [sp+Ch] [bp-4h]@1
|
|
918
|
|
919 v5 = 0;
|
|
920 if ( this->uActorQueueSize > 0 )
|
|
921 {
|
|
922 v1 = &this->pQueue[0].field_4;
|
|
923 do
|
|
924 {
|
|
925 if ( !*(int *)v1 )
|
|
926 {
|
|
927 if ( PID_TYPE(*(v1 - 4)) == OBJECT_Player)
|
|
928 return;
|
|
929 v2 = &pActors[PID_ID(*(v1 - 1))];
|
|
930 v3 = v2->uAIState;
|
|
931 if (v3 == Standing || v3 == Fleeing || v3 == Fidgeting)
|
|
932 {
|
|
933 v4 = pMonsterStats->pInfos[v2->pMonsterInfo.uID].uRecoveryTime;
|
|
934 *(int *)v1 = v4;
|
|
935 if ( (signed __int64)v2->pActorBuffs[7].uExpireTime > 0 )
|
|
936 *(int *)v1 = 2 * v4;
|
|
937 }
|
|
938 }
|
|
939 ++v5;
|
|
940 v1 += 16;
|
|
941 }
|
|
942 while ( v5 < this->uActorQueueSize );
|
|
943 }
|
|
944 }
|
|
945
|
|
946 //----- (004065B0) --------------------------------------------------------
|
|
947 void stru262_TurnBased::_4065B0()
|
|
948 {
|
|
949 stru262_TurnBased *v1; // esi@1
|
|
950 signed int v2; // eax@1
|
|
951 int v3; // ebx@6
|
|
952 int v4; // edi@7
|
|
953 unsigned int v5; // edi@14
|
|
954
|
|
955 v1 = this;
|
|
956 SortTurnQueue();
|
|
957 if ( v1->pQueue[0].field_4 <= 0
|
|
958 || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ?
|
|
959 (uActiveCharacter = 0) : (v2 = (PID_ID(v2)) + 1, uActiveCharacter = v2),
|
|
960 viewparams->bRedrawGameUI = 1,
|
|
961 v1->pQueue[0].field_4 <= 0) )
|
|
962 {
|
|
963 v3 = 0;
|
|
964 if ( v1->uActorQueueSize > 0 )
|
|
965 {
|
|
966 v4 = (int)v1->pQueue;
|
|
967 do
|
|
968 {
|
|
969 v2 = *(int *)v4;
|
|
970 if ( PID_TYPE(*(char *)v4) == OBJECT_Player || *(int *)(v4 + 4) > 0 )
|
|
971 break;
|
|
972 if ( *(int *)(v4 + 8) <= 0 )
|
|
973 {
|
|
974 LOWORD(v2) = v2 & 3;
|
|
975 if ( (char)v2 == 3 )
|
|
976 LOWORD(v2) = v1->_40680F(v3);
|
|
977 }
|
|
978 ++v3;
|
|
979 v4 += 16;
|
|
980 }
|
|
981 while ( v3 < v1->uActorQueueSize );
|
|
982 }
|
|
983 }
|
|
984 v5 = 0;
|
|
985 if ( v1->uActorQueueSize > 0 )
|
|
986 {
|
|
987 do
|
|
988 v1->_406648(v5++);
|
|
989 while ( (signed int)v5 < v1->uActorQueueSize );
|
|
990 }
|
|
991 }
|
|
992
|
|
993 //----- (00406648) --------------------------------------------------------
|
|
994 void stru262_TurnBased::_406648(unsigned int a2)
|
|
995 {
|
|
996 TurnBased_QueueElem *v1; // ecx@1
|
|
997 int v3; // eax@1
|
|
998 unsigned int v4; // ebx@2
|
|
999 Actor *v5; // esi@2
|
|
1000 signed int v6; // edi@5
|
|
1001 int v7; // ecx@6
|
|
1002 int v8; // eax@6
|
|
1003 int v9; // eax@7
|
|
1004 int v10; // eax@8
|
|
1005 int v11; // eax@9
|
|
1006 int v12; // eax@10
|
|
1007 int v13; // eax@11
|
|
1008 int v14; // eax@14
|
|
1009 unsigned int v15; // ecx@14
|
|
1010 unsigned int v16; // edx@14
|
|
1011 int v17; // eax@17
|
|
1012 int v18; // eax@20
|
|
1013 char v19; // al@24
|
|
1014 unsigned int v21; // [sp-8h] [bp-50h]@16
|
|
1015 int v22; // [sp-8h] [bp-50h]@17
|
|
1016 AIDirection *v23; // [sp-4h] [bp-4Ch]@14
|
|
1017 unsigned int v24; // [sp-4h] [bp-4Ch]@17
|
|
1018 char v25; // [sp-4h] [bp-4Ch]@20
|
|
1019 AIDirection a3; // [sp+Ch] [bp-3Ch]@2
|
|
1020 AIDirection a4; // [sp+28h] [bp-20h]@2
|
|
1021 TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
|
|
1022 unsigned int a2a; // [sp+50h] [bp+8h]@2
|
|
1023
|
|
1024 v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
|
|
1025 v28 = v1;
|
|
1026 v3 = v1->uPackedID;
|
|
1027 if (PID_TYPE(v1->uPackedID) != OBJECT_Player)
|
|
1028 {
|
|
1029 v4 = PID_ID(v3);
|
|
1030 a2a = ai_near_actors_targets_pid[PID_ID(v3)];
|
|
1031 memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3));
|
|
1032 memcpy(&a4, &a3, sizeof(a4));
|
|
1033 v5 = &pActors[PID_ID(v3)];
|
|
1034 LOWORD(v3) = v5->uAIState;
|
|
1035 if ( (short)v3 != Dead )
|
|
1036 {
|
|
1037 if ( (short)v3 != Disabled )
|
|
1038 {
|
|
1039 if ( (short)v3 != Removed )
|
|
1040 {
|
|
1041 v6 = v5->uCurrentActionLength;
|
|
1042 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
|
|
1043 if ( (signed int)v5->uCurrentActionTime >= v6 )
|
|
1044 {
|
|
1045 v7 = (signed __int16)v3;
|
|
1046 v8 = (signed __int16)v3 - 2;
|
|
1047 if ( !v8 )
|
|
1048 {
|
|
1049 v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4);
|
|
1050 stru_50FE08.Add(
|
|
1051 v28->uPackedID,
|
|
1052 5120,
|
|
1053 v5->vPosition.x,
|
|
1054 v5->vPosition.y,
|
|
1055 v5->vPosition.z + ((signed int)v5->uActorHeight >> 1),
|
|
1056 v19,
|
|
1057 1);
|
|
1058 goto LABEL_25;
|
|
1059 }
|
|
1060 v9 = v8 - 1;
|
|
1061 if ( v9 )
|
|
1062 {
|
|
1063 v10 = v9 - 1;
|
|
1064 if ( !v10 )
|
|
1065 goto LABEL_21;
|
|
1066 v11 = v10 - 4;
|
|
1067 if ( !v11 )
|
|
1068 goto LABEL_25;
|
|
1069 v12 = v11 - 4;
|
|
1070 if ( v12 )
|
|
1071 {
|
|
1072 v13 = v12 - 1;
|
|
1073 if ( v13 )
|
|
1074 {
|
|
1075 if ( v13 != Dead )
|
|
1076 {
|
|
1077 if ( v7 != 4 )
|
|
1078 {
|
|
1079 v14 = rand();
|
|
1080 v15 = v4;
|
|
1081 v23 = &a4;
|
|
1082 v16 = a2a;
|
|
1083 if ( !(v14 % 2) )
|
|
1084 {
|
|
1085 Actor::AI_Bored(v4, a2a, &a4);
|
|
1086 return;
|
|
1087 }
|
|
1088 v21 = 64;
|
|
1089 LABEL_26:
|
|
1090 Actor::AI_Stand(v15, v16, v21, v23);
|
|
1091 return;
|
|
1092 }
|
|
1093 LABEL_21:
|
|
1094 v5->uCurrentActionTime = 0;
|
|
1095 v5->uCurrentActionLength = 0;
|
|
1096 v5->uAIState = Dead;
|
|
1097 pActors[v4].UpdateAnimation();
|
|
1098 return;
|
|
1099 }
|
|
1100 v24 = v5->pMonsterInfo.uSpellSkillAndMastery2;
|
|
1101 v22 = 3;
|
|
1102 v17 = v5->pMonsterInfo.uSpell2ID;
|
|
1103 }
|
|
1104 else
|
|
1105 {
|
|
1106 v24 = v5->pMonsterInfo.uSpellSkillAndMastery1;
|
|
1107 v22 = 2;
|
|
1108 v17 = v5->pMonsterInfo.uSpell1ID;
|
|
1109 }
|
|
1110 Actor::AI_SpellAttack(v4, &a4, v17, v22, v24);
|
|
1111 LABEL_25:
|
|
1112 v16 = a2a;
|
|
1113 v23 = &a4;
|
|
1114 v21 = 0;
|
|
1115 v15 = v4;
|
|
1116 goto LABEL_26;
|
|
1117 }
|
|
1118 v18 = v5->pMonsterInfo.uMissleAttack2Type;
|
|
1119 v25 = 1;
|
|
1120 }
|
|
1121 else
|
|
1122 {
|
|
1123 v18 = v5->pMonsterInfo.uMissleAttack1Type;
|
|
1124 v25 = 0;
|
|
1125 }
|
|
1126 Actor::AI_RangedAttack(v4, &a4, v18, v25);
|
|
1127 goto LABEL_25;
|
|
1128 }
|
|
1129 }
|
|
1130 }
|
|
1131 }
|
|
1132 }
|
|
1133 }
|
|
1134 // 50FE08: using guessed type stru298 stru_50FE08;
|
|
1135
|
|
1136 //----- (0040680F) --------------------------------------------------------
|
|
1137 __int16 stru262_TurnBased::_40680F(int a2)
|
|
1138 {
|
|
1139 TurnBased_QueueElem *v2; // eax@1
|
|
1140 unsigned int v3; // eax@1
|
|
1141 unsigned int v4; // edi@2
|
|
1142 Actor *v5; // ebx@2
|
|
1143 unsigned int *v6; // esi@7
|
|
1144 AIDirection *v7; // esi@10
|
|
1145 int v8; // eax@10
|
|
1146 unsigned int v9; // ecx@10
|
|
1147 signed int v10; // eax@13
|
|
1148 unsigned __int8 v11; // sf@19
|
|
1149 unsigned __int8 v12; // of@19
|
|
1150 int v13; // esi@29
|
|
1151 bool v14; // eax@29
|
|
1152 unsigned __int8 v15; // cl@33
|
|
1153 AIDirection a3; // [sp+Ch] [bp-44h]@10
|
|
1154 AIDirection v18; // [sp+28h] [bp-28h]@10
|
|
1155 int a2a; // [sp+44h] [bp-Ch]@2
|
|
1156 unsigned int v20; // [sp+48h] [bp-8h]@10
|
|
1157 TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1
|
|
1158 signed int v22; // [sp+58h] [bp+8h]@10
|
|
1159
|
|
1160 v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
|
|
1161 v21 = v2;
|
|
1162 v2->uActionLength = 0;
|
|
1163 v3 = v2->uPackedID;
|
|
1164 if ( (unsigned __int8)v3 & 3 )
|
|
1165 {
|
|
1166 v3 = PID_ID(v3);
|
|
1167 v4 = v3;
|
|
1168 a2a = v3;
|
|
1169 v5 = &pActors[v3];
|
|
1170 LOWORD(v3) = v5->uAIState;
|
|
1171 if ( (short)v3 != 5 )
|
|
1172 {
|
|
1173 if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 )
|
|
1174 {
|
|
1175 v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4];
|
|
1176 Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true);
|
|
1177 if ( v5->pMonsterInfo.uHostilityType && !*v6 )
|
|
1178 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
|
|
1179 v22 = *v6;
|
|
1180 v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,(int)v4), *v6, &a3, 0);
|
|
1181 v8 = v5->uActorRadius;
|
|
1182 memcpy(&a3, v7, sizeof(a3));
|
|
1183 memcpy(&v18, &a3, sizeof(v18));
|
|
1184 v9 = a3.uDistance - v8;
|
|
1185 v20 = a3.uDistance - v8;
|
|
1186 if ( ((a3.uDistance - v8) & 0x80000000u) != 0 )
|
|
1187 {
|
|
1188 v9 = 0;
|
|
1189 v20 = 0;
|
|
1190 }
|
|
1191 if (PID_TYPE(v22) == OBJECT_Actor)
|
|
1192 //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3);
|
|
1193 v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(v5->pMonsterInfo.uID - 1) / 3 + 1];
|
|
1194 else
|
|
1195 v10 = 4;
|
|
1196 if ( v10 == 1 )
|
|
1197 {
|
|
1198 if ( (double)(signed int)v20 < 307.2 )
|
|
1199 goto LABEL_25;
|
|
1200 }
|
|
1201 else
|
|
1202 {
|
|
1203 if ( v10 == 2 )
|
|
1204 {
|
|
1205 v12 = __OFSUB__(v9, 1024);
|
|
1206 v11 = ((v9 - 1024) & 0x80000000u) != 0;
|
|
1207 }
|
|
1208 else
|
|
1209 {
|
|
1210 if ( v10 == 3 )
|
|
1211 {
|
|
1212 v12 = __OFSUB__(v9, 2560);
|
|
1213 v11 = ((v9 - 2560) & 0x80000000u) != 0;
|
|
1214 }
|
|
1215 else
|
|
1216 {
|
|
1217 if ( v10 != 4 )
|
|
1218 goto LABEL_26;
|
|
1219 v12 = __OFSUB__(v9, 5120);
|
|
1220 v11 = ((v9 - 5120) & 0x80000000u) != 0;
|
|
1221 }
|
|
1222 }
|
|
1223 if ( v11 ^ v12 )
|
|
1224 {
|
|
1225 LABEL_25:
|
|
1226 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
|
|
1227 goto LABEL_26;
|
|
1228 }
|
|
1229 }
|
|
1230 LABEL_26:
|
|
1231 if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 )
|
|
1232 {
|
|
1233 v13 = a2a;
|
|
1234 goto LABEL_47;
|
|
1235 }
|
|
1236 v13 = a2a;
|
|
1237 v14 = stru_50C198.special_ability_use_check(v5, a2a);
|
|
1238 if ( v14 == 1 )
|
|
1239 {
|
|
1240 if ( v5->pMonsterInfo.uMissleAttack2Type )
|
|
1241 {
|
|
1242 Actor::AI_MissileAttack2(v13, v22, &v18);
|
|
1243 goto LABEL_43;
|
|
1244 }
|
|
1245 }
|
|
1246 else
|
|
1247 {
|
|
1248 if ( v14 > 1 && v14 <= 3 )
|
|
1249 {
|
|
1250 if ( v14 == 2 )
|
|
1251 v15 = v5->pMonsterInfo.uSpell1ID;
|
|
1252 else
|
|
1253 v15 = v5->pMonsterInfo.uSpell2ID;
|
|
1254 if ( v15 )
|
|
1255 {
|
|
1256 if ( v14 == 2 )
|
|
1257 Actor::AI_SpellAttack1(v13, v22, &v18);
|
|
1258 else
|
|
1259 Actor::AI_SpellAttack2(v13, v22, &v18);
|
|
1260 goto LABEL_43;
|
|
1261 }
|
|
1262 goto LABEL_44;
|
|
1263 }
|
|
1264 if ( v5->pMonsterInfo.uMissleAttack1Type )
|
|
1265 {
|
|
1266 Actor::AI_MissileAttack1(v13, v22, &v18);
|
|
1267 LABEL_43:
|
|
1268 //v3 = v21;
|
|
1269 v21->field_C = 1;
|
|
1270 LABEL_48:
|
|
1271 v21->uActionLength = v5->uCurrentActionLength;
|
|
1272 //return (signed __int16)v3;
|
|
1273 return (signed __int16)&v21;
|
|
1274 }
|
|
1275 }
|
|
1276 LABEL_44:
|
|
1277 if ( (double)(signed int)v20 < 307.2 )
|
|
1278 {
|
|
1279 Actor::AI_MeleeAttack(v13, v22, &v18);
|
|
1280 //v3 = v21;
|
|
1281 v21->field_C = 3;
|
|
1282 goto LABEL_48;
|
|
1283 }
|
|
1284 LABEL_47:
|
|
1285 Actor::AI_Stand(v13, v22, 0x40u, &v18);
|
|
1286 //v3 = v21;
|
|
1287 v21->field_C = 0;
|
|
1288 goto LABEL_48;
|
|
1289 }
|
|
1290 }
|
|
1291 }
|
|
1292 return (signed __int16)v3;
|
|
1293 }
|
|
1294
|
|
1295 //----- (00406A63) --------------------------------------------------------
|
|
1296 void stru262_TurnBased::_406A63()
|
|
1297 {
|
|
1298 stru262_TurnBased *v1; // ebx@1
|
|
1299 int v2; // esi@1
|
|
1300 unsigned __int8 v3; // zf@1
|
|
1301 unsigned __int8 v4; // sf@1
|
|
1302 signed int v5; // ecx@4
|
|
1303 AIDirection a3; // [sp+8h] [bp-44h]@5
|
|
1304 AIDirection v7; // [sp+24h] [bp-28h]@5
|
|
1305 unsigned int v8; // [sp+40h] [bp-Ch]@5
|
|
1306 signed int a2; // [sp+44h] [bp-8h]@1
|
|
1307 TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2
|
|
1308
|
|
1309 v1 = this;
|
|
1310 v2 = 0;
|
|
1311 this->field_8 = 64;
|
|
1312 dword_50C994 = 0;
|
|
1313 uActiveCharacter = 0;
|
|
1314 v3 = this->uActorQueueSize == 0;
|
|
1315 v4 = this->uActorQueueSize < 0;
|
|
1316 a2 = 0;
|
|
1317 if ( !(v4 | v3) )
|
|
1318 {
|
|
1319 v10 = this->pQueue;
|
|
1320 while ( 1 )
|
|
1321 {
|
|
1322 v5 = v10->uPackedID;
|
|
1323 if (PID_TYPE(v10->uPackedID) == OBJECT_Actor)
|
|
1324 {
|
|
1325 v8 = ai_near_actors_targets_pid[PID_ID(v5)];
|
|
1326 memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7));
|
|
1327 if ( !v1->ActorTurn(a2) )
|
|
1328 Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 32, &v7);
|
|
1329 }
|
|
1330 ++a2;
|
|
1331 ++v10;
|
|
1332 if ( a2 >= v1->uActorQueueSize )
|
|
1333 break;
|
|
1334 v2 = 0;
|
|
1335 }
|
|
1336 }
|
|
1337 }
|
|
1338 // 50C994: using guessed type int dword_50C994;
|
|
1339
|
|
1340 //----- (00406AFE) --------------------------------------------------------
|
|
1341 void stru262_TurnBased::_406AFE()
|
|
1342 {
|
|
1343 stru262_TurnBased *v1; // edi@1
|
|
1344 TurnBased_QueueElem *v2; // ebx@2
|
|
1345 int v3; // esi@4
|
|
1346 int v4; // ecx@5
|
|
1347 AIDirection a3; // [sp+4h] [bp-48h]@5
|
|
1348 AIDirection v6; // [sp+20h] [bp-2Ch]@5
|
|
1349 stru262_TurnBased *v7; // [sp+3Ch] [bp-10h]@1
|
|
1350 unsigned int v8; // [sp+40h] [bp-Ch]@4
|
|
1351 unsigned int v9; // [sp+44h] [bp-8h]@5
|
|
1352 int v10; // [sp+48h] [bp-4h]@1
|
|
1353
|
|
1354 v10 = 0;
|
|
1355 v1 = this;
|
|
1356 v7 = this;
|
|
1357 if ( this->uActorQueueSize > 0 )
|
|
1358 {
|
|
1359 v2 = this->pQueue;
|
|
1360 do
|
|
1361 {
|
|
1362 if (PID_TYPE(v2->uPackedID) == OBJECT_Actor)
|
|
1363 {
|
|
1364 v3 = PID_ID(v2->uPackedID);
|
|
1365 v8 = v3;
|
|
1366 if ( pActors[v3].CanAct() )
|
|
1367 {
|
|
1368 v4 = v2->uPackedID;
|
|
1369 v9 = ai_near_actors_targets_pid[v3];
|
|
1370 memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6));
|
|
1371 Actor::AI_Stand(v8, v9, 32, &v6);
|
|
1372 v2->field_C = 0;
|
|
1373 v2->uActionLength = 0;
|
|
1374 v1 = v7;
|
|
1375 }
|
|
1376 }
|
|
1377 ++v10;
|
|
1378 ++v2;
|
|
1379 }
|
|
1380 while ( v10 < v1->uActorQueueSize );
|
|
1381 }
|
|
1382 v1->field_4 = 2;
|
|
1383 v1->field_8 = 100;
|
|
1384 }
|
|
1385
|
|
1386 //----- (00406B9F) --------------------------------------------------------
|
|
1387 int stru262_TurnBased::_406B9F()
|
|
1388 {
|
|
1389 signed int result; // eax@1
|
|
1390 unsigned __int8 v2; // zf@1
|
|
1391 unsigned __int8 v3; // sf@1
|
|
1392 int v4; // esi@4
|
|
1393 unsigned int v5; // esi@5
|
|
1394 Actor *v6; // ebx@5
|
|
1395 unsigned __int16 v7; // cx@15
|
|
1396 AIDirection a3; // [sp+0h] [bp-50h]@15
|
|
1397 AIDirection v9; // [sp+1Ch] [bp-34h]@15
|
|
1398 signed int a1; // [sp+38h] [bp-18h]@4
|
|
1399 stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1
|
|
1400 unsigned int v12; // [sp+40h] [bp-10h]@5
|
|
1401 unsigned int v13; // [sp+44h] [bp-Ch]@8
|
|
1402 TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2
|
|
1403 signed int a2; // [sp+4Ch] [bp-4h]@1
|
|
1404
|
|
1405 result = 0;
|
|
1406 thisa = this;
|
|
1407 v2 = this->uActorQueueSize == 0;
|
|
1408 v3 = this->uActorQueueSize < 0;
|
|
1409 a2 = 0;
|
|
1410 if ( !(v3 | v2) )
|
|
1411 {
|
|
1412 v14 = this->pQueue;
|
|
1413 while ( 1 )
|
|
1414 {
|
|
1415 v4 = v14->uPackedID;
|
|
1416 a1 = v14->uPackedID;
|
|
1417 if (PID_TYPE(a1) != OBJECT_Player)
|
|
1418 {
|
|
1419 v5 = PID_ID(v4);
|
|
1420 v12 = v5;
|
|
1421 v6 = &pActors[v5];
|
|
1422 if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
|
|
1423 || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result )
|
|
1424 v13 = result;
|
|
1425 else
|
|
1426 v13 = 1;
|
|
1427 if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result
|
|
1428 && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) )
|
|
1429 result = 1;
|
|
1430 if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) )
|
|
1431 {
|
|
1432 v13 = ai_near_actors_targets_pid[v5];
|
|
1433 memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
|
|
1434 v7 = v6->uAIState;
|
|
1435 if ( v7 == 6 || v7 == 1 )
|
|
1436 {
|
|
1437 if ( (double)(signed int)v9.uDistance < 307.2 )
|
|
1438 goto LABEL_26;
|
|
1439 }
|
|
1440 v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
|
|
1441 if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength )
|
|
1442 {
|
|
1443 if ( v7 == 4 )
|
|
1444 {
|
|
1445 v6->uCurrentActionTime = 0;
|
|
1446 v6->uCurrentActionLength = 0;
|
|
1447 v6->uAIState = Dead;
|
|
1448 v6->UpdateAnimation();
|
|
1449 }
|
|
1450 if ( !thisa->ActorTurn(a2) )
|
|
1451 LABEL_26:
|
|
1452 Actor::AI_Stand(v12, v13, 32, &v9);
|
|
1453 }
|
|
1454 }
|
|
1455 }
|
|
1456 ++a2;
|
|
1457 result = (signed int)thisa;
|
|
1458 ++v14;
|
|
1459 if ( a2 >= thisa->uActorQueueSize )
|
|
1460 break;
|
|
1461 result = 0;
|
|
1462 }
|
|
1463 }
|
|
1464 return result;
|
|
1465 }
|
|
1466
|
|
1467 //----- (00406D10) --------------------------------------------------------
|
|
1468 bool stru262_TurnBased::ActorTurn(signed int a2)
|
|
1469 {
|
|
1470 int v2; // ecx@1
|
|
1471 //int v3; // ecx@2
|
|
1472 Actor *actor; // ebx@2
|
|
1473 //unsigned __int16 v5; // dx@2
|
|
1474 int *v6; // esi@7
|
|
1475 TurnBased_QueueElem *v7; // edi@7
|
|
1476 int v8; // eax@7
|
|
1477 AIDirection *v9; // esi@10
|
|
1478 int v10; // eax@10
|
|
1479 unsigned int v11; // ecx@10
|
|
1480 unsigned __int8 pHostileType; // al@12
|
|
1481 unsigned __int8 v13; // sf@16
|
|
1482 unsigned __int8 v14; // of@16
|
|
1483 unsigned int v15; // edx@22
|
|
1484 unsigned int v16; // ecx@23
|
|
1485 TurnBased_QueueElem *v17; // eax@25
|
|
1486 double v18; // st7@33
|
|
1487 double v19; // st6@33
|
|
1488 int v21; // [sp-8h] [bp-5Ch]@23
|
|
1489 int v22; // [sp-8h] [bp-5Ch]@26
|
|
1490 AIDirection *v23; // [sp-4h] [bp-58h]@23
|
|
1491 int v24; // [sp-4h] [bp-58h]@26
|
|
1492 AIDirection a3; // [sp+Ch] [bp-48h]@10
|
|
1493 AIDirection pDir; // [sp+28h] [bp-2Ch]@10
|
|
1494 int v27; // [sp+44h] [bp-10h]@33
|
|
1495 unsigned int v28; // [sp+48h] [bp-Ch]@10
|
|
1496 TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7
|
|
1497 unsigned int uActorID; // [sp+50h] [bp-4h]@2
|
|
1498 unsigned int a2a; // [sp+5Ch] [bp+8h]@7
|
|
1499
|
|
1500 // __debugbreak();//ñðàáàòûâàåò ïðè ïîøàãîâîì ðåæèìå ïîñëå ïÿòè øàãîâ
|
|
1501 v2 = *(&this->field_0 + 4 * (a2 + 2));
|
|
1502 if (PID_TYPE(v2) == OBJECT_Player)
|
|
1503 return 0;
|
|
1504 uActorID = PID_ID(v2);
|
|
1505 //uActorID = v3;
|
|
1506 actor = &pActors[uActorID];
|
|
1507 //v5 = v4->uAIState;
|
|
1508 if ( actor->uAIState == 5 || actor->uAIState == 4 || actor->uAIState == 11 || actor->uAIState == 19 || actor->uAIState == 17 )
|
|
1509 return 1;
|
|
1510 v6 = &ai_near_actors_targets_pid[uActorID];
|
|
1511 v7 = &pTurnEngine->pQueue[a2];
|
|
1512 v8 = *v6;
|
|
1513 v29 = &pTurnEngine->pQueue[a2];
|
|
1514 a2a = v8;
|
|
1515 Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true);
|
|
1516 if ( actor->pMonsterInfo.uHostilityType && !*v6 )
|
|
1517 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
|
|
1518 v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
|
|
1519 v10 = actor->uActorRadius;
|
|
1520 memcpy(&a3, v9, sizeof(a3));
|
|
1521 memcpy(&pDir, &a3, sizeof(pDir));
|
|
1522 v11 = a3.uDistance - v10;
|
|
1523 v28 = a3.uDistance - v10;
|
|
1524 if ( ((a3.uDistance - v10) & 0x80000000u) != 0 )
|
|
1525 {
|
|
1526 v11 = 0;
|
|
1527 v28 = 0;
|
|
1528 }
|
|
1529 pHostileType = actor->pMonsterInfo.uHostilityType;
|
|
1530 if ( pHostileType == 1 )
|
|
1531 {
|
|
1532 if ( (double)(signed int)v28 >= 307.2 )
|
|
1533 goto LABEL_21;
|
|
1534 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
|
|
1535 goto LABEL_21;
|
|
1536 }
|
|
1537 if ( pHostileType == 2 )
|
|
1538 {
|
|
1539 v14 = __OFSUB__(v11, 1024);
|
|
1540 v13 = ((v11 - 1024) & 0x80000000u) != 0;
|
|
1541 }
|
|
1542 else
|
|
1543 {
|
|
1544 if ( pHostileType != 3 )
|
|
1545 goto LABEL_21;
|
|
1546 v14 = __OFSUB__(v11, 2560);
|
|
1547 v13 = ((v11 - 2560) & 0x80000000u) != 0;
|
|
1548 }
|
|
1549 if ( v13 ^ v14 )
|
|
1550 {
|
|
1551 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
|
|
1552 }
|
|
1553 LABEL_21:
|
|
1554 if ( (signed __int64)actor->pActorBuffs[4].uExpireTime > 0 )
|
|
1555 {
|
|
1556 if ( (signed int)v11 < 10240 )
|
|
1557 {
|
|
1558 Actor::AI_Flee(uActorID, a2a, 0, &pDir);
|
|
1559 v29->field_C = 4;
|
|
1560 v29->uActionLength = actor->uCurrentActionLength;
|
|
1561 return 1;
|
|
1562 }
|
|
1563 Actor::AI_4032B2(uActorID, a2a, 1024, 0);
|
|
1564 v29->field_C = 2;
|
|
1565 v29->uActionLength = actor->uCurrentActionLength;
|
|
1566 return 1;
|
|
1567 }
|
|
1568 if ( actor->pMonsterInfo.uHostilityType != 4 )
|
|
1569 goto LABEL_46;
|
|
1570 if ( !(actor->uAttributes & 0x020000) || actor->pMonsterInfo.uAIType == 1 )
|
|
1571 {
|
|
1572 if ( actor->pMonsterInfo.uAIType == 1 )
|
|
1573 {
|
|
1574 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1575 {
|
|
1576 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1577 v29->field_C = 4;
|
|
1578 v29->uActionLength = actor->uCurrentActionLength;
|
|
1579 return 1;
|
|
1580 }
|
|
1581 Actor::AI_Flee(uActorID, a2a, 32, 0);
|
|
1582 v29->field_C = 4;
|
|
1583 v29->uActionLength = actor->uCurrentActionLength;
|
|
1584 return 1;
|
|
1585 }
|
|
1586 if ( actor->pMonsterInfo.uAIType == 2 )
|
|
1587 {
|
|
1588 v27 = actor->sCurrentHP;
|
|
1589 v18 = (double)v27;
|
|
1590 v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.2;
|
|
1591 if ( v19 > v18 && (signed int)v11 < 10240 )
|
|
1592 {
|
|
1593 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1594 {
|
|
1595 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1596 v29->field_C = 4;
|
|
1597 v29->uActionLength = actor->uCurrentActionLength;
|
|
1598 return 1;
|
|
1599 }
|
|
1600 Actor::AI_Flee(uActorID, a2a, 32, 0);
|
|
1601 v29->field_C = 4;
|
|
1602 v29->uActionLength = actor->uCurrentActionLength;
|
|
1603 return 1;
|
|
1604 }
|
|
1605 goto LABEL_39;
|
|
1606 }
|
|
1607 if ( actor->pMonsterInfo.uAIType == 3 )
|
|
1608 {
|
|
1609 v27 = actor->sCurrentHP;
|
|
1610 v18 = (double)v27;
|
|
1611 v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.1;
|
|
1612 if ( v19 > v18 && (signed int)v11 < 10240 )
|
|
1613 {
|
|
1614 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1615 {
|
|
1616 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1617 v29->field_C = 4;
|
|
1618 v29->uActionLength = actor->uCurrentActionLength;
|
|
1619 return 1;
|
|
1620 }
|
|
1621 Actor::AI_Flee(uActorID, a2a, 32, 0);
|
|
1622 v29->field_C = 4;
|
|
1623 v29->uActionLength = actor->uCurrentActionLength;
|
|
1624 return 1;
|
|
1625 }
|
|
1626 goto LABEL_39;
|
|
1627 }
|
|
1628 }
|
|
1629 LABEL_39:
|
|
1630 if ( (double)(signed int)v28 < 307.2 )
|
|
1631 return 0;
|
|
1632 if ( (signed int)v11 < 5120 )
|
|
1633 {
|
|
1634 if ( actor->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
|
|
1635 Actor::AI_Pursue1(uActorID, a2a, uActorID, 32, &pDir);
|
|
1636 else
|
|
1637 Actor::AI_Pursue2(uActorID, a2a, 32, &pDir, 307);
|
|
1638 v29->field_C = 2;
|
|
1639 v29->uActionLength = actor->uCurrentActionLength;
|
|
1640 return 1;
|
|
1641 }
|
|
1642 LABEL_46:
|
|
1643 if ( actor->pMonsterInfo.uMovementType == 0 )
|
|
1644 {
|
|
1645 Actor::AI_4032B2(uActorID, a2a, 1024, 32);
|
|
1646 v29->field_C = 2;
|
|
1647 v29->uActionLength = actor->uCurrentActionLength;
|
|
1648 return 1;
|
|
1649 }
|
|
1650 if ( actor->pMonsterInfo.uMovementType == 1 )
|
|
1651 {
|
|
1652 Actor::AI_4032B2(uActorID, a2a, 2560, 32);
|
|
1653 v29->field_C = 2;
|
|
1654 v29->uActionLength = actor->uCurrentActionLength;
|
|
1655 return 1;
|
|
1656 }
|
|
1657 if ( actor->pMonsterInfo.uMovementType == 2 )
|
|
1658 {
|
|
1659 Actor::AI_4032B2(uActorID, a2a, 5120, 32);
|
|
1660 v29->field_C = 2;
|
|
1661 v29->uActionLength = actor->uCurrentActionLength;
|
|
1662 return 1;
|
|
1663 }
|
|
1664 if ( actor->pMonsterInfo.uMovementType == 4 )
|
|
1665 {
|
|
1666 Actor::AI_4032B2(uActorID, a2a, 10240, 32);
|
|
1667 v29->field_C = 2;
|
|
1668 v29->uActionLength = actor->uCurrentActionLength;
|
|
1669 return 1;
|
|
1670 }
|
|
1671 if ( actor->pMonsterInfo.uMovementType == 5 )
|
|
1672 {
|
|
1673 Actor::AI_Stand(uActorID, a2a, 32, 0);
|
|
1674 v29->field_C = 2;
|
|
1675 v29->uActionLength = actor->uCurrentActionLength;
|
|
1676 return 1;
|
|
1677 }
|
|
1678 return 1;
|
|
1679 }
|
|
1680
|
|
1681 //----- (00406FA8) --------------------------------------------------------
|
|
1682 void stru262_TurnBased::_406FA8()
|
|
1683 {
|
|
1684 unsigned __int8 v1; // zf@1
|
|
1685 unsigned __int8 v2; // sf@1
|
|
1686 TurnBased_QueueElem *v3; // edi@2
|
|
1687 int v4; // eax@4
|
|
1688 Actor *v5; // ebx@4
|
|
1689 unsigned __int16 v6; // cx@4
|
|
1690 unsigned int *v7; // edx@8
|
|
1691 unsigned int v8; // esi@8
|
|
1692 unsigned __int8 v9; // of@13
|
|
1693 AIDirection a3; // [sp+Ch] [bp-6Ch]@8
|
|
1694 AIDirection v11; // [sp+28h] [bp-50h]@8
|
|
1695 AIDirection a4; // [sp+44h] [bp-34h]@8
|
|
1696 stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1
|
|
1697 TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2
|
|
1698 int uActorID; // [sp+68h] [bp-10h]@4
|
|
1699 unsigned int a2; // [sp+6Ch] [bp-Ch]@8
|
|
1700 int v17; // [sp+70h] [bp-8h]@1
|
|
1701 unsigned int v18; // [sp+74h] [bp-4h]@2
|
|
1702
|
|
1703 v17 = 0;
|
|
1704 v1 = this->uActorQueueSize == 0;
|
|
1705 v2 = this->uActorQueueSize < 0;
|
|
1706 v13 = this;
|
|
1707 if ( !(v2 | v1) )
|
|
1708 {
|
|
1709 v3 = this->pQueue;
|
|
1710 v18 = (char *)&pTurnEngine - (char *)this;
|
|
1711 v14 = this->pQueue;
|
|
1712 do
|
|
1713 {
|
|
1714 if (PID_TYPE(v3->uPackedID) != OBJECT_Player)
|
|
1715 {
|
|
1716 v4 = PID_ID(v3->uPackedID);
|
|
1717 uActorID = v4;
|
|
1718 v5 = &pActors[v4];
|
|
1719 v6 = v5->uAIState;
|
|
1720 if ( v6 != 5 )
|
|
1721 {
|
|
1722 if ( v6 != 11 )
|
|
1723 {
|
|
1724 if ( v6 != 19 )
|
|
1725 {
|
|
1726 if ( v6 != 17 )
|
|
1727 {
|
|
1728 v7 = (unsigned int *)&ai_near_actors_targets_pid[v4];
|
|
1729 a2 = *v7;
|
|
1730 v8 = a2;
|
|
1731 Actor::_SelectTarget(v4, (int *)v7, true);
|
|
1732 memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11));
|
|
1733 memcpy(&a4, &v11, sizeof(a4));
|
|
1734 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
|
|
1735 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
|
|
1736 {
|
|
1737 if (v5->uAIState == Dying)
|
|
1738 {
|
|
1739 v5->uCurrentActionTime = 0;
|
|
1740 v5->uCurrentActionLength = 0;
|
|
1741 v5->uAIState = Dead;
|
|
1742 v5->UpdateAnimation();
|
|
1743 return;
|
|
1744 }
|
|
1745 if ( rand() % 2 )
|
|
1746 Actor::AI_Stand(uActorID, a2, 64, &a4);
|
|
1747 else
|
|
1748 Actor::AI_Bored(uActorID, a2, &a4);
|
|
1749 }
|
|
1750 }
|
|
1751 }
|
|
1752 }
|
|
1753 }
|
|
1754 }
|
|
1755 ++v17;
|
|
1756 v3 = v14 + 1;
|
|
1757 v9 = __OFSUB__(v17, v13->uActorQueueSize);
|
|
1758 v2 = v17 - v13->uActorQueueSize < 0;
|
|
1759 ++v14;
|
|
1760 }
|
|
1761 while ( v2 ^ v9 );
|
|
1762 }
|
|
1763 }
|
|
1764
|