-
Notifications
You must be signed in to change notification settings - Fork 3
GameTest hacking
The GameTest scene is the current playground for RGU. It's a pretty simple affair, there's only a single interesting component, the AreaLoader. This is just here to execute the LoadWorld script and make things go.
The LoadWorld script is where the world gets initialized. This is done in the "Start" function, where we see:
WorldLoader.LoadWorld(18,0,1024);
Changing the world that is loaded can be done by changing the magic numbers:
- 18 is the world id, you can see this in WORLD.INI, 18 is the silversmith:
world_map[18]=maps\silver1.rgm
- 0 is the spawnpoint id, this is visible in the world scripts. 0 should always exist so that's a safe bet.
- 1024 is the player rotation on spawn.
The easiest way to find the spawnpoints is by looking at the map scripts for the doors, eg in the tavern:
1388 EXTTAV
1389 {
1390 if PlayerDistance() < 50688 and PlayerLooking(456) = 1
1391 {
1392 if ACTIVATE("$exr") = 1 // Dlg $exr = EXIT THE DRAGGIN TALE
1393 {
1394 talking = 0 // we set this when cyrus is in dialog
1395 FlatSound(35, 0, 0)
1396 ****LoadWorld(timeofday, 8, 1724)****
1397 }
1398 }
1399 End
1400 }
So now we know that the tavern exit is spawnpoint #8 in the overworld. Overworld is timeofday here, which maps to 1 for day and 28 for night.
Apart from loading the world, the LoadWorld script can also turn scripting on for objects. Not all scripted objects are enabled by default because they would spam the error log with unimplemented functions.
Enabling a script for an object can be done with a line like this:
ModelLoader.scriptedObjects[0x82BD9E40].EnableScripting(); // EXTOBSRV
The magic hex number there is the object ID. I get this from io_tst/rgmtst/rgmtst.cs where you can fill in the RGM file to read and it will spit out all scripted objects and their IDs. At some point we should make a list with all the objects to make this easier, probably taking this along with https://github.com/RGUnity/redguard-unity/issues/49
BREAKAGE NOTE: if you try to enable scripting on an object that does not exist, the EnableScripting() line will throw an exception and stop the rest of the script, resulting in weird things if you dont know about this.