Mercurial > mm7
annotate Engine/Objects/Actor.cpp @ 2566:30eb6dcac768
big spell fx overhaul
author | a.parshin |
---|---|
date | Wed, 20 May 2015 21:05:07 +0200 |
parents | b8a56afc6ba1 |
children | d569340b05ff |
rev | line source |
---|---|
2497 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 | |
2541 | 7 #include "Engine/Engine.h" |
8 | |
2499 | 9 #include "../Graphics/PaletteManager.h" |
10 #include "../Graphics/DecalBuilder.h" | |
11 #include "../Graphics/Sprites.h" | |
12 #include "../../stru6.h" | |
2497 | 13 #include "Actor.h" |
2499 | 14 #include "../OurMath.h" |
15 #include "../Graphics/Outdoor.h" | |
2502 | 16 #include "Media/Audio/AudioPlayer.h" |
2497 | 17 #include "ObjectList.h" |
2499 | 18 #include "../Graphics/Overlays.h" |
19 #include "../Tables/FactionTable.h" | |
20 #include "../TurnEngine/TurnEngine.h" | |
21 #include "../Spells/CastSpellInfo.h" | |
22 #include "../Timer.h" | |
23 #include "../LOD.h" | |
24 #include "../Party.h" | |
2502 | 25 #include "GUI/GUIWindow.h" |
2497 | 26 #include "SpriteObject.h" |
2499 | 27 #include "../stru298.h" |
28 #include "../Texts.h" | |
29 #include "../Graphics/Level/Decoration.h" | |
30 #include "../Graphics/Viewport.h" | |
31 #include "../Graphics/Vis.h" | |
2497 | 32 |
33 | |
34 | |
35 | |
36 | |
37 std::array<Actor, 500> pActors; | |
38 size_t uNumActors; | |
39 | |
40 stru319 stru_50C198; // idb | |
41 | |
42 | |
43 std::array<uint, 5> _4DF380_hostilityRanges = {0, 1024, 2560, 5120, 10240}; | |
44 | |
45 | |
46 | |
47 | |
48 //----- (0042FB5C) -------------------------------------------------------- | |
49 // True if monster should play attack animation when casting this spell. | |
50 bool ShouldMonsterPlayAttackAnim(signed int spell_id) | |
51 { | |
52 switch (spell_id) | |
53 { | |
54 case SPELL_FIRE_HASTE: | |
55 case SPELL_AIR_SHIELD: | |
56 case SPELL_EARTH_STONESKIN: | |
57 case SPELL_SPIRIT_BLESS: | |
58 case SPELL_SPIRIT_FATE: | |
59 case SPELL_SPIRIT_HEROISM: | |
60 case SPELL_BODY_HAMMERHANDS: | |
61 case SPELL_BODY_POWER_CURE: | |
62 case SPELL_LIGHT_DISPEL_MAGIC: | |
63 case SPELL_LIGHT_DAY_OF_PROTECTION: | |
64 case SPELL_LIGHT_HOUR_OF_POWER: | |
65 case SPELL_DARK_PAIN_REFLECTION: | |
66 return false; | |
67 } | |
68 | |
69 return true; | |
70 } | |
71 | |
72 | |
73 //----- (0041AF52) -------------------------------------------------------- | |
74 void Actor::DrawHealthBar(Actor *actor, GUIWindow *window) | |
75 { | |
76 unsigned int bar_length; // esi@1 | |
77 unsigned int uX; // ebx@10 | |
78 unsigned int v9; // [sp+14h] [bp-Ch]@4 | |
79 unsigned int v10; // [sp+1Ch] [bp-4h]@4 | |
80 | |
81 if (actor->pMonsterInfo.uHP <= 25) | |
82 bar_length = 25; | |
83 else if ( actor->pMonsterInfo.uHP < 200 ) | |
84 bar_length = actor->pMonsterInfo.uHP; | |
85 else | |
86 bar_length = 200; | |
87 | |
88 v10 = bar_length; | |
89 if ( actor->sCurrentHP <= (0.34 * actor->pMonsterInfo.uHP) ) | |
90 v9 = uTextureID_mhp_red; | |
91 else if ( actor->sCurrentHP <= ( 0.67 * actor->pMonsterInfo.uHP) ) | |
92 v9 = uTextureID_mhp_yel; | |
93 else | |
94 v9 = uTextureID_mhp_grn; | |
95 | |
96 if ( actor->sCurrentHP < (int)actor->pMonsterInfo.uHP ) | |
97 v10 = bar_length / actor->pMonsterInfo.uHP * actor->sCurrentHP; | |
98 | |
99 uX = window->uFrameX + (signed int)(window->uFrameWidth - bar_length) / 2; | |
100 | |
2524 | 101 pRenderer->SetUIClipRect(uX, window->uFrameY + 32, uX + bar_length, window->uFrameY + 52); |
2497 | 102 pRenderer->DrawTextureIndexed(uX, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_bd)); |
2524 | 103 pRenderer->SetUIClipRect(uX, window->uFrameY + 32, uX + v10, window->uFrameY + 52); |
2497 | 104 pRenderer->DrawTextureIndexed(uX, window->uFrameY + 34, pIcons_LOD->GetTexture(v9)); |
105 | |
2524 | 106 pRenderer->ResetUIClipRect(); |
2497 | 107 pRenderer->DrawTextureIndexed(uX - 5, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capl)); |
108 pRenderer->DrawTextureIndexed(uX + bar_length, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capr)); | |
109 } | |
110 | |
111 //----- (00448A40) -------------------------------------------------------- | |
112 void Actor::ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle) | |
113 { | |
114 if ( uActorID >= 0 && uActorID <= (signed int)(uNumActors - 1) ) | |
115 { | |
116 if ( bToggle ) | |
117 pActors[uActorID].uAttributes |= uFlag; | |
118 else | |
119 { | |
120 if ( uFlag == 0x10000 ) | |
121 { | |
122 if (pActors[uActorID].uAIState == Disabled ) | |
123 pActors[uActorID].uAIState = Standing; | |
124 } | |
125 pActors[uActorID].uAttributes &= ~uFlag; | |
126 } | |
127 } | |
128 } | |
129 | |
130 //----- (00448518) -------------------------------------------------------- | |
131 void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3) | |
132 { | |
133 for (uint i = 0; i < uNumActors; i++) | |
134 { | |
135 if (pActors[uNumActors].sNPC_ID == npc) | |
136 Actor::GiveItem(i, item, a3); | |
137 } | |
138 } | |
139 | |
140 //----- (004485A7) -------------------------------------------------------- | |
141 void Actor::GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive) | |
142 { | |
143 if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) ) | |
144 { | |
145 if ( bGive ) | |
146 { | |
147 if ( pActors[uActorID].uCarriedItemID == 0) | |
148 pActors[uActorID].uCarriedItemID = uItemID; | |
149 else if ( pActors[uActorID].ActorHasItems[0].uItemID == 0) | |
150 pActors[uActorID].ActorHasItems[0].uItemID = uItemID; | |
151 else if ( pActors[uActorID].ActorHasItems[1].uItemID == 0) | |
152 pActors[uActorID].ActorHasItems[1].uItemID = uItemID; | |
153 } | |
154 else | |
155 { | |
156 if ( pActors[uActorID].uCarriedItemID == uItemID ) | |
157 pActors[uActorID].uCarriedItemID = 0; | |
158 else if ( pActors[uActorID].ActorHasItems[0].uItemID == uItemID ) | |
159 pActors[uActorID].ActorHasItems[0].Reset(); | |
160 else if ( pActors[uActorID].ActorHasItems[1].uItemID == uItemID ) | |
161 pActors[uActorID].ActorHasItems[1].Reset(); | |
162 } | |
163 } | |
164 } | |
165 | |
166 //----- (0040894B) -------------------------------------------------------- | |
167 bool Actor::CanAct() | |
168 { | |
169 bool isparalyzed; // esi@1 | |
170 bool isstoned; // edi@2 | |
171 | |
172 isstoned = (signed __int64)this->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0;// stoned | |
173 isparalyzed = (signed __int64)this->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0;// paralyzed | |
174 return !(isstoned || isparalyzed || this->uAIState == Dying || this->uAIState == Dead | |
175 || this->uAIState == Removed || this->uAIState == Summoned || this->uAIState == Disabled); | |
176 } | |
177 | |
178 //----- (004089C7) -------------------------------------------------------- | |
179 bool Actor::IsNotAlive() | |
180 { | |
181 bool isstoned; // esi@1 | |
182 | |
183 isstoned = (signed __int64)this->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0;// stoned | |
184 return (isstoned || (uAIState == Dying) || (uAIState == Dead) || (uAIState == Removed) || (uAIState == Summoned) || (uAIState == Disabled)); | |
185 } | |
186 | |
187 //----- (004086E9) -------------------------------------------------------- | |
188 void Actor::SetRandomGoldIfTheresNoItem() | |
189 { | |
190 int v2; // edi@1 | |
191 | |
192 v2 = 0; | |
193 if ( !this->ActorHasItems[3].uItemID ) | |
194 { | |
195 if ( this->pMonsterInfo.uTreasureDiceRolls ) | |
196 { | |
197 for (int i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++) | |
198 v2 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1; | |
199 if ( v2 ) | |
200 { | |
201 this->ActorHasItems[3].uItemID = 197; | |
202 this->ActorHasItems[3].uSpecEnchantmentType = v2; //actual gold amount | |
203 } | |
204 } | |
205 } | |
206 if ( rand() % 100 < this->pMonsterInfo.uTreasureDropChance ) | |
207 { | |
208 if ( this->pMonsterInfo.uTreasureLevel ) | |
209 pItemsTable->GenerateItem(this->pMonsterInfo.uTreasureLevel, this->pMonsterInfo.uTreasureType, &this->ActorHasItems[2]); | |
210 } | |
211 this->uAttributes |= ACTOR_HAS_ITEM; | |
212 } | |
213 | |
214 //----- (00404AC7) -------------------------------------------------------- | |
215 void Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel) | |
216 { | |
217 Actor *actorPtr; // esi@1 | |
218 unsigned int realPoints; // edi@1 | |
219 unsigned int masteryLevel; // eax@1 | |
220 int v8; // edi@16 | |
221 signed int v10; // ecx@22 | |
222 int v19; // edi@34 | |
223 int v20; // eax@35 | |
224 signed int v23; // eax@41 | |
225 int v28; // st6@50 | |
226 int v30; // esi@50 | |
227 int v31; // ST3C_4@51 | |
228 unsigned int v32; // edi@51 | |
229 signed int v36; // eax@67 | |
230 int v39; // ecx@75 | |
231 int v42; // ecx@91 | |
232 int v44; // ecx@100 | |
233 int v48; // ecx@110 | |
234 int v51; // ecx@130 | |
235 int v54; // ecx@138 | |
236 int v59; // edi@146 | |
237 int v61; // edi@146 | |
238 signed int v63; // edi@146 | |
239 int v68; // edi@168 | |
240 signed int v70; // ecx@172 | |
241 int v79; // edx@185 | |
242 int v80; // eax@185 | |
243 signed int v91; // eax@200 | |
244 int v94; // ecx@208 | |
245 int v96; // ecx@217 | |
246 int pitch; // [sp+2Ch] [bp-A4h]@51 | |
247 int v114; // [sp+48h] [bp-88h]@41 | |
248 SpriteObject a1; // [sp+4Ch] [bp-84h]@1 | |
249 int v116; // [sp+BCh] [bp-14h]@49 | |
250 int v118; // [sp+C4h] [bp-Ch]@29 | |
251 int v119; // [sp+C8h] [bp-8h]@48 | |
252 int v120; // [sp+CCh] [bp-4h]@1 | |
253 int spellnuma; // [sp+D8h] [bp+8h]@29 | |
254 int spellnumb; // [sp+D8h] [bp+8h]@48 | |
255 int spellnumc; // [sp+D8h] [bp+8h]@50 | |
256 int spellnume; // [sp+D8h] [bp+8h]@179 | |
257 int a1a; // [sp+E0h] [bp+10h]@34 | |
258 int a1c; // [sp+E0h] [bp+10h]@184 | |
259 | |
260 | |
261 actorPtr = &pActors[uActorID]; | |
262 realPoints = uSkillLevel & 0x3F; | |
263 masteryLevel = SkillToMastery(uSkillLevel); | |
264 | |
265 switch (uSpellID) | |
266 { | |
267 case SPELL_FIRE_FIRE_BOLT: | |
268 case SPELL_FIRE_FIREBALL: | |
269 case SPELL_FIRE_INCINERATE: | |
270 case SPELL_AIR_LIGHNING_BOLT: | |
271 case SPELL_WATER_ICE_BOLT: | |
272 case SPELL_WATER_ACID_BURST: | |
273 case SPELL_EARTH_BLADES: | |
274 case SPELL_EARTH_ROCK_BLAST: | |
275 case SPELL_MIND_MIND_BLAST: | |
276 case SPELL_MIND_PSYCHIC_SHOCK: | |
277 case SPELL_BODY_HARM: | |
278 case SPELL_LIGHT_LIGHT_BOLT: | |
279 case SPELL_DARK_TOXIC_CLOUD: | |
280 case SPELL_DARK_DRAGON_BREATH: | |
2566 | 281 a1.uType = spell_sprite_mapping[uSpellID].uSpriteType; |
2497 | 282 a1.uObjectDescID = GetObjDescId(uSpellID); |
2566 | 283 a1.containing_item.Reset(); |
2497 | 284 a1.spell_id = uSpellID; |
285 a1.spell_level = uSkillLevel; | |
286 a1.vPosition.x = actorPtr->vPosition.x; | |
287 a1.spell_skill = 0; | |
288 a1.vPosition.y = actorPtr->vPosition.y; | |
289 a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); | |
290 a1.uFacing = LOWORD(pDir->uYawAngle); | |
291 a1.uSoundID = 0; | |
292 a1.uAttributes = 0; | |
293 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); | |
294 a1.uSpriteFrameID = 0; | |
295 a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); | |
296 a1.spell_target_pid = 0; | |
297 if ((double)pDir->uDistance < 307.2 ) | |
298 a1.field_60_distance_related_prolly_lod = 0; | |
299 else if ( pDir->uDistance < 1024 ) | |
300 a1.field_60_distance_related_prolly_lod = 1; | |
301 else if ( pDir->uDistance < 2560 ) | |
302 a1.field_60_distance_related_prolly_lod = 2; | |
303 else | |
304 a1.field_60_distance_related_prolly_lod = 3; | |
305 | |
306 a1.field_61 = 2; | |
307 v91 = a1.Create(pDir->uYawAngle, pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); | |
308 if ( v91 != -1 ) | |
309 { | |
310 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], PID(OBJECT_Item, v91), 0, -1, 0, 0, 0, 0); | |
311 return; | |
312 } | |
313 return; | |
314 break; | |
315 | |
316 case SPELL_FIRE_HASTE: | |
317 if (masteryLevel == 1 || masteryLevel == 2) | |
318 v39 = 60 * (realPoints + 60); | |
319 else if (masteryLevel == 3 ) | |
320 v39 = 180 * (realPoints + 20); | |
321 else if (masteryLevel == 4 ) | |
322 v39 = 240 * (realPoints + 15); | |
323 else | |
324 v39 = 0; | |
325 actorPtr->pActorBuffs[ACTOR_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335), | |
326 masteryLevel, 0, 0, 0); | |
2541 | 327 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFF3C1Eu); |
2534 | 328 pAudioPlayer->PlaySound((SoundID)SOUND_Haste, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 329 return; |
330 | |
331 case SPELL_FIRE_METEOR_SHOWER: | |
332 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
333 return; | |
334 v114 = pParty->vPosition.z + 2500; | |
335 v23 = 8; | |
336 if (masteryLevel == 2) | |
337 v23 = 10; | |
338 else if (masteryLevel == 3) | |
339 v23 = 12; | |
340 else if (masteryLevel == 4) | |
341 v23 = 14; | |
342 spellnumb = 0; | |
343 v28 = 0; | |
344 for ( int i = 0; i < v23; i++) | |
345 { | |
346 v30 = rand() % 1000; | |
347 spellnumc = v30 - 2500; | |
348 v120 = v28 * v28; | |
349 v119 = spellnumb * spellnumb; | |
350 if ( sqrt((float)(spellnumc * spellnumc + v119 + v120)) <= 1.0 ) | |
351 { | |
352 v32 = 0; | |
353 pitch = 0; | |
354 } | |
355 else | |
356 { | |
357 v31 = (signed __int64)sqrt((float)(v119 + v120)); | |
358 v32 = stru_5C6E00->Atan2(spellnumb, (int)v28); | |
359 pitch = stru_5C6E00->Atan2(v31, (int)spellnumc); | |
360 } | |
2566 | 361 a1.containing_item.Reset(); |
362 a1.uType = spell_sprite_mapping[uSpellID].uSpriteType; | |
2497 | 363 a1.uObjectDescID = GetObjDescId(uSpellID); |
364 a1.spell_level = uSkillLevel; | |
365 a1.vPosition.x = pParty->vPosition.x; | |
366 a1.vPosition.y = pParty->vPosition.y; | |
367 a1.vPosition.z = v30 + v114; | |
368 a1.spell_id = SPELL_FIRE_METEOR_SHOWER; | |
369 a1.spell_skill = 0; | |
370 a1.uAttributes = 0; | |
371 a1.uSectorID = 0; | |
372 a1.uSpriteFrameID = 0; | |
373 a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); | |
374 a1.spell_target_pid = 0; | |
375 a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500); | |
376 a1.uFacing = v32; | |
377 a1.uSoundID = 0; | |
378 if (pDir->uDistance < 307.2 ) | |
379 a1.field_60_distance_related_prolly_lod = 0; | |
380 else if ( pDir->uDistance < 1024 ) | |
381 a1.field_60_distance_related_prolly_lod = 1; | |
382 else if ( pDir->uDistance < 2560 ) | |
383 a1.field_60_distance_related_prolly_lod = 2; | |
384 else | |
385 a1.field_60_distance_related_prolly_lod = 3; | |
386 a1.field_61 = 2; | |
387 v36 = a1.Create(v32, pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); | |
388 if ( v36 != -1 ) | |
389 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[9], PID(OBJECT_Item, v36), 0, -1, 0, 0, 0, 0); | |
390 spellnumb = rand() % 1024 - 512; | |
391 v28 = rand() % 1024 - 512; | |
392 } | |
393 return; | |
394 break; | |
395 | |
396 case SPELL_AIR_SPARKS: | |
397 if (masteryLevel == 2 ) | |
398 v10 = 5; | |
399 else if (masteryLevel == 3 ) | |
400 v10 = 7; | |
401 else if (masteryLevel == 4 ) | |
402 v10 = 9; | |
403 else | |
404 v10 = 3; | |
405 spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; | |
2566 | 406 a1.uType = spell_sprite_mapping[uSpellID].uSpriteType; |
2497 | 407 v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); |
408 a1.uObjectDescID = GetObjDescId(uSpellID); | |
409 | |
2566 | 410 a1.containing_item.Reset(); |
2497 | 411 a1.spell_id = SPELL_AIR_SPARKS; |
412 a1.spell_level = uSkillLevel; | |
413 a1.vPosition.x = actorPtr->vPosition.x; | |
414 a1.spell_skill = 0; | |
415 a1.vPosition.y = actorPtr->vPosition.y; | |
416 a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); | |
417 a1.uFacing = pDir->uYawAngle; | |
418 a1.uSoundID = 0; | |
419 a1.uAttributes = 0; | |
420 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); | |
421 a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); | |
422 a1.uSpriteFrameID = 0; | |
423 a1.spell_target_pid = 0; | |
424 a1.field_60_distance_related_prolly_lod = 3; | |
425 v19 = spellnuma / -2; | |
426 a1a = spellnuma / 2; | |
427 if ( spellnuma / -2 > spellnuma / 2 ) | |
428 v20 = spellnuma / 2; | |
429 else | |
430 { | |
431 do | |
432 { | |
433 a1.uFacing = v19 + LOWORD(pDir->uYawAngle); | |
434 v20 = a1.Create((signed __int16)a1.uFacing, pDir->uPitchAngle, | |
435 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); | |
436 v19 += v118; | |
437 } | |
438 while ( v19 <= a1a ); | |
439 } | |
440 if ( v20 != -1 ) | |
441 { | |
442 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[15], PID(OBJECT_Item, v20), 0, -1, 0, 0, 0, 0); | |
443 return; | |
444 } | |
445 return; | |
446 break; | |
447 | |
448 case SPELL_AIR_SHIELD: | |
449 if (masteryLevel == 1 || masteryLevel == 2) | |
450 v8 = 300 * realPoints + 3840; | |
451 else if (masteryLevel == 3 ) | |
452 v8 = 900 * realPoints + 3840; | |
453 else if (masteryLevel == 4 ) | |
454 v8 = 3600 * (realPoints + 64); | |
455 else | |
456 v8 = 0; | |
457 actorPtr->pActorBuffs[ACTOR_BUFF_SHIELD].Apply( | |
458 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335), | |
459 masteryLevel, 0, 0, 0); | |
460 return; | |
461 | |
462 case SPELL_EARTH_STONESKIN: | |
463 if (masteryLevel == 1 || masteryLevel == 2) | |
464 v44 = 300 * realPoints + 3840; | |
465 else if (masteryLevel == 3 ) | |
466 v44 = 900 * realPoints + 3840; | |
467 else if (masteryLevel == 4 ) | |
468 v44 = 3600 * (realPoints + 64); | |
469 else | |
470 v44 = 0; | |
471 actorPtr->pActorBuffs[ACTOR_BUFF_STONESKIN].Apply( | |
472 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335), | |
473 masteryLevel, realPoints + 5, 0, 0); | |
2541 | 474 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x5C310Eu); |
2534 | 475 pAudioPlayer->PlaySound((SoundID)SOUND_Stoneskin, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 476 return; |
477 | |
478 case SPELL_SPIRIT_BLESS: | |
479 if (masteryLevel == 1 || masteryLevel == 2) | |
480 v42 = 300 * realPoints + 3840; | |
481 else if (masteryLevel == 3 ) | |
482 v42 = 900 * realPoints + 3840; | |
483 else if (masteryLevel == 4 ) | |
484 v42 = 1200 * realPoints + 3840; | |
485 else | |
486 v42 = 0; | |
487 actorPtr->pActorBuffs[ACTOR_BUFF_BLESS].Apply( | |
488 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335), | |
489 masteryLevel, realPoints + 5, 0, 0); | |
2541 | 490 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); |
2534 | 491 pAudioPlayer->PlaySound((SoundID)SOUND_Bless, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 492 return; |
493 break; | |
494 | |
495 case SPELL_SPIRIT_FATE: | |
496 if (masteryLevel == 1 || masteryLevel == 2) | |
497 v48 = 2 * realPoints + 40; | |
498 else if (masteryLevel == 3 ) | |
499 v48 = 3 * realPoints + 60; | |
500 else if (masteryLevel == 4 ) | |
501 v48 = 2 * (3 * realPoints + 60); | |
502 else | |
503 v48 = 0; | |
504 actorPtr->pActorBuffs[ACTOR_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, masteryLevel, v48, 0, 0); | |
2541 | 505 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); |
2534 | 506 pAudioPlayer->PlaySound((SoundID)SOUND_Fate, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 507 return; |
508 | |
509 case SPELL_SPIRIT_HEROISM: | |
510 if (masteryLevel == 1 || masteryLevel == 2) | |
511 v54 = 300 * realPoints + 3840; | |
512 else if (masteryLevel == 3 ) | |
513 v54 = 900 * realPoints + 3840; | |
514 else if (masteryLevel == 4 ) | |
515 v54 = 1200 * realPoints + 3840; | |
516 else | |
517 v54 = 0; | |
518 actorPtr->pActorBuffs[ACTOR_BUFF_HEROISM].Apply( | |
519 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335), | |
520 masteryLevel, realPoints + 5, 0, 0); | |
2541 | 521 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); |
2534 | 522 pAudioPlayer->PlaySound((SoundID)SOUND_51heroism03, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 523 return; |
524 | |
525 case SPELL_BODY_HAMMERHANDS: | |
526 if ( (signed int)masteryLevel <= 0 || (signed int)masteryLevel > 4 ) | |
527 v51 = 0; | |
528 else | |
529 v51 = 3600 * realPoints; | |
530 actorPtr->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].Apply( | |
531 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335), | |
532 masteryLevel, | |
533 realPoints, | |
534 0, | |
535 0); | |
2541 | 536 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); |
2534 | 537 pAudioPlayer->PlaySound((SoundID)SOUND_51heroism03, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 538 return; |
539 | |
540 case SPELL_BODY_POWER_CURE: | |
541 actorPtr->sCurrentHP += 5 * realPoints + 10; | |
542 if ( actorPtr->sCurrentHP >= (signed int)actorPtr->pMonsterInfo.uHP ) | |
543 actorPtr->sCurrentHP = LOWORD(actorPtr->pMonsterInfo.uHP); | |
2541 | 544 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); |
2534 | 545 pAudioPlayer->PlaySound((SoundID)SOUND_Fate, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 546 return; |
547 | |
548 case SPELL_LIGHT_DISPEL_MAGIC: | |
549 for (int i = 0; i < 20; i++ ) | |
550 pParty->pPartyBuffs[i].Reset(); | |
551 for (int i = 1; i <= 4; i++) | |
552 { | |
553 v59 = pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualWillpower()); | |
554 v61 = (pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualIntelligence()) + v59) / 2; | |
555 v63 = v61 + pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualLuck()) + 30; | |
556 if ( rand() % v63 < 30 ) | |
557 { | |
558 for (uint k = 0; k < pPlayers[i]->pPlayerBuffs.size(); k++) | |
559 pPlayers[i]->pPlayerBuffs[k].Reset(); | |
560 pOtherOverlayList->_4418B1(11210, i + 99, 0, 65536); | |
561 } | |
562 } | |
563 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[80], PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | |
564 return; | |
565 | |
566 case SPELL_LIGHT_DAY_OF_PROTECTION: | |
567 if (masteryLevel == 1 || masteryLevel == 2) | |
568 v96 = 300 * realPoints + 3840; | |
569 else if (masteryLevel == 3 ) | |
570 { | |
571 LOWORD(realPoints) = 3 * realPoints; | |
572 v96 = 900 * (uSkillLevel & 0x3F) + 3840; | |
573 } | |
574 else if (masteryLevel == 4 ) | |
575 { | |
576 v96 = 1200 * realPoints + 3840; | |
577 LOWORD(realPoints) = 4 * realPoints; | |
578 } | |
579 else | |
580 { | |
581 LOWORD(realPoints) = uSkillLevel; | |
582 v96 = 0; | |
583 } | |
584 actorPtr->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].Apply( | |
585 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335), | |
586 masteryLevel, realPoints, 0, 0); | |
2541 | 587 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); |
2534 | 588 pAudioPlayer->PlaySound((SoundID)SOUND_94dayofprotection03, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 589 return; |
590 | |
591 case SPELL_LIGHT_HOUR_OF_POWER: | |
592 if (masteryLevel == 1 || masteryLevel == 2) | |
593 v94 = 300 * realPoints + 3840; | |
594 else if (masteryLevel == 3) | |
595 v94 = 900 * realPoints + 3840; | |
596 else if (masteryLevel == 4) | |
597 v94 = 1200 * realPoints + 3840; | |
598 else | |
599 v94 = 0; | |
600 actorPtr->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].Apply( | |
601 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335), | |
602 masteryLevel, realPoints + 5, 0, 0); | |
2541 | 603 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); |
2534 | 604 pAudioPlayer->PlaySound((SoundID)SOUND_9armageddon01, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 605 return; |
606 | |
607 case SPELL_DARK_SHARPMETAL: | |
608 if (masteryLevel == 2) | |
609 v70 = 5; | |
610 else if (masteryLevel == 3) | |
611 v70 = 7; | |
612 else if (masteryLevel == 4) | |
613 v70 = 9; | |
614 else | |
615 v70 = 3; | |
616 | |
617 spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; | |
2566 | 618 a1.uType = spell_sprite_mapping[uSpellID].uSpriteType; |
2497 | 619 v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); |
620 a1.uObjectDescID = GetObjDescId(uSpellID); | |
2566 | 621 a1.containing_item.Reset(); |
2497 | 622 a1.spell_id = uSpellID; |
623 a1.spell_level = uSkillLevel; | |
624 a1.vPosition.x = actorPtr->vPosition.x; | |
625 a1.spell_skill = 0; | |
626 a1.vPosition.y = actorPtr->vPosition.y; | |
627 a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); | |
628 a1.uFacing = pDir->uYawAngle; | |
629 a1.uSoundID = 0; | |
630 a1.uAttributes = 0; | |
631 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); | |
632 a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); | |
633 a1.uSpriteFrameID = 0; | |
634 a1.spell_target_pid = 0; | |
635 a1.field_60_distance_related_prolly_lod = 3; | |
636 a1c = spellnume / -2; | |
637 if ( spellnume / -2 > spellnume / 2 ) | |
638 v80 = spellnume / -2; | |
639 else | |
640 { | |
641 do | |
642 { | |
643 v79 = pDir->uYawAngle; | |
644 a1.uFacing = a1c + LOWORD(pDir->uYawAngle); | |
645 v80 = a1.Create(v79, pDir->uPitchAngle, | |
646 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); | |
647 a1c += v116; | |
648 } | |
649 while ( a1c <= spellnume / 2 ); | |
650 } | |
651 if ( v80 != -1 ) | |
652 { | |
653 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[93], PID(OBJECT_Item, v80), 0, -1, 0, 0, 0, 0); | |
654 return; | |
655 } | |
656 return; | |
657 break; | |
658 | |
659 case SPELL_DARK_PAIN_REFLECTION: | |
660 if (masteryLevel == 0) | |
661 v68 = 0; | |
662 else if (masteryLevel == 1 || (masteryLevel == 2) || (masteryLevel == 3)) | |
663 v68 = 300 * realPoints + 3840; | |
664 else | |
665 v68 = 900 * realPoints + 3840; | |
666 actorPtr->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].Apply( | |
667 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335), | |
668 masteryLevel, 0, 0, 0); | |
2541 | 669 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x7E7E7Eu); |
2534 | 670 pAudioPlayer->PlaySound((SoundID)SOUND_Sacrifice2, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
2497 | 671 return; |
672 } | |
673 } | |
674 | |
675 //----- (new func) -------------------------------------------------------- | |
676 unsigned short Actor::GetObjDescId( int spellId ) | |
677 { | |
678 for (unsigned int i = 0; i < pObjectList->uNumObjects; i++) | |
679 { | |
2566 | 680 if (spell_sprite_mapping[spellId].uSpriteType == pObjectList->pObjects[i].uObjectID) |
2497 | 681 { |
682 return i; | |
683 break; | |
684 } | |
685 } | |
686 return 0; | |
687 } | |
688 | |
689 | |
690 //----- (0043ABB0) -------------------------------------------------------- | |
691 bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2) | |
692 { | |
693 unsigned int v2; // esi@1 | |
694 unsigned int v3; // edi@1 | |
695 | |
696 v2 = a1->uAlly; | |
697 if ( !a1->uAlly ) | |
698 v2 = (a1->pMonsterInfo.uID - 1) / 3 + 1; | |
699 | |
700 v3 = a2->uAlly; | |
701 if ( !a2->uAlly ) | |
702 v3 = (a2->pMonsterInfo.uID - 1) / 3 + 1; | |
703 | |
704 if ( v2 >= 39 && v2 <= 44 && v3 >= 39 && v3 <= 44 | |
705 || v2 >= 45 && v2 <= 50 && v3 >= 45 && v3 <= 50 | |
706 || v2 >= 51 && v2 <= 62 && v3 >= 51 && v3 <= 62 | |
707 || v2 >= 78 && v2 <= 83 && v3 >= 78 && v3 <= 83 | |
708 || v2 == v3 | |
709 ) | |
710 return true; | |
711 else | |
712 return false; | |
713 } | |
714 | |
715 //----- (0043AC45) -------------------------------------------------------- | |
716 void Actor::AggroSurroundingPeasants(unsigned int uActorID, int a2) | |
717 { | |
718 int v4; // ebx@8 | |
719 int v5; // ST1C_4@8 | |
720 int v6; // eax@8 | |
721 | |
722 int x = 0; x |= 0x80000; | |
723 int y = 0; y |= 0x80000; | |
724 Actor* victim = &pActors[uActorID]; | |
725 if ( a2 == 1 ) | |
726 victim->uAttributes |= ACTOR_AGGRESSOR; | |
727 | |
728 for (uint i = 0; i < uNumActors; ++i) | |
729 { | |
730 Actor* actor = &pActors[i]; | |
731 if (!actor->CanAct() || i == uActorID) | |
732 continue; | |
733 | |
734 if (Actor::ArePeasantsOfSameFaction(victim, actor)) | |
735 { | |
736 v4 = abs(actor->vPosition.x - victim->vPosition.x); | |
737 v5 = abs(actor->vPosition.y - victim->vPosition.y); | |
738 v6 = abs(actor->vPosition.z - victim->vPosition.z); | |
739 if (int_get_vector_length(v4, v5, v6) < 4096) | |
740 { | |
741 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
742 if ( a2 == 1 ) | |
743 actor->uAttributes |= ACTOR_AGGRESSOR; | |
744 | |
745 } | |
746 } | |
747 } | |
748 } | |
749 | |
750 //----- (00404874) -------------------------------------------------------- | |
751 void Actor::AI_RangedAttack( unsigned int uActorID, struct AIDirection *pDir, int type, char a4 ) | |
752 { | |
753 char specAb; // al@1 | |
754 int v13; // edx@28 | |
755 | |
756 SpriteObject a1; // [sp+Ch] [bp-74h]@1 | |
757 | |
758 switch ( type ) | |
759 { | |
760 case 1: | |
2566 | 761 a1.uType = SPRITE_PROJECTILE_545; |
2497 | 762 break; |
763 case 2: | |
2566 | 764 a1.uType = SPRITE_PROJECTILE_550; |
2497 | 765 break; |
766 case 3: | |
2566 | 767 a1.uType = SPRITE_PROJECTILE_510; |
2497 | 768 break; |
769 case 4: | |
2566 | 770 a1.uType = SPRITE_PROJECTILE_500; |
2497 | 771 break; |
772 case 5: | |
2566 | 773 a1.uType = SPRITE_PROJECTILE_515; |
2497 | 774 break; |
775 case 6: | |
2566 | 776 a1.uType = SPRITE_PROJECTILE_505; |
2497 | 777 break; |
778 case 7: | |
2566 | 779 a1.uType = SPRITE_PROJECTILE_530; |
2497 | 780 break; |
781 case 8: | |
2566 | 782 a1.uType = SPRITE_PROJECTILE_525; |
2497 | 783 break; |
784 case 9: | |
2566 | 785 a1.uType = SPRITE_PROJECTILE_520; |
2497 | 786 break; |
787 case 10: | |
2566 | 788 a1.uType = SPRITE_PROJECTILE_535; |
2497 | 789 break; |
790 case 11: | |
2566 | 791 a1.uType = SPRITE_PROJECTILE_540; |
2497 | 792 break; |
793 case 13: | |
2566 | 794 a1.uType = SPRITE_PROJECTILE_555; |
2497 | 795 break; |
796 default: | |
797 return; | |
798 } | |
799 bool found = false; | |
800 for ( uint i = 0; i < pObjectList->uNumObjects; i++) | |
801 { | |
802 if (pObjectList->pObjects[i].uObjectID == a1.uType) | |
803 { | |
804 a1.uObjectDescID = i; | |
805 found = true; | |
806 break; | |
807 } | |
808 } | |
809 if (!found) | |
810 { | |
811 Error("Item not found"); | |
812 return; | |
813 } | |
2566 | 814 a1.containing_item.Reset(); |
2497 | 815 a1.spell_id = 0; |
816 a1.vPosition.x = pActors[uActorID].vPosition.x; | |
817 a1.vPosition.y = pActors[uActorID].vPosition.y; | |
818 a1.vPosition.z = pActors[uActorID].vPosition.z - (unsigned int)(pActors[uActorID].uActorHeight * -0.75); | |
819 a1.spell_level = 0; | |
820 a1.spell_skill = 0; | |
821 a1.uFacing = pDir->uYawAngle; | |
822 a1.uSoundID = 0; | |
823 a1.uAttributes = 0; | |
824 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); | |
825 a1.uSpriteFrameID = 0; | |
826 a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); | |
827 a1.spell_target_pid = 0; | |
828 if (pDir->uDistance < 307.2 ) | |
829 a1.field_60_distance_related_prolly_lod = 0; | |
830 else if ( pDir->uDistance < 1024 ) | |
831 a1.field_60_distance_related_prolly_lod = 1; | |
832 else if ( pDir->uDistance < 2560 ) | |
833 a1.field_60_distance_related_prolly_lod = 2; | |
834 else | |
835 a1.field_60_distance_related_prolly_lod = 3; | |
836 | |
837 a1.field_61 = a4; | |
838 a1.Create(pDir->uYawAngle, pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); | |
839 if ( pActors[uActorID].pMonsterInfo.uSpecialAbilityType == 1 ) | |
840 { | |
841 specAb = pActors[uActorID].pMonsterInfo.uSpecialAbilityDamageDiceBonus; | |
842 if ( specAb == 2 ) | |
843 { | |
844 a1.vPosition.z += 40; | |
845 v13 = pDir->uYawAngle; | |
846 } | |
847 else | |
848 { | |
849 if ( specAb != 3 ) | |
850 return; | |
851 a1.Create(pDir->uYawAngle + 30, //TODO find out why the YawAngle change | |
852 pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); | |
853 v13 = pDir->uYawAngle - 30; | |
854 } | |
855 a1.Create(v13, pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); | |
856 } | |
857 return; | |
858 } | |
859 | |
860 //----- (00404736) -------------------------------------------------------- | |
861 void Actor::Explode( unsigned int uActorID ) | |
862 { | |
863 SpriteObject a1; // [sp+Ch] [bp-78h]@1 | |
864 | |
2566 | 865 a1.uType = SPRITE_600; |
2497 | 866 a1.uObjectDescID = GetObjDescId(a1.uType); |
2566 | 867 a1.containing_item.Reset(); |
2497 | 868 a1.spell_id = 0; |
869 a1.spell_level = 0; | |
870 a1.spell_skill = 0; | |
871 a1.vPosition.x = pActors[uActorID].vPosition.x; | |
872 a1.vPosition.y = pActors[uActorID].vPosition.y; | |
873 a1.vPosition.z = pActors[uActorID].vPosition.z - (unsigned int)(pActors[uActorID].uActorHeight * -0.75); | |
874 a1.uFacing = 0; | |
875 a1.uSoundID = 0; | |
876 a1.uAttributes = 0; | |
877 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); | |
878 a1.uSpriteFrameID = 0; | |
879 a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); | |
880 a1.spell_target_pid = 0; | |
881 a1.field_60_distance_related_prolly_lod = 3; | |
882 a1.field_61 = 4; | |
883 a1.Create(0, 0, 0, 0); | |
884 return; | |
885 } | |
886 | |
887 //----- (004040E9) -------------------------------------------------------- | |
888 // // Get direction vector from object1 to object2, | |
889 // // distance from object1 to object2 and Euler angles of the direction vector | |
890 // // | |
891 // // | |
892 // // object1 & object2 format : objectType | (objectID << 3) | |
893 // // objectType == 2 - SpriteObject | |
894 // // objectType == 3 - Actor | |
895 // // objectType == 4 - Party | |
896 // // objectType == 5 - Decoration | |
897 // // | |
898 // // originally this function had following prototype: | |
899 // // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4) | |
900 // // but compiler converts functions returning structures by value in the such way | |
901 void Actor::GetDirectionInfo( unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4 ) | |
902 { | |
903 signed int v4; // eax@1 | |
904 signed int v5; // ecx@1 | |
905 int v18; // edx@15 | |
906 float v31; // st7@45 | |
907 float v32; // st6@45 | |
908 float v33; // st7@45 | |
909 Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15 | |
910 AIDirection v41; // [sp+14h] [bp-38h]@46 | |
911 float outy2; // [sp+38h] [bp-14h]@33 | |
912 float outx2; // [sp+3Ch] [bp-10h]@33 | |
913 int outz; // [sp+40h] [bp-Ch]@6 | |
914 int outy; // [sp+44h] [bp-8h]@6 | |
915 int outx; // [sp+48h] [bp-4h]@6 | |
916 float a4a; // [sp+58h] [bp+Ch]@45 | |
917 | |
918 v4 = PID_ID(uObj1ID); | |
919 //v6 = uObj2ID; | |
920 v5 = PID_ID(uObj2ID); | |
921 switch( PID_TYPE(uObj1ID) ) | |
922 { | |
923 case OBJECT_Item: | |
924 { | |
925 outx = pSpriteObjects[v4].vPosition.x; | |
926 outy = pSpriteObjects[v4].vPosition.y; | |
927 outz = pSpriteObjects[v4].vPosition.z; | |
928 break; | |
929 } | |
930 case OBJECT_Actor: | |
931 { | |
932 outx = pActors[v4].vPosition.x; | |
933 outy = pActors[v4].vPosition.y; | |
934 outz = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v4].uActorHeight * -0.75); | |
935 break; | |
936 } | |
937 case OBJECT_Player: | |
938 { | |
939 if ( !v4 ) | |
940 { | |
941 outx = pParty->vPosition.x; | |
942 outy = pParty->vPosition.y; | |
943 outz = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
944 break; | |
945 } | |
946 if ( v4 == 4 ) | |
947 { | |
948 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; | |
949 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
950 v37.x = pParty->vPosition.x; | |
951 v37.y = pParty->vPosition.y; | |
952 Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); | |
953 break; | |
954 } | |
955 if ( v4 == 3 ) | |
956 { | |
957 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; | |
958 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
959 v37.x = pParty->vPosition.x; | |
960 v37.y = pParty->vPosition.y; | |
961 Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); | |
962 break; | |
963 } | |
964 if ( v4 == 2 ) | |
965 { | |
966 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
967 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; | |
968 v37.x = pParty->vPosition.x; | |
969 v37.y = pParty->vPosition.y; | |
970 Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); | |
971 break; | |
972 } | |
973 if ( v4 == 1 ) | |
974 { | |
975 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
976 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; | |
977 v37.x = pParty->vPosition.x; | |
978 v37.y = pParty->vPosition.y; | |
979 Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); | |
980 break; | |
981 } | |
982 } | |
983 case OBJECT_Decoration: | |
984 { | |
985 outx = pLevelDecorations[v4].vPosition.x; | |
986 outy = pLevelDecorations[v4].vPosition.y; | |
987 outz = pLevelDecorations[v4].vPosition.z; | |
988 break; | |
989 } | |
990 default: | |
991 { | |
992 outz = 0; | |
993 outy = 0; | |
994 outx = 0; | |
995 break; | |
996 } | |
997 case OBJECT_BModel: | |
998 { | |
999 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1000 { | |
1001 outx = (pIndoor->pFaces[v4].pBounding.x1 + pIndoor->pFaces[v4].pBounding.x2) >> 1; | |
1002 outy = (pIndoor->pFaces[v4].pBounding.y1 + pIndoor->pFaces[v4].pBounding.y2) >> 1; | |
1003 outz = (pIndoor->pFaces[v4].pBounding.z1 + pIndoor->pFaces[v4].pBounding.z2) >> 1; | |
1004 } | |
1005 break; | |
1006 } | |
1007 } | |
1008 | |
1009 switch( PID_TYPE(uObj2ID) ) | |
1010 { | |
1011 case OBJECT_Item: | |
1012 { | |
1013 outx2 = (float)pSpriteObjects[v5].vPosition.x; | |
1014 outy2 =(float) pSpriteObjects[v5].vPosition.y; | |
1015 a4 = pSpriteObjects[v5].vPosition.z; | |
1016 break; | |
1017 } | |
1018 case OBJECT_Actor: | |
1019 { | |
1020 outx2 = (float)pActors[v5].vPosition.x; | |
1021 outy2 = (float)pActors[v5].vPosition.y; | |
1022 a4 = pActors[v5].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v5].uActorHeight * -0.75); | |
1023 break; | |
1024 } | |
1025 case OBJECT_Player: | |
1026 { | |
1027 outx2 = (float)pParty->vPosition.x; | |
1028 outy2 = (float)pParty->vPosition.y; | |
1029 if ( !a4 ) | |
1030 a4 = pParty->sEyelevel; | |
1031 a4 = pParty->vPosition.z + a4; | |
1032 break; | |
1033 } | |
1034 case OBJECT_Decoration: | |
1035 { | |
1036 outx2 = (float)pLevelDecorations[v5].vPosition.x; | |
1037 outy2 = (float)pLevelDecorations[v5].vPosition.y; | |
1038 a4 = pLevelDecorations[v5].vPosition.z; | |
1039 break; | |
1040 } | |
1041 default: | |
1042 { | |
1043 outx2 = 0.0; | |
1044 outy2 = 0.0; | |
1045 a4 = 0; | |
1046 break; | |
1047 } | |
1048 case OBJECT_BModel: | |
1049 { | |
1050 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1051 { | |
1052 outx2 = (float)((pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1); | |
1053 outy2 = (float)((pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1); | |
1054 a4 = (pIndoor->pFaces[v5].pBounding.z1 + pIndoor->pFaces[v5].pBounding.z2) >> 1; | |
1055 } | |
1056 break; | |
1057 } | |
1058 } | |
1059 | |
1060 v31 = (float)outx2 - (float)outx; | |
1061 v32 = (float)outy2 - (float)outy; | |
1062 a4a = (float)a4 - (float)outz; | |
1063 outx2 = v32 * v32; | |
1064 outy2 = v31 * v31; | |
1065 v33 = sqrt(a4a * a4a + outy2 + outx2); | |
1066 if ( v33 <= 1.0 ) | |
1067 { | |
1068 pOut->vDirection.x = 65536; | |
1069 pOut->vDirection.y = 0; | |
1070 pOut->vDirection.z = 0; | |
1071 pOut->uDistance = 1; | |
1072 pOut->uDistanceXZ = 1; | |
1073 pOut->uYawAngle = 0; | |
1074 pOut->uPitchAngle = 0; | |
1075 } | |
1076 else | |
1077 { | |
1078 pOut->vDirection.x = (int32_t)(1.0 / v33 * v31 * 65536.0); | |
1079 pOut->vDirection.y = (int32_t)(1.0 / v33 * v32 * 65536.0); | |
1080 pOut->vDirection.z = (int32_t)(1.0 / v33 * a4a * 65536.0); | |
1081 pOut->uDistance = (uint)v33; | |
1082 pOut->uDistanceXZ = (uint)sqrt(outy2 + outx2); | |
1083 pOut->uYawAngle = stru_5C6E00->Atan2((signed __int64)v31, (signed __int64)v32); | |
1084 pOut->uPitchAngle = stru_5C6E00->Atan2(pOut->uDistanceXZ, (signed __int64)a4a); | |
1085 } | |
1086 } | |
1087 | |
1088 //----- (00404030) -------------------------------------------------------- | |
1089 void Actor::AI_FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4) | |
1090 { | |
1091 AIDirection *v7; // eax@3 | |
1092 AIDirection v1; // eax@3 | |
1093 AIDirection a3; // [sp+8h] [bp-38h]@4 | |
1094 | |
1095 if ( rand() % 100 >= 5 ) | |
1096 { | |
1097 //v9 = &pActors[uActorID]; | |
1098 if ( !a4 ) | |
1099 { | |
1100 Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), uObjID, &v1, 0); | |
1101 v7 = &v1; | |
1102 } | |
1103 else | |
1104 v7 = a4; | |
1105 pActors[uActorID].uYawAngle = v7->uYawAngle; | |
1106 pActors[uActorID].uCurrentActionTime = 0; | |
1107 pActors[uActorID].vVelocity.z = 0; | |
1108 pActors[uActorID].vVelocity.y = 0; | |
1109 pActors[uActorID].vVelocity.x = 0; | |
1110 pActors[uActorID].uPitchAngle = v7->uPitchAngle; | |
1111 pActors[uActorID].uCurrentActionLength = 256; | |
1112 pActors[uActorID].uAIState = Interacting; | |
1113 pActors[uActorID].UpdateAnimation(); | |
1114 } | |
1115 else | |
1116 Actor::AI_Bored(uActorID, uObjID, a4); | |
1117 } | |
1118 | |
1119 //----- (00403F58) -------------------------------------------------------- | |
1120 void Actor::AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) | |
1121 { | |
1122 if (rand() % 2)//0 or 1 | |
1123 AI_Bored(uActorID, uObjID, a4); | |
1124 else | |
1125 AI_Stand(uActorID, uObjID, uActionLength, a4); | |
1126 } | |
1127 | |
1128 //----- (00403EB6) -------------------------------------------------------- | |
1129 void Actor::AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, AIDirection *a4) | |
1130 { | |
1131 assert(uActorID < uNumActors); | |
1132 // Actor* actor = &pActors[uActorID]; | |
1133 | |
1134 AIDirection a3; | |
1135 if (!a4) | |
1136 { | |
1137 Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0); | |
1138 a4 = &a3; | |
1139 } | |
1140 | |
1141 pActors[uActorID].uAIState = Standing; | |
1142 if (!uActionLength) | |
1143 pActors[uActorID].uCurrentActionLength = rand() % 256 + 256;// от 256 до 256 + 256 | |
1144 else | |
1145 pActors[uActorID].uCurrentActionLength = uActionLength; | |
1146 pActors[uActorID].uCurrentActionTime = 0; | |
1147 pActors[uActorID].uYawAngle = a4->uYawAngle; | |
1148 pActors[uActorID].uPitchAngle = a4->uPitchAngle; | |
1149 pActors[uActorID].vVelocity.z = 0; | |
1150 pActors[uActorID].vVelocity.y = 0; | |
1151 pActors[uActorID].vVelocity.x = 0; | |
1152 pActors[uActorID].UpdateAnimation(); | |
1153 } | |
1154 | |
1155 //----- (00403E61) -------------------------------------------------------- | |
1156 void __fastcall Actor::StandAwhile(unsigned int uActorID) | |
1157 { | |
1158 pActors[uActorID].uCurrentActionLength = rand() % 128 + 128; | |
1159 pActors[uActorID].uCurrentActionTime = 0; | |
1160 pActors[uActorID].uAIState = Standing; | |
1161 pActors[uActorID].vVelocity.z = 0; | |
1162 pActors[uActorID].vVelocity.y = 0; | |
1163 pActors[uActorID].vVelocity.x = 0; | |
1164 pActors[uActorID].UpdateAnimation(); | |
1165 } | |
1166 | |
1167 //----- (00403C6C) -------------------------------------------------------- | |
1168 void Actor::AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) | |
1169 { | |
1170 int16_t v6; // esi@6 | |
1171 int16_t v7; // edi@6 | |
1172 signed int v8; // eax@7 | |
1173 Vec3_int_ v10; // ST04_12@9 | |
1174 AIDirection *v12; // eax@11 | |
1175 AIDirection a3; // [sp+Ch] [bp-48h]@12 | |
1176 AIDirection v20; // [sp+28h] [bp-2Ch]@12 | |
1177 int v23; // [sp+4Ch] [bp-8h]@6 | |
1178 unsigned int v25; // [sp+5Ch] [bp+8h]@13 | |
1179 | |
1180 assert(uActorID < uNumActors); | |
1181 | |
1182 if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY && pActors[uActorID].pMonsterInfo.uAIType == 1 ) | |
1183 { | |
1184 Actor::AI_Stand(uActorID, sTargetPid, 0, arg0); | |
1185 return; | |
1186 } | |
1187 | |
1188 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | |
1189 { | |
1190 v8 = PID_ID(sTargetPid); | |
1191 v6 = pActors[v8].vPosition.x; | |
1192 v7 = pActors[v8].vPosition.y; | |
1193 v23 = (int)(pActors[v8].uActorHeight * 0.75 + pActors[v8].vPosition.z); | |
1194 } | |
1195 else if ( PID_TYPE(sTargetPid) == OBJECT_Player) | |
1196 { | |
1197 v6 = pParty->vPosition.x; | |
1198 v7 = pParty->vPosition.y; | |
1199 v23 = pParty->vPosition.z + pParty->sEyelevel; | |
1200 } | |
1201 else | |
1202 { | |
1203 Error("Should not get here"); | |
1204 return; | |
1205 } | |
1206 | |
1207 v10.x = pActors[uActorID].vPosition.x; | |
1208 v10.y = pActors[uActorID].vPosition.y; | |
1209 v10.z = (int32_t)(pActors[uActorID].uActorHeight * 0.75 + pActors[uActorID].vPosition.z); | |
1210 | |
1211 if ( sub_407A1C((int)v6, (int)v7, v23, v10) ) | |
1212 { | |
1213 if (arg0 != nullptr) | |
1214 v12 = arg0; | |
1215 else | |
1216 { | |
1217 Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), sTargetPid, &a3, 0); | |
1218 v12 = &a3; | |
1219 } | |
1220 pActors[uActorID].uYawAngle = LOWORD(v12->uYawAngle); | |
1221 pActors[uActorID].uCurrentActionLength = pSpriteFrameTable->pSpriteSFrames[pActors[uActorID].pSpriteIDs[ANIM_AtkMelee]].uAnimLength * 8; | |
1222 pActors[uActorID].uCurrentActionTime = 0; | |
1223 pActors[uActorID].uAIState = AttackingMelee; | |
1224 Actor::PlaySound(uActorID, 0); | |
1225 v25 = pMonsterStats->pInfos[pActors[uActorID].pMonsterInfo.uID].uRecoveryTime; | |
1226 if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) | |
1227 v25 *= 2; | |
1228 if ( pParty->bTurnBasedModeOn != 1 ) | |
1229 pActors[uActorID].pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * v25 * 2.133333333333333); | |
1230 else | |
1231 pActors[uActorID].pMonsterInfo.uRecoveryTime = v25; | |
1232 pActors[uActorID].vVelocity.z = 0; | |
1233 pActors[uActorID].vVelocity.y = 0; | |
1234 pActors[uActorID].vVelocity.x = 0; | |
1235 pActors[uActorID].UpdateAnimation(); | |
1236 } | |
1237 else | |
1238 Actor::AI_Pursue1(uActorID, sTargetPid, rand() % 2, 64, arg0); | |
1239 } | |
1240 | |
1241 //----- (00438CF3) -------------------------------------------------------- | |
1242 void Actor::ApplyFineForKillingPeasant(unsigned int uActorID) | |
1243 { | |
1244 if ( uLevelMapStatsID == 0 || !pActors[uActorID].IsPeasant()) | |
1245 return; | |
1246 | |
1247 if ( (uLevelMapStatsID == 6 || uLevelMapStatsID == 7) && pParty->IsPartyEvil()) //celeste and bracada | |
1248 return; | |
1249 | |
1250 if ( (uLevelMapStatsID == 5 || uLevelMapStatsID == 8) && pParty->IsPartyGood()) // the pit and deyja | |
1251 return; | |
1252 | |
1253 pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[uActorID].pMonsterInfo.uLevel + pParty->GetPartyReputation()); | |
1254 if ( pParty->uFine < 0 ) | |
1255 pParty->uFine = 0; | |
1256 if ( pParty->uFine > 4000000 ) | |
1257 pParty->uFine = 4000000; | |
1258 | |
1259 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
1260 { | |
1261 if (pOutdoor->ddm.uReputation < 10000) | |
1262 pOutdoor->ddm.uReputation++; | |
1263 } | |
1264 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1265 { | |
1266 if (pIndoor->dlv.uReputation < 10000) | |
1267 pIndoor->dlv.uReputation++; | |
1268 } | |
1269 else assert(false); | |
1270 | |
1271 if ( pParty->uFine ) | |
1272 { | |
1273 for ( int i = 1; i <= 4; i++) | |
1274 { | |
1275 if ( !_449B57_test_bit(pPlayers[i]->_achieved_awards_bits, 1) ) | |
1276 _449B7E_toggle_bit(pPlayers[i]->_achieved_awards_bits, 1, 1u); | |
1277 } | |
1278 } | |
1279 } | |
1280 | |
1281 //----- (0043AE80) -------------------------------------------------------- | |
1282 void Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3) | |
1283 { | |
1284 unsigned int v4; // esi@1 | |
1285 | |
1286 v4 = PID(OBJECT_Actor,uActorID); | |
1287 switch ( a2 ) | |
1288 { | |
1289 case 1: | |
1290 if ( a3 ) | |
1291 pOtherOverlayList->_4418B6(904, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); | |
1292 return; | |
1293 case 2: | |
1294 if ( a3 ) | |
1295 pOtherOverlayList->_4418B6(905, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); | |
1296 return; | |
1297 case 3: | |
1298 if ( a3 ) | |
1299 pOtherOverlayList->_4418B6(906, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); | |
1300 return; | |
1301 case 4: | |
1302 if ( a3 ) | |
1303 pOtherOverlayList->_4418B6(907, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); | |
1304 return; | |
1305 case 5: | |
1306 pOtherOverlayList->_4418B6(901, v4, 0, PID(OBJECT_Actor,uActorID), 0); | |
1307 return; | |
1308 case 6: | |
1309 pOtherOverlayList->_4418B6(902, v4, 0, PID(OBJECT_Actor,uActorID), 0); | |
1310 return; | |
1311 case 7: | |
1312 pOtherOverlayList->_4418B6(903, v4, 0, PID(OBJECT_Actor,uActorID), 0); | |
1313 return; | |
1314 case 8: | |
1315 pOtherOverlayList->_4418B6(900, v4, 0, PID(OBJECT_Actor,uActorID), 0); | |
1316 return; | |
1317 case 9: | |
1318 pOtherOverlayList->_4418B6(909, v4, 0, PID(OBJECT_Actor,uActorID), 0); | |
1319 return; | |
1320 case 10: | |
1321 pOtherOverlayList->_4418B6(908, v4, 0, PID(OBJECT_Actor,uActorID), 0); | |
1322 return; | |
1323 default: | |
1324 return; | |
1325 } | |
1326 return; | |
1327 } | |
1328 | |
1329 //----- (0043B3E0) -------------------------------------------------------- | |
1330 int Actor::_43B3E0_CalcDamage( signed int dmgSource ) | |
1331 { | |
1332 signed int v2; // ebp@1 | |
1333 int v3; // eax@9 | |
1334 signed int v4; // edi@9 | |
1335 int v5; // esi@9 | |
1336 unsigned __int16 v8; // si@21 | |
1337 int v9; // edi@21 | |
1338 signed int v10; // eax@23 | |
1339 int v11; // [sp+10h] [bp-4h]@1 | |
1340 | |
1341 v2 = 0; | |
1342 v11 = 0; | |
1343 | |
1344 switch( dmgSource ) | |
1345 { | |
1346 case 0: | |
1347 if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) | |
1348 v2 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; | |
1349 if ( this->pActorBuffs[ACTOR_BUFF_HEROISM].uExpireTime > 0 && this->pActorBuffs[ACTOR_BUFF_HEROISM].uPower > v2 ) | |
1350 v2 = this->pActorBuffs[ACTOR_BUFF_HEROISM].uPower; | |
1351 if ( this->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].uExpireTime > 0 ) | |
1352 v2 += this->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].uPower; | |
1353 v3 = this->pMonsterInfo.uAttack1DamageDiceRolls; | |
1354 v4 = this->pMonsterInfo.uAttack1DamageDiceSides; | |
1355 v5 = this->pMonsterInfo.uAttack1DamageBonus; | |
1356 break; | |
1357 case 1: | |
1358 v3 = this->pMonsterInfo.uAttack2DamageDiceRolls; | |
1359 v4 = this->pMonsterInfo.uAttack2DamageDiceSides; | |
1360 v5 = this->pMonsterInfo.uAttack2DamageBonus; | |
1361 break; | |
1362 case 2: | |
1363 v8 = this->pMonsterInfo.uSpellSkillAndMastery1; | |
1364 v9 = this->pMonsterInfo.uSpell1ID; | |
1365 v10 = SkillToMastery(v8); | |
1366 return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0); | |
1367 break; | |
1368 case 3: | |
1369 v8 = this->pMonsterInfo.uSpellSkillAndMastery2; | |
1370 v9 = this->pMonsterInfo.uSpell2ID; | |
1371 v10 = SkillToMastery(v8); | |
1372 return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0); | |
1373 break; | |
1374 case 4: | |
1375 v3 = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls; | |
1376 v4 = this->pMonsterInfo.uSpecialAbilityDamageDiceSides; | |
1377 v5 = this->pMonsterInfo.uSpecialAbilityDamageDiceBonus; | |
1378 default: | |
1379 return 0; | |
1380 } | |
1381 for ( int i = 0; i < v3; i++) | |
1382 v11 += rand() % v4 + 1; | |
1383 return v11 + v5 + v2; | |
1384 } | |
1385 | |
1386 //----- (00438B9B) -------------------------------------------------------- | |
1387 bool Actor::IsPeasant() | |
1388 { | |
1389 unsigned int InHostile_Id; // eax@1 | |
1390 | |
1391 InHostile_Id = this->uAlly; | |
1392 if ( !this->uAlly ) | |
1393 InHostile_Id = (this->pMonsterInfo.uID - 1) / 3 + 1; | |
1394 return (signed int)InHostile_Id >= 39 && (signed int)InHostile_Id <= 44//Dwarfs peasants | |
1395 || (signed int)InHostile_Id >= 45 && (signed int)InHostile_Id <= 50//Elves peasants | |
1396 || (signed int)InHostile_Id >= 51 && (signed int)InHostile_Id <= 62//Humans peasants | |
1397 || (signed int)InHostile_Id >= 78 && (signed int)InHostile_Id <= 83;//Goblins peasants | |
1398 } | |
1399 | |
1400 //----- (0042EBEE) -------------------------------------------------------- | |
1401 void Actor::StealFrom( unsigned int uActorID ) | |
1402 { | |
1403 Player *pPlayer; // edi@1 | |
1404 int v4; // ebx@2 | |
1405 unsigned int v5; // eax@2 | |
1406 DDM_DLV_Header *v6; // esi@4 | |
1407 int v8; // [sp+8h] [bp-4h]@6 | |
1408 | |
1409 pPlayer = &pParty->pPlayers[uActiveCharacter-1]; | |
1410 if ( pPlayer->CanAct() ) | |
1411 { | |
1412 CastSpellInfoHelpers::_427D48(); | |
1413 v4 = 0; | |
1414 v5 = pMapStats->GetMapInfo(pCurrentMapName); | |
1415 if ( v5 ) | |
1416 v4 = pMapStats->pInfos[v5]._steal_perm; | |
1417 v6 = &pOutdoor->ddm; | |
1418 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) | |
1419 v6 = &pIndoor->dlv; | |
1420 pPlayer->StealFromActor(uActorID, v4, v6->uReputation++); | |
1421 v8 = pPlayer->GetAttackRecoveryTime(0); | |
1422 if ( v8 < 30 ) | |
1423 v8 = 30; | |
1424 if ( !pParty->bTurnBasedModeOn ) | |
1425 pPlayer->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * v8 * 2.133333333333333)); | |
1426 pTurnEngine->ApplyPlayerAction(); | |
1427 } | |
1428 return; | |
1429 } | |
1430 | |
1431 //----- (00403A60) -------------------------------------------------------- | |
1432 void Actor::AI_SpellAttack2(unsigned int uActorID, signed int edx0, AIDirection *pDir) | |
1433 { | |
1434 Actor *v3; // ebx@1 | |
1435 int16_t v4; // esi@3 | |
1436 int16_t v5; // edi@3 | |
1437 signed int v6; // eax@4 | |
1438 Vec3_int_ v7; // ST04_12@6 | |
1439 AIDirection *v9; // eax@8 | |
1440 __int16 v13; // ax@10 | |
1441 AIDirection a3; // [sp+Ch] [bp-48h]@9 | |
1442 AIDirection v18; // [sp+28h] [bp-2Ch]@9 | |
1443 int v19; // [sp+44h] [bp-10h]@6 | |
1444 signed int a2; // [sp+48h] [bp-Ch]@1 | |
1445 int v21; // [sp+4Ch] [bp-8h]@3 | |
1446 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 | |
1447 | |
1448 v3 = &pActors[uActorID]; | |
1449 a2 = edx0; | |
1450 if ( PID_TYPE(edx0) == OBJECT_Actor) | |
1451 { | |
1452 v6 = PID_ID(edx0); | |
1453 v4 = pActors[v6].vPosition.x; | |
1454 v5 = pActors[v6].vPosition.y; | |
1455 v21 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); | |
1456 } | |
1457 else if ( PID_TYPE(edx0) == OBJECT_Player) | |
1458 { | |
1459 v4 = pParty->vPosition.x; | |
1460 v5 = pParty->vPosition.y; | |
1461 v21 = pParty->vPosition.z + pParty->sEyelevel; | |
1462 } | |
1463 else | |
1464 { | |
1465 Error("Should not get here"); | |
1466 return; | |
1467 } | |
1468 v19 = v3->uActorHeight; | |
1469 v7.z = v3->vPosition.z - (int)(v19 * -0.75); | |
1470 v7.y = v3->vPosition.y; | |
1471 v7.x = v3->vPosition.x; | |
1472 if ( sub_407A1C(v4, v5, v21, v7) ) | |
1473 { | |
1474 if ( pDir == nullptr) | |
1475 { | |
1476 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), a2, &a3, 0); | |
1477 v9 = &a3; | |
1478 } | |
1479 else | |
1480 v9 = pDir; | |
1481 v3->uYawAngle = LOWORD(v9->uYawAngle); | |
1482 v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; | |
1483 v3->uCurrentActionLength = 8 * v13; | |
1484 v3->uCurrentActionTime = 0; | |
1485 v3->uAIState = AttackingRanged4; | |
1486 Actor::PlaySound(uActorID, 0); | |
1487 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
1488 if (v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0) | |
1489 pDira *= 2; | |
1490 if ( pParty->bTurnBasedModeOn == 1 ) | |
1491 v3->pMonsterInfo.uRecoveryTime = pDira; | |
1492 else | |
1493 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); | |
1494 v3->vVelocity.z = 0; | |
1495 v3->vVelocity.y = 0; | |
1496 v3->vVelocity.x = 0; | |
1497 if ( ShouldMonsterPlayAttackAnim(v3->pMonsterInfo.uSpell2ID) ) | |
1498 { | |
1499 v3->uCurrentActionLength = 64; | |
1500 v3->uCurrentActionTime = 0; | |
1501 v3->uAIState = Fidgeting; | |
1502 v3->UpdateAnimation(); | |
1503 v3->uAIState = AttackingRanged4; | |
1504 } | |
1505 else | |
1506 v3->UpdateAnimation(); | |
1507 } | |
1508 else | |
1509 Actor::AI_Pursue1(uActorID, a2, uActorID, 64, pDir); | |
1510 } | |
1511 | |
1512 //----- (00403854) -------------------------------------------------------- | |
1513 void Actor::AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) | |
1514 { | |
1515 Actor *v3; // ebx@1 | |
1516 int16_t v4; // esi@3 | |
1517 int16_t v5; // edi@3 | |
1518 signed int v6; // eax@4 | |
1519 Vec3_int_ v7; // ST04_12@6 | |
1520 AIDirection *v9; // eax@8 | |
1521 __int16 v13; // ax@10 | |
1522 signed int v16; // ecx@17 | |
1523 AIDirection a3; // [sp+Ch] [bp-48h]@9 | |
1524 AIDirection v18; // [sp+28h] [bp-2Ch]@9 | |
1525 int v19; // [sp+44h] [bp-10h]@6 | |
1526 int v21; // [sp+4Ch] [bp-8h]@3 | |
1527 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 | |
1528 | |
1529 v3 = &pActors[uActorID]; | |
1530 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | |
1531 { | |
1532 v6 = PID_ID(sTargetPid); | |
1533 v4 = pActors[v6].vPosition.x; | |
1534 v5 = pActors[v6].vPosition.y; | |
1535 v21 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); | |
1536 } | |
1537 else if ( PID_TYPE(sTargetPid) == OBJECT_Player) | |
1538 { | |
1539 v4 = pParty->vPosition.x; | |
1540 v5 = pParty->vPosition.y; | |
1541 v21 = pParty->vPosition.z + pParty->sEyelevel; | |
1542 } | |
1543 else | |
1544 { | |
1545 Error("Should not get here"); | |
1546 return; | |
1547 } | |
1548 v19 = v3->uActorHeight; | |
1549 v7.z = v3->vPosition.z - (int)(v19 * -0.75); | |
1550 v7.y = v3->vPosition.y; | |
1551 v7.x = v3->vPosition.x; | |
1552 if ( sub_407A1C(v4, v5, v21, v7) ) | |
1553 { | |
1554 if ( pDir == nullptr ) | |
1555 { | |
1556 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); | |
1557 v9 = &a3; | |
1558 } | |
1559 else | |
1560 v9 = pDir; | |
1561 v3->uYawAngle = LOWORD(v9->uYawAngle); | |
1562 v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; | |
1563 v3->uCurrentActionLength = 8 * v13; | |
1564 v3->uCurrentActionTime = 0; | |
1565 v3->uAIState = AttackingRanged3; | |
1566 Actor::PlaySound(uActorID, 0); | |
1567 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
1568 if (v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0) | |
1569 pDira *= 2; | |
1570 if ( pParty->bTurnBasedModeOn == 1 ) | |
1571 v3->pMonsterInfo.uRecoveryTime = pDira; | |
1572 else | |
1573 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); | |
1574 v16 = v3->pMonsterInfo.uSpell1ID; | |
1575 v3->vVelocity.z = 0; | |
1576 v3->vVelocity.y = 0; | |
1577 v3->vVelocity.x = 0; | |
1578 if ( ShouldMonsterPlayAttackAnim(v3->pMonsterInfo.uSpell1ID) ) | |
1579 { | |
1580 v3->uCurrentActionLength = 64; | |
1581 v3->uCurrentActionTime = 0; | |
1582 v3->uAIState = Fidgeting; | |
1583 v3->UpdateAnimation(); | |
1584 v3->uAIState = AttackingRanged3; | |
1585 } | |
1586 else | |
1587 v3->UpdateAnimation(); | |
1588 } | |
1589 else | |
1590 Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); | |
1591 } | |
1592 | |
1593 //----- (0040368B) -------------------------------------------------------- | |
1594 void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) | |
1595 { | |
1596 Actor *v3; // ebx@1 | |
1597 int16_t v4; // esi@3 | |
1598 int16_t v5; // edi@3 | |
1599 signed int v6; // eax@4 | |
1600 Vec3_int_ v7; // ST04_12@6 | |
1601 AIDirection *v9; // eax@8 | |
1602 __int16 v13; // ax@10 | |
1603 AIDirection a3; // [sp+Ch] [bp-48h]@9 | |
1604 AIDirection v17; // [sp+28h] [bp-2Ch]@9 | |
1605 int v18; // [sp+44h] [bp-10h]@6 | |
1606 int v20; // [sp+4Ch] [bp-8h]@3 | |
1607 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 | |
1608 | |
1609 v3 = &pActors[uActorID]; | |
1610 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | |
1611 { | |
1612 v6 = PID_ID(sTargetPid); | |
1613 v4 = pActors[v6].vPosition.x; | |
1614 v5 = pActors[v6].vPosition.y; | |
1615 v20 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); | |
1616 } | |
1617 else if ( PID_TYPE(sTargetPid) == OBJECT_Player) | |
1618 { | |
1619 v4 = pParty->vPosition.x; | |
1620 v5 = pParty->vPosition.y; | |
1621 v20 = pParty->vPosition.z + pParty->sEyelevel; | |
1622 } | |
1623 else | |
1624 { | |
1625 Error("Should not get here"); | |
1626 return; | |
1627 } | |
1628 v18 = v3->uActorHeight; | |
1629 v7.z = v3->vPosition.z - (int)(v18 * -0.75); | |
1630 v7.y = v3->vPosition.y; | |
1631 v7.x = v3->vPosition.x; | |
1632 if ( sub_407A1C(v4, v5, v20, v7) ) | |
1633 { | |
1634 if ( pDir == nullptr ) | |
1635 { | |
1636 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); | |
1637 v9 = &a3; | |
1638 } | |
1639 else | |
1640 v9 = pDir; | |
1641 v3->uYawAngle = LOWORD(v9->uYawAngle); | |
1642 v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; | |
1643 v3->uCurrentActionLength = 8 * v13; | |
1644 v3->uCurrentActionTime = 0; | |
1645 v3->uAIState = AttackingRanged2; | |
1646 Actor::PlaySound(uActorID, 0); | |
1647 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
1648 if ( v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) | |
1649 pDira *= 2; | |
1650 if ( pParty->bTurnBasedModeOn != 1 ) | |
1651 v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); | |
1652 else | |
1653 v3->pMonsterInfo.uRecoveryTime = pDira; | |
1654 v3->vVelocity.z = 0; | |
1655 v3->vVelocity.y = 0; | |
1656 v3->vVelocity.x = 0; | |
1657 v3->UpdateAnimation(); | |
1658 } | |
1659 else | |
1660 Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); | |
1661 } | |
1662 | |
1663 //----- (00403476) -------------------------------------------------------- | |
1664 void Actor::AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) | |
1665 { | |
1666 Actor *v3; // ebx@1 | |
1667 int v4; // esi@3 | |
1668 int v5; // edi@3 | |
1669 signed int v6; // eax@4 | |
1670 Vec3_int_ v7; // ST04_12@6 | |
1671 AIDirection *v10; // eax@9 | |
1672 __int16 v14; // ax@11 | |
1673 AIDirection a3; // [sp+Ch] [bp-48h]@10 | |
1674 AIDirection v18; // [sp+28h] [bp-2Ch]@10 | |
1675 int v19; // [sp+44h] [bp-10h]@6 | |
1676 //signed int a2; // [sp+48h] [bp-Ch]@1 | |
1677 int v22; // [sp+50h] [bp-4h]@3 | |
1678 unsigned int pDira; // [sp+5Ch] [bp+8h]@11 | |
1679 | |
1680 v3 = &pActors[uActorID]; | |
1681 //a2 = edx0; | |
1682 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | |
1683 { | |
1684 v6 = PID_ID(sTargetPid); | |
1685 v4 = pActors[v6].vPosition.x; | |
1686 v5 = pActors[v6].vPosition.y; | |
1687 v22 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); | |
1688 } | |
1689 else | |
1690 { | |
1691 if ( PID_TYPE(sTargetPid) == OBJECT_Player) | |
1692 { | |
1693 v4 = pParty->vPosition.x; | |
1694 v5 = pParty->vPosition.y; | |
1695 v22 = pParty->vPosition.z + pParty->sEyelevel; | |
1696 } | |
1697 else | |
1698 { | |
1699 v4 = (int)pDir; | |
1700 v5 = (int)pDir; | |
1701 } | |
1702 } | |
1703 v19 = v3->uActorHeight; | |
1704 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); | |
1705 v7.y = v3->vPosition.y; | |
1706 v7.x = v3->vPosition.x; | |
1707 if ( sub_407A1C(v4, v5, v22, v7) || sub_407A1C(v7.x, v7.y, v7.z, Vec3_int_(v4, v5, v22))) | |
1708 { | |
1709 if ( pDir == nullptr ) | |
1710 { | |
1711 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); | |
1712 v10 = &a3; | |
1713 } | |
1714 else | |
1715 v10 = pDir; | |
1716 v3->uYawAngle = LOWORD(v10->uYawAngle); | |
1717 v14 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; | |
1718 v3->uCurrentActionLength = 8 * v14; | |
1719 v3->uCurrentActionTime = 0; | |
1720 v3->uAIState = AttackingRanged1; | |
1721 Actor::PlaySound(uActorID, 0); | |
1722 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
1723 if ( v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) | |
1724 pDira *= 2; | |
1725 if ( pParty->bTurnBasedModeOn == 1 ) | |
1726 v3->pMonsterInfo.uRecoveryTime = pDira; | |
1727 else | |
1728 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength - (int)(flt_6BE3A8_debug_recmod2 * pDira * -2.133333333333333); | |
1729 v3->vVelocity.z = 0; | |
1730 v3->vVelocity.y = 0; | |
1731 v3->vVelocity.x = 0; | |
1732 v3->UpdateAnimation(); | |
1733 } | |
1734 else | |
1735 Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); | |
1736 } | |
1737 | |
1738 //----- (004032B2) -------------------------------------------------------- | |
1739 void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength ) | |
1740 { | |
1741 int x; // ebx@1 | |
1742 int absy; // eax@1 | |
1743 unsigned int v9; // ebx@11 | |
1744 int v10; // ebx@13 | |
1745 AIDirection doNotInitializeBecauseShouldBeRandom; // [sp+Ch] [bp-30h]@7 | |
1746 int y; // [sp+30h] [bp-Ch]@1 | |
1747 int absx; // [sp+38h] [bp-4h]@1 | |
1748 | |
1749 x = pActors[uActor_id].vInitialPosition.x - pActors[uActor_id].vPosition.x; | |
1750 y = pActors[uActor_id].vInitialPosition.y - pActors[uActor_id].vPosition.y; | |
1751 absx = abs(x); | |
1752 absy = abs(y); | |
1753 if ( absx <= absy ) | |
1754 absx = absy + (absx / 2 ); | |
1755 else | |
1756 absx = absx + absy / 2; | |
1757 if ( MonsterStats::BelongsToSupertype(pActors[uActor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
1758 { | |
1759 if ( !uActionLength ) | |
1760 uActionLength = 256; | |
1761 Actor::AI_StandOrBored(uActor_id, OBJECT_Player, uActionLength, &doNotInitializeBecauseShouldBeRandom); | |
1762 return; | |
1763 } | |
1764 if ( pActors[uActor_id].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_GLOBAL && absx < 128 ) | |
1765 { | |
1766 Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom); | |
1767 return; | |
1768 } | |
1769 absx += ((rand() & 0xF) * radius) / 16; | |
1770 v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(x, y); | |
1771 if ( rand() % 100 < 25 ) | |
1772 { | |
1773 Actor::StandAwhile(uActor_id); | |
1774 return; | |
1775 } | |
1776 v10 = v9 + rand() % 256 - 128; | |
1777 if ( abs(v10 - pActors[uActor_id].uYawAngle) > 256 && !(pActors[uActor_id].uAttributes & ACTOR_ANIMATION) ) | |
1778 { | |
1779 Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom); | |
1780 return; | |
1781 } | |
1782 pActors[uActor_id].uYawAngle = v10; | |
1783 if ( pActors[uActor_id].uMovementSpeed) | |
1784 pActors[uActor_id].uCurrentActionLength = 32 * absx / pActors[uActor_id].uMovementSpeed; | |
1785 else | |
1786 pActors[uActor_id].uCurrentActionLength = 0; | |
1787 pActors[uActor_id].uCurrentActionTime = 0; | |
1788 pActors[uActor_id].uAIState = Tethered; | |
1789 if ( rand() % 100 < 2 ) | |
1790 Actor::PlaySound(uActor_id, 3); | |
1791 pActors[uActor_id].UpdateAnimation(); | |
1792 } | |
1793 | |
1794 //----- (004031C1) -------------------------------------------------------- | |
1795 char __fastcall Actor::_4031C1_update_job_never_gets_called(unsigned int uActorID, signed int a2, int a3) //attempted to implement something like jobs for actors, but apparently was never finished | |
1796 { | |
1797 return 0; | |
1798 /*unsigned int v3; // edi@1 | |
1799 Actor *v4; // esi@1 | |
1800 ActorJob *v5; // eax@1 | |
1801 signed int v6; // edx@2 | |
1802 ActorJob *v7; // eax@2 | |
1803 signed int v8; // edi@2 | |
1804 ActorJob *v9; // ecx@2 | |
1805 __int16 v10; // cx@15 | |
1806 signed int v12; // [sp+8h] [bp-4h]@1 | |
1807 | |
1808 v3 = uActorID; | |
1809 v12 = a2; | |
1810 v4 = &pActors[uActorID]; | |
1811 v5 = (ActorJob *)pActors[uActorID].CanAct(); | |
1812 if ( v5 ) | |
1813 { | |
1814 v6 = 65535; | |
1815 v7 = &v4->pScheduledJobs[v3]; | |
1816 v8 = 7; | |
1817 v9 = &v7[7];//(char *)&v7[7].uHour; | |
1818 while ( !(v9->uAttributes & 1) || v9->uHour > v12 ) | |
1819 { | |
1820 --v8; | |
1821 --v9; | |
1822 if ( v8 < 0 ) | |
1823 break; | |
1824 } | |
1825 if( v8 >= 0 ) | |
1826 v6 = v8; | |
1827 if ( !v8 && v6 == 65535 ) | |
1828 v6 = 7; | |
1829 v5 = &v7[v6]; | |
1830 if ( v4->vInitialPosition.x != v5->vPos.x | |
1831 || v4->vInitialPosition.y != v5->vPos.y | |
1832 || v4->vInitialPosition.z != v5->vPos.z | |
1833 || v4->pMonsterInfo.uMovementType != v5->uAction ) | |
1834 { | |
1835 v4->vInitialPosition.x = v5->vPos.x; | |
1836 v4->vInitialPosition.y = v5->vPos.y; | |
1837 v10 = v5->vPos.z; | |
1838 v4->vInitialPosition.z = v10; | |
1839 LOBYTE(v5) = v5->uAction; | |
1840 v4->pMonsterInfo.uMovementType = MONSTER_MOVEMENT_TYPE_STAIONARY; | |
1841 if ( a3 == 1 ) | |
1842 { | |
1843 v4->vPosition.x = v4->vInitialPosition.x; | |
1844 v4->vPosition.y = v4->vInitialPosition.y; | |
1845 LOBYTE(v5) = v10; | |
1846 v4->vPosition.z = v10; | |
1847 } | |
1848 } | |
1849 } | |
1850 return (char)v5;*/ | |
1851 } | |
1852 | |
1853 //----- (004030AD) -------------------------------------------------------- | |
1854 void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int stunRegardlessOfState) | |
1855 { | |
1856 __int16 v7; // ax@16 | |
1857 AIDirection a3; // [sp+Ch] [bp-40h]@16 | |
1858 | |
1859 if ( pActors[uActorID].uAIState == Fleeing ) | |
1860 pActors[uActorID].uAttributes |= ACTOR_FLEEING; | |
1861 if ( pActors[uActorID].pMonsterInfo.uHostilityType != 4 ) | |
1862 { | |
1863 pActors[uActorID].uAttributes &= 0xFFFFFFFB;//~0x4 | |
1864 pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
1865 } | |
1866 if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) | |
1867 pActors[uActorID].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); | |
1868 if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0 ) | |
1869 pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].Reset(); | |
1870 if ( stunRegardlessOfState || (pActors[uActorID].uAIState != Stunned | |
1871 && pActors[uActorID].uAIState != AttackingRanged1 | |
1872 && pActors[uActorID].uAIState != AttackingRanged2 | |
1873 && pActors[uActorID].uAIState != AttackingRanged3 | |
1874 && pActors[uActorID].uAIState != AttackingRanged4 | |
1875 && pActors[uActorID].uAIState != AttackingMelee)) | |
1876 { | |
1877 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0); | |
1878 //v10 = &a3; | |
1879 pActors[uActorID].uYawAngle = LOWORD(a3.uYawAngle); | |
1880 v7 = pSpriteFrameTable->pSpriteSFrames[pActors[uActorID].pSpriteIDs[ANIM_GotHit]].uAnimLength; | |
1881 pActors[uActorID].uCurrentActionTime = 0; | |
1882 pActors[uActorID].uAIState = Stunned; | |
1883 pActors[uActorID].uCurrentActionLength = 8 * v7; | |
1884 Actor::PlaySound(uActorID, 2); | |
1885 pActors[uActorID].UpdateAnimation(); | |
1886 } | |
1887 } | |
1888 | |
1889 //----- (00402F87) -------------------------------------------------------- | |
1890 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) | |
1891 { | |
1892 unsigned int v7; // eax@3 | |
1893 unsigned int v9; // eax@3 | |
1894 | |
1895 Actor* actor = &pActors[uActorID]; | |
1896 | |
1897 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 | |
1898 if (!a4) | |
1899 { | |
1900 Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), uObjID, &a3, 0); | |
1901 a4 = &a3; | |
1902 } | |
1903 | |
1904 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; | |
1905 | |
2543 | 1906 v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCameraD3D->vPartyPos.x, actor->vPosition.y - pIndoorCameraD3D->vPartyPos.y); |
2497 | 1907 v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; |
1908 | |
1909 if ( v9 & 0x700 ) // turned away - just stand | |
1910 Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); | |
1911 else // facing player - play bored anim | |
1912 { | |
1913 actor->uAIState = Fidgeting; | |
1914 actor->uCurrentActionTime = 0; | |
1915 actor->uYawAngle = a4->uYawAngle; | |
1916 actor->vVelocity.z = 0; | |
1917 actor->vVelocity.y = 0; | |
1918 actor->vVelocity.x = 0; | |
1919 if ( rand() % 100 < 5 ) | |
1920 Actor::PlaySound(uActorID, 3); | |
1921 actor->UpdateAnimation(); | |
1922 } | |
1923 } | |
1924 | |
1925 //----- (00402F27) -------------------------------------------------------- | |
1926 void Actor::Resurrect(unsigned int uActorID) | |
1927 { | |
1928 Actor *pActor; // esi@1 | |
1929 | |
1930 pActor = &pActors[uActorID]; | |
1931 pActor->uCurrentActionTime = 0; | |
1932 pActor->uAIState = Resurrected; | |
1933 pActor->uCurrentActionAnimation = ANIM_Dying; | |
1934 pActor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[pActor->pSpriteIDs[ANIM_Dying]].uAnimLength; | |
1935 pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP); | |
1936 Actor::PlaySound(uActorID, 1); | |
1937 pActor->UpdateAnimation(); | |
1938 } | |
1939 | |
1940 //----- (00402D6E) -------------------------------------------------------- | |
1941 void Actor::Die(unsigned int uActorID) | |
1942 { | |
1943 Actor* actor = &pActors[uActorID]; | |
1944 | |
1945 actor->uCurrentActionTime = 0; | |
1946 actor->uAIState = Dying; | |
1947 actor->uCurrentActionAnimation = ANIM_Dying; | |
1948 actor->sCurrentHP = 0; | |
1949 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Dying]].uAnimLength; | |
1950 actor->pActorBuffs[ACTOR_BUFF_PARALYZED].Reset(); | |
1951 actor->pActorBuffs[ACTOR_BUFF_STONED].Reset(); | |
1952 Actor::PlaySound(uActorID, 1); | |
1953 actor->UpdateAnimation(); | |
1954 | |
1955 for (uint i = 0; i < 5; ++i) | |
1956 if (pParty->monster_id_for_hunting[i] == actor->pMonsterInfo.uID) | |
1957 pParty->monster_for_hunting_killed[i] = true; | |
1958 | |
1959 for (uint i = 0; i < 22; ++i) | |
1960 actor->pActorBuffs[i].Reset(); | |
1961 | |
1962 ItemGen drop; | |
1963 drop.Reset(); | |
1964 switch (actor->pMonsterInfo.uID) | |
1965 { | |
1966 case MONSTER_HARPY_1: case MONSTER_HARPY_2: case MONSTER_HARPY_3: | |
1967 drop.uItemID = ITEM_HARPY_FEATHER; | |
1968 break; | |
1969 | |
1970 case MONSTER_OOZE_1: case MONSTER_OOZE_2: case MONSTER_OOZE_3: | |
1971 drop.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE; | |
1972 break; | |
1973 | |
1974 case MONSTER_TROLL_1: case MONSTER_TROLL_2: case MONSTER_TROLL_3: | |
1975 drop.uItemID = ITEM_TROLL_BLOOD; | |
1976 break; | |
1977 | |
1978 case MONSTER_DEVIL_1: case MONSTER_DEVIL_2: case MONSTER_DEVIL_3: | |
1979 drop.uItemID = ITEM_DEVIL_ICHOR; | |
1980 break; | |
1981 | |
1982 case MONSTER_DRAGON_1: case MONSTER_DRAGON_2: case MONSTER_DRAGON_3: | |
1983 drop.uItemID = ITEM_DRAGON_EYE; | |
1984 break; | |
1985 } | |
1986 | |
1987 if (rand() % 100 < 20 && drop.uItemID != 0) | |
1988 { | |
2566 | 1989 SpriteObject::sub_42F7EB_DropItemAt( |
1990 (SPRITE_OBJECT_TYPE)pItemsTable->pItems[drop.uItemID].uSpriteID, | |
1991 actor->vPosition.x, | |
1992 actor->vPosition.y, | |
1993 actor->vPosition.z + 16, | |
1994 rand() % 200 + 200, | |
1995 1, | |
1996 1, | |
1997 0, | |
1998 &drop | |
1999 ); | |
2497 | 2000 } |
2001 | |
2002 if (actor->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE) | |
2003 Actor::Explode(uActorID); | |
2004 } | |
2005 | |
2006 //----- (00402CED) -------------------------------------------------------- | |
2007 void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) | |
2008 { | |
2009 unsigned __int16 v3; // dx@1 | |
2010 | |
2011 v3 = pActors[uActorID].pSoundSampleIDs[uSoundID]; | |
2012 if ( v3 ) | |
2013 { | |
2014 if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime <= 0 ) | |
2015 pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | |
2016 else | |
2017 { | |
2018 switch(pActors[uActorID].pActorBuffs[ACTOR_BUFF_SHRINK].uPower) | |
2019 { | |
2020 case 1: | |
2021 pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075); | |
2022 break; | |
2023 case 2: | |
2024 pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075); | |
2025 break; | |
2026 case 3: | |
2027 case 4: | |
2028 pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075); | |
2029 break; | |
2030 default: | |
2031 pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | |
2032 break; | |
2033 } | |
2034 } | |
2035 } | |
2036 } | |
2037 | |
2038 //----- (00402AD7) -------------------------------------------------------- | |
2039 void Actor::AI_Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) | |
2040 { | |
2041 int v6; // eax@1 | |
2042 Actor *v7; // ebx@1 | |
2043 unsigned int v8; // ecx@1 | |
2044 AIDirection *v10; // esi@6 | |
2045 AIDirection a3; // [sp+Ch] [bp-5Ch]@7 | |
2046 unsigned int v18; // [sp+64h] [bp-4h]@1 | |
2047 | |
2048 v6 = 0; | |
2049 v7 = &pActors[uActorID]; | |
2050 v8 = PID(OBJECT_Actor,uActorID); | |
2051 if ( v7->pMonsterInfo.uFlying != 0 && !pParty->bFlying ) //TODO: Does v6 have a point? | |
2052 { | |
2053 if ( v7->pMonsterInfo.uMissleAttack1Type ) | |
2054 v6 = v7->uActorRadius + 512; | |
2055 else | |
2056 v6 = pParty->uPartyHeight; | |
2057 } | |
2058 | |
2059 if ( pDir == nullptr ) | |
2060 { | |
2061 Actor::GetDirectionInfo(v8, a2, &a3, v6); | |
2062 v10 = &a3; | |
2063 } | |
2064 else | |
2065 v10 = pDir; | |
2066 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
2067 { | |
2068 if ( !uActionLength ) | |
2069 uActionLength = 256; | |
2070 Actor::AI_StandOrBored(uActorID, 4, uActionLength, v10); | |
2071 return; | |
2072 } | |
2073 if ( v10->uDistance < 307.2 ) | |
2074 { | |
2075 if ( !uActionLength ) | |
2076 uActionLength = 256; | |
2077 Actor::AI_Stand(uActorID, a2, uActionLength, v10); | |
2078 return; | |
2079 } | |
2080 if ( v7->uMovementSpeed == 0 ) | |
2081 { | |
2082 Actor::AI_Stand(uActorID, a2, uActionLength, v10); | |
2083 return; | |
2084 } | |
2085 if ( arg0 % 2 ) | |
2086 v18 = -16; | |
2087 else | |
2088 v18 = 16; | |
2089 | |
2090 v7->uYawAngle = stru_5C6E00->Atan2( | |
2091 pParty->vPosition.x + (int)fixpoint_mul(stru_5C6E00->Cos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.x, | |
2092 pParty->vPosition.y + (int)fixpoint_mul(stru_5C6E00->Sin(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.y); | |
2093 if ( uActionLength ) | |
2094 v7->uCurrentActionLength = uActionLength; | |
2095 else | |
2096 v7->uCurrentActionLength = 128; | |
2097 v7->uPitchAngle = LOWORD(v10->uPitchAngle); | |
2098 v7->uAIState = Pursuing; | |
2099 v7->UpdateAnimation(); | |
2100 } | |
2101 | |
2102 //----- (00402968) -------------------------------------------------------- | |
2103 void Actor::AI_Flee(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4) | |
2104 { | |
2105 Actor *v5; // ebx@1 | |
2106 int v7; // ecx@2 | |
2107 unsigned __int16 v9; // ax@15 | |
2108 AIDirection v10; // [sp+8h] [bp-7Ch]@4 | |
2109 AIDirection a3; // [sp+24h] [bp-60h]@3 | |
2110 AIDirection* v13; // [sp+5Ch] [bp-28h]@4 | |
2111 | |
2112 v5 = &pActors[uActorID]; | |
2113 if ( v5->CanAct() ) | |
2114 { | |
2115 v7 = PID(OBJECT_Actor,uActorID); | |
2116 if ( !a4 ) | |
2117 { | |
2118 Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying); | |
2119 a4 = &a3; | |
2120 } | |
2121 Actor::GetDirectionInfo(v7, 4u, &v10, 0); | |
2122 v13 = &v10; | |
2123 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) | |
2124 || PID_TYPE(sTargetPid) == OBJECT_Actor && v13->uDistance < 307.2 ) | |
2125 { | |
2126 if ( !uActionLength ) | |
2127 uActionLength = 256; | |
2128 Actor::AI_StandOrBored(uActorID, 4, uActionLength, v13); | |
2129 } | |
2130 else | |
2131 { | |
2132 if ( v5->uMovementSpeed ) | |
2133 v5->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v5->uMovementSpeed; | |
2134 else | |
2135 v5->uCurrentActionLength = 0; | |
2136 if ( v5->uCurrentActionLength > 256 ) | |
2137 v5->uCurrentActionLength = 256; | |
2138 v5->uYawAngle = LOWORD(stru_5C6E00->uIntegerHalfPi) + LOWORD(a4->uYawAngle); | |
2139 v5->uYawAngle = LOWORD(stru_5C6E00->uDoublePiMask) & (v5->uYawAngle + rand() % (signed int)stru_5C6E00->uIntegerPi); | |
2140 v9 = LOWORD(a4->uPitchAngle); | |
2141 v5->uCurrentActionTime = 0; | |
2142 v5->uPitchAngle = v9; | |
2143 v5->uAIState = Fleeing; | |
2144 v5->UpdateAnimation(); | |
2145 } | |
2146 } | |
2147 } | |
2148 | |
2149 //----- (0040281C) -------------------------------------------------------- | |
2150 void Actor::AI_Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) | |
2151 { | |
2152 int v6; // eax@1 | |
2153 Actor *v7; // ebx@1 | |
2154 unsigned int v8; // ecx@1 | |
2155 AIDirection *v10; // esi@7 | |
2156 signed __int16 v13; // cx@19 | |
2157 unsigned __int16 v14; // ax@25 | |
2158 AIDirection a3; // [sp+Ch] [bp-40h]@8 | |
2159 AIDirection v18; // [sp+28h] [bp-24h]@8 | |
2160 | |
2161 v6 = 0; | |
2162 v7 = &pActors[uActorID]; | |
2163 v8 = PID(OBJECT_Actor,uActorID); | |
2164 if ( v7->pMonsterInfo.uFlying != 0 && !pParty->bFlying ) | |
2165 { | |
2166 if ( v7->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
2167 v6 = v7->uActorRadius + 512; | |
2168 else | |
2169 v6 = pParty->uPartyHeight; | |
2170 } | |
2171 v10 = pDir; | |
2172 if ( !pDir ) | |
2173 { | |
2174 Actor::GetDirectionInfo(v8, a2, &a3, v6); | |
2175 v10 = &a3; | |
2176 } | |
2177 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
2178 { | |
2179 if ( !uActionLength ) | |
2180 uActionLength = 256; | |
2181 Actor::AI_StandOrBored(uActorID, 4, uActionLength, v10); | |
2182 return; | |
2183 } | |
2184 if ( (signed int)v10->uDistance < a5 ) | |
2185 { | |
2186 if ( !uActionLength ) | |
2187 uActionLength = 256; | |
2188 Actor::AI_StandOrBored(uActorID, a2, uActionLength, v10); | |
2189 return; | |
2190 } | |
2191 if ( uActionLength ) | |
2192 { | |
2193 v7->uCurrentActionLength = uActionLength; | |
2194 } | |
2195 else | |
2196 { | |
2197 v13 = v7->uMovementSpeed; | |
2198 if ( v13 ) | |
2199 v7->uCurrentActionLength = (signed int)(v10->uDistanceXZ << 7) / v13; | |
2200 else | |
2201 v7->uCurrentActionLength = 0; | |
2202 if ( v7->uCurrentActionLength > 32 ) | |
2203 v7->uCurrentActionLength = 32; | |
2204 } | |
2205 v7->uYawAngle = LOWORD(v10->uYawAngle); | |
2206 v14 = LOWORD(v10->uPitchAngle); | |
2207 v7->uCurrentActionTime = 0; | |
2208 v7->uPitchAngle = v14; | |
2209 v7->uAIState = Pursuing; | |
2210 v7->UpdateAnimation(); | |
2211 } | |
2212 | |
2213 //----- (00402686) -------------------------------------------------------- | |
2214 void Actor::AI_Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) | |
2215 { | |
2216 int v5; // eax@1 | |
2217 Actor *v6; // ebx@1 | |
2218 int v7; // ecx@1 | |
2219 signed __int16 v12; // cx@19 | |
2220 __int16 v14; // ax@25 | |
2221 unsigned __int16 v16; // ax@28 | |
2222 AIDirection a3; // [sp+Ch] [bp-40h]@8 | |
2223 AIDirection* v20; // [sp+28h] [bp-24h]@8 | |
2224 | |
2225 v5 = 0; | |
2226 v6 = &pActors[uActorID]; | |
2227 v7 = PID(OBJECT_Actor,uActorID); | |
2228 if ( v6->pMonsterInfo.uFlying != 0 && !pParty->bFlying ) | |
2229 { | |
2230 if ( v6->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
2231 v5 = v6->uActorRadius + 512; | |
2232 else | |
2233 v5 = pParty->uPartyHeight; | |
2234 } | |
2235 if ( !a4 ) | |
2236 { | |
2237 Actor::GetDirectionInfo(v7, a2, &a3, v5); | |
2238 v20 = &a3; | |
2239 } | |
2240 if ( MonsterStats::BelongsToSupertype(v6->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
2241 { | |
2242 if ( !uActionLength ) | |
2243 uActionLength = 256; | |
2244 return Actor::AI_StandOrBored(uActorID, 4, uActionLength, a4); | |
2245 } | |
2246 if ( a4->uDistance < 307.2 ) | |
2247 { | |
2248 if ( !uActionLength ) | |
2249 uActionLength = 256; | |
2250 return Actor::AI_StandOrBored(uActorID, a2, uActionLength, a4); | |
2251 } | |
2252 if ( uActionLength ) | |
2253 v6->uCurrentActionLength = uActionLength + rand() % uActionLength; | |
2254 else | |
2255 { | |
2256 v12 = v6->uMovementSpeed; | |
2257 if ( v12 ) | |
2258 v6->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v12; | |
2259 else | |
2260 v6->uCurrentActionLength = 0; | |
2261 if ( v6->uCurrentActionLength > 128 ) | |
2262 v6->uCurrentActionLength = 128; | |
2263 } | |
2264 v14 = LOWORD(a4->uYawAngle); | |
2265 if ( rand() % 2 ) | |
2266 v14 += 256; | |
2267 else | |
2268 v14 -= 256; | |
2269 v6->uYawAngle = v14; | |
2270 v16 = LOWORD(a4->uPitchAngle); | |
2271 v6->uCurrentActionTime = 0; | |
2272 v6->uPitchAngle = v16; | |
2273 v6->uAIState = Pursuing; | |
2274 if ( rand() % 100 < 2 ) | |
2506 | 2275 Actor::PlaySound(uActorID, 2); |
2497 | 2276 v6->UpdateAnimation(); |
2277 } | |
2278 | |
2279 //----- (00401221) -------------------------------------------------------- | |
2280 void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party) | |
2281 { | |
2282 int v5; // ecx@1 | |
2283 signed int v10; // eax@13 | |
2284 uint v11; // ebx@16 | |
2285 uint v12; // eax@16 | |
2286 signed int v14; // eax@31 | |
2287 uint v15; // edi@43 | |
2288 uint v16; // ebx@45 | |
2289 uint v17; // eax@45 | |
2290 signed int closestId; // [sp+14h] [bp-1Ch]@1 | |
2291 uint v23; // [sp+1Ch] [bp-14h]@16 | |
2292 unsigned int lowestRadius; // [sp+24h] [bp-Ch]@1 | |
2293 uint v27; // [sp+2Ch] [bp-4h]@16 | |
2294 uint v28; // [sp+2Ch] [bp-4h]@45 | |
2295 | |
2296 lowestRadius = UINT_MAX; | |
2297 v5 = 0; | |
2298 *a2 = 0; | |
2299 closestId = 0; | |
2300 assert(uActorID < uNumActors); | |
2301 Actor* thisActor = &pActors[uActorID]; | |
2302 | |
2303 for (uint i = 0; i < uNumActors; ++i) | |
2304 { | |
2305 Actor* actor = &pActors[i]; | |
2306 if (actor->uAIState == Dead || actor->uAIState == Dying || | |
2307 actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) | |
2308 continue; | |
2309 | |
2310 if (thisActor->uLastCharacterIDToHit == 0 || PID(OBJECT_Actor,v5) != thisActor->uLastCharacterIDToHit ) | |
2311 { | |
2312 v10 = thisActor->GetActorsRelation(actor); | |
2313 if ( v10 == 0 ) | |
2314 continue; | |
2315 } | |
2316 else if (thisActor->IsNotAlive()) | |
2317 { | |
2318 thisActor->uLastCharacterIDToHit = 0; | |
2319 v10 = thisActor->GetActorsRelation(actor); | |
2320 if ( v10 == 0 ) | |
2321 continue; | |
2322 } | |
2323 else | |
2324 { | |
2325 if ( (actor->uGroup != 0 || thisActor->uGroup != 0) && actor->uGroup == thisActor->uGroup ) | |
2326 continue; | |
2327 v10 = 4; | |
2328 } | |
2329 if ( thisActor->pMonsterInfo.uHostilityType ) | |
2330 v10 = pMonsterStats->pInfos[thisActor->pMonsterInfo.uID].uHostilityType; | |
2331 v11 = _4DF380_hostilityRanges[v10]; | |
2332 v23 = abs(thisActor->vPosition.x - actor->vPosition.x); | |
2333 v27 = abs(thisActor->vPosition.y - actor->vPosition.y); | |
2334 v12 = abs(thisActor->vPosition.z - actor->vPosition.z); | |
2335 if ( v23 <= v11 | |
2336 && v27 <= v11 | |
2337 && v12 <= v11 | |
2338 && sub_4070EF_prolly_detect_player(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) | |
2339 && v23 * v23 + v27 * v27 + v12 * v12 < lowestRadius ) | |
2340 { | |
2341 lowestRadius = v23 * v23 + v27 * v27 + v12 * v12; | |
2342 closestId = i; | |
2343 } | |
2344 } | |
2345 | |
2346 if ( lowestRadius != UINT_MAX ) | |
2347 { | |
2348 *a2 = PID(OBJECT_Actor, closestId); | |
2349 } | |
2350 | |
2351 if (can_target_party && !pParty->Invisible()) | |
2352 { | |
2353 if ( thisActor->ActorEnemy() | |
2354 && thisActor->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime <= 0 | |
2355 && thisActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime <= 0 | |
2356 && thisActor->pActorBuffs[ACTOR_BUFF_SUMMONED].uExpireTime <= 0 ) | |
2357 v14 = 4; | |
2358 else | |
2359 v14 = thisActor->GetActorsRelation(0); | |
2360 if ( v14 != 0 ) | |
2361 { | |
2362 if ( !thisActor->pMonsterInfo.uHostilityType ) | |
2363 v15 = _4DF380_hostilityRanges[v14]; | |
2364 else | |
2365 v15 = _4DF380_hostilityRanges[4]; | |
2366 v16 = abs(thisActor->vPosition.x - pParty->vPosition.x); | |
2367 v28 = abs(thisActor->vPosition.y - pParty->vPosition.y); | |
2368 v17 = abs(thisActor->vPosition.z - pParty->vPosition.z); | |
2369 if ( v16 <= v15 && v28 <= v15 && v17 <= v15 && (v16 * v16 + v28 * v28 + v17 * v17 < lowestRadius)) | |
2370 { | |
2371 *a2 = OBJECT_Player; | |
2372 } | |
2373 } | |
2374 } | |
2375 } | |
2376 // 4DF380: using guessed type int dword_4DF380[]; | |
2377 // 4DF390: using guessed type int dword_4DF390; | |
2378 | |
2379 //----- (0040104C) -------------------------------------------------------- | |
2380 signed int Actor::GetActorsRelation(Actor *otherActPtr) | |
2381 { | |
2382 unsigned int thisGroup; // ebp@19 | |
2383 int otherGroup; // eax@22 | |
2384 unsigned int thisAlly; // edx@25 | |
2385 unsigned int otherAlly; // edx@33 | |
2386 | |
2387 if ( otherActPtr) | |
2388 { | |
2389 if ( otherActPtr->uGroup != 0 && this->uGroup != 0 && otherActPtr->uGroup == this->uGroup ) | |
2390 return 0; | |
2391 } | |
2392 | |
2393 if (this->pActorBuffs[ACTOR_BUFF_BERSERK].uExpireTime > 0) | |
2394 return 4; | |
2395 thisAlly = this->uAlly; | |
2396 if ( this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 || thisAlly == 9999) | |
2397 thisGroup = 0; | |
2398 else if ( thisAlly > 0 ) | |
2399 thisGroup = thisAlly; | |
2400 else | |
2401 thisGroup = (this->pMonsterInfo.uID - 1) / 3 + 1; | |
2402 | |
2403 if ( otherActPtr ) | |
2404 { | |
2405 if (otherActPtr->pActorBuffs[ACTOR_BUFF_BERSERK].uExpireTime > 0) | |
2406 return 4; | |
2407 otherAlly = otherActPtr->uAlly; | |
2408 if ( otherActPtr->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 || otherAlly == 9999) | |
2409 otherGroup = 0; | |
2410 else if ( otherAlly > 0 ) | |
2411 otherGroup = otherAlly; | |
2412 else | |
2413 otherGroup = (otherActPtr->pMonsterInfo.uID - 1) / 3 + 1; | |
2414 } | |
2415 else | |
2416 otherGroup = 0; | |
2417 | |
2418 if ( this->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 && !otherGroup | |
2419 || otherActPtr && otherActPtr->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 && !thisGroup ) | |
2420 return 0; | |
2421 if ( this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime <= 0 && this->ActorEnemy() && !otherGroup ) | |
2422 return 4; | |
2423 if (thisGroup >= 89 || otherGroup >= 89) | |
2424 return 0; | |
2425 | |
2426 if ( thisGroup == 0 ) | |
2427 { | |
2428 if ( (!otherActPtr || this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 && otherActPtr->ActorFriend()) && !pFactionTable->relations[otherGroup][0]) | |
2429 return pFactionTable->relations[0][otherGroup]; | |
2430 else | |
2431 return 4; | |
2432 } | |
2433 else | |
2434 return pFactionTable->relations[thisGroup][otherGroup]; | |
2435 } | |
2436 | |
2437 //----- (0045976D) -------------------------------------------------------- | |
2438 void Actor::UpdateAnimation() | |
2439 { | |
2440 ResetAnimation(); | |
2441 switch (uAIState) | |
2442 { | |
2443 case Tethered: | |
2444 uCurrentActionAnimation = ANIM_Walking; | |
2445 break; | |
2446 | |
2447 case AttackingMelee: | |
2448 uCurrentActionAnimation = ANIM_AtkMelee; | |
2449 uAttributes |= ACTOR_ANIMATION; | |
2450 break; | |
2451 | |
2452 case AttackingRanged1: | |
2453 case AttackingRanged2: | |
2454 case AttackingRanged3: | |
2455 case AttackingRanged4: | |
2456 uCurrentActionAnimation = ANIM_AtkRanged; | |
2457 uAttributes |= ACTOR_ANIMATION; | |
2458 break; | |
2459 | |
2460 case Dying: | |
2461 case Resurrected: | |
2462 uCurrentActionAnimation = ANIM_Dying; | |
2463 uAttributes |= ACTOR_ANIMATION; | |
2464 break; | |
2465 | |
2466 case Pursuing: | |
2467 case Fleeing: | |
2468 uCurrentActionAnimation = ANIM_Walking; | |
2469 uAttributes |= ACTOR_ANIMATION; | |
2470 break; | |
2471 | |
2472 case Stunned: | |
2473 uCurrentActionAnimation = ANIM_GotHit; | |
2474 uAttributes |= ACTOR_ANIMATION; | |
2475 break; | |
2476 | |
2477 case Fidgeting: | |
2478 uCurrentActionAnimation = ANIM_Bored; | |
2479 uAttributes |= ACTOR_ANIMATION; | |
2480 break; | |
2481 | |
2482 case Standing: | |
2483 case Interacting: | |
2484 case Summoned: | |
2485 uCurrentActionAnimation = ANIM_Standing; | |
2486 uAttributes |= ACTOR_ANIMATION; | |
2487 break; | |
2488 | |
2489 case Dead: | |
2490 if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0) | |
2491 uAIState = Removed; | |
2492 else | |
2493 uCurrentActionAnimation = ANIM_Dead; | |
2494 break; | |
2495 | |
2496 case Removed: | |
2497 case Disabled: | |
2498 return; | |
2499 | |
2500 default: | |
2501 assert(false); | |
2502 } | |
2503 } | |
2504 | |
2505 //----- (00459671) -------------------------------------------------------- | |
2506 void Actor::Reset() | |
2507 { | |
2508 this->pActorName[0] = 0; | |
2509 this->word_000086_some_monster_id = 0; | |
2510 this->sNPC_ID = 0; | |
2511 this->vPosition.z = 0; | |
2512 this->vPosition.y = 0; | |
2513 this->vPosition.x = 0; | |
2514 this->vVelocity.z = 0; | |
2515 this->vVelocity.y = 0; | |
2516 this->vVelocity.x = 0; | |
2517 this->uYawAngle = 0; | |
2518 this->uPitchAngle = 0; | |
2519 this->uAttributes = 0; | |
2520 this->uSectorID = 0; | |
2521 this->uCurrentActionTime = 0; | |
2522 this->vInitialPosition.z = 0; | |
2523 this->vInitialPosition.y = 0; | |
2524 this->vInitialPosition.x = 0; | |
2525 this->vGuardingPosition.z = 0; | |
2526 this->vGuardingPosition.y = 0; | |
2527 this->vGuardingPosition.x = 0; | |
2528 this->uTetherDistance = 256; | |
2529 this->uActorRadius = 32; | |
2530 this->uActorHeight = 128; | |
2531 this->uAIState = Standing; | |
2532 this->uCurrentActionAnimation = ANIM_Standing; | |
2533 this->uMovementSpeed = 200; | |
2534 this->uCarriedItemID = 0; | |
2535 this->uGroup = 0; | |
2536 this->uAlly = 0; | |
2537 this->uSummonerID = 0; | |
2538 this->uLastCharacterIDToHit = 0; | |
2539 this->dword_000334_unique_name = 0; | |
2540 memset(this->pSpriteIDs, 0, sizeof(pSpriteIDs)); | |
2541 memset(this->pActorBuffs, 0, 0x160u); | |
2542 } | |
2543 | |
2544 //----- (0045959A) -------------------------------------------------------- | |
2545 void Actor::PrepareSprites(char load_sounds_if_bit1_set) | |
2546 { | |
2547 | |
2548 MonsterDesc *v3; // esi@1 | |
2549 MonsterInfo *v9; // [sp+84h] [bp-10h]@1 | |
2550 | |
2551 v3 = &pMonsterList->pMonsters[pMonsterInfo.uID - 1]; | |
2552 v9 = &pMonsterStats->pInfos[pMonsterInfo.uID - 1 + 1]; | |
2553 //v12 = pSpriteIDs; | |
2554 //Source = (char *)v3->pSpriteNames; | |
2555 //do | |
2556 for (uint i = 0; i < 8; ++i) | |
2557 { | |
2558 //strcpy(pSpriteName, v3->pSpriteNames[i]); | |
2559 pSpriteIDs[i] = pSpriteFrameTable->FastFindSprite(v3->pSpriteNames[i]); | |
2560 pSpriteFrameTable->InitializeSprite(pSpriteIDs[i]); | |
2561 } | |
2562 uActorHeight = v3->uMonsterHeight; | |
2563 uActorRadius = v3->uMonsterRadius; | |
2564 uMovementSpeed = v9->uBaseSpeed; | |
2565 if ( !(load_sounds_if_bit1_set & 1) ) | |
2566 { | |
2567 for ( int i = 0; i < 4; ++i ) | |
2568 pSoundSampleIDs[i] = v3->pSoundSampleIDs[i]; | |
2569 } | |
2570 } | |
2571 | |
2572 //----- (00459667) -------------------------------------------------------- | |
2573 void Actor::Remove() | |
2574 { | |
2575 this->uAIState = Removed; | |
2576 } | |
2577 | |
2578 | |
2579 //----- (0043B1B0) -------------------------------------------------------- | |
2580 void Actor::ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, Vec3_int_ *pVelocity, signed int a4) | |
2581 { | |
2582 int v4; // ebx@1 | |
2583 int dmgToRecv; // qax@8 | |
2584 signed int v12; // ecx@20 | |
2585 int finalDmg; // edi@30 | |
2586 int pushDistance; // [sp+20h] [bp+Ch]@34 | |
2587 | |
2588 v4 = 0; | |
2589 if ( PID_TYPE(attacker_id) == OBJECT_Item) | |
2590 { | |
2591 v4 = pSpriteObjects[PID_ID(attacker_id)].field_60_distance_related_prolly_lod; | |
2592 attacker_id = pSpriteObjects[PID_ID(attacker_id)].spell_caster_pid; | |
2593 } | |
2594 if ( PID_TYPE(attacker_id) == OBJECT_Actor) | |
2595 { | |
2596 if ( !pActors[actor_id].IsNotAlive() ) | |
2597 { | |
2598 pActors[actor_id].uLastCharacterIDToHit = attacker_id; | |
2599 if ( pActors[actor_id].uAIState == Fleeing ) | |
2600 pActors[actor_id].uAttributes |= ACTOR_FLEEING; | |
2601 if ( pActors[PID_ID(attacker_id)]._4273BB_DoesHitOtherActor(&pActors[actor_id], v4, 0) ) | |
2602 { | |
2603 dmgToRecv = pActors[PID_ID(attacker_id)]._43B3E0_CalcDamage(a4); | |
2604 if ( pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) | |
2605 { | |
2606 if ( pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower ) | |
2607 dmgToRecv = dmgToRecv / pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower; | |
2608 } | |
2609 if ( pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 ) | |
2610 dmgToRecv = 0; | |
2611 if ( a4 == 0 ) | |
2612 v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.uAttack1Type; | |
2613 else if ( a4 == 1 ) | |
2614 { | |
2615 v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.uAttack2Type; | |
2616 if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > 0 ) | |
2617 dmgToRecv = dmgToRecv / 2; | |
2618 } | |
2619 else if ( a4 == 2 ) | |
2620 v12 = pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell1ID].uSchool; | |
2621 else if ( a4 == 3 ) | |
2622 v12 = pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell2ID].uSchool; | |
2623 else if ( a4 == 4 ) | |
2624 v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.field_3C_some_special_attack; | |
2625 else | |
2626 v12 = 4; | |
2627 finalDmg = pActors[actor_id].CalcMagicalDamageToActor((DAMAGE_TYPE)v12, dmgToRecv); | |
2628 pActors[actor_id].sCurrentHP -= finalDmg; | |
2629 if ( finalDmg ) | |
2630 { | |
2631 if ( pActors[actor_id].sCurrentHP > 0 ) | |
2632 Actor::AI_Stun(actor_id, attacker_id, 0); | |
2633 else | |
2634 Actor::Die(actor_id); | |
2635 Actor::AggroSurroundingPeasants(actor_id, 0); | |
2636 pushDistance = 20 * finalDmg / pActors[actor_id].pMonsterInfo.uHP; | |
2637 if ( pushDistance > 10 ) | |
2638 pushDistance = 10; | |
2639 if ( !MonsterStats::BelongsToSupertype(pActors[actor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
2640 { | |
2641 pVelocity->x = (int32)fixpoint_mul(pushDistance, pVelocity->x); | |
2642 pVelocity->y = (int32)fixpoint_mul(pushDistance, pVelocity->y); | |
2643 pVelocity->z = (int32)fixpoint_mul(pushDistance, pVelocity->z); | |
2644 pActors[actor_id].vVelocity.x = 50 * LOWORD(pVelocity->x); | |
2645 pActors[actor_id].vVelocity.y = 50 * LOWORD(pVelocity->y); | |
2646 pActors[actor_id].vVelocity.z = 50 * LOWORD(pVelocity->z); | |
2647 } | |
2648 Actor::AddBloodsplatOnDamageOverlay(actor_id, 1, finalDmg); | |
2649 } | |
2650 else | |
2651 Actor::AI_Stun(actor_id, attacker_id, 0); | |
2652 return; | |
2653 } | |
2654 } | |
2655 } | |
2656 } | |
2657 | |
2658 //----- (0044FD29) -------------------------------------------------------- | |
2659 void Actor::SummonMinion( int summonerId ) | |
2660 { | |
2661 unsigned __int8 extraSummonLevel; // al@1 | |
2662 int summonMonsterBaseType; // esi@1 | |
2663 int v5; // edx@2 | |
2664 int v7; // edi@10 | |
2665 Actor *actor; // esi@10 | |
2666 MonsterInfo *v9; // ebx@10 | |
2667 //MonsterDesc *v10; // edi@10 | |
2668 int v13; // ebx@10 | |
2669 int v15; // edi@10 | |
2670 int v17; // ebx@10 | |
2671 unsigned int v19; // qax@10 | |
2672 int result; // eax@13 | |
2673 unsigned int monsterId; // [sp+10h] [bp-18h]@8 | |
2674 int v27; // [sp+18h] [bp-10h]@10 | |
2675 int actorSector; // [sp+1Ch] [bp-Ch]@8 | |
2676 | |
2677 | |
2678 actorSector = 0; | |
2679 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
2680 actorSector = pIndoor->GetSector(this->vPosition.x, this->vPosition.y, this->vPosition.z); | |
2681 | |
2682 v19 = this->uAlly; | |
2683 if ( !this->uAlly ) | |
2684 { | |
2685 monsterId = this->pMonsterInfo.uID - 1; | |
2686 v19 = (uint)(monsterId * 0.33333334); | |
2687 } | |
2688 v27 = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? 128 : 64; | |
2689 v13 = rand() % 2048; | |
2690 v15 = fixpoint_mul(stru_5C6E00->Cos(v13), v27) + this->vPosition.x; | |
2691 v17 = fixpoint_mul(stru_5C6E00->Sin(v13), v27) + this->vPosition.y; | |
2692 | |
2693 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
2694 { | |
2695 result = pIndoor->GetSector(v15, v17, this->vPosition.z); | |
2696 if (result != actorSector) | |
2697 return; | |
2698 result = BLV_GetFloorLevel(v15, v17, v27, result, &monsterId); | |
2699 if (result != -30000) | |
2700 return; | |
2701 if (abs(result - v27) > 1024) | |
2702 return; | |
2703 } | |
2704 | |
2705 extraSummonLevel = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls; | |
2706 summonMonsterBaseType = this->pMonsterInfo.field_3C_some_special_attack; | |
2707 if ( extraSummonLevel ) | |
2708 { | |
2709 if ( extraSummonLevel >= 1 && extraSummonLevel <= 3 ) | |
2710 summonMonsterBaseType = summonMonsterBaseType + extraSummonLevel - 1; | |
2711 } | |
2712 else | |
2713 { | |
2714 v5 = rand() % 100; | |
2715 if ( v5 >= 90 ) | |
2716 summonMonsterBaseType += 2; | |
2717 else if ( v5 >= 60 ) | |
2718 summonMonsterBaseType += 1; | |
2719 } | |
2720 v7 = summonMonsterBaseType - 1; | |
2721 actor = &pActors[uNumActors]; | |
2722 v9 = &pMonsterStats->pInfos[v7 + 1]; | |
2723 pActors[uNumActors].Reset(); | |
2724 strcpy(actor->pActorName, v9->pName); | |
2725 actor->sCurrentHP = LOWORD(v9->uHP); | |
2726 memcpy(&actor->pMonsterInfo, v9, sizeof(actor->pMonsterInfo)); | |
2727 actor->word_000086_some_monster_id = summonMonsterBaseType; | |
2728 actor->uActorRadius = pMonsterList->pMonsters[v7].uMonsterRadius; | |
2729 actor->uActorHeight = pMonsterList->pMonsters[v7].uMonsterHeight; | |
2730 actor->pMonsterInfo.uTreasureDiceRolls = 0; | |
2731 actor->pMonsterInfo.uTreasureType = 0; | |
2732 actor->pMonsterInfo.uExp = 0; | |
2733 actor->uMovementSpeed = pMonsterList->pMonsters[v7].uMovementSpeed; | |
2734 | |
2735 actor->vInitialPosition.x = v15; | |
2736 actor->vInitialPosition.y = v17; | |
2737 actor->vInitialPosition.z = this->vPosition.z; | |
2738 actor->vPosition.x = v15; | |
2739 actor->vPosition.y = v17; | |
2740 actor->vPosition.z = this->vPosition.z; | |
2741 | |
2742 actor->uTetherDistance = 256; | |
2743 actor->uSectorID = actorSector; | |
2744 actor->PrepareSprites(0); | |
2745 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
2746 actor->uAlly = v19; | |
2747 actor->uCurrentActionTime = 0; | |
2748 actor->uGroup = this->uGroup; | |
2749 actor->uAIState = Summoned; | |
2750 actor->uCurrentActionLength = 256; | |
2751 actor->UpdateAnimation(); | |
2752 | |
2753 ++uNumActors; | |
2754 ++this->pMonsterInfo.uSpecialAbilityDamageDiceBonus; | |
2755 if ( ActorEnemy()) | |
2756 actor->uAttributes |= ACTOR_AGGRESSOR; | |
2757 actor->uSummonerID = PID(OBJECT_Actor,summonerId); | |
2758 | |
2759 } | |
2760 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); | |
2761 //----- (0046DF1A) -------------------------------------------------------- | |
2762 bool Actor::_46DF1A_collide_against_actor( int a1, int a2 ) | |
2763 { | |
2764 Actor *v2; // edi@1 | |
2765 unsigned __int16 v3; // ax@1 | |
2766 int v4; // esi@6 | |
2767 int v8; // ecx@14 | |
2768 int v9; // eax@14 | |
2769 int v10; // ebx@14 | |
2770 int v11; // esi@14 | |
2771 int v12; // ebx@15 | |
2772 int v13; // ebx@17 | |
2773 | |
2774 v2 = &pActors[a1]; | |
2775 v3 = v2->uAIState; | |
2776 if ( v3 == Removed || v3 == Dying || v3 == Disabled || v3 == Dead || v3 == Summoned ) | |
2777 return 0; | |
2778 v4 = v2->uActorRadius; | |
2779 if ( a2 ) | |
2780 v4 = a2; | |
2781 | |
2782 if (stru_721530.sMaxX > v2->vPosition.x + v4 || | |
2783 stru_721530.sMinX < v2->vPosition.x - v4 || | |
2784 stru_721530.sMaxY > v2->vPosition.y + v4 || | |
2785 stru_721530.sMinY < v2->vPosition.y - v4 || | |
2786 stru_721530.sMaxZ > v2->vPosition.z + v2->uActorHeight || | |
2787 stru_721530.sMinZ < v2->vPosition.z) | |
2788 { | |
2789 return false; | |
2790 } | |
2791 v8 = v2->vPosition.x - stru_721530.normal.x; | |
2792 v9 = v2->vPosition.y - stru_721530.normal.y; | |
2793 v10 = stru_721530.prolly_normal_d + v4; | |
2794 v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16; | |
2795 v12 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16; | |
2796 if ( abs(v11) > v10 || v12 <= 0) | |
2797 return false; | |
2798 if (fixpoint_mul(stru_721530.direction.z, v12) + stru_721530.normal.z < v2->vPosition.z) | |
2799 return false; | |
2800 | |
2801 v13 = v12 - integer_sqrt(v10 * v10 - v11 * v11); | |
2802 if ( v13 < 0 ) | |
2803 v13 = 0; | |
2804 if ( v13 < stru_721530.field_7C ) | |
2805 { | |
2806 stru_721530.field_7C = v13; | |
2807 stru_721530.uFaceID = PID(OBJECT_Actor,a1); | |
2808 } | |
2809 return true; | |
2810 } | |
2811 //----- (00401A91) -------------------------------------------------------- | |
2812 void Actor::UpdateActorAI() | |
2813 { | |
2814 signed int v4; // edi@10 | |
2815 signed int sDmg; // eax@14 | |
2816 Player *pPlayer; // ecx@21 | |
2817 Actor *pActor; // esi@34 | |
2818 //unsigned __int16 v22; // ax@86 | |
2819 unsigned int v27; // ecx@123 | |
2820 unsigned int v28; // eax@123 | |
2821 int v33; // eax@144 | |
2822 int v34; // eax@147 | |
2823 char v35; // al@150 | |
2824 unsigned int v36; // edi@152 | |
2825 signed int v37; // eax@154 | |
2826 double v42; // st7@176 | |
2827 double v43; // st6@176 | |
2828 int v45; // eax@192 | |
2829 unsigned __int8 v46; // cl@197 | |
2830 signed int v47; // st7@206 | |
2831 uint v58; // st7@246 | |
2832 unsigned int v65; // [sp-10h] [bp-C0h]@144 | |
2833 int v70; // [sp-10h] [bp-C0h]@213 | |
2834 AIDirection v72; // [sp+0h] [bp-B0h]@246 | |
2835 AIDirection a3; // [sp+1Ch] [bp-94h]@129 | |
2836 int target_pid_type; // [sp+70h] [bp-40h]@83 | |
2837 signed int a1; // [sp+74h] [bp-3Ch]@129 | |
2838 int v78; // [sp+78h] [bp-38h]@79 | |
2839 AIDirection* pDir; // [sp+7Ch] [bp-34h]@129 | |
2840 float radiusMultiplier; // [sp+98h] [bp-18h]@33 | |
2841 int v81; // [sp+9Ch] [bp-14h]@100 | |
2842 signed int target_pid; // [sp+ACh] [bp-4h]@83 | |
2843 AIState uAIState; | |
2844 uint v38; | |
2845 | |
2846 //Build AI array | |
2847 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2848 Actor::MakeActorAIList_ODM(); | |
2849 else | |
2850 Actor::MakeActorAIList_BLV(); | |
2851 | |
2852 //Armageddon damage mechanic | |
2853 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) | |
2854 { | |
2855 if ( pParty->armageddon_timer > 417 ) | |
2856 pParty->armageddon_timer = 0; | |
2857 else | |
2858 { | |
2859 pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8); | |
2860 pParty->sRotationX = pParty->sRotationX + rand() % 16 - 8; | |
2861 if ( pParty->sRotationX > 128) | |
2862 pParty->sRotationX = 128; | |
2863 else if ( pParty->sRotationX < -128 ) | |
2864 pParty->sRotationX = -128; | |
2865 | |
2866 pParty->uFlags |= 2u; | |
2867 pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; | |
2868 v4 = pParty->armageddonDamage + 50; | |
2869 if ( pParty->armageddon_timer <= 0 ) | |
2870 { | |
2871 pParty->armageddon_timer = 0; | |
2872 for(size_t i = 0; i < uNumActors; i++) | |
2873 { | |
2874 pActor=&pActors[i]; | |
2875 if ( pActor->CanAct() ) | |
2876 { | |
2877 sDmg = pActor->CalcMagicalDamageToActor((DAMAGE_TYPE)5, v4); | |
2878 pActor->sCurrentHP -= sDmg; | |
2879 if ( sDmg ) | |
2880 { | |
2881 if ( pActor->sCurrentHP >= 0 ) | |
2882 Actor::AI_Stun(i, 4, 0); | |
2883 else | |
2884 { | |
2885 Actor::Die(i); | |
2886 if ( pActor->pMonsterInfo.uExp ) | |
2887 pParty->GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp); | |
2888 } | |
2889 } | |
2890 } | |
2891 } | |
2892 for(int i = 1; i <= 4; i++) | |
2893 { | |
2894 pPlayer = pPlayers[i]; | |
2895 if ( !pPlayer->pConditions[Condition_Dead] && !pPlayer->pConditions[Condition_Pertified] && !pPlayer->pConditions[Condition_Eradicated] ) | |
2896 pPlayer->ReceiveDamage(v4, DMGT_MAGICAL); | |
2897 } | |
2898 } | |
2899 if (pTurnEngine->pending_actions) | |
2900 --pTurnEngine->pending_actions; | |
2901 } | |
2902 } | |
2903 | |
2904 //Turn-based mode: return | |
2905 if (pParty->bTurnBasedModeOn) | |
2906 { | |
2907 pTurnEngine->AITurnBasedAction(); | |
2908 return; | |
2909 } | |
2910 | |
2911 for (uint i = 0; i < uNumActors; ++i) | |
2912 { | |
2913 pActor = &pActors[i]; | |
2914 ai_near_actors_targets_pid[i] = OBJECT_Player; | |
2915 | |
2916 //Skip actor if: Dead / Removed / Disabled / uAttributes & 0x0400 | |
2917 if (pActor->uAIState == Dead || pActor->uAIState == Removed || pActor->uAIState == Disabled || pActor->uAttributes & ACTOR_ALIVE) | |
2918 continue; | |
2919 | |
2920 //Kill actor if HP == 0 | |
2921 if (!pActor->sCurrentHP && pActor->uAIState != Dying) | |
2922 Actor::Die(i); | |
2923 | |
2924 //Kill buffs if expired | |
2925 for (uint j = 0; j < 22; ++j) | |
2926 { | |
2927 if (j != 10) | |
2928 pActor->pActorBuffs[j].IsBuffExpiredToTime(pParty->uTimePlayed); | |
2929 } | |
2930 | |
2931 //If shrink expired: reset height | |
2932 if (pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0) | |
2933 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; | |
2934 | |
2935 //If Charm still active: make actor friendly | |
2936 if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0) | |
2937 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
2938 //Else: reset hostilty | |
2939 else if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0) | |
2940 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; | |
2941 | |
2942 //If actor Paralyzed or Stoned: skip | |
2943 if (pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 || pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) | |
2944 continue; | |
2945 | |
2946 //Calculate RecoveryTime | |
2947 pActor->pMonsterInfo.uRecoveryTime = max(pActor->pMonsterInfo.uRecoveryTime - pMiscTimer->uTimeElapsed, 0); | |
2948 | |
2949 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; | |
2950 if (pActor->uCurrentActionTime < pActor->uCurrentActionLength) | |
2951 continue; | |
2952 | |
2953 if (pActor->uAIState == Dying) | |
2954 pActor->uAIState = Dead; | |
2955 else | |
2956 { | |
2957 if (pActor->uAIState != Summoned) | |
2958 { | |
2959 Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); | |
2960 continue; | |
2961 } | |
2962 pActor->uAIState = Standing; | |
2963 } | |
2964 | |
2965 pActor->uCurrentActionTime = 0; | |
2966 pActor->uCurrentActionLength = 0; | |
2967 pActor->UpdateAnimation(); | |
2968 } | |
2969 | |
2970 for(v78 = 0; v78 < ai_arrays_size; ++v78) | |
2971 { | |
2972 uint actor_id = ai_near_actors_ids[v78]; | |
2973 assert(actor_id < uNumActors); | |
2974 | |
2975 pActor = &pActors[actor_id]; | |
2976 | |
2977 v47 = (signed int)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333); | |
2978 | |
2979 Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); | |
2980 | |
2981 if (pActor->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) | |
2982 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
2983 | |
2984 target_pid = ai_near_actors_targets_pid[actor_id]; | |
2985 target_pid_type = PID_TYPE(target_pid); | |
2986 | |
2987 if ( target_pid_type == OBJECT_Actor) | |
2988 radiusMultiplier = 0.5; | |
2989 else | |
2990 radiusMultiplier = 1.0; | |
2991 | |
2992 //v22 = pActor->uAIState; | |
2993 if ( pActor->uAIState == Dying || pActor->uAIState == Dead || pActor->uAIState == Removed | |
2994 || pActor->uAIState == Disabled || pActor->uAIState == Summoned) | |
2995 continue; | |
2996 | |
2997 if ( !pActor->sCurrentHP ) | |
2998 Actor::Die(actor_id); | |
2999 | |
3000 for( int i = 0;i < 22; i++ ) | |
3001 { | |
3002 if ( i != 10 ) | |
3003 pActor->pActorBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed); | |
3004 } | |
3005 | |
3006 if ( pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) | |
3007 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; | |
3008 if ( pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) | |
3009 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
3010 else if ( pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) | |
3011 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; | |
3012 | |
3013 //If actor is summoned and buff expired: continue and set state to Removed | |
3014 if ( pActor->pActorBuffs[ACTOR_BUFF_SUMMONED].uExpireTime < 0 ) | |
3015 { | |
3016 pActor->uAIState = Removed; | |
3017 continue; | |
3018 } | |
3019 | |
3020 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 || (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0) | |
3021 { | |
3022 continue; | |
3023 } | |
3024 | |
3025 v27 = pMiscTimer->uTimeElapsed; | |
3026 v28 = pActor->pMonsterInfo.uRecoveryTime; | |
3027 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; | |
3028 | |
3029 if ( (signed int)v28 > 0 ) | |
3030 pActor->pMonsterInfo.uRecoveryTime = v28 - v27; | |
3031 if ( pActor->pMonsterInfo.uRecoveryTime < 0 ) | |
3032 pActor->pMonsterInfo.uRecoveryTime = 0; | |
3033 if ( !pActor->ActorNearby() ) | |
3034 pActor->uAttributes |= ACTOR_NEARBY; | |
3035 | |
3036 a1 = PID(OBJECT_Actor,actor_id); | |
3037 Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); | |
3038 pDir = &a3; | |
3039 uAIState = pActor->uAIState; | |
3040 | |
3041 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly | |
3042 || (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 | |
3043 || radiusMultiplier * 307.2 < pDir->uDistance | |
3044 || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting | |
3045 && !pActor->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned ) | |
3046 { | |
3047 if ( (signed int)pActor->uCurrentActionTime < pActor->uCurrentActionLength ) | |
3048 continue; | |
3049 else if ( pActor->uAIState == AttackingMelee ) | |
3050 { | |
3051 v35 = pActor->special_ability_use_check(actor_id); | |
3052 AttackerInfo.Add(a1, 5120, pActor->vPosition.x, pActor->vPosition.y, pActor->vPosition.z + ((signed int)pActor->uActorHeight >> 1), v35, 1 ); | |
3053 } | |
3054 else if ( pActor->uAIState == AttackingRanged1 ) | |
3055 { | |
3056 v34 = pActor->pMonsterInfo.uMissleAttack1Type; | |
3057 Actor::AI_RangedAttack(actor_id, pDir, v34, 0); | |
3058 } | |
3059 else if ( pActor->uAIState == AttackingRanged2 ) | |
3060 { | |
3061 v34 = pActor->pMonsterInfo.uMissleAttack2Type; | |
3062 Actor::AI_RangedAttack(actor_id, pDir, v34, 1); | |
3063 } | |
3064 else if ( pActor->uAIState == AttackingRanged3 ) | |
3065 { | |
3066 v65 = pActor->pMonsterInfo.uSpellSkillAndMastery1; | |
3067 v33 = pActor->pMonsterInfo.uSpell1ID; | |
3068 Actor::AI_SpellAttack(actor_id, pDir, v33, 2, v65); | |
3069 } | |
3070 else if ( pActor->uAIState == AttackingRanged4 ) | |
3071 { | |
3072 v65 = pActor->pMonsterInfo.uSpellSkillAndMastery2; | |
3073 v33 = pActor->pMonsterInfo.uSpell2ID; | |
3074 Actor::AI_SpellAttack(actor_id, pDir, v33, 3, v65); | |
3075 } | |
3076 } | |
3077 | |
3078 v36 = pDir->uDistance; | |
3079 | |
3080 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) | |
3081 { | |
3082 if ( target_pid_type == OBJECT_Actor ) | |
3083 { | |
3084 v36 = pDir->uDistance; | |
3085 v37 =pFactionTable->relations[(pActor->pMonsterInfo.uID-1) / 3 + 1][(pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3 + 1]; | |
3086 } | |
3087 else | |
3088 v37 = 4; | |
3089 v38 = 0; | |
3090 if ( v37 == 2 ) | |
3091 v38 = 1024; | |
3092 else if ( v37 == 3 ) | |
3093 v38 = 2560; | |
3094 else if ( v37 == 4 ) | |
3095 v38 = 5120; | |
3096 if ( v37 >= 1 && v37 <= 4 && v36 < v38 || v37 == 1 ) | |
3097 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
3098 } | |
3099 | |
3100 //If actor afraid: flee or if out of range random move | |
3101 if (pActor->pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0) | |
3102 { | |
3103 if ( (signed int)v36 >= 10240 ) | |
3104 Actor::AI_RandomMove(actor_id, target_pid, 1024, 0); | |
3105 else | |
3106 Actor::AI_Flee(actor_id, target_pid, 0, pDir); | |
3107 continue; | |
3108 } | |
3109 | |
3110 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) | |
3111 { | |
3112 if ( pActor->pMonsterInfo.uAIType == 1 ) | |
3113 { | |
3114 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
3115 Actor::AI_Stand(actor_id, target_pid, (uint)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333), pDir); | |
3116 else | |
3117 { | |
3118 Actor::AI_Flee(actor_id, target_pid, 0, pDir); | |
3119 continue; | |
3120 } | |
3121 | |
3122 } | |
3123 if ( !(pActor->uAttributes & ACTOR_FLEEING) ) | |
3124 { | |
3125 if ( pActor->pMonsterInfo.uAIType == 2 || pActor->pMonsterInfo.uAIType == 3) | |
3126 { | |
3127 if ( pActor->pMonsterInfo.uAIType == 2 ) | |
3128 v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.2; | |
3129 if ( pActor->pMonsterInfo.uAIType == 3 ) | |
3130 v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.1; | |
3131 v42 = (double)pActor->sCurrentHP; | |
3132 if ( v43 > v42 && (signed int)v36 < 10240 ) | |
3133 { | |
3134 Actor::AI_Flee(actor_id, target_pid, 0, pDir); | |
3135 continue; | |
3136 } | |
3137 } | |
3138 } | |
3139 | |
3140 v81 = v36 - pActor->uActorRadius; | |
3141 if ( target_pid_type == OBJECT_Actor ) | |
3142 v81 -= pActors[PID_ID(target_pid)].uActorRadius; | |
3143 if ( v81 < 0 ) | |
3144 v81 = 0; | |
3145 rand(); | |
3146 pActor->uAttributes &= ~ACTOR_UNKNOW5;//~0x40000 | |
3147 if ( v81 < 5120 ) | |
3148 { | |
3149 v45 = pActor->special_ability_use_check(actor_id); | |
3150 if ( v45 == 0 ) | |
3151 { | |
3152 if ( pActor->pMonsterInfo.uMissleAttack1Type ) | |
3153 { | |
3154 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) | |
3155 Actor::AI_MissileAttack1(actor_id, target_pid, pDir); | |
3156 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
3157 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3158 else | |
3159 { | |
3160 if ( radiusMultiplier * 307.2 > (double)v81 ) | |
3161 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3162 else | |
3163 Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir); | |
3164 } | |
3165 } | |
3166 else | |
3167 { | |
3168 if ( (double)v81 >= radiusMultiplier * 307.2 ) | |
3169 { | |
3170 if (pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY) | |
3171 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3172 else if ( v81 >= 1024 )//monsters | |
3173 Actor::AI_Pursue3(actor_id, target_pid, 0, pDir); | |
3174 else | |
3175 { | |
3176 v70 = (signed int)(radiusMultiplier * 307.2); | |
3177 //monsters | |
3178 //guard after player runs away | |
3179 // follow player | |
3180 Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70); | |
3181 } | |
3182 } | |
3183 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
3184 { | |
3185 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3186 } | |
3187 else | |
3188 { | |
3189 //monsters | |
3190 Actor::AI_MeleeAttack(actor_id, target_pid, pDir); | |
3191 } | |
3192 } | |
3193 continue; | |
3194 } | |
3195 else if ( v45 == 2 || v45 == 3 ) | |
3196 { | |
3197 if ( v45 == 2 ) | |
3198 v46 = pActor->pMonsterInfo.uSpell1ID; | |
3199 else | |
3200 v46 = pActor->pMonsterInfo.uSpell2ID; | |
3201 if ( v46 ) | |
3202 { | |
3203 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) | |
3204 { | |
3205 if ( v45 == 2 ) | |
3206 Actor::AI_SpellAttack1(actor_id, target_pid, pDir); | |
3207 else | |
3208 Actor::AI_SpellAttack2(actor_id, target_pid, pDir); | |
3209 } | |
3210 else if ( radiusMultiplier * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
3211 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3212 else | |
3213 Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir); | |
3214 } | |
3215 else | |
3216 { | |
3217 if ( (double)v81 >= radiusMultiplier * 307.2 ) | |
3218 { | |
3219 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
3220 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3221 else if ( v81 >= 1024 ) | |
3222 Actor::AI_Pursue3(actor_id, target_pid, 256, pDir); | |
3223 else | |
3224 { | |
3225 v70 = (signed int)(radiusMultiplier * 307.2); | |
3226 Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70); | |
3227 } | |
3228 } | |
3229 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
3230 { | |
3231 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3232 } | |
3233 else | |
3234 { | |
3235 Actor::AI_MeleeAttack(actor_id, target_pid, pDir); | |
3236 } | |
3237 } | |
3238 continue; | |
3239 } | |
3240 } | |
3241 } | |
3242 | |
3243 if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) | |
3244 { | |
3245 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_SHORT ) | |
3246 Actor::AI_RandomMove(actor_id, 4, 1024, 0); | |
3247 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_MEDIUM ) | |
3248 Actor::AI_RandomMove(actor_id, 4, 2560, 0); | |
3249 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_LONG ) | |
3250 Actor::AI_RandomMove(actor_id, 4, 5120, 0); | |
3251 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_FREE ) | |
3252 Actor::AI_RandomMove(actor_id, 4, 10240, 0); | |
3253 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
3254 { | |
3255 Actor::GetDirectionInfo(a1, 4, &v72, 0); | |
3256 v58 = (uint)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333); | |
3257 Actor::AI_Stand(actor_id, 4, v58, &v72); | |
3258 } | |
3259 } | |
3260 else if ( !pActor->pMonsterInfo.uMissleAttack2Type ) | |
3261 { | |
3262 if ( (double)v81 >= radiusMultiplier * 307.2 ) | |
3263 { | |
3264 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
3265 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3266 else if ( v81 >= 1024 ) | |
3267 Actor::AI_Pursue3(actor_id, target_pid, 256, pDir); | |
3268 else | |
3269 { | |
3270 v70 = (int)(radiusMultiplier * 307.2); | |
3271 Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70); | |
3272 } | |
3273 } | |
3274 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
3275 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3276 else | |
3277 Actor::AI_MeleeAttack(actor_id, target_pid, pDir); | |
3278 } | |
3279 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
3280 { | |
3281 if ( radiusMultiplier * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
3282 Actor::AI_Stand(actor_id, target_pid, v47, pDir); | |
3283 else | |
3284 Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir); | |
3285 } | |
3286 else | |
3287 Actor::AI_MissileAttack2(actor_id, target_pid, pDir); | |
3288 } | |
3289 } | |
3290 //----- (0044665D) -------------------------------------------------------- | |
3291 // uType: 0 -> any monster | |
3292 // 1 -> uParam is GroupID | |
3293 // 2 -> uParam is MonsterID | |
3294 // 3 -> uParam is ActorID | |
3295 // uNumAlive: 0 -> all must be alive | |
3296 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive) | |
3297 { | |
3298 unsigned int uAliveActors; // eax@6 | |
3299 unsigned int uTotalActors; // [sp+0h] [bp-4h]@1 | |
3300 | |
3301 uTotalActors = 0; | |
3302 if ( uType ) | |
3303 { | |
3304 if ( uType == 1 ) | |
3305 uAliveActors = Actor::SearchActorByGroup(&uTotalActors, uParam); | |
3306 else | |
3307 { | |
3308 if ( uType == 2 ) | |
3309 uAliveActors = Actor::SearchActorByMonsterID(&uTotalActors, uParam); | |
3310 else | |
3311 { | |
3312 if ( uType != 3 ) | |
3313 return 0; | |
3314 uAliveActors = Actor::SearchActorByID(&uTotalActors, uParam); | |
3315 } | |
3316 } | |
3317 } | |
3318 else | |
3319 uAliveActors = Actor::SearchAliveActors(&uTotalActors); | |
3320 | |
3321 if (uNumAlive) | |
3322 return uAliveActors >= uNumAlive; | |
3323 else | |
3324 return uTotalActors == uAliveActors; | |
3325 } | |
3326 //----- (00408B54) -------------------------------------------------------- | |
3327 unsigned int Actor::SearchActorByID(unsigned int *pTotalActors, unsigned int a2) | |
3328 { | |
3329 //int v4; // eax@1 | |
3330 unsigned int result; // ebx@1 | |
3331 | |
3332 //v4 = GetAlertStatus(); | |
3333 *pTotalActors = 0; | |
3334 result = 0; | |
3335 if ( (pActors[a2].uAttributes & ACTOR_UNKNOW7) == GetAlertStatus() ) | |
3336 { | |
3337 *pTotalActors = 1; | |
3338 if ( pActors[a2].IsNotAlive() == 1 ) | |
3339 result = 1; | |
3340 } | |
3341 return result; | |
3342 } | |
3343 //----- (00408AE7) -------------------------------------------------------- | |
3344 unsigned int Actor::SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) | |
3345 { | |
3346 unsigned int result; // [sp+10h] [bp-4h]@1 | |
3347 | |
3348 int v8 = GetAlertStatus(); | |
3349 *pTotalActors = 0; | |
3350 result = 0; | |
3351 for ( uint i = 0; i < uNumActors; i++) | |
3352 { | |
3353 if ( (pActors[i].uAttributes & ACTOR_UNKNOW7) == v8 && pActors[i].uGroup == uGroup) | |
3354 { | |
3355 ++*pTotalActors; | |
3356 if ( pActors[i].IsNotAlive() == 1 ) | |
3357 ++result; | |
3358 } | |
3359 } | |
3360 return result; | |
3361 } | |
3362 //----- (00408A7E) -------------------------------------------------------- | |
3363 unsigned int Actor::SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID) | |
3364 { | |
3365 int v8; // [sp+Ch] [bp-8h]@1 | |
3366 unsigned int result; // [sp+10h] [bp-4h]@1 | |
3367 | |
3368 v8 = GetAlertStatus(); | |
3369 *pTotalActors = 0; | |
3370 result = 0; | |
3371 for ( uint i = 0; i < uNumActors; i++) | |
3372 { | |
3373 if ( (pActors[i].uAttributes & ACTOR_UNKNOW7) == v8 && pActors[i].pMonsterInfo.field_33 == uMonsterID) | |
3374 { | |
3375 ++*pTotalActors; | |
3376 if ( pActors[i].IsNotAlive() == 1 ) | |
3377 ++result; | |
3378 } | |
3379 } | |
3380 return result; | |
3381 } | |
3382 //----- (00408A27) -------------------------------------------------------- | |
3383 unsigned int Actor::SearchAliveActors(unsigned int *pTotalActors) | |
3384 { | |
3385 int v2; // eax@1 | |
3386 unsigned int result; // ebp@1 | |
3387 | |
3388 v2 = GetAlertStatus(); | |
3389 result = 0; | |
3390 *pTotalActors = 0; | |
3391 for ( uint i = 0; i < uNumActors; i++) | |
3392 { | |
3393 if ( (pActors[i].uAttributes & ACTOR_UNKNOW7) == v2 ) | |
3394 { | |
3395 ++*pTotalActors; | |
3396 if ( pActors[i].IsNotAlive() == 1 ) | |
3397 ++result; | |
3398 } | |
3399 } | |
3400 return result; | |
3401 } | |
3402 //----- (00408768) -------------------------------------------------------- | |
3403 void Actor::InitializeActors() | |
3404 { | |
3405 bool evil; // [sp+Ch] [bp-10h]@1 | |
3406 bool bPit; // [sp+10h] [bp-Ch]@1 | |
3407 bool good; // [sp+14h] [bp-8h]@1 | |
3408 bool bCelestia; // [sp+18h] [bp-4h]@1 | |
3409 | |
3410 bCelestia = false; | |
3411 bPit = false; | |
3412 good = false; | |
3413 evil = false; | |
3414 if ( !_stricmp(pCurrentMapName, "d25.blv") )//the Celestia | |
3415 bCelestia = true; | |
3416 if ( !_stricmp(pCurrentMapName, "d26.blv") )//the Pit | |
3417 bPit = true; | |
3418 if (pParty->IsPartyGood()) | |
3419 good = true; | |
3420 if (pParty->IsPartyEvil()) | |
3421 evil = true; | |
3422 | |
3423 Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical | |
3424 for (uint i = 0; i < uNumActors; ++i) | |
3425 { | |
3426 Actor* actor = &pActors[i]; | |
3427 | |
3428 if (actor->CanAct() || actor->uAIState == Disabled) | |
3429 { | |
3430 actor->vPosition.x = actor->vInitialPosition.x; | |
3431 actor->vPosition.y = actor->vInitialPosition.y; | |
3432 actor->vPosition.z = actor->vInitialPosition.z; | |
3433 actor->sCurrentHP = actor->pMonsterInfo.uHP; | |
3434 if (actor->uAIState != Disabled) | |
3435 { | |
3436 Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0); | |
3437 } | |
3438 } | |
3439 | |
3440 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
3441 | |
3442 if (!bCelestia || good) | |
3443 if (!bPit || evil) | |
3444 if (actor->IsPeasant()) | |
3445 actor->ResetAggressor();//~0x80000 | |
3446 | |
3447 actor->ResetHasItem();//~0x800000 | |
3448 if (actor->uAttributes & ACTOR_UNKNOW9) | |
3449 Actor::_4031C1_update_job_never_gets_called(i, pParty->uCurrentHour, 1); | |
3450 } | |
3451 } | |
3452 //----- (00439474) -------------------------------------------------------- | |
3453 void Actor::DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) | |
3454 { | |
3455 SpriteObject *projectileSprite; // ebx@1 | |
3456 Actor *pMonster; // esi@7 | |
3457 unsigned __int16 v16; // cx@25 | |
3458 int v33; // eax@100 | |
3459 int v40; // ebx@107 | |
3460 int extraRecoveryTime; // qax@125 | |
3461 unsigned __int16 v43; // ax@132 | |
3462 unsigned __int16 v45; // ax@132 | |
3463 unsigned __int64 v46; // [sp+Ch] [bp-60h]@6 | |
3464 char *pPlayerName; // [sp+18h] [bp-54h]@12 | |
3465 char *pMonsterName; // [sp+1Ch] [bp-50h]@6 | |
3466 signed int a4; // [sp+44h] [bp-28h]@1 | |
3467 bool IsAdditionalDamagePossible; // [sp+50h] [bp-1Ch]@1 | |
3468 int v61; // [sp+58h] [bp-14h]@1 | |
3469 bool isLifeStealing; // [sp+5Ch] [bp-10h]@1 | |
3470 int uDamageAmount; // [sp+60h] [bp-Ch]@1 | |
3471 DAMAGE_TYPE attackElement; // [sp+64h] [bp-8h]@27 | |
3472 | |
3473 projectileSprite = 0; | |
3474 uDamageAmount = 0; | |
3475 a4 = 0; | |
3476 v61 = 0; | |
3477 IsAdditionalDamagePossible = false; | |
3478 isLifeStealing = 0; | |
3479 if ( PID_TYPE(a1) == OBJECT_Item) | |
3480 { | |
3481 projectileSprite = &pSpriteObjects[PID_ID(a1)]; | |
3482 v61 = projectileSprite->field_60_distance_related_prolly_lod; | |
3483 a1 = projectileSprite->spell_caster_pid; | |
3484 } | |
3485 if (PID_TYPE(a1) != OBJECT_Player) | |
3486 return; | |
3487 | |
3488 assert(PID_ID(abs(a1)) < 4); | |
3489 Player* player = &pParty->pPlayers[PID_ID(a1)]; | |
3490 pMonster = &pActors[uActorID_Monster]; | |
3491 if (pMonster->IsNotAlive()) | |
3492 return; | |
3493 | |
3494 pMonster->uAttributes |= 0xC000; | |
3495 if ( pMonster->uAIState == Fleeing ) | |
3496 pMonster->uAttributes |= ACTOR_FLEEING; | |
3497 bool hit_will_stun = false, | |
3498 hit_will_paralyze = false; | |
3499 if ( !projectileSprite ) | |
3500 { | |
3501 int main_hand_idx = player->pEquipment.uMainHand; | |
3502 IsAdditionalDamagePossible = true; | |
3503 if ( player->HasItemEquipped(EQUIP_TWO_HANDED) ) | |
3504 { | |
3505 uint main_hand_skill = player->GetMainHandItem()->GetPlayerSkillType(); | |
3506 uint main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]); | |
3507 switch (main_hand_skill) | |
3508 { | |
3509 case PLAYER_SKILL_STAFF: | |
3510 if (main_hand_mastery >= 3) | |
3511 { | |
3512 if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F)) // stun chance when mastery >= 3 | |
3513 hit_will_stun = true; | |
3514 } | |
3515 break; | |
3516 | |
3517 case PLAYER_SKILL_MACE: | |
3518 if (main_hand_mastery >= 3) | |
3519 { | |
3520 if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) | |
3521 hit_will_stun = true; | |
3522 } | |
3523 if (main_hand_mastery >= 4) | |
3524 { | |
3525 if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) | |
3526 hit_will_paralyze = true; | |
3527 } | |
3528 break; | |
3529 } | |
3530 } | |
3531 attackElement = DMGT_PHISYCAL; | |
3532 uDamageAmount = player->CalculateMeleeDamageTo(false, false, pMonster->pMonsterInfo.uID); | |
3533 if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) | |
3534 { | |
3535 player->PlaySound(SPEECH_52, 0); | |
3536 return; | |
3537 } | |
3538 } | |
3539 else | |
3540 { | |
3541 v61 = projectileSprite->field_60_distance_related_prolly_lod; | |
3542 if ( projectileSprite->spell_id != SPELL_DARK_SOULDRINKER ) | |
3543 { | |
3544 int d1 = abs(pParty->vPosition.x - projectileSprite->vPosition.x); | |
3545 int d2 = abs(pParty->vPosition.y - projectileSprite->vPosition.y); | |
3546 int d3 = abs(pParty->vPosition.z - projectileSprite->vPosition.z); | |
3547 v61 = int_get_vector_length(d1, d2, d3); | |
3548 | |
3549 if ( v61 >= 5120 && !(pMonster->uAttributes & ACTOR_ALIVE) )//0x400 | |
3550 return; | |
3551 else if ( v61 >= 2560 ) | |
3552 v61 = 2; | |
3553 else | |
3554 v61 = 1; | |
3555 } | |
3556 | |
3557 switch (projectileSprite->spell_id) | |
3558 { | |
3559 case SPELL_LASER_PROJECTILE: | |
3560 v16 = player->pActiveSkills[PLAYER_SKILL_BLASTER]; | |
3561 v61 = 1; | |
3562 if ( SkillToMastery(v16) >= 3 ) | |
3563 a4 = player->pActiveSkills[PLAYER_SKILL_BLASTER] & 0x3F; | |
3564 attackElement = DMGT_PHISYCAL; | |
3565 uDamageAmount = player->CalculateMeleeDamageTo(true, true, 0); | |
3566 if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) | |
3567 { | |
3568 player->PlaySound(SPEECH_52, 0); | |
3569 return; | |
3570 } | |
3571 break; | |
3572 case SPELL_101: | |
3573 attackElement = DMGT_FIRE; | |
3574 uDamageAmount = player->CalculateRangedDamageTo(0); | |
3575 if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) | |
3576 uDamageAmount >>= 1; | |
3577 IsAdditionalDamagePossible = true; | |
3578 if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) | |
3579 { | |
3580 player->PlaySound(SPEECH_52, 0); | |
3581 return; | |
3582 } | |
3583 break; | |
3584 case SPELL_EARTH_BLADES: | |
3585 a4 = 5 * projectileSprite->spell_level; | |
3586 attackElement = (DAMAGE_TYPE)player->GetSpellSchool(SPELL_EARTH_BLADES); | |
3587 uDamageAmount = _43AFE3_calc_spell_damage(39, projectileSprite->spell_level, projectileSprite->spell_skill, pMonster->sCurrentHP); | |
3588 if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) | |
3589 uDamageAmount >>= 1; | |
3590 IsAdditionalDamagePossible = false; | |
3591 if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) | |
3592 { | |
3593 player->PlaySound(SPEECH_52, 0); | |
3594 return; | |
3595 } | |
3596 break; | |
3597 case SPELL_EARTH_STUN: | |
3598 uDamageAmount = 0; | |
3599 attackElement = DMGT_PHISYCAL; | |
3600 hit_will_stun = 1; | |
3601 if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) | |
3602 { | |
3603 player->PlaySound(SPEECH_52, 0); | |
3604 return; | |
3605 } | |
3606 break; | |
3607 case SPELL_BOW_ARROW: | |
3608 attackElement = DMGT_PHISYCAL; | |
3609 uDamageAmount = player->CalculateRangedDamageTo(pMonster->word_000086_some_monster_id); | |
3610 if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) | |
3611 uDamageAmount /= 2; | |
3612 IsAdditionalDamagePossible = true; | |
2566 | 3613 if (projectileSprite->containing_item.uItemID != 0 && projectileSprite->containing_item.uSpecEnchantmentType == 3) //of carnage |
2497 | 3614 { |
3615 attackElement = DMGT_FIRE; | |
3616 } | |
3617 else if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) | |
3618 { | |
3619 player->PlaySound(SPEECH_52, 0); | |
3620 return; | |
3621 } | |
3622 break; | |
3623 | |
3624 default: | |
3625 attackElement = (DAMAGE_TYPE)player->GetSpellSchool(projectileSprite->spell_id); | |
3626 IsAdditionalDamagePossible = false; | |
3627 uDamageAmount = _43AFE3_calc_spell_damage(projectileSprite->spell_id, projectileSprite->spell_level, projectileSprite->spell_skill, pMonster->sCurrentHP); | |
3628 break; | |
3629 } | |
3630 } | |
3631 | |
3632 if (player->IsWeak()) | |
3633 uDamageAmount /= 2; | |
3634 if ( pMonster->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 ) | |
3635 uDamageAmount = 0; | |
3636 v61 = pMonster->CalcMagicalDamageToActor(attackElement, uDamageAmount); | |
3637 if ( !projectileSprite && player->IsUnarmed() && player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime > 0 ) | |
3638 { | |
3639 v61 += pMonster->CalcMagicalDamageToActor((DAMAGE_TYPE)8, player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uPower); | |
3640 } | |
3641 uDamageAmount = v61; | |
3642 if ( IsAdditionalDamagePossible ) | |
3643 { | |
3644 if ( projectileSprite ) | |
3645 { | |
2566 | 3646 a4 = projectileSprite->containing_item._439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing); |
2497 | 3647 if ( isLifeStealing && pMonster->sCurrentHP > 0 ) |
3648 { | |
3649 player->sHealth += v61 / 5; | |
3650 if ( player->sHealth > player->GetMaxHealth() ) | |
3651 player->sHealth = player->GetMaxHealth(); | |
3652 } | |
3653 uDamageAmount += pMonster->CalcMagicalDamageToActor(attackElement, a4); | |
3654 } | |
3655 else | |
3656 { | |
3657 for (int i = 0; i < 2; i++) | |
3658 { | |
3659 if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
3660 { | |
3661 ItemGen* item; | |
3662 if (i == 0) | |
3663 item = player->GetOffHandItem(); | |
3664 else | |
3665 item = player->GetMainHandItem(); | |
3666 a4 = item->_439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing); | |
3667 if ( isLifeStealing && pMonster->sCurrentHP > 0 ) | |
3668 { | |
3669 player->sHealth += v61 / 5; | |
3670 if ( player->sHealth > player->GetMaxHealth() ) | |
3671 player->sHealth = player->GetMaxHealth(); | |
3672 } | |
3673 uDamageAmount += pMonster->CalcMagicalDamageToActor(attackElement, a4); | |
3674 } | |
3675 } | |
3676 } | |
3677 } | |
3678 pMonster->sCurrentHP -= uDamageAmount; | |
3679 if ( uDamageAmount == 0 && !hit_will_stun ) | |
3680 { | |
3681 player->PlaySound(SPEECH_52, 0); | |
3682 return; | |
3683 } | |
3684 if ( pMonster->sCurrentHP > 0 ) | |
3685 { | |
3686 Actor::AI_Stun(uActorID_Monster, a1, 0); | |
3687 Actor::AggroSurroundingPeasants(uActorID_Monster, 1); | |
3688 if ( bShowDamage ) | |
3689 { | |
3690 if ( projectileSprite ) | |
3691 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[189], player->pName, pMonster->pActorName, uDamageAmount);// "%s shoots %s for %lu points" | |
3692 else | |
3693 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[164], player->pName, pMonster->pActorName, uDamageAmount);// "%s hits %s for %lu damage" | |
3694 ShowStatusBarString(pTmpBuf.data(), 2u); | |
3695 } | |
3696 } | |
3697 else | |
3698 { | |
3699 if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) | |
3700 { | |
2541 | 3701 if ( /*pRenderer->pRenderD3D &&*/ pEngine->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) |
2497 | 3702 { |
2541 | 3703 v33 = byte_4D864C && pEngine->uFlags & 0x80000 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; |
2497 | 3704 pDecalBuilder->AddBloodsplat((float)pMonster->vPosition.x, (float)pMonster->vPosition.y, (float)pMonster->vPosition.z, 1.0, 0.0, 0.0, (float)v33, 0, 0); |
3705 } | |
3706 } | |
3707 Actor::Die(uActorID_Monster); | |
3708 Actor::ApplyFineForKillingPeasant(uActorID_Monster); | |
3709 Actor::AggroSurroundingPeasants(uActorID_Monster, 1); | |
3710 if ( pMonster->pMonsterInfo.uExp ) | |
3711 pParty->GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); | |
3712 v40 = SPEECH_51; | |
3713 if ( rand() % 100 < 20 ) | |
3714 v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1; | |
3715 player->PlaySound((PlayerSpeech)v40, 0); | |
3716 if ( bShowDamage ) | |
3717 { | |
3718 pMonsterName = (char *)uDamageAmount; | |
3719 pPlayerName = player->pName; // "%s inflicts %lu points killing %s" | |
3720 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); | |
3721 ShowStatusBarString(pTmpBuf.data(), 2u); | |
3722 } | |
3723 } | |
3724 if ( pMonster->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].uExpireTime > 0 | |
3725 && uDamageAmount != 0 ) | |
3726 player->ReceiveDamage(uDamageAmount, attackElement); | |
3727 int knockbackValue = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; | |
3728 if ( (player->GetSpecialItemBonus(24) || hit_will_stun) && pMonster->DoesDmgTypeDoDamage(DMGT_EARTH) ) | |
3729 { | |
3730 extraRecoveryTime = 20; | |
3731 knockbackValue = 10; | |
3732 if ( !pParty->bTurnBasedModeOn ) | |
3733 extraRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * 42.66666666666666); | |
3734 pMonster->pMonsterInfo.uRecoveryTime += extraRecoveryTime; | |
3735 if ( bShowDamage ) | |
3736 { | |
3737 pMonsterName = player->pName; // "%s stuns %s" | |
3738 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[635], player->pName, pMonster); | |
3739 ShowStatusBarString(pTmpBuf.data(), 2u); | |
3740 } | |
3741 } | |
3742 if ( hit_will_paralyze && pMonster->CanAct() && pMonster->DoesDmgTypeDoDamage(DMGT_EARTH)) | |
3743 { | |
3744 v43 = player->GetActualSkillLevel(PLAYER_SKILL_MACE); | |
3745 v45 = SkillToMastery(v43); | |
3746 v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v43 & 0x3F)) * 0.033333335); | |
3747 pMonster->pActorBuffs[ACTOR_BUFF_PARALYZED].Apply(v46, v45, 0, 0, 0); | |
3748 if ( bShowDamage ) | |
3749 { | |
3750 pMonsterName = player->pName; // "%s paralyzes %s" | |
3751 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[636], player->pName, pMonster); | |
3752 ShowStatusBarString(pTmpBuf.data(), 2u); | |
3753 } | |
3754 } | |
3755 if ( knockbackValue > 10 ) | |
3756 knockbackValue = 10; | |
3757 if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
3758 { | |
3759 pVelocity->x = fixpoint_mul(knockbackValue, pVelocity->x); | |
3760 pVelocity->y = fixpoint_mul(knockbackValue, pVelocity->y); | |
3761 pVelocity->z = fixpoint_mul(knockbackValue, pVelocity->z); | |
3762 pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x); | |
3763 pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y); | |
3764 pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z); | |
3765 } | |
3766 Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster, 1, v61); | |
3767 } | |
3768 //----- (004BBF61) -------------------------------------------------------- | |
3769 void Actor::Arena_summon_actor( int monster_id, __int16 x, int y, int z ) | |
3770 { | |
3771 int v12; // ebx@7 | |
3772 int v13; // eax@8 | |
3773 __int16 v16; // [sp+10h] [bp-4h]@3 | |
3774 | |
3775 if (uNumActors < 500) | |
3776 { | |
3777 v16 = 0; | |
3778 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
3779 v16 = pIndoor->GetSector(x, y, z); | |
3780 pActors[uNumActors].Reset(); | |
3781 strcpy(pActors[uNumActors].pActorName, pMonsterStats->pInfos[monster_id].pName); | |
3782 pActors[uNumActors].sCurrentHP = LOWORD(pMonsterStats->pInfos[monster_id].uHP); | |
3783 memcpy(&pActors[uNumActors].pMonsterInfo, &pMonsterStats->pInfos[monster_id], 0x58u); | |
3784 pActors[uNumActors].word_000086_some_monster_id = monster_id; | |
3785 pActors[uNumActors].uActorRadius = pMonsterList->pMonsters[monster_id - 1].uMonsterRadius; | |
3786 pActors[uNumActors].uActorHeight = pMonsterList->pMonsters[monster_id - 1].uMonsterHeight; | |
3787 pActors[uNumActors].uMovementSpeed = pMonsterList->pMonsters[monster_id - 1].uMovementSpeed; | |
3788 pActors[uNumActors].vInitialPosition.x = x; | |
3789 pActors[uNumActors].vPosition.x = x; | |
3790 pActors[uNumActors].uAttributes |= ACTOR_AGGRESSOR; | |
3791 pActors[uNumActors].pMonsterInfo.uTreasureType = 0; | |
3792 pActors[uNumActors].pMonsterInfo.uTreasureLevel = 0; | |
3793 pActors[uNumActors].pMonsterInfo.uTreasureDiceSides = 0; | |
3794 pActors[uNumActors].pMonsterInfo.uTreasureDiceRolls = 0; | |
3795 pActors[uNumActors].pMonsterInfo.uTreasureDropChance = 0; | |
3796 pActors[uNumActors].vInitialPosition.y = y; | |
3797 pActors[uNumActors].vPosition.y = y; | |
3798 pActors[uNumActors].vInitialPosition.z = z; | |
3799 pActors[uNumActors].vPosition.z = z; | |
3800 pActors[uNumActors].uTetherDistance = 256; | |
3801 pActors[uNumActors].uSectorID = v16; | |
3802 pActors[uNumActors].uGroup = 1; | |
3803 pActors[uNumActors].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
3804 pActors[uNumActors].PrepareSprites(0); | |
3805 for ( int i = 0; i < 4; i++) | |
3806 pSoundList->LoadSound(pMonsterList->pMonsters[monster_id - 1].pSoundSampleIDs[i], 0); | |
3807 v12 = 0; | |
3808 do | |
3809 { | |
3810 v13 = pSoundList->LoadSound(v12 + word_4EE088_sound_ids[pMonsterStats->pInfos[monster_id].uSpell1ID], 1); | |
3811 v12++; | |
3812 } | |
3813 while ( v13 ); | |
3814 ++uNumActors; | |
3815 } | |
3816 } | |
3817 //----- (00426E10) -------------------------------------------------------- | |
3818 int stru319::which_player_to_attack(Actor *pActor) | |
3819 { | |
3820 signed int v2; // ebx@1 | |
3821 bool flag; // edi@37 | |
3822 int v22; // [sp+8h] [bp-140h]@3 | |
3823 int Victims_list[60]; // [sp+48h] [bp-100h]@48 | |
3824 int for_sex; // [sp+13Ch] [bp-Ch]@1 | |
3825 int for_race; // [sp+140h] [bp-8h]@1 | |
3826 int for_class; // [sp+144h] [bp-4h]@1 | |
3827 | |
3828 for_class = -1; | |
3829 for_race = -1; | |
3830 for_sex = -1; | |
3831 v2 = 0; | |
3832 if ( pActor->pMonsterInfo.uAttackPreference ) | |
3833 { | |
3834 for ( uint i = 0; i < 16; i++ ) | |
3835 { | |
3836 v22 = pActor->pMonsterInfo.uAttackPreference & (1 << i); | |
3837 if ( v22 ) | |
3838 { | |
3839 switch ( v22 ) | |
3840 { | |
3841 case 1: | |
3842 for_class = 0; | |
3843 break; | |
3844 case 2: | |
3845 for_class = 12; | |
3846 break; | |
3847 case 4: | |
3848 for_class = 16; | |
3849 break; | |
3850 case 8: | |
3851 for_class = 28; | |
3852 break; | |
3853 case 16: | |
3854 for_class = 24; | |
3855 break; | |
3856 case 32: | |
3857 for_class = 32; | |
3858 break; | |
3859 case 64: | |
3860 for_class = 20; | |
3861 break; | |
3862 case 128: | |
3863 for_class = 4; | |
3864 break; | |
3865 case 256: | |
3866 for_class = 8; | |
3867 break; | |
3868 case 512: | |
3869 for_sex = 0; | |
3870 break; | |
3871 case 1024: | |
3872 for_sex = 1; | |
3873 break; | |
3874 case 2048: | |
3875 for_race = 0; | |
3876 break; | |
3877 case 4096: | |
3878 for_race = 1; | |
3879 break; | |
3880 case 8192: | |
3881 for_race = 3; | |
3882 break; | |
3883 case 16384: | |
3884 for_race = 2; | |
3885 break; | |
3886 } | |
3887 v2 = 0; | |
3888 for ( uint j = 0; j < 4; ++j ) | |
3889 { | |
3890 flag = 0; | |
3891 if ( for_class != -1 && for_class == pPlayers[j + 1]->classType ) | |
3892 flag = true; | |
3893 if ( for_sex != -1 && for_sex == pPlayers[j + 1]->uSex ) | |
3894 flag = true; | |
3895 if ( for_race != -1 && for_race == pPlayers[j + 1]->GetRace() ) | |
3896 flag = true; | |
3897 if ( flag == true ) | |
3898 { | |
3899 if ( !(pPlayers[j + 1]->pConditions[Condition_Paralyzed] | pPlayers[j + 1]->pConditions[Condition_Unconcious] | |
3900 | pPlayers[j + 1]->pConditions[Condition_Dead] | pPlayers[j + 1]->pConditions[Condition_Pertified] | pPlayers[j + 1]->pConditions[Condition_Eradicated]) ) | |
3901 Victims_list[v2++] = j; | |
3902 } | |
3903 } | |
3904 } | |
3905 } | |
3906 if ( v2 ) | |
3907 return Victims_list[rand() % v2]; | |
3908 } | |
3909 for ( uint i = 0; i < 4; ++i ) | |
3910 { | |
3911 if ( !(pPlayers[i + 1]->pConditions[Condition_Paralyzed] | pPlayers[i + 1]->pConditions[Condition_Unconcious] | |
3912 | pPlayers[i + 1]->pConditions[Condition_Dead] | pPlayers[i + 1]->pConditions[Condition_Pertified] | pPlayers[i + 1]->pConditions[Condition_Eradicated]) ) | |
3913 Victims_list[v2++] = i; | |
3914 } | |
3915 if ( v2 ) | |
3916 return Victims_list[rand() % v2]; | |
3917 else | |
3918 return 0; | |
3919 } | |
3920 //----- (00427546) -------------------------------------------------------- | |
3921 int stru319::_427546(int a2) | |
3922 { | |
3923 int result; // eax@2 | |
3924 | |
3925 if (a2 >= 0) | |
3926 { | |
3927 if (a2 >= 1) | |
3928 result = (a2 >= 2) + 2; | |
3929 else | |
3930 result = 1; | |
3931 } | |
3932 else | |
3933 { | |
3934 result = 0; | |
3935 } | |
3936 return result; | |
3937 } | |
3938 //----- (0042F184) -------------------------------------------------------- | |
3939 int stru319::FindClosestActor(int pick_depth, int a3, int a4) | |
3940 { | |
3941 int v4; // edi@1 | |
3942 stru319 *v5; // esi@1 | |
3943 int v6; // eax@2 | |
3944 int v7; // eax@4 | |
3945 // int result; // eax@5 | |
3946 // int *v9; // edx@8 | |
3947 // signed int v10; // ebx@10 | |
3948 // int v11; // edi@11 | |
3949 //Actor *v12; // esi@12 | |
3950 //unsigned __int16 v13; // ax@12 | |
3951 // int v14; // eax@22 | |
3952 //char v15; // zf@30 | |
3953 // int v16; // esi@32 | |
3954 // int v17; // ecx@34 | |
3955 // stru319 *v18; // eax@39 | |
3956 // int v19; // edx@39 | |
3957 // int v20; // ecx@41 | |
3958 // unsigned __int16 v21; // ax@42 | |
3959 // unsigned int v22; // [sp+8h] [bp-24h]@11 | |
3960 //unsigned int v23; // [sp+Ch] [bp-20h]@7 | |
3961 stru319 *v24; // [sp+10h] [bp-1Ch]@1 | |
3962 // unsigned int v25; // [sp+14h] [bp-18h]@8 | |
3963 // int *v26; // [sp+18h] [bp-14h]@8 | |
3964 // int v27; // [sp+1Ch] [bp-10h]@10 | |
3965 // int *v28; // [sp+20h] [bp-Ch]@10 | |
3966 //unsigned int v29; // [sp+24h] [bp-8h]@7 | |
3967 // int v30; // [sp+28h] [bp-4h]@6 | |
3968 // int i; // [sp+38h] [bp+Ch]@33 | |
3969 // signed int v32; // [sp+3Ch] [bp+10h]@32 | |
3970 | |
3971 v4 = 0; | |
3972 v5 = this; | |
3973 v24 = this; | |
3974 //if ( pRenderer->pRenderD3D ) | |
3975 { | |
3976 v6 = a3 != 0; | |
3977 if (a4) | |
3978 LOBYTE(v6) = v6 | 8; | |
2541 | 3979 v7 = pEngine->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1); |
2497 | 3980 if (v7 != -1) |
3981 return (unsigned __int16)v7; | |
3982 else return 0; | |
3983 } | |
3984 /*else // software impl | |
3985 { | |
3986 v30 = 0; | |
3987 if ( pRenderer->pActiveZBuffer ) | |
3988 { | |
3989 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) | |
3990 { | |
3991 v9 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; | |
3992 v26 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; | |
3993 for ( v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y; v25; --v25 ) | |
3994 { | |
3995 if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X ) | |
3996 { | |
3997 v28 = v9; | |
3998 v10 = v4; | |
3999 for ( v27 = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X; v27; --v27 ) | |
4000 { | |
4001 v22 = *v28; | |
4002 v11 = *v28 & 0xFFFF; | |
4003 if (PID_TYPE(v11) == OBJECT_Actor) | |
4004 { | |
4005 if ( pActors[PID_ID(v11)].uAIState != Dead ) | |
4006 { | |
4007 if ( pActors[PID_ID(v11)].uAIState != Dying && pActors[PID_ID(v11)].uAIState != Removed | |
4008 && pActors[PID_ID(v11)].uAIState != Summoned && pActors[PID_ID(v11)].uAIState != Disabled | |
4009 && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) ) | |
4010 { | |
4011 if ( (!a4 || MonsterStats::BelongsToSupertype(pActors[PID_ID(v11)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) | |
4012 && v22 <= pick_depth << 16 ) | |
4013 { | |
4014 v14 = 0; | |
4015 if ( v10 > 0 ) | |
4016 { | |
4017 for ( v14; v14 < v30; ++v14 ) | |
4018 { | |
4019 if ( dword_50BDA0[v14] == v11 ) | |
4020 break; | |
4021 } | |
4022 } | |
4023 if ( v14 == v30 && v10 < 100 ) | |
4024 { | |
4025 ++v30; | |
4026 dword_50BC10[v10] = v22; | |
4027 dword_50BDA0[v10] = v11; | |
4028 ++v10; | |
4029 } | |
4030 } | |
4031 } | |
4032 } | |
4033 } | |
4034 ++v28; | |
4035 } | |
4036 v4 = v30; | |
4037 v5 = v24; | |
4038 } | |
4039 v9 = v26 + 640; | |
4040 v26 += 640; | |
4041 } | |
4042 } | |
4043 if ( v4 > 0 ) | |
4044 { | |
4045 v16 = (int)dword_50BC10.data(); | |
4046 for ( v32 = 1; v32 - 1 < v4; ++v32 ) | |
4047 { | |
4048 for ( i = v32; i < v4; ++i ) | |
4049 { | |
4050 v17 = dword_50BC10[i]; | |
4051 if ( dword_50BC10[i] < *(int *)v16 ) | |
4052 { | |
4053 dword_50BC10[i] = *(int *)v16; | |
4054 *(int *)v16 = v17; | |
4055 } | |
4056 } | |
4057 v16 += 4; | |
4058 } | |
4059 v5 = v24; | |
4060 if ( v4 > 0 ) | |
4061 { | |
4062 v18 = v24; | |
4063 for ( v19 = v4; v19; --v19 ) | |
4064 { | |
4065 *(int *)&v18->field_0 = (*(int *)&v18[(char *)dword_50BC10.data() - (char *)v24].field_0 >> 3) & 0x1FFF; | |
4066 v18 += 4; | |
4067 } | |
4068 } | |
4069 } | |
4070 v20 = 0; | |
4071 for ( *(int *)&v5[2000].field_0 = v4; v20 < v4; ++v20 ) | |
4072 { | |
4073 v21 = pActors[*(int *)&v5[4 * v20].field_0].uAIState; | |
4074 if ( v21 != 4 && v21 != 5 ) | |
4075 break; | |
4076 } | |
4077 if ( v20 != v4 ) | |
4078 { | |
4079 result = 8 * *(int *)&v5[4 * v20].field_0; | |
4080 LOBYTE(result) = result | 3; | |
4081 return result; | |
4082 } | |
4083 } | |
4084 } | |
4085 return 0;*/ | |
4086 } | |
4087 | |
4088 //----- (0042F4DA) -------------------------------------------------------- | |
4089 bool CheckActors_proximity() | |
4090 { | |
4091 signed int distance; // edi@1 | |
4092 int for_x; // ebx@5 | |
4093 int for_y; // [sp+Ch] [bp-10h]@5 | |
4094 int for_z; // [sp+10h] [bp-Ch]@5 | |
4095 | |
4096 | |
4097 distance = 5120; | |
4098 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
4099 distance = 2560; | |
4100 | |
4101 if ( (signed int)uNumActors <= 0 ) | |
4102 return false; | |
4103 for ( uint i = 0; i < (signed int)uNumActors; ++i ) | |
4104 { | |
4105 for_x = abs(pActors[i].vInitialPosition.x - pParty->vPosition.x); | |
4106 for_y = abs(pActors[i].vInitialPosition.y - pParty->vPosition.y); | |
4107 for_z = abs(pActors[i].vInitialPosition.z - pParty->vPosition.z); | |
4108 if ( int_get_vector_length(for_x, for_y, for_z) < distance ) | |
4109 { | |
4110 if ( pActors[i].uAIState != Dead ) | |
4111 { | |
4112 if ( pActors[i].uAIState != Dying && pActors[i].uAIState != Removed | |
4113 && pActors[i].uAIState != Disabled && pActors[i].uAIState != Summoned | |
4114 && (pActors[i].ActorEnemy() || pActors[i].GetActorsRelation(0) ) ) | |
4115 return true; | |
4116 } | |
4117 } | |
4118 } | |
4119 return false; | |
4120 } | |
4121 | |
4122 | |
4123 //----- (00426A5A) -------------------------------------------------------- | |
4124 void Actor::LootActor() | |
4125 { | |
4126 signed int v2; // edi@1 | |
4127 unsigned __int8 v7; // al@30 | |
4128 char *v9; // [sp-4h] [bp-3Ch]@10 | |
4129 char *v10; // [sp-4h] [bp-3Ch]@31 | |
4130 char *v11; // [sp-4h] [bp-3Ch]@38 | |
4131 ItemGen Dst; // [sp+Ch] [bp-2Ch]@1 | |
4132 bool itemFound; // [sp+30h] [bp-8h]@1 | |
4133 int v14; // [sp+34h] [bp-4h]@1 | |
4134 | |
4135 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
4136 Dst.Reset(); | |
4137 v2 = 0; | |
4138 itemFound = false; | |
4139 v14 = 0; | |
4140 if ( !ActorHasItem() ) | |
4141 { | |
4142 for (uchar i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++ ) | |
4143 v14 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1; | |
4144 if ( v14 ) | |
4145 { | |
4146 pParty->PartyFindsGold(v14, 0); | |
4147 viewparams->bRedrawGameUI = 1; | |
4148 } | |
4149 } | |
4150 else | |
4151 { | |
4152 if ( this->ActorHasItems[3].uItemID != 0 && this->ActorHasItems[3].GetItemEquipType() == EQUIP_GOLD ) | |
4153 { | |
4154 v14 = this->ActorHasItems[3].uSpecEnchantmentType; | |
4155 this->ActorHasItems[3].Reset(); | |
4156 if ( v14 ) | |
4157 { | |
4158 pParty->PartyFindsGold(v14, 0); | |
4159 viewparams->bRedrawGameUI = 1; | |
4160 } | |
4161 } | |
4162 } | |
4163 if ( this->uCarriedItemID ) | |
4164 { | |
4165 Dst.Reset(); | |
4166 Dst.uItemID = this->uCarriedItemID; | |
4167 v9 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; | |
4168 if ( v14 ) | |
4169 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v9); | |
4170 else | |
4171 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v9); | |
4172 ShowStatusBarString(pTmpBuf2.data(), 2); | |
4173 if ( Dst.GetItemEquipType() == 12 ) | |
4174 { | |
4175 Dst.uNumCharges = rand() % 6 + Dst.GetDamageMod() + 1; | |
4176 Dst.uMaxCharges = Dst.uNumCharges; | |
4177 } | |
4178 if ( pItemsTable->pItems[Dst.uItemID].uEquipType == 14 && Dst.uItemID != 220 ) | |
4179 Dst.uEnchantmentType = 2 * rand() % 4 + 2; | |
4180 pItemsTable->SetSpecialBonus(&Dst); | |
4181 if ( !pParty->AddItemToParty(&Dst) ) | |
4182 pParty->SetHoldingItem(&Dst); | |
4183 this->uCarriedItemID = 0; | |
4184 if ( this->ActorHasItems[0].uItemID ) | |
4185 { | |
4186 if ( !pParty->AddItemToParty(this->ActorHasItems) ) | |
4187 { | |
4188 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
4189 pParty->SetHoldingItem(this->ActorHasItems); | |
4190 } | |
4191 this->ActorHasItems[0].Reset(); | |
4192 } | |
4193 if ( this->ActorHasItems[1].uItemID ) | |
4194 { | |
4195 if ( !pParty->AddItemToParty(&this->ActorHasItems[1]) ) | |
4196 { | |
4197 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
4198 pParty->SetHoldingItem(&this->ActorHasItems[1]); | |
4199 } | |
4200 this->ActorHasItems[1].Reset(); | |
4201 } | |
4202 this->Remove(); | |
4203 return; | |
4204 } | |
4205 if ( this->ActorHasItem() ) | |
4206 { | |
4207 if ( this->ActorHasItems[3].uItemID ) | |
4208 { | |
4209 memcpy(&Dst, &this->ActorHasItems[3], sizeof(Dst)); | |
4210 this->ActorHasItems[3].Reset(); | |
4211 //v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; | |
4212 if ( v14 ) | |
4213 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, pItemsTable->pItems[Dst.uItemID].pUnidentifiedName); | |
4214 else | |
4215 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[Dst.uItemID].pUnidentifiedName); | |
4216 ShowStatusBarString(pTmpBuf2.data(), 2); | |
4217 if ( !pParty->AddItemToParty(&Dst) ) | |
4218 pParty->SetHoldingItem(&Dst); | |
4219 itemFound = true; | |
4220 } | |
4221 } | |
4222 else | |
4223 { | |
4224 if ( rand() % 100 < this->pMonsterInfo.uTreasureDropChance && (v7 = this->pMonsterInfo.uTreasureLevel) != 0 ) | |
4225 { | |
4226 pItemsTable->GenerateItem(v7, this->pMonsterInfo.uTreasureType, &Dst); | |
4227 v10 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; | |
4228 if ( v14 ) | |
4229 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v10);//Вы нашли ^I[%d] золот^L[ой;ых;ых] и предмет (%s)! | |
4230 else | |
4231 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v10);//Вы нашли ^Pv[%s]! | |
4232 ShowStatusBarString(pTmpBuf2.data(), 2); | |
4233 if ( !pParty->AddItemToParty(&Dst) ) | |
4234 pParty->SetHoldingItem(&Dst); | |
4235 itemFound = true; | |
4236 } | |
4237 } | |
4238 if ( this->ActorHasItems[0].uItemID ) | |
4239 { | |
4240 if ( !pParty->AddItemToParty(this->ActorHasItems) ) | |
4241 { | |
4242 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
4243 pParty->SetHoldingItem(this->ActorHasItems); | |
4244 itemFound = true; | |
4245 } | |
4246 this->ActorHasItems[0].Reset(); | |
4247 } | |
4248 if ( this->ActorHasItems[1].uItemID ) | |
4249 { | |
4250 if ( !pParty->AddItemToParty(&this->ActorHasItems[1]) ) | |
4251 { | |
4252 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
4253 pParty->SetHoldingItem(&this->ActorHasItems[1]); | |
4254 itemFound = true; | |
4255 } | |
4256 this->ActorHasItems[1].Reset(); | |
4257 } | |
4258 if ( !itemFound || rand() % 100 < 90 )//for repeatedly get gold and item | |
4259 this->Remove(); | |
4260 } | |
4261 | |
4262 | |
4263 //----- (00427102) -------------------------------------------------------- | |
4264 bool Actor::_427102_IsOkToCastSpell( signed int a2 ) | |
4265 { | |
4266 switch(a2) | |
4267 { | |
4268 case SPELL_BODY_POWER_CURE: | |
4269 { | |
4270 if ( this->sCurrentHP >= (signed int)this->pMonsterInfo.uHP ) | |
4271 return false; | |
4272 return true; | |
4273 } | |
4274 case SPELL_LIGHT_DISPEL_MAGIC: | |
4275 { | |
4276 for (int i = 0; i < 20; i++) | |
4277 { | |
4278 if (pParty->pPartyBuffs[i].uExpireTime > 0) | |
4279 return true; | |
4280 } | |
4281 for ( int i = 1; i <= 4; i++ ) | |
4282 { | |
4283 for ( int j = 0; j < 22; j++ ) | |
4284 { | |
4285 if (pPlayers[i]->pPlayerBuffs[j].uExpireTime > 0) | |
4286 return true; | |
4287 } | |
4288 } | |
4289 return false; | |
4290 } | |
4291 case SPELL_LIGHT_DAY_OF_PROTECTION: | |
4292 { | |
4293 return this->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].uExpireTime <= 0; | |
4294 break; | |
4295 } | |
4296 case SPELL_LIGHT_HOUR_OF_POWER: | |
4297 { | |
4298 return this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime <= 0; | |
4299 break; | |
4300 } | |
4301 case SPELL_DARK_PAIN_REFLECTION: | |
4302 { | |
4303 return this->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].uExpireTime <= 0; | |
4304 break; | |
4305 } | |
4306 case SPELL_BODY_HAMMERHANDS: | |
4307 { | |
4308 return this->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].uExpireTime <= 0; | |
4309 break; | |
4310 } | |
4311 case SPELL_FIRE_HASTE: | |
4312 { | |
4313 return this->pActorBuffs[ACTOR_BUFF_HASTE].uExpireTime <= 0; | |
4314 break; | |
4315 } | |
4316 case SPELL_AIR_SHIELD: | |
4317 { | |
4318 return this->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime <= 0; | |
4319 break; | |
4320 } | |
4321 case SPELL_EARTH_STONESKIN: | |
4322 { | |
4323 return this->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime <= 0; | |
4324 break; | |
4325 } | |
4326 case SPELL_SPIRIT_BLESS: | |
4327 { | |
4328 return this->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime <= 0; | |
4329 break; | |
4330 } | |
4331 case SPELL_SPIRIT_FATE: | |
4332 { | |
4333 return this->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime <= 0; | |
4334 break; | |
4335 } | |
4336 case SPELL_SPIRIT_HEROISM: | |
4337 { | |
4338 return this->pActorBuffs[ACTOR_BUFF_HEROISM].uExpireTime <= 0; | |
4339 break; | |
4340 } | |
4341 default: | |
4342 return true; | |
4343 } | |
4344 } | |
4345 | |
4346 | |
4347 //----- (0042704B) -------------------------------------------------------- | |
4348 ABILITY_INDEX Actor::special_ability_use_check( int a2 ) | |
4349 { | |
4350 signed int okToCastSpell1; // ebx@5 | |
4351 signed int okToCastSpell2; // edi@5 | |
4352 | |
4353 if ( this->pMonsterInfo.uSpecialAbilityType == 2 | |
4354 && this->pMonsterInfo.uSpecialAbilityDamageDiceBonus < 3 | |
4355 && rand() % 100 < 5 ) | |
4356 this->SummonMinion(a2); | |
4357 okToCastSpell1 = this->_427102_IsOkToCastSpell(this->pMonsterInfo.uSpell1ID); | |
4358 okToCastSpell2 = this->_427102_IsOkToCastSpell(this->pMonsterInfo.uSpell2ID); | |
4359 if ( okToCastSpell1 && this->pMonsterInfo.uSpell1UseChance && rand() % 100 < this->pMonsterInfo.uSpell1UseChance ) | |
4360 return ABILITY_SPELL1; | |
4361 if ( okToCastSpell2 && this->pMonsterInfo.uSpell2UseChance && rand() % 100 < this->pMonsterInfo.uSpell2UseChance ) | |
4362 return ABILITY_SPELL2; | |
4363 if (this->pMonsterInfo.uAttack2Chance && rand() % 100 < this->pMonsterInfo.uAttack2Chance) | |
4364 return ABILITY_ATTACK2; | |
4365 return ABILITY_ATTACK1; | |
4366 } | |
4367 | |
4368 | |
4369 | |
4370 //----- (004273BB) -------------------------------------------------------- | |
4371 bool Actor::_4273BB_DoesHitOtherActor( Actor *defender, int a3, int a4 ) | |
4372 { | |
4373 signed int v6; // ebx@1 | |
4374 signed int v7; // esi@1 | |
4375 int armorSum; // ebx@10 | |
4376 signed int a2a; // [sp+18h] [bp+Ch]@1 | |
4377 | |
4378 v6 = defender->pMonsterInfo.uAC; | |
4379 v7 = 0; | |
4380 a2a = 0; | |
4381 if ( defender->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) | |
4382 v6 /= 2; | |
4383 if ( defender->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) | |
4384 v7 = defender->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; | |
4385 if ( defender->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime > 0 && defender->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower > v7 ) | |
4386 v7 = defender->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower; | |
4387 armorSum = v7 + v6; | |
4388 if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) | |
4389 a2a = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; | |
4390 if ( this->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime > 0 && this->pActorBuffs[ACTOR_BUFF_BLESS].uPower > a2a ) | |
4391 a2a = this->pActorBuffs[ACTOR_BUFF_BLESS].uPower; | |
4392 if ( this->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) | |
4393 { | |
4394 a2a += this->pActorBuffs[ACTOR_BUFF_FATE].uPower; | |
4395 this->pActorBuffs[ACTOR_BUFF_FATE].Reset(); | |
4396 } | |
4397 return rand() % (armorSum + 2 * this->pMonsterInfo.uLevel + 10) + a2a + 1 > armorSum + 5; | |
4398 } | |
4399 | |
4400 //----- (004274AD) -------------------------------------------------------- | |
4401 bool Actor::ActorHitOrMiss(Player *pPlayer) | |
4402 { | |
4403 signed int v3; // edi@1 | |
4404 signed int v4; // esi@8 | |
4405 int v5; // esi@8 | |
4406 | |
4407 v3 = 0; | |
4408 if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) | |
4409 v3 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; | |
4410 if ( this->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime > 0 && this->pActorBuffs[ACTOR_BUFF_BLESS].uPower > v3 ) | |
4411 v3 = this->pActorBuffs[ACTOR_BUFF_BLESS].uPower; | |
4412 if ( this->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) | |
4413 { | |
4414 v3 += this->pActorBuffs[ACTOR_BUFF_FATE].uPower; | |
4415 this->pActorBuffs[ACTOR_BUFF_FATE].Reset(); | |
4416 } | |
4417 v4 = pPlayer->GetActualAC() + 2 * this->pMonsterInfo.uLevel + 10; | |
4418 v5 = rand() % v4 + 1; | |
4419 return (v3 + v5 > pPlayer->GetActualAC() + 5); | |
4420 } | |
4421 | |
4422 | |
4423 //----- (0042756B) -------------------------------------------------------- | |
4424 int Actor::CalcMagicalDamageToActor(DAMAGE_TYPE dmgType, signed int incomingDmg) | |
4425 { | |
4426 int v4; // edx@1 | |
4427 int v5; // ecx@1 | |
4428 signed int v6; // eax@4 | |
4429 signed int result; // eax@17 | |
4430 signed int v8; // esi@18 | |
4431 | |
4432 v4 = 0; | |
4433 v5 = 0; | |
4434 if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) | |
4435 v5 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; | |
4436 switch ( dmgType ) | |
4437 { | |
4438 case DMGT_FIRE: | |
4439 v6 = this->pMonsterInfo.uResFire; | |
4440 v4 = v5; | |
4441 break; | |
4442 case DMGT_ELECTR: | |
4443 v6 = this->pMonsterInfo.uResAir; | |
4444 v4 = v5; | |
4445 break; | |
4446 case DMGT_COLD: | |
4447 v6 = this->pMonsterInfo.uResWater; | |
4448 v4 = v5; | |
4449 break; | |
4450 case DMGT_EARTH: | |
4451 v6 = this->pMonsterInfo.uResEarth; | |
4452 v4 = v5; | |
4453 break; | |
4454 case DMGT_PHISYCAL: | |
4455 v6 = this->pMonsterInfo.uResPhysical; | |
4456 break; | |
4457 case DMGT_SPIRIT: | |
4458 v6 = this->pMonsterInfo.uResSpirit; | |
4459 break; | |
4460 case DMGT_MIND: | |
4461 v6 = this->pMonsterInfo.uResMind; | |
4462 v4 = v5; | |
4463 break; | |
4464 case DMGT_BODY: | |
4465 v6 = this->pMonsterInfo.uResBody; | |
4466 v4 = v5; | |
4467 break; | |
4468 case DMGT_LIGHT: | |
4469 v6 = this->pMonsterInfo.uResLight; | |
4470 break; | |
4471 case DMGT_DARK: | |
4472 v6 = this->pMonsterInfo.uResDark; | |
4473 break; | |
4474 default: | |
4475 v6 = 0; | |
4476 break; | |
4477 } | |
4478 if ( v6 < 200 ) | |
4479 { | |
4480 v8 = v4 + v6 + 30; | |
4481 for (int i = 0; i < 4; i++) | |
4482 { | |
4483 if ( rand() % v8 < 30 ) | |
4484 break; | |
4485 incomingDmg /= 2; | |
4486 } | |
4487 result = incomingDmg; | |
4488 } | |
4489 else | |
4490 result = 0; | |
4491 return result; | |
4492 } | |
4493 | |
4494 //----- (00427662) -------------------------------------------------------- | |
4495 bool Actor::DoesDmgTypeDoDamage(DAMAGE_TYPE uType) | |
4496 { | |
4497 signed int resist; // esi@2 | |
4498 bool result; // eax@13 | |
4499 | |
4500 switch ( uType ) | |
4501 { | |
4502 case 0: | |
4503 resist = this->pMonsterInfo.uResFire; | |
4504 break; | |
4505 case 1: | |
4506 resist = this->pMonsterInfo.uResAir; | |
4507 break; | |
4508 case 2: | |
4509 resist = this->pMonsterInfo.uResWater; | |
4510 break; | |
4511 case 3: | |
4512 resist = this->pMonsterInfo.uResEarth; | |
4513 break; | |
4514 case 4: | |
4515 resist = this->pMonsterInfo.uResPhysical; | |
4516 break; | |
4517 case 6: | |
4518 resist = this->pMonsterInfo.uResSpirit; | |
4519 break; | |
4520 case 7: | |
4521 resist = this->pMonsterInfo.uResMind; | |
4522 case 8: | |
4523 resist = this->pMonsterInfo.uResBody; | |
4524 break; | |
4525 case 9: | |
4526 resist = this->pMonsterInfo.uResLight; | |
4527 break; | |
4528 case 10: | |
4529 resist = this->pMonsterInfo.uResDark; | |
4530 break; | |
4531 default: | |
4532 return 1; | |
4533 } | |
4534 if ( resist < 200 ) | |
4535 result = rand() % ((this->pMonsterInfo.uLevel >> 2) + resist + 30) < 30; | |
4536 else | |
4537 result = 0; | |
4538 return result; | |
4539 } | |
4540 | |
4541 //----- (00448A98) -------------------------------------------------------- | |
4542 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle) | |
4543 { | |
4544 if ( uGroupID ) | |
4545 { | |
4546 if ( bToggle ) | |
4547 { | |
4548 for ( uint i = 0; i < (unsigned int)uNumActors; ++i ) | |
4549 { | |
4550 if ( pActors[i].uGroup == uGroupID ) | |
4551 { | |
4552 pActors[i].uAttributes |= uFlag; | |
4553 if ( uFlag == 0x10000 ) | |
4554 { | |
4555 pActors[i].uAIState = Disabled; | |
4556 pActors[i].UpdateAnimation(); | |
4557 } | |
4558 } | |
4559 } | |
4560 } | |
4561 else | |
4562 { | |
4563 for ( uint i = 0; i < (unsigned int)uNumActors; ++i ) | |
4564 { | |
4565 if ( pActors[i].uGroup == uGroupID ) | |
4566 { | |
4567 if ( uFlag == 0x10000 ) | |
4568 { | |
4569 if ( pActors[i].uAIState != Dead ) | |
4570 { | |
4571 if ( pActors[i].uAIState != 4 && pActors[i].uAIState != 11 ) | |
4572 pActors[i].uAIState = Standing; | |
4573 } | |
4574 } | |
4575 LODWORD(pActors[i].uAttributes) &= ~uFlag; | |
4576 } | |
4577 } | |
4578 } | |
4579 } | |
4580 } | |
4581 | |
4582 //----- (004014E6) -------------------------------------------------------- | |
4583 void Actor::MakeActorAIList_ODM() | |
4584 { | |
4585 int v1; // eax@4 | |
4586 unsigned int v7; // ST20_4@10 | |
4587 int distance; // edi@10 | |
4588 int v10; // ebx@14 | |
4589 int v21; // [sp+Ch] [bp-14h]@4 | |
4590 int v22; // [sp+10h] [bp-10h]@4 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2543
diff
changeset
|
4591 |
2497 | 4592 pParty->uFlags &= 0xFFFFFFCF;//~0x30 |
4593 | |
4594 ai_arrays_size = 0; | |
4595 for (uint i = 0; i < uNumActors; ++i) | |
4596 { | |
4597 Actor* actor = &pActors[i]; | |
4598 | |
4599 actor->ResetAlive();//~0x400 | |
4600 if (!actor->CanAct()) | |
4601 { | |
4602 actor->ResetActive(); | |
4603 continue; | |
4604 } | |
4605 | |
4606 v22 = abs(pParty->vPosition.z - actor->vPosition.z); | |
4607 v21 = abs(pParty->vPosition.y - actor->vPosition.y); | |
4608 v1 = abs(pParty->vPosition.x - actor->vPosition.x); | |
4609 v7 = int_get_vector_length(v22, v21, v1); | |
4610 distance = v7 - actor->uActorRadius; | |
4611 if ( distance < 0 ) | |
4612 distance = 0; | |
4613 | |
4614 if (distance < 5632) | |
4615 { | |
4616 actor->ResetHostile(); | |
4617 if ( actor->ActorEnemy() || actor->GetActorsRelation(0) ) | |
4618 { | |
4619 //v11 = (pParty->uFlags & 0x10) == 0; | |
4620 actor->uAttributes |= ACTOR_HOSTILE; | |
4621 if (distance < 5120 ) | |
4622 pParty->SetYellowAlert(); | |
4623 if (distance < 307) | |
4624 pParty->SetRedAlert(); | |
4625 } | |
4626 actor->uAttributes |= ACTOR_ACTIVE; | |
4627 ai_near_actors_distances[ai_arrays_size] = distance; | |
4628 ai_near_actors_ids[ai_arrays_size++] = i; | |
4629 } | |
4630 else | |
4631 actor->ResetActive(); | |
4632 } | |
4633 | |
4634 /* | |
4635 result = v27; | |
4636 if ( v27 > 0 ) | |
4637 { | |
4638 v14 = 0; | |
4639 v15 = 1; | |
4640 v26 = 1; | |
4641 do | |
4642 { | |
4643 while ( 1 ) | |
4644 { | |
4645 v24 = v15; | |
4646 if ( v15 >= result ) | |
4647 break; | |
4648 v16 = ai_near_actors_distances[v14]; | |
4649 if ( v16 > ai_near_actors_distances[v15] ) | |
4650 { | |
4651 v17 = &ai_near_actors_ids[v15]; | |
4652 v18 = ai_near_actors_ids[v14]; | |
4653 ai_near_actors_ids[v14] = *v17; | |
4654 *v17 = v18; | |
4655 v15 = v24; | |
4656 ai_near_actors_distances[v14] = ai_near_actors_distances[v24]; | |
4657 ai_near_actors_distances[v24] = v16; | |
4658 } | |
4659 result = v27; | |
4660 ++v15; | |
4661 } | |
4662 ++v14; | |
4663 v15 = v26 + 1; | |
4664 v26 = v15; | |
4665 } | |
4666 while ( v15 - 1 < result ); | |
4667 }*/ | |
4668 | |
4669 for (uint i = 0; i < ai_arrays_size; ++i) | |
4670 for (uint j = 0; j < i; ++j) | |
4671 if (ai_near_actors_distances[j] > ai_near_actors_distances[i]) | |
4672 { | |
4673 int tmp = ai_near_actors_distances[j]; | |
4674 ai_near_actors_distances[j] = ai_near_actors_distances[i]; | |
4675 ai_near_actors_distances[i] = tmp; | |
4676 | |
4677 tmp = ai_near_actors_ids[j]; | |
4678 ai_near_actors_ids[j] = ai_near_actors_ids[i]; | |
4679 ai_near_actors_ids[i] = tmp; | |
4680 } | |
4681 | |
4682 | |
4683 if (ai_arrays_size > 30) | |
4684 ai_arrays_size = 30; | |
4685 | |
4686 for (uint i = 0; i < ai_arrays_size; ++i) | |
4687 pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_ALIVE;//0x400 | |
4688 } | |
4689 | |
4690 //----- (004016FA) -------------------------------------------------------- | |
4691 int Actor::MakeActorAIList_BLV() | |
4692 { | |
4693 int v1; // eax@4 | |
4694 int distance; // edi@10 | |
4695 int v13; // edx@24 | |
4696 int v15; // ebx@26 | |
4697 unsigned int v17; // esi@27 | |
4698 int v18; // ecx@31 | |
4699 signed int v19; // edi@31 | |
4700 signed int v25; // eax@40 | |
4701 int j; // edi@45 | |
4702 int v30; // eax@48 | |
4703 int v37; // [sp+Ch] [bp-18h]@1 | |
4704 int v38; // [sp+10h] [bp-14h]@4 | |
4705 int v39; // [sp+14h] [bp-10h]@4 | |
4706 int i; // [sp+18h] [bp-Ch]@31 | |
4707 uint v45; // [sp+20h] [bp-4h]@1 | |
4708 | |
4709 // __debugbreak(); // refactor for blv ai | |
4710 pParty->uFlags &= 0xFFFFFFCF;//~0x30 | |
4711 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
4712 v45 = 0; | |
4713 for ( uint i = 0; i < (signed int)uNumActors; ++i ) | |
4714 { | |
4715 pActors[i].ResetAlive();//~0x0400 | |
4716 if ( !pActors[i].CanAct() ) | |
4717 { | |
4718 pActors[i].ResetActive(); | |
4719 continue; | |
4720 } | |
4721 v1 = abs(pParty->vPosition.x - pActors[i].vPosition.x); | |
4722 v38 = abs(pParty->vPosition.y - pActors[i].vPosition.y); | |
4723 v39 = abs(pParty->vPosition.z - pActors[i].vPosition.z); | |
4724 | |
4725 distance = int_get_vector_length(v39, v38, v1) - pActors[i].uActorRadius; | |
4726 if ( distance < 0 ) | |
4727 distance = 0; | |
4728 if ( distance < 10240 ) | |
4729 { | |
4730 pActors[i].ResetHostile();//~0x01000000 | |
4731 if ( pActors[i].ActorEnemy() || pActors[i].GetActorsRelation(0) ) | |
4732 { | |
4733 pActors[i].uAttributes |= ACTOR_HOSTILE; | |
4734 if ( !(pParty->uFlags & 0x10) && (double)distance < 307.2 ) | |
4735 pParty->SetRedAlert(); | |
4736 if ( !(pParty->uFlags & 0x20) && distance < 5120 ) | |
4737 pParty->SetYellowAlert(); | |
4738 } | |
4739 ai_near_actors_distances[v45] = distance; | |
4740 ai_near_actors_ids[v45] = i; | |
4741 v45++; | |
4742 } | |
4743 else | |
4744 pActors[i].ResetActive(); | |
4745 } | |
4746 v13 = 0; | |
4747 if ( v45 > 0 ) | |
4748 { | |
4749 for ( uint i = 1; i < v45; i++ ) | |
4750 { | |
4751 for ( uint j = 1; j < v45; ++j ) | |
4752 { | |
4753 v15 = ai_near_actors_distances[v13]; | |
4754 if ( ai_near_actors_distances[v13] > ai_near_actors_distances[j] ) | |
4755 { | |
4756 v17 = ai_near_actors_ids[v13]; | |
4757 ai_near_actors_ids[v13] = ai_near_actors_ids[j]; | |
4758 ai_near_actors_ids[j] = v17; | |
4759 ai_near_actors_distances[v13] = ai_near_actors_distances[j]; | |
4760 ai_near_actors_distances[j] = v15; | |
4761 } | |
4762 } | |
4763 ++v13; | |
4764 } | |
4765 } | |
4766 v18 = 0; | |
4767 v19 = 0; | |
4768 for ( i = 0; i < v45; i++ ) | |
4769 { | |
4770 if ( pActors[ai_near_actors_ids[i]].ActorNearby() | |
4771 || sub_4070EF_prolly_detect_player(PID(OBJECT_Actor,ai_near_actors_ids[i]), 4) ) | |
4772 { | |
4773 pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_NEARBY; | |
4774 ai_array_4F6638_actor_ids[v19] = ai_near_actors_ids[i]; | |
4775 ai_array_4F5E68[v19++] = ai_near_actors_distances[i]; | |
4776 if ( v19 >= 30 ) | |
4777 break; | |
4778 } | |
4779 } | |
4780 ai_arrays_size = v19; | |
4781 if ( (signed int)uNumActors > 0 ) | |
4782 { | |
4783 for ( uint i = 0; i < (signed int)uNumActors; ++i ) | |
4784 { | |
4785 if ( pActors[i].CanAct() && pActors[i].uSectorID == v37 ) | |
4786 { | |
4787 v25 = 0; | |
4788 if ( v19 <= 0 ) | |
4789 { | |
4790 pActors[i].uAttributes |= ACTOR_ACTIVE; | |
4791 ai_array_4F6638_actor_ids[ai_arrays_size++] = i; | |
4792 } | |
4793 else | |
4794 { | |
4795 while ( ai_array_4F6638_actor_ids[v25] != i ) | |
4796 { | |
4797 ++v25; | |
4798 if ( v25 >= v19 ) | |
4799 { | |
4800 pActors[i].uAttributes |= ACTOR_ACTIVE; | |
4801 ai_array_4F6638_actor_ids[ai_arrays_size++] = i; | |
4802 break; | |
4803 } | |
4804 } | |
4805 } | |
4806 } | |
4807 } | |
4808 } | |
4809 for ( j = 0; j < v45; ++j ) | |
4810 { | |
4811 if ( pActors[ai_near_actors_ids[j]].uAttributes & 0xC000 && pActors[ai_near_actors_ids[j]].CanAct() ) | |
4812 { | |
4813 v30 = 0; | |
4814 if ( ai_arrays_size <= 0 ) | |
4815 ai_array_4F6638_actor_ids[ai_arrays_size++] = ai_near_actors_ids[j]; | |
4816 else | |
4817 { | |
4818 while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) | |
4819 { | |
4820 ++v30; | |
4821 if ( v30 >= ai_arrays_size ) | |
4822 { | |
4823 ai_array_4F6638_actor_ids[ai_arrays_size++] = ai_near_actors_ids[j]; | |
4824 break; | |
4825 } | |
4826 } | |
4827 } | |
4828 } | |
4829 } | |
4830 if ( ai_arrays_size > 30 ) | |
4831 ai_arrays_size = 30; | |
4832 memcpy(ai_near_actors_ids.data(), ai_array_4F6638_actor_ids.data(), 4 * ai_arrays_size); | |
4833 memcpy(ai_near_actors_distances.data(), ai_array_4F5E68.data(), 4 * ai_arrays_size); | |
4834 for ( uint i = 0; i < ai_arrays_size; i++ ) | |
4835 pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_ALIVE;//0x400 | |
4836 return ai_arrays_size; | |
4837 } | |
4838 | |
4839 | |
4840 //----- (004070EF) -------------------------------------------------------- | |
4841 bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID) | |
4842 { | |
4843 signed int v2; // eax@1 | |
4844 int obj1_sector; // eax@4 | |
4845 float v8; // ST24_4@5 | |
4846 signed int v12; // eax@7 | |
4847 int obj2_z; // edi@11 | |
4848 int obj2_x; // esi@11 | |
4849 int obj2_sector; // eax@13 | |
4850 float v20; // ST24_4@14 | |
4851 int dist_x; // ebx@16 | |
4852 signed int dist_3d; // ecx@16 | |
4853 int v25; // eax@18 | |
4854 BLVFace *v29; // ebx@32 | |
4855 Vec3_short_ *v30; // esi@32 | |
4856 int v31; // eax@32 | |
4857 int v32; // ST50_4@44 | |
4858 int v33; // ST54_4@44 | |
4859 int v34; // eax@44 | |
4860 signed int v38; // esi@45 | |
4861 __int16 next_sector; // bx@58 | |
4862 int v47; // [sp+18h] [bp-50h]@20 | |
4863 int v48; // [sp+1Ch] [bp-4Ch]@20 | |
4864 int v49; // [sp+20h] [bp-48h]@20 | |
4865 int dist_z; // [sp+24h] [bp-44h]@16 | |
4866 signed int higher_z; // [sp+24h] [bp-44h]@27 | |
4867 signed int lower_z; // [sp+28h] [bp-40h]@26 | |
4868 signed int higher_y; // [sp+2Ch] [bp-3Ch]@23 | |
4869 signed int lower_y; // [sp+30h] [bp-38h]@22 | |
4870 signed int higher_x; // [sp+34h] [bp-34h]@21 | |
4871 signed int lower_x; // [sp+38h] [bp-30h]@20 | |
4872 signed int sectors_visited; // [sp+3Ch] [bp-2Ch]@28 | |
4873 int v58; // [sp+44h] [bp-24h]@50 | |
4874 int v59; // [sp+48h] [bp-20h]@44 | |
4875 int obj2_y; // [sp+50h] [bp-18h]@11 | |
4876 int obj1_x; // [sp+58h] [bp-10h]@4 | |
4877 int obj1_y; // [sp+5Ch] [bp-Ch]@4 | |
4878 int obj1_z; // [sp+60h] [bp-8h]@4 | |
4879 int current_sector; // [sp+64h] [bp-4h]@7 | |
4880 int dist_y; | |
4881 int v70; | |
4882 | |
4883 v2 = PID_ID(uObjID); | |
4884 switch( PID_TYPE(uObjID) ) | |
4885 { | |
4886 case OBJECT_Decoration: | |
4887 obj1_x = pLevelDecorations[v2].vPosition.x; | |
4888 obj1_y = pLevelDecorations[v2].vPosition.y; | |
4889 obj1_z = pLevelDecorations[v2].vPosition.z; | |
4890 obj1_sector = pIndoor->GetSector(obj1_x, obj1_y, obj1_z); | |
4891 break; | |
4892 case OBJECT_Actor: | |
4893 obj1_x = pActors[v2].vPosition.x; | |
4894 obj1_y = pActors[v2].vPosition.y; | |
4895 v8 = (double)pActors[v2].uActorHeight * 0.69999999; | |
4896 //v9 = v8 + 6.7553994e15; | |
4897 //obj1_z = LODWORD(v9) + pActors[v2].vPosition.z; | |
4898 obj1_z = (int)v8 + pActors[v2].vPosition.z; | |
4899 obj1_sector = pActors[v2].uSectorID; | |
4900 break; | |
4901 case OBJECT_Item: | |
4902 obj1_x = pSpriteObjects[v2].vPosition.x; | |
4903 obj1_y = pSpriteObjects[v2].vPosition.y; | |
4904 obj1_z = pSpriteObjects[v2].vPosition.z; | |
4905 obj1_sector = pSpriteObjects[v2].uSectorID; | |
4906 break; | |
4907 default: | |
4908 return 0; | |
4909 } | |
4910 v12 = PID_ID(uObj2ID); | |
4911 switch( PID_TYPE(uObj2ID) ) | |
4912 { | |
4913 case OBJECT_Decoration: | |
4914 obj2_z = pLevelDecorations[v12].vPosition.z; | |
4915 obj2_x = pLevelDecorations[v12].vPosition.x; | |
4916 obj2_y = pLevelDecorations[v12].vPosition.y; | |
4917 obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); | |
4918 break; | |
4919 case OBJECT_Player: | |
4920 obj2_x = pParty->vPosition.x; | |
4921 obj2_z = pParty->sEyelevel + pParty->vPosition.z; | |
4922 obj2_y = pParty->vPosition.y; | |
4923 obj2_sector = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
4924 break; | |
4925 case OBJECT_Actor: | |
4926 obj2_y = pActors[v12].vPosition.y; | |
4927 obj2_x = pActors[v12].vPosition.x; | |
4928 v20 = (double)pActors[v12].uActorHeight * 0.69999999; | |
4929 //v21 = v20 + 6.7553994e15; | |
4930 //obj2_z = LODWORD(v21) + pActors[v12].vPosition.z; | |
4931 obj2_z = (int)v20 + pActors[v12].vPosition.z; | |
4932 obj2_sector = pActors[v12].uSectorID; | |
4933 break; | |
4934 case OBJECT_Item: | |
4935 obj2_x = pSpriteObjects[v12].vPosition.x; | |
4936 obj2_z = pSpriteObjects[v12].vPosition.z; | |
4937 obj2_y = pSpriteObjects[v12].vPosition.y; | |
4938 obj2_sector = pSpriteObjects[v12].uSectorID; | |
4939 break; | |
4940 default: | |
4941 return 0; | |
4942 } | |
4943 dist_x = obj2_x - obj1_x; | |
4944 dist_z = obj2_z - obj1_z; | |
4945 dist_y = obj2_y - obj1_y; | |
4946 dist_3d = integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z); | |
4947 //range check | |
4948 if ( dist_3d > 5120 ) | |
4949 return 0; | |
4950 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
4951 return 1; | |
4952 v25 = 65536; | |
4953 if ( dist_3d ) | |
4954 v25 = 65536 / dist_3d; | |
4955 v49 = dist_x * v25; | |
4956 v47 = dist_z * v25; | |
4957 v48 = dist_y * v25; | |
4958 if ( obj1_x < obj2_x ) | |
4959 { | |
4960 lower_x = obj1_x; | |
4961 higher_x = obj2_x; | |
4962 } | |
4963 else | |
4964 { | |
4965 lower_x = obj2_x; | |
4966 higher_x = obj1_x; | |
4967 } | |
4968 if ( obj1_y < obj2_y ) | |
4969 { | |
4970 lower_y = obj1_y; | |
4971 higher_y = obj2_y; | |
4972 } | |
4973 else | |
4974 { | |
4975 lower_y = obj2_y; | |
4976 higher_y = obj1_y; | |
4977 } | |
4978 if ( obj1_z < obj2_z ) | |
4979 { | |
4980 lower_z = obj1_z; | |
4981 higher_z = obj2_z; | |
4982 } | |
4983 else | |
4984 { | |
4985 lower_z = obj2_z; | |
4986 higher_z = obj1_z; | |
4987 } | |
4988 sectors_visited = 0; | |
4989 //monster in same sector with player | |
4990 if ( obj1_sector == obj2_sector ) | |
4991 return 1; | |
4992 //search starts from monster | |
4993 current_sector = obj1_sector; | |
4994 for( int current_portal = 0; current_portal < pIndoor->pSectors[current_sector].uNumPortals; current_portal++ ) | |
4995 { | |
4996 v29 = &pIndoor->pFaces[pIndoor->pSectors[current_sector].pPortals[current_portal]]; | |
4997 v30 = &pIndoor->pVertices[*v29->pVertexIDs]; | |
4998 v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj1_z) | |
4999 + v29->pFacePlane_old.vNormal.y * (v30->y - obj1_y) | |
5000 + v29->pFacePlane_old.vNormal.x * (v30->x - obj1_x); | |
5001 | |
5002 if ( current_sector != v29->uSectorID ) | |
5003 v31 = -v31; | |
5004 | |
5005 if ( v31 >= 0 && v30->x != obj1_x && v30->y != obj1_y && v30->z != obj1_z) | |
5006 continue; | |
5007 | |
5008 if( lower_x > v29->pBounding.x2 | |
5009 || higher_x < v29->pBounding.x1 | |
5010 || lower_y > v29->pBounding.y2 | |
5011 || higher_y < v29->pBounding.y1 | |
5012 || lower_z > v29->pBounding.z2 | |
5013 || higher_z < v29->pBounding.z1 ) | |
5014 { | |
5015 continue; | |
5016 } | |
5017 | |
5018 v32 = fixpoint_mul(v29->pFacePlane_old.vNormal.x,v49); | |
5019 v34 = fixpoint_mul(v29->pFacePlane_old.vNormal.y,v48); | |
5020 v33 = fixpoint_mul(v29->pFacePlane_old.vNormal.z,v47); | |
5021 | |
5022 v59 = v32 + v33 + v34; | |
5023 if ( v59 ) | |
5024 { | |
5025 v70 = v29->pFacePlane_old.dist | |
5026 + obj1_z * v29->pFacePlane_old.vNormal.z | |
5027 + obj1_x * v29->pFacePlane_old.vNormal.x | |
5028 + obj1_y * v29->pFacePlane_old.vNormal.y; | |
5029 v38 = -v70; | |
5030 | |
5031 // if ( v59 <= 0 ^ v70 <= 0 ) | |
5032 | |
5033 /* TEMPORARY | |
5034 if ( v59 <= 0 && v70 <= 0 ) | |
5035 { | |
5036 continue; | |
5037 } | |
5038 if ( !(v59 <= 0 && v70 <= 0) ) | |
5039 { | |
5040 continue; | |
5041 } | |
5042 */ | |
5043 | |
5044 if( abs(v38) >> 14 > abs(v59) ) | |
5045 continue; | |
5046 | |
5047 v58 = fixpoint_div(v38,v59); | |
5048 | |
5049 if( v58 < 0 ) | |
5050 continue; | |
5051 | |
5052 if(!sub_4075DB(obj1_x + ((fixpoint_mul(v49,v58) + 32768) >> 16), obj1_y + ((fixpoint_mul(v48,v58) + 32768) >> 16), | |
5053 obj1_z + ((fixpoint_mul(v47,v58) + 32768) >> 16), v29) ) | |
5054 { | |
5055 continue; | |
5056 } | |
5057 | |
5058 //if there is no next sector turn back | |
5059 if ( v29->uSectorID == current_sector ) | |
5060 next_sector = v29->uBackSectorID; | |
5061 else | |
5062 next_sector = v29->uSectorID; | |
5063 | |
5064 //no more portals, quit | |
5065 if ( next_sector == current_sector ) | |
5066 break; | |
5067 | |
5068 ++sectors_visited; | |
5069 current_sector = next_sector; | |
5070 | |
5071 //found player, quit | |
5072 if ( next_sector == obj2_sector ) | |
5073 return 1; | |
5074 | |
5075 current_sector = next_sector; | |
5076 | |
5077 //did we hit limit for portals? | |
5078 //does the next room have portals? | |
5079 if ( sectors_visited < 30 && pIndoor->pSectors[current_sector].uNumPortals > 0) | |
5080 { | |
5081 current_portal=-1; | |
5082 continue; | |
5083 } | |
5084 else | |
5085 break; | |
5086 } | |
5087 } | |
5088 //did we stop in the sector where player is? | |
5089 if ( current_sector != obj2_sector ) | |
5090 return 0; | |
5091 return 1; | |
5092 } | |
5093 | |
5094 | |
5095 //----- (00450B0A) -------------------------------------------------------- | |
5096 bool __fastcall SpawnActor(unsigned int uMonsterID) | |
5097 { | |
5098 unsigned int v1; // ebx@1 | |
5099 bool result; // eax@2 | |
5100 unsigned int v6; // ecx@5 | |
5101 Actor actor; // [sp+4h] [bp-350h]@5 | |
5102 Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5 | |
5103 | |
5104 v1 = uMonsterID; | |
5105 if ( uNumActors == 499 ) | |
5106 result = 0; | |
5107 else | |
5108 { | |
5109 if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters ) | |
5110 v1 = 0; | |
5111 memset(&actor, 0, sizeof(Actor)); | |
5112 strcpy(actor.pActorName, pMonsterStats->pInfos[v1 + 1].pName); | |
5113 actor.sCurrentHP = LOWORD(pMonsterStats->pInfos[v1 + 1].uHP); | |
5114 memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], sizeof(MonsterInfo)); | |
5115 actor.word_000086_some_monster_id = v1 + 1; | |
5116 actor.uActorRadius = pMonsterList->pMonsters[v1].uMonsterRadius; | |
5117 actor.uActorHeight = pMonsterList->pMonsters[v1].uMonsterHeight; | |
5118 actor.uMovementSpeed = pMonsterList->pMonsters[v1].uMovementSpeed; | |
5119 | |
5120 Vec3_int_::Rotate(200, pParty->sRotationY, 0, pParty->vPosition, &pOut.x, &pOut.z, &pOut.y); | |
5121 actor.vInitialPosition.x = pOut.x; | |
5122 actor.vPosition.x = pOut.x; | |
5123 actor.uTetherDistance = 256; | |
5124 actor.vInitialPosition.y = LOWORD(pOut.z); | |
5125 actor.vPosition.y = LOWORD(pOut.z); | |
5126 actor.vInitialPosition.z = LOWORD(pOut.y); | |
5127 actor.vPosition.z = LOWORD(pOut.y); | |
5128 pSprites_LOD->DeleteSomeSprites(); | |
5129 pPaletteManager->ResetNonTestLocked(); | |
5130 v6 = uNumActors - 1; | |
5131 if ( dword_5C6DF8 == 1 ) | |
5132 { | |
5133 dword_5C6DF8 = 0; | |
5134 v6 = uNumActors++; | |
5135 } | |
5136 memcpy(&pActors[v6], &actor, sizeof(Actor)); | |
5137 pActors[v6].PrepareSprites(1); | |
5138 result = 1; | |
5139 } | |
5140 return result; | |
5141 } | |
5142 // 5C6DF8: using guessed type int dword_5C6DF8; | |
5143 | |
5144 | |
5145 //----- (0044FA4C) -------------------------------------------------------- | |
5146 signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3) | |
5147 { | |
5148 signed int result; // eax@13 | |
5149 int v10; // ebx@16 | |
5150 const char *v15; // [sp-4h] [bp-24h]@2 | |
5151 unsigned int uFaceID; // [sp+8h] [bp-18h]@16 | |
5152 int v19; // [sp+Ch] [bp-14h]@16 | |
5153 size_t v20; // [sp+10h] [bp-10h]@6 | |
5154 int v21; // [sp+14h] [bp-Ch]@14 | |
5155 unsigned int v23; // [sp+1Ch] [bp-4h]@6 | |
5156 | |
5157 if ( a2 == 4 ) | |
5158 v15 = "Elemental Light C"; | |
5159 else if ( a2 == 3 ) | |
5160 v15 = "Elemental Light B"; | |
5161 else | |
5162 v15 = "Elemental Light A"; | |
5163 | |
5164 v23 = pMonsterList->GetMonsterIDByName(v15); | |
5165 v20 = 0; | |
5166 for ( v20; v20 < uNumActors; v20++ ) | |
5167 { | |
5168 if ( pActors[v20].uAIState == Removed ) | |
5169 break; | |
5170 } | |
5171 | |
5172 result = uNumActors + 1; | |
5173 if ( v20 != uNumActors || result < 500 ) | |
5174 { | |
5175 v21 = 0; | |
5176 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
5177 v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
5178 v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; | |
5179 pActors[v20].Reset(); | |
5180 strcpy(pActors[v20].pActorName, pMonsterStats->pInfos[v23 + 1].pName); | |
5181 pActors[v20].sCurrentHP = pMonsterStats->pInfos[v23 + 1].uHP; | |
5182 memcpy(&pActors[v20].pMonsterInfo, &pMonsterStats->pInfos[v23 + 1], sizeof(MonsterInfo)); | |
5183 pActors[v20].word_000086_some_monster_id = v23 + 1; | |
5184 pActors[v20].uActorRadius = pMonsterList->pMonsters[v23].uMonsterRadius; | |
5185 pActors[v20].uActorHeight = pMonsterList->pMonsters[v23].uMonsterHeight; | |
5186 pActors[v20].pMonsterInfo.uTreasureDiceRolls = 0; | |
5187 pActors[v20].pMonsterInfo.uTreasureType = 0; | |
5188 pActors[v20].pMonsterInfo.uExp = 0; | |
5189 pActors[v20].uMovementSpeed = pMonsterList->pMonsters[v23].uMovementSpeed; | |
5190 v10 = rand() % 2048; | |
5191 pActors[v20].vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); | |
5192 pActors[v20].vPosition.x = pActors[v20].vInitialPosition.x; | |
5193 pActors[v20].vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(stru_5C6E00->Sin(v10), v19); | |
5194 pActors[v20].vPosition.y = pActors[v20].vInitialPosition.y; | |
5195 pActors[v20].vInitialPosition.z = pParty->vPosition.z; | |
5196 pActors[v20].vPosition.z = pActors[v20].vInitialPosition.z; | |
5197 pActors[v20].uTetherDistance = 256; | |
5198 pActors[v20].uSectorID = v21; | |
5199 pActors[v20].PrepareSprites(0); | |
5200 pActors[v20].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
5201 pActors[v20].uAlly = 9999; | |
5202 pActors[v20].uGroup = 0; | |
5203 pActors[v20].uCurrentActionTime = 0; | |
5204 pActors[v20].uAIState = Summoned; | |
5205 pActors[v20].uCurrentActionLength = 256; | |
5206 pActors[v20].UpdateAnimation(); | |
5207 | |
5208 result = pIndoor->GetSector(pActors[v20].vPosition.x, pActors[v20].vPosition.y, pActors[v20].vPosition.z); | |
5209 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor | |
5210 || result == v21 | |
5211 && (result = BLV_GetFloorLevel(pActors[v20].vPosition.x, pActors[v20].vPosition.y, pActors[v20].vPosition.z, result, &uFaceID), result != -30000) | |
5212 && (result = abs(result - pParty->vPosition.z), result <= 1024) ) | |
5213 { | |
5214 if ( v20 == uNumActors ) | |
5215 ++uNumActors; | |
5216 pActors[v20].uSummonerID = PID(OBJECT_Player, a1); | |
5217 result = pActors[v20].pActorBuffs[ACTOR_BUFF_SUMMONED].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f, a2, a1, 0, 0); | |
5218 } | |
5219 } | |
5220 return result; | |
5221 } | |
5222 | |
5223 //----- (0044F57C) -------------------------------------------------------- | |
5224 void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) | |
5225 { | |
5226 int v7; // eax@2 | |
5227 char v8; // zf@5 | |
5228 int v12; // edx@9 | |
5229 int v18; // esi@31 | |
5230 Actor *pMonster; // esi@35 | |
5231 int v23; // edx@36 | |
5232 signed int v24; // edi@36 | |
5233 int v25; // ecx@36 | |
5234 MonsterDesc *v27; // edi@48 | |
5235 signed int v28; // eax@48 | |
5236 int v32; // eax@50 | |
5237 int v37; // eax@51 | |
5238 int v38; // eax@52 | |
5239 int v39; // edi@52 | |
5240 std::string v40; // [sp-18h] [bp-100h]@60 | |
5241 const char *v44; // [sp-8h] [bp-F0h]@13 | |
5242 char *pTexture; // [sp-4h] [bp-ECh]@9 | |
5243 char Str[32]; // [sp+Ch] [bp-DCh]@60 | |
5244 char Str2[120]; // [sp+2Ch] [bp-BCh]@29 | |
5245 unsigned int uFaceID; // [sp+A4h] [bp-44h]@52 | |
5246 MonsterInfo *Src; // [sp+A8h] [bp-40h]@50 | |
5247 int v50; // [sp+ACh] [bp-3Ch]@47 | |
5248 char Source[32]; // [sp+B0h] [bp-38h]@20 | |
5249 int v52; // [sp+D0h] [bp-18h]@34 | |
5250 int v53; // [sp+D4h] [bp-14h]@34 | |
5251 int pSector; // [sp+D8h] [bp-10h]@32 | |
5252 int pPosX; // [sp+DCh] [bp-Ch]@32 | |
5253 int v56; // [sp+E0h] [bp-8h]@8 | |
5254 int v57; // [sp+E4h] [bp-4h]@1 | |
5255 | |
5256 //auto a2 = spawn; | |
5257 v57 = 0; | |
5258 //v5 = pMapInfo; | |
5259 //v6 = spawn; | |
5260 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
5261 v7 = pOutdoor->ddm.field_C_alert; | |
5262 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
5263 v7 = pIndoor->dlv.field_C_alert; | |
5264 else | |
5265 v7 = 0; | |
5266 if (v7) | |
5267 v8 = (spawn->uAttributes & 1) == 0; | |
5268 else | |
5269 v8 = (spawn->uAttributes & 1) == 1; | |
5270 if (v8) | |
5271 return; | |
5272 //result = (void *)(spawn->uIndex - 1); | |
5273 v56 = 1; | |
5274 switch (spawn->uIndex - 1) | |
5275 { | |
5276 case 0: | |
5277 //v9 = pMapInfo->uEncounterMonster1AtLeast; | |
5278 //v10 = rand(); | |
5279 //v11 = pMapInfo->uEncounterMonster1AtMost; | |
5280 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
5281 v12 = rand() % (pMapInfo->uEncounterMonster1AtMost - pMapInfo->uEncounterMonster1AtLeast + 1); | |
5282 //v13 = pMapInfo->Dif_M1; | |
5283 v57 = pMapInfo->Dif_M1; | |
5284 v56 = pMapInfo->uEncounterMonster1AtLeast + v12; | |
5285 strcpy(Source, pMapInfo->pEncounterMonster1Texture); | |
5286 break; | |
5287 case 3: | |
5288 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
5289 //v44 = "%s A"; | |
5290 sprintf(Source, "%s A", pMapInfo->pEncounterMonster1Texture); | |
5291 break; | |
5292 case 4: | |
5293 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
5294 //v44 = "%s A"; | |
5295 sprintf(Source, "%s A", pMapInfo->pEncounterMonster2Texture); | |
5296 break; | |
5297 case 5: | |
5298 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
5299 //v44 = "%s A"; | |
5300 sprintf(Source, "%s A", pMapInfo->pEncounterMonster3Texture); | |
5301 break; | |
5302 case 1: | |
5303 //v9 = pMapInfo->uEncounterMonster2AtLeast; | |
5304 //v14 = rand(); | |
5305 //v15 = pMapInfo->uEncounterMonster2AtMost; | |
5306 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
5307 v12 = rand() % (pMapInfo->uEncounterMonster2AtMost - pMapInfo->uEncounterMonster2AtLeast + 1); | |
5308 //v13 = pMapInfo->Dif_M2; | |
5309 v57 = pMapInfo->Dif_M2; | |
5310 v56 = pMapInfo->uEncounterMonster2AtLeast + v12; | |
5311 strcpy(Source, pMapInfo->pEncounterMonster2Texture); | |
5312 break; | |
5313 case 6: | |
5314 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
5315 //v44 = "%s B"; | |
5316 sprintf(Source, "%s B", pMapInfo->pEncounterMonster1Texture); | |
5317 break; | |
5318 case 7: | |
5319 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
5320 //v44 = "%s B"; | |
5321 sprintf(Source, "%s B", pMapInfo->pEncounterMonster2Texture); | |
5322 break; | |
5323 case 8: | |
5324 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
5325 //v44 = "%s B"; | |
5326 sprintf(Source, "%s B", pMapInfo->pEncounterMonster3Texture); | |
5327 break; | |
5328 case 2: | |
5329 //v9 = pMapInfo->uEncounterMonster3AtLeast; | |
5330 //v16 = rand(); | |
5331 //v17 = pMapInfo->uEncounterMonster3AtMost; | |
5332 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
5333 v12 = rand() % (pMapInfo->uEncounterMonster3AtMost - pMapInfo->uEncounterMonster3AtLeast + 1); | |
5334 //v13 = pMapInfo->Dif_M3; | |
5335 v57 = pMapInfo->Dif_M3; | |
5336 v56 = pMapInfo->uEncounterMonster3AtLeast + v12; | |
5337 strcpy(Source, pMapInfo->pEncounterMonster3Texture); | |
5338 break; | |
5339 case 9: | |
5340 //pTexture = pMapInfo->pEncounterMonster1Texture; | |
5341 //v44 = "%s C"; | |
5342 sprintf(Source, "%s C", pMapInfo->pEncounterMonster1Texture); | |
5343 break; | |
5344 case 10: | |
5345 //pTexture = pMapInfo->pEncounterMonster2Texture; | |
5346 //v44 = "%s C"; | |
5347 sprintf(Source, "%s C", pMapInfo->pEncounterMonster2Texture); | |
5348 break; | |
5349 case 11: | |
5350 //pTexture = pMapInfo->pEncounterMonster3Texture; | |
5351 //v44 = "%s C"; | |
5352 sprintf(Source, "%s C", pMapInfo->pEncounterMonster3Texture); | |
5353 break; | |
5354 default: | |
5355 return; | |
5356 } | |
5357 if (Source[0] == '0') | |
5358 return; | |
5359 v57 += a3; | |
5360 if ( v57 > 4 ) | |
5361 v57 = 4; | |
5362 strcpy(Str2, Source); | |
5363 if ( a4 ) | |
5364 v56 = a4; | |
5365 v18 = v56; | |
5366 if ( (signed int)(v56 + uNumActors) >= 500 ) | |
5367 return; | |
5368 pSector = 0; | |
5369 pPosX = spawn->vPosition.x; | |
5370 a4 = spawn->vPosition.y; | |
5371 a3 = spawn->vPosition.z; | |
5372 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
5373 pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); | |
5374 v53 = 0; | |
5375 v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; | |
5376 if ( v18 <= 0 ) | |
5377 return; | |
5378 for (uint i = v53; i < v56; ++i) | |
5379 { | |
5380 pMonster = &pActors[uNumActors]; | |
5381 pActors[uNumActors].Reset(); | |
5382 if ( v57 ) | |
5383 { | |
5384 v23 = rand() % 100; | |
5385 v24 = 3; | |
5386 v25 = (unsigned __int16)word_4E8152[3 * v57]; | |
5387 if ( v23 >= v25 ) | |
5388 { | |
5389 if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] ) | |
5390 v24 = 2; | |
5391 } | |
5392 else | |
5393 v24 = 1; | |
5394 if ( v24 == 1 ) | |
5395 { | |
5396 pTexture = Source; | |
5397 v44 = "%s A"; | |
5398 } | |
5399 else | |
5400 { | |
5401 if ( v24 == 2 ) | |
5402 { | |
5403 pTexture = Source; | |
5404 v44 = "%s B"; | |
5405 } | |
5406 else | |
5407 { | |
5408 if ( v24 != 3 ) | |
5409 continue; | |
5410 pTexture = Source; | |
5411 v44 = "%s C"; | |
5412 } | |
5413 } | |
5414 sprintf(Str2, v44, pTexture); | |
5415 } | |
5416 v50 = pMonsterList->GetMonsterIDByName(Str2); | |
5417 pTexture = Str2; | |
5418 if ( (signed __int16)v50 == -1 ) | |
5419 { | |
5420 sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture); | |
5421 MessageBoxA(nullptr, Str, nullptr, 0); | |
5422 ExitProcess(0); | |
5423 } | |
5424 v27 = &pMonsterList->pMonsters[(signed __int16)v50]; | |
5425 v28 = pMonsterStats->FindMonsterByTextureName(pTexture); | |
5426 if ( !v28 ) | |
5427 v28 = 1; | |
5428 Src = &pMonsterStats->pInfos[v28]; | |
5429 strcpy(pMonster->pActorName, Src->pName); | |
5430 pMonster->sCurrentHP = Src->uHP; | |
5431 assert(sizeof(MonsterInfo) == 88); | |
5432 memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));//Uninitialized portail memory access | |
5433 pMonster->word_000086_some_monster_id = v50 + 1; | |
5434 pMonster->uActorRadius = v27->uMonsterRadius; | |
5435 pMonster->uActorHeight = v27->uMonsterHeight; | |
5436 pMonster->uMovementSpeed = v27->uMovementSpeed; | |
5437 pMonster->vInitialPosition.x = spawn->vPosition.x; | |
5438 pMonster->vPosition.x = spawn->vPosition.x; | |
5439 pMonster->uTetherDistance = 256; | |
5440 pMonster->vInitialPosition.y = a4; | |
5441 pMonster->vPosition.y = a4; | |
5442 pMonster->vInitialPosition.z = a3; | |
5443 pMonster->vPosition.z = a3; | |
5444 pMonster->uSectorID = pSector; | |
5445 pMonster->uGroup = spawn->uGroup; | |
5446 pMonster->PrepareSprites(0); | |
5447 pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
5448 v32 = rand(); | |
5449 a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52); | |
5450 pPosX = a3 + spawn->vPosition.x; | |
5451 a3 = fixpoint_mul(stru_5C6E00->Sin(v32 % 2048), v52); | |
5452 a4 = a3 + spawn->vPosition.y; | |
5453 a3 = spawn->vPosition.z; | |
5454 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
5455 { | |
5456 if ( a5 ) | |
5457 pMonster->uAttributes |= ACTOR_AGGRESSOR; | |
5458 ++uNumActors; | |
5459 continue; | |
5460 } | |
5461 v37 = pIndoor->GetSector(pPosX, a4, spawn->vPosition.z); | |
5462 if ( v37 == pSector ) | |
5463 { | |
5464 v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID); | |
5465 v39 = v38; | |
5466 if ( v38 != -30000 ) | |
5467 { | |
5468 if ( abs(v38 - a3) <= 1024 ) | |
5469 { | |
5470 a3 = v39; | |
5471 if ( a5 ) | |
5472 pMonster->uAttributes |= ACTOR_AGGRESSOR; | |
5473 ++uNumActors; | |
5474 continue; | |
5475 } | |
5476 } | |
5477 } | |
5478 ; | |
5479 //v53 = (char *)v53 + 1; | |
5480 //result = v53; | |
5481 } | |
5482 //while ( (signed int)v53 < v56 ); | |
5483 } | |
5484 | |
5485 //----- (00438F8F) -------------------------------------------------------- | |
5486 void area_of_effect__damage_evaluate() | |
5487 { | |
5488 int attacker_type; // ecx@3 | |
5489 signed int v3; // eax@3 | |
5490 unsigned int target_id; // edi@6 | |
5491 int target_type; // eax@6 | |
5492 int v10; // edi@8 | |
5493 Vec3_int_ attacker_coord; // ST04_12@9 | |
5494 // int v12; // ST0C_4@10 | |
5495 int v15; // edx@15 | |
5496 int v19; // edi@15 | |
5497 int v23; // edx@18 | |
5498 int v24; // eax@18 | |
5499 // int v30; // eax@29 | |
5500 int v31; // edx@29 | |
5501 int v32; // eax@29 | |
5502 int v33; // ST24_4@29 | |
5503 SpriteObject *v36; // [sp+0h] [bp-28h]@0 | |
5504 int attacker_id; // [sp+10h] [bp-18h]@1 | |
5505 int v44; // [sp+14h] [bp-14h]@15 | |
5506 //Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2 | |
5507 signed int a1; // [sp+20h] [bp-8h]@8 | |
5508 int v48; // [sp+24h] [bp-4h]@8 | |
5509 | |
5510 | |
5511 for (attacker_id = 0; attacker_id < AttackerInfo.count; ++attacker_id) | |
5512 { | |
5513 attacker_type = PID_TYPE(AttackerInfo.pIDs[attacker_id]); | |
5514 v3 = PID_ID(AttackerInfo.pIDs[attacker_id]); | |
5515 | |
5516 if (attacker_type == 2) | |
5517 { | |
5518 v36 = &pSpriteObjects[v3]; | |
5519 attacker_type = PID_TYPE(pSpriteObjects[v3].spell_caster_pid); | |
5520 v3 = PID_ID(pSpriteObjects[v3].spell_caster_pid); | |
5521 } | |
5522 | |
5523 if (AttackerInfo.field_3EC[attacker_id] & 1) | |
5524 { | |
5525 target_id = PID_ID(ai_near_actors_targets_pid[v3]); | |
5526 target_type = PID_TYPE(ai_near_actors_targets_pid[v3]) - 3; | |
5527 if (target_type) | |
5528 { | |
5529 if (target_type == 1)//party damage from monsters(повреждения группе от монстров) | |
5530 { | |
5531 v10 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; | |
5532 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; | |
5533 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; | |
5534 if (a1 * a1 + v10 * v10 | |
5535 + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
5536 * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
5537 < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32))) | |
5538 { | |
5539 attacker_coord.x = AttackerInfo.pXs[attacker_id]; | |
5540 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
5541 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
5542 if (sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord)) | |
5543 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], stru_50C198.which_player_to_attack(&pActors[v3])); | |
5544 } | |
5545 } | |
5546 } | |
5547 else//Actor damage from monsters(повреждение местного жителя) | |
5548 { | |
5549 if (SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) > 0 | |
5550 || SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) >= 0 | |
5551 && LODWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) | |
5552 || pActors[target_id].CanAct()) | |
5553 { | |
5554 v15 = pActors[target_id].vPosition.y - AttackerInfo.pYs[attacker_id]; | |
5555 a1 = pActors[target_id].vPosition.x - AttackerInfo.pXs[attacker_id]; | |
5556 v44 = pActors[target_id].vPosition.z; | |
5557 v19 = AttackerInfo.field_324[attacker_id] + pActors[target_id].uActorRadius; | |
5558 v48 = v15; | |
5559 if (a1 * a1 + v15 * v15 + (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) | |
5560 * (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) < (unsigned int)(v19 * v19)) | |
5561 { | |
5562 attacker_coord.x = AttackerInfo.pXs[attacker_id]; | |
5563 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
5564 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
5565 if (sub_407A1C(pActors[target_id].vPosition.x, pActors[target_id].vPosition.y, pActors[target_id].vPosition.z + 50, attacker_coord)) | |
5566 { | |
5567 Vec3_int_::Normalize(&a1, &v48, &v44); | |
5568 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
5569 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
5570 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
5571 Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], target_id, &AttackerInfo.vec_4B4[attacker_id], AttackerInfo.field_450[attacker_id]); | |
5572 } | |
5573 } | |
5574 } | |
5575 } | |
5576 } | |
5577 else //damage from spells(повреждения от заклов(метеоритный дождь)) | |
5578 { | |
5579 v23 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; | |
5580 v24 = ((signed int)pParty->uPartyHeight / 2) - AttackerInfo.pZs[attacker_id]; | |
5581 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; | |
5582 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; | |
5583 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))) | |
5584 {//party damage (повреждения группе) | |
5585 attacker_coord.x = AttackerInfo.pXs[attacker_id]; | |
5586 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
5587 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
5588 if (sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord)) | |
5589 { | |
5590 for (uint i = 0; i < 4; ++i) | |
5591 { | |
5592 if (!(HIDWORD(pParty->pPlayers[i].pConditions[Condition_Dead]) | LODWORD(pParty->pPlayers[i].pConditions[Condition_Dead])) | |
5593 && !pParty->pPlayers[i].pConditions[Condition_Pertified] && !pParty->pPlayers[i].pConditions[Condition_Eradicated]) | |
5594 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], i); | |
5595 } | |
5596 } | |
5597 } | |
5598 if ((signed int)uNumActors > 0) | |
5599 {//actors damage(повреждения другим участникам) | |
5600 for (int actorID = 0; (signed int)actorID < (signed int)uNumActors; ++actorID) | |
5601 { | |
5602 if (pActors[actorID].CanAct()) | |
5603 { | |
5604 //v30 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; | |
5605 a1 = pActors[actorID].vPosition.x - AttackerInfo.pXs[attacker_id]; | |
5606 v31 = pActors[actorID].vPosition.z; | |
5607 v48 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; | |
5608 v44 = pActors[actorID].vPosition.z; | |
5609 v32 = (pActors[actorID].uActorHeight / 2) - AttackerInfo.pZs[attacker_id]; | |
5610 v33 = pActors[actorID].uActorRadius + AttackerInfo.field_324[attacker_id]; | |
5611 if (a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33)) | |
5612 { | |
5613 attacker_coord.x = AttackerInfo.pXs[attacker_id]; | |
5614 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
5615 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
5616 if (sub_407A1C(pActors[actorID].vPosition.x, pActors[actorID].vPosition.y, pActors[actorID].vPosition.z + 50, attacker_coord))//что делает ф-ция? | |
5617 { | |
5618 Vec3_int_::Normalize(&a1, &v48, &v44); | |
5619 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
5620 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
5621 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
5622 switch (attacker_type) | |
5623 { | |
5624 case OBJECT_Player: | |
5625 Actor::DamageMonsterFromParty(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); | |
5626 break; | |
5627 case OBJECT_Actor: | |
5628 if (v36 && pActors[v3].GetActorsRelation(&pActors[actorID])) | |
5629 Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id], v36->field_61); | |
5630 break; | |
5631 case OBJECT_Item: | |
5632 ItemDamageFromActor(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); | |
5633 break; | |
5634 } | |
5635 } | |
5636 } | |
5637 } | |
5638 } | |
5639 } | |
5640 } | |
5641 } | |
5642 AttackerInfo.count = 0; | |
5643 } | |
5644 | |
5645 //----- (0043AE12) -------------------------------------------------------- | |
5646 double __fastcall sub_43AE12(signed int a1) | |
5647 { | |
5648 //signed int v1; // ST00_4@1 | |
5649 signed int v2; // ecx@1 | |
5650 double v3; // st7@1 | |
5651 double result; // st7@6 | |
5652 | |
5653 v3 = (double)a1; | |
5654 for (v2 = 0; v2 < 5; ++v2) | |
5655 { | |
5656 if (v3 < flt_4E4A80[v2 + 5]) | |
5657 break; | |
5658 } | |
5659 if (v2 <= 0 || v2 >= 5) | |
5660 { | |
5661 if (v2) | |
5662 result = flt_4E4A80[4]; | |
5663 else | |
5664 result = flt_4E4A80[0]; | |
5665 } | |
5666 else | |
5667 result = (flt_4E4A80[v2] - flt_4E4A80[v2 - 1]) * (v3 - flt_4E4A80[v2 + 4]) / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4]) + flt_4E4A80[v2]; | |
5668 return result; | |
5669 } | |
5670 | |
5671 //----- (0043B057) -------------------------------------------------------- | |
5672 void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) | |
5673 { | |
5674 int v6; // eax@4 | |
5675 int damage; // edi@4 | |
5676 int a2a; // [sp+Ch] [bp-4h]@8 | |
5677 | |
5678 if (!pActors[uActorID].IsNotAlive()) | |
5679 { | |
5680 if (PID_TYPE(uObjID) == OBJECT_Item) | |
5681 { | |
5682 if (pSpriteObjects[PID_ID(uObjID)].spell_id) | |
5683 { | |
5684 v6 = _43AFE3_calc_spell_damage(pSpriteObjects[PID_ID(uObjID)].spell_id, pSpriteObjects[PID_ID(uObjID)].spell_level, pSpriteObjects[PID_ID(uObjID)].spell_skill, pActors[uActorID].sCurrentHP); | |
5685 damage = pActors[uActorID].CalcMagicalDamageToActor((DAMAGE_TYPE)0, v6); | |
5686 pActors[uActorID].sCurrentHP -= damage; | |
5687 if (damage) | |
5688 { | |
5689 if (pActors[uActorID].sCurrentHP > 0) | |
5690 Actor::AI_Stun(uActorID, uObjID, 0); | |
5691 else | |
5692 Actor::Die(uActorID); | |
5693 a2a = 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP; | |
5694 if (20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10) | |
5695 a2a = 10; | |
5696 if (!MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT)) | |
5697 { | |
5698 pVelocity->x = fixpoint_mul(a2a, pVelocity->x); | |
5699 pVelocity->y = fixpoint_mul(a2a, pVelocity->y); | |
5700 pVelocity->z = fixpoint_mul(a2a, pVelocity->z); | |
5701 pActors[uActorID].vVelocity.x = 50 * LOWORD(pVelocity->x); | |
5702 pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); | |
5703 pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); | |
5704 } | |
5705 Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, damage); | |
5706 } | |
5707 else | |
5708 Actor::AI_Stun(uActorID, uObjID, 0); | |
5709 } | |
5710 } | |
5711 } | |
5712 } |