Large Portraits

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Feenicks
Metal Slime
Posts: 697
Joined: Tue Aug 10, 2010 9:23 pm
Location: ON THE AIR IN THE AIR
Contact:

Large Portraits

Post by Feenicks »

Okay, so I'm doing large portraits for harpy game. While I currently just have them as transparent backdrops, what I'd really like to do is to be able to replace regular portraits with them without having to plotscript every conversation out. At the very least I'd like to have the ability to just have a generic plotscript to use, and the lack of arguments which I can throw to any script triggered from a text box complicates that.
Here's what I have so far:

Code: Select all

plotscript,portraitReplace,begin
variable(portrait)
variable(portraitNumber)
portrait := lookup slice(sl:textbox portrait)
if(portrait) then(
portraitNumber := get sprite set number(portrait)
switch(portraitNumber) do(
case(1) replace backdrop sprite (portrait,37)
#etc.
case(else) do()
)
#this would be where the backdrop's moved into position - it'd be the same each time, unless I'm horribly wrong with how backdrops get loaded in
)
end
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

You can also just set the portrait-backdrop as the backdrop for the textbox, is that good enough? But then you don't get the portrait features to select portrait by party position.

How would you trigger this script? From the NPC which triggers the textbox? Neither the "run <script> instead" or "run <script> next" textbox conditionals are very useful for this. (And that's a pretty big oversight in the engine). One option is actually to have a loop constantly running to detect when a new textbox is displayed.

If you did use "replace backdrop sprite", the simplest way to position that slice so that it's aligned with/fills the screen is "put slice screen(portrait, 0, 0)". However, the portrait appears above the textbox, not behind. You could fix that with "move slice below(lookup slice(sl:textbox portrait box), lookup slice(sl:textbox box))".
User avatar
Feenicks
Metal Slime
Posts: 697
Joined: Tue Aug 10, 2010 9:23 pm
Location: ON THE AIR IN THE AIR
Contact:

Post by Feenicks »

I'd go the backdrop method, but it would mean that the portraits would be getting covered up to varying degrees for any amount of text greater than two lines. Normally that's fine, but I want to be able to account for edge cases like in the attached picture.

As far as I can tell, the best place to do it would be from a script triggered from an NPC. I'd have to be triggering the script for every textbox, though, which is the main reason I can't really see a way of having a generic plotscript work out. For NPCs with just one textbox (treasure chests and the like) I could probably make a generic script, but unfortunately I don't have too many of those.

There's two main reasons I want to go this method; the first is so that the portraits are always sitting on top of the text boxes (so just moving them to 0,0 isn't the best solution), and the second is that I can use portraits in places where I'm already using backdrops without having to make a whole lot of variations of said backdrops. The slice layering information is useful though, thanks.
Attachments
theonewithharpiesinit0151.png
theonewithharpiesinit0151.png (10.68 KiB) Viewed 938 times
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

OK, if you want the portraits in front then you don't need to use "move slice below" at all.

I would go with a script that constantly runs and checks whether a new textbox has appeared, and if so fixes it. You can run it each tick with a timer. Then you don't need to modify any of your existing scripts, NPCs, or textboxes. Like so:

Code: Select all

# Call from new-game and load-game scripts.
plotscript, change portraits to backdops, begin

  variable&#40;portrait&#41;
  portrait &#58;= lookup slice&#40;sl&#58;textbox portrait&#41;
  # This is false if no textbox displayed
  if&#40;portrait&#41; then&#40;
    # Check whether this portrait hasn't been processed already
    if&#40;get sprite type&#40;portrait&#41; == spritetype&#58;portrait&#41; then&#40;

      switch&#40;get sprite set number&#40;portrait&#41;&#41; do&#40;
        case&#40;1&#41; replace backdrop sprite &#40;portrait,37&#41;
        #etc.
        case&#40;else&#41; do&#40;&#41;
      &#41;
      #this would be where the backdrop's moved into position - it'd be the same each time, unless I'm horribly wrong with how backdrops get loaded in
    &#41;
  &#41;

  # Run again next tick
  set timer&#40;0, 0, 1, @change portraits to backdops&#41;
end
I'm not completely clear on the portrait positioning. So you want to have the ability to show the portrait at different positions on different textboxes? Then you probably want to move the portrait slice to a fixed position like (-20, -80) relative to its starting position. If not, moving it to (0,0) on the screen would be the right choice.
User avatar
Feenicks
Metal Slime
Posts: 697
Joined: Tue Aug 10, 2010 9:23 pm
Location: ON THE AIR IN THE AIR
Contact:

Post by Feenicks »

Alright, it works! There's a 1-tick delay in between the portrait showing up and it being replaced by the bigger portrait, but as I'm just going to blank out the portraits for the eventual final release of harpy game, that won't be a big deal.
Attachments
thanks TMC~
thanks TMC~
theonewithharpiesinit0152.png (11.79 KiB) Viewed 927 times
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

I wonder if we need an each-tick script trigger?

An each-tick script would wreck havoc if you used any "wait" commands, but it would make stuff like this simpler.

It would also be great for map layer parallax scripts.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Ah, I hadn't considered that one-tick delay.

An each-tick trigger would be the same using timers if you don't use wait commands, and could fail horribly if you do, due to "Don't double-trigger scripts" being broken.

Script multitasking, and being able to run scripts after built-in gameplay logic instead of before hopefully won't be far off, and should be a much better solution to things like map layer parallax and that one-tick delay when replacing the portrait slice.
Post Reply