diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 1ee494376b..5a891740dd 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -448,6 +448,8 @@ src/OpenSHC/Map/Units/UpdateHunter.cpp src/OpenSHC/Map/Units/UpdateAppleFarmer.cpp src/OpenSHC/Map/Units/UpdateJester.cpp src/OpenSHC/Map/Units/UpdateSlave.cpp +src/OpenSHC/Map/Entities/EntityState/angleToRotationFrameIndex.cpp +src/OpenSHC/Map/Entities/EntityState/updateProjectileHeightAndCollision.cpp src/OpenSHC/Map/Units/UpdateHealer.cpp src/OpenSHC/Map/Units/UpdateSpearman.cpp src/OpenSHC/Map/Units/UpdateSlinger.cpp @@ -457,3 +459,4 @@ src/OpenSHC/Map/Units/UpdatePoleTurner.cpp src/OpenSHC/Map/Units/UpdateBlacksmith.cpp src/OpenSHC/Map/Units/UpdateArmorer.cpp src/OpenSHC/Map/Units/UpdateTanner.cpp +src/OpenSHC/Map/Entities/IgniteFireAtMiniTile.cpp diff --git a/cmake/function-visibility.txt b/cmake/function-visibility.txt index b8706d92a7..5274facff6 100644 --- a/cmake/function-visibility.txt +++ b/cmake/function-visibility.txt @@ -431,3 +431,5 @@ OpenSHC::Map::Units::UpdateFireBallista OpenSHC::Map::Units::UnitsState::deselectUnit OpenSHC::Map::Units::UpdateHorseArcher OpenSHC::Map::Units::UnitsState::hasUnitReachedDestination +OpenSHC::Map::Entities::IgniteFireAtMiniTile + OpenSHC::Map::Entities::EntityState::getFireEntityIDAtTile diff --git a/src/OpenSHC/Map/Entities/EntityState/angleToRotationFrameIndex.cpp b/src/OpenSHC/Map/Entities/EntityState/angleToRotationFrameIndex.cpp new file mode 100644 index 0000000000..e333edeeb9 --- /dev/null +++ b/src/OpenSHC/Map/Entities/EntityState/angleToRotationFrameIndex.cpp @@ -0,0 +1,42 @@ +#include "../EntityState.func.hpp" + +namespace OpenSHC { +namespace Map { + namespace Entities { + + // FUNCTION: STRONGHOLDCRUSADER 0x00402BD0 + int EntityState::angleToRotationFrameIndex(int angle) + { + if (angle <= 5) { + if (angle <= -50) { + return 0; + } + if (angle <= -35) { + return 1; + } + if (angle <= -17) { + return 2; + } + if (angle <= -5) { + return 3; + } + } else { + if (angle <= 20) { + return 5; + } + if (angle <= 35) { + return 6; + } + if (angle <= 50) { + return 7; + } + if (angle <= 90) { + return 8; + } + } + return 4; + } + + } +} +} diff --git a/src/OpenSHC/Map/Entities/EntityState/calculateEntityDrawOffset.cpp b/src/OpenSHC/Map/Entities/EntityState/calculateEntityDrawOffset.cpp new file mode 100644 index 0000000000..3ca08cfb5f --- /dev/null +++ b/src/OpenSHC/Map/Entities/EntityState/calculateEntityDrawOffset.cpp @@ -0,0 +1,39 @@ +#include "../EntityState.func.hpp" + +#include "OpenSHC/Map/Enums/MapOrientation.hpp" + +#include "OpenSHC/Globals/DAT_EntityDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" + +namespace OpenSHC { +namespace Map { + namespace Entities { + + // FUNCTION: STRONGHOLDCRUSADER 0x004036F0 + void EntityState::calculateEntityDrawOffset(int entityID) + { + uint x = this->entityArray[entityID].microX & 7; + uint y = this->entityArray[entityID].microY & 7; + if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_SOUTH) { + x = 7 - x; + y = 7 - y; + } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_EAST) { + x = 7 - x; + } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_WEST) { + y = 7 - y; + } + if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_SOUTH + || DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_NORTH) { + x <<= 1; + y <<= 4; + } else { + x <<= 4; + y *= 2; + } + this->entityArray[entityID].x1 = DAT_EntityDefinedData::instance.EntitySubTileDrawOffsets[y + x].x; + this->entityArray[entityID].y1 = DAT_EntityDefinedData::instance.EntitySubTileDrawOffsets[y + x + 1].x; + } + + } +} +} diff --git a/src/OpenSHC/Map/Entities/EntityState/handleProjectileWallBounce.cpp b/src/OpenSHC/Map/Entities/EntityState/handleProjectileWallBounce.cpp new file mode 100644 index 0000000000..580de645f8 --- /dev/null +++ b/src/OpenSHC/Map/Entities/EntityState/handleProjectileWallBounce.cpp @@ -0,0 +1,384 @@ +#include "../EntityState.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Map/Navigation/DirectionAlgorithmState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/DE/SHCDE/eSFX.hpp" +#include "OpenSHC/Map/Entities/Enums/PathAxisCase.hpp" +#include "OpenSHC/Map/Enums/NeighbourMask.hpp" + +#include "OpenSHC/Globals/DAT_DirectionAlgorithmState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" + +#include "math.h" + +namespace OpenSHC { +namespace Map { + namespace Entities { + + // FUNCTION: STRONGHOLDCRUSADER 0x00403FF0 + void EntityState::handleProjectileWallBounce(int entityID) + { + int const microY = this->entityArray[entityID].microY; + int const microX = this->entityArray[entityID].microX; + int subX = microX & 7; + int targetX = 0; + int targetY = 0; + int subY = microY & 7; + uint const wallFlags = MACRO_CALL_MEMBER(Map::TileMapState_Func::setBitFlagBasedOnWallTowerGatehouseOrKeep, + DAT_TileMapState::ptr)(microX / 8, microY / 8); + // orientation - 60 is one of sixteen directions; 60, 64, 68 and 72 run along an axis and keep + // their target, the others bounce off the wall side the sub-tile position is closer to. + switch (this->entityArray[entityID].orientation) { + case 60: + case 64: + case 68: + case 72: + straight: + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + break; + case 61: + subY = 7 - subY; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_WEST: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + subY = 100; + break; + case (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 62: + subY = 7 - subY; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_WEST: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + subY = 100; + break; + case (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 63: + subY = 7 - subY; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_SOUTH: + subY = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_WEST: + subX = 100; + break; + case (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 65: + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_WEST)) { + case Map::Enums::NM_NORTH: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_WEST: + subY = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_WEST): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 66: + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_WEST)) { + case Map::Enums::NM_NORTH: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_WEST: + subY = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_WEST): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 67: + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_WEST)) { + case Map::Enums::NM_WEST: + subY = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_NORTH: + subX = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_WEST): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 69: + subX = 7 - subX; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_EAST)) { + case Map::Enums::NM_EAST: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_NORTH: + subY = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_EAST): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 70: + subX = 7 - subX; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_EAST)) { + case Map::Enums::NM_EAST: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_NORTH: + subY = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_EAST): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 71: + subX = 7 - subX; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_EAST)) { + case Map::Enums::NM_NORTH: + subY = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_EAST: + subX = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_EAST): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 73: + subX = 7 - subX; + subY = 7 - subY; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_SOUTH: + subY = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_EAST: + subX = 100; + break; + case (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 74: + subX = 7 - subX; + subY = 7 - subY; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_EAST: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + subY = 100; + break; + case (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 75: + subX = 7 - subX; + subY = 7 - subY; + if (subX == subY) { + switch (wallFlags & (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_EAST: + subX = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + subY = 100; + break; + case (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (subX > subY) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + } + MACRO_CALL_MEMBER(Map::Navigation::DirectionAlgorithmState_Func::somethingWithProjectileDistance, + DAT_DirectionAlgorithmState::ptr)(microX, microY, targetX, targetY); + this->entityArray[entityID].orientation = DAT_DirectionAlgorithmState::instance.orientation; + if (microY > targetY) { + this->entityArray[entityID].pathDeltaY = microY - targetY; + } else { + this->entityArray[entityID].pathDeltaY = targetY - microY; + } + if (microX > targetX) { + this->entityArray[entityID].pathDeltaX = microX - targetX; + } else { + this->entityArray[entityID].pathDeltaX = targetX - microX; + } + this->entityArray[entityID].pathTargetX = targetX; + this->entityArray[entityID].someMicroX = microX <= targetX ? 1 : -1; + this->entityArray[entityID].pathTargetY = targetY; + this->entityArray[entityID].someMicroY = microY <= targetY ? 1 : -1; + if (this->entityArray[entityID].pathDeltaX == 0 && this->entityArray[entityID].pathDeltaY == 0) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_NONE; + } else if (this->entityArray[entityID].pathDeltaX == 0) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_VERTICAL; + } else if (this->entityArray[entityID].pathDeltaY == 0) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_HORIZONTAL; + } else if (this->entityArray[entityID].pathDeltaY > this->entityArray[entityID].pathDeltaX) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_Y_MAJOR; + } else { + this->entityArray[entityID].pathAxisCase = Enums::PAC_X_MAJOR; + } + if (this->entityArray[entityID].pathAxisCase == Enums::PAC_Y_MAJOR) { + this->entityArray[entityID].pathErrorStepStraight = this->entityArray[entityID].pathDeltaX * 2; + this->entityArray[entityID].pathErrorStepDiagonal + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaY * 2; + this->entityArray[entityID].pathError + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaY; + } else if (this->entityArray[entityID].pathAxisCase == Enums::PAC_X_MAJOR) { + this->entityArray[entityID].pathErrorStepStraight = this->entityArray[entityID].pathDeltaY * 2; + this->entityArray[entityID].pathErrorStepDiagonal + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaX * 2; + this->entityArray[entityID].pathError + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaX; + } + short const rotation = this->entityArray[entityID].graphicRotationUnk; + this->entityArray[entityID].startingAngle = rotation; + if (rotation < -80) { + this->entityArray[entityID].startingAngle = -80; + } + int const angle = this->entityArray[entityID].startingAngle; + this->entityArray[entityID].speedUnk = 0; + double const radians = angle * 3.1415926535 / 180.0; + short const velocity = (this->entityArray[entityID].velocityUnk / 8); + this->entityArray[entityID].velocityUnk = velocity; + this->entityArray[entityID].startingHeight = this->entityArray[entityID].height; + this->entityArray[entityID].travelledDistance = 0; + this->entityArray[entityID].vCos = (float)(this->entityArray[entityID].velocityUnk * cos(radians)); + this->entityArray[entityID].vSin = (float)(this->entityArray[entityID].velocityUnk * sin(radians)); + this->entityArray[entityID].rotationFrameIndex + = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::angleToRotationFrameIndex, this)(angle); + this->entityArray[entityID].gmLookupValue = 0; + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playSFXAtLocation, DAT_SFXState::ptr)( + this->entityArray[entityID].xPosition, this->entityArray[entityID].yPosition, + DE::SHCDE::FX_ARROW_BOUNCE); + } + + } +} +} diff --git a/src/OpenSHC/Map/Entities/EntityState/initializeProjectileVelocities.cpp b/src/OpenSHC/Map/Entities/EntityState/initializeProjectileVelocities.cpp new file mode 100644 index 0000000000..1adcc30cbe --- /dev/null +++ b/src/OpenSHC/Map/Entities/EntityState/initializeProjectileVelocities.cpp @@ -0,0 +1,176 @@ +#include "../EntityState.func.hpp" + +#include "OpenSHC/Map/Entities/EntityType.hpp" +#include "OpenSHC/Map/Entities/Enums/PathAxisCase.hpp" + +#include "OpenSHC/Globals/DAT_EntityDefinedData.hpp" + +#include "math.h" + +namespace OpenSHC { +namespace Map { + namespace Entities { + + // FUNCTION: STRONGHOLDCRUSADER 0x00403A20 + void EntityState::initializeProjectileVelocities( + int entityID, int x, int y, int height, int targetX, int targetY, int targetZ) + { + if (y > targetY) { + this->entityArray[entityID].pathDeltaY = y - targetY; + } else { + this->entityArray[entityID].pathDeltaY = targetY - y; + } + if (x > targetX) { + this->entityArray[entityID].pathDeltaX = x - targetX; + } else { + this->entityArray[entityID].pathDeltaX = targetX - x; + } + if (this->entityArray[entityID].height >= this->entityArray[entityID].targetZ) { + this->entityArray[entityID].pathDeltaZ + = this->entityArray[entityID].height - this->entityArray[entityID].targetZ; + } else { + this->entityArray[entityID].pathDeltaZ + = this->entityArray[entityID].targetZ - this->entityArray[entityID].height; + } + this->entityArray[entityID].pathTargetX = targetX; + this->entityArray[entityID].pathTargetY = targetY; + this->entityArray[entityID].someMicroX = x <= targetX ? 1 : -1; + this->entityArray[entityID].someMicroY = y <= targetY ? 1 : -1; + if (this->entityArray[entityID].pathDeltaX == 0 && this->entityArray[entityID].pathDeltaY == 0) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_NONE; + } else if (this->entityArray[entityID].pathDeltaX == 0) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_VERTICAL; + } else if (this->entityArray[entityID].pathDeltaY == 0) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_HORIZONTAL; + } else if (this->entityArray[entityID].pathDeltaY > this->entityArray[entityID].pathDeltaX) { + this->entityArray[entityID].pathAxisCase = Enums::PAC_Y_MAJOR; + } else { + this->entityArray[entityID].pathAxisCase = Enums::PAC_X_MAJOR; + } + if (this->entityArray[entityID].pathAxisCase == Enums::PAC_Y_MAJOR) { + this->entityArray[entityID].pathErrorStepStraight = this->entityArray[entityID].pathDeltaX * 2; + this->entityArray[entityID].pathErrorStepDiagonal + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaY * 2; + this->entityArray[entityID].pathError + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaY; + } else if (this->entityArray[entityID].pathAxisCase == Enums::PAC_X_MAJOR) { + this->entityArray[entityID].pathErrorStepStraight = this->entityArray[entityID].pathDeltaY * 2; + this->entityArray[entityID].pathErrorStepDiagonal + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaX * 2; + this->entityArray[entityID].pathError + = this->entityArray[entityID].pathErrorStepStraight - this->entityArray[entityID].pathDeltaX; + } + int const curveType = DAT_EntityDefinedData::instance + .EntityArrayCurveTypeForProjectileType[this->entityArray[entityID].entityType]; + if (curveType == 0) { + int const distanceRaw = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::computeLineOfSightDistance, + this)(x, y, height, targetX, targetY, targetZ, 1); + this->entityArray[entityID].field_0x94 = distanceRaw; + this->entityArray[entityID].totalFlightDistance = distanceRaw; + this->entityArray[entityID].clearanceStepsRemaining = this->lineOfSightClearanceSteps; + short const distance = distanceRaw; + this->entityArray[entityID].startingAngle = MACRO_CALL_MEMBER( + Map::Entities::EntityState_Func::math_atan_1, this)(this->entityArray[entityID].entityType, + this->entityArray[entityID].velocityUnk, distance, this->entityArray[entityID].heightDifference); + } else if (curveType == 1) { + int const distanceRaw = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::computeLineOfSightDistance, + this)(x, y, height, targetX, targetY, targetZ, 1); + this->entityArray[entityID].field_0x94 = distanceRaw; + this->entityArray[entityID].totalFlightDistance = distanceRaw; + this->entityArray[entityID].clearanceStepsRemaining = this->lineOfSightClearanceSteps; + short const distance = distanceRaw; + this->entityArray[entityID].velocityUnk = MACRO_CALL_MEMBER( + Map::Entities::EntityState_Func::computeVelocity, this)(this->entityArray[entityID].entityType, + this->entityArray[entityID].startingAngle, distance, this->entityArray[entityID].heightDifference); + } else if (curveType == 2) { + int const distanceRaw = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::computeLineOfSightDistance, + this)(x, y, height, targetX, targetY, targetZ, 1); + this->entityArray[entityID].field_0x94 = distanceRaw; + this->entityArray[entityID].totalFlightDistance = distanceRaw; + this->entityArray[entityID].clearanceStepsRemaining = this->lineOfSightClearanceSteps; + short const distance = distanceRaw; + // from above, aim low first + if (this->entityArray[entityID].height > this->entityArray[entityID].targetZ) { + this->entityArray[entityID].startingAngle = 3; + } + int const heightDifference = this->entityArray[entityID].heightDifference; + this->entityArray[entityID].velocityUnk = MACRO_CALL_MEMBER( + Map::Entities::EntityState_Func::computeVelocity, this)(this->entityArray[entityID].entityType, + this->entityArray[entityID].startingAngle, distance, heightDifference); + if (this->entityArray[entityID].velocityUnk <= 0) { + int const type = this->entityArray[entityID].entityType; + this->entityArray[entityID].startingAngle = 15; + this->entityArray[entityID].velocityUnk = MACRO_CALL_MEMBER( + Map::Entities::EntityState_Func::computeVelocity, this)(type, 15.0, distance, heightDifference); + } + } else if (curveType == 3) { + ushort const rng = this->entityArray[entityID].rng_1; + this->entityArray[entityID].startingAngle = (rng & 0xf) + 8; + this->entityArray[entityID].velocityUnk = (rng & 7) + 21; + } else if (curveType == 4) { + this->entityArray[entityID].startingAngle = (this->entityArray[entityID].rng_1 % 20 + 16); + if (this->entityArray[entityID].rng_1 & 0x80) { + this->entityArray[entityID].startingAngle = -this->entityArray[entityID].startingAngle; + } + this->entityArray[entityID].velocityUnk = ((this->entityArray[entityID].rng_1 >> 8) % 20 + 16); + if (this->entityArray[entityID].rng_1 & 0x8000) { + this->entityArray[entityID].velocityUnk = -this->entityArray[entityID].velocityUnk; + } + return; + } else if (curveType == 5) { + this->entityArray[entityID].velocityUnk = 0; + this->entityArray[entityID].startingAngle = this->entityArray[entityID].rng_1 & 7; + this->entityArray[entityID].graphicRotationUnk = ((this->entityArray[entityID].rng_1 >> 8) & 0x3f); + return; + } else if (curveType == 6) { + int const distanceRaw = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::computeLineOfSightDistance, + this)(x, y, height, targetX, targetY, targetZ, 1); + this->entityArray[entityID].field_0x94 = distanceRaw; + this->entityArray[entityID].totalFlightDistance = distanceRaw; + this->entityArray[entityID].clearanceStepsRemaining = this->lineOfSightClearanceSteps; + short const distance = distanceRaw; + if (distance > 150) { + this->entityArray[entityID].velocityUnk = 125; + } + this->entityArray[entityID].startingAngle = MACRO_CALL_MEMBER( + Map::Entities::EntityState_Func::math_atan_1, this)(this->entityArray[entityID].entityType, + this->entityArray[entityID].velocityUnk, distance, this->entityArray[entityID].heightDifference); + } else if (curveType == 7 || curveType == 10) { + return; + } else if (curveType == 8) { + if (this->entityArray[entityID].unitID_OR_seaGullID == 0) { + this->entityArray[entityID].startingAngle = this->entityArray[entityID].rng_1 % 60 + 8; + this->entityArray[entityID].velocityUnk = (this->entityArray[entityID].rng_1 & 7) + 35; + } else if (this->entityArray[entityID].unitID_OR_seaGullID == 4) { + this->entityArray[entityID].startingAngle = this->entityArray[entityID].rng_1 % 30 + 15; + this->entityArray[entityID].velocityUnk = (this->entityArray[entityID].rng_1 & 7) + 15; + this->entityArray[entityID]._elapsedTimeOrGravityAccumulator *= 0.75; + } else if (this->entityArray[entityID].unitID_OR_seaGullID == 5) { + this->entityArray[entityID].startingAngle = this->entityArray[entityID].rng_1 % 30 + 45; + this->entityArray[entityID].velocityUnk = (this->entityArray[entityID].rng_1 & 7) + 35; + } else { + this->entityArray[entityID].startingAngle = this->entityArray[entityID].rng_1 % 35 + 20; + this->entityArray[entityID].velocityUnk = (this->entityArray[entityID].rng_1 & 7) + 25; + this->entityArray[entityID]._elapsedTimeOrGravityAccumulator *= 0.75; + } + } else if (curveType == 9) { + this->entityArray[entityID].startingAngle = 0; + } + if ((this->entityArray[entityID].entityType == Map::Entities::ET_ARROW_AND_DEFAULT + || this->entityArray[entityID].entityType == Map::Entities::ET_CROSSBOWARROW) + && height + 54 < targetZ && this->entityArray[entityID].rng_1 % 10 == 5) { + this->entityArray[entityID].hasDoneEffectUnk = 1; + } + int const angle = this->entityArray[entityID].startingAngle; + this->entityArray[entityID].speedUnk = 0; + this->entityArray[entityID].travelledDistance = 0; + double const radians = angle * 3.1415926535 / 180.0; + this->entityArray[entityID].vCos = (float)(cos(radians) * this->entityArray[entityID].velocityUnk); + this->entityArray[entityID].vSin = (float)(sin(radians) * this->entityArray[entityID].velocityUnk); + this->entityArray[entityID].rotationFrameIndex + = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::angleToRotationFrameIndex, this)(angle); + } + + } +} +} diff --git a/src/OpenSHC/Map/Entities/EntityState/spawnProjectileImpactDebris.cpp b/src/OpenSHC/Map/Entities/EntityState/spawnProjectileImpactDebris.cpp new file mode 100644 index 0000000000..c2d97d375b --- /dev/null +++ b/src/OpenSHC/Map/Entities/EntityState/spawnProjectileImpactDebris.cpp @@ -0,0 +1,323 @@ +#include "../EntityState.func.hpp" + +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/Entities/EntityType.hpp" +#include "OpenSHC/Map/Enums/NeighbourMask.hpp" + +#include "OpenSHC/Globals/DAT_TileMapState.hpp" + +namespace OpenSHC { +namespace Map { + namespace Entities { + + // FUNCTION: STRONGHOLDCRUSADER 0x00405DA0 + void EntityState::spawnProjectileImpactDebris(int entityID) + { + int const microX = this->entityArray[entityID].microX; + int const microY = this->entityArray[entityID].microY; + int targetX = 0; + int targetY = 0; + int y = microY & 7; + int x = microX & 7; + uint const wallFlags = MACRO_CALL_MEMBER(Map::TileMapState_Func::setBitFlagBasedOnWallTowerGatehouseOrKeep, + DAT_TileMapState::ptr)(microX / 8, microY / 8); + // orientation - 60 is one of sixteen directions; 60, 64, 68 and 72 run along an axis and keep + // their target, the others bounce off the wall side the sub-tile position is closer to. + switch (this->entityArray[entityID].orientation) { + case 60: + case 64: + case 68: + case 72: + straight: + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + break; + case 61: + y = 7 - y; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_WEST: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + y = 100; + break; + case (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 62: + y = 7 - y; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_WEST: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + y = 100; + break; + case (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 63: + y = 7 - y; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_SOUTH: + y = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_WEST: + x = 100; + break; + case (Map::Enums::NM_WEST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 65: + if (x == y) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_WEST)) { + case Map::Enums::NM_NORTH: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_WEST: + y = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_WEST): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 66: + if (x == y) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_WEST)) { + case Map::Enums::NM_NORTH: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_WEST: + y = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_WEST): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 67: + if (x == y) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_WEST)) { + case Map::Enums::NM_WEST: + y = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_NORTH: + x = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_WEST): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 69: + x = 7 - x; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_EAST)) { + case Map::Enums::NM_EAST: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_NORTH: + y = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_EAST): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 70: + x = 7 - x; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_EAST)) { + case Map::Enums::NM_EAST: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_NORTH: + y = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_EAST): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 71: + x = 7 - x; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_NORTH | Map::Enums::NM_EAST)) { + case Map::Enums::NM_NORTH: + y = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_EAST: + x = 100; + break; + case (Map::Enums::NM_NORTH | Map::Enums::NM_EAST): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 73: + x = 7 - x; + y = 7 - y; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_SOUTH: + y = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_EAST: + x = 100; + break; + case (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 74: + x = 7 - x; + y = 7 - y; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_EAST: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + y = 100; + break; + case (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + case 75: + x = 7 - x; + y = 7 - y; + if (x == y) { + switch (wallFlags & (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH)) { + case Map::Enums::NM_EAST: + x = 100; + break; + case Map::Enums::NM_NONE: + case Map::Enums::NM_SOUTH: + y = 100; + break; + case (Map::Enums::NM_EAST | Map::Enums::NM_SOUTH): + goto straight; + } + } + if (x > y) { + targetX = this->entityArray[entityID].microX * 2 - this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].y_2; + } else { + targetX = this->entityArray[entityID].x_2; + targetY = this->entityArray[entityID].microY * 2 - this->entityArray[entityID].y_2; + } + break; + } + for (int i = 0; i < this->entityArray[entityID].rng_1 % 8 + 5; i++) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::spawnProjectileEntity, this)(0, 0, 0, microX, microY, + this->entityArray[entityID].height, targetX, targetY, 8, (EntityType)27, 0); + } + int const height = this->entityArray[entityID].height; + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::spawnProjectileEntity, this)( + 0, 0, 0, microX, microY, height, microX + 1, microY + 1, height, ET_UNKNOWN_30, 0); + } + + } +} +} diff --git a/src/OpenSHC/Map/Entities/EntityState/updateEntities.cpp b/src/OpenSHC/Map/Entities/EntityState/updateEntities.cpp new file mode 100644 index 0000000000..1878f4b8bd --- /dev/null +++ b/src/OpenSHC/Map/Entities/EntityState/updateEntities.cpp @@ -0,0 +1,252 @@ +#include "../EntityState.func.hpp" + +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Map/Entities/EntityType.hpp" + +#include "OpenSHC/Globals/DAT_CurrentEntityID.hpp" +#include "OpenSHC/Globals/DAT_EntityDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace Map { + namespace Entities { + + // FUNCTION: STRONGHOLDCRUSADER 0x004087C0 + void EntityState::updateEntities() + { + if (DAT_GameState::instance.gameTicksLoadBalancer % 10 == 0) { + this->everyTenTicks = 25; + } + this->totalEntityCount = 0; + int newMaxEntityCount = 0; + for (DAT_CurrentEntityID::instance = 1; (int)DAT_CurrentEntityID::instance < this->maxEntityCount; + DAT_CurrentEntityID::instance++) { + if (this->entityArray[DAT_CurrentEntityID::instance].logicalState == 0) { + continue; + } + newMaxEntityCount = DAT_CurrentEntityID::instance + 1; + this->totalEntityCount++; + switch (this->entityArray[DAT_CurrentEntityID::instance].logicalState) { + case 1: + this->entityArray[DAT_CurrentEntityID::instance].logicalState = 2; + break; + case 5: + this->entityArray[DAT_CurrentEntityID::instance].logicalState = 6; + break; + case 4: + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::activateProjectileEntity, this)( + DAT_CurrentEntityID::instance); + break; + case 7: + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::tickEntityDecayCounter, this)( + DAT_CurrentEntityID::instance); + continue; + case 8: + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::tickEntityDecayCounter, this)( + DAT_CurrentEntityID::instance); + break; + case 3: + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::deleteEntity, this)( + DAT_CurrentEntityID::instance); + continue; + } + if (DAT_CurrentEntityID::instance + == this->entityArray[DAT_CurrentEntityID::instance].nextEntityOnThisTileByID) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::deleteEntity, this)( + DAT_CurrentEntityID::instance); + continue; + } + if (this->entityArray[DAT_CurrentEntityID::instance].field_0x12 + >= this->entityArray[DAT_CurrentEntityID::instance].unkOne_1) { + this->entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated++; + this->entityArray[DAT_CurrentEntityID::instance].field_0x12 = 0; + } + this->entityArray[DAT_CurrentEntityID::instance].field_0x12++; + if (this->entityArray[DAT_CurrentEntityID::instance].logicalState != 6) { + switch (this->entityArray[DAT_CurrentEntityID::instance].entityType) { + case Map::Entities::ET_FIRE: + break; + case Map::Entities::ET_DUST_CLOUD: + if (this->entityArray[DAT_CurrentEntityID::instance].unitID != 2) { + if (this->entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated & 1) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::doSomethingWithOtherEntitiesOnTile, + this)(DAT_CurrentEntityID::instance); + this->entityArray[DAT_CurrentEntityID::instance].height++; + short const stepX = this->entityArray[DAT_CurrentEntityID::instance].startingAngle; + int const frameX + = this->entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated; + if (stepX < 0) { + if (frameX % stepX == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microX--; + } + } else if (frameX % stepX == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microX++; + } + short const stepY = this->entityArray[DAT_CurrentEntityID::instance].velocityUnk; + int const frameY + = this->entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated; + if (stepY < 0) { + if (frameY % stepY == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microY--; + } + } else if (frameY % stepY == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microY++; + } + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::processEntityHitBuildingOrUnit, + this)(DAT_CurrentEntityID::instance); + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::calculateEntityDrawOffset, this)( + DAT_CurrentEntityID::instance); + } + } else { + if (this->entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated & 1) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::doSomethingWithOtherEntitiesOnTile, + this)(DAT_CurrentEntityID::instance); + this->entityArray[DAT_CurrentEntityID::instance].height++; + int const frameX + = this->entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated; + short const stepX = this->entityArray[DAT_CurrentEntityID::instance].startingAngle; + if (stepX < 0) { + if (frameX % stepX == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microX--; + } + } else if (frameX % stepX == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microX++; + } + short const stepY = this->entityArray[DAT_CurrentEntityID::instance].velocityUnk; + int const frameY + = this->entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated; + if (stepY < 0) { + if (frameY % stepY == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microY--; + } + } else if (frameY % stepY == 0) { + this->entityArray[DAT_CurrentEntityID::instance].microY++; + } + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::processEntityHitBuildingOrUnit, + this)(DAT_CurrentEntityID::instance); + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::calculateEntityDrawOffset, this)( + DAT_CurrentEntityID::instance); + } + } + break; + case Map::Entities::EntityTypeInt__ET_EXPLOSION: + case Map::Entities::ET_GOLD_POPUP: + case Map::Entities::ET_POPULARITY_POPUP: + case Map::Entities::ET_TRADE_BUY_POPUP: + case Map::Entities::ET_TRADE_SELL_POPUP: + this->entityArray[DAT_CurrentEntityID::instance].height++; + break; + case Map::Entities::ET_COW_POISON_CLOUD: + this->entityArray[DAT_CurrentEntityID::instance].velocityUnk++; + if (this->entityArray[DAT_CurrentEntityID::instance].velocityUnk > 30) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::doSomethingWithOtherEntitiesOnTile, + this)(DAT_CurrentEntityID::instance); + if (this->entityArray[DAT_CurrentEntityID::instance].velocityUnk != 1000) { + this->entityArray[DAT_CurrentEntityID::instance].graphicRotationUnk--; + if (this->entityArray[DAT_CurrentEntityID::instance].graphicRotationUnk <= 0) { + this->entityArray[DAT_CurrentEntityID::instance].graphicRotationUnk + = (SEC_RNG::instance.currentNumber2 >> 8) & 0x3f; + this->entityArray[DAT_CurrentEntityID::instance].startingAngle + = (SEC_RNG::instance.currentNumber2 >> 4) & 7; + MACRO_CALL_MEMBER(Random::RNG_Func::nextRandomNumber2, SEC_RNG::ptr)(); + } + } + this->entityArray[DAT_CurrentEntityID::instance].velocityUnk = 0; + switch (this->entityArray[DAT_CurrentEntityID::instance].startingAngle) { + case 0: + this->entityArray[DAT_CurrentEntityID::instance].microY--; + break; + case 4: + this->entityArray[DAT_CurrentEntityID::instance].microY++; + break; + case 2: + this->entityArray[DAT_CurrentEntityID::instance].microX++; + break; + case 6: + this->entityArray[DAT_CurrentEntityID::instance].microX--; + break; + case 7: + this->entityArray[DAT_CurrentEntityID::instance].microX--; + this->entityArray[DAT_CurrentEntityID::instance].microY--; + break; + case 1: + this->entityArray[DAT_CurrentEntityID::instance].microX++; + this->entityArray[DAT_CurrentEntityID::instance].microY--; + break; + case 5: + this->entityArray[DAT_CurrentEntityID::instance].microX--; + this->entityArray[DAT_CurrentEntityID::instance].microY++; + break; + case 3: + this->entityArray[DAT_CurrentEntityID::instance].microX++; + this->entityArray[DAT_CurrentEntityID::instance].microY++; + break; + } + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::processEntityHitBuildingOrUnit, this)( + DAT_CurrentEntityID::instance); + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::calculateEntityDrawOffset, this)( + DAT_CurrentEntityID::instance); + } + this->entityArray[DAT_CurrentEntityID::instance].height + = DAT_TileMapState::instance + .HeightLayer[this->entityArray[DAT_CurrentEntityID::instance].tile] + + 20; + break; + case Map::Entities::ET_FLAG_1: + case Map::Entities::ET_FLAG_4: + case Map::Entities::ET_FLAG_2: + case Map::Entities::ET_FLAG_3: + case Map::Entities::ET_BRAZIER: + case Map::Entities::ET_HEADS_ON_SPIKES: + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::doSomethingWithOtherEntitiesOnTile, this)( + DAT_CurrentEntityID::instance); + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::processEntityHitBuildingOrUnit, this)( + DAT_CurrentEntityID::instance); + break; + default: + this->entityArray[DAT_CurrentEntityID::instance].screenDirection + = this->entityArray[DAT_CurrentEntityID::instance].orientation - 60; + this->entityArray[DAT_CurrentEntityID::instance].screenDirection + -= DAT_TileMapState::instance.mapOrientation * 2; + if (this->entityArray[DAT_CurrentEntityID::instance].screenDirection < 0) { + this->entityArray[DAT_CurrentEntityID::instance].screenDirection += 16; + } + if (this->entityArray[DAT_CurrentEntityID::instance].speedUnk != 0.0 + && this->entityArray[DAT_CurrentEntityID::instance].gmLookupValue != 0 + && this->entityArray[DAT_CurrentEntityID::instance].someCounter_OR_hitGround == 0) { + if (this->entityArray[DAT_CurrentEntityID::instance].gmLookupValue != 3) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::spawnEntityEffect2, this)( + this->entityArray[DAT_CurrentEntityID::instance].microX, + this->entityArray[DAT_CurrentEntityID::instance].microY, + this->entityArray[DAT_CurrentEntityID::instance].height, (EntityType)5, + this->entityArray[DAT_CurrentEntityID::instance].gmLookupValue); + } else { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::spawnEntityEffect1, this)( + this->entityArray[DAT_CurrentEntityID::instance].microX, + this->entityArray[DAT_CurrentEntityID::instance].microY, + this->entityArray[DAT_CurrentEntityID::instance].height, (EntityType)6, + this->entityArray[DAT_CurrentEntityID::instance].gmID, + this->entityArray[DAT_CurrentEntityID::instance].graphicType2); + } + } + if (this->entityArray[DAT_CurrentEntityID::instance].someCounter_OR_hitGround == 0) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::moveProjectileEntity, this)( + DAT_CurrentEntityID::instance); + } + } + } + DAT_EntityDefinedData::instance + .EntityCallbacks[this->entityArray[DAT_CurrentEntityID::instance].entityType](); + if (this->entityArray[DAT_CurrentEntityID::instance].entityType == Map::Entities::ET_SEAGULLUnk) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::processSeaGulls, this)( + this->entityArray[DAT_CurrentEntityID::instance].unitID_OR_seaGullID); + } + } + this->maxEntityCount = newMaxEntityCount; + } + + } +} +} diff --git a/src/OpenSHC/Map/Entities/EntityState/updateProjectileHeightAndCollision.cpp b/src/OpenSHC/Map/Entities/EntityState/updateProjectileHeightAndCollision.cpp new file mode 100644 index 0000000000..1b2c239bfc --- /dev/null +++ b/src/OpenSHC/Map/Entities/EntityState/updateProjectileHeightAndCollision.cpp @@ -0,0 +1,28 @@ +#include "../EntityState.func.hpp" + +namespace OpenSHC { +namespace Map { + namespace Entities { + + // FUNCTION: STRONGHOLDCRUSADER 0x004081E0 + void EntityState::updateProjectileHeightAndCollision( + uint entityID, undefined4 heightOffset, int angle, int skipCollision) + { + this->entityArray[entityID].height = this->entityArray[entityID].startingHeight + heightOffset; + if (this->entityArray[entityID].height <= 2 && !skipCollision) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::doSomethingWithOtherEntitiesOnTile, this)(entityID); + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::processEntityHitBuildingOrUnit, this)(entityID); + } + short const currentHeight = this->entityArray[entityID].height; + if (currentHeight > 10000) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::markEntityDestroyed, this)(entityID); + return; + } + this->entityArray[entityID].rotationFrameIndex + = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::angleToRotationFrameIndex, this)(angle); + this->entityArray[entityID].height_2 = currentHeight; + } + + } +} +} diff --git a/src/OpenSHC/Map/Entities/IgniteFireAtMiniTile.cpp b/src/OpenSHC/Map/Entities/IgniteFireAtMiniTile.cpp new file mode 100644 index 0000000000..988f580007 --- /dev/null +++ b/src/OpenSHC/Map/Entities/IgniteFireAtMiniTile.cpp @@ -0,0 +1,91 @@ +#include "../Entities.func.hpp" + +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Map/Entities/EntityState.func.hpp" +#include "OpenSHC/Map/LandscapeState.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Map/Entities/EntityType.hpp" +#include "OpenSHC/Map/LogicHelpers/Logic1.hpp" +#include "OpenSHC/Map/MapConstants.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_EntityDefinedData.hpp" +#include "OpenSHC/Globals/DAT_EntityState.hpp" +#include "OpenSHC/Globals/DAT_LandscapeState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x004052E0 + uint Entities::IgniteFireAtMiniTile( + int playerID, int miniTileX, int miniTileY, int tileHeightMin8, int fireParameter, int fireIntensity) + { + uint const randomJitter = SEC_RNG::instance.currentNumber2; + MACRO_CALL_MEMBER(Random::RNG_Func::nextRandomNumber2, SEC_RNG::ptr)(); + miniTileX += DAT_EntityDefinedData::instance.XYOffsetsInAllDirections[randomJitter & 0x3f][0]; + miniTileY += DAT_EntityDefinedData::instance.XYOffsetsInAllDirections[randomJitter & 0x3f][1]; + uint const x = miniTileX / 8; + uint const y = miniTileY / 8; + if (x > MC_MAP_XY_LIMIT_INCLUSIVE || y > MC_MAP_XY_LIMIT_INCLUSIVE) { + return 0; + } + if (DAT_ViewportRenderState::instance.DAT_BinaryTileMap400x400[y * MC_MAP_XY_LIMIT + x] == 0) { + return 0; + } + int const tile = DAT_ViewportRenderState::instance.translationMatrix[y].addXgetTile + x; + if (!(DAT_TileMapState::instance.LogicLayer[tile] + & (LogicHelpers::L_SEA | LogicHelpers::L_BORDER | LogicHelpers::L_BORDER_EDGE + | LogicHelpers::L_WALL_OR_GATEHOUSE | LogicHelpers::L_RIVER | LogicHelpers::L_FORD + | LogicHelpers::L_KEEP_NON_MANOR_HOUSE))) { + short const buildingID = DAT_TileMapState::instance.BuildingLayer[tile]; + if (buildingID) { + switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + return 0; + } + } + int const fireID + = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::getFireEntityIDAtTile, DAT_EntityState::ptr)(tile); + if (fireID) { + DAT_EntityState::instance.entityArray[fireID].someTracker = 0; + if (fireParameter > DAT_EntityState::instance.entityArray[fireID].fireParameter_0xb6) { + DAT_EntityState::instance.entityArray[fireID].fireParameter_0xb6 = fireParameter; + } + DAT_EntityState::instance.entityArray[fireID].unknownAnimationFrameRelated = 0; + return 0; + } + if (buildingID) { + MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func::lightUpBuilding, DAT_BuildingsState::ptr)( + buildingID, playerID, fireIntensity); + } + if (DAT_TileMapState::instance.LogicLayer[tile] & LogicHelpers::L_TREE) { + MACRO_CALL_MEMBER(Map::LandscapeState_Func::lightUpTree, DAT_LandscapeState::ptr)(tile, playerID); + } + uint const entityID + = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::spawnProjectileEntity, DAT_EntityState::ptr)( + 0, playerID, 0, miniTileX, miniTileY, tileHeightMin8, 0, 0, 0, Map::Entities::ET_FIRE, 0); + if (fireParameter >= 3 && !(DAT_TileMapState::instance.RandomLayer[tile] & 3)) { + MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::spawnProjectileEntity, DAT_EntityState::ptr)(0, + playerID, 0, miniTileX, miniTileY, tileHeightMin8, 0, 0, 0, + Map::Entities::EntityTypeInt__ET_EXPLOSION, 0); + } + if (entityID) { + DAT_EntityState::instance.entityArray[entityID].fireParameter_0xb6 = fireParameter; + DAT_EntityState::instance.entityArray[entityID].fireIntensity = fireIntensity; + } + return entityID; + } + return 0; + } + +} +} diff --git a/src/OpenSHC/Map/Entities/UpdateEntity_CowFlying.cpp b/src/OpenSHC/Map/Entities/UpdateEntity_CowFlying.cpp new file mode 100644 index 0000000000..abedd8b9b2 --- /dev/null +++ b/src/OpenSHC/Map/Entities/UpdateEntity_CowFlying.cpp @@ -0,0 +1,46 @@ +#include "../Entities.func.hpp" + +#include "OpenSHC/Globals/DAT_CurrentEntityID.hpp" +#include "OpenSHC/Globals/DAT_EntityState.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x00402180 + void Entities::UpdateEntity_CowFlying() + { + int const entityID = DAT_CurrentEntityID::instance; + if (DAT_EntityState::instance.entityArray[entityID].someCounter_OR_hitGround != 0) { + if (DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated < 100) { + DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated = 100; + } + if (DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated >= 120) { + DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated = 119; + } + short* const counter = &DAT_EntityState::instance.entityArray[entityID].someCounter_OR_hitGround; + (*counter)--; + if (*counter <= 0) { + DAT_EntityState::instance.entityArray[entityID].logicalState = 7; + } + DAT_EntityState::instance.entityArray[entityID].graphicType2 + = (DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated - 100) / 4 + 12 + + DAT_EntityState::instance.entityArray[entityID].graphicType2RelatedOffset; + DAT_EntityState::instance.entityArray[entityID].imageID = 0; + } else { + if (DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated >= 12) { + DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated = 0; + } + DAT_EntityState::instance.entityArray[entityID].graphicType2 + = DAT_EntityState::instance.entityArray[entityID].graphicType2RelatedOffset + + DAT_EntityState::instance.entityArray[entityID].unknownAnimationFrameRelated; + DAT_EntityState::instance.entityArray[entityID].imageID + = (DAT_EntityState::instance.entityArray[entityID].graphicType2 + 17); + } + if (DAT_EntityState::instance.entityArray[entityID].orientation == 76) { + DAT_EntityState::instance.entityArray[entityID].orientation = 60; + DAT_EntityState::instance.entityArray[entityID].logicalState = 7; + } + } + +} +} diff --git a/src/OpenSHC/Map/Entities/UpdateFlag_1_2_4_Entity.cpp b/src/OpenSHC/Map/Entities/UpdateFlag_1_2_4_Entity.cpp new file mode 100644 index 0000000000..fdb3f6caa6 --- /dev/null +++ b/src/OpenSHC/Map/Entities/UpdateFlag_1_2_4_Entity.cpp @@ -0,0 +1,78 @@ +#include "../Entities.func.hpp" + +#include "OpenSHC/AI/AIRecruitUnitChoice.hpp" +#include "OpenSHC/AI/AIRecruitUnitChoiceInt.hpp" +#include "OpenSHC/Game/GameMode.hpp" + +#include "OpenSHC/Globals/DAT_CurrentEntityID.hpp" +#include "OpenSHC/Globals/DAT_EntityDefinedData.hpp" +#include "OpenSHC/Globals/DAT_EntityState.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LandscapeState.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x00402900 + void Entities::UpdateFlag_1_2_4_Entity() + { + int nextTracker = DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].someTracker; + int const owner = DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].owner; + DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].graphicType2 + = DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].graphicType2RelatedOffset; + if ((DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].yPosition & 0x1f) + >= DAT_LandscapeState::instance.wind.countdown) { + nextTracker = DAT_LandscapeState::instance.wind.value; + } + if (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentPlayerFullIDArray[owner] == -1 + && DAT_GameSynchronyState::instance.currentAIArray[owner] != 0) { + if (DAT_GameState::instance.playerDataArray[owner].aiBuildingDestroyChoiceTracker != 0) { + nextTracker = 3; + } else if (DAT_GameState::instance.playerDataArray[owner].aiNervousActionsTracker != 0) { + nextTracker = 3; + } else { + AI::AIRecruitUnitChoiceInt const recruitChoice + = DAT_GameState::instance.playerDataArray[owner].aiRecruitUnitChoiceState; + nextTracker = 0; + if (recruitChoice != AI::AIRUC_DEFENSIVE) { + nextTracker = (recruitChoice != AI::AIRUC_RAIDING) + 1; + } + } + } + DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].unkOne_1 = 3; + // the animation table follows the tracker; tracker 3 also advances the frame every tick instead of every third + int frame; + switch (DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].someTracker) { + case 0: + frame = DAT_EntityDefinedData::instance + .FlagAnimationFrames1[DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance] + .unknownAnimationFrameRelated]; + break; + case 1: + frame = DAT_EntityDefinedData::instance + .FlagAnimationFrames2[DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance] + .unknownAnimationFrameRelated]; + break; + case 3: + DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].unkOne_1 = 1; + /* falls through into case 2 */ + case 2: + frame = DAT_EntityDefinedData::instance + .FlagAnimationFrames3[DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance] + .unknownAnimationFrameRelated]; + break; + default: + return; + } + if (frame <= 0) { + DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].unknownAnimationFrameRelated = 0; + DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].someTracker = nextTracker; + return; + } + DAT_EntityState::instance.entityArray[DAT_CurrentEntityID::instance].graphicType2 += frame - 1; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index caffa45278..1396f94e5d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -469,7 +469,7 @@ SHC_3BB0A8C1_0x00401EA0 | 0.0% | Pending SHC_3BB0A8C1_0x00401FF0 | 0.0% | Pending -SHC_3BB0A8C1_0x00402180 | 0.0% | Pending +SHC_3BB0A8C1_0x00402180 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00402260 | 0.0% | Pending @@ -491,7 +491,7 @@ SHC_3BB0A8C1_0x00402730 | 0.0% | Pending SHC_3BB0A8C1_0x00402820 | 0.0% | Pending -SHC_3BB0A8C1_0x00402900 | 0.0% | Pending +SHC_3BB0A8C1_0x00402900 | 68.2% | Register allocation differs SHC_3BB0A8C1_0x00402A0C | 0.0% | Pending @@ -517,7 +517,7 @@ SHC_3BB0A8C1_0x00402BC8 | 0.0% | Pending SHC_3BB0A8C1_0x00402BCC | 0.0% | Pending -SHC_3BB0A8C1_0x00402BD0 | 0.0% | Pending +SHC_3BB0A8C1_0x00402BD0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00402C50 | 0.0% | Pending @@ -527,7 +527,7 @@ SHC_3BB0A8C1_0x00402E20 | 0.0% | Pending SHC_3BB0A8C1_0x00403200 | 0.0% | Pending -SHC_3BB0A8C1_0x004036F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004036F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00403790 | 100.0% | Pending @@ -543,9 +543,9 @@ SHC_3BB0A8C1_0x004039B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004039F0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00403A20 | 0.0% | Pending +SHC_3BB0A8C1_0x00403A20 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00403FF0 | 0.0% | Pending +SHC_3BB0A8C1_0x00403FF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004044E4 | 0.0% | Pending @@ -1623,7 +1623,7 @@ SHC_3BB0A8C1_0x00405125 | 0.0% | Pending SHC_3BB0A8C1_0x00405130 | 100.0% | Reimplemented (counted: only the constant 0x10300131 is shown as an address label in ours) -SHC_3BB0A8C1_0x004052E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004052E0 | 94.2% | 100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on SHC_3BB0A8C1_0x004054AC | 0.0% | Pending @@ -1707,7 +1707,7 @@ SHC_3BB0A8C1_0x00405C00 | 0.0% | Pending SHC_3BB0A8C1_0x00405CF0 | 100.0% | Pending -SHC_3BB0A8C1_0x00405DA0 | 0.0% | Pending +SHC_3BB0A8C1_0x00405DA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0040612C | 0.0% | Pending @@ -2441,7 +2441,7 @@ SHC_3BB0A8C1_0x004081D4 | 0.0% | Pending SHC_3BB0A8C1_0x004081D5 | 0.0% | Pending -SHC_3BB0A8C1_0x004081E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004081E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00408250 | 100.0% | Reimplemented @@ -2453,7 +2453,7 @@ SHC_3BB0A8C1_0x004084A0 | 0.0% | Pending SHC_3BB0A8C1_0x00408770 | 0.0% | Pending -SHC_3BB0A8C1_0x004087C0 | 0.0% | Pending +SHC_3BB0A8C1_0x004087C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00408D90 | 0.0% | Pending