Author Topic: Allowing custom scenarios to include cutscenes  (Read 3894 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Allowing custom scenarios to include cutscenes
« on: November 04, 2017, 11:20:51 PM »
Hey everyone,

I’d like to allow custom scenarios access to showing video clips when completed (either victory or defeat).

Perhaps we could use OP2Ext for this purpose? I was thinking we could attach string resources to the scenario .DLL that included key value pairs for the video. For example:
 * VictoryVideo: blah.avi
 * DefeatVideo: blah2.avi

We could  have Outpost 2 search the list of already hardcoded end of scenario video files and then check for an attached resource afterwards. Or, we could just replace the hardcoded text with searching for a resource. I could easily go back and manually add the proper victory and defeat video names as resources to the existing 30 or so scenarios with videos produced by Sierra.

Resource Hacker can be used to modify existing scenario .DLLs or as a post compilation step for new DLLs. Visual Studio could also be used to apply the resource in house.

We are already using resource strings when adding intro text for Outpost 2 colony game scenarios.

This might even let someone load a custom video (if one was ever created for a scenario).

The other option, would be to list all the resources in a .txt or .xml file. This would allow easy loading without worrying about resources. The downside is that there would be versioning issues with the file as each scenario tried to add themselves to the single file. By placing the video info as a resource on the .DLL, it would isolate the information to the DLL that required the information to display the video, which would be cleaner.

I don’t know if it would be possible to also display intro videos to scenarios in this way or not? Probably not worth a lot of work if not easily available.

I figure we should work the *.VOL change first in OP2Ext, and then perhaps look at this project.

I have not actually reviewed any of the Outpost 2 source code to see how feasible a change this would be. If it is feasible, I would be pretty interested in helping implement it.

Any thoughts?



Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Re: Allowing custom scenarios to include cutscenes
« Reply #1 on: November 04, 2017, 11:59:02 PM »
The CCF2 alpha source code has a hack for that. All this code is pretty bad and from a long time ago, but it works.

OP2's actual cutscene playing implementation is actually in op2shell.dll, and it's hardcoded to only play cutscenes for missions with specific filenames of course.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Re: Allowing custom scenarios to include cutscenes
« Reply #2 on: November 05, 2017, 01:17:15 PM »
Thanks Arklon,

I'm guessing the code I'm interested in is cutscene.h/.cpp, which has the function PlayAvi.

Code: [Select]
#ifndef CUTSCENE_H
#define CUTSCENE_H

#include <windows.h>

bool PlayAvi(const char *fileName, bool isAtMissionEnd = false);

void CenterWindow(HWND hWnd, bool clipToScreen = false);
void PaintWndRectBlack(HWND hWnd, LPRECT paintRect);
HWND CreateBlackWindow(HWND hWndParent);



By the way, that is a beautiful map someone designed. Much better than the poor mapmaking I've attempted. I'm guessing it doesn't play well with Outpost 2's pathfinding algorithm though.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Allowing custom scenarios to include cutscenes
« Reply #3 on: November 06, 2017, 01:32:07 AM »
Not such as bad idea.

I think I rather like the resource string idea. That makes it easier to edit in already compiled DLLs. Though it'd probably best to make the current behaviour the default if that string doesn't exist, rather then edit all the old DLLs to have it.

Another way, perhaps more flexible, is to allow extensions using special named exported DLL functions. Perhaps a method can be called to select a game ending video, which could depend on more than just success/failure, but perhaps what happened during the scenario, or the manner of failure.

Could also implement multiple ways. A custom function it exists, otherwise a stored string if that exists, otherwise default behaviour based on DLL name/type.

As for how easy it would be to do, I'm not sure. Might need a code overwrite hook to do this for any level. Not usually terribly difficult to do, but it does require detailed knowledge of the right section of code. You could implement and test this as a mod loader addon.