Timing change for death handler script (Dying.sc)

From SCI Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Originally posted on the SCI Programming Forums by Gumby.


I just utilized the dying.sc script for the first time and I immediately noticed that there is a significant delay between calling the the script and the death 'screen' popping up.

This is by design, but I didn't like the fact that the delay length was hard-coded into script. Making a few modifications, I exposed the delay property for the script:

Code:
(instance public DyingScript of Script
	(properties
	    seconds 3	     //  Exposed this property (just by adding it here), 
        )                    //  which is inherited from the Script class & set the default to 3
	
	(method (changeState newState)
		(var mbResult, message)
		= state newState
		(if(== state 0)
			ProgramControl()
			(send gTheMusic:fade())
			(send gRoom:setScript(0))
			Load(rsSOUND 2)
			//= seconds 3     // Commented out this line, which set the delay to 3 seconds
		)(else
  			(if(== state 1)
                ...

 

So now, when I call the dying script, I can specify seconds like so:


Code:
  (send dyingScript:
       caller(802)
       seconds(1)   //  You can set this to however long you wish, based on your animation length
       register("You are dead.")
   )

  If you need more granularity than seconds, it would be simple to expose the 'cycles' property instead of the 'seconds' property in the Script class, then change the dying script to use cycles instead of seconds.