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