summaryrefslogtreecommitdiffstats
path: root/src/weapons/Explosion.cpp
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-03-17 18:47:12 +0100
committerGitHub <noreply@github.com>2020-03-17 18:47:12 +0100
commit31d16d395eb6582b20a157764ce8b0da608ef3d8 (patch)
tree4443d13dedf97357acfe2e9b859d1ed431fdbbf0 /src/weapons/Explosion.cpp
parentMerge pull request #347 from Nick007J/master (diff)
parentMerge branch 'master' into Radar2 (diff)
downloadre3-31d16d395eb6582b20a157764ce8b0da608ef3d8.tar
re3-31d16d395eb6582b20a157764ce8b0da608ef3d8.tar.gz
re3-31d16d395eb6582b20a157764ce8b0da608ef3d8.tar.bz2
re3-31d16d395eb6582b20a157764ce8b0da608ef3d8.tar.lz
re3-31d16d395eb6582b20a157764ce8b0da608ef3d8.tar.xz
re3-31d16d395eb6582b20a157764ce8b0da608ef3d8.tar.zst
re3-31d16d395eb6582b20a157764ce8b0da608ef3d8.zip
Diffstat (limited to '')
-rw-r--r--src/weapons/Explosion.cpp111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/weapons/Explosion.cpp b/src/weapons/Explosion.cpp
new file mode 100644
index 00000000..05087335
--- /dev/null
+++ b/src/weapons/Explosion.cpp
@@ -0,0 +1,111 @@
+#include "common.h"
+#include "patcher.h"
+#include "DMAudio.h"
+#include "Explosion.h"
+
+CExplosion(&gaExplosion)[48] = *(CExplosion(*)[48])*(uintptr*)0x64E208;
+
+WRAPPER void CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32) { EAXJMP(0x5591C0); }
+//WRAPPER void CExplosion::RemoveAllExplosionsInArea(CVector, float) { EAXJMP(0x55AD40); }
+//WRAPPER bool CExplosion::TestForExplosionInArea(eExplosionType, float, float, float, float, float, float) { EAXJMP(0x55AC80); }
+
+int AudioHandle = AEHANDLE_NONE;
+
+void
+CExplosion::Initialise()
+{
+ debug("Initialising CExplosion...\n");
+ for (int i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
+ gaExplosion[i].m_ExplosionType = EXPLOSION_GRENADE;
+ gaExplosion[i].m_vecPosition.x = 0.0f;
+ gaExplosion[i].m_vecPosition.y = 0.0f;
+ gaExplosion[i].m_vecPosition.z = 0.0f;
+ gaExplosion[i].m_fRadius = 1.0f;
+ gaExplosion[i].m_fPropagationRate = 0.0f;
+ gaExplosion[i].field_38 = 0;
+ gaExplosion[i].m_pCreatorEntity = nil;
+ gaExplosion[i].m_pVictimEntity = nil;
+ gaExplosion[i].m_fStopTime = 0.0f;
+ gaExplosion[i].m_bActive = false;
+ gaExplosion[i].m_nStartTime = 0;
+ gaExplosion[i].field_34 = 0;
+ }
+ AudioHandle = DMAudio.CreateEntity(AUDIOTYPE_EXPLOSION, (void*)1);
+ if (AudioHandle >= 0)
+ DMAudio.SetEntityStatus(AudioHandle, 1);
+ debug("CExplosion ready\n");
+}
+
+void CExplosion::Shutdown()
+{
+ debug("Shutting down CExplosion...\n");
+ if (AudioHandle >= 0) {
+ DMAudio.DestroyEntity(AudioHandle);
+ AudioHandle = AEHANDLE_NONE;
+ }
+ debug("CExplosion shut down\n");
+}
+
+void
+CExplosion::RemoveAllExplosionsInArea(CVector pos, float radius)
+{
+ for (int i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
+ if (gaExplosion[i].m_bActive) {
+ if ((pos - gaExplosion[i].m_vecPosition).MagnitudeSqr() < SQR(radius))
+ gaExplosion[i].m_bActive = false;
+ }
+ }
+}
+
+int8
+CExplosion::GetExplosionActiveCounter(uint8 id)
+{
+ return gaExplosion[id].m_bActiveCounter;
+}
+
+CVector *
+CExplosion::GetExplosionPosition(uint8 id)
+{
+ return &gaExplosion[id].m_vecPosition;
+}
+
+uint8
+CExplosion::GetExplosionType(uint8 id)
+{
+ return gaExplosion[id].m_ExplosionType;
+}
+
+void
+CExplosion::ResetExplosionActiveCounter(uint8 id)
+{
+ gaExplosion[id].m_bActiveCounter = 0;
+}
+
+bool
+CExplosion::TestForExplosionInArea(eExplosionType a1, float x1, float x2, float y1, float y2, float z1, float z2)
+{
+ for (int i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
+ if (gaExplosion[i].m_bActive) {
+ if (a1 == gaExplosion[i].m_ExplosionType) {
+ if (gaExplosion[i].m_vecPosition.x >= x1 && gaExplosion[i].m_vecPosition.x <= x2) {
+ if (gaExplosion[i].m_vecPosition.y >= y1 && gaExplosion[i].m_vecPosition.y <= y2) {
+ if (gaExplosion[i].m_vecPosition.z >= z1 && gaExplosion[i].m_vecPosition.z <= z2)
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
+STARTPATCHES
+ InjectHook(0x559030, &CExplosion::Initialise, PATCH_JUMP);
+ InjectHook(0x559100, &CExplosion::Shutdown, PATCH_JUMP);
+ InjectHook(0x55AD40, &CExplosion::RemoveAllExplosionsInArea, PATCH_JUMP);
+ InjectHook(0x559140, &CExplosion::GetExplosionActiveCounter, PATCH_JUMP);
+ InjectHook(0x5591A0, &CExplosion::GetExplosionPosition, PATCH_JUMP);
+ InjectHook(0x559180, &CExplosion::GetExplosionType, PATCH_JUMP);
+ InjectHook(0x559160, &CExplosion::ResetExplosionActiveCounter, PATCH_JUMP);
+ InjectHook(0x55AC80, &CExplosion::TestForExplosionInArea, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file