Mercurial > mm7
annotate mm7_5.cpp @ 2117:c7bf59066842
mm7_4-6 cleaned
author | Ritor1 |
---|---|
date | Mon, 23 Dec 2013 23:38:51 +0600 |
parents | 68fbaf45ef66 |
children | 3eab5530cc94 |
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 | 5 #include "MapInfo.h" |
6 #include "LightmapBuilder.h" | |
0 | 7 #include "mm7.h" |
8 #include "GUIWindow.h" | |
9 #include "Party.h" | |
10 #include "Outdoor.h" | |
11 #include "LOD.h" | |
12 #include "Actor.h" | |
13 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2006
diff
changeset
|
14 #include "OurMath.h" |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
513
diff
changeset
|
15 #include "SpriteObject.h" |
2044 | 16 #include "Timer.h" |
0 | 17 #include "stru298.h" |
1262 | 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 | 20 |
21 //----- (004356FF) -------------------------------------------------------- | |
1575 | 22 void back_to_game() |
0 | 23 { |
24 dword_507BF0_is_there_popup_onscreen = 0; | |
25 dword_4E455C = 1; | |
1575 | 26 |
27 extern int no_rightlick_in_inventory; | |
28 no_rightlick_in_inventory = false; | |
29 | |
0 | 30 if ( pGUIWindow_ScrollWindow ) |
31 free_book_subwindow(); | |
32 if ( !pCurrentScreen && !pGUIWindow_Settings ) | |
33 pEventTimer->Resume(); | |
34 viewparams->bRedrawGameUI = 1; | |
35 } | |
782 | 36 |
0 | 37 //----- (0043648F) -------------------------------------------------------- |
38 void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2) | |
39 { | |
40 _this->flt_2C = 0.0; | |
41 | |
42 _this->vWorldPosition.x = a2->x; | |
43 _this->vWorldPosition.y = a2->y; | |
44 _this->vWorldPosition.z = a2->z; | |
45 } | |
46 | |
47 //----- (004369DB) -------------------------------------------------------- | |
48 void Vec3_float_::Normalize() | |
49 { | |
1025 | 50 this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x; |
51 this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y; | |
52 this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z; | |
0 | 53 } |
54 | |
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 | 57 { |
2059 | 58 int attacker_type; // ecx@3 |
0 | 59 signed int v3; // eax@3 |
2059 | 60 unsigned int target_id; // edi@6 |
61 int target_type; // eax@6 | |
0 | 62 int v10; // edi@8 |
2059 | 63 Vec3_int_ attacker_coord; // ST04_12@9 |
0 | 64 int v12; // ST0C_4@10 |
65 int v15; // edx@15 | |
66 int v19; // edi@15 | |
67 int v23; // edx@18 | |
68 int v24; // eax@18 | |
69 int v30; // eax@29 | |
70 int v31; // edx@29 | |
71 int v32; // eax@29 | |
72 int v33; // ST24_4@29 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
513
diff
changeset
|
73 SpriteObject *v36; // [sp+0h] [bp-28h]@0 |
2059 | 74 int attacker_id; // [sp+10h] [bp-18h]@1 |
0 | 75 int v44; // [sp+14h] [bp-14h]@15 |
2059 | 76 //Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2 |
0 | 77 int a1; // [sp+20h] [bp-8h]@8 |
78 int v48; // [sp+24h] [bp-4h]@8 | |
79 | |
2059 | 80 |
81 for ( attacker_id = 0; attacker_id < AttackerInfo.count; ++attacker_id ) | |
0 | 82 { |
2059 | 83 attacker_type = PID_TYPE(AttackerInfo.pIDs[attacker_id]); |
84 v3 = PID_ID(AttackerInfo.pIDs[attacker_id]); | |
2057 | 85 |
2059 | 86 if ( attacker_type == 2 ) |
87 { | |
88 v36 = &pSpriteObjects[v3]; | |
89 attacker_type = PID_TYPE(pSpriteObjects[v3].spell_caster_pid); | |
90 v3 = PID_ID(pSpriteObjects[v3].spell_caster_pid); | |
91 } | |
2057 | 92 |
2059 | 93 if ( AttackerInfo.field_3EC[attacker_id] & 1 ) |
94 { | |
95 target_id = PID_ID(ai_near_actors_targets_pid[v3]); | |
96 target_type = PID_TYPE(ai_near_actors_targets_pid[v3]) - 3; | |
97 if ( target_type ) | |
0 | 98 { |
2059 | 99 if ( target_type == 1 )//party damage from monsters(повреждения группе от монстров) |
0 | 100 { |
2059 | 101 v10 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
102 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; | |
2117 | 103 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 104 if ( a1 * a1 + v10 * v10 |
105 + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
106 * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
107 < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32)) ) | |
0 | 108 { |
2059 | 109 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
110 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
111 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
112 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord) ) | |
113 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], stru_50C198.which_player_to_attack(&pActors[v3])); | |
0 | 114 } |
115 } | |
2059 | 116 } |
117 else//Actor damage from monsters(повреждение местного жителя) | |
118 { | |
119 if ( SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) > 0 | |
120 || SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) >= 0 | |
121 && LODWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) | |
122 || pActors[target_id].CanAct() ) | |
0 | 123 { |
2059 | 124 v15 = pActors[target_id].vPosition.y - AttackerInfo.pYs[attacker_id]; |
125 a1 = pActors[target_id].vPosition.x - AttackerInfo.pXs[attacker_id]; | |
126 v44 = pActors[target_id].vPosition.z; | |
127 v19 = AttackerInfo.pYs[attacker_id] + pActors[target_id].uActorRadius; | |
128 v48 = v15; | |
129 if ( a1 * a1 + v15 * v15 + (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) | |
130 * (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) < (unsigned int)(v19 * v19) ) | |
0 | 131 { |
2059 | 132 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
133 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
134 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
135 if ( sub_407A1C(pActors[target_id].vPosition.x, pActors[target_id].vPosition.y, pActors[target_id].vPosition.z + 50, attacker_coord) ) | |
0 | 136 { |
2059 | 137 Vec3_int_::Normalize(&a1, &v48, &v44); |
138 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
139 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
140 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
141 ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], target_id, &AttackerInfo.vec_4B4[attacker_id], AttackerInfo.field_450[attacker_id]); | |
0 | 142 } |
143 } | |
144 } | |
145 } | |
2059 | 146 } |
147 else //damage from spells(повреждения от заклов(метеоритный дождь)) | |
148 { | |
149 v23 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; | |
150 v24 = ((signed int)pParty->uPartyHeight >> 1) - AttackerInfo.pZs[attacker_id]; | |
151 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; | |
2117 | 152 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 153 if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32)) ) |
154 {//party damage (повреждения группе) | |
155 attacker_coord.x = AttackerInfo.pXs[attacker_id]; | |
156 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
157 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
158 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord) ) | |
159 { | |
160 for ( uint i = 0; i < 4; ++i ) | |
0 | 161 { |
2059 | 162 if ( !(HIDWORD(pParty->pPlayers[i].pConditions[Condition_Dead]) | LODWORD(pParty->pPlayers[i].pConditions[Condition_Dead])) |
163 && !pParty->pPlayers[i].pConditions[Condition_Pertified] && !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) | |
164 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], i); | |
0 | 165 } |
166 } | |
2059 | 167 } |
168 if ( (signed int)uNumActors > 0 ) | |
169 {//actors damage(повреждения другим участникам) | |
170 for ( int actorID = 0; (signed int)actorID < (signed int)uNumActors; ++actorID ) | |
171 { | |
172 if ( pActors[actorID].CanAct() ) | |
0 | 173 { |
2059 | 174 v30 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; |
175 a1 = pActors[actorID].vPosition.x - AttackerInfo.pXs[attacker_id]; | |
176 v31 = pActors[actorID].vPosition.z; | |
177 v48 = v30; | |
178 v44 = pActors[actorID].vPosition.z; | |
179 v32 = (pActors[actorID].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]; | |
180 v33 = pActors[actorID].uActorRadius + AttackerInfo.pYs[attacker_id]; | |
181 if ( a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33) ) | |
0 | 182 { |
2059 | 183 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
184 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
185 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
186 if ( sub_407A1C(pActors[actorID].vPosition.x, pActors[actorID].vPosition.y, pActors[actorID].vPosition.z + 50, attacker_coord) ) | |
0 | 187 { |
2059 | 188 Vec3_int_::Normalize(&a1, &v48, &v44); |
189 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
190 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
191 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
192 switch ( attacker_type ) | |
0 | 193 { |
2059 | 194 case OBJECT_Player: |
195 DamageMonsterFromParty(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); | |
196 break; | |
197 case OBJECT_Actor: | |
198 if ( v36 && pActors[v3].GetActorsRelation(&pActors[actorID]) ) | |
199 ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id], v36->field_61); | |
200 break; | |
201 case OBJECT_Item: | |
202 sub_43B057(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); | |
203 break; | |
0 | 204 } |
205 } | |
206 } | |
207 } | |
208 } | |
209 } | |
210 } | |
211 } | |
2059 | 212 AttackerInfo.count = 0; |
0 | 213 } |
214 | |
215 | |
216 //----- (0043A97E) -------------------------------------------------------- | |
217 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) | |
218 { | |
1979 | 219 if (PID_TYPE(a2) == OBJECT_Player) |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
220 { |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
221 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
222 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
223 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
224 |
0 | 225 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); |
2006 | 226 DamagePlayerFromMonster(PID(OBJECT_Item, uLayingItemID), pSpriteObjects[uLayingItemID].field_61, &layingitem_vel_50FDFC, -1); |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
227 } |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
228 else if (PID_TYPE(a2) == OBJECT_Actor) |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
229 { |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
230 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
231 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
232 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
233 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
234 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
|
235 switch (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid)) |
0 | 236 { |
237 case OBJECT_Actor: | |
2057 | 238 ActorDamageFromMonster(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC, pSpriteObjects[uLayingItemID].field_61); |
0 | 239 break; |
240 case OBJECT_Player: | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
241 DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); |
0 | 242 break; |
243 case OBJECT_Item: | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
244 sub_43B057(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); |
0 | 245 break; |
246 } | |
247 } | |
248 } | |
249 | |
250 //----- (0043AE12) -------------------------------------------------------- | |
251 double __fastcall sub_43AE12(signed int a1) | |
252 { | |
2117 | 253 //signed int v1; // ST00_4@1 |
0 | 254 signed int v2; // ecx@1 |
255 double v3; // st7@1 | |
256 double result; // st7@6 | |
257 | |
2117 | 258 __debugbreak();//Ritor1 |
259 v3 = (double)a1; | |
260 for ( v2 = 0; v2 < 5; ++v2 ) | |
0 | 261 { |
262 if ( v3 < flt_4E4A80[v2 + 5] ) | |
263 break; | |
264 } | |
265 if ( v2 <= 0 || v2 >= 5 ) | |
266 { | |
267 if ( v2 ) | |
268 result = flt_4E4A80[4]; | |
269 else | |
270 result = flt_4E4A80[0]; | |
271 } | |
272 else | |
1469 | 273 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 | 274 return result; |
275 } | |
276 | |
277 //----- (0043B057) -------------------------------------------------------- | |
278 void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) | |
279 { | |
280 int v6; // eax@4 | |
281 int v7; // edi@4 | |
282 int a2a; // [sp+Ch] [bp-4h]@8 | |
283 | |
2117 | 284 __debugbreak();//Ritor1 |
303 | 285 if ( !pActors[uActorID].IsNotAlive() ) |
0 | 286 { |
2117 | 287 if ( PID_TYPE(uObjID) == OBJECT_Item) |
848 | 288 { |
2117 | 289 if ( pSpriteObjects[PID_ID(uObjID)].spell_id ) |
0 | 290 { |
2117 | 291 v6 = _43AFE3_calc_spell_damage(pSpriteObjects[PID_ID(uObjID)].spell_id, pSpriteObjects[PID_ID(uObjID)].spell_level, pSpriteObjects[PID_ID(uObjID)].spell_skill, pActors[uActorID].sCurrentHP); |
292 v7 = stru_50C198.CalcMagicalDamageToActor(&pActors[uActorID], 0, v6); | |
293 pActors[uActorID].sCurrentHP -= v7; | |
0 | 294 if ( v7 ) |
295 { | |
2117 | 296 if ( pActors[uActorID].sCurrentHP > 0 ) |
297 Actor::AI_Stun(uActorID, uObjID, 0); | |
0 | 298 else |
2117 | 299 Actor::Die(uActorID); |
300 a2a = 20 * v7 / (signed int)pActors[uActorID].pMonsterInfo.uHP; | |
301 if ( 20 * v7 / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10 ) | |
0 | 302 a2a = 10; |
2117 | 303 if ( !MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) |
0 | 304 { |
305 pVelocity->x = (unsigned __int64)(a2a * (signed __int64)pVelocity->x) >> 16; | |
306 pVelocity->y = (unsigned __int64)(a2a * (signed __int64)pVelocity->y) >> 16; | |
307 pVelocity->z = (unsigned __int64)(a2a * (signed __int64)pVelocity->z) >> 16; | |
2117 | 308 pActors[uActorID].vVelocity.x = 50 * LOWORD(pVelocity->x); |
309 pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); | |
310 pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); | |
0 | 311 } |
2117 | 312 Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v7); |
0 | 313 } |
314 else | |
2117 | 315 Actor::AI_Stun(uActorID, uObjID, 0); |
0 | 316 } |
317 } | |
318 } | |
319 } | |
320 | |
321 //----- (0043B1B0) -------------------------------------------------------- | |
2059 | 322 void ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, Vec3_int_ *pVelocity, signed int a4) |
0 | 323 { |
324 int v4; // ebx@1 | |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1916
diff
changeset
|
325 int v6; // eax@3 |
0 | 326 __int64 v10; // qax@8 |
327 signed int v12; // ecx@20 | |
328 int v13; // ecx@22 | |
329 int v14; // edi@30 | |
330 signed int v17; // [sp+10h] [bp-4h]@1 | |
331 int v18; // [sp+20h] [bp+Ch]@34 | |
332 | |
333 v4 = 0; | |
2059 | 334 v17 = attacker_id; |
335 if ( PID_TYPE(attacker_id) == OBJECT_Item) | |
848 | 336 { |
2059 | 337 v4 = pSpriteObjects[PID_ID(attacker_id)].field_60_distance_related_prolly_lod; |
338 v17 = pSpriteObjects[PID_ID(attacker_id)].spell_caster_pid; | |
0 | 339 } |
2057 | 340 if ( PID_TYPE(v17) == OBJECT_Actor) |
0 | 341 { |
2057 | 342 v6 = pActors[actor_id].IsNotAlive(); |
0 | 343 if ( !v6 ) |
344 { | |
2059 | 345 pActors[actor_id].uLastCharacterIDToHit = v17; |
2114 | 346 if ( pActors[actor_id].uAIState == Fleeing ) |
347 BYTE2(pActors[actor_id].uAttributes) |= 2; | |
348 if ( pActors[PID_ID(v17)]._4273BB_DoesHitOtherActor(&pActors[actor_id], v4, 0) ) | |
0 | 349 { |
2059 | 350 v10 = (unsigned int)pActors[PID_ID(v17)]._43B3E0_CalcDamage(a4); |
351 if ( (signed __int64)pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) | |
0 | 352 { |
2114 | 353 if ( pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower ) |
354 v10 = (signed int)v10 / (unsigned __int16)pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower; | |
0 | 355 } |
2059 | 356 if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) >= SHIDWORD(v10) |
357 && (SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > SHIDWORD(v10) | |
358 || LODWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > HIDWORD(v10)) ) | |
0 | 359 LODWORD(v10) = 0; |
2117 | 360 if ( a4 == HIDWORD(v10) ) |
361 v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack1Type; | |
362 else if ( a4 - HIDWORD(v10) == 1 ) | |
0 | 363 { |
2117 | 364 v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack2Type; |
365 if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) >= SHIDWORD(v10) | |
366 && (SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > SHIDWORD(v10) | |
367 || LODWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > HIDWORD(v10)) ) | |
368 LODWORD(v10) = (signed int)v10 / 2; | |
369 } | |
370 else if ( a4 - HIDWORD(v10) == 2 ) | |
371 v12 = LOBYTE(pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell1ID].uSchool); | |
372 else if ( a4 - HIDWORD(v10) == 3 ) | |
373 v12 = LOBYTE(pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell2ID].uSchool); | |
374 else if ( a4 - HIDWORD(v10) == 4 ) | |
375 v12 = pActors[PID_ID(v17)].pMonsterInfo.field_3C_some_special_attack; | |
376 else | |
377 v12 = 4; | |
378 v14 = stru_50C198.CalcMagicalDamageToActor(&pActors[actor_id], v12, v10); | |
379 pActors[actor_id].sCurrentHP -= v14; | |
380 if ( v14 ) | |
381 { | |
382 if ( pActors[actor_id].sCurrentHP > 0 ) | |
383 Actor::AI_Stun(actor_id, v17, 0); | |
0 | 384 else |
2117 | 385 Actor::Die(actor_id); |
386 Actor::AggroSurroundingPeasants(actor_id, 0); | |
387 v18 = 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP; | |
388 if ( 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP > 10 ) | |
389 v18 = 10; | |
390 if ( !MonsterStats::BelongsToSupertype(pActors[actor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
0 | 391 { |
2117 | 392 pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16; |
393 pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16; | |
394 pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16; | |
395 pActors[actor_id].vVelocity.x = 50 * LOWORD(pVelocity->x); | |
396 pActors[actor_id].vVelocity.y = 50 * LOWORD(pVelocity->y); | |
397 pActors[actor_id].vVelocity.z = 50 * LOWORD(pVelocity->z); | |
0 | 398 } |
2117 | 399 Actor::AddBloodsplatOnDamageOverlay(actor_id, 1, v14); |
0 | 400 } |
2117 | 401 else |
402 Actor::AI_Stun(actor_id, v17, 0); | |
403 return; | |
0 | 404 } |
405 } | |
406 } | |
407 } | |
408 | |
409 //----- (0043F515) -------------------------------------------------------- | |
657 | 410 void FindBillboardsLightLevels_BLV() |
0 | 411 { |
412 for (uint i = 0; i < uNumBillboardsToDraw; ++i) | |
413 { | |
2114 | 414 if (pBillboardRenderList[i].field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !pBillboardRenderList[i].uIndoorSectorID) |
415 pBillboardRenderList[i].dimming_level = 0; | |
0 | 416 else |
2114 | 417 pBillboardRenderList[i].dimming_level = _43F55F_get_billboard_light_level(&pBillboardRenderList[i], -1); |
0 | 418 } |
419 } | |
420 | |
421 //----- (0043F55F) -------------------------------------------------------- | |
422 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel) | |
423 { | |
424 signed int v3; // ecx@2 | |
425 | |
426 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
427 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel; | |
428 else | |
429 { | |
430 if ( uBaseLightLevel == -1 ) | |
657 | 431 v3 = a1->dimming_level; |
0 | 432 else |
433 v3 = uBaseLightLevel; | |
434 } | |
430 | 435 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z); |
0 | 436 } |
437 | |
438 //----- (0043F5C8) -------------------------------------------------------- | |
439 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z) | |
440 { | |
441 int v5; // esi@1 | |
442 signed int v6; // edi@1 | |
443 int v8; // eax@6 | |
444 int v9; // ebx@6 | |
445 unsigned int v10; // ecx@6 | |
446 unsigned int v11; // edx@9 | |
447 unsigned int v12; // edx@11 | |
448 signed int v13; // ecx@12 | |
449 BLVLightMM7 *v16; // esi@20 | |
450 int v17; // ebx@21 | |
451 int v18; // eax@24 | |
452 int v19; // ebx@24 | |
453 unsigned int v20; // ecx@24 | |
454 int v21; // edx@25 | |
455 unsigned int v22; // edx@27 | |
456 unsigned int v23; // edx@29 | |
457 signed int v24; // ecx@30 | |
458 int v26; // ebx@35 | |
459 int v27; // eax@38 | |
460 int v28; // ebx@38 | |
461 unsigned int v29; // ecx@38 | |
462 int v30; // edx@39 | |
463 unsigned int v31; // edx@41 | |
464 unsigned int v32; // edx@43 | |
465 signed int v33; // ecx@44 | |
466 int v37; // [sp+Ch] [bp-18h]@37 | |
467 int v38; // [sp+10h] [bp-14h]@5 | |
468 int v39; // [sp+10h] [bp-14h]@23 | |
469 int v40; // [sp+10h] [bp-14h]@36 | |
470 int v42; // [sp+14h] [bp-10h]@22 | |
471 unsigned int v43; // [sp+18h] [bp-Ch]@12 | |
472 unsigned int v44; // [sp+18h] [bp-Ch]@30 | |
473 unsigned int v45; // [sp+18h] [bp-Ch]@44 | |
474 | |
475 v6 = uBaseLightLevel; | |
476 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) | |
477 { | |
1980 | 478 MobileLight* p = &pMobileLightsStack->pLights[i]; |
0 | 479 |
1980 | 480 float distX = abs(p->vPosition.x - x); |
0 | 481 if ( distX <= p->uRadius) |
482 { | |
1980 | 483 float distY = abs(p->vPosition.y - y); |
0 | 484 if ( distY <= p->uRadius) |
485 { | |
1980 | 486 float distZ = abs(p->vPosition.z - z); |
0 | 487 if ( distZ <= p->uRadius) |
488 { | |
489 v8 = distX; | |
490 v9 = distY; | |
491 v10 = distZ; | |
492 if (distX < distY) | |
493 { | |
494 v8 = distY; | |
495 v9 = distX; | |
496 } | |
497 if ( v8 < distZ ) | |
498 { | |
499 v11 = v8; | |
500 v8 = distZ; | |
501 v10 = v11; | |
502 } | |
503 if ( v9 < (signed int)v10 ) | |
504 { | |
505 v12 = v10; | |
506 v10 = v9; | |
507 v9 = v12; | |
508 } | |
509 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8; | |
510 v13 = p->uRadius; | |
511 if ( (signed int)v43 < v13 ) | |
512 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30; | |
513 } | |
514 } | |
515 } | |
516 } | |
517 | |
518 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
519 { | |
1980 | 520 BLVSector* pSector = &pIndoor->pSectors[uSectorID]; |
0 | 521 |
522 for (uint i = 0; i < pSector->uNumLights; ++i) | |
523 { | |
524 v16 = pIndoor->pLights + pSector->pLights[i]; | |
525 if (~v16->uAtributes & 8) | |
526 { | |
527 v17 = abs(v16->vPosition.x - x); | |
528 if ( v17 <= v16->uRadius ) | |
529 { | |
530 v42 = abs(v16->vPosition.y - y); | |
531 if ( v42 <= v16->uRadius ) | |
532 { | |
533 v39 = abs(v16->vPosition.z - z); | |
534 if ( v39 <= v16->uRadius ) | |
535 { | |
536 v18 = v17; | |
537 v19 = v42; | |
538 v20 = v39; | |
539 if ( v18 < v42 ) | |
540 { | |
541 v21 = v18; | |
542 v18 = v42; | |
543 v19 = v21; | |
544 } | |
545 if ( v18 < v39 ) | |
546 { | |
547 v22 = v18; | |
548 v18 = v39; | |
549 v20 = v22; | |
550 } | |
551 if ( v19 < (signed int)v20 ) | |
552 { | |
553 v23 = v20; | |
554 v20 = v19; | |
555 v19 = v23; | |
556 } | |
557 v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18; | |
558 v24 = v16->uRadius; | |
559 if ( (signed int)v44 < v24 ) | |
560 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30; | |
561 } | |
562 } | |
563 } | |
564 } | |
565 } | |
566 } | |
567 | |
568 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | |
569 { | |
1980 | 570 StationaryLight* p = &pStationaryLightsStack->pLights[i]; |
0 | 571 v26 = abs(p->vPosition.x - x); |
572 if ( v26 <= p->uRadius) | |
573 { | |
574 v40 = abs(p->vPosition.y - y); | |
575 if ( v40 <= p->uRadius) | |
576 { | |
577 v37 = abs(p->vPosition.z - z); | |
578 if ( v37 <= p->uRadius) | |
579 { | |
580 v27 = v26; | |
581 v28 = v40; | |
582 v29 = v37; | |
583 if ( v27 < v40 ) | |
584 { | |
585 v30 = v27; | |
586 v27 = v40; | |
587 v28 = v30; | |
588 } | |
589 if ( v27 < v37 ) | |
590 { | |
591 v31 = v27; | |
592 v27 = v37; | |
593 v29 = v31; | |
594 } | |
595 if ( v28 < (signed int)v29 ) | |
596 { | |
597 v32 = v29; | |
598 v29 = v28; | |
599 v28 = v32; | |
600 } | |
601 v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27; | |
602 v33 = p->uRadius; | |
603 if ( (signed int)v45 < v33 ) | |
604 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30; | |
605 } | |
606 } | |
607 } | |
608 } | |
609 | |
610 if ( v6 <= 31 ) | |
611 { | |
612 if ( v6 < 0 ) | |
613 v6 = 0; | |
614 } | |
615 else | |
616 { | |
617 v6 = 31; | |
618 } | |
619 return v6; | |
620 } | |
621 | |
622 | |
623 //----- (004070EF) -------------------------------------------------------- | |
1493 | 624 bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID) |
0 | 625 { |
626 signed int v2; // eax@1 | |
627 int v5; // ecx@2 | |
1615 | 628 int obj1_sector; // eax@4 |
0 | 629 float v8; // ST24_4@5 |
630 double v9; // ST18_8@5 | |
631 int v11; // ecx@6 | |
632 signed int v12; // eax@7 | |
633 int v13; // esi@7 | |
634 int v14; // esi@8 | |
635 int v15; // esi@9 | |
1493 | 636 int obj2_z; // edi@11 |
637 int obj2_x; // esi@11 | |
638 int obj2_sector; // eax@13 | |
0 | 639 float v20; // ST24_4@14 |
640 double v21; // ST18_8@14 | |
1615 | 641 int dist_x; // ebx@16 |
642 signed int dist_3d; // ecx@16 | |
0 | 643 int v25; // eax@18 |
644 BLVFace *v29; // ebx@32 | |
645 Vec3_short_ *v30; // esi@32 | |
646 int v31; // eax@32 | |
647 int v32; // ST50_4@44 | |
648 int v33; // ST54_4@44 | |
649 int v34; // eax@44 | |
650 signed int v38; // esi@45 | |
651 signed __int64 v40; // qtt@50 | |
1615 | 652 __int16 next_sector; // bx@58 |
0 | 653 int v43; // [sp-8h] [bp-70h]@11 |
654 int v44; // [sp-4h] [bp-6Ch]@11 | |
655 int v47; // [sp+18h] [bp-50h]@20 | |
656 int v48; // [sp+1Ch] [bp-4Ch]@20 | |
657 int v49; // [sp+20h] [bp-48h]@20 | |
1615 | 658 int dist_z; // [sp+24h] [bp-44h]@16 |
659 signed int higher_z; // [sp+24h] [bp-44h]@27 | |
660 signed int lower_z; // [sp+28h] [bp-40h]@26 | |
661 signed int higher_y; // [sp+2Ch] [bp-3Ch]@23 | |
662 signed int lower_y; // [sp+30h] [bp-38h]@22 | |
663 signed int higher_x; // [sp+34h] [bp-34h]@21 | |
664 signed int lower_x; // [sp+38h] [bp-30h]@20 | |
665 signed int sectors_visited; // [sp+3Ch] [bp-2Ch]@28 | |
0 | 666 int v58; // [sp+44h] [bp-24h]@50 |
667 int v59; // [sp+48h] [bp-20h]@44 | |
1493 | 668 int obj2_y; // [sp+50h] [bp-18h]@11 |
1615 | 669 int obj1_x; // [sp+58h] [bp-10h]@4 |
670 int obj1_y; // [sp+5Ch] [bp-Ch]@4 | |
671 int obj1_z; // [sp+60h] [bp-8h]@4 | |
672 int current_sector; // [sp+64h] [bp-4h]@7 | |
673 int dist_y; | |
674 int v70; | |
0 | 675 |
848 | 676 v2 = PID_ID(uObjID); |
1615 | 677 switch( PID_TYPE(uObjID) ) |
0 | 678 { |
1615 | 679 case OBJECT_Decoration: |
680 obj1_x = pLevelDecorations[v2].vPosition.x; | |
681 obj1_y = pLevelDecorations[v2].vPosition.y; | |
682 obj1_z = pLevelDecorations[v2].vPosition.z; | |
683 obj1_sector = pIndoor->GetSector(obj1_x, obj1_y, obj1_z); | |
684 break; | |
685 case OBJECT_Actor: | |
686 obj1_x = pActors[v2].vPosition.x; | |
687 obj1_y = pActors[v2].vPosition.y; | |
0 | 688 v8 = (double)pActors[v2].uActorHeight * 0.69999999; |
1493 | 689 //v9 = v8 + 6.7553994e15; |
1615 | 690 //obj1_z = LODWORD(v9) + pActors[v2].vPosition.z; |
691 obj1_z = (int)v8 + pActors[v2].vPosition.z; | |
692 obj1_sector = pActors[v2].uSectorID; | |
693 break; | |
694 case OBJECT_Item: | |
695 obj1_x = pSpriteObjects[v2].vPosition.x; | |
696 obj1_y = pSpriteObjects[v2].vPosition.y; | |
697 obj1_z = pSpriteObjects[v2].vPosition.z; | |
698 obj1_sector = pSpriteObjects[v2].uSectorID; | |
699 break; | |
700 default: | |
701 return 0; | |
0 | 702 } |
1493 | 703 v12 = PID_ID(uObj2ID); |
1615 | 704 switch( PID_TYPE(uObj2ID) ) |
1493 | 705 { |
1615 | 706 case OBJECT_Decoration: |
707 obj2_z = pLevelDecorations[v12].vPosition.z; | |
708 obj2_x = pLevelDecorations[v12].vPosition.x; | |
709 obj2_y = pLevelDecorations[v12].vPosition.y; | |
710 obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); | |
711 break; | |
712 case OBJECT_Player: | |
713 obj2_x = pParty->vPosition.x; | |
714 obj2_z = pParty->sEyelevel + pParty->vPosition.z; | |
715 obj2_y = pParty->vPosition.y; | |
2114 | 716 obj2_sector = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); |
1615 | 717 break; |
718 case OBJECT_Actor: | |
719 obj2_y = pActors[v12].vPosition.y; | |
720 obj2_x = pActors[v12].vPosition.x; | |
721 v20 = (double)pActors[v12].uActorHeight * 0.69999999; | |
722 //v21 = v20 + 6.7553994e15; | |
723 //obj2_z = LODWORD(v21) + pActors[v12].vPosition.z; | |
724 obj2_z = (int)v20 + pActors[v12].vPosition.z; | |
725 obj2_sector = pActors[v12].uSectorID; | |
726 break; | |
727 case OBJECT_Item: | |
728 obj2_x = pSpriteObjects[v12].vPosition.x; | |
729 obj2_z = pSpriteObjects[v12].vPosition.z; | |
730 obj2_y = pSpriteObjects[v12].vPosition.y; | |
731 obj2_sector = pSpriteObjects[v12].uSectorID; | |
732 break; | |
733 default: | |
734 return 0; | |
1493 | 735 } |
1615 | 736 dist_x = obj2_x - obj1_x; |
737 dist_z = obj2_z - obj1_z; | |
738 dist_y = obj2_y - obj1_y; | |
739 dist_3d = integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z); | |
740 //range check | |
741 if ( dist_3d > 5120 ) | |
0 | 742 return 0; |
743 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
744 return 1; | |
745 v25 = 65536; | |
1615 | 746 if ( dist_3d ) |
747 v25 = 65536 / dist_3d; | |
748 v49 = dist_x * v25; | |
749 v47 = dist_z * v25; | |
750 v48 = dist_y * v25; | |
751 if ( obj1_x < obj2_x ) | |
0 | 752 { |
1615 | 753 lower_x = obj1_x; |
754 higher_x = obj2_x; | |
0 | 755 } |
756 else | |
757 { | |
1615 | 758 lower_x = obj2_x; |
759 higher_x = obj1_x; | |
0 | 760 } |
1615 | 761 if ( obj1_y < obj2_y ) |
0 | 762 { |
1615 | 763 lower_y = obj1_y; |
764 higher_y = obj2_y; | |
0 | 765 } |
766 else | |
767 { | |
1615 | 768 lower_y = obj2_y; |
769 higher_y = obj1_y; | |
0 | 770 } |
1615 | 771 if ( obj1_z < obj2_z ) |
0 | 772 { |
1615 | 773 lower_z = obj1_z; |
774 higher_z = obj2_z; | |
0 | 775 } |
776 else | |
777 { | |
1615 | 778 lower_z = obj2_z; |
779 higher_z = obj1_z; | |
0 | 780 } |
1615 | 781 sectors_visited = 0; |
782 //monster in same sector with player | |
783 if ( obj1_sector == obj2_sector ) | |
0 | 784 return 1; |
1615 | 785 //search starts from monster |
786 current_sector = obj1_sector; | |
787 for( int current_portal = 0; current_portal < pIndoor->pSectors[current_sector].uNumPortals; current_portal++ ) | |
788 { | |
789 v29 = &pIndoor->pFaces[pIndoor->pSectors[current_sector].pPortals[current_portal]]; | |
790 v30 = &pIndoor->pVertices[*v29->pVertexIDs]; | |
791 v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj1_z) | |
792 + v29->pFacePlane_old.vNormal.y * (v30->y - obj1_y) | |
793 + v29->pFacePlane_old.vNormal.x * (v30->x - obj1_x); | |
794 | |
795 if ( current_sector != v29->uSectorID ) | |
796 v31 = -v31; | |
797 | |
798 if ( v31 >= 0 && v30->x != obj1_x && v30->y != obj1_y && v30->z != obj1_z) | |
799 continue; | |
800 | |
801 if( lower_x > v29->pBounding.x2 | |
802 || higher_x < v29->pBounding.x1 | |
803 || lower_y > v29->pBounding.y2 | |
804 || higher_y < v29->pBounding.y1 | |
805 || lower_z > v29->pBounding.z2 | |
806 || higher_z < v29->pBounding.z1 ) | |
807 { | |
808 continue; | |
809 } | |
810 | |
1643 | 811 v32 = fixpoint_mul(v29->pFacePlane_old.vNormal.x,v49); |
812 v33 = fixpoint_mul(v29->pFacePlane_old.vNormal.z,v47); | |
813 v34 = fixpoint_mul(v29->pFacePlane_old.vNormal.y,v48); | |
1615 | 814 v59 = v32 + v33 + v34; |
815 if ( v59 ) | |
1493 | 816 { |
1615 | 817 v70 = v29->pFacePlane_old.dist |
818 + obj1_z * v29->pFacePlane_old.vNormal.z | |
819 + obj1_x * v29->pFacePlane_old.vNormal.x | |
820 + obj1_y * v29->pFacePlane_old.vNormal.y; | |
821 v38 = -v70; | |
822 | |
823 // if ( v59 <= 0 ^ v70 <= 0 ) | |
824 | |
825 /* TEMPORARY | |
826 if ( v59 <= 0 && v70 <= 0 ) | |
827 { | |
828 continue; | |
829 } | |
830 if ( !(v59 <= 0 && v70 <= 0) ) | |
831 { | |
832 continue; | |
833 } | |
834 */ | |
835 | |
836 if( abs(v38) >> 14 > abs(v59) ) | |
837 continue; | |
838 | |
1643 | 839 v58 = fixpoint_div(v38,v59); |
1615 | 840 |
841 if( v58 < 0 ) | |
2114 | 842 continue; |
1493 | 843 |
2114 | 844 if(!sub_4075DB(obj1_x + ((fixpoint_mul(v49,v58) + 32768) >> 16), obj1_y + ((fixpoint_mul(v48,v58) + 32768) >> 16), |
845 obj1_z + ((fixpoint_mul(v47,v58) + 32768) >> 16), v29) ) | |
1615 | 846 { |
1616 | 847 continue; |
1615 | 848 } |
849 | |
850 //if there is no next sector turn back | |
851 if ( v29->uSectorID == current_sector ) | |
852 next_sector = v29->uBackSectorID; | |
853 else | |
854 next_sector = v29->uSectorID; | |
855 | |
856 //no more portals, quit | |
857 if ( next_sector == current_sector ) | |
2114 | 858 break; |
1615 | 859 |
860 ++sectors_visited; | |
861 current_sector = next_sector; | |
862 | |
863 //found player, quit | |
864 if ( next_sector == obj2_sector ) | |
865 return 1; | |
866 | |
867 current_sector = next_sector; | |
868 | |
869 //did we hit limit for portals? | |
870 //does the next room have portals? | |
871 if ( sectors_visited < 30 && pIndoor->pSectors[current_sector].uNumPortals > 0) | |
872 { | |
873 current_portal=-1; | |
874 continue; | |
875 } | |
876 else | |
877 break; | |
878 } | |
879 } | |
880 //did we stop in the sector where player is? | |
881 if ( current_sector != obj2_sector ) | |
0 | 882 return 0; |
883 return 1; | |
884 } | |
885 | |
886 //----- (004075DB) -------------------------------------------------------- | |
2114 | 887 bool __fastcall sub_4075DB(int x, int y, int z, BLVFace *face) |
0 | 888 { |
889 int v8; // edi@2 | |
890 signed int v25; // eax@22 | |
891 bool result; // eax@25 | |
892 signed int a3a; // [sp+24h] [bp+8h]@14 | |
893 int a4a; // [sp+28h] [bp+Ch]@2 | |
894 | |
2000 | 895 std::array<int, 52> dword_4F5CC8_ys; // idb |
896 std::array<int, 52> dword_4F5D98_xs; // idb | |
897 | |
1493 | 898 //__debugbreak(); |
1458 | 899 |
2114 | 900 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 901 { |
1616 | 902 a4a = x; |
903 v8 = y; | |
2114 | 904 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 905 { |
2114 | 906 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
907 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; | |
1471 | 908 } |
0 | 909 } |
910 else | |
911 { | |
1616 | 912 v8 = z; |
2114 | 913 if ( face->uAttributes & FACE_XZ_PLANE ) |
0 | 914 { |
1616 | 915 a4a = x; |
2114 | 916 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 917 { |
2114 | 918 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
919 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 920 } |
0 | 921 } |
922 else | |
923 { | |
1616 | 924 a4a = y; |
2114 | 925 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 926 { |
2114 | 927 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; |
928 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 929 } |
0 | 930 } |
931 } | |
932 a3a = 0; | |
2114 | 933 dword_4F5D98_xs[face->uNumVertices] = dword_4F5D98_xs[0]; |
934 dword_4F5CC8_ys[face->uNumVertices] = dword_4F5CC8_ys[0]; | |
935 for(int i = 0; i < face->uNumVertices && a3a < 2; i++) | |
0 | 936 { |
1615 | 937 if ( dword_4F5CC8_ys[i] >= v8 ^ (dword_4F5CC8_ys[i + 1] >= v8) ) |
0 | 938 { |
1615 | 939 //if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a) |
940 if( !(dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] < a4a)) | |
0 | 941 { |
1615 | 942 if ( (dword_4F5D98_xs[i + 1] < a4a && dword_4F5D98_xs[i] >= a4a) ) |
943 ++a3a; | |
944 //|| (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],LODWORD(v26) = v25 << 16, HIDWORD(v26) = v25 >> 16, | |
945 //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) | |
946 // + 32768) >> 16) >= a4a) ) | |
947 else | |
948 { | |
1643 | 949 v25 = fixpoint_div(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]); |
2114 | 950 if( dword_4F5D98_xs[i] + (fixpoint_mul(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 0x8000 >> 16) >= a4a) |
1615 | 951 ++a3a; |
952 } | |
0 | 953 } |
954 } | |
955 } | |
956 result = 1; | |
957 if ( a3a != 1 ) | |
958 result = 0; | |
959 return result; | |
960 } | |
961 | |
962 //----- (004077F1) -------------------------------------------------------- | |
2114 | 963 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *face, BSPVertexBuffer *a5) |
0 | 964 { |
965 int a4a; // [sp+28h] [bp+Ch]@2 | |
966 signed int a5a; // [sp+2Ch] [bp+10h]@14 | |
967 | |
2000 | 968 std::array<int, 52> dword_4F5B24_ys; // idb |
969 std::array<int, 52> dword_4F5BF4_xs; // idb | |
2114 | 970 |
2057 | 971 //__debugbreak(); //срабатывает при нападении стрекозавров с огнём |
1458 | 972 |
2114 | 973 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 974 { |
975 a4a = a1; | |
976 a3 = a2; | |
2114 | 977 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
978 { |
2114 | 979 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
980 dword_4F5B24_ys[i+1] = a5->pVertices[face->pVertexIDs[i]].y; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
981 } |
0 | 982 } |
983 else | |
984 { | |
2114 | 985 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 986 { |
987 a4a = a1; | |
2114 | 988 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
989 { |
2114 | 990 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
991 dword_4F5B24_ys[i+1] = a5->pVertices[face->pVertexIDs[i]].z; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
992 } |
0 | 993 } |
994 else | |
995 { | |
996 a4a = a2; | |
2114 | 997 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
998 { |
2114 | 999 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].y; |
1000 dword_4F5B24_ys[i+1] = a5->pVertices[face->pVertexIDs[i]].z; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
1001 } |
0 | 1002 } |
1003 } | |
1004 a5a = 0; | |
2114 | 1005 dword_4F5BF4_xs[face->uNumVertices + 1] = dword_4F5BF4_xs[1]; |
1006 dword_4F5B24_ys[face->uNumVertices + 1] = dword_4F5B24_ys[1]; | |
1007 for(int i = 0; i < face->uNumVertices; i++) | |
0 | 1008 { |
1009 if ( a5a >= 2 ) | |
1010 break; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
1011 if ( dword_4F5B24_ys[i + 1] >= a3 ^ (dword_4F5B24_ys[i + 2] >= a3) ) |
0 | 1012 { |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
1013 if( dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a) |
0 | 1014 { |
1545 | 1015 if (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a) |
1016 ++a5a; | |
1017 else | |
1018 { | |
2114 | 1019 //v23 = (__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16; |
1545 | 1020 __int64 _a = dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1]; |
1021 __int64 _b = (__int64)(a3 - dword_4F5B24_ys[i + 1]) << 16; | |
1022 | |
2114 | 1023 if (dword_4F5BF4_xs[i + 1] + ((((((__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16) / _a * _b) >> 16) + 0x8000) >> 16) >= a4a) |
1545 | 1024 ++a5a; |
1025 } | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
1026 } |
0 | 1027 } |
1028 } | |
1545 | 1029 |
0 | 1030 if ( a5a != 1 ) |
1545 | 1031 return false; |
1032 return true; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
1033 |
0 | 1034 } |
1035 | |
1036 //----- (004088E9) -------------------------------------------------------- | |
1459 | 1037 int __fastcall sub_4088E9(int x1, int y1, int x2, int y2, int x3, int y3) |
0 | 1038 { |
1039 signed int result; // eax@1 | |
1040 | |
2114 | 1041 result = integer_sqrt(abs(x2 - x1) * abs(x2 - x1) + abs(y2 - y1) * abs(y2 - y1)); |
0 | 1042 if ( result ) |
1459 | 1043 result = abs(((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / result); |
0 | 1044 return result; |
1045 } | |
1046 | |
1047 //----- (0040F82D) -------------------------------------------------------- | |
1048 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue) | |
1049 { | |
973 | 1050 assert(uTextureId != -1); |
1051 ZBuffer_DoFill(pZBuffer, pIcons_LOD->GetTexture(uTextureId), iZValue); | |
0 | 1052 } |
1053 | |
1054 //----- (0040F89C) -------------------------------------------------------- | |
1055 void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue) | |
2114 | 1056 {//срабатывает при продаже в магазине |
0 | 1057 void *v3; // eax@3 |
2114 | 1058 //void *v4; // esi@5 |
1059 //int *v5; // edi@5 | |
1060 //int v6; // eax@5 | |
0 | 1061 int v7; // ecx@6 |
1062 int v11; // [sp+18h] [bp-8h]@1 | |
2114 | 1063 //void *v12; // [sp+1Ch] [bp-4h]@5 |
0 | 1064 |
1065 if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize ) | |
1066 v3 = pTex->UnzipPalette(); | |
1067 else | |
710 | 1068 v3 = pTex->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 1069 //v12 = v3; |
1070 //v4 = v3; | |
1071 //v5 = pZBuffer; | |
1072 //v6 = 0; | |
1073 for ( uint i = 0; i < pTex->uTextureHeight; i++ ) | |
0 | 1074 { |
2114 | 1075 for ( uint j = 0; j < pTex->uTextureWidth; j++ ) |
0 | 1076 { |
2114 | 1077 //LOBYTE(v6) = *(char *)v4; |
1078 //v4 = (char *)v4 + 1; | |
1079 //if ( v6 ) | |
1080 *pZBuffer = uZValue; | |
1081 ++pZBuffer; | |
0 | 1082 } |
2114 | 1083 pZBuffer += 640 - pTex->uTextureWidth; |
0 | 1084 } |
1085 if ( pIcons_LOD->dword_011BA4 ) | |
1086 { | |
2114 | 1087 if ( pTex->uDecompressedSize ) |
1088 free(v3); | |
0 | 1089 } |
1090 } | |
1091 | |
1092 //----- (0040F92A) -------------------------------------------------------- | |
1458 | 1093 void __fastcall ZBuffer_DoFill2(int *pZBuffer, Texture *a2, int a3) |
2114 | 1094 {//срабатывает в покупке в магазине |
0 | 1095 void *v4; // eax@3 |
2114 | 1096 //int *v5; // edi@5 |
0 | 1097 int v6; // ecx@6 |
1098 int v9; // [sp+18h] [bp-4h]@1 | |
1099 | |
1100 if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize ) | |
1101 v4 = a2->UnzipPalette(); | |
1102 else | |
710 | 1103 v4 = a2->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 1104 //v5 = pZBuffer; |
1105 for ( uint i = 0; i < a2->uTextureHeight; i++ ) | |
0 | 1106 { |
2114 | 1107 for ( uint j = 0; j < a2->uTextureWidth; j++ ) |
0 | 1108 { |
2114 | 1109 *pZBuffer = a3; |
1110 ++pZBuffer; | |
0 | 1111 } |
2114 | 1112 pZBuffer += 640 - a2->uTextureWidth; |
0 | 1113 } |
1114 if ( pIcons_LOD->dword_011BA4 ) | |
1115 { | |
2114 | 1116 if ( a2->uDecompressedSize ) |
0 | 1117 free(v4); |
1118 } | |
1119 } | |
1120 | |
1121 //----- (00410D99) -------------------------------------------------------- | |
1458 | 1122 int __fastcall sub_410D99_get_map_index(int a1) |
0 | 1123 { |
1124 int v1; // edi@1 | |
1125 signed int v2; // ebp@1 | |
1126 const char **v3; // esi@2 | |
1127 char *v4; // ebx@2 | |
1128 | |
2114 | 1129 __debugbreak();//Ritor1 |
0 | 1130 v1 = a1; |
1131 v2 = 1; | |
1104 | 1132 if ( _stricmp(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) ) |
0 | 1133 { |
1134 v3 = (const char **)&pMapStats->pInfos[1].pFilename; | |
1135 v4 = (char *)&pMapStats->pInfos[1].pFilename; | |
1136 do | |
1137 { | |
1138 if ( !*(int *)v4 ) | |
1139 break; | |
1140 v3 += 17; | |
1141 ++v2; | |
1142 v4 = (char *)v3; | |
1143 } | |
1104 | 1144 while ( _stricmp(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) ); |
0 | 1145 } |
1146 return v2; | |
1147 } | |
1148 | |
1149 // 4E28F8: using guessed type int pCurrentScreen; | |
1150 | |
1151 //----- (00417AD4) -------------------------------------------------------- | |
983 | 1152 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) |
1393 | 1153 { |
1154 switch (uPlayerClass % 4) | |
269 | 1155 { |
1393 | 1156 case 0: |
269 | 1157 { |
1393 | 1158 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
1159 return ui_character_skillinfo_can_learn; | |
1160 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level && | |
1161 byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
1162 { | |
1163 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType] < skill_level) | |
1164 return ui_character_skillinfo_cant_learn; | |
1165 } | |
1166 return ui_character_skillinfo_can_learn_gm; | |
0 | 1167 } |
1393 | 1168 break; |
1169 | |
1170 case 1: | |
269 | 1171 { |
1393 | 1172 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
1173 return ui_character_skillinfo_can_learn; | |
1174 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level) | |
1175 { | |
1176 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
1177 return ui_character_skillinfo_cant_learn; | |
1178 } | |
1179 return ui_character_skillinfo_can_learn_gm; | |
0 | 1180 } |
1393 | 1181 break; |
1182 | |
1183 case 2: | |
1184 case 3: | |
1185 { | |
1186 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level) | |
1187 return ui_character_skillinfo_cant_learn; | |
1188 return ui_character_skillinfo_can_learn; | |
1189 } | |
1190 break; | |
0 | 1191 } |
1575 | 1192 Error("Invalid player class: %u", uPlayerClass); |
1296 | 1193 } |