annotate Engine/TurnEngine/TurnEngine.cpp @ 2534:1bcadc6dd203

enum SOUND_
author Ritor1
date Mon, 09 Feb 2015 19:17:12 +0600
parents a77c34acdbc9
children a902abdfc7f2
rev   line source
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2 #include <stdlib.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
3 #include <crtdbg.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
8 #include "../MM7.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
9 #include "../mm7_data.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
10 #include "Engine/Objects/Actor.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
11 #include "../Party.h"
2502
a77c34acdbc9 Media folder
Ritor1
parents: 2499
diff changeset
12 #include "Media/Audio/AudioPlayer.h"
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
13 #include "Engine/Objects/SpriteObject.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
14 #include "../Timer.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
15 #include "../stru298.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
16 #include "Engine/Tables/IconFrameTable.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
17 #include "Engine/Graphics/Viewport.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
18 #include "Engine/Tables/FactionTable.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
19
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
20 #include "TurnEngine.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
23 #include "../Game.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
24 struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
25
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
26
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
27 //----- (00404544) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
28 void stru262_TurnBased::SortTurnQueue()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
29 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
30 int active_actors;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
31 TurnBased_QueueElem *current_top; // eax@16
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
32 TurnBased_QueueElem *test_element; // ecx@18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
33 TurnBased_QueueElem temp_elem;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
34 int i,j;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
35 unsigned int p_type;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
36 unsigned int p_id;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
37
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
38 active_actors = this->uActorQueueSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
39 //set non active actors in queue initiative that not allow them to paticipate
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
40 for( i = 0; i < uActorQueueSize; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
41 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
42 p_type = PID_TYPE(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
43 p_id = PID_ID(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
44
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
45 if ( p_type == OBJECT_Actor )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
46 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
47 pActors[p_id].uAttributes |= ACTOR_STAND_IN_QUEUE;//0x80
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
48 if ( !pActors[p_id].CanAct() )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
49 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
50 --active_actors;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
51 pQueue[i].actor_initiative = 1001;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
52 pActors[p_id].ResetQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
53 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
54 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
55 else if ( p_type == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
56 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
57 if ( !pParty->pPlayers[p_id].CanAct() )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
58 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
59 --active_actors;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
60 pQueue[i].actor_initiative = 1001;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
61 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
62 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
63 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
64 //sort
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
65 if (uActorQueueSize > 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
66 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
67 for( i = 0; i < uActorQueueSize-1; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
68 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
69 current_top=&pQueue[i];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
70 for ( j = i+1; j < uActorQueueSize; ++j )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
71 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
72 test_element=&pQueue[j];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
73 if ( test_element->actor_initiative < current_top->actor_initiative || // if less initiative -> top
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
74 ((test_element->actor_initiative == current_top->actor_initiative) &&
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
75 (((PID_TYPE(test_element->uPackedID) == OBJECT_Player) && (PID_TYPE(current_top->uPackedID) == OBJECT_Actor)) || //player preferable
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
76 ((PID_TYPE(test_element->uPackedID) == PID_TYPE(current_top->uPackedID)) && (PID_ID(test_element->uPackedID) < PID_ID(current_top->uPackedID)))))) //less id preferable
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
77 { //swap
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
78 memcpy(&temp_elem,current_top,sizeof(TurnBased_QueueElem));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
79 memcpy(current_top,test_element, sizeof(TurnBased_QueueElem));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
80 memcpy(test_element, &temp_elem, sizeof(TurnBased_QueueElem));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
81 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
82 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
83 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
84 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
85 uActorQueueSize = active_actors;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
86 if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) //we have player at queue top
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
87 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
88 uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
89 field_18 |= TE_PLAYER_TURN;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
90 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
91 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
92 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
93 uActiveCharacter = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
94 field_18 &= ~TE_PLAYER_TURN;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
95 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
96 for ( i = 0; i < uActorQueueSize; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
97 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
98 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) //set recovery times
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
99 pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (unsigned __int16)((double)pQueue[i].actor_initiative * 0.46875);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
100 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
101 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
102 //----- (0040471C) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
103 void stru262_TurnBased::ApplyPlayerAction()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
104 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
105 if ( pParty->bTurnBasedModeOn == 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
106 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
107 if ( pTurnEngine->turn_stage == TE_ATTACK )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
108 _406457(0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
109 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
110 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
111
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
112 //----- (004059DB) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
113 void stru262_TurnBased::Start()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
114 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
115 int v17; // edx@22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
116 AIDirection v30; // [sp+Ch] [bp-68h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
117 AIDirection v31; // [sp+28h] [bp-4Ch]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
118 AIDirection a3; // [sp+44h] [bp-30h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
119 int activ_players[4];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
120 int players_recovery_time[4];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
121 int a_players_count;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
122 int i,j;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
123 int temp;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
124
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
125 pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
126 pEventTimer->TrackGameTime();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
127 pAudioPlayer->StopChannels(-1, -1);
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2502
diff changeset
128 pAudioPlayer->PlaySound(SOUND_batllest, 0, 0, -1, 0, 0, 0, 0);
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
129 //pPlayer = pParty->pPlayers.data();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
130 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
131 dword_50C994 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
132
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
133 this->turn_initiative = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
134 this->turns_count = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
135 this->ai_turn_timer = 64;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
136 this->turn_stage = TE_WAIT;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
137 this->uActorQueueSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
138
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
139 for ( uint pl_id = 0; pl_id < 4 ; ++pl_id )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
140 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
141 if ( pParty->pPlayers[pl_id].CanAct() )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
142 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
143 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,pl_id);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
144 this->pQueue[this->uActorQueueSize].AI_action_type = TE_AI_PURSUE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
145 this->pQueue[this->uActorQueueSize].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
146 pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
147 ++this->uActorQueueSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
148 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
149 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
150
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
151 for ( int i = 0; i < ai_arrays_size ; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
152 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
153 if (ai_near_actors_ids[i] == 10)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
154 continue;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
155 if ( pActors[ai_near_actors_ids[i]].CanAct() )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
156 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
157 if ( pActors[ai_near_actors_ids[i]].ActorNearby() )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
158 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
159 pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_STAND_IN_QUEUE;//0x80
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
160 Actor::GetDirectionInfo(PID(OBJECT_Actor,ai_near_actors_ids[i]), ai_near_actors_targets_pid[ai_near_actors_ids[i]], &v31, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
161 memcpy(&v30, &v31, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
162 Actor::AI_StandOrBored(ai_near_actors_ids[i], 4, 32, &v30);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
163 this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[i]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
164 this->pQueue[this->uActorQueueSize].AI_action_type = TE_AI_PURSUE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
165 this->pQueue[this->uActorQueueSize].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
166 ++this->uActorQueueSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
167 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
168 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
169 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
170
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
171 a_players_count = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
172 for ( int k = 0; k < this->uActorQueueSize; ++k )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
173 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
174 //set initial initiative for turn actors
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
175 if ( PID_TYPE(this->pQueue[k].uPackedID) == OBJECT_Player )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
176 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
177 if ( pPlayers[PID_ID(this->pQueue[k].uPackedID) + 1]->uTimeToRecovery != 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
178 this->pQueue[k].actor_initiative = (signed int)((double)pPlayers[PID_ID(this->pQueue[k].uPackedID) + 1]->uTimeToRecovery * 0.46875);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
179 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
180 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
181 activ_players[a_players_count] = k;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
182 ++a_players_count;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
183 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
184 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
185 else if ( PID_TYPE(this->pQueue[k].uPackedID) == OBJECT_Actor )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
186 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
187 v17 = rand() % 99;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
188 if ( v17 < 33 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
189 this->pQueue[k].actor_initiative = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
190 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
191 this->pQueue[k].actor_initiative= (v17 >= 66)? 5 : 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
192 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
193 else //fot non player and actor
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
194 this->pQueue[k].actor_initiative = 666;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
195 this->pQueue[k].actor_initiative += 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
196 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
197
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
198 if ( a_players_count > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
199 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
200 for ( i = 0; i < a_players_count; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
201 players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
202 //sort players by recovery time
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
203 for ( i = 0; i < a_players_count-1; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
204 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
205 for ( j = i + 1; j < a_players_count; ++j )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
206 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
207 if (players_recovery_time[j] < players_recovery_time[i]) //swap values
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
208 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
209 temp = players_recovery_time[i];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
210 players_recovery_time[i] = players_recovery_time[j];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
211 players_recovery_time[j] = temp;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
212 temp = activ_players[i];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
213 activ_players[i] = activ_players[j];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
214 activ_players[j] = temp;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
215 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
216 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
217 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
218 for ( i = 0; i < a_players_count; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
219 this->pQueue[activ_players[i]].actor_initiative = i + 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
220 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
221 this->SortTurnQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
222 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
223
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
224 //----- (00405CFF) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
225 void stru262_TurnBased::End(bool bPlaySound)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
226 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
227 ObjectType objType; // eax@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
228 int objID; // esi@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
229 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
230
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
231 this->turn_stage = TE_NONE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
232 for( i = 0; i < uActorQueueSize; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
233 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
234 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
235 pActors[PID_ID(pQueue[i].uPackedID)].ResetQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
236 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
237
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
238 for( uint i = 0; i < uNumSpriteObjects; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
239 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
240 if (pSpriteObjects[i].uAttributes & 4)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
241 pSpriteObjects[i].uAttributes &= ~0x04;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
242 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
243
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
244 for( i = 0; i < uActorQueueSize; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
245 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
246 objType = (ObjectType)PID_TYPE(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
247 objID = PID_ID(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
248 if ( objType == OBJECT_Player )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
249 pPlayers[objID + 1]->uTimeToRecovery = (unsigned __int16)((double)pQueue[i].actor_initiative * 2.133333333333333);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
250 else if ( objType == OBJECT_Actor )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
251 pActors[objID].pMonsterInfo.uRecoveryTime = (unsigned __int16)((double)pQueue[i].actor_initiative * 2.133333333333333);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
252 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
253 pAudioPlayer->StopChannels(-1, -1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
254 if ( bPlaySound != 0 )
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2502
diff changeset
255 pAudioPlayer->PlaySound(SOUND_batlleen, 0, 0, -1, 0, 0, 0, 0);
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
256 pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
257 pEventTimer->StopGameTime();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
258 dword_50C994 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
259 dword_50C998_turnbased_icon_1A = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
260 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
261 // 50C994: using guessed type int dword_50C994;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
262 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
263
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
264 //----- (00405E14) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
265 void stru262_TurnBased::AITurnBasedAction()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
266 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
267 AIDirection v6; // esi@21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
268 AIDirection a3; // [sp+4h] [bp-68h]@21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
269 AIDirection v14; // [sp+20h] [bp-4Ch]@21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
270 AIDirection v15; // [sp+3Ch] [bp-30h]@21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
271 Actor *curr_actor; // [sp+58h] [bp-14h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
272 int target_pid; // [sp+5Ch] [bp-10h]@6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
273 int shrinked;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
274 int j;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
275
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
276 for (uint i = 0; i < uNumActors; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
277 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
278 curr_actor=&pActors[i];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
279 shrinked=pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
280 for (j = 0; j < 22; ++j) //check expired spell Buffs
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
281 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
282 if (j != 10)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
283 pActors[i].pActorBuffs[j].IsBuffExpiredToTime(pParty->uTimePlayed);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
284 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
285 if (shrinked && pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime <= 0) //buff 3 expired
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
286 pActors[i].uActorHeight = pMonsterList->pMonsters[pActors[i].pMonsterInfo.uID - 1].uMonsterHeight;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
287 if (!(curr_actor->uAttributes & 0x80) && (!curr_actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) &&
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
288 (!curr_actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
289 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
290 curr_actor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
291 if (curr_actor->uCurrentActionTime>=curr_actor->uCurrentActionLength)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
292 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
293 target_pid = ai_near_actors_targets_pid[i];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
294 Actor::GetDirectionInfo(PID(OBJECT_Actor,i), target_pid, &v6, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
295 memcpy(&v15, &v6, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
296 memcpy(&v14, &v15, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
297 if ( curr_actor->uAIState == Dying )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
298 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
299 curr_actor->uCurrentActionTime = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
300 curr_actor->uCurrentActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
301 curr_actor->uAIState = Dead;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
302 curr_actor->UpdateAnimation();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
303 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
304 else if ( (curr_actor->uAIState > Removed) && (curr_actor->uAIState < Disabled))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
305 Actor::AI_StandOrBored(i, target_pid, 32, &v14);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
306 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
307 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
308 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
309 if ( turn_stage == TE_WAIT )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
310 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
311 if ( ai_turn_timer == 64 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
312 ActorAISetMovementDecision();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
313 else if ( ai_turn_timer > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
314 ActorAIDoAdditionalMove();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
315 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
316 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
317 ActorAIStopMovement();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
318 turn_initiative = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
319 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
320 ai_turn_timer -= pEventTimer->uTimeElapsed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
321 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
322 else if ( turn_stage == TE_ATTACK )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
323 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
324 if ( !(field_18 &TE_FLAG_1))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
325 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
326 if ( turn_initiative == 100 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
327 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
328 StartTurn();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
329 SetAIRecoveryTimes();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
330 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
331 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
332 if ( turn_initiative > 0 || pQueue[0].actor_initiative <= 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
333 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
334 _4065B0();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
335 SetAIRecoveryTimes();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
336 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
337 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
338 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
339 NextTurn();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
340 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
341 else if ( turn_stage == TE_MOVEMENT )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
342 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
343 if ( (uActionPointsLeft > 0) && (!(field_18 & TE_FLAG_8)) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
344 ActorAIChooseNewTargets();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
345 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
346 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
347 field_18 &= ~TE_FLAG_8;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
348 turn_stage = TE_WAIT;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
349 ai_turn_timer = 64;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
350 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
351 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
352 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
353
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
354
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
355 //----- (00406051) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
356 void stru262_TurnBased::StartTurn()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
357 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
358 int player_num, actor_num, i, j;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
359
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
360 pending_actions = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
361 //add player to queue if he can act
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
362 for ( player_num = 0; player_num < 4; ++player_num)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
363 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
364 for ( j = 0; j < uActorQueueSize; ++j )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
365 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
366 if (PID_TYPE(pQueue[j].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
367 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
368 if (pPlayers[PID_ID(pQueue[j].uPackedID) + 1]->CanAct() && (player_num != PID_ID(pQueue[j].uPackedID)) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
369 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
370 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
371 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
372 if ( j == uActorQueueSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
373 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
374 pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Player,player_num);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
375 pQueue[uActorQueueSize].actor_initiative = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
376 pQueue[uActorQueueSize].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
377 pQueue[uActorQueueSize].AI_action_type = TE_AI_STAND;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
378 ++uActorQueueSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
379 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
380 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
381 //add new arrived actors
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
382 for ( actor_num = 0; actor_num < ai_arrays_size; ++actor_num )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
383 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
384 for ( j = 0; j < uActorQueueSize; ++j )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
385 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
386 if ((PID_TYPE(pQueue[j].uPackedID)== OBJECT_Actor)&&
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
387 ai_near_actors_ids[actor_num] == PID_ID(pQueue[j].uPackedID))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
388 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
389 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
390 if ( j == uActorQueueSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
391 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
392 pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[actor_num]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
393 pQueue[uActorQueueSize].actor_initiative = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
394 pQueue[uActorQueueSize].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
395 pQueue[uActorQueueSize].AI_action_type = TE_AI_STAND;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
396 ++uActorQueueSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
397 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
398 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
399 ++turns_count;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
400 turn_initiative = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
401 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
402 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
403 if (pQueue[i].actor_initiative == 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
404 pQueue[i].actor_initiative = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
405 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
406 StepTurnQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
407 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
408 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
409 if ((PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) || (pQueue[i].actor_initiative > 0))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
410 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
411 AI_Action_(i);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
412 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
413 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
414 // 4F75D8: using guessed type int ai_arrays_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
415
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
416 //----- (004061CA) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
417 void stru262_TurnBased::NextTurn()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
418 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
419 int v13; // [sp+10h] [bp-4h]@7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
420 int monster_id; // eax@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
421
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
422 SortTurnQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
423 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
424 uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
425 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
426 uActiveCharacter = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
427 viewparams->bRedrawGameUI = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
428
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
429 if ( pending_actions )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
430 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
431 pTurnEngine->field_18 |= TE_HAVE_PENDING_ACTIONS;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
432 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
433 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
434 pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
435 if ( pQueue[0].actor_initiative <= 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
436 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
437
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
438 v13 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
439 if (uActorQueueSize > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
440 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
441 for ( int i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
442 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
443 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
444 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
445 monster_id = PID_ID(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
446 if ( (pActors[monster_id].uAIState == Dying) || (pActors[monster_id].uAIState == Stunned)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
447 || (pActors[monster_id].uAIState == AttackingMelee) || (pActors[monster_id].uAIState == AttackingRanged1)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
448 || (pActors[monster_id].uAIState == AttackingRanged2) || (pActors[monster_id].uAIState == AttackingRanged3)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
449 || (pActors[monster_id].uAIState == AttackingRanged4) || (pActors[monster_id].uAIState == Summoned))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
450 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
451 pActors[monster_id].uCurrentActionTime += pEventTimer->uTimeElapsed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
452 if ( pActors[monster_id].uCurrentActionTime < pActors[monster_id].uCurrentActionLength )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
453 v13 = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
454 else if ( pActors[monster_id].uAIState == Dying )// Dying
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
455 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
456 pActors[monster_id].uAIState = Dead;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
457 pActors[monster_id].uCurrentActionTime = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
458 pActors[monster_id].uCurrentActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
459 pActors[monster_id].UpdateAnimation();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
460 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
461 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
462 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
463 if ( pActors[monster_id].uAIState == Stunned ) //Stunned
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
464 Actor::AI_StandOrBored(monster_id, ai_near_actors_targets_pid[monster_id], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
465 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
466 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
467 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
468 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
469 if ( v13 != 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
470 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
471 field_18 |= TE_FLAG_1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
472 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
473 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
474 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
475
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
476 field_18 &= ~TE_FLAG_1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
477 //set all actors to stay
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
478 for ( int i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
479 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
480 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
481 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
482 monster_id = PID_ID(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
483 if ((pActors[monster_id].uAIState != Dead) && (pActors[monster_id].uAIState != Dying) &&
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
484 (pActors[monster_id].uAIState != Removed) && (pActors[monster_id].uAIState != Summoned) &&
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
485 (pActors[monster_id].uAIState != Disabled))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
486 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
487 pQueue[i].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
488 Actor::AI_StandOrBored(monster_id, ai_near_actors_targets_pid[monster_id], 32, nullptr);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
489 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
490 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
491 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
492 // turn tick
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
493 turn_stage = TE_MOVEMENT;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
494 pParty->uTimePlayed += 213i64;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
495 _494035_timed_effects__water_walking_damage__etc();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
496 uActionPointsLeft = 130;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
497 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
498
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
499 //----- (004063A1) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
500 bool stru262_TurnBased::StepTurnQueue()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
501 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
502 int v9; // dx@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
503 int j;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
504
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
505 SortTurnQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
506 viewparams->bRedrawGameUI = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
507 if ( pQueue[0].actor_initiative != 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
508 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
509 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
510 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
511 do
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
512 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
513 for (j = 0; j < uActorQueueSize; ++j )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
514 --pQueue[j].actor_initiative;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
515 --turn_initiative;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
516 if (turn_initiative == 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
517 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
518 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
519 while (pQueue[0].actor_initiative != 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
520 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
521 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
522 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
523 if ( pQueue[0].actor_initiative > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
524 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
525 v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
526 if (!(v9 == Dying || v9 == Dead ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
527 v9 == Disabled || v9 == Removed))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
528 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
529 do
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
530 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
531 for ( j = 0; j < uActorQueueSize; ++j )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
532 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
533 --pQueue[j].actor_initiative;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
534 if (pQueue[j].actor_initiative == 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
535 pQueue[j].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
536 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
537 --turn_initiative;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
538 if (turn_initiative == 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
539 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
540 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
541 while (pQueue[0].actor_initiative > 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
542 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
543 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
544 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
545 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
546 return false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
547 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
548
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
549 //----- (00406457) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
550 void stru262_TurnBased::_406457( int a2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
551 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
552 signed int v4; // ecx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
553 signed int v6; // eax@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
554 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
555 v6 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
556 if ( PID_TYPE(pQueue[a2].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
557 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
558 v4 = PID_ID(pQueue[a2].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
559 if ( pParty->pTurnBasedPlayerRecoveryTimes[v4] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
560 pParty->pTurnBasedPlayerRecoveryTimes[v4] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
561 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
562 v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
563 if ( v6 < 30 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
564 v6 = 30;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
565 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
566 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
567 v6 = pMonsterStats->pInfos[pActors[PID_ID(pQueue[a2].uPackedID)].pMonsterInfo.uID].uRecoveryTime;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
568
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
569 pQueue[a2].actor_initiative = v6;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
570 SortTurnQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
571 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
572 uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
573 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
574 uActiveCharacter = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
575 viewparams->bRedrawGameUI = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
576 while ( (pQueue[0].actor_initiative > 0) && (turn_initiative > 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
577 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
578 for ( i = 0; i < uActorQueueSize; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
579 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
580 --pQueue[i].actor_initiative;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
581 if (pQueue[i].actor_initiative == 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
582 pQueue[i].uActionLength=0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
583 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
584 --turn_initiative;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
585 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
586 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
587
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
588 //----- (0040652A) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
589 void stru262_TurnBased::SetAIRecoveryTimes()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
590 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
591 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
592 int monster_ai_state;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
593 Actor *monster; // eax@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
594
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
595 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
596 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
597 if (pQueue[i].actor_initiative == 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
598 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
599 if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
600 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
601 monster=&pActors[PID_ID(pQueue[i].uPackedID)];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
602 monster_ai_state=monster->uAIState;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
603 if (monster_ai_state == Standing ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
604 monster_ai_state == Fleeing ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
605 monster_ai_state == Fidgeting)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
606 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
607 pQueue[i].actor_initiative = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
608 if (monster->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
609 pQueue[i].actor_initiative*=2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
610 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
611 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
612 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
613 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
614
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
615 //----- (004065B0) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
616 void stru262_TurnBased::_4065B0()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
617 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
618 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
619
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
620 SortTurnQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
621 if (pQueue[0].actor_initiative <= 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
622 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
623 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
624 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
625 if ((PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)|| (pQueue[i].actor_initiative > 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
626 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
627 if ((pQueue[i].uActionLength <= 0) && (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
628 AI_Action_(i);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
629 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
630 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
631 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
632 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
633 StepTurnQueue();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
634 if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
635 uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
636 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
637 uActiveCharacter = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
638 viewparams->bRedrawGameUI = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
639 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
640 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
641 AIAttacks(i);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
642 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
643
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
644 //----- (00406648) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
645 void stru262_TurnBased::AIAttacks( unsigned int queue_index )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
646 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
647 //TurnBased_QueueElem *v1; // ecx@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
648 //int v3; // eax@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
649 unsigned int actor_id; // ebx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
650 //Actor *v5; // esi@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
651 char v19; // al@24
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
652 AIDirection a3; // [sp+Ch] [bp-3Ch]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
653 AIDirection a4; // [sp+28h] [bp-20h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
654 //TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
655 //unsigned int a2a; // [sp+50h] [bp+8h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
656
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
657 //v1 = &pQueue[queue_index];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
658 //v28 = v1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
659 //v3 = pQueue[queue_index].uPackedID;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
660 if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
661 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
662 actor_id = PID_ID(pQueue[queue_index].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
663 //a2a = ai_near_actors_targets_pid[v4];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
664 Actor::GetDirectionInfo(pQueue[queue_index].uPackedID, ai_near_actors_targets_pid[actor_id], &a3, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
665 memcpy(&a4, &a3, sizeof(a4));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
666 //v5 = &pActors[v4];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
667 //LOWORD(v3) = v5->uAIState;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
668 if (( pActors[actor_id].uAIState != Dead ) && ( pActors[actor_id].uAIState != Disabled )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
669 &&( pActors[actor_id].uAIState != Removed ))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
670 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
671 pActors[actor_id].uCurrentActionTime += pEventTimer->uTimeElapsed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
672 if ( (signed int)pActors[actor_id].uCurrentActionTime >= pActors[actor_id].uCurrentActionLength )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
673 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
674 switch (pActors[actor_id].uAIState)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
675 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
676 case AttackingMelee:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
677 v19 = pActors[actor_id].special_ability_use_check(actor_id);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
678 AttackerInfo.Add( pQueue[queue_index].uPackedID, 5120, pActors[actor_id].vPosition.x, pActors[actor_id].vPosition.y,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
679 pActors[actor_id].vPosition.z + ((signed int)pActors[actor_id].uActorHeight >> 1), v19, 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
680 Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
681 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
682 case AttackingRanged1:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
683 Actor::AI_RangedAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uMissleAttack1Type, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
684 Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
685 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
686 case Dying:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
687 pActors[actor_id].uCurrentActionTime = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
688 pActors[actor_id].uCurrentActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
689 pActors[actor_id].uAIState = Dead;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
690 pActors[actor_id].UpdateAnimation();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
691 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
692 case Stunned:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
693 Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
694 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
695 case AttackingRanged2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
696 Actor::AI_RangedAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uMissleAttack2Type, 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
697 Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
698 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
699 case AttackingRanged3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
700 Actor::AI_SpellAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uSpell1ID, 2, pActors[actor_id].pMonsterInfo.uSpellSkillAndMastery1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
701 Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
702 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
703 case AttackingRanged4:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
704 Actor::AI_SpellAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uSpell2ID, 3, pActors[actor_id].pMonsterInfo.uSpellSkillAndMastery2);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
705 Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
706 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
707 default:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
708 if ( !(rand() % 2) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
709 Actor::AI_Bored(actor_id, ai_near_actors_targets_pid[actor_id], &a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
710 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
711 Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 64,&a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
712 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
713 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
714 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
715 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
716 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
717 // 50FE08: using guessed type stru298 AttackerInfo;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
718
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
719 //----- (0040680F) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
720 void stru262_TurnBased::AI_Action_( int queue_index )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
721 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
722 unsigned int actor_id; // edi@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
723 AIDirection v7; // esi@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
724 int v9; // ecx@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
725 signed int v10; // eax@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
726 int v14; // eax@29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
727 AIDirection a3; // [sp+Ch] [bp-44h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
728 AIDirection v18; // [sp+28h] [bp-28h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
729 signed int v22; // [sp+58h] [bp+8h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
730
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
731 pQueue[queue_index].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
732 if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
733 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
734 actor_id = PID_ID(pQueue[queue_index].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
735 if (!(pActors[actor_id].uAIState == Dying || pActors[actor_id].uAIState == Dead || pActors[actor_id].uAIState == Summoned ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
736 pActors[actor_id].uAIState == Disabled || pActors[actor_id].uAIState == Removed))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
737 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
738 Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
739 v22 = ai_near_actors_targets_pid[actor_id];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
740 if ( pActors[actor_id].pMonsterInfo.uHostilityType && !v22)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
741 pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
742 Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v22, &v7, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
743 memcpy(&a3, &v7, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
744 memcpy(&v18, &a3, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
745 v9 = a3.uDistance - pActors[actor_id].uActorRadius;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
746 if ( v9 < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
747 v9 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
748 if (PID_TYPE(v22) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
749 //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
750 v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(pActors[actor_id].pMonsterInfo.uID - 1) / 3 + 1];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
751 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
752 v10 = 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
753 switch (v10)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
754 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
755 case 1:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
756 if ( (double)(signed int)v9 < 307.2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
757 pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
758 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
759 case 2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
760 if ( v9 < 1024 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
761 pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
762 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
763 case 3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
764 if ( v9 < 2560 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
765 pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
766 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
767 case 4:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
768 if ( v9 < 5120 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
769 pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
770 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
771 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
772 if ( pActors[actor_id].pMonsterInfo.uHostilityType == 4 && v22 && (signed int)v9 < 5120 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
773 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
774 v14 = pActors[actor_id].special_ability_use_check(actor_id);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
775 pQueue[queue_index].AI_action_type = TE_AI_STAND;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
776 switch (v14)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
777 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
778 case 1:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
779 if ( pActors[actor_id].pMonsterInfo.uMissleAttack2Type )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
780 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
781 Actor::AI_MissileAttack2(actor_id, v22, &v18);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
782 pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
783 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
784 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
785 case 2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
786 if ( pActors[actor_id].pMonsterInfo.uSpell1ID )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
787 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
788 Actor::AI_SpellAttack1(actor_id, v22, &v18);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
789 pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
790 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
791 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
792 case 3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
793 if (pActors[actor_id].pMonsterInfo.uSpell2ID)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
794 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
795 Actor::AI_SpellAttack2(actor_id, v22, &v18);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
796 pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
797 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
798 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
799 default:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
800 if ( pActors[actor_id].pMonsterInfo.uMissleAttack1Type )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
801 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
802 Actor::AI_MissileAttack1(actor_id, v22, &v18);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
803 pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
804 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
805 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
806 //if (!pQueue[queue_index].AI_action_type)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
807 if ( (double)v9 < 307.2)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
808 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
809 Actor::AI_MeleeAttack(actor_id, v22, &v18);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
810 pQueue[queue_index].AI_action_type = TE_AI_MELEE_ATTACK;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
811 pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
812 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
813 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
814 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
815 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
816 Actor::AI_Stand(actor_id, v22, 64, &v18);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
817 pQueue[queue_index].AI_action_type = TE_AI_STAND;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
818 pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
819 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
820 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
821 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
822 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
823 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
824 Actor::AI_Stand(actor_id, v22, 64, &v18);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
825 pQueue[queue_index].AI_action_type = TE_AI_STAND;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
826 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
827 pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
828 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
829 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
830 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
831
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
832 //----- (00406A63) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
833 void stru262_TurnBased::ActorAISetMovementDecision()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
834 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
835 AIDirection a3; // [sp+8h] [bp-44h]@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
836 AIDirection v7; // [sp+24h] [bp-28h]@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
837 unsigned int target_pid; // [sp+40h] [bp-Ch]@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
838 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
839
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
840 this->ai_turn_timer = 64;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
841 dword_50C994 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
842 uActiveCharacter = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
843 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
844 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
845 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
846 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
847 target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
848 Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v7, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
849 if ( !ActorMove(i) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
850 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
851 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
852 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
853 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
854 // 50C994: using guessed type int dword_50C994;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
855
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
856 //----- (00406AFE) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
857 void stru262_TurnBased::ActorAIStopMovement()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
858 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
859 AIDirection a3; // [sp+4h] [bp-48h]@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
860 AIDirection v7; // [sp+20h] [bp-2Ch]@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
861 unsigned int target_pid;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
862 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
863
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
864 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
865 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
866 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
867 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
868 target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
869 Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v7, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
870 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
871 pQueue[i].AI_action_type = TE_AI_STAND;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
872 pQueue[i].uActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
873 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
874 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
875 turn_stage = TE_ATTACK;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
876 ai_turn_timer = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
877 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
878
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
879 //----- (00406B9F) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
880 void stru262_TurnBased::ActorAIDoAdditionalMove()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
881 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
882 AIDirection a3; // [sp+0h] [bp-50h]@15
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
883 AIDirection v9; // [sp+1Ch] [bp-34h]@15
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
884 unsigned int v13; // [sp+44h] [bp-Ch]@8
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
885 unsigned int monster_id;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
886
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
887 for ( int i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
888 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
889 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
890 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
891 monster_id = PID_ID(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
892 if ( !(pActors[monster_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0|| (pActors[monster_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0) ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
893 pActors[monster_id].uAIState == Dead || pActors[monster_id].uAIState == Removed || pActors[monster_id].uAIState == Disabled) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
894 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
895 v13 = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
896 Actor::GetDirectionInfo(pQueue[i].uPackedID, v13, &v9, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
897 if ( pActors[monster_id].uAIState == Pursuing || pActors[monster_id].uAIState == Tethered )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
898 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
899 if ( (double)(signed int)v9.uDistance < 307.2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
900 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
901 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
902 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
903 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
904 pActors[monster_id].uCurrentActionTime += pEventTimer->uTimeElapsed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
905 if ( pActors[monster_id].uCurrentActionTime > pActors[monster_id].uCurrentActionLength )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
906 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
907 if ( pActors[monster_id].uAIState == Dying )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
908 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
909 pActors[monster_id].uCurrentActionTime = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
910 pActors[monster_id].uCurrentActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
911 pActors[monster_id].uAIState = Dead;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
912 pActors[monster_id].UpdateAnimation();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
913 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
914 if ( !ActorMove(i) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
915 Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
916 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
917 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
918 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
919 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
920 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
921 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
922
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
923 //----- (00406D10) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
924 bool stru262_TurnBased::ActorMove(signed int queue_position)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
925 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
926 AIDirection v9; // esi@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
927 int v11; // ecx@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
928 unsigned __int8 pHostileType; // al@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
929 AIDirection a3; // [sp+Ch] [bp-48h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
930 AIDirection pDir; // [sp+28h] [bp-2Ch]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
931 unsigned int uActorID; // [sp+50h] [bp-4h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
932
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
933 if (PID_TYPE(pQueue[queue_position].uPackedID) == OBJECT_Player)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
934 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
935 uActorID = PID_ID(pQueue[queue_position].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
936 if ( pActors[uActorID].uAIState == Dead || pActors[uActorID].uAIState == Dying ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
937 pActors[uActorID].uAIState == Removed|| pActors[uActorID].uAIState == Disabled ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
938 pActors[uActorID].uAIState == Summoned )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
939 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
940 Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
941 if ( pActors[uActorID].pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[uActorID] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
942 pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
943 Actor::GetDirectionInfo(pQueue[queue_position].uPackedID, ai_near_actors_targets_pid[uActorID], &v9, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
944 memcpy(&a3, &v9, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
945 memcpy(&pDir, &a3, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
946 v11 = a3.uDistance - pActors[uActorID].uActorRadius;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
947 if ( v11 < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
948 v11 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
949 pHostileType = pActors[uActorID].pMonsterInfo.uHostilityType;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
950 switch (pHostileType)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
951 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
952 case 1:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
953 if ( (double)v11 < 307.2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
954 pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
955 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
956 case 2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
957 if ( v11 < 1024 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
958 pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
959 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
960 case 3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
961 if ( v11 < 2560 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
962 pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
963 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
964 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
965 if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
966 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
967 if (v11 < 10240 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
968 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
969 Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 0, &pDir);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
970 pTurnEngine->pQueue[queue_position].AI_action_type = 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
971 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
972 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
973 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
974 Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 1024, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
975 pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
976 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
977 pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
978 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
979 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
980 if ( pActors[uActorID].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
981 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
982 if ( !(pActors[uActorID].uAttributes & ACTOR_FLEEING) || pActors[uActorID].pMonsterInfo.uAIType == 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
983 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
984 if ( pActors[uActorID].pMonsterInfo.uAIType == 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
985 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
986 if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
987 Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
988 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
989 Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
990 pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
991 pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
992 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
993 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
994 if ( pActors[uActorID].pMonsterInfo.uAIType == 2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
995 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
996 if (((double)pActors[uActorID].pMonsterInfo.uHP * 0.2) > (double)pActors[uActorID].sCurrentHP && (v11 < 10240 ) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
997 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
998 if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
999 Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1000 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1001 Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1002 pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1003 pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1004 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1005 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1006 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1007 if ( pActors[uActorID].pMonsterInfo.uAIType == 3 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1008 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1009 if ( ((double)pActors[uActorID].pMonsterInfo.uHP * 0.1) > (double)pActors[uActorID].sCurrentHP && (v11 < 10240 ))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1010 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1011 if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1012 Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1013 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1014 Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1015 pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1016 pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1017 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1018 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1019 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1020 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1021 if ( (double)(signed int)v11 < 307.2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1022 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1023 if ( (signed int)v11 < 5120 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1024 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1025 if ( pActors[uActorID].pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1026 Actor::AI_Pursue1(uActorID, ai_near_actors_targets_pid[uActorID], uActorID, 32, &pDir);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1027 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1028 Actor::AI_Pursue2(uActorID, ai_near_actors_targets_pid[uActorID], 32, &pDir, 307);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1029 pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1030 pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1031 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1032 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1033 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1034 switch(pActors[uActorID].pMonsterInfo.uMovementType)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1035 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1036 case MONSTER_MOVEMENT_TYPE_SHORT:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1037 Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 1024, 32);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1038 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1039 case MONSTER_MOVEMENT_TYPE_MEDIUM:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1040 Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 2560, 32);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1041 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1042 case MONSTER_MOVEMENT_TYPE_LONG:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1043 Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 5120, 32);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1044 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1045 case MONSTER_MOVEMENT_TYPE_FREE:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1046 Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 10240, 32);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1047 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1048 case MONSTER_MOVEMENT_TYPE_STAIONARY:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1049 Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1050 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1051 default:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1052 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1053 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1054 pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1055 pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1056 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1057 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1058
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1059 //----- (00406FA8) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1060 void stru262_TurnBased::ActorAIChooseNewTargets()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1061 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1062 Actor *curr_acror; // ebx@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1063 AIDirection a3; // [sp+Ch] [bp-6Ch]@8
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1064 AIDirection v9; // [sp+28h] [bp-50h]@8
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1065 AIDirection a4; // [sp+44h] [bp-34h]@8
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1066 unsigned int target_pid; // [sp+60h] [bp-18h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1067 int uActorID; // [sp+68h] [bp-10h]@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1068 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1069
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1070 for ( i = 0; i < uActorQueueSize; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1071 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1072 if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1073 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1074 uActorID=PID_ID(pQueue[i].uPackedID);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1075 curr_acror = &pActors[uActorID];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1076 if ( !( curr_acror->uAIState == Summoned|| curr_acror->uAIState == Dead ||
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1077 curr_acror->uAIState == Removed || curr_acror->uAIState == Disabled) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1078 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1079 target_pid = ai_near_actors_targets_pid[uActorID];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1080 Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1081 Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v9, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1082 memcpy(&a4, &v9, sizeof(AIDirection));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1083 curr_acror->uCurrentActionTime += pEventTimer->uTimeElapsed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1084 if ( curr_acror->uCurrentActionTime > curr_acror->uCurrentActionLength )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1085 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1086 if ( curr_acror->uAIState == Dying )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1087 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1088 curr_acror->uCurrentActionTime = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1089 curr_acror->uCurrentActionLength = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1090 curr_acror->uAIState = Dead;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1091 curr_acror->UpdateAnimation();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1092 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1093 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1094 if ( rand() % 2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1095 Actor::AI_Stand(uActorID, target_pid, 64, &a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1096 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1097 Actor::AI_Bored(uActorID, target_pid, &a4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1098 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1099 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1100 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1101 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1102 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1103