annotate TurnEngine.cpp @ 1333:d14bc530cddb

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