Mercurial > mm7
comparison Engine/Objects/Actor.cpp @ 2541:a902abdfc7f2
1. Renamed class Game to class Engine.
2. Separated game logic as state of FSM from game logic as engine.
3. Found out that many UI screen initializers were optimized away, intially
they all returned newly created window as separate object like it is done
in CharacterUI_Initialize.
author | a.parshin |
---|---|
date | Sun, 10 May 2015 01:29:11 +0200 |
parents | 1bcadc6dd203 |
children | b6140dfeac27 |
comparison
equal
deleted
inserted
replaced
2540:abc6a9d079b9 | 2541:a902abdfc7f2 |
---|---|
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <crtdbg.h> | 3 #include <crtdbg.h> |
4 | 4 |
5 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
6 | 6 |
7 #include "Engine/Engine.h" | |
8 | |
7 #include "../Graphics/PaletteManager.h" | 9 #include "../Graphics/PaletteManager.h" |
8 #include "../ErrorHandling.h" | |
9 | |
10 #include "../Graphics/DecalBuilder.h" | 10 #include "../Graphics/DecalBuilder.h" |
11 | |
12 #include "../Graphics/Sprites.h" | 11 #include "../Graphics/Sprites.h" |
13 #include "../../stru6.h" | 12 #include "../../stru6.h" |
14 | |
15 | |
16 #include "Actor.h" | 13 #include "Actor.h" |
17 #include "../OurMath.h" | 14 #include "../OurMath.h" |
18 #include "../Graphics/Outdoor.h" | 15 #include "../Graphics/Outdoor.h" |
19 #include "Media/Audio/AudioPlayer.h" | 16 #include "Media/Audio/AudioPlayer.h" |
20 #include "../Game.h" | |
21 #include "ObjectList.h" | 17 #include "ObjectList.h" |
22 #include "../Graphics/Overlays.h" | 18 #include "../Graphics/Overlays.h" |
23 #include "../Tables/FactionTable.h" | 19 #include "../Tables/FactionTable.h" |
24 #include "../TurnEngine/TurnEngine.h" | 20 #include "../TurnEngine/TurnEngine.h" |
25 #include "../Spells/CastSpellInfo.h" | 21 #include "../Spells/CastSpellInfo.h" |
26 #include "../Timer.h" | 22 #include "../Timer.h" |
27 #include "../LOD.h" | 23 #include "../LOD.h" |
28 #include "../Party.h" | 24 #include "../Party.h" |
29 #include "GUI/GUIWindow.h" | 25 #include "GUI/GUIWindow.h" |
30 | |
31 #include "../MM7.h" | |
32 #include "SpriteObject.h" | 26 #include "SpriteObject.h" |
33 #include "../stru298.h" | 27 #include "../stru298.h" |
34 #include "../Log.h" | |
35 #include "../Texts.h" | 28 #include "../Texts.h" |
36 #include "../Graphics/Level/Decoration.h" | 29 #include "../Graphics/Level/Decoration.h" |
37 #include "../Graphics/Viewport.h" | 30 #include "../Graphics/Viewport.h" |
38 #include "../Graphics/Vis.h" | 31 #include "../Graphics/Vis.h" |
39 | 32 |
329 v39 = 240 * (realPoints + 15); | 322 v39 = 240 * (realPoints + 15); |
330 else | 323 else |
331 v39 = 0; | 324 v39 = 0; |
332 actorPtr->pActorBuffs[ACTOR_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335), | 325 actorPtr->pActorBuffs[ACTOR_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335), |
333 masteryLevel, 0, 0, 0); | 326 masteryLevel, 0, 0, 0); |
334 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFF3C1Eu); | 327 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFF3C1Eu); |
335 pAudioPlayer->PlaySound((SoundID)SOUND_Haste, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | 328 pAudioPlayer->PlaySound((SoundID)SOUND_Haste, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
336 return; | 329 return; |
337 | 330 |
338 case SPELL_FIRE_METEOR_SHOWER: | 331 case SPELL_FIRE_METEOR_SHOWER: |
339 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | 332 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
476 else | 469 else |
477 v44 = 0; | 470 v44 = 0; |
478 actorPtr->pActorBuffs[ACTOR_BUFF_STONESKIN].Apply( | 471 actorPtr->pActorBuffs[ACTOR_BUFF_STONESKIN].Apply( |
479 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335), | 472 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335), |
480 masteryLevel, realPoints + 5, 0, 0); | 473 masteryLevel, realPoints + 5, 0, 0); |
481 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x5C310Eu); | 474 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x5C310Eu); |
482 pAudioPlayer->PlaySound((SoundID)SOUND_Stoneskin, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); | 475 pAudioPlayer->PlaySound((SoundID)SOUND_Stoneskin, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); |
483 return; | 476 return; |
484 | 477 |
485 case SPELL_SPIRIT_BLESS: | 478 case SPELL_SPIRIT_BLESS: |
486 if (masteryLevel == 1 || masteryLevel == 2) | 479 if (masteryLevel == 1 || masteryLevel == 2) |
492 else | 485 else |
493 v42 = 0; | 486 v42 = 0; |
494 actorPtr->pActorBuffs[ACTOR_BUFF_BLESS].Apply( | 487 actorPtr->pActorBuffs[ACTOR_BUFF_BLESS].Apply( |
495 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335), | 488 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335), |
496 masteryLevel, realPoints + 5, 0, 0); | 489 masteryLevel, realPoints + 5, 0, 0); |
497 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); | 490 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); |
498 pAudioPlayer->PlaySound((SoundID)SOUND_Bless, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); | 491 pAudioPlayer->PlaySound((SoundID)SOUND_Bless, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); |
499 return; | 492 return; |
500 break; | 493 break; |
501 | 494 |
502 case SPELL_SPIRIT_FATE: | 495 case SPELL_SPIRIT_FATE: |
507 else if (masteryLevel == 4 ) | 500 else if (masteryLevel == 4 ) |
508 v48 = 2 * (3 * realPoints + 60); | 501 v48 = 2 * (3 * realPoints + 60); |
509 else | 502 else |
510 v48 = 0; | 503 v48 = 0; |
511 actorPtr->pActorBuffs[ACTOR_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, masteryLevel, v48, 0, 0); | 504 actorPtr->pActorBuffs[ACTOR_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, masteryLevel, v48, 0, 0); |
512 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); | 505 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); |
513 pAudioPlayer->PlaySound((SoundID)SOUND_Fate, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | 506 pAudioPlayer->PlaySound((SoundID)SOUND_Fate, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
514 return; | 507 return; |
515 | 508 |
516 case SPELL_SPIRIT_HEROISM: | 509 case SPELL_SPIRIT_HEROISM: |
517 if (masteryLevel == 1 || masteryLevel == 2) | 510 if (masteryLevel == 1 || masteryLevel == 2) |
523 else | 516 else |
524 v54 = 0; | 517 v54 = 0; |
525 actorPtr->pActorBuffs[ACTOR_BUFF_HEROISM].Apply( | 518 actorPtr->pActorBuffs[ACTOR_BUFF_HEROISM].Apply( |
526 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335), | 519 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335), |
527 masteryLevel, realPoints + 5, 0, 0); | 520 masteryLevel, realPoints + 5, 0, 0); |
528 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); | 521 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); |
529 pAudioPlayer->PlaySound((SoundID)SOUND_51heroism03, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); | 522 pAudioPlayer->PlaySound((SoundID)SOUND_51heroism03, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); |
530 return; | 523 return; |
531 | 524 |
532 case SPELL_BODY_HAMMERHANDS: | 525 case SPELL_BODY_HAMMERHANDS: |
533 if ( (signed int)masteryLevel <= 0 || (signed int)masteryLevel > 4 ) | 526 if ( (signed int)masteryLevel <= 0 || (signed int)masteryLevel > 4 ) |
538 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335), | 531 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335), |
539 masteryLevel, | 532 masteryLevel, |
540 realPoints, | 533 realPoints, |
541 0, | 534 0, |
542 0); | 535 0); |
543 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); | 536 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); |
544 pAudioPlayer->PlaySound((SoundID)SOUND_51heroism03, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | 537 pAudioPlayer->PlaySound((SoundID)SOUND_51heroism03, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
545 return; | 538 return; |
546 | 539 |
547 case SPELL_BODY_POWER_CURE: | 540 case SPELL_BODY_POWER_CURE: |
548 actorPtr->sCurrentHP += 5 * realPoints + 10; | 541 actorPtr->sCurrentHP += 5 * realPoints + 10; |
549 if ( actorPtr->sCurrentHP >= (signed int)actorPtr->pMonsterInfo.uHP ) | 542 if ( actorPtr->sCurrentHP >= (signed int)actorPtr->pMonsterInfo.uHP ) |
550 actorPtr->sCurrentHP = LOWORD(actorPtr->pMonsterInfo.uHP); | 543 actorPtr->sCurrentHP = LOWORD(actorPtr->pMonsterInfo.uHP); |
551 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); | 544 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); |
552 pAudioPlayer->PlaySound((SoundID)SOUND_Fate, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | 545 pAudioPlayer->PlaySound((SoundID)SOUND_Fate, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
553 return; | 546 return; |
554 | 547 |
555 case SPELL_LIGHT_DISPEL_MAGIC: | 548 case SPELL_LIGHT_DISPEL_MAGIC: |
556 for (int i = 0; i < 20; i++ ) | 549 for (int i = 0; i < 20; i++ ) |
589 v96 = 0; | 582 v96 = 0; |
590 } | 583 } |
591 actorPtr->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].Apply( | 584 actorPtr->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].Apply( |
592 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335), | 585 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335), |
593 masteryLevel, realPoints, 0, 0); | 586 masteryLevel, realPoints, 0, 0); |
594 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); | 587 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); |
595 pAudioPlayer->PlaySound((SoundID)SOUND_94dayofprotection03, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | 588 pAudioPlayer->PlaySound((SoundID)SOUND_94dayofprotection03, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
596 return; | 589 return; |
597 | 590 |
598 case SPELL_LIGHT_HOUR_OF_POWER: | 591 case SPELL_LIGHT_HOUR_OF_POWER: |
599 if (masteryLevel == 1 || masteryLevel == 2) | 592 if (masteryLevel == 1 || masteryLevel == 2) |
605 else | 598 else |
606 v94 = 0; | 599 v94 = 0; |
607 actorPtr->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].Apply( | 600 actorPtr->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].Apply( |
608 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335), | 601 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335), |
609 masteryLevel, realPoints + 5, 0, 0); | 602 masteryLevel, realPoints + 5, 0, 0); |
610 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); | 603 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); |
611 pAudioPlayer->PlaySound((SoundID)SOUND_9armageddon01, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | 604 pAudioPlayer->PlaySound((SoundID)SOUND_9armageddon01, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
612 return; | 605 return; |
613 | 606 |
614 case SPELL_DARK_SHARPMETAL: | 607 case SPELL_DARK_SHARPMETAL: |
615 if (masteryLevel == 2) | 608 if (masteryLevel == 2) |
671 else | 664 else |
672 v68 = 900 * realPoints + 3840; | 665 v68 = 900 * realPoints + 3840; |
673 actorPtr->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].Apply( | 666 actorPtr->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].Apply( |
674 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335), | 667 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335), |
675 masteryLevel, 0, 0, 0); | 668 masteryLevel, 0, 0, 0); |
676 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x7E7E7Eu); | 669 pEngine->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x7E7E7Eu); |
677 pAudioPlayer->PlaySound((SoundID)SOUND_Sacrifice2, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); | 670 pAudioPlayer->PlaySound((SoundID)SOUND_Sacrifice2, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); |
678 return; | 671 return; |
679 } | 672 } |
680 } | 673 } |
681 | 674 |
1908 a4 = &a3; | 1901 a4 = &a3; |
1909 } | 1902 } |
1910 | 1903 |
1911 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; | 1904 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; |
1912 | 1905 |
1913 v7 = stru_5C6E00->Atan2(actor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, actor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); | 1906 v7 = stru_5C6E00->Atan2(actor->vPosition.x - pEngine->pIndoorCameraD3D->vPartyPos.x, actor->vPosition.y - pEngine->pIndoorCameraD3D->vPartyPos.y); |
1914 v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; | 1907 v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; |
1915 | 1908 |
1916 if ( v9 & 0x700 ) // turned away - just stand | 1909 if ( v9 & 0x700 ) // turned away - just stand |
1917 Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); | 1910 Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); |
1918 else // facing player - play bored anim | 1911 else // facing player - play bored anim |
3701 } | 3694 } |
3702 else | 3695 else |
3703 { | 3696 { |
3704 if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) | 3697 if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) |
3705 { | 3698 { |
3706 if ( /*pRenderer->pRenderD3D &&*/ pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) | 3699 if ( /*pRenderer->pRenderD3D &&*/ pEngine->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) |
3707 { | 3700 { |
3708 v33 = byte_4D864C && pGame->uFlags & 0x80000 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; | 3701 v33 = byte_4D864C && pEngine->uFlags & 0x80000 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; |
3709 pDecalBuilder->AddBloodsplat((float)pMonster->vPosition.x, (float)pMonster->vPosition.y, (float)pMonster->vPosition.z, 1.0, 0.0, 0.0, (float)v33, 0, 0); | 3702 pDecalBuilder->AddBloodsplat((float)pMonster->vPosition.x, (float)pMonster->vPosition.y, (float)pMonster->vPosition.z, 1.0, 0.0, 0.0, (float)v33, 0, 0); |
3710 } | 3703 } |
3711 } | 3704 } |
3712 Actor::Die(uActorID_Monster); | 3705 Actor::Die(uActorID_Monster); |
3713 Actor::ApplyFineForKillingPeasant(uActorID_Monster); | 3706 Actor::ApplyFineForKillingPeasant(uActorID_Monster); |
3979 //if ( pRenderer->pRenderD3D ) | 3972 //if ( pRenderer->pRenderD3D ) |
3980 { | 3973 { |
3981 v6 = a3 != 0; | 3974 v6 = a3 != 0; |
3982 if (a4) | 3975 if (a4) |
3983 LOBYTE(v6) = v6 | 8; | 3976 LOBYTE(v6) = v6 | 8; |
3984 v7 = pGame->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1); | 3977 v7 = pEngine->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1); |
3985 if (v7 != -1) | 3978 if (v7 != -1) |
3986 return (unsigned __int16)v7; | 3979 return (unsigned __int16)v7; |
3987 else return 0; | 3980 else return 0; |
3988 } | 3981 } |
3989 /*else // software impl | 3982 /*else // software impl |