Author Topic: SCI0: right click to look like in QFG2  (Read 1545 times)

0 Members and 1 Guest are viewing this topic.

Offline robbo007

SCI0: right click to look like in QFG2
« on: December 26, 2023, 09:09:32 PM »
Hi guys,
Is it possible using the SCI0 template to use the right click mouse button on things to get a look description like what they did with QFG2? What code is involved? How do you link this to your handleEvents etc?
Thanks,



Offline lskovlun

Re: SCI0: right click to look like in QFG2
« Reply #1 on: December 26, 2023, 09:42:46 PM »
Yes, you can do this in SCI0 (it works in Codename: ICEMAN, for example). The implementation there is much simpler, too.

Offline robbo007

Re: SCI0: right click to look like in QFG2
« Reply #2 on: January 05, 2024, 11:06:30 AM »
Thanks. I was looking through the source code to try and work where its declaring this. I see for example in Room 10 the Hotel lobby, the fish picture on the wall. They are using a RPicView and the handleEvent is declared there also. Does it have something to do with that? I can't see anything else that would refer to a mouse click on the view or part of screen?

Code: [Select]
(instance picturePic of RPicView
(properties
y 124
x 43
z 30
view 10
loop 2
priority 5
)

(method (handleEvent event)
(cond
((super handleEvent: event))
((Said '[/painting,(wall<left)]>')
(cond
((TurnIfSaid self event 'look/*'))
((Said 'look[<at]')
(Print 10 3) ; "There is a picture of a Humuhumunukunukuapua'a on the wall."
)
)
)
)
)
)

Offline doomlazer

Re: SCI0: right click to look like in QFG2
« Reply #3 on: January 05, 2024, 05:40:09 PM »
I saw this recently in Laura Bow 1.

In the starting room rm44 they use a combination of the MousedOn and DoLook procedures:

Code: [Select]
(instance sofa of RPicView
(properties
y 169
x 172
view 144
cel 1
priority 13
signal 16384
)

(method (handleEvent event)
(if (MousedOn self event 3) ;3 == rightClick
(event claimed: 1)
(DoLook {couch})
)
)
)

MousedOn is defined in Interface.sc (script 255):

Code: [Select]
(procedure (MousedOn obj event theMods)
(cond
((!= (event type:) 1) 0)
((and (>= argc 3) theMods (== (& (event modifiers:) theMods) 0)) 0)
((obj respondsTo: #nsLeft)
(InRect
(obj nsLeft:)
(obj nsTop:)
(obj nsRight:)
(obj nsBottom:)
event
)
)
)
)

And DoLook is defined in Main.sc:

Code: [Select]
(procedure (DoLook param1 &tmp temp0)
(StrCpy (User inputLineAddr:) {Look })
(StrCat (User inputLineAddr:) param1)
((= temp0 (Event new:)) type: evSAID)
(Parse (User inputLineAddr:) temp0)
(User said: temp0)
(temp0 dispose:)
)

Hope that helps a little.

Edit: In case it's not obvious, this simulates the player typing LOOK COUCH, so it also requires (Said 'look/couch') to exist as well. In this specific case that exists in the region associated with rm44, insideReg.sc (script 210), but it would be easier just to include it in the Sofa's handleEvent method before or after the MousedOn check.

Also, I might be misremembering, but I recall the difference between RPicView and the PicView in older SCI0 games is PicView doesn't respond to nsLeft. You might need to port RPicView into your project as well.
« Last Edit: January 05, 2024, 09:50:56 PM by doomlazer »

Offline Doan Sephim

Re: SCI0: right click to look like in QFG2
« Reply #4 on: March 18, 2024, 11:49:08 AM »
Here's what I do in Betrayed Alliance. It might not be the most efficient code, but it works for me well enough.
First I will make a procedure:
Code: [Select]
(procedure (checkEvent pEvent x1 x2 y1 y2)
(if
(and
(> (pEvent x?) x1)
(< (pEvent x?) x2)
(> (pEvent y?) y1)
(< (pEvent y?) y2)
)
(return TRUE)
else
(return FALSE)
)
)
I will reference this procedure in the handleEvent method in this way:
Code: [Select]
(if (== (pEvent type?) evMOUSEBUTTON)
(if (& (pEvent modifiers?) emRIGHT_BUTTON)
(if (checkEvent pEvent 92 123 65 117) ; clicked within the box of these coordinates
(PrintOther 18 6)
)
You can also reference the coordinates of a view this way:
Code: [Select]
(checkEvent pEvent (mapItem nsLeft?) (mapItem nsRight?) (mapItem nsTop?) (mapItem nsBottom?))
(PrintOther 18 24)
)
You can also check to see if the click happened on a control color:
Code: [Select]
(if
(== ctlGREY (OnControl ocSPECIAL (pEvent x?) (pEvent y?)))
(PrintOther 18 77)
)
Or on a priority color:
Code: [Select]
(if
(== ctlYELLOW (OnControl ocPRIORITY (pEvent x?) (pEvent y?)))
(PrintOther 18 78)
)
This is what works for me. Perhaps when I start a new project, I'll look into having something more global, but this does the trick for now,



SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.068 seconds with 23 queries.