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