Author Topic: Understanding later SCI code... SQ4  (Read 33811 times)

0 Members and 1 Guest are viewing this topic.

Offline troflip

Re: Understanding later SCI code... SQ4
« Reply #30 on: May 10, 2015, 11:33:18 PM »
I don't follow this step:

param1 = 7- (3(7/3))
param1 = 7 - 7

The parentheses define the order of operations. It goes like this:

param1 = 7 - 3 (7 / 3)
param1 = 7 - 3 (2)
param1 = 7 - 6
param1 = 1


This is pretty easy to verify for yourself. Stick this in a script:

Code: [Select]
(procedure public (proc999_1 param1 param2)
    return (- param1 (* param2 (/ param1 param2)))
)

And then call

Code: [Select]
FormatPrint("Result is %d" proc999_1(7 3))
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: Understanding later SCI code... SQ4
« Reply #31 on: May 10, 2015, 11:38:58 PM »
I guess I was thinking that the remainder would come out of 7/3 too. So then multiplying that result by 3 would negate the whole point of the division.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: Understanding later SCI code... SQ4
« Reply #32 on: May 10, 2015, 11:42:30 PM »
I guess I was thinking that the remainder would come out of 7/3 too. So then multiplying that result by 3 would negate the whole point of the division.

The result can only have one value, so how would the remainder and quotient both be produced? SCI has no floating point operations, just integer operations.


http://en.wikipedia.org/wiki/Modulo_operation#Modulo_operation_expression

Quote
for environments lacking a mod() function (note that 'int' inherently produces the floor value of a/n)

a - (n * int(a/n)).
« Last Edit: May 10, 2015, 11:44:38 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: Understanding later SCI code... SQ4
« Reply #33 on: May 10, 2015, 11:47:39 PM »
In case anyone is wondering, this procedure is coming out of the sq4 obj script.

And I digress, the resulting print statement was in fact, 1
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: Understanding later SCI code... SQ4
« Reply #34 on: May 11, 2015, 12:35:39 AM »
Ahhh yes. Floating point. Right.
Brass Lantern Prop Competition

Offline Cloudee1

Re: Understanding later SCI code... SQ4
« Reply #35 on: May 11, 2015, 05:57:55 PM »
Ok, I am staring at two different Motion classes... Approach and Chase. They are virtually identical. The only difference is in the doit method.

One of them includes this and the other one does not.
Code: [Select]
(if (== {b-moveCnt} 0)
     (super:init(client (send who:x) (send who:y) caller))
)

Here is the whole doit method just for further reference
Code: [Select]
    (method (doit)
        (if ((self:onTarget()))
            (self:moveDone())
        )(else
            (super:doit())
            (if (== {b-moveCnt} 0)
                (super:init(client (send who:x) (send who:y) caller))
            )
        )
    )

What does that actually do. Reset the chaser's x and y to it's current position and trigger an instance presumably with the caller, if it isn't moving?

It looks like who is the chased and if I understand correctly, the client would be the chasing actor.

Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: Understanding later SCI code... SQ4
« Reply #36 on: May 11, 2015, 06:13:52 PM »
Well just from the names, I would assume Chase keeps going after the who. So once it gets to where they were, it reinitializes itself maybe?

Whereas Approach would go to the who and stop, and be done.

I forget what b-moveCnt is again, but it's something to do with the bresenham line algorithm that moves actors along paths.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: Understanding later SCI code... SQ4
« Reply #37 on: May 11, 2015, 06:21:31 PM »
Yeah, they both get to the target (within a defined distance) and stop. Literally the only difference is that b-count statement.

So I am just assuming that they changed the name of the script from one game to another. I think I prefer chase personally so that is probably what I am going to go with and ditch the other version. I just wasn't sure what that was actually doing
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: Understanding later SCI code... SQ4
« Reply #38 on: May 11, 2015, 07:44:52 PM »
Which game are you looking at now? I don't see either of those classes in SQ4. In SQ5, they both exist. I'm pretty sure they are supposed to have different behavior, so I would hesitate before considering them "the same".

It's possible they behave the same in SCI0, but differently in SCI 1.1. According to the ScummVM code, the DoBresen kernel function updates {b-moveCnt} in SCI0 and SCI01, but not in SCI1.1 (presumably leaving it up to the scripts to update?). So the same code might have different functionality in different SCI versions.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: Understanding later SCI code... SQ4
« Reply #39 on: May 11, 2015, 09:36:18 PM »
Actually it looks like I am looking at approach and chase both from sq5. That is where the b-count difference is.

There is also an approach in the kq4 cycle script. I had thought that was where one of them had come from.

* Oh yeah, there was one other difference. But it is so pointless I didn't think it was worth mentioning. The default distances for approach was set to 20 and chase 0. But as that is one of the passable parameters, it's a worthless difference.
« Last Edit: May 11, 2015, 11:56:54 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: Understanding later SCI code... SQ4
« Reply #40 on: May 12, 2015, 02:08:48 AM »
Ok, so it looks like b-moveCnt just counts down from the moveSpeed number of the client to zero (or vice verse, doesn't matter). At any rate, it should be 0 every time the client moves.

Therefore Chase is constantly re-initializing itself every step the client takes.

So that suggests that the difference between Chase and Approach is that Chase adjusts for the who moving around, while approach just "captures" the who's initial position when you set the Approach motion. Is that what you observe?
Check out my website: http://icefallgames.com
Groundhog Day Competition


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

Page created in 0.029 seconds with 17 queries.