Difference between revisions of "Jumping Bug"

From SCI Wiki
Jump to navigationJump to search
 
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
 
Replace the '''setTest''' method with this:
 
Replace the '''setTest''' method with this:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">    (method (setTest)
+
<syntaxhighlight lang="sci" class="cs">    (method (setTest)
 
         (if (> (send client:x) x)
 
         (if (> (send client:x) x)
 
             (= dx -1)
 
             (= dx -1)
Line 45: Line 45:
 
Old code:
 
Old code:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">(send client:
+
<syntaxhighlight lang="sci" class="cs">(send client:
 
     x(+ xLast xStep)
 
     x(+ xLast xStep)
 
     x(+ yLast yStep)
 
     x(+ yLast yStep)
Line 56: Line 56:
 
Fixed code:
 
Fixed code:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">(send client:
+
<syntaxhighlight lang="sci" class="cs">(send client:
 
     x(+ xLast xStep)
 
     x(+ xLast xStep)
 
       y(+ yLast yStep)
 
       y(+ yLast yStep)
Line 67: Line 67:
 
Fixed code:
 
Fixed code:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">(method (moveDone)
+
<syntaxhighlight lang="sci" class="cs">(method (moveDone)
 
     (send client:
 
     (send client:
 
         illegalBits(illegalBits)
 
         illegalBits(illegalBits)
Line 86: Line 86:
 
Example:
 
Example:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">// Make the ego jump to 100,100
+
<syntaxhighlight lang="sci" class="cs">// Make the ego jump to 100,100
 
(send gEgo:setMotion(JumpTo 100 100))</syntaxhighlight>
 
(send gEgo:setMotion(JumpTo 100 100))</syntaxhighlight>
  

Latest revision as of 16:03, 5 August 2013

Chapter 5 - Jumping

if you've ever tried using the JumpTo class, you may have found it doesn't work very well. This is because there are bugs in the template game that comes with SCI Studio. Using Brian's disassembler, I looked at the Space Quest 3 scripts to see what the code was really supposed to do. With these fixes, you can make the ego jump to a particular screen location.

Fixing Jump.sc

Open the Jump.sc script, and make the following changes.

Replace the setTest method with this:

Code:
    (method (setTest)
        (if (> (send client:x) x)
            (= dx -1)
        )(else
            (if (<> x (send client:x))
                (= dx 1)
            )(else
                (if (> xStep 0)
                    (= dx -1)
                )(else
                    (= dx 1)
                )
            )
        )
        (if (> (send client:y) y)
            (= dy -1)
        )(else
            (if (<> y (send client:y))
                (= dy 1)
            )(else
                (if (> yStep 0)
                    (= dy -1)
                )(else
                    (= dy 1)
                )
            )
        )
    )

Then go to the doit method. There is an 'x' where there should be a 'y'. Replace this code:

Old code:

Code:
(send client:
     x(+ xLast xStep)
     x(+ yLast yStep)
)

With this:

Fixed code:

Code:
(send client:
     x(+ xLast xStep)
      y(+ yLast yStep)
)

Finally, the moveDone method of the Jump class is missing a (self:motionCue()). It should look like this:

Fixed code:

Code:
(method (moveDone)
    (send client:
        illegalBits(illegalBits)
        signal(signal)
    )
    = completed TRUE
    (if(caller)
        = gCastMotionCue TRUE
    )(else
        (self:motionCue())
    )
)

With these changes, jumping should work properly. Just add (use 'Jump')to the top of your script, and then use the JumpTo class:

Example:

Code:
// Make the ego jump to 100,100
(send gEgo:setMotion(JumpTo 100 100))

 

< Previous: Chapter 4 - Loopers Next: Chapter 6 - The z-coordinate >