annotate TurnEngine.cpp @ 2244:66c509997062

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