annotate mm7_5.cpp @ 2114:68fbaf45ef66

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