diff --git a/asm/MetroidPrime/Cameras/CCameraManager.s b/asm/MetroidPrime/Cameras/CCameraManager.s index 43b8eb0f..5dcf46a6 100644 --- a/asm/MetroidPrime/Cameras/CCameraManager.s +++ b/asm/MetroidPrime/Cameras/CCameraManager.s @@ -2492,15 +2492,15 @@ lbl_8000B220: /* 8000B238 00008198 38 61 00 0C */ addi r3, r1, 0xc /* 8000B23C 0000819C 38 86 00 04 */ addi r4, r6, 4 /* 8000B240 000081A0 38 A1 00 08 */ addi r5, r1, 8 -/* 8000B244 000081A4 48 00 00 15 */ bl "find,Q24rstl17rmemory_allocator>,9TUniqueId>__4rstlFQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>RC9TUniqueId" +/* 8000B244 000081A4 48 00 00 15 */ bl "erase__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" lbl_8000B248: /* 8000B248 000081A8 80 01 00 34 */ lwz r0, 0x34(r1) /* 8000B24C 000081AC 7C 08 03 A6 */ mtlr r0 /* 8000B250 000081B0 38 21 00 30 */ addi r1, r1, 0x30 /* 8000B254 000081B4 4E 80 00 20 */ blr -.global "find,Q24rstl17rmemory_allocator>,9TUniqueId>__4rstlFQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>RC9TUniqueId" -"find,Q24rstl17rmemory_allocator>,9TUniqueId>__4rstlFQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>RC9TUniqueId": +.global "erase__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" +"erase__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>": /* 8000B258 000081B8 94 21 FF E0 */ stwu r1, -0x20(r1) /* 8000B25C 000081BC 7C 08 02 A6 */ mflr r0 /* 8000B260 000081C0 90 01 00 24 */ stw r0, 0x24(r1) diff --git a/asm/MetroidPrime/Enemies/CTeamAiMgr.s b/asm/MetroidPrime/Enemies/CTeamAiMgr.s index bf752f14..45343ee7 100644 --- a/asm/MetroidPrime/Enemies/CTeamAiMgr.s +++ b/asm/MetroidPrime/Enemies/CTeamAiMgr.s @@ -753,7 +753,7 @@ lbl_80238578: /* 8023859C 002354FC 38 61 00 1C */ addi r3, r1, 0x1c /* 802385A0 00235500 38 9F 00 78 */ addi r4, r31, 0x78 /* 802385A4 00235504 38 A1 00 18 */ addi r5, r1, 0x18 -/* 802385A8 00235508 4B DD 2C B1 */ bl "find,Q24rstl17rmemory_allocator>,9TUniqueId>__4rstlFQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>RC9TUniqueId" +/* 802385A8 00235508 4B DD 2C B1 */ bl "erase__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" lbl_802385AC: /* 802385AC 0023550C 80 01 00 44 */ lwz r0, 0x44(r1) /* 802385B0 00235510 83 E1 00 3C */ lwz r31, 0x3c(r1) @@ -1253,7 +1253,7 @@ lbl_80238C60: /* 80238C84 00235BE4 38 61 00 1C */ addi r3, r1, 0x1c /* 80238C88 00235BE8 38 9F 00 68 */ addi r4, r31, 0x68 /* 80238C8C 00235BEC 38 A1 00 18 */ addi r5, r1, 0x18 -/* 80238C90 00235BF0 4B DD 25 C9 */ bl "find,Q24rstl17rmemory_allocator>,9TUniqueId>__4rstlFQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>RC9TUniqueId" +/* 80238C90 00235BF0 4B DD 25 C9 */ bl "erase__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" lbl_80238C94: /* 80238C94 00235BF4 80 01 00 44 */ lwz r0, 0x44(r1) /* 80238C98 00235BF8 83 E1 00 3C */ lwz r31, 0x3c(r1) diff --git a/asm/MetroidPrime/ScriptObjects/CScriptGenerator.s b/asm/MetroidPrime/ScriptObjects/CScriptGenerator.s index 8fae4643..6ef9e1da 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptGenerator.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptGenerator.s @@ -3,12 +3,12 @@ .section .data .balign 8 -.global lbl_803DF328 -lbl_803DF328: +.global __vt__16CScriptGenerator +__vt__16CScriptGenerator: # ROM: 0x3DC328 .4byte 0 .4byte 0 - .4byte __dt__16CScriptGenerator + .4byte __dt__16CScriptGeneratorFv .4byte Accept__16CScriptGeneratorFR8IVisitor .4byte PreThink__7CEntityFfR13CStateManager .4byte Think__7CEntityFfR13CStateManager @@ -635,7 +635,7 @@ lbl_800B4DA0: /* 800B4DB0 000B1D10 7C 00 D2 14 */ add r0, r0, r26 /* 800B4DB4 000B1D14 90 01 00 9C */ stw r0, 0x9c(r1) /* 800B4DB8 000B1D18 90 01 00 A0 */ stw r0, 0xa0(r1) -/* 800B4DBC 000B1D1C 48 00 01 01 */ bl sub_800b4ebc +/* 800B4DBC 000B1D1C 48 00 01 01 */ bl "erase__Q24rstl71vector,Q24rstl17rmemory_allocator>FQ24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" /* 800B4DC0 000B1D20 88 1C 00 38 */ lbz r0, 0x38(r28) /* 800B4DC4 000B1D24 54 00 CF FF */ rlwinm. r0, r0, 0x19, 0x1f, 0x1f /* 800B4DC8 000B1D28 41 82 00 24 */ beq lbl_800B4DEC @@ -646,7 +646,7 @@ lbl_800B4DA0: /* 800B4DDC 000B1D3C 7C 00 C2 14 */ add r0, r0, r24 /* 800B4DE0 000B1D40 90 01 00 90 */ stw r0, 0x90(r1) /* 800B4DE4 000B1D44 90 01 00 94 */ stw r0, 0x94(r1) -/* 800B4DE8 000B1D48 4B F5 64 71 */ bl "find,Q24rstl17rmemory_allocator>,9TUniqueId>__4rstlFQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>RC9TUniqueId" +/* 800B4DE8 000B1D48 4B F5 64 71 */ bl "erase__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FQ24rstl110pointer_iterator<9TUniqueId,Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" lbl_800B4DEC: /* 800B4DEC 000B1D4C 3A F7 00 01 */ addi r23, r23, 1 lbl_800B4DF0: @@ -709,8 +709,8 @@ lbl_800B4E7C: /* 800B4EB4 000B1E14 38 21 01 E0 */ addi r1, r1, 0x1e0 /* 800B4EB8 000B1E18 4E 80 00 20 */ blr -.global sub_800b4ebc -sub_800b4ebc: +.global "erase__Q24rstl71vector,Q24rstl17rmemory_allocator>FQ24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" +"erase__Q24rstl71vector,Q24rstl17rmemory_allocator>FQ24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>": /* 800B4EBC 000B1E1C 94 21 FF E0 */ stwu r1, -0x20(r1) /* 800B4EC0 000B1E20 7C 08 02 A6 */ mflr r0 /* 800B4EC4 000B1E24 90 01 00 24 */ stw r0, 0x24(r1) @@ -724,15 +724,15 @@ sub_800b4ebc: /* 800B4EE4 000B1E44 90 E1 00 08 */ stw r7, 8(r1) /* 800B4EE8 000B1E48 90 E1 00 0C */ stw r7, 0xc(r1) /* 800B4EEC 000B1E4C 90 01 00 10 */ stw r0, 0x10(r1) -/* 800B4EF0 000B1E50 48 00 00 19 */ bl sub_800b4f08 +/* 800B4EF0 000B1E50 48 00 00 19 */ bl "erase__Q24rstl71vector,Q24rstl17rmemory_allocator>FQ24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" /* 800B4EF4 000B1E54 80 01 00 24 */ lwz r0, 0x24(r1) /* 800B4EF8 000B1E58 83 E1 00 1C */ lwz r31, 0x1c(r1) /* 800B4EFC 000B1E5C 7C 08 03 A6 */ mtlr r0 /* 800B4F00 000B1E60 38 21 00 20 */ addi r1, r1, 0x20 /* 800B4F04 000B1E64 4E 80 00 20 */ blr -.global sub_800b4f08 -sub_800b4f08: +.global "erase__Q24rstl71vector,Q24rstl17rmemory_allocator>FQ24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>" +"erase__Q24rstl71vector,Q24rstl17rmemory_allocator>FQ24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl162pointer_iterator,Q24rstl71vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>": /* 800B4F08 000B1E68 94 21 FF F0 */ stwu r1, -0x10(r1) /* 800B4F0C 000B1E6C 80 E5 00 00 */ lwz r7, 0(r5) /* 800B4F10 000B1E70 80 06 00 00 */ lwz r0, 0(r6) @@ -778,8 +778,8 @@ lbl_800B4F78: /* 800B4F9C 000B1EFC 38 21 00 10 */ addi r1, r1, 0x10 /* 800B4FA0 000B1F00 4E 80 00 20 */ blr -.global __dt__16CScriptGenerator -__dt__16CScriptGenerator: +.global __dt__16CScriptGeneratorFv +__dt__16CScriptGeneratorFv: /* 800B4FA4 000B1F04 94 21 FF F0 */ stwu r1, -0x10(r1) /* 800B4FA8 000B1F08 7C 08 02 A6 */ mflr r0 /* 800B4FAC 000B1F0C 90 01 00 14 */ stw r0, 0x14(r1) @@ -788,9 +788,9 @@ __dt__16CScriptGenerator: /* 800B4FB8 000B1F18 93 C1 00 08 */ stw r30, 8(r1) /* 800B4FBC 000B1F1C 7C 7E 1B 79 */ or. r30, r3, r3 /* 800B4FC0 000B1F20 41 82 00 28 */ beq lbl_800B4FE8 -/* 800B4FC4 000B1F24 3C A0 80 3E */ lis r5, lbl_803DF328@ha +/* 800B4FC4 000B1F24 3C A0 80 3E */ lis r5, __vt__16CScriptGenerator@ha /* 800B4FC8 000B1F28 38 80 00 00 */ li r4, 0 -/* 800B4FCC 000B1F2C 38 05 F3 28 */ addi r0, r5, lbl_803DF328@l +/* 800B4FCC 000B1F2C 38 05 F3 28 */ addi r0, r5, __vt__16CScriptGenerator@l /* 800B4FD0 000B1F30 90 1E 00 00 */ stw r0, 0(r30) /* 800B4FD4 000B1F34 4B F9 C2 A1 */ bl __dt__7CEntityFv /* 800B4FD8 000B1F38 7F E0 07 35 */ extsh. r0, r31 @@ -832,8 +832,8 @@ lbl_800B4FE8: /* 800B5058 000B1FB8 7D 67 5B 78 */ mr r7, r11 /* 800B505C 000B1FBC 38 81 00 08 */ addi r4, r1, 8 /* 800B5060 000B1FC0 4B F9 C2 C5 */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" -/* 800B5064 000B1FC4 3C 60 80 3E */ lis r3, lbl_803DF328@ha -/* 800B5068 000B1FC8 38 03 F3 28 */ addi r0, r3, lbl_803DF328@l +/* 800B5064 000B1FC4 3C 60 80 3E */ lis r3, __vt__16CScriptGenerator@ha +/* 800B5068 000B1FC8 38 03 F3 28 */ addi r0, r3, __vt__16CScriptGenerator@l /* 800B506C 000B1FCC 90 1B 00 00 */ stw r0, 0(r27) /* 800B5070 000B1FD0 7F 63 DB 78 */ mr r3, r27 /* 800B5074 000B1FD4 93 9B 00 34 */ stw r28, 0x34(r27) diff --git a/configure.py b/configure.py index a88226bb..d3d3d409 100755 --- a/configure.py +++ b/configure.py @@ -88,7 +88,7 @@ LIBS = [ "MetroidPrime/ScriptObjects/CScriptSound", ["MetroidPrime/ScriptObjects/CScriptPlatform", False], ["MetroidPrime/UserNames", True], - "MetroidPrime/ScriptObjects/CScriptGenerator", + ["MetroidPrime/ScriptObjects/CScriptGenerator", False], ["MetroidPrime/ScriptObjects/CScriptCameraWaypoint", False], ["MetroidPrime/CGameLight", True], "MetroidPrime/Tweaks/CTweakTargeting", diff --git a/include/MetroidPrime/ScriptObjects/CScriptGenerator.hpp b/include/MetroidPrime/ScriptObjects/CScriptGenerator.hpp new file mode 100644 index 00000000..b5c179d9 --- /dev/null +++ b/include/MetroidPrime/ScriptObjects/CScriptGenerator.hpp @@ -0,0 +1,25 @@ +#ifndef _CSCRIPTGENERATOR +#define _CSCRIPTGENERATOR + +#include "MetroidPrime/CEntity.hpp" + +class CScriptGenerator : public CEntity { +public: + CScriptGenerator(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + int spawnCount, bool noReuseFollowers, const CVector3f& vec1, bool noInheritXf, + bool active, float minScale, float maxScale); + ~CScriptGenerator(); + + void Accept(IVisitor& visitor) override; + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override; + +private: + int x34_spawnCount; + bool x38_24_noReuseFollowers : 1; + bool x38_25_noInheritTransform : 1; + CVector3f x3c_offset; + float x48_minScale; + float x4c_maxScale; +}; + +#endif // _CSCRIPTGENERATOR diff --git a/include/rstl/pair.hpp b/include/rstl/pair.hpp index cd4be389..4c3eda85 100644 --- a/include/rstl/pair.hpp +++ b/include/rstl/pair.hpp @@ -10,6 +10,8 @@ public: pair() {} pair(const L& first, const R& second) : first(first), second(second) {} + bool operator==(const pair& other) const { return first == other.first && second == other.second; } + L first; R second; }; diff --git a/src/MetroidPrime/ScriptObjects/CScriptGenerator.cpp b/src/MetroidPrime/ScriptObjects/CScriptGenerator.cpp new file mode 100644 index 00000000..3ac81b5d --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptGenerator.cpp @@ -0,0 +1,175 @@ +#include "MetroidPrime/ScriptObjects/CScriptGenerator.hpp" + +#include "MetroidPrime/CActor.hpp" +#include "MetroidPrime/CStateManager.hpp" +#include "MetroidPrime/Enemies/CWallCrawlerSwarm.hpp" + +#include "rstl/algorithm.hpp" + +CScriptGenerator::CScriptGenerator(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + int spawnCount, bool noReuseFollowers, const CVector3f& vec1, + bool noInheritXf, bool active, float minScale, float maxScale) +: CEntity(uid, info, active, name) +, x34_spawnCount(spawnCount) +, x38_24_noReuseFollowers(noReuseFollowers) +, x38_25_noInheritTransform(noInheritXf) +, x3c_offset(vec1) +, x48_minScale(minScale) +, x4c_maxScale(maxScale) {} + +CScriptGenerator::~CScriptGenerator() {} + +void CScriptGenerator::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, + CStateManager& stateMgr) { + switch (msg) { + case kSM_SetToZero: { + if (!GetActive()) { + break; + } + + rstl::vector< TUniqueId > follows; + int connectionsCount = GetConnectionList().size(); + int reseveSize = 1; + if (connectionsCount != 0) { + reseveSize = connectionsCount; + } + follows.reserve(reseveSize); + rstl::vector< SConnection >::const_iterator iter = GetConnectionList().begin(); + for (; iter != GetConnectionList().end(); ++iter) { + if (iter->x0_state != kSS_Zero || iter->x4_msg != kSM_Follow) { + continue; + } + + const TUniqueId uid = stateMgr.GetIdForScript(iter->x8_objId); + if (uid != kInvalidUniqueId) { + const CEntity* entity = stateMgr.GetObjectById(uid); + if (entity && entity->GetActive()) { + follows.push_back(uid); + } + } + } + + if (follows.empty()) { + follows.push_back(sender); + } + + rstl::vector< rstl::pair< TUniqueId, TEditorId > > activates; + activates.reserve(GetConnectionList().size()); + + for (iter = GetConnectionList().begin(); iter != GetConnectionList().end(); ++iter) { + if (iter->x0_state != kSS_Zero) { + continue; + } + + TUniqueId uid = stateMgr.GetIdForScript(iter->x8_objId); + if (uid == kInvalidUniqueId) { + continue; + } + + if (iter->x4_msg == kSM_Activate) { + if (!stateMgr.GetObjectById(uid)) { + continue; + } + activates.push_back(rstl::pair< TUniqueId, TEditorId >(uid, iter->x8_objId)); + } else { + stateMgr.SendScriptMsgAlways(uid, GetUniqueId(), iter->x4_msg); + } + } + + if (activates.empty()) { + break; + } + + for (int i = 0; i < x34_spawnCount; ++i) { + if (activates.size() == 0 || follows.size() == 0) { + break; + } + + int activatesRand = 0.99f * (stateMgr.Random()->Float() * activates.size()); + const int followsRand = 0.99f * (stateMgr.Random()->Float() * follows.size()); + + for (int j = 0; j < activates.size(); ++j) { + if (TCastToConstPtr< CScriptSound >(stateMgr.GetObjectById(activates[j].first))) { + activatesRand = j; + break; + } + } + + const rstl::pair< TUniqueId, TEditorId > idPair = activates[activatesRand]; + CEntity* activate = stateMgr.ObjectById(idPair.first); + CEntity* follow = stateMgr.ObjectById(follows[followsRand]); + + if (!activate || !follow) { + break; + } + + const bool oldGeneratingObject = stateMgr.IsGeneratingObject(); + stateMgr.SetIsGeneratingObject(true); + TUniqueId objId = stateMgr.GenerateObject(idPair.second).second; + stateMgr.SetIsGeneratingObject(oldGeneratingObject); + + if (objId != kInvalidUniqueId) { + CEntity* genObj = stateMgr.ObjectById(objId); + { + CActor* activateActor = TCastToPtr< CActor >(genObj); + const CActor* followActor = TCastToConstPtr< CActor >(follow); + const CWallCrawlerSwarm* wallCrawlerSwarm = TCastToConstPtr< CWallCrawlerSwarm >(follow); + + if (activateActor && wallCrawlerSwarm) { + if (!x38_25_noInheritTransform) { + activateActor->SetTransform(wallCrawlerSwarm->GetTransform()); + } + activateActor->SetTranslation(wallCrawlerSwarm->GetLastKilledOffset() + x3c_offset); + } else if (activateActor && followActor) { + if (!x38_25_noInheritTransform) { + activateActor->SetTransform(followActor->GetTransform()); + } + activateActor->SetTranslation(followActor->GetTranslation() + x3c_offset); + } + } + if (genObj) { + CEntity* genObj = stateMgr.ObjectById(objId); + CActor* activateActor = TCastToPtr< CActor >(genObj); + const CActor* followActor = TCastToConstPtr< CActor >(follow); + const CWallCrawlerSwarm* wallCrawlerSwarm = TCastToConstPtr< CWallCrawlerSwarm >(follow); + + if (activateActor) { + if (activateActor && wallCrawlerSwarm) { + if (!x38_25_noInheritTransform) { + activateActor->SetTransform(wallCrawlerSwarm->GetTransform()); + } + activateActor->SetTranslation(wallCrawlerSwarm->GetLastKilledOffset() + x3c_offset); + } else if (activateActor && followActor) { + if (!x38_25_noInheritTransform) { + activateActor->SetTransform(followActor->GetTransform()); + } + activateActor->SetTranslation(followActor->GetTranslation() + x3c_offset); + } + } + + const float rnd = stateMgr.Random()->Range(x48_minScale, x4c_maxScale); + CModelData* mData = activateActor->ModelData(); + bool valid = mData && !mData->IsNull(); + if (valid) { + mData->SetScale(rnd * mData->GetScale()); + } + + stateMgr.SendScriptMsg(genObj, GetUniqueId(), kSM_Activate); + } + } + + activates.erase(activates.begin() + activatesRand); + if (x38_24_noReuseFollowers) { + follows.erase(follows.begin() + followsRand); + } + } + break; + } + default: + break; + } + + CEntity::AcceptScriptMsg(msg, sender, stateMgr); +} + +void CScriptGenerator::Accept(IVisitor& visitor) { visitor.Visit(*this); }