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