annotate TurnEngine.cpp @ 1342:bdf0cc8620ad

TE continue
author Gloval
date Mon, 08 Jul 2013 01:04:42 +0400
parents 67e47fc3133d
children f0b95fb02b83
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 for( i=0; i<uActorQueueSize-1; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
64 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
65 v7=&pQueue[i];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
66 for(j=i+1; j<uActorQueueSize;++j )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
67 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
68 v8=&pQueue[j];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
69 if ( v8->field_4 < v7->field_4 ||
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
70 ((v8->field_4 == v7->field_4) &&
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
71 (
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
72 ((PID_TYPE(v8->uPackedID) == OBJECT_Player) && (PID_TYPE(v7->uPackedID) == OBJECT_Actor)) ||
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
73 ((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
74 )
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 memcpy(&temp_elem,v7,sizeof(TurnBased_QueueElem));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
79 memcpy(v7,v8, sizeof(TurnBased_QueueElem));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
80 memcpy(v8, &temp_elem, sizeof(TurnBased_QueueElem));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
81 }
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 uActorQueueSize = active_actors;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
86 if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
87 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
88 uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
89 field_18 |= TE_PLAYER_TURN;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
90 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
91 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
92 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
93 uActiveCharacter = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
94 field_18 &= ~TE_PLAYER_TURN;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
95 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
96 for(i=0; i<uActorQueueSize; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
97 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
98 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
99 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
100 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
101
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
102
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
103 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
104
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
105 //----- (0040471C) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
106 void stru262_TurnBased::_40471C()
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
107 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
108 if ( pParty->bTurnBasedModeOn == 1 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
109 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
110 if ( pTurnEngine->turn_stage == 2 )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
111 _406457(0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
112 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
113 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
114
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
115 //----- (004059DB) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
116 void stru262_TurnBased::Start()
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
117 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
118
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
119 int v3; // esi@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
120 unsigned int actor_id; // esi@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
121 Actor *pActor; // edi@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
122 unsigned int v8; // edx@10
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
123 signed int v16; // qax@19
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
124 int v17; // edx@22
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
125 AIDirection v30; // [sp+Ch] [bp-68h]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
126 AIDirection v31; // [sp+28h] [bp-4Ch]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
127 AIDirection a3; // [sp+44h] [bp-30h]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
128 Player *pPlayer; // [sp+6Ch] [bp-8h]@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
129 int v40b;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
130 int activ_players[4];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
131 int players_recovery_time[4];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
132 int a_players_count;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
133 int i,j;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
134 int temp;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
135
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
136 pTurnEngine->field_18 &= ~TE_FLAG_2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
137 pEventTimer->TrackGameTime();
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
138 pAudioPlayer->StopChannels(-1, -1);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
139 pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
140 pPlayer = pParty->pPlayers;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
141 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
142 dword_50C994 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
143
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
144 this->field_10 = 100;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
145 this->field_0 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
146 this->field_8 = 64;
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
147 this->turn_stage = 1;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
148 this->uActorQueueSize = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
149
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
150 for ( v3 = 0; v3 < 4 ; ++v3 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
151 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
152 if ( pParty->pPlayers[v3].CanAct() )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
153 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
154 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,v3);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
155 this->pQueue[this->uActorQueueSize].field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
156 this->pQueue[this->uActorQueueSize].uActionLength = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
157 pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
158 ++this->uActorQueueSize;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
159 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
160 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
161
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
162 for ( v3 = 0; v3 < ai_arrays_size ; ++v3 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
163 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
164 actor_id = ai_near_actors_ids[v3];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
165 if (actor_id == 10)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
166 continue;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
167 if ( pActors[actor_id].CanAct() )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
168 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
169 if ( pActors[actor_id].uAttributes & 0x8000 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
170 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
171 v8 = ai_near_actors_targets_pid[actor_id];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
172 pActors[actor_id].uAttributes |= 0x80;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
173 memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v8, &a3, 0), sizeof(AIDirection));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
174 memcpy(&v30, &v31, sizeof(AIDirection));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
175 Actor::AI_StandOrBored(actor_id, 4, 32, &v30);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
176 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,actor_id);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
177 this->pQueue[this->uActorQueueSize].field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
178 this->pQueue[this->uActorQueueSize].uActionLength = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
179 ++this->uActorQueueSize;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
180 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
181 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
182 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
183
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
184 a_players_count=0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
185 for ( v40b = 0; v40b < this->uActorQueueSize; ++v40b )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
186 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
187 //v13 = PID_TYPE(this->pQueue[0].uPackedID);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
188 if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Player )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
189 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
190 if ( pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery != 0 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
191 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
192 //v33 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
193 v16 = (signed int)((double)pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery * 0.46875);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
194 this->pQueue[v40b].field_4 = v16;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
195 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
196 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
197 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
198 activ_players[a_players_count] = v40b;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
199 ++a_players_count;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
200 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
201 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
202 else if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Actor )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
203 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
204 v17 = rand() % 99;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
205 if ( v17 < 33 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
206 this->pQueue[v40b].field_4 = 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
207 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
208 this->pQueue[v40b].field_4= (v17 >= 66)? 5 : 3;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
209 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
210 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
211 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
212 this->pQueue[v40b].field_4 = 666;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
213 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
214 this->pQueue[v40b].field_4 += 16;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
215 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
216
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
217 if ( a_players_count > 0 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
218 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
219 for (i=0; i<a_players_count; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
220 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
221 //sort players by recovery time
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
222 for (i=0; i < a_players_count-1; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
223 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
224 for(j=i+1; j<a_players_count;++j )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
225 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
226 if (players_recovery_time[j] < players_recovery_time[i]) //swap values
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
227 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
228 temp = players_recovery_time[i];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
229 players_recovery_time[i] = players_recovery_time[j];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
230 players_recovery_time[j] = temp;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
231
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
232 temp = activ_players[i];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
233 activ_players[i] = activ_players[j];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
234 activ_players[j] = temp;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
235 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
236 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
237 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
238
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
239 for (i=0; i<a_players_count; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
240 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
241 this->pQueue[activ_players[i]].field_4 = i+2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
242 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
243 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
244 this->SortTurnQueue();
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
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
249 //----- (00405CFF) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
250 void stru262_TurnBased::End(bool bPlaySound)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
251 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
252
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
253 ObjectType objType; // eax@13
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
254 int objID; // esi@13
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
255 int i;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
256
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
257 this->turn_stage = 0;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
258
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
259 for( i=0; i<uActorQueueSize; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
260 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
261 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
262 pActors[PID_ID(pQueue[i].uPackedID)].uAttributes &= ~0x80;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
263 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
264
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
265 for( i=0; i<uNumSpriteObjects; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
266 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
267 if (pSpriteObjects[i].uAttributes & 4)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
268 pSpriteObjects[i].uAttributes &= ~0x04;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
269 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
270
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
271 for( i=0; i<uActorQueueSize; ++i)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
272 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
273 objType = (ObjectType)PID_TYPE(pQueue[i].uPackedID);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
274 objID = PID_ID(pQueue[i].uPackedID);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
275 if ( objType == OBJECT_Player )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
276 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
277 pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
278 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
279 else if ( objType == OBJECT_Actor )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
280 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
281 pActors[objID].pMonsterInfo.uRecoveryTime = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333);
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
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
285 pAudioPlayer->StopChannels(-1, -1);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
286 if ( bPlaySound != 0 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
287 pAudioPlayer->PlaySound(SOUND_206, 0, 0, -1, 0, 0, 0, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
288 pTurnEngine->field_18 &= ~TE_FLAG_2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
289 pEventTimer->StopGameTime();
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
290 dword_50C994 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
291 dword_50C998_turnbased_icon_1A = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
292 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
293 // 50C994: using guessed type int dword_50C994;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
294 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
295
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
296 //----- (00405E14) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
297 void stru262_TurnBased::_405E14()
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
298 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
299 AIDirection *v6; // esi@21
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
300 int v7; // eax@21
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
301 AIDirection a3; // [sp+4h] [bp-68h]@21
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
302 AIDirection v14; // [sp+20h] [bp-4Ch]@21
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
303 AIDirection v15; // [sp+3Ch] [bp-30h]@21
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
304 Actor *curr_actor; // [sp+58h] [bp-14h]@2
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
305 int target_pid; // [sp+5Ch] [bp-10h]@6
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
306 int shrinked;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
307 int i,j;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
308
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
309 for (i =0; i<uNumActors; ++i )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
310 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
311 curr_actor=&pActors[i];
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
312 shrinked=pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
313 for (j =0; j<22; ++j) //check expired spell Buffs
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
314 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
315 if(j != 10)
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
316 pActors[i].pActorBuffs[j].IsBuffExpiredToTime(pParty->uTimePlayed);
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
317 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
318 if (shrinked && pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime <=0) //buff 3 expired
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
319 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
320 pActors[i].uActorHeight = pMonsterList->pMonsters[pActors[i].pMonsterInfo.uID - 1].uMonsterHeight;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
321 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
322 if(!(curr_actor->uAttributes&0x80)&&
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
323 (!curr_actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime)&&
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
324 (!curr_actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime))
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
325 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
326 curr_actor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
327 if (curr_actor->uCurrentActionTime>=curr_actor->uCurrentActionLength)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
328 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
329 target_pid = ai_near_actors_targets_pid[i];
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
330 v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,i), target_pid, &a3, 0);
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
331 memcpy(&v15, v6, sizeof(AIDirection));
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
332 memcpy(&v14, &v15, sizeof(AIDirection));
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
333 v7 = curr_actor->uAIState;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
334 if(v7==AIState::Dying)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
335 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
336 curr_actor->uCurrentActionTime = 0;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
337 curr_actor->uCurrentActionLength = 0;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
338 curr_actor->uAIState = Dead;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
339 curr_actor->UpdateAnimation();
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
340 }
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
341 else if ( (v7 > AIState::Removed)&&(v7 < AIState::Disabled))
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
342 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
343 Actor::AI_StandOrBored(i, target_pid, 32, &v14);
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
344 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
345 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
346 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
347 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
348
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
349 if ( turn_stage == 1 )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
350 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
351 if ( field_8 == 64 )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
352 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
353 _406A63();
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
354 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
355 else if ( field_8 > 0 )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
356 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
357 _406B9F();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
358 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
359 else
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
360 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
361 _406AFE();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
362 field_10 = 100;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
363 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
364 field_8 -= pEventTimer->uTimeElapsed;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
365 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
366 else if ( turn_stage == 2 )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
367 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
368 if ( !(field_18 & TE_FLAG_1) )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
369 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
370 if ( field_10 == 100 )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
371 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
372 StartTurn();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
373 _40652A();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
374 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
375 if ( field_10 > 0 || pQueue[0].field_4 <= 0 )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
376 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
377 _4065B0();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
378 _40652A();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
379 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
380 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
381 else
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
382 NextTurn();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
383 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
384 else if ( turn_stage == 3 )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
385 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
386 if ( uActionPointsLeft <= 0 || field_18 & TE_FLAG_8 )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
387 {
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
388 field_18 &= ~TE_FLAG_8;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
389 turn_stage = 1;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
390 field_8 = 64;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
391 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
392 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
393 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
394 _406FA8();
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
395 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
396 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
397 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
398
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
399
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
400 //----- (00406051) --------------------------------------------------------
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
401 void stru262_TurnBased::StartTurn()
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
402 {
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
403 int player_num, actor_num, i, j;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
404
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
405 field_1C = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
406 for(player_num=0; player_num<4; ++player_num)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
407 {
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
408 for(j=0; j<uActorQueueSize; ++j)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
409 {
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
410 if (PID_TYPE(pQueue[j].uPackedID)== OBJECT_Player)
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
411 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
412 if (pPlayers[PID_ID(pQueue[j].uPackedID) + 1]->CanAct() && (player_num != PID_ID(pQueue[j].uPackedID)) )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
413 break;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
414 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
415 }
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
416 if (j==uActorQueueSize )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
417 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
418 pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Player,player_num);
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
419 pQueue[uActorQueueSize].field_4 = 100;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
420 pQueue[uActorQueueSize].uActionLength = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
421 pQueue[uActorQueueSize].field_C = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
422 ++uActorQueueSize;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
423 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
424 }
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
425
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
426 for(actor_num=0; actor_num<ai_arrays_size; ++actor_num)
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
427 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
428 for(j=0; j<uActorQueueSize; ++j)
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
429 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
430 if ((PID_TYPE(pQueue[j].uPackedID)== OBJECT_Actor)&&
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
431 ai_near_actors_ids[actor_num] == PID_ID(pQueue[j].uPackedID))
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
432 break;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
433 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
434 if (j==uActorQueueSize )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
435 {
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
436 pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[actor_num]);
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
437 pQueue[uActorQueueSize].field_4 = 1;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
438 pQueue[uActorQueueSize].uActionLength = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
439 pQueue[uActorQueueSize].field_C = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
440 ++uActorQueueSize;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
441 }
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
442 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
443
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
444 ++field_0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
445 field_10 = 100;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
446
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
447 for(i=0; i<uActorQueueSize; ++i)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
448 {
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
449 if (pQueue[i].field_4 == 0 )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
450 pQueue[i].field_4 = 100;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
451 }
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
452
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
453 _4063A1();
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
454 for(i=0; i<uActorQueueSize; ++i)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
455 {
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
456 if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)||(pQueue[i].field_4 > 0))
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
457 break;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
458 _40680F(i);
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
459 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
460 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
461 // 4F75D8: using guessed type int ai_arrays_size;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
462
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
463 //----- (004061CA) --------------------------------------------------------
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
464 void stru262_TurnBased::NextTurn()
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
465 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
466 Actor *curr_actor; // eax@9
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
467 int ai_state; // ecx@9
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
468 int v13; // [sp+10h] [bp-4h]@7
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
469 int i;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
470 int monster_ai_state;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
471 int monster; // eax@5
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
472
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
473 SortTurnQueue();
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
474 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
475 uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
476 else
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
477 uActiveCharacter = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
478 viewparams->bRedrawGameUI = 1;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
479
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
480 if ( field_1C )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
481 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
482 pTurnEngine->field_18 |= TE_FLAG_2;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
483 return;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
484 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
485 pTurnEngine->field_18 &= ~TE_FLAG_2;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
486 if ( pQueue[0].field_4 <= 0 )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
487 return;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
488
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
489 v13 = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
490 if (uActorQueueSize > 0 )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
491 {
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
492
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
493 for (i=0; i<uActorQueueSize; ++i )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
494 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
495 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
496 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
497 curr_actor = &pActors[PID_ID(pQueue[i].uPackedID)];
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
498 ai_state = curr_actor->uAIState;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
499 if ( (ai_state == AIState::Dying) || (ai_state == AIState::Stunned) || (ai_state == AIState::AttackingMelee) ||
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
500 (ai_state == AIState::AttackingRanged1) || (ai_state == AIState::AttackingRanged2) ||
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
501 (ai_state == AIState::AttackingRanged3) || (ai_state == AIState::AttackingRanged4) || (ai_state ==AIState::Summoned))
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
502 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
503 curr_actor->uCurrentActionTime += pEventTimer->uTimeElapsed;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
504 if ( curr_actor->uCurrentActionTime < curr_actor->uCurrentActionLength )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
505 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
506 v13 = 1;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
507 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
508 else if ( ai_state == 4 )// Dying
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
509 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
510 curr_actor->uAIState = AIState::Dead;
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
511 curr_actor->uCurrentActionTime = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
512 curr_actor->uCurrentActionLength = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
513 curr_actor->UpdateAnimation();
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
514 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
515 else
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
516 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
517 if ( ai_state == 8 ) //Stunned
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
518 Actor::AI_StandOrBored(PID_ID(pQueue[i].uPackedID), ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)], 32, 0);
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
519 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
520 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
521 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
522 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
523 if ( v13 != 0 )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
524 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
525 field_18 |= TE_FLAG_1;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
526 return;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
527 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
528 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
529
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
530 field_18 &= ~TE_FLAG_1;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
531 for (i=0; i<uActorQueueSize; ++i )
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
532 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
533 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
534 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
535 monster=PID_ID(pQueue[i].uPackedID);
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
536 monster_ai_state=pActors[monster].uAIState;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
537 if ((monster_ai_state != AIState::Dead) &&
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
538 (monster_ai_state != AIState::Dying) &&
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
539 (monster_ai_state != AIState::Removed) &&
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
540 (monster_ai_state != AIState::Summoned) &&
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
541 (monster_ai_state != AIState::Disabled))
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
542 {
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
543 pQueue[i].uActionLength = 0;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
544 Actor::AI_StandOrBored(monster, ai_near_actors_targets_pid[monster], 32, nullptr);
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
545 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
546 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
547 }
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
548 turn_stage = 3;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
549 pParty->uTimePlayed += 213i64;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
550 _494035_timed_effects__water_walking_damage__etc();
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
551 uActionPointsLeft = 130;
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
552 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
553
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
554 //----- (004063A1) --------------------------------------------------------
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
555 int stru262_TurnBased::_4063A1()
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
556 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
557 int v9; // dx@12
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
558 int j;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
559
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
560 SortTurnQueue();
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
561 viewparams->bRedrawGameUI = 1;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
562 if ( pQueue[0].field_4 )
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
563 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
564 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
565 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
566 do
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
567 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
568 for (j=0; j<uActorQueueSize; ++j )
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
569 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
570 --pQueue[j].field_4;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
571 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
572 --field_10;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
573 if (field_10 == 0)
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
574 return 1;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
575 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
576 while (pQueue[0].field_4 > 0);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
577 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
578 else
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
579 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
580 v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
581 if (!(v9 == AIState::Dying || v9 == AIState::Dead ||
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
582 v9 == AIState::Disabled || v9 == AIState::Removed))
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
583 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
584 do
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
585 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
586 for (j=0; j<uActorQueueSize; ++j )
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
587 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
588 --pQueue[j].field_4;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
589 if (pQueue[j].field_4 == 1)
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
590 pQueue[j].uActionLength = 0;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
591 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
592 --field_10;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
593 if (field_10 == 0)
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
594 return 1;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
595 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
596 while (pQueue[0].field_4 > 0);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
597 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
598 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
599 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
600 return 0;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
601 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
602
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
603 //----- (00406457) --------------------------------------------------------
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
604 void stru262_TurnBased::_406457( int a2 )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
605 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
606 stru262_TurnBased *v2; // esi@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
607 signed int v3; // eax@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
608 signed int v4; // ecx@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
609 char *v5; // edx@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
610 signed int v6; // eax@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
611 int result; // eax@11
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
612 int v8; // edx@13
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
613 int v9; // ecx@14
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
614 char v10; // zf@15
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
615 int i;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
616
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
617 if ( PID_TYPE(pQueue[a2].uPackedID) == OBJECT_Player)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
618 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
619 v4 = PID_ID(pQueue[a2].uPackedID);
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
620 if ( pParty->pTurnBasedPlayerRecoveryTimes[v4] )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
621 pParty->pTurnBasedPlayerRecoveryTimes[v4] = 0;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
622 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
623 v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
624 if ( v6 < 30 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
625 v6 = 30;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
626 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
627 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
628 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
629 v6 = pMonsterStats->pInfos[pActors[PID_ID(pQueue[a2].uPackedID)].pMonsterInfo.uID].uRecoveryTime;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
630 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
631
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
632 pQueue[a2].field_4 = v6;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
633 SortTurnQueue();
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
634 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
635 uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
636 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
637 uActiveCharacter = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
638 viewparams->bRedrawGameUI = 1;
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
639 if (pQueue[0].field_4 > 0)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
640 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
641 while(field_10 > 0)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
642 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
643 for (i=0; i<uActorQueueSize; ++i)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
644 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
645 --pQueue[i].field_4;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
646 if (pQueue[i].field_4==0)
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
647 pQueue[i].uActionLength=0;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
648 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
649 --field_10;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
650 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
651 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
652 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
653
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
654 //----- (0040652A) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
655 void stru262_TurnBased::_40652A()
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
656 {
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
657 int i;
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
658 int monster_ai_state;
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
659 Actor *monster; // eax@5
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
660
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
661 for (i=0; i<uActorQueueSize; ++i )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
662 {
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
663 if (pQueue[i].field_4 == 0)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
664 {
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
665 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
666 break;
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
667 monster=&pActors[PID_ID(pQueue[i].uPackedID)];
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
668 monster_ai_state=monster->uAIState;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
669 if (monster_ai_state == AIState::Standing ||
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
670 monster_ai_state == AIState::Fleeing ||
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
671 monster_ai_state == AIState::Fidgeting)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
672 {
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
673 pQueue[i].field_4 = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime;
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
674 if (monster->pActorBuffs[7].uExpireTime > 0)
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
675 pQueue[i].field_4*=2;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
676 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
677 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
678 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
679 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
680
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
681 //----- (004065B0) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
682 void stru262_TurnBased::_4065B0()
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
683 {
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
684 int i;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
685
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
686 SortTurnQueue();
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
687 if (pQueue[0].field_4 <= 0)
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
688 {
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
689 for (i=0; i<uActorQueueSize; ++i )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
690 {
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
691 if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)|| (pQueue[i].field_4 > 0) )
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
692 break;
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
693 if ((pQueue[i].uActionLength<=0) && (PID_TYPE(pQueue[i].uPackedID)==OBJECT_Actor))
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
694 _40680F(i);
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
695 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
696 }
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
697 else
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
698 {
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
699 _4063A1();
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
700 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
701 uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1;
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
702 else
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
703 uActiveCharacter = 0;
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
704 viewparams->bRedrawGameUI = 1;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
705 }
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
706
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
707 for (i=0; i<uActorQueueSize; ++i )
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
708 AIRangedAttacks(i);
1333
d14bc530cddb turnengine refactor continue
Gloval
parents: 1332
diff changeset
709 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
710
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
711 //----- (00406648) --------------------------------------------------------
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
712 void stru262_TurnBased::AIRangedAttacks( unsigned int queue_index )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
713 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
714 TurnBased_QueueElem *v1; // ecx@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
715 int v3; // eax@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
716 unsigned int v4; // ebx@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
717 Actor *v5; // esi@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
718 signed int v6; // edi@5
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
719 int v7; // ecx@6
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
720 int v8; // eax@6
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
721 int v9; // eax@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
722 int v10; // eax@8
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
723 int v11; // eax@9
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
724 int v12; // eax@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
725 int v13; // eax@11
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
726 int v14; // eax@14
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
727 unsigned int v15; // ecx@14
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
728 unsigned int v16; // edx@14
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
729 int v17; // eax@17
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
730 int v18; // eax@20
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
731 char v19; // al@24
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
732 unsigned int v21; // [sp-8h] [bp-50h]@16
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
733 int v22; // [sp-8h] [bp-50h]@17
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
734 AIDirection *v23; // [sp-4h] [bp-4Ch]@14
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
735 unsigned int v24; // [sp-4h] [bp-4Ch]@17
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
736 char v25; // [sp-4h] [bp-4Ch]@20
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
737 AIDirection a3; // [sp+Ch] [bp-3Ch]@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
738 AIDirection a4; // [sp+28h] [bp-20h]@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
739 TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
740 unsigned int a2a; // [sp+50h] [bp+8h]@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
741
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
742 v1 = &pQueue[queue_index];
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
743 v28 = v1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
744 v3 = v1->uPackedID;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
745 if (PID_TYPE(v1->uPackedID) != OBJECT_Player)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
746 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
747 v4 = PID_ID(v3);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
748 a2a = ai_near_actors_targets_pid[PID_ID(v3)];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
749 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
750 memcpy(&a4, &a3, sizeof(a4));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
751 v5 = &pActors[PID_ID(v3)];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
752 LOWORD(v3) = v5->uAIState;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
753 if (( (short)v3 != AIState::Dead )&& ( (short)v3 != AIState::Disabled )&&( (short)v3 != AIState::Removed ))
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
754 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
755 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
756 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
757 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
758 v7 = (signed __int16)v3;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
759 v8 = (signed __int16)v3 - 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
760 if ( !v8 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
761 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
762 v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4);
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
763 stru_50FE08.Add( v28->uPackedID, 5120,
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
764 v5->vPosition.x, v5->vPosition.y,
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
765 v5->vPosition.z + ((signed int)v5->uActorHeight >> 1),
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
766 v19, 1);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
767 Actor::AI_Stand(v4, a2a, 0,&a4);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
768 return;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
769 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
770 v9 = v8 - 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
771 if ( v9 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
772 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
773 v10 = v9 - 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
774 if ( !v10 )
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
775 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
776 v5->uCurrentActionTime = 0;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
777 v5->uCurrentActionLength = 0;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
778 v5->uAIState = Dead;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
779 pActors[v4].UpdateAnimation();
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
780 return;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
781 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
782 v11 = v10 - 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
783 if ( !v11 )
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
784 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
785 Actor::AI_Stand(v4, a2a, 0,&a4);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
786 return;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
787 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
788 v12 = v11 - 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
789 if ( v12 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
790 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
791 v13 = v12 - 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
792 if ( v13 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
793 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
794 if ( v13 != 5 )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
795 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
796 if ( v7 != 4 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
797 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
798 v14 = rand();
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
799 if ( !(v14 % 2) )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
800 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
801 Actor::AI_Bored(v4, a2a, &a4);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
802 return;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
803 }
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
804 Actor::AI_Stand(v4, a2a, 64,&a4);
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
805 return;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
806 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
807 v5->uCurrentActionTime = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
808 v5->uCurrentActionLength = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
809 v5->uAIState = Dead;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
810 pActors[v4].UpdateAnimation();
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
811 return;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
812 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
813 v24 = v5->pMonsterInfo.uSpellSkillAndMastery2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
814 v22 = 3;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
815 v17 = v5->pMonsterInfo.uSpell2ID;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
816 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
817 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
818 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
819 v24 = v5->pMonsterInfo.uSpellSkillAndMastery1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
820 v22 = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
821 v17 = v5->pMonsterInfo.uSpell1ID;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
822 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
823 Actor::AI_SpellAttack(v4, &a4, v17, v22, v24);
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
824 Actor::AI_Stand(v4, a2a, 0, &a4);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
825 return;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
826 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
827 v18 = v5->pMonsterInfo.uMissleAttack2Type;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
828 v25 = 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
829 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
830 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
831 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
832 v18 = v5->pMonsterInfo.uMissleAttack1Type;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
833 v25 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
834 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
835 Actor::AI_RangedAttack(v4, &a4, v18, v25);
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
836 Actor::AI_Stand(v4, a2a, 0,&a4);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
837 return;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
838 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
839 }
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
840
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
841 }
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
842
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
843 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
844 // 50FE08: using guessed type stru298 stru_50FE08;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
845
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
846 //----- (0040680F) --------------------------------------------------------
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
847 void stru262_TurnBased::_40680F( int a2 )
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
848 {
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
849 TurnBased_QueueElem *v2; // eax@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
850 unsigned int v3; // eax@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
851 unsigned int v4; // edi@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
852 Actor *v5; // ebx@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
853 unsigned int *v6; // esi@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
854 AIDirection *v7; // esi@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
855 int v8; // eax@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
856 unsigned int v9; // ecx@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
857 signed int v10; // eax@13
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
858 unsigned __int8 v11; // sf@19
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
859 unsigned __int8 v12; // of@19
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
860 int v13; // esi@29
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
861 bool v14; // eax@29
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
862 unsigned __int8 v15; // cl@33
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
863 AIDirection a3; // [sp+Ch] [bp-44h]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
864 AIDirection v18; // [sp+28h] [bp-28h]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
865 int a2a; // [sp+44h] [bp-Ch]@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
866 unsigned int v20; // [sp+48h] [bp-8h]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
867 TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
868 signed int v22; // [sp+58h] [bp+8h]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
869
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
870 v2 = &pQueue[a2];
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
871 v21 = v2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
872 v2->uActionLength = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
873 v3 = v2->uPackedID;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
874 if ( (unsigned __int8)v3 & 3 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
875 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
876 v3 = PID_ID(v3);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
877 v4 = v3;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
878 a2a = v3;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
879 v5 = &pActors[v3];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
880 LOWORD(v3) = v5->uAIState;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
881 if ( (short)v3 != 5 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
882 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
883 if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
884 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
885 v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
886 Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
887 if ( v5->pMonsterInfo.uHostilityType && !*v6 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
888 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
889 v22 = *v6;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
890 v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,(int)v4), *v6, &a3, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
891 v8 = v5->uActorRadius;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
892 memcpy(&a3, v7, sizeof(a3));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
893 memcpy(&v18, &a3, sizeof(v18));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
894 v9 = a3.uDistance - v8;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
895 v20 = a3.uDistance - v8;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
896 if ( ((a3.uDistance - v8) & 0x80000000u) != 0 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
897 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
898 v9 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
899 v20 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
900 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
901 if (PID_TYPE(v22) == OBJECT_Actor)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
902 //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
903 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
904 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
905 v10 = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
906 if ( v10 == 1 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
907 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
908 if ( (double)(signed int)v20 < 307.2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
909 goto LABEL_25;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
910 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
911 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
912 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
913 if ( v10 == 2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
914 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
915 v12 = __OFSUB__(v9, 1024);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
916 v11 = ((v9 - 1024) & 0x80000000u) != 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
917 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
918 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
919 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
920 if ( v10 == 3 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
921 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
922 v12 = __OFSUB__(v9, 2560);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
923 v11 = ((v9 - 2560) & 0x80000000u) != 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
924 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
925 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
926 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
927 if ( v10 != 4 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
928 goto LABEL_26;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
929 v12 = __OFSUB__(v9, 5120);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
930 v11 = ((v9 - 5120) & 0x80000000u) != 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
931 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
932 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
933 if ( v11 ^ v12 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
934 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
935 LABEL_25:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
936 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
937 goto LABEL_26;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
938 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
939 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
940 LABEL_26:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
941 if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
942 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
943 v13 = a2a;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
944 goto LABEL_47;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
945 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
946 v13 = a2a;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
947 v14 = stru_50C198.special_ability_use_check(v5, a2a);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
948 if ( v14 == 1 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
949 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
950 if ( v5->pMonsterInfo.uMissleAttack2Type )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
951 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
952 Actor::AI_MissileAttack2(v13, v22, &v18);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
953 goto LABEL_43;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
954 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
955 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
956 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
957 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
958 if ( v14 > 1 && v14 <= 3 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
959 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
960 if ( v14 == 2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
961 v15 = v5->pMonsterInfo.uSpell1ID;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
962 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
963 v15 = v5->pMonsterInfo.uSpell2ID;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
964 if ( v15 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
965 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
966 if ( v14 == 2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
967 Actor::AI_SpellAttack1(v13, v22, &v18);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
968 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
969 Actor::AI_SpellAttack2(v13, v22, &v18);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
970 goto LABEL_43;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
971 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
972 goto LABEL_44;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
973 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
974 if ( v5->pMonsterInfo.uMissleAttack1Type )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
975 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
976 Actor::AI_MissileAttack1(v13, v22, &v18);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
977 LABEL_43:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
978 //v3 = v21;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
979 v21->field_C = 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
980 LABEL_48:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
981 v21->uActionLength = v5->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
982 //return (signed __int16)v3;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
983 return;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
984 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
985 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
986 LABEL_44:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
987 if ( (double)(signed int)v20 < 307.2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
988 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
989 Actor::AI_MeleeAttack(v13, v22, &v18);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
990 //v3 = v21;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
991 v21->field_C = 3;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
992 goto LABEL_48;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
993 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
994 LABEL_47:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
995 Actor::AI_Stand(v13, v22, 0x40u, &v18);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
996 //v3 = v21;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
997 v21->field_C = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
998 goto LABEL_48;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
999 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1000 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1001 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1002 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1003
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1004 //----- (00406A63) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1005 void stru262_TurnBased::_406A63()
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1006 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1007
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1008 AIDirection a3; // [sp+8h] [bp-44h]@5
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1009 AIDirection v7; // [sp+24h] [bp-28h]@5
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1010 unsigned int target_pid; // [sp+40h] [bp-Ch]@5
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1011 int i;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1012
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1013 this->field_8 = 64;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1014 dword_50C994 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1015 uActiveCharacter = 0;
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1016 for (i=0; i<uActorQueueSize; ++i )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1017 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1018 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1019 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1020 target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)];
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1021 memcpy(&v7, Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &a3, 0), sizeof(AIDirection));
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1022 if ( !ActorTurn(i) )
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1023 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7);
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1024 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1025 }
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1026 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1027 // 50C994: using guessed type int dword_50C994;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1028
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1029 //----- (00406AFE) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1030 void stru262_TurnBased::_406AFE()
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1031 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1032 AIDirection a3; // [sp+4h] [bp-48h]@5
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1033 AIDirection v7; // [sp+20h] [bp-2Ch]@5
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1034 unsigned int target_pid;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1035 int i;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1036
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1037 for (i=0; i<uActorQueueSize; ++i )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1038 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1039 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1040 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1041 target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)];
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1042 memcpy(&v7, Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &a3, 0), sizeof(AIDirection));
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1043 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7);
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1044 pQueue[i].field_C = 0;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1045 pQueue[i].uActionLength = 0;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1046 }
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1047 }
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1048 turn_stage = 2;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1049 field_8 = 100;
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1050
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1051 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1052
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1053 //----- (00406B9F) --------------------------------------------------------
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1054 void stru262_TurnBased::_406B9F()
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1055 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1056 unsigned int v5; // esi@5
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1057 Actor *v6; // ebx@5
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1058 AIDirection a3; // [sp+0h] [bp-50h]@15
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1059 AIDirection v9; // [sp+1Ch] [bp-34h]@15
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1060 unsigned int v12; // [sp+40h] [bp-10h]@5
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1061 unsigned int v13; // [sp+44h] [bp-Ch]@8
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1062 int i;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1063
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1064 for (i=0; i<uActorQueueSize; ++i )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1065 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1066 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1067 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1068 v6 = &pActors[PID_ID(pQueue[i].uPackedID)];
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1069 if ( !(v6->pActorBuffs[5].uExpireTime > 0|| (v6->pActorBuffs[6].uExpireTime > 0) ||
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1070 v6->uAIState == AIState::Dead || v6->uAIState == AIState::Removed || v6->uAIState == AIState::Disabled) )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1071 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1072 v13 = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)];
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1073 memcpy(&v9, Actor::GetDirectionInfo(pQueue[i].uPackedID, v13, &a3, 0), sizeof(AIDirection));
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1074 if ( v6->uAIState == AIState::Pursuing || v6->uAIState == AIState::Tethered )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1075 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1076 if ( (double)(signed int)v9.uDistance < 307.2 )
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1077 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9);
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1078 }
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1079 else
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1080 {
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1081 v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1082 if ( v6->uCurrentActionTime > v6->uCurrentActionLength )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1083 {
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1084 if ( v6->uAIState == AIState::Dying )
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1085 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1086 v6->uCurrentActionTime = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1087 v6->uCurrentActionLength = 0;
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1088 v6->uAIState = AIState::Dead;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1089 v6->UpdateAnimation();
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1090 }
1342
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1091 if ( !ActorTurn(i) )
bdf0cc8620ad TE continue
Gloval
parents: 1341
diff changeset
1092 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9);
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1093 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1094 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1095 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1096 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1097 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1098 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1099
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1100 //----- (00406D10) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1101 bool stru262_TurnBased::ActorTurn(signed int a2)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1102 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1103 int v2; // ecx@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1104 //int v3; // ecx@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1105 Actor *actor; // ebx@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1106 //unsigned __int16 v5; // dx@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1107 int *v6; // esi@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1108 TurnBased_QueueElem *v7; // edi@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1109 int v8; // eax@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1110 AIDirection *v9; // esi@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1111 int v10; // eax@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1112 unsigned int v11; // ecx@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1113 unsigned __int8 pHostileType; // al@12
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1114 unsigned __int8 v13; // sf@16
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1115 unsigned __int8 v14; // of@16
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1116 unsigned int v15; // edx@22
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1117 unsigned int v16; // ecx@23
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1118 TurnBased_QueueElem *v17; // eax@25
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1119 double v18; // st7@33
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1120 double v19; // st6@33
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1121 AIDirection a3; // [sp+Ch] [bp-48h]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1122 AIDirection pDir; // [sp+28h] [bp-2Ch]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1123 int v27; // [sp+44h] [bp-10h]@33
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1124 unsigned int v28; // [sp+48h] [bp-Ch]@10
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1125 TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1126 unsigned int uActorID; // [sp+50h] [bp-4h]@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1127 unsigned int a2a; // [sp+5Ch] [bp+8h]@7
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1128
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1129 // __debugbreak();//ñðàáàòûâàåò ïðè ïîøàãîâîì ðåæèìå ïîñëå ïÿòè øàãîâ
1341
67e47fc3133d TE refactiring continue
Gloval
parents: 1340
diff changeset
1130 v2 = pQueue[a2].uPackedID;
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1131 if (PID_TYPE(v2) == OBJECT_Player)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1132 return 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1133 uActorID = PID_ID(v2);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1134 //uActorID = v3;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1135 actor = &pActors[uActorID];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1136 //v5 = v4->uAIState;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1137 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
1138 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1139 v6 = &ai_near_actors_targets_pid[uActorID];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1140 v7 = &pTurnEngine->pQueue[a2];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1141 v8 = *v6;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1142 v29 = &pTurnEngine->pQueue[a2];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1143 a2a = v8;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1144 Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1145 if ( actor->pMonsterInfo.uHostilityType && !*v6 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1146 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1147 v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1148 v10 = actor->uActorRadius;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1149 memcpy(&a3, v9, sizeof(a3));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1150 memcpy(&pDir, &a3, sizeof(pDir));
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1151 v11 = a3.uDistance - v10;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1152 v28 = a3.uDistance - v10;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1153 if ( ((a3.uDistance - v10) & 0x80000000u) != 0 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1154 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1155 v11 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1156 v28 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1157 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1158 pHostileType = actor->pMonsterInfo.uHostilityType;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1159 if ( pHostileType == 1 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1160 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1161 if ( (double)(signed int)v28 >= 307.2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1162 goto LABEL_21;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1163 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1164 goto LABEL_21;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1165 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1166 if ( pHostileType == 2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1167 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1168 v14 = __OFSUB__(v11, 1024);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1169 v13 = ((v11 - 1024) & 0x80000000u) != 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1170 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1171 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1172 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1173 if ( pHostileType != 3 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1174 goto LABEL_21;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1175 v14 = __OFSUB__(v11, 2560);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1176 v13 = ((v11 - 2560) & 0x80000000u) != 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1177 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1178 if ( v13 ^ v14 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1179 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1180 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1181 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1182 LABEL_21:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1183 if ( (signed __int64)actor->pActorBuffs[4].uExpireTime > 0 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1184 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1185 if ( (signed int)v11 < 10240 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1186 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1187 Actor::AI_Flee(uActorID, a2a, 0, &pDir);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1188 v29->field_C = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1189 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1190 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1191 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1192 Actor::AI_4032B2(uActorID, a2a, 1024, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1193 v29->field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1194 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1195 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1196 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1197 if ( actor->pMonsterInfo.uHostilityType != 4 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1198 goto LABEL_46;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1199 if ( !(actor->uAttributes & 0x020000) || actor->pMonsterInfo.uAIType == 1 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1200 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1201 if ( actor->pMonsterInfo.uAIType == 1 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1202 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1203 if ( actor->pMonsterInfo.uMovementType == 5 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1204 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1205 Actor::AI_Stand(uActorID, a2a, 32, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1206 v29->field_C = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1207 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1208 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1209 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1210 Actor::AI_Flee(uActorID, a2a, 32, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1211 v29->field_C = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1212 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1213 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1214 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1215 if ( actor->pMonsterInfo.uAIType == 2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1216 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1217 v27 = actor->sCurrentHP;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1218 v18 = (double)v27;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1219 v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1220 if ( v19 > v18 && (signed int)v11 < 10240 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1221 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1222 if ( actor->pMonsterInfo.uMovementType == 5 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1223 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1224 Actor::AI_Stand(uActorID, a2a, 32, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1225 v29->field_C = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1226 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1227 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1228 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1229 Actor::AI_Flee(uActorID, a2a, 32, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1230 v29->field_C = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1231 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1232 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1233 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1234 goto LABEL_39;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1235 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1236 if ( actor->pMonsterInfo.uAIType == 3 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1237 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1238 v27 = actor->sCurrentHP;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1239 v18 = (double)v27;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1240 v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1241 if ( v19 > v18 && (signed int)v11 < 10240 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1242 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1243 if ( actor->pMonsterInfo.uMovementType == 5 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1244 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1245 Actor::AI_Stand(uActorID, a2a, 32, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1246 v29->field_C = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1247 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1248 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1249 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1250 Actor::AI_Flee(uActorID, a2a, 32, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1251 v29->field_C = 4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1252 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1253 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1254 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1255 goto LABEL_39;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1256 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1257 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1258 LABEL_39:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1259 if ( (double)(signed int)v28 < 307.2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1260 return 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1261 if ( (signed int)v11 < 5120 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1262 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1263 if ( actor->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1264 Actor::AI_Pursue1(uActorID, a2a, uActorID, 32, &pDir);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1265 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1266 Actor::AI_Pursue2(uActorID, a2a, 32, &pDir, 307);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1267 v29->field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1268 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1269 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1270 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1271 LABEL_46:
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1272 if ( actor->pMonsterInfo.uMovementType == 0 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1273 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1274 Actor::AI_4032B2(uActorID, a2a, 1024, 32);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1275 v29->field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1276 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1277 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1278 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1279 if ( actor->pMonsterInfo.uMovementType == 1 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1280 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1281 Actor::AI_4032B2(uActorID, a2a, 2560, 32);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1282 v29->field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1283 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1284 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1285 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1286 if ( actor->pMonsterInfo.uMovementType == 2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1287 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1288 Actor::AI_4032B2(uActorID, a2a, 5120, 32);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1289 v29->field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1290 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1291 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1292 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1293 if ( actor->pMonsterInfo.uMovementType == 4 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1294 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1295 Actor::AI_4032B2(uActorID, a2a, 10240, 32);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1296 v29->field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1297 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1298 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1299 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1300 if ( actor->pMonsterInfo.uMovementType == 5 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1301 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1302 Actor::AI_Stand(uActorID, a2a, 32, 0);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1303 v29->field_C = 2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1304 v29->uActionLength = actor->uCurrentActionLength;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1305 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1306 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1307 return 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1308 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1309
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1310 //----- (00406FA8) --------------------------------------------------------
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1311 void stru262_TurnBased::_406FA8()
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1312 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1313 unsigned __int8 v1; // zf@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1314 unsigned __int8 v2; // sf@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1315 TurnBased_QueueElem *v3; // edi@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1316 int v4; // eax@4
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1317 Actor *v5; // ebx@4
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1318 unsigned __int16 v6; // cx@4
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1319 unsigned int *v7; // edx@8
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1320 unsigned int v8; // esi@8
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1321 unsigned __int8 v9; // of@13
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1322 AIDirection a3; // [sp+Ch] [bp-6Ch]@8
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1323 AIDirection v11; // [sp+28h] [bp-50h]@8
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1324 AIDirection a4; // [sp+44h] [bp-34h]@8
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1325 stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1326 TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1327 int uActorID; // [sp+68h] [bp-10h]@4
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1328 unsigned int a2; // [sp+6Ch] [bp-Ch]@8
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1329 int v17; // [sp+70h] [bp-8h]@1
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1330 unsigned int v18; // [sp+74h] [bp-4h]@2
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1331
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1332 v17 = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1333 v1 = this->uActorQueueSize == 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1334 v2 = this->uActorQueueSize < 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1335 v13 = this;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1336 if ( !(v2 | v1) )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1337 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1338 v3 = this->pQueue;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1339 v18 = (char *)&pTurnEngine - (char *)this;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1340 v14 = this->pQueue;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1341 do
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1342 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1343 if (PID_TYPE(v3->uPackedID) != OBJECT_Player)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1344 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1345 v4 = PID_ID(v3->uPackedID);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1346 uActorID = v4;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1347 v5 = &pActors[v4];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1348 v6 = v5->uAIState;
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1349 if ( v6 != 5 ) // Dead
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1350 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1351 if ( v6 != 11 )// Removed
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1352 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1353 if ( v6 != 19 ) //Disabled
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1354 {
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1355 if ( v6 != 17 ) //Summoned
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1356 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1357 v7 = (unsigned int *)&ai_near_actors_targets_pid[v4];
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1358 a2 = *v7;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1359 v8 = a2;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1360 Actor::_SelectTarget(v4, (int *)v7, true);
1340
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1361 memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(AIDirection));
22cb507446a4 turnengine refactoring continue
Gloval
parents: 1333
diff changeset
1362 memcpy(&a4, &v11, sizeof(AIDirection));
1332
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1363 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1364 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1365 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1366 if (v5->uAIState == Dying)
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1367 {
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1368 v5->uCurrentActionTime = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1369 v5->uCurrentActionLength = 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1370 v5->uAIState = Dead;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1371 v5->UpdateAnimation();
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1372 return;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1373 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1374 if ( rand() % 2 )
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1375 Actor::AI_Stand(uActorID, a2, 64, &a4);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1376 else
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1377 Actor::AI_Bored(uActorID, a2, &a4);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1378 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1379 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1380 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1381 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1382 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1383 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1384 ++v17;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1385 v3 = v14 + 1;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1386 v9 = __OFSUB__(v17, v13->uActorQueueSize);
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1387 v2 = v17 - v13->uActorQueueSize < 0;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1388 ++v14;
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1389 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1390 while ( v2 ^ v9 );
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1391 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1392 }
1e35cfed7928 turn engine file added
Gloval
parents:
diff changeset
1393