annotate mm7_5.cpp @ 1989:33787c8938a5

Single and Two-handed ENUM
author zipi
date Sat, 02 Nov 2013 17:45:58 +0000
parents c1c74df0a33e
children 985fff9fb62d
rev   line source
1165
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1160
diff changeset
1 #ifdef _MSC_VER
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1160
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1160
diff changeset
3 #endif
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1160
diff changeset
4
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 1000
diff changeset
5 #include "MapInfo.h"
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 1000
diff changeset
6 #include "LightmapBuilder.h"
0
Ritor1
parents:
diff changeset
7 #include "mm7.h"
Ritor1
parents:
diff changeset
8 #include "GUIWindow.h"
Ritor1
parents:
diff changeset
9 #include "Party.h"
Ritor1
parents:
diff changeset
10 #include "Outdoor.h"
Ritor1
parents:
diff changeset
11 #include "LOD.h"
Ritor1
parents:
diff changeset
12 #include "Actor.h"
Ritor1
parents:
diff changeset
13 #include "Viewport.h"
Ritor1
parents:
diff changeset
14 #include "Math.h"
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 513
diff changeset
15 #include "SpriteObject.h"
0
Ritor1
parents:
diff changeset
16 #include "Time.h"
Ritor1
parents:
diff changeset
17 #include "stru298.h"
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1254
diff changeset
18 #include "Lights.h"
1828
35c1e4ff6ba7 party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents: 1793
diff changeset
19 #include "Level/Decoration.h"
0
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21 //----- (004356FF) --------------------------------------------------------
1575
43d3536a20f7 OnInventoryItemRightClick
Nomad
parents: 1546
diff changeset
22 void back_to_game()
0
Ritor1
parents:
diff changeset
23 {
Ritor1
parents:
diff changeset
24 dword_507BF0_is_there_popup_onscreen = 0;
Ritor1
parents:
diff changeset
25 dword_4E455C = 1;
1575
43d3536a20f7 OnInventoryItemRightClick
Nomad
parents: 1546
diff changeset
26
43d3536a20f7 OnInventoryItemRightClick
Nomad
parents: 1546
diff changeset
27 extern int no_rightlick_in_inventory;
43d3536a20f7 OnInventoryItemRightClick
Nomad
parents: 1546
diff changeset
28 no_rightlick_in_inventory = false;
43d3536a20f7 OnInventoryItemRightClick
Nomad
parents: 1546
diff changeset
29
0
Ritor1
parents:
diff changeset
30 if ( pGUIWindow_ScrollWindow )
Ritor1
parents:
diff changeset
31 free_book_subwindow();
Ritor1
parents:
diff changeset
32 if ( !pCurrentScreen && !pGUIWindow_Settings )
Ritor1
parents:
diff changeset
33 pEventTimer->Resume();
Ritor1
parents:
diff changeset
34 viewparams->bRedrawGameUI = 1;
Ritor1
parents:
diff changeset
35 }
782
c47efaf23642 more tidy
zipi
parents: 766
diff changeset
36
0
Ritor1
parents:
diff changeset
37 //----- (0043648F) --------------------------------------------------------
Ritor1
parents:
diff changeset
38 void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
Ritor1
parents:
diff changeset
39 {
Ritor1
parents:
diff changeset
40 _this->flt_2C = 0.0;
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42 _this->vWorldPosition.x = a2->x;
Ritor1
parents:
diff changeset
43 _this->vWorldPosition.y = a2->y;
Ritor1
parents:
diff changeset
44 _this->vWorldPosition.z = a2->z;
Ritor1
parents:
diff changeset
45 }
Ritor1
parents:
diff changeset
46
Ritor1
parents:
diff changeset
47 //----- (004369DB) --------------------------------------------------------
Ritor1
parents:
diff changeset
48 void Vec3_float_::Normalize()
Ritor1
parents:
diff changeset
49 {
1025
8b492d4722d4 Intersection
Ritor1
parents: 1023
diff changeset
50 this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x;
8b492d4722d4 Intersection
Ritor1
parents: 1023
diff changeset
51 this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y;
8b492d4722d4 Intersection
Ritor1
parents: 1023
diff changeset
52 this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z;
0
Ritor1
parents:
diff changeset
53 }
Ritor1
parents:
diff changeset
54
Ritor1
parents:
diff changeset
55 //----- (00438F8F) --------------------------------------------------------
1391
cc9a3a24d61d Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents: 1384
diff changeset
56 void area_of_effect__damage_evaluate()
0
Ritor1
parents:
diff changeset
57 {
Ritor1
parents:
diff changeset
58 int v0; // edx@1
Ritor1
parents:
diff changeset
59 char *v1; // esi@2
Ritor1
parents:
diff changeset
60 int v2; // ecx@3
Ritor1
parents:
diff changeset
61 signed int v3; // eax@3
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 513
diff changeset
62 SpriteObject *v4; // eax@4
0
Ritor1
parents:
diff changeset
63 signed int v5; // eax@4
Ritor1
parents:
diff changeset
64 signed int v6; // eax@6
Ritor1
parents:
diff changeset
65 unsigned int v7; // edi@6
Ritor1
parents:
diff changeset
66 int v8; // eax@6
Ritor1
parents:
diff changeset
67 __int16 v9; // bx@8
Ritor1
parents:
diff changeset
68 int v10; // edi@8
Ritor1
parents:
diff changeset
69 Vec3_int_ v11; // ST04_12@9
Ritor1
parents:
diff changeset
70 int v12; // ST0C_4@10
Ritor1
parents:
diff changeset
71 Actor *v13; // edi@11
Ritor1
parents:
diff changeset
72 int v14; // edx@15
Ritor1
parents:
diff changeset
73 int v15; // edx@15
Ritor1
parents:
diff changeset
74 int v16; // ebx@15
Ritor1
parents:
diff changeset
75 signed int v17; // eax@15
Ritor1
parents:
diff changeset
76 int v18; // edi@15
Ritor1
parents:
diff changeset
77 int v19; // edi@15
Ritor1
parents:
diff changeset
78 Vec3_int_ v20; // ST04_12@16
Ritor1
parents:
diff changeset
79 Vec3_int_ *v21; // eax@17
Ritor1
parents:
diff changeset
80 unsigned int v22; // edx@17
Ritor1
parents:
diff changeset
81 int v23; // edx@18
Ritor1
parents:
diff changeset
82 int v24; // eax@18
Ritor1
parents:
diff changeset
83 Vec3_int_ v25; // ST04_12@19
Ritor1
parents:
diff changeset
84 unsigned int v26; // ebx@20
89
98cd93e14777 pointer fixes
zipi
parents: 82
diff changeset
85 Player *v27; // edi@20
90
d61f6bc04bf2 more pointer fixes
zipi
parents: 89
diff changeset
86 Actor *v28; // edi@27
0
Ritor1
parents:
diff changeset
87 int v29; // ebx@29
Ritor1
parents:
diff changeset
88 int v30; // eax@29
Ritor1
parents:
diff changeset
89 int v31; // edx@29
Ritor1
parents:
diff changeset
90 int v32; // eax@29
Ritor1
parents:
diff changeset
91 int v33; // ST24_4@29
Ritor1
parents:
diff changeset
92 Vec3_int_ v34; // ST04_12@30
Ritor1
parents:
diff changeset
93 Vec3_int_ *v35; // eax@31
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 513
diff changeset
94 SpriteObject *v36; // [sp+0h] [bp-28h]@0
0
Ritor1
parents:
diff changeset
95 signed int v37; // [sp+4h] [bp-24h]@5
Ritor1
parents:
diff changeset
96 int v38; // [sp+4h] [bp-24h]@15
Ritor1
parents:
diff changeset
97 signed int v39; // [sp+8h] [bp-20h]@3
Ritor1
parents:
diff changeset
98 int v40; // [sp+8h] [bp-20h]@15
Ritor1
parents:
diff changeset
99 int v41; // [sp+Ch] [bp-1Ch]@5
Ritor1
parents:
diff changeset
100 int v42; // [sp+Ch] [bp-1Ch]@15
Ritor1
parents:
diff changeset
101 int v43; // [sp+10h] [bp-18h]@1
Ritor1
parents:
diff changeset
102 int v44; // [sp+14h] [bp-14h]@15
Ritor1
parents:
diff changeset
103 unsigned int uActorID; // [sp+18h] [bp-10h]@6
Ritor1
parents:
diff changeset
104 Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2
Ritor1
parents:
diff changeset
105 int a1; // [sp+20h] [bp-8h]@8
Ritor1
parents:
diff changeset
106 int v48; // [sp+24h] [bp-4h]@8
Ritor1
parents:
diff changeset
107
Ritor1
parents:
diff changeset
108 v0 = 0;
Ritor1
parents:
diff changeset
109 v43 = 0;
Ritor1
parents:
diff changeset
110 if ( stru_50FE08.count > 0 )
Ritor1
parents:
diff changeset
111 {
Ritor1
parents:
diff changeset
112 pVelocity = &stru_50FE08.vec_4B4;
Ritor1
parents:
diff changeset
113 v1 = (char *)stru_50FE08.pZs;
Ritor1
parents:
diff changeset
114 do
Ritor1
parents:
diff changeset
115 {
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
116 v2 = PID_TYPE(*((short *)v1 - 300));
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
117 v3 = PID_ID((signed int)*((short *)v1 - 300));
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
118 v39 = PID_ID((signed int)*((short *)v1 - 300));
0
Ritor1
parents:
diff changeset
119 if ( v2 == 2 )
Ritor1
parents:
diff changeset
120 {
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 513
diff changeset
121 v4 = &pSpriteObjects[v3];
0
Ritor1
parents:
diff changeset
122 v36 = v4;
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 819
diff changeset
123 v5 = v4->spell_caster_pid;
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
124 v2 = PID_TYPE(v5);
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
125 v3 = PID_ID(v5);
0
Ritor1
parents:
diff changeset
126 }
Ritor1
parents:
diff changeset
127 v41 = v2;
Ritor1
parents:
diff changeset
128 v37 = v3;
Ritor1
parents:
diff changeset
129 if ( stru_50FE08.field_3EC[v0] & 1 )
Ritor1
parents:
diff changeset
130 {
417
55684f4eda73 Actor::SelectTarget & ai_near_actors_targets_pid
Nomad
parents: 414
diff changeset
131 v6 = ai_near_actors_targets_pid[v3];
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
132 v7 = PID_ID(v6);
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
133 v8 = PID_TYPE(v6) - 3;
0
Ritor1
parents:
diff changeset
134 uActorID = v7;
Ritor1
parents:
diff changeset
135 if ( v8 )
Ritor1
parents:
diff changeset
136 {
Ritor1
parents:
diff changeset
137 if ( v8 == 1 )
Ritor1
parents:
diff changeset
138 {
Ritor1
parents:
diff changeset
139 v9 = *(short *)v1;
Ritor1
parents:
diff changeset
140 v10 = pParty->vPosition.y - *((short *)v1 - 100);
Ritor1
parents:
diff changeset
141 a1 = pParty->vPosition.x - *((short *)v1 - 200);
Ritor1
parents:
diff changeset
142 v48 = v10;
Ritor1
parents:
diff changeset
143 if ( a1 * a1
Ritor1
parents:
diff changeset
144 + v10 * v10
Ritor1
parents:
diff changeset
145 + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9))
Ritor1
parents:
diff changeset
146 * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
Ritor1
parents:
diff changeset
147 {
Ritor1
parents:
diff changeset
148 v11.z = *(short *)v1;
Ritor1
parents:
diff changeset
149 v11.y = *((short *)v1 - 100);
Ritor1
parents:
diff changeset
150 v11.x = *((short *)v1 - 200);
Ritor1
parents:
diff changeset
151 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v11) )
Ritor1
parents:
diff changeset
152 {
1911
af38275939cc which_player_to_attack rename and cleaning
Ritor1
parents: 1876
diff changeset
153 v12 = stru_50C198.which_player_to_attack(&pActors[v39]);
0
Ritor1
parents:
diff changeset
154 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v12);
Ritor1
parents:
diff changeset
155 }
Ritor1
parents:
diff changeset
156 }
Ritor1
parents:
diff changeset
157 }
Ritor1
parents:
diff changeset
158 }
Ritor1
parents:
diff changeset
159 else
Ritor1
parents:
diff changeset
160 {
Ritor1
parents:
diff changeset
161 v13 = &pActors[v7];
1946
aa3ca49a10f5 pActorBuffs[6] to pActorBuffs[ACTOR_BUFF_PARALYZED]
Grumpy7
parents: 1945
diff changeset
162 if ( SHIDWORD(v13->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) > 0
aa3ca49a10f5 pActorBuffs[6] to pActorBuffs[ACTOR_BUFF_PARALYZED]
Grumpy7
parents: 1945
diff changeset
163 || SHIDWORD(v13->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) >= 0 && LODWORD(v13->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime)
0
Ritor1
parents:
diff changeset
164 || v13->CanAct() )
Ritor1
parents:
diff changeset
165 {
Ritor1
parents:
diff changeset
166 v14 = v13->vPosition.y;
Ritor1
parents:
diff changeset
167 v40 = v13->vPosition.x;
Ritor1
parents:
diff changeset
168 v38 = v14;
Ritor1
parents:
diff changeset
169 v15 = v14 - *((short *)v1 - 100);
Ritor1
parents:
diff changeset
170 v16 = *(short *)v1;
Ritor1
parents:
diff changeset
171 v42 = v13->vPosition.z;
Ritor1
parents:
diff changeset
172 a1 = v40 - *((short *)v1 - 200);
Ritor1
parents:
diff changeset
173 v17 = v13->uActorHeight;
Ritor1
parents:
diff changeset
174 v18 = v13->uActorRadius;
Ritor1
parents:
diff changeset
175 v44 = v42;
Ritor1
parents:
diff changeset
176 v19 = *((short *)v1 + 100) + v18;
Ritor1
parents:
diff changeset
177 v48 = v15;
Ritor1
parents:
diff changeset
178 if ( a1 * a1 + v15 * v15 + (v42 + (v17 >> 1) - v16) * (v42 + (v17 >> 1) - v16) < (unsigned int)(v19 * v19) )
Ritor1
parents:
diff changeset
179 {
Ritor1
parents:
diff changeset
180 v20.z = *(short *)v1;
Ritor1
parents:
diff changeset
181 v20.y = *((short *)v1 - 100);
Ritor1
parents:
diff changeset
182 v20.x = *((short *)v1 - 200);
Ritor1
parents:
diff changeset
183 if ( sub_407A1C(v40, v38, v42 + 50, v20) )
Ritor1
parents:
diff changeset
184 {
Ritor1
parents:
diff changeset
185 Vec3_int_::Normalize(&a1, &v48, &v44);
Ritor1
parents:
diff changeset
186 v21 = pVelocity;
Ritor1
parents:
diff changeset
187 v22 = uActorID;
Ritor1
parents:
diff changeset
188 pVelocity->x = a1;
Ritor1
parents:
diff changeset
189 v21->y = v48;
Ritor1
parents:
diff changeset
190 v21->z = v44;
Ritor1
parents:
diff changeset
191 sub_43B1B0(*((short *)v1 - 300), v22, v21, stru_50FE08.field_450[v43]);
Ritor1
parents:
diff changeset
192 }
Ritor1
parents:
diff changeset
193 }
Ritor1
parents:
diff changeset
194 }
Ritor1
parents:
diff changeset
195 }
Ritor1
parents:
diff changeset
196 }
Ritor1
parents:
diff changeset
197 else
Ritor1
parents:
diff changeset
198 {
Ritor1
parents:
diff changeset
199 v23 = pParty->vPosition.y - *((short *)v1 - 100);
Ritor1
parents:
diff changeset
200 v24 = ((signed int)pParty->uPartyHeight >> 1) - *(short *)v1;
Ritor1
parents:
diff changeset
201 a1 = pParty->vPosition.x - *((short *)v1 - 200);
Ritor1
parents:
diff changeset
202 v48 = v23;
Ritor1
parents:
diff changeset
203 if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
Ritor1
parents:
diff changeset
204 {
Ritor1
parents:
diff changeset
205 v25.z = *(short *)v1;
Ritor1
parents:
diff changeset
206 v25.y = *((short *)v1 - 100);
Ritor1
parents:
diff changeset
207 v25.x = *((short *)v1 - 200);
Ritor1
parents:
diff changeset
208 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v25) )
Ritor1
parents:
diff changeset
209 {
Ritor1
parents:
diff changeset
210 v26 = 0;
1861
a86c60679949 changing most of party arrays to std::arrays, some minor cleanups in actor.cpp
Grumpy7
parents: 1828
diff changeset
211 v27 = pParty->pPlayers.data();//[0].pConditions[15];
0
Ritor1
parents:
diff changeset
212 do
Ritor1
parents:
diff changeset
213 {
89
98cd93e14777 pointer fixes
zipi
parents: 82
diff changeset
214 if ( !(HIDWORD(v27->pConditions[14]) | LODWORD(v27->pConditions[14])) && !v27->pConditions[15] && !v27->pConditions[16] )
0
Ritor1
parents:
diff changeset
215 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v26);
89
98cd93e14777 pointer fixes
zipi
parents: 82
diff changeset
216 ++v27;
0
Ritor1
parents:
diff changeset
217 ++v26;
Ritor1
parents:
diff changeset
218 }
89
98cd93e14777 pointer fixes
zipi
parents: 82
diff changeset
219 while ( v27 <= &pParty->pPlayers[3] );
0
Ritor1
parents:
diff changeset
220 }
Ritor1
parents:
diff changeset
221 }
Ritor1
parents:
diff changeset
222 uActorID = 0;
Ritor1
parents:
diff changeset
223 if ( (signed int)uNumActors > 0 )
Ritor1
parents:
diff changeset
224 {
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1184
diff changeset
225 v28 = pActors.data();//[0].vPosition.z;
0
Ritor1
parents:
diff changeset
226 do
Ritor1
parents:
diff changeset
227 {
91
471b1354cc73 previous commit fix
zipi
parents: 90
diff changeset
228 if ( v28->CanAct() )
0
Ritor1
parents:
diff changeset
229 {
Ritor1
parents:
diff changeset
230 v29 = *(short *)v1;
91
471b1354cc73 previous commit fix
zipi
parents: 90
diff changeset
231 v30 = v28->vPosition.y - *((short *)v1 - 100);
471b1354cc73 previous commit fix
zipi
parents: 90
diff changeset
232 a1 = v28->vPosition.x - *((short *)v1 - 200);
90
d61f6bc04bf2 more pointer fixes
zipi
parents: 89
diff changeset
233 v31 = v28->vPosition.z;
0
Ritor1
parents:
diff changeset
234 v48 = v30;
Ritor1
parents:
diff changeset
235 v44 = v31;
90
d61f6bc04bf2 more pointer fixes
zipi
parents: 89
diff changeset
236 v32 = (v28->uActorHeight >> 1) - v29;
91
471b1354cc73 previous commit fix
zipi
parents: 90
diff changeset
237 v33 = v28->uActorRadius + *((short *)v1 + 100);
0
Ritor1
parents:
diff changeset
238 if ( a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33) )
Ritor1
parents:
diff changeset
239 {
Ritor1
parents:
diff changeset
240 v34.z = *(short *)v1;
Ritor1
parents:
diff changeset
241 v34.y = *((short *)v1 - 100);
Ritor1
parents:
diff changeset
242 v34.x = *((short *)v1 - 200);
90
d61f6bc04bf2 more pointer fixes
zipi
parents: 89
diff changeset
243 if ( sub_407A1C(v28->vPosition.x, v28->vPosition.y, v28->vPosition.z + 50, v34) )
0
Ritor1
parents:
diff changeset
244 {
Ritor1
parents:
diff changeset
245 Vec3_int_::Normalize(&a1, &v48, &v44);
Ritor1
parents:
diff changeset
246 v35 = pVelocity;
Ritor1
parents:
diff changeset
247 pVelocity->x = a1;
Ritor1
parents:
diff changeset
248 v35->y = v48;
Ritor1
parents:
diff changeset
249 v35->z = v44;
Ritor1
parents:
diff changeset
250 switch ( v41 )
Ritor1
parents:
diff changeset
251 {
303
3dcc9d945eeb DamageMonsterFromParty
Nomad
parents: 296
diff changeset
252 case OBJECT_Player:
0
Ritor1
parents:
diff changeset
253 DamageMonsterFromParty(*((short *)v1 - 300), uActorID, v35);
Ritor1
parents:
diff changeset
254 break;
303
3dcc9d945eeb DamageMonsterFromParty
Nomad
parents: 296
diff changeset
255 case OBJECT_Actor:
90
d61f6bc04bf2 more pointer fixes
zipi
parents: 89
diff changeset
256 if ( v36 && pActors[v37].GetActorsRelation(v28) )
0
Ritor1
parents:
diff changeset
257 sub_43B1B0(*((short *)v1 - 300), uActorID, pVelocity, v36->field_61);
Ritor1
parents:
diff changeset
258 break;
303
3dcc9d945eeb DamageMonsterFromParty
Nomad
parents: 296
diff changeset
259 case OBJECT_Item:
0
Ritor1
parents:
diff changeset
260 sub_43B057(*((short *)v1 - 300), uActorID, v35);
Ritor1
parents:
diff changeset
261 break;
Ritor1
parents:
diff changeset
262 }
Ritor1
parents:
diff changeset
263 }
Ritor1
parents:
diff changeset
264 }
Ritor1
parents:
diff changeset
265 }
Ritor1
parents:
diff changeset
266 ++uActorID;
90
d61f6bc04bf2 more pointer fixes
zipi
parents: 89
diff changeset
267 ++v28;
0
Ritor1
parents:
diff changeset
268 }
Ritor1
parents:
diff changeset
269 while ( (signed int)uActorID < (signed int)uNumActors );
Ritor1
parents:
diff changeset
270 }
Ritor1
parents:
diff changeset
271 }
Ritor1
parents:
diff changeset
272 ++pVelocity;
Ritor1
parents:
diff changeset
273 v0 = v43 + 1;
Ritor1
parents:
diff changeset
274 v1 += 2;
Ritor1
parents:
diff changeset
275 ++v43;
Ritor1
parents:
diff changeset
276 }
Ritor1
parents:
diff changeset
277 while ( v43 < stru_50FE08.count );
Ritor1
parents:
diff changeset
278 }
Ritor1
parents:
diff changeset
279 stru_50FE08.count = 0;
Ritor1
parents:
diff changeset
280 }
Ritor1
parents:
diff changeset
281
Ritor1
parents:
diff changeset
282
Ritor1
parents:
diff changeset
283 //----- (0043A97E) --------------------------------------------------------
Ritor1
parents:
diff changeset
284 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
Ritor1
parents:
diff changeset
285 {
1979
92dfa0cafbe3 Fixing players not getting damaged by projectiles
Grumpy7
parents: 1974
diff changeset
286 if (PID_TYPE(a2) == OBJECT_Player)
828
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
287 {
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
288 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x;
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
289 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y;
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
290 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z;
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
291
0
Ritor1
parents:
diff changeset
292 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
828
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
293 DamagePlayerFromMonster(PID(OBJECT_Item, uLayingItemID), pSpriteObjects[uLayingItemID].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu);
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
294 }
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
295 else if (PID_TYPE(a2) == OBJECT_Actor)
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
296 {
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
297 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x;
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
298 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y;
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
299 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z;
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
300
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
301 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
302 switch (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid))
0
Ritor1
parents:
diff changeset
303 {
Ritor1
parents:
diff changeset
304 case OBJECT_Actor:
828
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
305 sub_43B1B0(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC, pSpriteObjects[uLayingItemID].field_61);
0
Ritor1
parents:
diff changeset
306 break;
Ritor1
parents:
diff changeset
307 case OBJECT_Player:
828
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
308 DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC);
0
Ritor1
parents:
diff changeset
309 break;
Ritor1
parents:
diff changeset
310 case OBJECT_Item:
828
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
311 sub_43B057(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC);
0
Ritor1
parents:
diff changeset
312 break;
Ritor1
parents:
diff changeset
313 }
Ritor1
parents:
diff changeset
314 }
Ritor1
parents:
diff changeset
315 }
Ritor1
parents:
diff changeset
316
Ritor1
parents:
diff changeset
317 //----- (0043AE12) --------------------------------------------------------
Ritor1
parents:
diff changeset
318 double __fastcall sub_43AE12(signed int a1)
Ritor1
parents:
diff changeset
319 {
Ritor1
parents:
diff changeset
320 signed int v1; // ST00_4@1
Ritor1
parents:
diff changeset
321 signed int v2; // ecx@1
Ritor1
parents:
diff changeset
322 double v3; // st7@1
Ritor1
parents:
diff changeset
323 double result; // st7@6
Ritor1
parents:
diff changeset
324
Ritor1
parents:
diff changeset
325 v1 = a1;
Ritor1
parents:
diff changeset
326 v2 = 0;
Ritor1
parents:
diff changeset
327 v3 = (double)v1;
Ritor1
parents:
diff changeset
328 do
Ritor1
parents:
diff changeset
329 {
Ritor1
parents:
diff changeset
330 if ( v3 < flt_4E4A80[v2 + 5] )
Ritor1
parents:
diff changeset
331 break;
Ritor1
parents:
diff changeset
332 ++v2;
Ritor1
parents:
diff changeset
333 }
Ritor1
parents:
diff changeset
334 while ( v2 < 5 );
Ritor1
parents:
diff changeset
335 if ( v2 <= 0 || v2 >= 5 )
Ritor1
parents:
diff changeset
336 {
Ritor1
parents:
diff changeset
337 if ( v2 )
Ritor1
parents:
diff changeset
338 result = flt_4E4A80[4];
Ritor1
parents:
diff changeset
339 else
Ritor1
parents:
diff changeset
340 result = flt_4E4A80[0];
Ritor1
parents:
diff changeset
341 }
Ritor1
parents:
diff changeset
342 else
Ritor1
parents:
diff changeset
343 {
1469
bba0944c9b27 minor fix
zipi
parents: 1459
diff changeset
344 result = (flt_4E4A80[v2] - flt_4E4A80[v2 - 1]) * (v3 - flt_4E4A80[v2 + 4]) / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4]) + flt_4E4A80[v2];
0
Ritor1
parents:
diff changeset
345 }
Ritor1
parents:
diff changeset
346 return result;
Ritor1
parents:
diff changeset
347 }
Ritor1
parents:
diff changeset
348
Ritor1
parents:
diff changeset
349 //----- (0043B057) --------------------------------------------------------
Ritor1
parents:
diff changeset
350 void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity)
Ritor1
parents:
diff changeset
351 {
Ritor1
parents:
diff changeset
352 Actor *pActor; // esi@1
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 513
diff changeset
353 SpriteObject *v4; // eax@3
0
Ritor1
parents:
diff changeset
354 int v5; // ecx@3
Ritor1
parents:
diff changeset
355 int v6; // eax@4
Ritor1
parents:
diff changeset
356 int v7; // edi@4
Ritor1
parents:
diff changeset
357 unsigned int uActorIDa; // [sp+8h] [bp-8h]@1
Ritor1
parents:
diff changeset
358 unsigned int a2; // [sp+Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
359 int a2a; // [sp+Ch] [bp-4h]@8
Ritor1
parents:
diff changeset
360
Ritor1
parents:
diff changeset
361 uActorIDa = uActorID;
Ritor1
parents:
diff changeset
362 pActor = &pActors[uActorID];
Ritor1
parents:
diff changeset
363 a2 = uObjID;
303
3dcc9d945eeb DamageMonsterFromParty
Nomad
parents: 296
diff changeset
364 if ( !pActors[uActorID].IsNotAlive() )
0
Ritor1
parents:
diff changeset
365 {
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
366 if ( PID_TYPE(a2) == OBJECT_Item)
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
367 {
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
368 v4 = &pSpriteObjects[PID_ID(a2)];
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 819
diff changeset
369 v5 = v4->spell_id;
0
Ritor1
parents:
diff changeset
370 if ( v5 )
Ritor1
parents:
diff changeset
371 {
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 819
diff changeset
372 v6 = _43AFE3_calc_spell_damage(v5, v4->spell_level, v4->spell_skill, pActor->sCurrentHP);
0
Ritor1
parents:
diff changeset
373 v7 = stru_50C198.CalcMagicalDamageToActor(pActor, 0, v6);
Ritor1
parents:
diff changeset
374 pActor->sCurrentHP -= v7;
Ritor1
parents:
diff changeset
375 if ( v7 )
Ritor1
parents:
diff changeset
376 {
Ritor1
parents:
diff changeset
377 if ( pActor->sCurrentHP > 0 )
1060
b79139c3b5c8 some AI cleaning
zipi
parents: 1057
diff changeset
378 Actor::AI_Stun(uActorIDa, a2, 0);
0
Ritor1
parents:
diff changeset
379 else
Ritor1
parents:
diff changeset
380 Actor::Die(uActorIDa);
Ritor1
parents:
diff changeset
381 a2a = 20 * v7 / (signed int)pActor->pMonsterInfo.uHP;
Ritor1
parents:
diff changeset
382 if ( 20 * v7 / (signed int)pActor->pMonsterInfo.uHP > 10 )
Ritor1
parents:
diff changeset
383 a2a = 10;
Ritor1
parents:
diff changeset
384 if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
Ritor1
parents:
diff changeset
385 {
Ritor1
parents:
diff changeset
386 pVelocity->x = (unsigned __int64)(a2a * (signed __int64)pVelocity->x) >> 16;
Ritor1
parents:
diff changeset
387 pVelocity->y = (unsigned __int64)(a2a * (signed __int64)pVelocity->y) >> 16;
Ritor1
parents:
diff changeset
388 pVelocity->z = (unsigned __int64)(a2a * (signed __int64)pVelocity->z) >> 16;
Ritor1
parents:
diff changeset
389 pActor->vVelocity.x = 50 * LOWORD(pVelocity->x);
Ritor1
parents:
diff changeset
390 pActor->vVelocity.y = 50 * LOWORD(pVelocity->y);
Ritor1
parents:
diff changeset
391 pActor->vVelocity.z = 50 * LOWORD(pVelocity->z);
Ritor1
parents:
diff changeset
392 }
Ritor1
parents:
diff changeset
393 Actor::AddBloodsplatOnDamageOverlay(uActorIDa, 1, v7);
Ritor1
parents:
diff changeset
394 }
Ritor1
parents:
diff changeset
395 else
Ritor1
parents:
diff changeset
396 {
1060
b79139c3b5c8 some AI cleaning
zipi
parents: 1057
diff changeset
397 Actor::AI_Stun(uActorIDa, a2, 0);
0
Ritor1
parents:
diff changeset
398 }
Ritor1
parents:
diff changeset
399 }
Ritor1
parents:
diff changeset
400 }
Ritor1
parents:
diff changeset
401 }
Ritor1
parents:
diff changeset
402 }
Ritor1
parents:
diff changeset
403
Ritor1
parents:
diff changeset
404 //----- (0043B1B0) --------------------------------------------------------
322
ce39b96acf5c Killing friendly peasants subs
Nomad
parents: 321
diff changeset
405 void sub_43B1B0(signed int a1, unsigned int a2, Vec3_int_ *pVelocity, signed int a4)
0
Ritor1
parents:
diff changeset
406 {
Ritor1
parents:
diff changeset
407 int v4; // ebx@1
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 513
diff changeset
408 SpriteObject *v5; // eax@2
1924
8cd321994943 MSVS 2012 project file & some compilation warning fixes
Nomad
parents: 1916
diff changeset
409 int v6; // eax@3
0
Ritor1
parents:
diff changeset
410 Actor *v7; // esi@4
Ritor1
parents:
diff changeset
411 Actor *v8; // edi@4
Ritor1
parents:
diff changeset
412 char v9; // zf@5
Ritor1
parents:
diff changeset
413 __int64 v10; // qax@8
Ritor1
parents:
diff changeset
414 signed __int16 v11; // cx@9
Ritor1
parents:
diff changeset
415 signed int v12; // ecx@20
Ritor1
parents:
diff changeset
416 int v13; // ecx@22
Ritor1
parents:
diff changeset
417 int v14; // edi@30
Ritor1
parents:
diff changeset
418 unsigned int uActorID; // [sp+Ch] [bp-8h]@1
Ritor1
parents:
diff changeset
419 signed int v17; // [sp+10h] [bp-4h]@1
Ritor1
parents:
diff changeset
420 int v18; // [sp+20h] [bp+Ch]@34
Ritor1
parents:
diff changeset
421
Ritor1
parents:
diff changeset
422 v4 = 0;
Ritor1
parents:
diff changeset
423 uActorID = a2;
Ritor1
parents:
diff changeset
424 v17 = a1;
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
425 if ( PID_TYPE(a1) == OBJECT_Item)
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
426 {
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
427 v5 = &pSpriteObjects[PID_ID(a1)];
0
Ritor1
parents:
diff changeset
428 v4 = v5->field_60_distance_related_prolly_lod;
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 819
diff changeset
429 v17 = v5->spell_caster_pid;
0
Ritor1
parents:
diff changeset
430 }
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
431 LOWORD(v6) = PID_TYPE(v17);
303
3dcc9d945eeb DamageMonsterFromParty
Nomad
parents: 296
diff changeset
432 if ( v6 == OBJECT_Actor)
0
Ritor1
parents:
diff changeset
433 {
Ritor1
parents:
diff changeset
434 v7 = &pActors[a2];
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
435 v8 = &pActors[PID_ID(v17)];
303
3dcc9d945eeb DamageMonsterFromParty
Nomad
parents: 296
diff changeset
436 v6 = pActors[a2].IsNotAlive();
0
Ritor1
parents:
diff changeset
437 if ( !v6 )
Ritor1
parents:
diff changeset
438 {
Ritor1
parents:
diff changeset
439 v9 = v7->uAIState == 7;
Ritor1
parents:
diff changeset
440 v7->uLastCharacterIDToHit = v17;
Ritor1
parents:
diff changeset
441 if ( v9 )
Ritor1
parents:
diff changeset
442 BYTE2(v7->uAttributes) |= 2u;
1974
0f62a2b8bd0a stru319::_4273BB moved to Actor::_4273BB, renamed to _4273BB_DoesHitOtherActor
Grumpy7
parents: 1959
diff changeset
443 v6 = v8->_4273BB_DoesHitOtherActor(v7, v4, 0);
0
Ritor1
parents:
diff changeset
444 if ( v6 )
Ritor1
parents:
diff changeset
445 {
1876
2070d01ccfae Actor::_43B3E0_CalcDamage changed to non-static
Grumpy7
parents: 1861
diff changeset
446 v10 = (unsigned int)v8->_43B3E0_CalcDamage(a4);
1949
2f45768fcb7a pActorBuffs[3] to pActorBuffs[ACTOR_BUFF_SHRINK]
Grumpy7
parents: 1946
diff changeset
447 if ( (signed __int64)v8->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 )
0
Ritor1
parents:
diff changeset
448 {
1949
2f45768fcb7a pActorBuffs[3] to pActorBuffs[ACTOR_BUFF_SHRINK]
Grumpy7
parents: 1946
diff changeset
449 v11 = v8->pActorBuffs[ACTOR_BUFF_SHRINK].uPower;
0
Ritor1
parents:
diff changeset
450 if ( v11 )
Ritor1
parents:
diff changeset
451 v10 = (signed int)v10 / (unsigned __int16)v11;
Ritor1
parents:
diff changeset
452 }
1945
431d3da6e945 pActorBuffs[5] to pActorBuffs[ACTOR_BUFF_STONED]
Grumpy7
parents: 1924
diff changeset
453 if ( SHIDWORD(v7->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) >= SHIDWORD(v10)
431d3da6e945 pActorBuffs[5] to pActorBuffs[ACTOR_BUFF_STONED]
Grumpy7
parents: 1924
diff changeset
454 && (SHIDWORD(v7->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > SHIDWORD(v10)
431d3da6e945 pActorBuffs[5] to pActorBuffs[ACTOR_BUFF_STONED]
Grumpy7
parents: 1924
diff changeset
455 || LODWORD(v7->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > HIDWORD(v10)) )
0
Ritor1
parents:
diff changeset
456 LODWORD(v10) = 0;
Ritor1
parents:
diff changeset
457 if ( a4 != HIDWORD(v10) )
Ritor1
parents:
diff changeset
458 {
Ritor1
parents:
diff changeset
459 if ( a4 - HIDWORD(v10) == 1 )
Ritor1
parents:
diff changeset
460 {
Ritor1
parents:
diff changeset
461 v12 = v8->pMonsterInfo.uAttack2Type;
1959
4fbffad6e011 pActorBuffs[15] to pActorBuffs[ACTOR_BUFF_SHIELD]
Grumpy7
parents: 1949
diff changeset
462 if ( SHIDWORD(v7->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) >= SHIDWORD(v10)
4fbffad6e011 pActorBuffs[15] to pActorBuffs[ACTOR_BUFF_SHIELD]
Grumpy7
parents: 1949
diff changeset
463 && (SHIDWORD(v7->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > SHIDWORD(v10)
4fbffad6e011 pActorBuffs[15] to pActorBuffs[ACTOR_BUFF_SHIELD]
Grumpy7
parents: 1949
diff changeset
464 || LODWORD(v7->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > HIDWORD(v10)) )
0
Ritor1
parents:
diff changeset
465 LODWORD(v10) = (signed int)v10 >> 1;
Ritor1
parents:
diff changeset
466 goto LABEL_30;
Ritor1
parents:
diff changeset
467 }
Ritor1
parents:
diff changeset
468 if ( a4 - HIDWORD(v10) == 2 )
Ritor1
parents:
diff changeset
469 {
Ritor1
parents:
diff changeset
470 v13 = v7->pMonsterInfo.uSpell1ID;
Ritor1
parents:
diff changeset
471 }
Ritor1
parents:
diff changeset
472 else
Ritor1
parents:
diff changeset
473 {
Ritor1
parents:
diff changeset
474 if ( a4 - HIDWORD(v10) != 3 )
Ritor1
parents:
diff changeset
475 {
Ritor1
parents:
diff changeset
476 if ( a4 - HIDWORD(v10) == 4 )
Ritor1
parents:
diff changeset
477 v12 = v8->pMonsterInfo.field_3C_some_special_attack;
Ritor1
parents:
diff changeset
478 else
Ritor1
parents:
diff changeset
479 v12 = 4;
Ritor1
parents:
diff changeset
480 LABEL_30:
Ritor1
parents:
diff changeset
481 v14 = stru_50C198.CalcMagicalDamageToActor(v7, v12, v10);
Ritor1
parents:
diff changeset
482 v7->sCurrentHP -= v14;
Ritor1
parents:
diff changeset
483 if ( v14 )
Ritor1
parents:
diff changeset
484 {
Ritor1
parents:
diff changeset
485 if ( v7->sCurrentHP > 0 )
1060
b79139c3b5c8 some AI cleaning
zipi
parents: 1057
diff changeset
486 Actor::AI_Stun(uActorID, v17, 0);
0
Ritor1
parents:
diff changeset
487 else
Ritor1
parents:
diff changeset
488 Actor::Die(uActorID);
322
ce39b96acf5c Killing friendly peasants subs
Nomad
parents: 321
diff changeset
489 Actor::AggroSurroundingPeasants(uActorID, 0);
0
Ritor1
parents:
diff changeset
490 v18 = 20 * v14 / (signed int)v7->pMonsterInfo.uHP;
Ritor1
parents:
diff changeset
491 if ( 20 * v14 / (signed int)v7->pMonsterInfo.uHP > 10 )
Ritor1
parents:
diff changeset
492 v18 = 10;
Ritor1
parents:
diff changeset
493 if ( !MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
Ritor1
parents:
diff changeset
494 {
Ritor1
parents:
diff changeset
495 pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16;
Ritor1
parents:
diff changeset
496 pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16;
Ritor1
parents:
diff changeset
497 pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16;
Ritor1
parents:
diff changeset
498 v7->vVelocity.x = 50 * LOWORD(pVelocity->x);
Ritor1
parents:
diff changeset
499 v7->vVelocity.y = 50 * LOWORD(pVelocity->y);
Ritor1
parents:
diff changeset
500 v7->vVelocity.z = 50 * LOWORD(pVelocity->z);
Ritor1
parents:
diff changeset
501 }
322
ce39b96acf5c Killing friendly peasants subs
Nomad
parents: 321
diff changeset
502 Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v14);
0
Ritor1
parents:
diff changeset
503 }
Ritor1
parents:
diff changeset
504 else
Ritor1
parents:
diff changeset
505 {
1060
b79139c3b5c8 some AI cleaning
zipi
parents: 1057
diff changeset
506 Actor::AI_Stun(uActorID, v17, 0);
0
Ritor1
parents:
diff changeset
507 }
322
ce39b96acf5c Killing friendly peasants subs
Nomad
parents: 321
diff changeset
508 return;
0
Ritor1
parents:
diff changeset
509 }
Ritor1
parents:
diff changeset
510 v13 = v7->pMonsterInfo.uSpell2ID;
Ritor1
parents:
diff changeset
511 }
Ritor1
parents:
diff changeset
512 v12 = LOBYTE(pSpellStats->pInfos[v13].uSchool);
Ritor1
parents:
diff changeset
513 goto LABEL_30;
Ritor1
parents:
diff changeset
514 }
Ritor1
parents:
diff changeset
515 v12 = v8->pMonsterInfo.uAttack1Type;
Ritor1
parents:
diff changeset
516 goto LABEL_30;
Ritor1
parents:
diff changeset
517 }
Ritor1
parents:
diff changeset
518 }
Ritor1
parents:
diff changeset
519 }
Ritor1
parents:
diff changeset
520 }
Ritor1
parents:
diff changeset
521
Ritor1
parents:
diff changeset
522
Ritor1
parents:
diff changeset
523 //----- (0043F515) --------------------------------------------------------
657
7747161ea5b5 RenderBillboard member rename
Nomad
parents: 651
diff changeset
524 void FindBillboardsLightLevels_BLV()
0
Ritor1
parents:
diff changeset
525 {
Ritor1
parents:
diff changeset
526 for (uint i = 0; i < uNumBillboardsToDraw; ++i)
Ritor1
parents:
diff changeset
527 {
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1979
diff changeset
528 RenderBillboard* p = &pBillboardRenderList[i];
0
Ritor1
parents:
diff changeset
529
Ritor1
parents:
diff changeset
530 if (p->field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !p->uIndoorSectorID)
657
7747161ea5b5 RenderBillboard member rename
Nomad
parents: 651
diff changeset
531 p->dimming_level = 0;
0
Ritor1
parents:
diff changeset
532 else
657
7747161ea5b5 RenderBillboard member rename
Nomad
parents: 651
diff changeset
533 p->dimming_level = _43F55F_get_billboard_light_level(p, -1);
0
Ritor1
parents:
diff changeset
534 }
Ritor1
parents:
diff changeset
535 }
Ritor1
parents:
diff changeset
536
Ritor1
parents:
diff changeset
537 //----- (0043F55F) --------------------------------------------------------
Ritor1
parents:
diff changeset
538 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel)
Ritor1
parents:
diff changeset
539 {
Ritor1
parents:
diff changeset
540 signed int v3; // ecx@2
Ritor1
parents:
diff changeset
541
Ritor1
parents:
diff changeset
542 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
Ritor1
parents:
diff changeset
543 {
Ritor1
parents:
diff changeset
544 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
Ritor1
parents:
diff changeset
545 }
Ritor1
parents:
diff changeset
546 else
Ritor1
parents:
diff changeset
547 {
Ritor1
parents:
diff changeset
548 if ( uBaseLightLevel == -1 )
657
7747161ea5b5 RenderBillboard member rename
Nomad
parents: 651
diff changeset
549 v3 = a1->dimming_level;
0
Ritor1
parents:
diff changeset
550 else
Ritor1
parents:
diff changeset
551 v3 = uBaseLightLevel;
Ritor1
parents:
diff changeset
552 }
430
58b71c1af7d8 Objects are drawn (items, spells sfx)
Nomad
parents: 417
diff changeset
553 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z);
0
Ritor1
parents:
diff changeset
554 }
Ritor1
parents:
diff changeset
555
Ritor1
parents:
diff changeset
556 //----- (0043F5C8) --------------------------------------------------------
Ritor1
parents:
diff changeset
557 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z)
Ritor1
parents:
diff changeset
558 {
Ritor1
parents:
diff changeset
559 int v5; // esi@1
Ritor1
parents:
diff changeset
560 signed int v6; // edi@1
Ritor1
parents:
diff changeset
561 int v8; // eax@6
Ritor1
parents:
diff changeset
562 int v9; // ebx@6
Ritor1
parents:
diff changeset
563 unsigned int v10; // ecx@6
Ritor1
parents:
diff changeset
564 unsigned int v11; // edx@9
Ritor1
parents:
diff changeset
565 unsigned int v12; // edx@11
Ritor1
parents:
diff changeset
566 signed int v13; // ecx@12
Ritor1
parents:
diff changeset
567 BLVLightMM7 *v16; // esi@20
Ritor1
parents:
diff changeset
568 int v17; // ebx@21
Ritor1
parents:
diff changeset
569 int v18; // eax@24
Ritor1
parents:
diff changeset
570 int v19; // ebx@24
Ritor1
parents:
diff changeset
571 unsigned int v20; // ecx@24
Ritor1
parents:
diff changeset
572 int v21; // edx@25
Ritor1
parents:
diff changeset
573 unsigned int v22; // edx@27
Ritor1
parents:
diff changeset
574 unsigned int v23; // edx@29
Ritor1
parents:
diff changeset
575 signed int v24; // ecx@30
Ritor1
parents:
diff changeset
576 int v26; // ebx@35
Ritor1
parents:
diff changeset
577 int v27; // eax@38
Ritor1
parents:
diff changeset
578 int v28; // ebx@38
Ritor1
parents:
diff changeset
579 unsigned int v29; // ecx@38
Ritor1
parents:
diff changeset
580 int v30; // edx@39
Ritor1
parents:
diff changeset
581 unsigned int v31; // edx@41
Ritor1
parents:
diff changeset
582 unsigned int v32; // edx@43
Ritor1
parents:
diff changeset
583 signed int v33; // ecx@44
Ritor1
parents:
diff changeset
584 int v37; // [sp+Ch] [bp-18h]@37
Ritor1
parents:
diff changeset
585 int v38; // [sp+10h] [bp-14h]@5
Ritor1
parents:
diff changeset
586 int v39; // [sp+10h] [bp-14h]@23
Ritor1
parents:
diff changeset
587 int v40; // [sp+10h] [bp-14h]@36
Ritor1
parents:
diff changeset
588 int v42; // [sp+14h] [bp-10h]@22
Ritor1
parents:
diff changeset
589 unsigned int v43; // [sp+18h] [bp-Ch]@12
Ritor1
parents:
diff changeset
590 unsigned int v44; // [sp+18h] [bp-Ch]@30
Ritor1
parents:
diff changeset
591 unsigned int v45; // [sp+18h] [bp-Ch]@44
Ritor1
parents:
diff changeset
592
Ritor1
parents:
diff changeset
593 v6 = uBaseLightLevel;
Ritor1
parents:
diff changeset
594 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
Ritor1
parents:
diff changeset
595 {
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1979
diff changeset
596 MobileLight* p = &pMobileLightsStack->pLights[i];
0
Ritor1
parents:
diff changeset
597
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1979
diff changeset
598 float distX = abs(p->vPosition.x - x);
0
Ritor1
parents:
diff changeset
599 if ( distX <= p->uRadius)
Ritor1
parents:
diff changeset
600 {
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1979
diff changeset
601 float distY = abs(p->vPosition.y - y);
0
Ritor1
parents:
diff changeset
602 if ( distY <= p->uRadius)
Ritor1
parents:
diff changeset
603 {
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1979
diff changeset
604 float distZ = abs(p->vPosition.z - z);
0
Ritor1
parents:
diff changeset
605 if ( distZ <= p->uRadius)
Ritor1
parents:
diff changeset
606 {
Ritor1
parents:
diff changeset
607 v8 = distX;
Ritor1
parents:
diff changeset
608 v9 = distY;
Ritor1
parents:
diff changeset
609 v10 = distZ;
Ritor1
parents:
diff changeset
610 if (distX < distY)
Ritor1
parents:
diff changeset
611 {
Ritor1
parents:
diff changeset
612 v8 = distY;
Ritor1
parents:
diff changeset
613 v9 = distX;
Ritor1
parents:
diff changeset
614 }
Ritor1
parents:
diff changeset
615 if ( v8 < distZ )
Ritor1
parents:
diff changeset
616 {
Ritor1
parents:
diff changeset
617 v11 = v8;
Ritor1
parents:
diff changeset
618 v8 = distZ;
Ritor1
parents:
diff changeset
619 v10 = v11;
Ritor1
parents:
diff changeset
620 }
Ritor1
parents:
diff changeset
621 if ( v9 < (signed int)v10 )
Ritor1
parents:
diff changeset
622 {
Ritor1
parents:
diff changeset
623 v12 = v10;
Ritor1
parents:
diff changeset
624 v10 = v9;
Ritor1
parents:
diff changeset
625 v9 = v12;
Ritor1
parents:
diff changeset
626 }
Ritor1
parents:
diff changeset
627 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
Ritor1
parents:
diff changeset
628 v13 = p->uRadius;
Ritor1
parents:
diff changeset
629 if ( (signed int)v43 < v13 )
Ritor1
parents:
diff changeset
630 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
Ritor1
parents:
diff changeset
631 }
Ritor1
parents:
diff changeset
632 }
Ritor1
parents:
diff changeset
633 }
Ritor1
parents:
diff changeset
634 }
Ritor1
parents:
diff changeset
635
Ritor1
parents:
diff changeset
636 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
Ritor1
parents:
diff changeset
637 {
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1979
diff changeset
638 BLVSector* pSector = &pIndoor->pSectors[uSectorID];
0
Ritor1
parents:
diff changeset
639
Ritor1
parents:
diff changeset
640 for (uint i = 0; i < pSector->uNumLights; ++i)
Ritor1
parents:
diff changeset
641 {
Ritor1
parents:
diff changeset
642 v16 = pIndoor->pLights + pSector->pLights[i];
Ritor1
parents:
diff changeset
643 if (~v16->uAtributes & 8)
Ritor1
parents:
diff changeset
644 {
Ritor1
parents:
diff changeset
645 v17 = abs(v16->vPosition.x - x);
Ritor1
parents:
diff changeset
646 if ( v17 <= v16->uRadius )
Ritor1
parents:
diff changeset
647 {
Ritor1
parents:
diff changeset
648 v42 = abs(v16->vPosition.y - y);
Ritor1
parents:
diff changeset
649 if ( v42 <= v16->uRadius )
Ritor1
parents:
diff changeset
650 {
Ritor1
parents:
diff changeset
651 v39 = abs(v16->vPosition.z - z);
Ritor1
parents:
diff changeset
652 if ( v39 <= v16->uRadius )
Ritor1
parents:
diff changeset
653 {
Ritor1
parents:
diff changeset
654 v18 = v17;
Ritor1
parents:
diff changeset
655 v19 = v42;
Ritor1
parents:
diff changeset
656 v20 = v39;
Ritor1
parents:
diff changeset
657 if ( v18 < v42 )
Ritor1
parents:
diff changeset
658 {
Ritor1
parents:
diff changeset
659 v21 = v18;
Ritor1
parents:
diff changeset
660 v18 = v42;
Ritor1
parents:
diff changeset
661 v19 = v21;
Ritor1
parents:
diff changeset
662 }
Ritor1
parents:
diff changeset
663 if ( v18 < v39 )
Ritor1
parents:
diff changeset
664 {
Ritor1
parents:
diff changeset
665 v22 = v18;
Ritor1
parents:
diff changeset
666 v18 = v39;
Ritor1
parents:
diff changeset
667 v20 = v22;
Ritor1
parents:
diff changeset
668 }
Ritor1
parents:
diff changeset
669 if ( v19 < (signed int)v20 )
Ritor1
parents:
diff changeset
670 {
Ritor1
parents:
diff changeset
671 v23 = v20;
Ritor1
parents:
diff changeset
672 v20 = v19;
Ritor1
parents:
diff changeset
673 v19 = v23;
Ritor1
parents:
diff changeset
674 }
Ritor1
parents:
diff changeset
675 v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18;
Ritor1
parents:
diff changeset
676 v24 = v16->uRadius;
Ritor1
parents:
diff changeset
677 if ( (signed int)v44 < v24 )
Ritor1
parents:
diff changeset
678 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
Ritor1
parents:
diff changeset
679 }
Ritor1
parents:
diff changeset
680 }
Ritor1
parents:
diff changeset
681 }
Ritor1
parents:
diff changeset
682 }
Ritor1
parents:
diff changeset
683 }
Ritor1
parents:
diff changeset
684 }
Ritor1
parents:
diff changeset
685
Ritor1
parents:
diff changeset
686 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
Ritor1
parents:
diff changeset
687 {
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1979
diff changeset
688 StationaryLight* p = &pStationaryLightsStack->pLights[i];
0
Ritor1
parents:
diff changeset
689 v26 = abs(p->vPosition.x - x);
Ritor1
parents:
diff changeset
690 if ( v26 <= p->uRadius)
Ritor1
parents:
diff changeset
691 {
Ritor1
parents:
diff changeset
692 v40 = abs(p->vPosition.y - y);
Ritor1
parents:
diff changeset
693 if ( v40 <= p->uRadius)
Ritor1
parents:
diff changeset
694 {
Ritor1
parents:
diff changeset
695 v37 = abs(p->vPosition.z - z);
Ritor1
parents:
diff changeset
696 if ( v37 <= p->uRadius)
Ritor1
parents:
diff changeset
697 {
Ritor1
parents:
diff changeset
698 v27 = v26;
Ritor1
parents:
diff changeset
699 v28 = v40;
Ritor1
parents:
diff changeset
700 v29 = v37;
Ritor1
parents:
diff changeset
701 if ( v27 < v40 )
Ritor1
parents:
diff changeset
702 {
Ritor1
parents:
diff changeset
703 v30 = v27;
Ritor1
parents:
diff changeset
704 v27 = v40;
Ritor1
parents:
diff changeset
705 v28 = v30;
Ritor1
parents:
diff changeset
706 }
Ritor1
parents:
diff changeset
707 if ( v27 < v37 )
Ritor1
parents:
diff changeset
708 {
Ritor1
parents:
diff changeset
709 v31 = v27;
Ritor1
parents:
diff changeset
710 v27 = v37;
Ritor1
parents:
diff changeset
711 v29 = v31;
Ritor1
parents:
diff changeset
712 }
Ritor1
parents:
diff changeset
713 if ( v28 < (signed int)v29 )
Ritor1
parents:
diff changeset
714 {
Ritor1
parents:
diff changeset
715 v32 = v29;
Ritor1
parents:
diff changeset
716 v29 = v28;
Ritor1
parents:
diff changeset
717 v28 = v32;
Ritor1
parents:
diff changeset
718 }
Ritor1
parents:
diff changeset
719 v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27;
Ritor1
parents:
diff changeset
720 v33 = p->uRadius;
Ritor1
parents:
diff changeset
721 if ( (signed int)v45 < v33 )
Ritor1
parents:
diff changeset
722 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
Ritor1
parents:
diff changeset
723 }
Ritor1
parents:
diff changeset
724 }
Ritor1
parents:
diff changeset
725 }
Ritor1
parents:
diff changeset
726 }
Ritor1
parents:
diff changeset
727
Ritor1
parents:
diff changeset
728 if ( v6 <= 31 )
Ritor1
parents:
diff changeset
729 {
Ritor1
parents:
diff changeset
730 if ( v6 < 0 )
Ritor1
parents:
diff changeset
731 v6 = 0;
Ritor1
parents:
diff changeset
732 }
Ritor1
parents:
diff changeset
733 else
Ritor1
parents:
diff changeset
734 {
Ritor1
parents:
diff changeset
735 v6 = 31;
Ritor1
parents:
diff changeset
736 }
Ritor1
parents:
diff changeset
737 return v6;
Ritor1
parents:
diff changeset
738 }
Ritor1
parents:
diff changeset
739
Ritor1
parents:
diff changeset
740
Ritor1
parents:
diff changeset
741 //----- (004070EF) --------------------------------------------------------
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
742 bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID)
0
Ritor1
parents:
diff changeset
743 {
Ritor1
parents:
diff changeset
744 signed int v2; // eax@1
Ritor1
parents:
diff changeset
745 int v5; // ecx@2
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
746 int obj1_sector; // eax@4
0
Ritor1
parents:
diff changeset
747 float v8; // ST24_4@5
Ritor1
parents:
diff changeset
748 double v9; // ST18_8@5
Ritor1
parents:
diff changeset
749 int v11; // ecx@6
Ritor1
parents:
diff changeset
750 signed int v12; // eax@7
Ritor1
parents:
diff changeset
751 int v13; // esi@7
Ritor1
parents:
diff changeset
752 int v14; // esi@8
Ritor1
parents:
diff changeset
753 int v15; // esi@9
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
754 int obj2_z; // edi@11
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
755 int obj2_x; // esi@11
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
756 int obj2_sector; // eax@13
0
Ritor1
parents:
diff changeset
757 float v20; // ST24_4@14
Ritor1
parents:
diff changeset
758 double v21; // ST18_8@14
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
759 int dist_x; // ebx@16
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
760 signed int dist_3d; // ecx@16
0
Ritor1
parents:
diff changeset
761 int v25; // eax@18
Ritor1
parents:
diff changeset
762 BLVFace *v29; // ebx@32
Ritor1
parents:
diff changeset
763 Vec3_short_ *v30; // esi@32
Ritor1
parents:
diff changeset
764 int v31; // eax@32
Ritor1
parents:
diff changeset
765 int v32; // ST50_4@44
Ritor1
parents:
diff changeset
766 int v33; // ST54_4@44
Ritor1
parents:
diff changeset
767 int v34; // eax@44
Ritor1
parents:
diff changeset
768 signed int v38; // esi@45
Ritor1
parents:
diff changeset
769 signed __int64 v40; // qtt@50
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
770 __int16 next_sector; // bx@58
0
Ritor1
parents:
diff changeset
771 int v43; // [sp-8h] [bp-70h]@11
Ritor1
parents:
diff changeset
772 int v44; // [sp-4h] [bp-6Ch]@11
Ritor1
parents:
diff changeset
773 int v47; // [sp+18h] [bp-50h]@20
Ritor1
parents:
diff changeset
774 int v48; // [sp+1Ch] [bp-4Ch]@20
Ritor1
parents:
diff changeset
775 int v49; // [sp+20h] [bp-48h]@20
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
776 int dist_z; // [sp+24h] [bp-44h]@16
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
777 signed int higher_z; // [sp+24h] [bp-44h]@27
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
778 signed int lower_z; // [sp+28h] [bp-40h]@26
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
779 signed int higher_y; // [sp+2Ch] [bp-3Ch]@23
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
780 signed int lower_y; // [sp+30h] [bp-38h]@22
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
781 signed int higher_x; // [sp+34h] [bp-34h]@21
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
782 signed int lower_x; // [sp+38h] [bp-30h]@20
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
783 signed int sectors_visited; // [sp+3Ch] [bp-2Ch]@28
0
Ritor1
parents:
diff changeset
784 int v58; // [sp+44h] [bp-24h]@50
Ritor1
parents:
diff changeset
785 int v59; // [sp+48h] [bp-20h]@44
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
786 int obj2_y; // [sp+50h] [bp-18h]@11
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
787 int obj1_x; // [sp+58h] [bp-10h]@4
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
788 int obj1_y; // [sp+5Ch] [bp-Ch]@4
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
789 int obj1_z; // [sp+60h] [bp-8h]@4
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
790 int current_sector; // [sp+64h] [bp-4h]@7
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
791 int dist_y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
792 int v70;
0
Ritor1
parents:
diff changeset
793
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 839
diff changeset
794 v2 = PID_ID(uObjID);
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
795 switch( PID_TYPE(uObjID) )
0
Ritor1
parents:
diff changeset
796 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
797 case OBJECT_Decoration:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
798 obj1_x = pLevelDecorations[v2].vPosition.x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
799 obj1_y = pLevelDecorations[v2].vPosition.y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
800 obj1_z = pLevelDecorations[v2].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
801 obj1_sector = pIndoor->GetSector(obj1_x, obj1_y, obj1_z);
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
802 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
803 case OBJECT_Actor:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
804 obj1_x = pActors[v2].vPosition.x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
805 obj1_y = pActors[v2].vPosition.y;
0
Ritor1
parents:
diff changeset
806 v8 = (double)pActors[v2].uActorHeight * 0.69999999;
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
807 //v9 = v8 + 6.7553994e15;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
808 //obj1_z = LODWORD(v9) + pActors[v2].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
809 obj1_z = (int)v8 + pActors[v2].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
810 obj1_sector = pActors[v2].uSectorID;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
811 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
812 case OBJECT_Item:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
813 obj1_x = pSpriteObjects[v2].vPosition.x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
814 obj1_y = pSpriteObjects[v2].vPosition.y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
815 obj1_z = pSpriteObjects[v2].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
816 obj1_sector = pSpriteObjects[v2].uSectorID;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
817 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
818 default:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
819 return 0;
0
Ritor1
parents:
diff changeset
820 }
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
821 v12 = PID_ID(uObj2ID);
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
822 switch( PID_TYPE(uObj2ID) )
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
823 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
824 case OBJECT_Decoration:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
825 obj2_z = pLevelDecorations[v12].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
826 obj2_x = pLevelDecorations[v12].vPosition.x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
827 obj2_y = pLevelDecorations[v12].vPosition.y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
828 obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z);
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
829 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
830 case OBJECT_Player:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
831 obj2_x = pParty->vPosition.x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
832 obj2_z = pParty->sEyelevel + pParty->vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
833 obj2_y = pParty->vPosition.y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
834 obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z);
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
835 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
836 case OBJECT_Actor:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
837 obj2_y = pActors[v12].vPosition.y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
838 obj2_x = pActors[v12].vPosition.x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
839 v20 = (double)pActors[v12].uActorHeight * 0.69999999;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
840 //v21 = v20 + 6.7553994e15;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
841 //obj2_z = LODWORD(v21) + pActors[v12].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
842 obj2_z = (int)v20 + pActors[v12].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
843 obj2_sector = pActors[v12].uSectorID;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
844 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
845 case OBJECT_Item:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
846 obj2_x = pSpriteObjects[v12].vPosition.x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
847 obj2_z = pSpriteObjects[v12].vPosition.z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
848 obj2_y = pSpriteObjects[v12].vPosition.y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
849 obj2_sector = pSpriteObjects[v12].uSectorID;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
850 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
851 default:
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
852 return 0;
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
853 }
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
854 dist_x = obj2_x - obj1_x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
855 dist_z = obj2_z - obj1_z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
856 dist_y = obj2_y - obj1_y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
857 dist_3d = integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z);
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
858 //range check
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
859 if ( dist_3d > 5120 )
0
Ritor1
parents:
diff changeset
860 return 0;
Ritor1
parents:
diff changeset
861 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
Ritor1
parents:
diff changeset
862 return 1;
Ritor1
parents:
diff changeset
863 v25 = 65536;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
864 if ( dist_3d )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
865 v25 = 65536 / dist_3d;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
866 v49 = dist_x * v25;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
867 v47 = dist_z * v25;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
868 v48 = dist_y * v25;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
869 if ( obj1_x < obj2_x )
0
Ritor1
parents:
diff changeset
870 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
871 lower_x = obj1_x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
872 higher_x = obj2_x;
0
Ritor1
parents:
diff changeset
873 }
Ritor1
parents:
diff changeset
874 else
Ritor1
parents:
diff changeset
875 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
876 lower_x = obj2_x;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
877 higher_x = obj1_x;
0
Ritor1
parents:
diff changeset
878 }
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
879 if ( obj1_y < obj2_y )
0
Ritor1
parents:
diff changeset
880 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
881 lower_y = obj1_y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
882 higher_y = obj2_y;
0
Ritor1
parents:
diff changeset
883 }
Ritor1
parents:
diff changeset
884 else
Ritor1
parents:
diff changeset
885 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
886 lower_y = obj2_y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
887 higher_y = obj1_y;
0
Ritor1
parents:
diff changeset
888 }
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
889 if ( obj1_z < obj2_z )
0
Ritor1
parents:
diff changeset
890 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
891 lower_z = obj1_z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
892 higher_z = obj2_z;
0
Ritor1
parents:
diff changeset
893 }
Ritor1
parents:
diff changeset
894 else
Ritor1
parents:
diff changeset
895 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
896 lower_z = obj2_z;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
897 higher_z = obj1_z;
0
Ritor1
parents:
diff changeset
898 }
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
899 sectors_visited = 0;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
900 //monster in same sector with player
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
901 if ( obj1_sector == obj2_sector )
0
Ritor1
parents:
diff changeset
902 return 1;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
903 //search starts from monster
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
904 current_sector = obj1_sector;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
905 for( int current_portal = 0; current_portal < pIndoor->pSectors[current_sector].uNumPortals; current_portal++ )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
906 {
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
907 v29 = &pIndoor->pFaces[pIndoor->pSectors[current_sector].pPortals[current_portal]];
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
908 v30 = &pIndoor->pVertices[*v29->pVertexIDs];
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
909 v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj1_z)
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
910 + v29->pFacePlane_old.vNormal.y * (v30->y - obj1_y)
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
911 + v29->pFacePlane_old.vNormal.x * (v30->x - obj1_x);
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
912
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
913 if ( current_sector != v29->uSectorID )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
914 v31 = -v31;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
915
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
916 if ( v31 >= 0 && v30->x != obj1_x && v30->y != obj1_y && v30->z != obj1_z)
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
917 continue;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
918
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
919 if( lower_x > v29->pBounding.x2
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
920 || higher_x < v29->pBounding.x1
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
921 || lower_y > v29->pBounding.y2
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
922 || higher_y < v29->pBounding.y1
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
923 || lower_z > v29->pBounding.z2
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
924 || higher_z < v29->pBounding.z1 )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
925 {
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
926 continue;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
927 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
928
1643
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
929 v32 = fixpoint_mul(v29->pFacePlane_old.vNormal.x,v49);
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
930 v33 = fixpoint_mul(v29->pFacePlane_old.vNormal.z,v47);
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
931 v34 = fixpoint_mul(v29->pFacePlane_old.vNormal.y,v48);
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
932 v59 = v32 + v33 + v34;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
933 if ( v59 )
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
934 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
935 v70 = v29->pFacePlane_old.dist
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
936 + obj1_z * v29->pFacePlane_old.vNormal.z
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
937 + obj1_x * v29->pFacePlane_old.vNormal.x
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
938 + obj1_y * v29->pFacePlane_old.vNormal.y;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
939 v38 = -v70;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
940
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
941 // if ( v59 <= 0 ^ v70 <= 0 )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
942
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
943 /* TEMPORARY
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
944 if ( v59 <= 0 && v70 <= 0 )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
945 {
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
946 continue;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
947 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
948 if ( !(v59 <= 0 && v70 <= 0) )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
949 {
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
950 continue;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
951 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
952 */
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
953
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
954 if( abs(v38) >> 14 > abs(v59) )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
955 continue;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
956
1643
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
957 v58 = fixpoint_div(v38,v59);
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
958
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
959 if( v58 < 0 )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
960 {
1616
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
961 continue;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
962 }
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
963
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
964 if(!sub_4075DB(
1643
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
965 obj1_x + ((fixpoint_mul(v49,v58) + 32768) >> 16),
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
966 obj1_y + ((fixpoint_mul(v48,v58) + 32768) >> 16),
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
967 obj1_z + ((fixpoint_mul(v47,v58) + 32768) >> 16),
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
968 v29) )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
969 {
1616
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
970 continue;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
971 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
972
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
973 //if there is no next sector turn back
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
974 if ( v29->uSectorID == current_sector )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
975 next_sector = v29->uBackSectorID;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
976 else
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
977 next_sector = v29->uSectorID;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
978
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
979 //no more portals, quit
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
980 if ( next_sector == current_sector )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
981 {
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
982 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
983 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
984
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
985 ++sectors_visited;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
986 current_sector = next_sector;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
987
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
988 //found player, quit
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
989 if ( next_sector == obj2_sector )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
990 return 1;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
991
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
992 current_sector = next_sector;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
993
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
994 //did we hit limit for portals?
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
995 //does the next room have portals?
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
996 if ( sectors_visited < 30 && pIndoor->pSectors[current_sector].uNumPortals > 0)
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
997 {
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
998 current_portal=-1;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
999 continue;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1000 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1001 else
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1002 break;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1003 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1004 }
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1005 //did we stop in the sector where player is?
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1006 if ( current_sector != obj2_sector )
0
Ritor1
parents:
diff changeset
1007 return 0;
Ritor1
parents:
diff changeset
1008 return 1;
Ritor1
parents:
diff changeset
1009 }
Ritor1
parents:
diff changeset
1010
Ritor1
parents:
diff changeset
1011 //----- (004075DB) --------------------------------------------------------
1616
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
1012 bool __fastcall sub_4075DB(int x, int y, int z, BLVFace *a4)
0
Ritor1
parents:
diff changeset
1013 {
Ritor1
parents:
diff changeset
1014 unsigned int v5; // esi@1
Ritor1
parents:
diff changeset
1015 char v7; // zf@2
Ritor1
parents:
diff changeset
1016 int v8; // edi@2
Ritor1
parents:
diff changeset
1017 Vec3_short_ *v9; // ecx@3
Ritor1
parents:
diff changeset
1018 int v10; // edx@4
Ritor1
parents:
diff changeset
1019 Vec3_short_ *v12; // ecx@8
Ritor1
parents:
diff changeset
1020 int v13; // edx@9
Ritor1
parents:
diff changeset
1021 Vec3_short_ *v15; // ecx@12
Ritor1
parents:
diff changeset
1022 int v16; // edx@13
Ritor1
parents:
diff changeset
1023 bool v18; // esi@14
Ritor1
parents:
diff changeset
1024 int v19; // ecx@14
Ritor1
parents:
diff changeset
1025 int v20; // ecx@16
Ritor1
parents:
diff changeset
1026 int v21; // edx@16
Ritor1
parents:
diff changeset
1027 int v22; // eax@17
Ritor1
parents:
diff changeset
1028 signed int v23; // ebx@18
Ritor1
parents:
diff changeset
1029 int v24; // esi@20
Ritor1
parents:
diff changeset
1030 signed int v25; // eax@22
Ritor1
parents:
diff changeset
1031 signed __int64 v26; // qtt@22
Ritor1
parents:
diff changeset
1032 bool result; // eax@25
Ritor1
parents:
diff changeset
1033 int v29; // [sp+10h] [bp-Ch]@14
Ritor1
parents:
diff changeset
1034 signed int a3a; // [sp+24h] [bp+8h]@14
Ritor1
parents:
diff changeset
1035 int a4a; // [sp+28h] [bp+Ch]@2
Ritor1
parents:
diff changeset
1036
1493
9e9a12506d51 player detection partly working
zipi
parents: 1477
diff changeset
1037 //__debugbreak();
1458
934074e7fcc1 ModalWindow
Nomad
parents: 1455
diff changeset
1038
0
Ritor1
parents:
diff changeset
1039 v5 = a4->uAttributes;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1040 v9 = pIndoor->pVertices;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1041 if ( v5 & FACE_XY_PLANE )
0
Ritor1
parents:
diff changeset
1042 {
1616
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
1043 a4a = x;
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
1044 v8 = y;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1045 for(int i = 0; i < a4->uNumVertices; i++)
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1046 {
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1047 dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].x;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1048 dword_4F5CC8_ys[i] = v9[a4->pVertexIDs[i]].y;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1049 }
0
Ritor1
parents:
diff changeset
1050 }
Ritor1
parents:
diff changeset
1051 else
Ritor1
parents:
diff changeset
1052 {
1616
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
1053 v8 = z;
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
1054 if ( v5 & FACE_XZ_PLANE )
0
Ritor1
parents:
diff changeset
1055 {
1616
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
1056 a4a = x;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1057 for(int i = 0; i < a4->uNumVertices; i++)
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1058 {
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1059 dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].x;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1060 dword_4F5CC8_ys[i] = v9[a4->pVertexIDs[i]].z;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1061 }
0
Ritor1
parents:
diff changeset
1062 }
Ritor1
parents:
diff changeset
1063 else
Ritor1
parents:
diff changeset
1064 {
1616
de6e646822a6 mul <> sub0 difference
zipi
parents: 1615
diff changeset
1065 a4a = y;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1066 for(int i = 0; i < a4->uNumVertices; i++)
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1067 {
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1068 dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].y;
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1069 dword_4F5CC8_ys[i] = v9[a4->pVertexIDs[i]].z;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1070 }
0
Ritor1
parents:
diff changeset
1071 }
Ritor1
parents:
diff changeset
1072 }
Ritor1
parents:
diff changeset
1073 a3a = 0;
1471
736973e11d11 sub_4075DB cleaned
zipi
parents: 1469
diff changeset
1074 dword_4F5D98_xs[a4->uNumVertices] = dword_4F5D98_xs[0];
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1075 dword_4F5CC8_ys[a4->uNumVertices] = dword_4F5CC8_ys[0];
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1076 for(int i = 0; i < a4->uNumVertices && a3a < 2; i++)
0
Ritor1
parents:
diff changeset
1077 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1078 if ( dword_4F5CC8_ys[i] >= v8 ^ (dword_4F5CC8_ys[i + 1] >= v8) )
0
Ritor1
parents:
diff changeset
1079 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1080 //if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a)
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1081 if( !(dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] < a4a))
0
Ritor1
parents:
diff changeset
1082 {
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1083 if ( (dword_4F5D98_xs[i + 1] < a4a && dword_4F5D98_xs[i] >= a4a) )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1084 ++a3a;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1085 //|| (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],LODWORD(v26) = v25 << 16, HIDWORD(v26) = v25 >> 16,
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1086 //dword_4F5D98_xs[i] + ((signed int)(((unsigned __int64)(v26 / (dword_4F5CC4_ys[i + 2] - dword_4F5CC4_ys[i + 1])* ((v8 - dword_4F5CC4_ys[i + 1]) << 16)) >> 16)
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1087 // + 32768) >> 16) >= a4a) )
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1088 else
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1089 {
1643
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
1090 v25 = fixpoint_div(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]);
7182930263b3 fixpoint functions renaming
zipi
parents: 1637
diff changeset
1091 if( dword_4F5D98_xs[i] + (fixpoint_mul(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 32768 >> 16) >= a4a)
1615
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1092 ++a3a;
89dec2be255f AI visibility issue temporarily fixed
zipi
parents: 1614
diff changeset
1093 }
0
Ritor1
parents:
diff changeset
1094 }
Ritor1
parents:
diff changeset
1095 }
Ritor1
parents:
diff changeset
1096 }
Ritor1
parents:
diff changeset
1097 result = 1;
Ritor1
parents:
diff changeset
1098 if ( a3a != 1 )
Ritor1
parents:
diff changeset
1099 result = 0;
Ritor1
parents:
diff changeset
1100 return result;
Ritor1
parents:
diff changeset
1101 }
Ritor1
parents:
diff changeset
1102
Ritor1
parents:
diff changeset
1103 //----- (004077F1) --------------------------------------------------------
Ritor1
parents:
diff changeset
1104 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *a4, BSPVertexBuffer *a5)
Ritor1
parents:
diff changeset
1105 {
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1106 //ODMFace *v5; // eax@1
1473
zipi
parents: 1472
diff changeset
1107 Vec3_int_ *v9;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1108 unsigned int v5; // esi@1
0
Ritor1
parents:
diff changeset
1109 signed int v7; // edi@1
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1110 //char v8; // zf@2
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1111 //unsigned __int16 *v9; // edx@3
0
Ritor1
parents:
diff changeset
1112 int v10; // ecx@4
Ritor1
parents:
diff changeset
1113 unsigned __int16 *v11; // edx@8
Ritor1
parents:
diff changeset
1114 int v12; // ecx@9
Ritor1
parents:
diff changeset
1115 int v13; // edx@12
Ritor1
parents:
diff changeset
1116 int v14; // ecx@13
Ritor1
parents:
diff changeset
1117 int v15; // esi@14
Ritor1
parents:
diff changeset
1118 bool v16; // edi@14
Ritor1
parents:
diff changeset
1119 int v17; // ecx@16
Ritor1
parents:
diff changeset
1120 int v18; // edx@16
Ritor1
parents:
diff changeset
1121 int v19; // eax@17
Ritor1
parents:
diff changeset
1122 signed int v20; // ebx@18
Ritor1
parents:
diff changeset
1123 int v21; // edi@20
Ritor1
parents:
diff changeset
1124 signed int v22; // eax@22
Ritor1
parents:
diff changeset
1125 signed __int64 v23; // qtt@22
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1126 //bool result; // eax@25
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1127 //int v25; // [sp+14h] [bp-8h]@14
0
Ritor1
parents:
diff changeset
1128 int a4a; // [sp+28h] [bp+Ch]@2
Ritor1
parents:
diff changeset
1129 signed int a5a; // [sp+2Ch] [bp+10h]@14
Ritor1
parents:
diff changeset
1130
1458
934074e7fcc1 ModalWindow
Nomad
parents: 1455
diff changeset
1131 __debugbreak();
934074e7fcc1 ModalWindow
Nomad
parents: 1455
diff changeset
1132
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1133 v5 = a4->uAttributes;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1134 v9 = a5->pVertices;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1135 if ( v5 & FACE_XY_PLANE )
0
Ritor1
parents:
diff changeset
1136 {
Ritor1
parents:
diff changeset
1137 a4a = a1;
Ritor1
parents:
diff changeset
1138 a3 = a2;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1139 for(int i = 0; i < a4->uNumVertices; i++)
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1140 {
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1141 dword_4F5BF4_xs[i+1] = v9[a4->pVertexIDs[i]].x;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1142 dword_4F5B24_ys[i+1] = v9[a4->pVertexIDs[i]].y;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1143 }
0
Ritor1
parents:
diff changeset
1144 }
Ritor1
parents:
diff changeset
1145 else
Ritor1
parents:
diff changeset
1146 {
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1147 if ( v5 & FACE_XY_PLANE )
0
Ritor1
parents:
diff changeset
1148 {
Ritor1
parents:
diff changeset
1149 a4a = a1;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1150 for(int i = 0; i < a4->uNumVertices; i++)
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1151 {
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1152 dword_4F5BF4_xs[i+1] = v9[a4->pVertexIDs[i]].x;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1153 dword_4F5B24_ys[i+1] = v9[a4->pVertexIDs[i]].z;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1154 }
0
Ritor1
parents:
diff changeset
1155 }
Ritor1
parents:
diff changeset
1156 else
Ritor1
parents:
diff changeset
1157 {
Ritor1
parents:
diff changeset
1158 a4a = a2;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1159 for(int i = 0; i < a4->uNumVertices; i++)
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1160 {
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1161 dword_4F5BF4_xs[i+1] = v9[a4->pVertexIDs[i]].y;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1162 dword_4F5B24_ys[i+1] = v9[a4->pVertexIDs[i]].z;
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1163 }
0
Ritor1
parents:
diff changeset
1164 }
Ritor1
parents:
diff changeset
1165 }
Ritor1
parents:
diff changeset
1166 a5a = 0;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1167 dword_4F5BF4_xs[a4->uNumVertices + 1] = dword_4F5BF4_xs[1];
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1168 dword_4F5B24_ys[a4->uNumVertices + 1] = dword_4F5B24_ys[1];
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1169 for(int i = 0; i < a4->uNumVertices; i++)
0
Ritor1
parents:
diff changeset
1170 {
Ritor1
parents:
diff changeset
1171 if ( a5a >= 2 )
Ritor1
parents:
diff changeset
1172 break;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1173 if ( dword_4F5B24_ys[i + 1] >= a3 ^ (dword_4F5B24_ys[i + 2] >= a3) )
0
Ritor1
parents:
diff changeset
1174 {
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1175 if( dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a)
0
Ritor1
parents:
diff changeset
1176 {
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1177 if (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a)
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1178 ++a5a;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1179 else
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1180 {
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1181 v23 = (__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1182 __int64 _a = dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1];
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1183 __int64 _b = (__int64)(a3 - dword_4F5B24_ys[i + 1]) << 16;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1184
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1185 if (dword_4F5BF4_xs[i + 1] + ((((v23 / _a * _b) >> 16) + 32768) >> 16) >= a4a)
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1186 ++a5a;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1187 }
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1188 }
0
Ritor1
parents:
diff changeset
1189 }
Ritor1
parents:
diff changeset
1190 }
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1191
0
Ritor1
parents:
diff changeset
1192 if ( a5a != 1 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1193 return false;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1520
diff changeset
1194 return true;
1472
2395e99b89d0 sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents: 1471
diff changeset
1195
0
Ritor1
parents:
diff changeset
1196 }
Ritor1
parents:
diff changeset
1197
Ritor1
parents:
diff changeset
1198 //----- (004088E9) --------------------------------------------------------
1459
2ca62c9e7b3c Function names
Nomad
parents: 1458
diff changeset
1199 int __fastcall sub_4088E9(int x1, int y1, int x2, int y2, int x3, int y3)
0
Ritor1
parents:
diff changeset
1200 {
Ritor1
parents:
diff changeset
1201 int v8; // eax@1
Ritor1
parents:
diff changeset
1202 signed int result; // eax@1
Ritor1
parents:
diff changeset
1203 int v11; // [sp+18h] [bp+8h]@1
Ritor1
parents:
diff changeset
1204
1459
2ca62c9e7b3c Function names
Nomad
parents: 1458
diff changeset
1205 v11 = abs(x2 - x1);
2ca62c9e7b3c Function names
Nomad
parents: 1458
diff changeset
1206 v8 = abs(y2 - y1);
295
640a176c030f sub_42ECB5
Nomad
parents: 275
diff changeset
1207 result = integer_sqrt(v11 * v11 + v8 * v8);
0
Ritor1
parents:
diff changeset
1208 if ( result )
1459
2ca62c9e7b3c Function names
Nomad
parents: 1458
diff changeset
1209 result = abs(((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / result);
0
Ritor1
parents:
diff changeset
1210 return result;
Ritor1
parents:
diff changeset
1211 }
Ritor1
parents:
diff changeset
1212
Ritor1
parents:
diff changeset
1213 //----- (0040DEF3) --------------------------------------------------------
949
Nomad
parents: 948
diff changeset
1214 unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
983
1462a5f12b65 Character Skills tab drawing fixed.
Nomad
parents: 982
diff changeset
1215 {
688
c0bfb386b15f some ui cleanup
Gloval
parents: 676
diff changeset
1216 return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) +
c0bfb386b15f some ui cleanup
Gloval
parents: 676
diff changeset
1217 LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) +
c0bfb386b15f some ui cleanup
Gloval
parents: 676
diff changeset
1218 LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
0
Ritor1
parents:
diff changeset
1219 }
Ritor1
parents:
diff changeset
1220
1184
a90dc4aee8f4 arcomage refactoring continued
Gloval
parents: 1183
diff changeset
1221
0
Ritor1
parents:
diff changeset
1222
Ritor1
parents:
diff changeset
1223 //----- (0040F82D) --------------------------------------------------------
Ritor1
parents:
diff changeset
1224 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue)
Ritor1
parents:
diff changeset
1225 {
973
ec7568e13b24 Minor code cleaning.
Nomad
parents: 972
diff changeset
1226 assert(uTextureId != -1);
ec7568e13b24 Minor code cleaning.
Nomad
parents: 972
diff changeset
1227 ZBuffer_DoFill(pZBuffer, pIcons_LOD->GetTexture(uTextureId), iZValue);
0
Ritor1
parents:
diff changeset
1228 }
Ritor1
parents:
diff changeset
1229
1160
502b8b2e36b4 font cleaning
Gloval
parents: 1118
diff changeset
1230
0
Ritor1
parents:
diff changeset
1231
Ritor1
parents:
diff changeset
1232 //----- (0040F89C) --------------------------------------------------------
Ritor1
parents:
diff changeset
1233 void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue)
Ritor1
parents:
diff changeset
1234 {
Ritor1
parents:
diff changeset
1235 void *v3; // eax@3
Ritor1
parents:
diff changeset
1236 void *v4; // esi@5
Ritor1
parents:
diff changeset
1237 int *v5; // edi@5
Ritor1
parents:
diff changeset
1238 int v6; // eax@5
Ritor1
parents:
diff changeset
1239 int v7; // ecx@6
Ritor1
parents:
diff changeset
1240 Texture *v8; // [sp+Ch] [bp-14h]@1
Ritor1
parents:
diff changeset
1241 int *v9; // [sp+10h] [bp-10h]@1
Ritor1
parents:
diff changeset
1242 int v10; // [sp+14h] [bp-Ch]@1
Ritor1
parents:
diff changeset
1243 int v11; // [sp+18h] [bp-8h]@1
Ritor1
parents:
diff changeset
1244 void *v12; // [sp+1Ch] [bp-4h]@5
Ritor1
parents:
diff changeset
1245
Ritor1
parents:
diff changeset
1246 v10 = pTex->uTextureWidth;
Ritor1
parents:
diff changeset
1247 v8 = pTex;
Ritor1
parents:
diff changeset
1248 v9 = pZBuffer;
Ritor1
parents:
diff changeset
1249 v11 = pTex->uTextureHeight;
Ritor1
parents:
diff changeset
1250 if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize )
Ritor1
parents:
diff changeset
1251 v3 = pTex->UnzipPalette();
Ritor1
parents:
diff changeset
1252 else
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 709
diff changeset
1253 v3 = pTex->pLevelOfDetail0_prolly_alpha_mask;
0
Ritor1
parents:
diff changeset
1254 v12 = v3;
Ritor1
parents:
diff changeset
1255 v4 = v3;
Ritor1
parents:
diff changeset
1256 v5 = v9;
Ritor1
parents:
diff changeset
1257 v6 = 0;
Ritor1
parents:
diff changeset
1258 do
Ritor1
parents:
diff changeset
1259 {
Ritor1
parents:
diff changeset
1260 v7 = v10;
Ritor1
parents:
diff changeset
1261 do
Ritor1
parents:
diff changeset
1262 {
Ritor1
parents:
diff changeset
1263 LOBYTE(v6) = *(char *)v4;
Ritor1
parents:
diff changeset
1264 v4 = (char *)v4 + 1;
Ritor1
parents:
diff changeset
1265 if ( v6 )
Ritor1
parents:
diff changeset
1266 *v5 = uZValue;
Ritor1
parents:
diff changeset
1267 ++v5;
Ritor1
parents:
diff changeset
1268 --v7;
Ritor1
parents:
diff changeset
1269 }
Ritor1
parents:
diff changeset
1270 while ( v7 );
Ritor1
parents:
diff changeset
1271 v5 += 640 - v10;
Ritor1
parents:
diff changeset
1272 --v11;
Ritor1
parents:
diff changeset
1273 }
Ritor1
parents:
diff changeset
1274 while ( v11 );
Ritor1
parents:
diff changeset
1275 if ( pIcons_LOD->dword_011BA4 )
Ritor1
parents:
diff changeset
1276 {
Ritor1
parents:
diff changeset
1277 if ( v8->uDecompressedSize )
Ritor1
parents:
diff changeset
1278 free(v12);
Ritor1
parents:
diff changeset
1279 }
Ritor1
parents:
diff changeset
1280 }
Ritor1
parents:
diff changeset
1281
Ritor1
parents:
diff changeset
1282 //----- (0040F92A) --------------------------------------------------------
1458
934074e7fcc1 ModalWindow
Nomad
parents: 1455
diff changeset
1283 void __fastcall ZBuffer_DoFill2(int *pZBuffer, Texture *a2, int a3)
0
Ritor1
parents:
diff changeset
1284 {
Ritor1
parents:
diff changeset
1285 Texture *v3; // esi@1
Ritor1
parents:
diff changeset
1286 void *v4; // eax@3
Ritor1
parents:
diff changeset
1287 int *v5; // edi@5
Ritor1
parents:
diff changeset
1288 int v6; // ecx@6
Ritor1
parents:
diff changeset
1289 int *v7; // [sp+Ch] [bp-10h]@1
Ritor1
parents:
diff changeset
1290 int v8; // [sp+10h] [bp-Ch]@1
Ritor1
parents:
diff changeset
1291 int v9; // [sp+18h] [bp-4h]@1
Ritor1
parents:
diff changeset
1292
Ritor1
parents:
diff changeset
1293 v3 = a2;
Ritor1
parents:
diff changeset
1294 v7 = pZBuffer;
Ritor1
parents:
diff changeset
1295 v8 = a2->uTextureWidth;
Ritor1
parents:
diff changeset
1296 v9 = a2->uTextureHeight;
Ritor1
parents:
diff changeset
1297 if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize )
Ritor1
parents:
diff changeset
1298 v4 = a2->UnzipPalette();
Ritor1
parents:
diff changeset
1299 else
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 709
diff changeset
1300 v4 = a2->pLevelOfDetail0_prolly_alpha_mask;
0
Ritor1
parents:
diff changeset
1301 v5 = v7;
Ritor1
parents:
diff changeset
1302 do
Ritor1
parents:
diff changeset
1303 {
Ritor1
parents:
diff changeset
1304 v6 = v8;
Ritor1
parents:
diff changeset
1305 do
Ritor1
parents:
diff changeset
1306 {
Ritor1
parents:
diff changeset
1307 *v5 = a3;
Ritor1
parents:
diff changeset
1308 ++v5;
Ritor1
parents:
diff changeset
1309 --v6;
Ritor1
parents:
diff changeset
1310 }
Ritor1
parents:
diff changeset
1311 while ( v6 );
Ritor1
parents:
diff changeset
1312 v5 += 640 - v8;
Ritor1
parents:
diff changeset
1313 --v9;
Ritor1
parents:
diff changeset
1314 }
Ritor1
parents:
diff changeset
1315 while ( v9 );
Ritor1
parents:
diff changeset
1316 if ( pIcons_LOD->dword_011BA4 )
Ritor1
parents:
diff changeset
1317 {
Ritor1
parents:
diff changeset
1318 if ( v3->uDecompressedSize )
Ritor1
parents:
diff changeset
1319 free(v4);
Ritor1
parents:
diff changeset
1320 }
Ritor1
parents:
diff changeset
1321 }
Ritor1
parents:
diff changeset
1322
Ritor1
parents:
diff changeset
1323 //----- (00410D99) --------------------------------------------------------
1458
934074e7fcc1 ModalWindow
Nomad
parents: 1455
diff changeset
1324 int __fastcall sub_410D99_get_map_index(int a1)
0
Ritor1
parents:
diff changeset
1325 {
Ritor1
parents:
diff changeset
1326 int v1; // edi@1
Ritor1
parents:
diff changeset
1327 signed int v2; // ebp@1
Ritor1
parents:
diff changeset
1328 const char **v3; // esi@2
Ritor1
parents:
diff changeset
1329 char *v4; // ebx@2
Ritor1
parents:
diff changeset
1330
Ritor1
parents:
diff changeset
1331 v1 = a1;
Ritor1
parents:
diff changeset
1332 v2 = 1;
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1101
diff changeset
1333 if ( _stricmp(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) )
0
Ritor1
parents:
diff changeset
1334 {
Ritor1
parents:
diff changeset
1335 v3 = (const char **)&pMapStats->pInfos[1].pFilename;
Ritor1
parents:
diff changeset
1336 v4 = (char *)&pMapStats->pInfos[1].pFilename;
Ritor1
parents:
diff changeset
1337 do
Ritor1
parents:
diff changeset
1338 {
Ritor1
parents:
diff changeset
1339 if ( !*(int *)v4 )
Ritor1
parents:
diff changeset
1340 break;
Ritor1
parents:
diff changeset
1341 v3 += 17;
Ritor1
parents:
diff changeset
1342 ++v2;
Ritor1
parents:
diff changeset
1343 v4 = (char *)v3;
Ritor1
parents:
diff changeset
1344 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1101
diff changeset
1345 while ( _stricmp(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) );
0
Ritor1
parents:
diff changeset
1346 }
Ritor1
parents:
diff changeset
1347 return v2;
Ritor1
parents:
diff changeset
1348 }
Ritor1
parents:
diff changeset
1349
Ritor1
parents:
diff changeset
1350 // 4E28F8: using guessed type int pCurrentScreen;
Ritor1
parents:
diff changeset
1351
Ritor1
parents:
diff changeset
1352 //----- (00417AD4) --------------------------------------------------------
983
1462a5f12b65 Character Skills tab drawing fixed.
Nomad
parents: 982
diff changeset
1353 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level)
1393
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1354 {
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1355 switch (uPlayerClass % 4)
269
b34b53ee874d skill_learn_ability_by_class_table[36][37]
Ritor1
parents: 264
diff changeset
1356 {
1393
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1357 case 0:
269
b34b53ee874d skill_learn_ability_by_class_table[36][37]
Ritor1
parents: 264
diff changeset
1358 {
1393
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1359 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level)
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1360 return ui_character_skillinfo_can_learn;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1361 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level &&
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1362 byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level)
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1363 {
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1364 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType] < skill_level)
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1365 return ui_character_skillinfo_cant_learn;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1366 }
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1367 return ui_character_skillinfo_can_learn_gm;
0
Ritor1
parents:
diff changeset
1368 }
1393
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1369 break;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1370
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1371 case 1:
269
b34b53ee874d skill_learn_ability_by_class_table[36][37]
Ritor1
parents: 264
diff changeset
1372 {
1393
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1373 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level)
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1374 return ui_character_skillinfo_can_learn;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1375 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level)
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1376 {
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1377 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level)
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1378 return ui_character_skillinfo_cant_learn;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1379 }
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1380 return ui_character_skillinfo_can_learn_gm;
0
Ritor1
parents:
diff changeset
1381 }
1393
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1382 break;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1383
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1384 case 2:
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1385 case 3:
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1386 {
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1387 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level)
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1388 return ui_character_skillinfo_cant_learn;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1389 return ui_character_skillinfo_can_learn;
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1390 }
28f87f5234a1 More hardcoded UI colors moved to varibables.
Nomad
parents: 1391
diff changeset
1391 break;
0
Ritor1
parents:
diff changeset
1392 }
1575
43d3536a20f7 OnInventoryItemRightClick
Nomad
parents: 1546
diff changeset
1393 Error("Invalid player class: %u", uPlayerClass);
1296
c423f946dc99 moving files continue
Ritor1
parents: 1273
diff changeset
1394 }