[Game Integration] Modding Tyranoscript Games

That worked… Holy. Thank you for the enlightenment.

I’m guessing all videos under avy_game\data\video will need a matchings script… There’s 531 videos in total. It’s a lot but can be handled.

And I’ve noticed that in these .tpatch files there are videos as well. Some of them already exists under data\video whilst some are not. I wonder what these are for…

1 Like

@hugecat Is it possible to extend the life of this topic? Since some progress has been made we may need more time with it.
image

Just checked some videos, many of them were duplicates.

3-4-4-1-2_抽送_速い_019_sex_2_0_1
3-4-4-1-2_抽送_速い_021_sex_2_0_3
3-4-4-1-2_抽送_速い_023_sex_2_0_5

If a videos have the same prefix like ‘3-4-4-1-2_抽送_速い’, they are likely videos with the same pattern.
Filtering with “抽送_速い” didn’t worked as they seems like same video but there were some frame differences.

1 Like

After some tinkering it worked. Awesome image
Many thanks to @to4st and @affqprow!

Started making scripts. There are a lot of videos but most share the same pattern. Spent more effort organising and renaming files than actual scripting.


The only problem I’ve noticed so far is that there seems to be a considerable delay, which becomes very noticeable at fast movement (it will feels like the strokes are basically inverted). Not sure if this can be overcome…

4 Likes

I think I have most if not all scripts ready. Would need a few more rounds of testing before releasing it.

5 Likes

It’s out! Thanks for everyone who helped on this! :smiling_face_with_three_hearts:

https://discuss.eroscripts.com/t/game-integration-a-tale-where-avy-moves-and-oniichan-cums-honey-moon-edition/108019

2 Likes

I’ve found this method also works on a few other Tyranoscript V5 games.

This is 白狼天狗とイチャイチャするやつ, developed with Tyrano V5.

Under \resources folder find “app.asar”. Unpack it. Modify the same “kag.tag_ext.js” mentioned above. You can repack it using 7zip, or just leave them in the app folder.

Game works and the custom player detects it pretty well.

2 Likes

This quote does not seem to work for the game I’m modding (the one mentioned above). Is there any other event listener other than “pause” such as “stopped” or “removed”?

Just noticed that I’ve attached wrong code, try changing pm.storage to null.

video.addEventListener("pause", function(event) {
    playScript(null);
});

and also add similar one to code below

            video2.addEventListener("play", function(event) {
                playScript(video_pm.storage);
            });
            video2.addEventListener("seeked", function(event) {
                playScript(video_pm.storage);
            });
            video2.addEventListener("pause", function(event) {
                playScript(null);
            });
1 Like

Thanks. In the case of momiji this still doesn’t work quite right, though.

Line114 -

            video2.addEventListener("pause", function(event) {
                playScript(null);
            });

This code doesn’t seem to do anything. The game does not use video2 to handle its scene playback I suppose?


Line 75 -

video.addEventListener("pause", function(event) {
    playScript(null);
});

This code had an effect. It does stop the script playback if one attends the pause menu. But it also stops script playback whenever the scene has been switched.
demo

(The game had a cross-fade transition between scenes which makes the previous video stops after the new one begins to play. Could this be the cause of this issue?)


:page_facing_up: kag.tag_ext.csv (rename to .js)

kag.tag_ext.txt (43.9 KB)

Can you test if this code works?

Added scriptPlayer on the top of the js file, and changed event listeners

video2.addEventListener(“play”, function(event) {scriptPlayer.playScript(video_pm.storage);});
video2.addEventListener(“seeked”, function(event) {scriptPlayer.playScript(video_pm.storage);});
video2.addEventListener(“pause”, function(event) {scriptPlayer.stopScript(video_pm.storage);});

video.addEventListener(“play”, function(event) {scriptPlayer.playScript(pm.storage);});
video.addEventListener(“seeked”, function(event) {scriptPlayer.playScript(pm.storage);});
video.addEventListener(“pause”, function(event) {scriptPlayer.stopScript(pm.storage);});

  • just reuploaded file, updated guide above.
1 Like

Works flawlessly! This will also be helpful when modding other games.
Incorporated your code into the game’s mod. Thanks so much for the contribution!

1 Like

I’m not sure if this is the correct way to fix this problem, try replacing play event listener with timeupdate event listener.

video.addEventListener("play", function(event) {scriptPlayer.playScript(pm.storage);});

to

video.addEventListener("timeupdate", function(event) {
	video.removeEventListener("timeupdate", arguments.callee);
	scriptPlayer.playScript(pm.storage);
});

,

video2.addEventListener("play", function(event) {scriptPlayer.playScript(video_pm.storage);});

to

video2.addEventListener("timeupdate", function(event) {
	video2.removeEventListener("timeupdate", arguments.callee);
	scriptPlayer.playScript(video_pm.storage);
});

In the case for Avy, I think it’s due to the game stalling before the video begins to play. So the scene switches, scripts are played, but the video playback starts ~200ms after.

This doesn’t happen with Momiji, which is made with Tyrano V5 and reads much more faster.

I’ll try out the code anyway and see if they helps.

I also noticed this and thought it was an engine related problem, not a Funscript Player related problem.

I checked video event cycle and found that timeupdate event is called 200~300ms after play event is occured.

with Momiji, timeupdate event is called 50~80ms before play event, I don’t think we need to update the code on the other games if they don’t have sync related problem.
image

or just adding a little delay when calling the playScript function on the video play event will work too.

1 Like

Tested the Timeupdate event listener code and it greatly improved sync with Avy (FunscriptPlayer v1.2 and v1.12.1 beta).

This is the modded file:
kag.tag_ext.txt (42.8 KB)

I guess this is definitely the method to use for this particular game. I will update the game mod once the new version drops.

Also might worth notifying @to4st for this discovery.

1 Like

@affqprow

Another Tyrano V5 game, Otutome Sakuya, has been modded by the community. I have attempted to mod the game using our code but have encountered some issues.

The game had an interesting file structure. Under \data\video, scenes for the same stage are grouped into individual folders.
image

Say the game plays 1.mp4 on stage 1, the application will try to play 1/1. This is impossible to provide a matching script for because filename cannot include “/”.
pr

Curiously, in the mod provided by @vylon, the name formatting have changed to 1-1.

I wondered how this was done. And it turns out vylon did more modification to app.asar and have reworked the file structure completely. If i have not mistaken, they must have also touched other code to make the game run.
image

So what I’m thinking is, is it possible to achieve this name conversion (either announced by the game or interpreted in Funscript Player) without heavily modifying the game files like this? Games can get updates and it’d be better to not carry out such rework each time.

It can be easily done by editing this part, replacing “/” with “-” will work.

	filterScriptName: function(scriptName) {
		return scriptName.substr(0, scriptName.lastIndexOf('.')) || scriptName;
	},
	filterScriptName: function(scriptName) {
		scriptName = scriptName.replace("/", "-");
		return scriptName.substr(0, scriptName.lastIndexOf('.')) || scriptName;
	},
1 Like

Thank you! Knowing how to read JavaScript helps… kag.tag_ext.txt
Here, a lite version of the Sakuya mod with modified kag.tag_ext.js and 99DM’s script only.

1 Like

It’s just simple
Tyrano games are controlled by scenario files in app.asar
You can modify the scenario file yourself

For example

Original script in main.ks
image

Use / symbols for folder structure in Tyrano games
But funscript players don’t have a deep folder structure
Also, you cannot use the / symbol in the file name

So I changed it like this
image

‘/’ Modified to use the ‘-’ symbol instead
The ‘-’ symbol does not have any special function in Tyrannogames, and can also be used in file names
All scripts associated with .mp4 have been modified

Rename all videos to new rules
After that, take it out of its original location and put it in the video folder

like this

As a result, the funscript player can access the video without going deeper into the structure

I apologize for my poor English
If you have the original game, you can easily find the difference
title_screen.ks, main.ks, bossrush.ks three files changed

1 Like