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