Skip to content

Commit 839c32a

Browse files
committed
2 parents 5544297 + a3ba75e commit 839c32a

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

TheForceEngine/TFE_DarkForces/Scripting/gs_game.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ namespace TFE_DarkForces
3131
{
3232
ScriptClassBegin("Game", "game", api);
3333
{
34+
// Enums
35+
ScriptEnumRegister("MessageType");
36+
ScriptEnum("M_TRIGGER", MSG_TRIGGER);
37+
ScriptEnum("NEXT_STOP", MSG_NEXT_STOP);
38+
ScriptEnum("PREV_STOP", MSG_PREV_STOP);
39+
// ScriptEnum("GOTO_STOP", MSG_GOTO_STOP); // GOTO_STOP requires a parameter, not yet implemented
40+
ScriptEnum("DONE", MSG_DONE);
41+
ScriptEnum("WAKEUP", MSG_WAKEUP);
42+
ScriptEnum("MASTER_ON", MSG_MASTER_ON);
43+
ScriptEnum("MASTER_OFF", MSG_MASTER_OFF);
44+
ScriptEnum("CRUSH", MSG_CRUSH);
45+
3446
// Functions
3547
ScriptObjMethod("float getGameTime()", getGameTime);
3648
ScriptObjMethod("int random(int)", scriptRandom);

TheForceEngine/TFE_DarkForces/Scripting/scriptObject.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <TFE_DarkForces/pickup.h>
1010
#include <TFE_DarkForces/player.h>
1111
#include <TFE_DarkForces/mission.h>
12+
#include <TFE_DarkForces/Actor/actor.h>
1213
#include <TFE_ForceScript/forceScript.h>
1314
#include <TFE_ForceScript/scriptAPI.h>
1415
#include <TFE_Jedi/Level/levelData.h>
@@ -277,6 +278,14 @@ namespace TFE_DarkForces
277278
if (s_nightVisionActive) { disableNightVision(); }
278279
}
279280

281+
void sendMessageToObject(MessageType messageType, ScriptObject* sObject)
282+
{
283+
if (!doesObjectExist(sObject)) { return; }
284+
285+
SecObject* obj = TFE_Jedi::s_objectRefList[sObject->m_id].object;
286+
message_sendToObj(obj, messageType, actor_messageFunc);
287+
}
288+
280289
void ScriptObject::registerType()
281290
{
282291
s32 res = 0;
@@ -314,5 +323,6 @@ namespace TFE_DarkForces
314323
ScriptObjFunc("void delete()", deleteObject);
315324
ScriptObjFunc("void addLogic(string)", addLogicToObject);
316325
ScriptObjFunc("void setCamera()", setCamera);
326+
ScriptObjFunc("void sendMessage(int)", sendMessageToObject)
317327
}
318328
}

TheForceEngine/TFE_DarkForces/Scripting/scriptSector.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <TFE_Jedi/Level/levelData.h>
66
#include <TFE_Jedi/Level/rwall.h>
77
#include <TFE_Jedi/Level/rsector.h>
8+
#include <TFE_Jedi/InfSystem/message.h>
89
#include <angelscript.h>
910

1011
using namespace TFE_Jedi;
@@ -169,6 +170,33 @@ namespace TFE_DarkForces
169170
}
170171
}
171172

173+
// Message with event and arg, eg. GOTO_STOP 131072 2
174+
void sendMessageToSector(MessageType messageType, u32 evt, u32 msgArg1, ScriptSector* sSector)
175+
{
176+
if (!isScriptSectorValid(sSector))
177+
{
178+
return;
179+
}
180+
181+
// TODO: investigate how to do this safely
182+
// s_msgArg1 = msgArg1;
183+
184+
RSector* sector = &s_levelState.sectors[sSector->m_id];
185+
message_sendToSector(sector, nullptr, evt, messageType);
186+
}
187+
188+
// Message with no event and no arg, eg. NEXT_STOP
189+
void sendMessageToSector1(MessageType messageType, ScriptSector* sSector)
190+
{
191+
sendMessageToSector(messageType, 0, 0, sSector);
192+
}
193+
194+
// Message with event, eg. NEXT_STOP 131072
195+
void sendMessageToSector2(MessageType messageType, u32 evt, ScriptSector* sSector)
196+
{
197+
sendMessageToSector(messageType, evt, 0, sSector);
198+
}
199+
172200
void ScriptSector::registerType()
173201
{
174202
s32 res = 0;
@@ -185,6 +213,11 @@ namespace TFE_DarkForces
185213
ScriptObjFunc("void setFlag(int, uint)", setSectorFlag);
186214
ScriptObjFunc("float2 getCenterXZ()", getCenterXZ);
187215
ScriptObjFunc("Wall getWall(int)", getWall);
216+
217+
ScriptObjFunc("void sendMessage(int)", sendMessageToSector1);
218+
ScriptObjFunc("void sendMessage(int, uint)", sendMessageToSector2);
219+
//ScriptObjFunc("void sendMessage(int, uint, uint)", sendMessageToSector); // For now do not expose the ability to pass an arg
220+
188221
// Properties
189222
ScriptPropertyGetFunc("float get_floorHeight()", getFloorHeight);
190223
ScriptPropertyGetFunc("float get_ceilHeight()", getCeilHeight);

0 commit comments

Comments
 (0)