Fullscreen story sequences with decisions

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Fullscreen story sequences with decisions

Post by meadwarrior »

Hello!

An important part of my game will be the 'fullscreen' story sections, see the example below.
I have a few questions regarding those.

Image

:?: Is it possible to display png transparency in the fullscreen picture with the game screen still being rendered, like in the example? I only managed to get a fully black background.

:?: I want the story to react to the players decisions.
How would I go about adding buttons to the fullscreen scene that lead to another fullscreen scene (or back to the game)?
I've looked around in the documentation and the forum, but I'm still not sure what the best way would be. :oops:

:?: I want some decisions to influence the game world (e.g. spawn a monster).
How would I set this up the best way? Can this partly be done in ESB?

Thanks!
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Fullscreen story sequences with decisions

Post by Sophia »

You can draw the game screen in the background of a dsb_fullscreen by using the game_draw parameter. For details see the documentation here.

When you create a fullscreen renderer, you can specify a click_func which is executed when the mouse is clicked. By checking the coordinates you can create buttons. If you do this often, you might want to create some sort of code structure for reading click zones and such.

Spawning a monster is fairly easy, because you can just activate a monster_generator.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Fullscreen story sequences with decisions

Post by meadwarrior »

Thank you! I'll try my luck :mrgreen:

If I understand it correctly, I'd activate the monster generator out of the function with the fullscreen, right?
So I'd use the numbers in brackets [XY] ESB provides?
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Fullscreen story sequences with decisions

Post by Gambit37 »

Ian Scho wrote a whole "event manager" for full-screen interludes. It's quite complex, but it might give you some clues on how to go about it. It's hosted on MediaFire here: http://www.mediafire.com/file/ym1d7qdjn ... events.zip It's pretty old though and might not work with newer DSB/ESB.

I've looked at a creating a simplified version for my own dungeons, but it's on hold while I work on my DM update project.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Fullscreen story sequences with decisions

Post by meadwarrior »

Thanks, Gambit, I'll check it out!
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Fullscreen story sequences with decisions

Post by Gambit37 »

Also, here's the basic approach to creating buttons that Sophia was suggesting:

In my call to the FSR (full screen renderer), the second parameter is the "click" function, mhf_options_click in this case.

Code: Select all

function mhf_options()
  dsb_fullscreen(mhf_options_draw, mhf_options_click, true, true, { fade = false, game_draw = false })	
end
Note the table of booleans in parameter 5: if you set game_draw = true, the full game UI is drawn behind your FSR, so if there's blank spaces or semi transparency in any of the bitmaps used in your FSR, the game will show through.

Here's my click function. It's constantly running while the FSR is displayed, and the x,y,buttonpressed variables will constantly update as the player moves the mouse and clicks it. So you can respond to that input by checking the position of the mouse and checking whether it's clicked. In my function, all I do is return true, which does nothing other than cause the FSR to abort/close. So whatever you want to do for that mouse click in that position, just add your code before the return true command. For example you could send a M_ACTIVATE message to a specific door, monster generator, etc, or display another FSR. Just remember that every FSR must eventually exit, and each FSR will return control to where it was called from.

Code: Select all

function mhf_options_click(x, y, buttonpressed)
  if ((x > 468 and x < 602) and (y > 436 and y < 468)) then
    if (buttonpressed == 1) then
      return true
    end
  end
return nil
end
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Fullscreen story sequences with decisions

Post by Gambit37 »

One other thing, if you're checking lots of button clicks in different positions, you can improve your code to check for the button click, then check all the positions:

Code: Select all

function mhf_options_click(x, y, buttonpressed)
    if (buttonpressed == 1) then
      if ((x > ?? and x < ??) and (y > ?? and y < ??)) then
        [.. button code 1 ...]
        return true
      elseif ((x > ?? and x < ??) and (y > ?? and y < ??)) then
        [.. button code 2 ...]
        return true
      end
    end
    return nil
end
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Fullscreen story sequences with decisions

Post by Sophia »

If you're doing lots of checks, of course, it would make more sense to store your coordinates in a table and iterate over all of those table entries. You can also store a function in the table to call when that button is pressed.
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Fullscreen story sequences with decisions

Post by Gambit37 »

Yep, agreed, but I didn't want to confuse the basic issue with too much code.
Out of interest, what's the correct syntax for storing a function in a table? Do you mean just a function call, or the entire function itself?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Fullscreen story sequences with decisions

Post by Sophia »

You can store a reference to a function in a table, which you already know how to do, but that reference can be to a lambda function as well.

Code: Select all

some_table.my_func = function (x, y)
   do_stuff(x)
   do_other_stuff(y)
end
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Re: Fullscreen story sequences with decisions

Post by terkio »

"You can be on the right track and still get hit by a train!" Alfred E. Neuman
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Fullscreen story sequences with decisions

Post by meadwarrior »

Thank you, guys! The choices work so far :)
I mostly used your method, Gambit.

I'll take a look into making tables as well!
Post Reply