Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Charles

Pages: [1] 2 3 4
1
SCI Syntax Help / Re: Setting a Cursor's location
« on: January 13, 2020, 11:05:34 PM »
I donít have the code snippets in front of me right now, but QFG1VGA and QFG3 also both move the mouse cursor programmatically (when clicking the ďotherĒ menu for running/sneaking/magic).  I would expect those to also be similar code to the above.

So as far as I can tell, there arenít two sets of variables ó one for visual one for actual cursor placement.

The thing thatís occurring to me now is that the QFG1EGA code only sets cursor coordinates if it detects no mouse. That uses SCI0, like your Betrayed Alliance, while the other examples use SCI1. Itís possible SCI0 interpreters donít actually let you position the actual cursor.

Iím racking my brains trying to think of an SCI0 example, but the closest I can get is vaguely recalling being annoyed when QFG2 used to move my mouse back to the corner after cutscenes. And even then, thatís technically SCI1, too.

2
SCI Syntax Help / Re: Setting a Cursor's location
« on: January 11, 2020, 08:41:33 AM »
I don't know much about Studio syntax, but looking at QFG1's code they did:

Code: [Select]
(theGame setCursor: normalCursor TRUE 304 174)

which in turn called the setCursor precedure on the Game object in script 994:
Code: [Select]
(method (setCursor cursorNumber &tmp oldCursor)
;
; Set the cursor form, returning the previous form

(= oldCursor theCursor)
(= theCursor cursorNumber)
(SetCursor cursorNumber &rest)
(return oldCursor)
)

which is calling the kernel command SetCursor http://scicompanion.com/Documentation/Kernels/SetCursor.html?highlight=setcursor

I'm sorry it's not a solution to your problem, but maybe it's a start to help debug it?

[EDIT: Just to confirm, you're seeing this behaviour when running in DosBox?]

3
SCI Development Tools / Re: Decompilation Archive
« on: November 18, 2019, 09:19:51 AM »
That sounds like a good idea. Of course, QFG1's minigames take Ego's stats into account, so those may be hard to implement.

I've thought about that one before, and I figure that could be mitigated with a difficulty setting. Easy uses maxxed out stats, hard uses new-character stats, etc... with extra magic potions... maybe a little play-testing to find the right balance between hard and impossible.

4
SCI Syntax Help / Re: Police Quest 1 VGA
« on: November 08, 2019, 12:01:01 PM »
@ Kawa,
I do not understand.
I have to write a "sentence" (code) with "GetFarText" in a script file?
Like this (example):
https://zupimages.net/viewer.php?id=19/45/xtsa.png

You had a typo in your post... an extra 't'. But it looks like you're spelling it correctly in your code.
Try these resources:
http://sierrahelp.com/SCI/SCIStudio3Help/SCC/Kernel_GetFarText.html
http://scicompanion.com/Documentation/Kernels/GetFarText.html?highlight=getfartext

I haven't used this function itself, but don't think you can call it as an exact substitute for the regular text function.

You may need to do something like this:
Code: [Select]
(method (doVerb theVerb param2 &tmp [test1 50] [str 50])
     (GetFarText 1 35 @str)
     (Printf "The %s won't fit in the box" @str)
)
(edit: posted before I finished typing)

That will retrieve the text from 1 35 and store it in the new str temp variable.  Then you reference that temp variable in the Printf function.

I'm not sure if that will fix your problem, honestly. I'm not very strong in SCI code myself yet.

5
Didn't see this posted elsewhere on here, and thought everyone'd be interested.

https://www.kickstarter.com/projects/klytos/the-sierra-adventure-the-story-of-sierra-on-line

Shawn Mills, one of the co-founders of Infamous Quests, has written a book about the history of Sierra, and has started a kickstarter to get it professionally edited and printed.

Some of the Backer Rewards include autographed copies from The Coles (already gone), and Josh Mandel.

Looks interesting.


6
SCI Syntax Help / Re: Can someone explain Flags to me?
« on: July 12, 2019, 10:50:10 PM »
I betcha whatís happening is the compiler is interpreting the |= as:
Code: [Select]
(= [gameFlags (/ (/ flagEnum 16) 16)] (| [gameFlags (/ flagEnum 16)] (>> $8000 (mod flagEnum 16))))

So, dividing the flag# by 16, then by 16 again.

If thatís the case, Iíd expect (Bset 16) to actually set flag 0, (Bset 17) to set flag 1, etc. and (Bset 256) to set flag 16.

7
SCI Syntax Help / Re: Can someone explain Flags to me?
« on: July 10, 2019, 11:10:18 PM »
Iím leaning towards there being an error in the Bset procedure.

Try doing some methodical testing:
Code: [Select]
(Bset 0)
(FormatPrint ... the game flag print code)
(Bset 1)
(FormatPrint  blahblah)
(Bset 69)
(FormatPrint ...)

Incidentally, the 8400 from the earlier output translates to binary 1000 0100 0000 0000, i.e. flag 0 and flag 5 are true. An easy way to convert is just ask google (or DuckDuckGo) for ď0x8400 in binaryĒ. With 0x#### being a common shorthand for ďhex numberĒ.


8
SCI Syntax Help / Re: Can someone explain Flags to me?
« on: July 10, 2019, 09:30:38 AM »
Is there a way to flush print the contents of gameFlags all over so I can check if the wrong bit is getting set for the bag?  I wouldn't even know how to go about fixing that, but I really just can't see anything that would cause this behavior and it's the only thought I'm having.

Try using %x instead of %d for the formatting. That'll display the hex value, instead of the signed number.  That'll make it easier to paste into your favorite hex calculator (I love Win10's calculator with it's Programming mode, for seeing hex and binary values).

How many bytes is your flag array?  It sounds like your Bset procedure isn't limiting itself to the specified bit. The code looks fine to me though, so to debug and see exactly what's in the flag arrays try: (so if your flag array is 5 bytes long)
Code: [Select]
(FormatPrint
    "gameFlags: %04x %04x %04x %04x %04x"
    [gameFlags 0]
    [gameFlags 1]
    [gameFlags 2]
    [gameFlags 3]
    [gameFlags 4]
)

Then convert that number into binary, and see the state of each flag.

9
SCI Syntax Help / Re: Can someone explain Flags to me?
« on: June 12, 2019, 02:46:40 PM »
Also considering the AddToScore procedure, which relies on the Btst/Bset/Bclr trio, let's round down to a hypothetical 50 flags being read in a single scene ( i.e. the current script, main.sc, game.sc, and whatever locales and regions are also included with the current script).  Is that a practical consideration?  50 flags read in a single game scene sounds more than sufficient, but I haven't done compared many games.

The only code I've really looked through is QFG1, and I'm struggling to recall if it ever did more than 5 flag read/writes in a single scene.

10
SCI Syntax Help / Re: Can someone explain Flags to me?
« on: June 12, 2019, 12:14:07 PM »
You can put them wherever. You can define then, or use enums. Enums are actually a bit easier to manage.  I mean, heck, if you wanted you could just use numbers for everything and keep it in your head.  Defines and Enums make no difference to the compiled code. They're only for making your code easier to read.  When they get compiled, the compiler will basically just do a find/replace with the defined or enumerated value.  They both have their place.  Defines are great for one-off values. Enums are great if you're defining a bunch of sequential values, like flags.

You could put enums in a seperate .sh file and include that in game.sh (although if you do that, the tooltip may not properly show up in SCICompanion when you hover over it).

I'll show you the more complicated example, and let you pare down as necessary. So if you have 160 flags to play with (as in the template game default), you can make those flags be whatever you want. Let's say your game has 40 rooms, and you want to know if ego has visited any room before. Then you have another 120 flags for game states or puzzle points.  You can break those up into multiple enums for easier readability.

in Game.sh:
Code: [Select]
;;; Sierra Script 1.0 - (do not remove this comment)
;put the Sierra Script comment at the top, so we can use sierra script in the header file
(include gameEnumVisited.sh)

create a new file called gameEnumVisited.sh:
Code: [Select]
;;; Sierra Script 1.0 - (do not remove this comment)
(enum    ;the default starting point is 0, although you can specify another)
   FLAG_VISITED_ROOM1    ;this is given a value of 0
   fVisitedRoom2                 ;this is given a value of 1
   VISITED_RM3                 ;this is given a value of 2
   ;... continue for as many as needed
   ;NOTE, flags can be called whatever you want, but being consistent with your naming will make your code easier to read.
)

(define FLAG_ROOM4  3)  ;we've explicitly given this a value of 3. We could have also made this the next line in the enum

;game states are called out here
(enum 40  ;we're starting this enum at 40, for the game state flags.
    fEgoIsJumping  ; has a value of 40. For when ego's jumping off a massive cliff.
    FLAG_BABAFROG ; has a value of 41. For when ego has turned Baba Yaga into a frog.
)

;puzzle points are defined here, so the user doesn't double-dip on points.
(enum 120
    POINTS_JUMPED ;120.  User jumped. Yay. Give yourself 5 points.
)

Then in each room's script, in the dispose code you would add the following
Code: [Select]
(method (dispose)
(Bset FLAG_VISITED_ROOM1) ; sets flag#0 to 1 (i.e. turns it on, or sets as TRUE)
                ;we'll also give the user some points, because the had to jump to leave the room
                (AddToScore POINTS_JUMPED 5) ;the AddToScore procedure will only add points if the POINTS_JUMPED flag is 0. 
                ;So no other checking is required. The user will only get 5 points once.
(super dispose:)
)

Keep in mind that you can still use Btst to check if points have been awarded. It's still just a flag.

11
SCI Syntax Help / Re: Can someone explain Flags to me?
« on: June 12, 2019, 11:06:55 AM »
It can be fun to learn about bit operations and binary/hex and all of that, but like Kawa said, that's all irrelevant knowledge for the Btst, Bset and Bclr procedures.  They do all the heavy lifting for you.

All you need to remember is that a single variable can hold 16 flags.  So the template game has 10 variables assigned to the gameFlags array. Ergo, 160 flags.  The first flag is flag #0, the last is flag #159. If you need more flags, extend the array; you get 16 more flags for each variable you extend the flag array.

You tell the Btst, Bset and Bclr procedures which flag number you want to test/set/clear.  And you should use an enum to track your flags, just to make things easier to read/follow. The enum's won't use any memory since the compiler will hardcode whatever number the flag is when compiling.

Here's how Btst, Bset, and Bclr compare to similar statements using individual global variables, assuming your global variable is named gVar1 and you want to replace it with a flag defined as FLAG1:
Code: [Select]
(Btst FLAG1)
(== gVar1 TRUE)

(Bset FLAG1)
(= gVar1 TRUE)

(Bclr FLAG1)
(= gVar1 FALSE)

12
SCI Syntax Help / Re: Loading External Scripts on the Fly?
« on: June 10, 2019, 11:50:03 PM »
Two ways come to mind:
I simplified the Tavern example, for simplicity's sake.  The Look external script (again, script 339) is actually:
Code: [Select]
(public
SaidLookTavern 0
TavernLookAround 1
TavernLookAtStool 2
)

(procedure (SaidLookTavern)
(cond
((Said '[<at,around][/!*,room,building,tavern,establishment]')
(TavernLookAround FALSE FALSE)
)
;snip
)
(DisposeScript TAVERN_LOOK)
)

(procedure (TavernLookAround firstTime doDispose)
(HighPrint 339 22)
;The grimy window lets little light into this tavern.  It smells like stale ale and other more unpleasant things.
;The floor is covered with dirt, and the bar with sticky beer.
(HighPrint 339 23)
;Smoke appears to be rising from the center cask behind the bar.  To your right, two gamblers are playing cards.
(if firstTime
(HighPrint 339 24)
;The bartender glares at you as you enter, and so does the ugly goon on the left. You get the impression that you are not welcome.
)
(if doDispose
(DisposeScript TAVERN_LOOK)
)
)

Then in the main Tavern.sc (script 331), when you enter the tavern for the first time, it will call (TavernLookAround TRUE TRUE), which will add the extra bit about the bartender glaring at you, then will unload itself from memory.  So you might be able to rework your local variables enough that you can call global procedures passing those local variables as references. I don't honestly know the memory impact global procedures have vs global variables, but I would assume procedures is less.

The other thing that comes to mind is using Btst, Bset, Bclr global flags, instead of global variables. You may have some global variables that are only used for TRUE/FALSE values, which could be condensed into flags instead.  A flag only uses 1 bit of memory, whereas a global variables uses 16 bits.

13
SCI Syntax Help / Re: Loading External Scripts on the Fly?
« on: June 10, 2019, 11:35:28 AM »
QFG1EGA did this in a couple places. Here's a snippet from the tavern:

TownTavern.sc: (script 331) in the Room's handleEvent:
Code: [Select]
(method (handleEvent event)
(cond
((super handleEvent: event))
((!= (event type?) evSAID))
(Said 'look>')
(SaidLookTavern event)
)
;snip a bunch more cond's
)
)

Then in an external script file, which I named RM331_Look.sc (script 339)
Code: [Select]
(script# TAVERN_LOOK)
(public
SaidLookTavern 0
)

(procedure (SaidLookTavern)
(cond
((Said '[<at,around][/!*,room,building,tavern,establishment]')
(HighPrint 339 22)
)
((Said '/barrel,barrel')
(HighPrint 339 0)
)
((Said '/dirt')
(HighPrint 339 1)
)
;etc...
)
(DisposeScript TAVERN_LOOK)
)

14
SCI Development Tools / Re: Decompilation Archive
« on: May 22, 2019, 01:59:35 PM »
Made some more improvements:
  • fixed two incorrect decompilation lines in rm171 (arenaBearChange)
  • split game.sh into multiple headers
  • manually decompiled Main.sc::EgoDead asm into Sierra Script (script 0)
  • manually decompiled BoxSelector.sc::chAlloc::init asm into Sierra Script (script 203)
  • manually decompiled TargetRange.sc::rm73::init asm into Sierra Script (script 73)

edit: fixed a variable name I copy/pasted incorrectly in arenaBearChange.sc, and fixed a long-standing bug in RandomEncounter.sc, where escaping from a fight sets Ego to Walk instead of Run.

15
SCI Development Tools / Re: Decompilation Archive
« on: May 06, 2019, 01:17:49 PM »
I've done a bit of touch-up work on Eric's excellent QFG1EGA src (v3).  A lot of minor changes:
  • replaced all view reference numbers with defines
  • replaced all OnControl and IllegalBits with defines
  • replaced all EncRoom::entrances with defines
  • replaced some StudioScript constants with SSCI constante (evKEYBOARD->keyDown, evJOYSTICK->direction)
  • gave names to all default global variables
  • renamed gCast, gRegions, gSounds, etc to their original SSCI names
  • fixed the (= controls controls) bug I mentioned in another thread
  • converted FLAGS to enum instead of individual defines
  • converted all Btst, Bclr, Bset flags to use the enum constant instead of a number. If I didn't know what the flag did, i named it FLAG_#, to make it easier to search for and trace later
  • added comments describing how the TrySkill and SkillUsed functions work
  • added defines for certain hardcoded values, like Ogre, kobold, Brutus Max HP; and the skill level needed to solve certain puzzles
  • I think that's the gist of it, but there were many little touches here and there so I may have missed mentioning something

It compiles, and I've done a quick play-through of a couple rooms without noticing any problems, but I haven't done an extensive start-to-finish run yet.

Pages: [1] 2 3 4

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

Page created in 0.111 seconds with 22 queries.