Ren'Py how to make multiple with punch or flash IN THE SAME LINE ?

Nayko93

Well-Known Member
Feb 3, 2018
1,245
2,730
hi , I need some help for my project please

here's my problem

I want to make a scene where the MC take a violent hit so he scream in pain

MC "AAAAAARRRRRGGGGGHHHHHH"

and to this I want to add vpunch to shake the screen and white flash

for the flash I already defined it with this " define flash = Fade(0.1, 0.0, 0.5, color="#fff") "

the problem is , I want to have MULTIPLE hpunch and multiple flash in a single line and not before or after this line , but at the same time as the text is displayed , like this

MC "AAAAAARRRRRGGGGGHHHHHH" with hpunch with hpunch with flash with hpunch with flash with flash

but renpy allow me to only put ONE "with" at the end of the line

I've already tried the " {nw} and extend " technique to put the effect in the middle my phrase but it make the text disappear when the effect play so it's not the right solution



I know that I could define a custom animation , lets call it "punch_flash" but I have no idea how do do this

I've read this page

but I don't understand a single thing of what they say ....
their "tuto" are made for people with a solid base knowledge , and I'm far from it ( first touched renpy 2 weeks ago ... )

so if someone know the simplest way to either force multiple flash and punch in the same line , or how to make a custom transition with multiple punch and flash ?

thank you
 

appelflappel

New Member
Mar 10, 2019
4
3
You were on the right track with the MultipleTransition class. In your case it would look something like
Python:
define punch_flash = MultipleTransition([
    False, hpunch,
    False, Pause(0.2),
    False, hpunch,
    False, Pause(0.3),
    False, flash,
    False, Pause(0.3),
    False, hpunch,
    False, Pause(0.2),
    False, flash,
    True])
Now the punch_flash transition represents a hpunch, followed by a 0.2 second pause, followed by another hpunch, and so on. You can tune the numbers in the Pause() transitions to make the pauses between the transitions as long as you would like. Hope this helps!
 
  • Like
Reactions: Nayko93

Nayko93

Well-Known Member
Feb 3, 2018
1,245
2,730
You were on the right track with the MultipleTransition class. In your case it would look something like
Python:
define punch_flash = MultipleTransition([
    False, hpunch,
    False, Pause(0.2),
    False, hpunch,
    False, Pause(0.3),
    False, flash,
    False, Pause(0.3),
    False, hpunch,
    False, Pause(0.2),
    False, flash,
    True])
Now the punch_flash transition represents a hpunch, followed by a 0.2 second pause, followed by another hpunch, and so on. You can tune the numbers in the Pause() transitions to make the pauses between the transitions as long as you would like. Hope this helps!
thanks you !! but it only do the flash , it don't do the hpunch
 

appelflappel

New Member
Mar 10, 2019
4
3
Oh I didn't realize hpunch was a built in transition, I'm not sure why that doesn't work. The following code is not very pretty but it should work at least. Somewhere at the start of your file you can put
Python:
init python:
    def flash_punch(who, what):
        renpy.say(who, what, interact=False)
        renpy.transition(hpunch)
        renpy.pause(0.5)
        renpy.say(who, what, interact=False)
        renpy.transition(hpunch)
        renpy.pause(0.7)
        renpy.say(who, what, interact=False)
        renpy.transition(flash)
        renpy.pause(0.7)
        renpy.say(who, what, interact=False)
        renpy.transition(hpunch)
        renpy.say(who, what)
And then in your script call this function using $ flash_punch(MC, "AAAAAARRRRRGGGGGHHHHHH")
 

Nayko93

Well-Known Member
Feb 3, 2018
1,245
2,730
Oh I didn't realize hpunch was a built in transition, I'm not sure why that doesn't work. The following code is not very pretty but it should work at least. Somewhere at the start of your file you can put
Python:
init python:
    def flash_punch(who, what):
        renpy.say(who, what, interact=False)
        renpy.transition(hpunch)
        renpy.pause(0.5)
        renpy.say(who, what, interact=False)
        renpy.transition(hpunch)
        renpy.pause(0.7)
        renpy.say(who, what, interact=False)
        renpy.transition(flash)
        renpy.pause(0.7)
        renpy.say(who, what, interact=False)
        renpy.transition(hpunch)
        renpy.say(who, what)
And then in your script call this function using $ flash_punch(MC, "AAAAAARRRRRGGGGGHHHHHH")
thank you but wow ! that's heavy just for that ...

so , this time it work I have punch punch flash punch like intended

BUT .... :

I can't remove the pause ( on the old one I could ) and it's too slow :(
if I try to remove a "pause" it don't play the transition on top and under this "pause"
for exemple if I remove the last "pause" , then the flash on top and the hpunch under it, don't play


each time there is a punch or a flash the text disappears and reappears ( it didn't do it with the old one )

why a build in transition create so many problem , there have to be a simpler way to make something as simple as multiple punch ....

what if we create a custom punch that act exactly like the build in hpunch but this one will be defined at the start so not build in so no stupidly bugged ?

anyway thank you for your help one again :)
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,490
7,035
why a build in transition create so many problem
What you're running into is a difference between what you want things to do and what they're designed to do.

A transition is a feature associated with showing a new image. So, when you say
Code:
scene my_image with hpunch
my_character "well, that was interesting"
then the transition is associated with putting the new scene on the screen, and runs BEFORE the "say" line that follows it. In other words, it "belongs" to the "scene" line, and that line has to complete before the "say" line executes. (The reality is slightly more complicated, but that's the basic idea.)

If you want to have effects like this overlap the "say" line, then what you should do is define an image using ATL, and put those effects inside the ATL. Even if an ATL image has pauses, multiple things going on, etc., that's all considered part of the image itself, so the "scene" line completes as soon as the image sequence begins running, and any effects within the ATL image continue while the "say" line is now executing.

So, if I'm understanding what you want, this is what you want to do:
Code:
define e = Character("Eileen")
image black = "#000"

image punchy:
    "ch6a_01_0" with hpunch
    pause 0.5
    "ch6a_01_0" with hpunch
    pause 0.5
    "ch6a_01_0" with hpunch
    pause 0.5
    "ch6a_01_0" with hpunch

label start:
    scene black
    e "ready to go"
    scene punchy
    e "what do you think?"
    return
("ch6a_01_0.jpg" was an image in my test code. Substitute with your own.)

The very first "hpunch" tends to get lost in the default transition between the "black" and "punchy" images, so even though I have four "hpunch" items, only three really are visible, at least for me. Your mileage may vary depending on what (if anything) you've done with the default scene transition.
 
  • Like
Reactions: anne O'nymous

Nayko93

Well-Known Member
Feb 3, 2018
1,245
2,730
What you're running into is a difference between what you want things to do and what they're designed to do.

A transition is a feature associated with showing a new image. So, when you say
Code:
scene my_image with hpunch
my_character "well, that was interesting"
then the transition is associated with putting the new scene on the screen, and runs BEFORE the "say" line that follows it. In other words, it "belongs" to the "scene" line, and that line has to complete before the "say" line executes. (The reality is slightly more complicated, but that's the basic idea.)

If you want to have effects like this overlap the "say" line, then what you should do is define an image using ATL, and put those effects inside the ATL. Even if an ATL image has pauses, multiple things going on, etc., that's all considered part of the image itself, so the "scene" line completes as soon as the image sequence begins running, and any effects within the ATL image continue while the "say" line is now executing.

So, if I'm understanding what you want, this is what you want to do:
Code:
define e = Character("Eileen")
image black = "#000"

image punchy:
    "ch6a_01_0" with hpunch
    pause 0.5
    "ch6a_01_0" with hpunch
    pause 0.5
    "ch6a_01_0" with hpunch
    pause 0.5
    "ch6a_01_0" with hpunch

label start:
    scene black
    e "ready to go"
    scene punchy
    e "what do you think?"
    return
("ch6a_01_0.jpg" was an image in my test code. Substitute with your own.)

The very first "hpunch" tends to get lost in the default transition between the "black" and "punchy" images, so even though I have four "hpunch" items, only three really are visible, at least for me. Your mileage may vary depending on what (if anything) you've done with the default scene transition.
thank you but in the meantime I simplid desided to use something else to make the effect
but I will keep this in a docs I can still use it laters

and so I have to define each image individually each time I want this effect?

like :

image punchy1:
"image1" with hpunch
pause 0.5
"image1" with hpunch
pause 0.5
"image1" with hpunch
pause 0.5
"image1" with hpunch

image punchy2:
"image2" with hpunch
pause 0.5
"image2" with hpunch
pause 0.5
"image2" with hpunch
pause 0.5
"image2" with hpunch
....

hope one they they integrate this automatically in renpy , because all others VN engine can have multiple transition at the same time without having to code something as complex as that
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Closest I can get is....

Python:
define flash = Fade(0.1, 0.0, 0.5, color="#fff")
define punch_flash = ComposeTransition(hpunch, after=flash)

label start:

    scene black with fade

    "*** START ***"

    scene image1 with punch_flash
    pause 0.25
    scene image1 with punch_flash
    pause 0.25
    scene image1 with punch_flash
    pause 0.25
    scene image1 with punch_flash

    return

I really don't understand why doesn't honor hpunch.
I tried some , but settled on as a "mostly works" solution.
 
Last edited:

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,490
7,035
hope one they they integrate this automatically in renpy , because all others VN engine can have multiple transition at the same time without having to code something as complex as that
I really don't understand why doesn't honor hpunch.
Well, these are the kinds of things that should probably be entered as issues over on Ren'py's GitHub. PyTom will never know about it unless someone points it out...
 
  • Like
Reactions: 79flavors

TDoddery

Member
Apr 28, 2020
170
160
This is kind of similar but a bit different so sorry if I might be going a bit off topic.

The things that catch me out with the use of ATL images "inline" in game code is that, on the one hand, the ATL can keep going irrespective of what say statements I have after it until I do another show (or something) which is OK and can work well.

But then on the other hand, if I have an ATL image that I want to finish playing and then something else happens without player input, so even if there's nothing like a say after it, then I have to do repeat "x" at the end of the ATL, and then I have to put in a pause after the ATL which is calculated to allow the ATL (times x) just enough time to finish, otherwise it just rushes to the next thing.

I've got the hang of it but as I say it catches me out.

It reminds me of that saying: "the best thing about computers is that they do exactly what you tell them to do, and the worst thing about computers is that they do exactly what you tell them to do."
 

K.T.L.

Keeping Families Together
Donor
Mar 5, 2019
555
1,079
Ok, going to jump on a soapbox here. All this is my opinion of course and will probably upset a few people who love these sorts of things... but...

As someone who plays a lot of renpy 'games' I'd urge you to think about this very carefully. There are few things as annoying, in renpy, as overdone transitions. Just because you *can* do something, it doesn't follow that you should. It's your game, of course, and you can do what you want, but annoying your players isn't going to turn them into fans.

As for multitransition not working with punches, it's probably because it's really incredibly annoying! Just like scripts with a slow dissolve on every single image change or hard pauses everywhere. When adding all these things to your VN, pause for a moment to imagine how your players are going to view them...
 
  • Like
Reactions: 79flavors

Nayko93

Well-Known Member
Feb 3, 2018
1,245
2,730
Ok, going to jump on a soapbox here. All this is my opinion of course and will probably upset a few people who love these sorts of things... but...

As someone who plays a lot of renpy 'games' I'd urge you to think about this very carefully. There are few things as annoying, in renpy, as overdone transitions. Just because you *can* do something, it doesn't follow that you should. It's your game, of course, and you can do what you want, but annoying your players isn't going to turn them into fans.

As for multitransition not working with punches, it's probably because it's really incredibly annoying! Just like scripts with a slow dissolve on every single image change or hard pauses everywhere. When adding all these things to your VN, pause for a moment to imagine how your players are going to view them...
don't worry, I've played enough game to know what upset people and I don't plan on doing something like that , it was just for 2 or 23 time in the game I wanted to make the screen shake 2 time and flash 4 time
in total this thing last 1.2 second so nothing to annoying I think ...