Author Topic: SCI1.1: Speech balloons on actors and such  (Read 3164 times)

0 Members and 1 Guest are viewing this topic.

Offline Kawa

SCI1.1: Speech balloons on actors and such
« on: September 09, 2015, 07:36:14 AM »
Police Quest 3 had these, but that used the old system with Text resources and all that. Here's my take on a no-hassle implementation that supports Messages.

By the end of this, you should be able to make this:




First, define a couple talkers. I called them NEATSPEAK1 through 5.

To main.sc's locals, add these:
Code: [Select]
gNeatSpeaker
[gNeatSpeakers 5]

In Template::init, add this:
Code: [Select]
(= gNarrator templateNarrator)
(= gNeatSpeaker neatSpeaker) ; this bit
(= gWindow mainWindow)

Elsewhere -- I picked between templateNarrator and testMessager -- add this:
Code: [Select]
(class NeatNarrator of Narrator
(properties)
(method (aim target)
(= gWindow gNewSpeakWindow)
(gNewSpeakWindow
tailX: (target nsLeft?)
tailY: (- (target nsTop?) 16)
)
; TODO: detect heads and center on those instead where available.
)
)
(instance neatSpeaker of NeatNarrator
(properties)
(method (init param1)
(= font gFont)
(super init: &rest param1)
)
)

In templateNarrator::init, add
Code: [Select]
(= gWindow mainWindow)If you use other narrators or talkers too, you might want to do similarly for those.

In testMessager::findTalker, add these cases:
Code: [Select]
(NEATSPEAK1
(gNeatSpeaker aim: [gNeatSpeakers 0])
gNeatSpeaker
)
(case NEATSPEAK2
(gNeatSpeaker aim: [gNeatSpeakers 1])
gNeatSpeaker
)
(case NEATSPEAK3
(gNeatSpeaker aim: [gNeatSpeakers 2])
gNeatSpeaker
)
(case NEATSPEAK4
(gNeatSpeaker aim: [gNeatSpeakers 3])
gNeatSpeaker
)
(case NEATSPEAK5
(gNeatSpeaker aim: [gNeatSpeakers 4])
gNeatSpeaker
)

Almost there. Before you display a message, perhaps in your room's init, you can now set the gNeatSpeakers entries you'll use to those views that'll speak like that:
Code: [Select]
(= [gNeatSpeakers 0] gEgo)
(= [gNeatSpeakers 1] neatTest) ; this is the coin in the screenshot.

Of course, this'll invalidate the pointers when you change rooms, but bulletproofing that is a challenge for later.

TODO: protect from stale pointers, allow separate heads, allow speech animation, look into SCUMM-style.
« Last Edit: May 25, 2017, 12:17:58 PM by Kawa »



Offline Cloudee1

Re: SCI1.1: Speech balloons on actors and such
« Reply #1 on: December 10, 2015, 09:22:09 AM »
Just came across this. That is actually pretty neat.

Not sure though about changing the orientation, or the tail to a thought bubble rather than a speach bubble.



Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Kawa

Re: SCI1.1: Speech balloons on actors and such
« Reply #2 on: December 10, 2015, 09:54:10 AM »
*** Untested ***

In SpeakWindow.sc, add a thought property, set to FALSE. Assuming the thought tails are the same size as the speech tails, add this before the part where underBits1 is set in SpeakWindow::open:
Code: [Select]
(if (thought) (= temp3 (+ temp3 8)) )
Because temp3 tracks which tail sprite to show. Don't forget to reset the thought flag afterwards, and good luck~

Offline Cloudee1

Re: SCI1.1: Speech balloons on actors and such
« Reply #3 on: December 10, 2015, 11:17:16 AM »
Yeah, I just did that myself... Here is an alternative way to accomplish the same scenario, at least from what I could trace by looking at some of what Phil has done... I'll try to spell out all of the steps from ground 0

First go into the Messages for a script that you plan to fire this off in and add a new global talker... In my case, I wanted the scientist to talk so that is what I named it "SCIENTIST"

Then I went to the specific message that I wanted to appear inside the speach bubble and changed the talker value from Narrator to my new scientist talker.

Then in the SpeakWindow script, I added thought to the list of properties for the speakWindow class

Code: [Select]
       thought 0

and slightly further down in the open method of the the speakWindow class, I included this just above the not isBottom if statement.

Code: [Select]
        (if (thought)
        = temp3 (+ temp3 8)
        )

Next, I went to the room script of where this talker is going to be used, in my case room 66, and I added two use statements up top with the other use statements.

Code: [Select]
(use "Talker")
(use "SpeakWindow")

Then at the bottom of the script, I made a public instance of a Narrator. In my case, since it is the scientist, I named it scientistTalker and in the tailX tailY attributes, I pointed it to the scientist Actors position.

Code: [Select]
(instance public scientistTalker of Narrator
    (properties
        talkWidth 120
    )

    (method (init param1)
        = font gFont
        = gWindow SpeakWindow
        (send gWindow:
            tailX((scientist:nsLeft))
            tailY((scientist:nsTop))
            xOffset(-50) // Offset from tail.
            thought(FALSE) // Speach Bubble, TRUE for thought
        )
        (super:init(rest param1))
    )

    (method (dispose param1)
        = gWindow gWindow2
        (super:dispose(rest param1))
    )
)

Also, since I made it a public instance, I added in the instance name to the export list back up at the top of the room script.

Code: [Select]
(exports
    0 rm066
    1 scientistTalker
)

and finally, I added the SCIENTIST case to the findTalker method of the testMessager of Messager instance found in the Main script real close to the bottom.

Code: [Select]

            (case SCIENTIST
                ScriptID(66 1) // Script 66, export 1
            )

Compiled everything and fired it up, everything seems to work.

Notes on usage...
In order to switch between the tails. When setting the xOffset in the room script instance.
   Negative, uses the tail which points to the right...
   Zero, uses the tail which points straight down...
   Positive, uses the tail which points to the left...

Moving and adjusting the windows location is done with the xOffset, but moving the tails position can be handled with the tailX and tailY values. You can always just hard code them if you want or do some math on them to tweak them to just the right position.

Code: [Select]
            tailX(10)
            tailY(105)
Code: [Select]
            tailX(- (scientist:nsLeft) 20)
            tailY(- (scientist:nsTop) 10)

So all of that said and done, these settings give me the attached result. The only thing left to do is figure out how to center the text inside the speach bubble.

Code: [Select]
            tailX(- (scientist:nsLeft) 20)
            tailY(- (scientist:nsTop) 10)
            xOffset(-45) // Offset from tail... tail points right
            thought(FALSE) // Speach Bubble, TRUE for thought





« Last Edit: December 10, 2015, 12:03:13 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: SCI1.1: Speech balloons on actors and such
« Reply #4 on: December 10, 2015, 12:16:34 PM »
Good tutorial! But what's all this old-style syntax!?!? :P
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: SCI1.1: Speech balloons on actors and such
« Reply #5 on: December 10, 2015, 12:22:56 PM »
I haven't been brave enough to look into the sierra syntax yet lol

Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Collector

Re: SCI1.1: Speech balloons on actors and such
« Reply #6 on: December 10, 2015, 12:49:54 PM »
Hey Cloudee, I converted your Aquarius to Sierra script and it worked flawlessly, at least after a Companion bug fix by Phil. So with the new Companion it seems to be an easy transition.
KQII Remake Pic

Offline troflip

Re: SCI1.1: Speech balloons on actors and such
« Reply #7 on: December 10, 2015, 12:53:41 PM »
It does take some getting used to, but it feels pretty natural after a while. And all the SCI 1.1 tutorials should eventually be in Sierra Script (or else people will get confused!).

Lemme know if there's confusion or unclear stuff about the new syntax. The docs on scicompanion.com should all refer to the new (or rather very old) syntax.
« Last Edit: December 10, 2015, 01:04:23 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Collector

Re: SCI1.1: Speech balloons on actors and such
« Reply #8 on: December 10, 2015, 02:35:29 PM »
And all the SCI 1.1 tutorials should eventually be in Sierra Script (or else people will get confused!).

Agreed. I am thinking of going through the Wiki and updating it with the Sierra scripting. Perhaps adding it to instead of replacing the Studio script.

Lemme know if there's confusion or unclear stuff about the new syntax. The docs on scicompanion.com should all refer to the new (or rather very old) syntax.

Maybe we should refer to simply as the original syntax vs Studio syntax.  :)
KQII Remake Pic

Offline troflip

Re: SCI1.1: Speech balloons on actors and such
« Reply #9 on: December 10, 2015, 02:42:15 PM »
The term I've been using in my documentation is Sierra Script, so we should probably stick to that ("Script" was the term Sierra appeared to use).
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: SCI1.1: Speech balloons on actors and such
« Reply #10 on: December 10, 2015, 04:41:40 PM »
Ok, I have now looked at it...  ???

I'm still not sure I am ready. I have been making some pretty steady progress in getting some of my sci0 work converted over to sci1.1 and having to re-evaluate how I do everything will seriously slow me down at this point.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: SCI1.1: Speech balloons on actors and such
« Reply #11 on: December 10, 2015, 05:10:43 PM »
I don't think we should call Sierra Script original Script. I almost thought you were referring to Studio script.
Brass Lantern Prop Competition


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.118 seconds with 24 queries.