Lua - Implement New Camera Cutscenes?

Spring E. Thing

Member
Modder
Apr 8, 2024
41
5
230
TL;DR
I want to add a cutscene int to my .lua that isn't present in vanilla SM64. After adding the cutscene, I want to start the cutscene from .lua, I want player input to still work during the cutscene, I want the cutscene to remain focused on some Object in the game world, and then I want the cutscene to end through .lua. All of this is bare minimum to my goal, so is this all possible?


Hey again, guys!
I see from my own investigation that the lua_definitions included with the Co-Op DX source have various methods exposed to interact with the cutscene state of the local player's camera. Nice and simple this time, just a few questions one after another:

1. Is a cutscene being active in SM64 directly tied to disabling player input? If it is, then discard all my other questions, as I will need at least one player input to remain active during the cutscene I'd like to implement (though I will accept a workaround assuming it involves input from the client controller that circumvents m.controller).

2. Can I define a new cutscene int that won't conflict with other mods? Sort of like how allocate_mario_action() is used to associate a custom action that's a part of the .lua with an int for bitwise operations in Co-Op DX that won't already be used by another custom action or any vanilla actions, I want that exact concept but for cutscenes but personally I'm not finding it anywhere in the lua_definitions.

3. Once I "allocate" a cutscene for lack of a better term, I want the cutscene to just focus on an Object in the game world until I tell the cutscene to stop somewhere in my .lua. If this were the Co-Op DX source, I'd begin such a cutscene with start_object_cutscene(), but I'm not seeing an equivalent to this exposed through lua_definitions despite several similar methods otherwise being exposed. What do I do about this? Is there a way around this even?

4. Following on from question 3, I mention I want the cutscene to be stopped through .lua much as it was started through .lua. I'm not finding a method exposed through lua_definitions to stop cutscenes, so what's the method by which this is done?

5. Just to be sure, I'd get the Camera to which I'd like the cutscene to apply through m.area.camera, right?

TY for reading!
 
Last edited:
Solution
though I will accept a workaround assuming it involves input from the client controller that circumvents m.controller
Use m.freeze = 1 instead, also, I am uncertain if you need m.freeze when using a camera cutscene.

2. Can I define a new cutscene int that won't conflict with other mods?
You're dealing with a variable all mods have access to, m.area.camera (or gLakituState, which you should keep in mind for these), so creating a unique int, it would probably be a big hexadecimal. What I would recommend is using a separate variable for when the mod sets it to that camera state, and checking that variable aswell, however, for me, so little mods actually use this, i'd just use a hexadecimal like 0x950 or...
though I will accept a workaround assuming it involves input from the client controller that circumvents m.controller
Use m.freeze = 1 instead, also, I am uncertain if you need m.freeze when using a camera cutscene.

2. Can I define a new cutscene int that won't conflict with other mods?
You're dealing with a variable all mods have access to, m.area.camera (or gLakituState, which you should keep in mind for these), so creating a unique int, it would probably be a big hexadecimal. What I would recommend is using a separate variable for when the mod sets it to that camera state, and checking that variable aswell, however, for me, so little mods actually use this, i'd just use a hexadecimal like 0x950 or something.

Once I "allocate" a cutscene for lack of a better term,
Allocate's a fine word
I want the cutscene to just focus on an Object in the game world until I tell the cutscene to stop somewhere in my .lua. If this were the Co-Op DX source, I'd begin such a cutscene with start_object_cutscene(), but I'm not seeing an equivalent to this exposed through lua_definitions despite several similar methods otherwise being exposed. What do I do about this? Is there a way around this even?
Use the focus entry in the camera. This is where I should tell you you're most likely gonna need to use gLakituState. Another thing to note is gLakituState contains multiple focus angle, gLakituState.focus, gLakituState.curFocus, and gLakituState.prevFocus, what i'd do is
gLakituState.focus.x = o.oPosX
gLakituState.focus.y = o.oPosY
gLakituState.focus.z = o.oPosZ
vec3f_copy(gLakituState.curFocus, gLakituState.focus)
vec3f_copy(gLakituState.prevFocus, gLakituState.focus)
vec3f_copy(m.area.camera.focus, gLakituState.focus)

Following on from question 3, I mention I want the cutscene to be stopped through .lua much as it was started through .lua. I'm not finding a method exposed through lua_definitions to stop cutscenes, so what's the method by which this is done?
Set the cutscene to 0

Just to be sure, I'd get the Camera to which I'd like the cutscene to apply through m.area.camera, right?
Discussed above.

The fact that you're already getting into camera cutscenes makes me really excited to see what you come up with next! Happy modding!
 
  • Like
Reactions: Spring E. Thing
Solution
Use m.freeze = 1 instead, also, I am uncertain if you need m.freeze when using a camera cutscene.


You're dealing with a variable all mods have access to, m.area.camera (or gLakituState, which you should keep in mind for these), so creating a unique int, it would probably be a big hexadecimal. What I would recommend is using a separate variable for when the mod sets it to that camera state, and checking that variable aswell, however, for me, so little mods actually use this, i'd just use a hexadecimal like 0x950 or something.


Allocate's a fine word

Use the focus entry in the camera. This is where I should tell you you're most likely gonna need to use gLakituState. Another thing to note is gLakituState contains multiple focus angle, gLakituState.focus, gLakituState.curFocus, and gLakituState.prevFocus, what i'd do is
gLakituState.focus.x = o.oPosX
gLakituState.focus.y = o.oPosY
gLakituState.focus.z = o.oPosZ
vec3f_copy(gLakituState.curFocus, gLakituState.focus)
vec3f_copy(gLakituState.prevFocus, gLakituState.focus)
vec3f_copy(m.area.camera.focus, gLakituState.focus)


Set the cutscene to 0


Discussed above.

The fact that you're already getting into camera cutscenes makes me really excited to see what you come up with next! Happy modding!
Thanks a ton again, Emerald! Your help in this area of the forums has been invaluable during my development time when source code analysis just won't cut it. I'll be trying some of this stuff out in a few hours and I'll update ya if I get stuck again. The cutscene I'm making is super basic and by typical definition isn't really a cutscene so much as forcing the camera to be a certain way during active gameplay, but I hope you'll like what I've got in store! What I'm working on currently is thankfully in a state where it'll definitely be releasing as the main loop of functionality is all there and fully networked even right now.
 
I haven't read anything that Emerald said but I would just write my own cutscene system entirely in Lua if I wanted to do custom cutscenes. That's what I ended up doing for Underworld.
I'll keep that in mind, TY! I haven't started work on any of this due to a mix of IRL obligations and a game release that has me hooked, but as of like 2 hours ago I'm back on it and I'll be getting to the subject of this thread likely within a day or two.
 

Users who are viewing this thread