From b7b0b7f50aeb9bd948e51cce7a0b6ddc457fa032 Mon Sep 17 00:00:00 2001
From: Joshua Peisach <itzswirlz2020@outlook.com>
Date: Sat, 8 Jun 2024 17:40:36 -0400
Subject: [PATCH] Match Ambulance::StopScriptOnAmbulance and StopScriptOnEntity
 (#1003)

* Match Ambulance::StopScriptOnAmbulance and StopScriptOnEntity

* Rename for consistency

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
---
 LEGO1/lego/legoomni/include/ambulance.h      |  4 +++-
 LEGO1/lego/legoomni/src/actors/ambulance.cpp | 17 ++++++++++++++---
 LEGO1/lego/legoomni/src/worlds/isle.cpp      |  4 ++--
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/LEGO1/lego/legoomni/include/ambulance.h b/LEGO1/lego/legoomni/include/ambulance.h
index aa357385..54e163e8 100644
--- a/LEGO1/lego/legoomni/include/ambulance.h
+++ b/LEGO1/lego/legoomni/include/ambulance.h
@@ -98,13 +98,15 @@ public:
 	void CreateState();
 	void FUN_10036e60();
 	void FUN_10037060();
-	void FUN_10037240();
+	void StopActions();
 	void FUN_10037250();
 
 	// SYNTHETIC: LEGO1 0x10036130
 	// Ambulance::`scalar deleting destructor'
 
 private:
+	void StopAction(MxS32 p_entityId);
+
 	undefined m_unk0x160[4];        // 0x160
 	AmbulanceMissionState* m_state; // 0x164
 	MxS16 m_unk0x168;               // 0x168
diff --git a/LEGO1/lego/legoomni/src/actors/ambulance.cpp b/LEGO1/lego/legoomni/src/actors/ambulance.cpp
index 2474c7b9..20d12b35 100644
--- a/LEGO1/lego/legoomni/src/actors/ambulance.cpp
+++ b/LEGO1/lego/legoomni/src/actors/ambulance.cpp
@@ -1,8 +1,10 @@
 #include "ambulance.h"
 
 #include "decomp.h"
+#include "isle_actions.h"
 #include "legocontrolmanager.h"
 #include "legogamestate.h"
+#include "legoutils.h"
 #include "legovariables.h"
 #include "legoworld.h"
 #include "misc.h"
@@ -123,6 +125,7 @@ MxLong Ambulance::Notify(MxParam& p_param)
 }
 
 // STUB: LEGO1 0x100364d0
+// FUNCTION: BETA10 0x10022cc2
 MxLong Ambulance::HandleEndAction(MxEndActionNotificationParam& p_param)
 {
 	// TODO
@@ -182,10 +185,10 @@ MxResult Ambulance::Tickle()
 	return SUCCESS;
 }
 
-// STUB: LEGO1 0x10037240
-void Ambulance::FUN_10037240()
+// FUNCTION: LEGO1 0x10037240
+void Ambulance::StopActions()
 {
-	// TODO
+	StopAction(IsleScript::c_pns018rd_RunAnim);
 }
 
 // STUB: LEGO1 0x10037250
@@ -194,6 +197,14 @@ void Ambulance::FUN_10037250()
 	// TODO
 }
 
+// FUNCTION: LEGO1 0x10037340
+void Ambulance::StopAction(MxS32 p_entityId)
+{
+	if (p_entityId != -1) {
+		InvokeAction(Extra::e_stop, *g_isleScript, p_entityId, NULL);
+	}
+}
+
 // FUNCTION: LEGO1 0x100373a0
 AmbulanceMissionState::AmbulanceMissionState()
 {
diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp
index de524cb2..b96d5814 100644
--- a/LEGO1/lego/legoomni/src/worlds/isle.cpp
+++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp
@@ -1201,7 +1201,7 @@ MxBool Isle::Escape()
 		break;
 	case 10:
 		if (CurrentActor() != NULL && !CurrentActor()->IsA("Ambulance")) {
-			m_ambulance->FUN_10037240();
+			m_ambulance->StopActions();
 			m_ambulance->FUN_10037250();
 		}
 		break;
@@ -1242,7 +1242,7 @@ void Isle::FUN_10033350()
 {
 	if (m_act1state->m_unk0x018 == 10) {
 		if (CurrentActor() != NULL && !CurrentActor()->IsA("Ambulance")) {
-			m_ambulance->FUN_10037240();
+			m_ambulance->StopActions();
 			m_ambulance->FUN_10037250();
 		}
 	}