Author Topic: Using the avoid script  (Read 26037 times)

0 Members and 1 Guest are viewing this topic.

Offline lskovlun

Re: Using the avoid script
« Reply #30 on: May 11, 2015, 04:10:29 PM »
Ok, but I really don't know what it is that this tells me... I assume that it has something to do with avoid being a class of the obj... but yeah
Code: [Select]
Not an object: $e226

Avoid
mul
acc:e226    sp:1868    pp:1860
You left out the send stack :) but I've just had a look at the earlier posts here. So you are using this in conjunction with a region, and setting offScreenOK...
that might indicate that either the region, the avoider itself or an actor is being disposed ahead of time. You should be able to inspect the object at $e226 while still in the room and see what it is.

Offline troflip

Re: Using the avoid script
« Reply #31 on: May 11, 2015, 04:11:26 PM »
Cool, thanks for the dosbox tip, that works.

I can repro this even with the template game Avoider script. It's crashing because the object it's trying to send to has been disposed. To me, the code in Act::setAvoider looks wrong in the template game. I think it should set avoider to NULL after disposing it.

The send stack is:
Code: [Select]
(aThing setAvoider:)
(aThing delete:)
(cast eachElementDo:)
(Game newRoom:)
etc....
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline troflip

Re: Using the avoid script
« Reply #32 on: May 11, 2015, 04:16:10 PM »
In Cascade Quest, an old game I was working on that used avoiders, setAvoider looks like this:

Code: [Select]
(method (setAvoider theAvoider sendParams)
(if(avoider)
(send avoider:dispose())
)
(if(IsObject(theAvoider))
(if(& (send theAvoider:{-info-}) $8000)
= avoider (send theAvoider:new())
)(else
= avoider theAvoider
)
)(else
            (= avoider NULL)
        )

(if(avoider)
(send avoider:
init(self)
rest sendParams
)
)
)

Note the assignment to NULL if theAvoider is not an object.
(Note: the decompiled version of setAvoider looks correct too)
« Last Edit: May 11, 2015, 04:18:40 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: Using the avoid script
« Reply #33 on: May 11, 2015, 04:27:29 PM »
 ;)

I didn't set mine to NULL, but I did manage to make it out of the room again by adding in an else statement in the same area you did.

Looking at sq4 picview script, I noticed that there was an and thrown in there and the two lines appeared as one. Where as in the template, the same line was broken up with two if statements. But only the second one had an else following... which meant that if it passed the first if and failed the second then something was falling through...

I stuck in the original response as demonstrated by the decompile

Code: [Select]
    (method (setAvoider theAvoider sendParams)
        (if (avoider)
            (send avoider:dispose())
        )
 
            (if (IsObject(theAvoider))
            (if(& (send theAvoider:{-info-}) $8000)
                = avoider (send theAvoider:new())
    )
    (else
    = avoider theAvoider
)
            )
            (else
                = avoider theAvoider
            )
        (if (avoider)
            (send avoider:init(self rest sendParams))
        )
)
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: Using the avoid script
« Reply #34 on: May 11, 2015, 04:35:08 PM »
Looking at sq4 picview script, I noticed that there was an and thrown in there and the two lines appeared as one. Where as in the template, the same line was broken up with two if statements. But only the second one had an else following... which meant that if it passed the first if and failed the second then something was falling through...

Yeah, looks like Brian "manually decompiled" it incorrectly. Not surprising, it's very tedious and error-prone for a human to do, and that bit of code was never tested since the Avoider script wasn't part of the original template game.

So, are things working better now with the template game fix, and the decompiled Avoider script?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: Using the avoid script
« Reply #35 on: May 11, 2015, 04:42:33 PM »
Holy crap... Looking at the first post in this thread, it started 5 years ago yesterday.

The good news is, today the problem is solved. Now it's time to go back and retrofit some code.

I had faked my own cheap avoider by outlining the white control lines with some navy ones and then checking for & onControl navy. If true it would switch the motion to wander for a few cycles, and then switch back to follow. It definitely wasn't pretty... and now I can get rid of it.  8)

I'll have to get back to you on how well everything works, it looks like in your original avoider script you provided, there is the offscreen procedure that got added in from somewhere as it isn't in the sq3 avoid script. I haven't found it yet in the other decompiles you have provided but I will be looking for it... especially since I am sending true for ok to be off screen.

I am trying to get as much functionality as possible in the current templates so that I can stick up a new version of each. The goal is to get them as close to sci1.1 as possible so that a lot of the same code can be used in almost any version.

Unfortunately I am really struggling to decipher the iconBar but anyway, I am so glad this avoid business is back on track.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: Using the avoid script
« Reply #36 on: May 11, 2015, 06:29:27 PM »
So much progress and activity lately. :) So nice to see.
« Last Edit: May 11, 2015, 06:34:26 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline Cloudee1

Re: Using the avoid script
« Reply #37 on: May 11, 2015, 07:14:51 PM »
Apparently Phil knows how to stir things up a bit

You know something is going on when Lars comes out of lurker mode and starts getting his hands dirty
« Last Edit: May 11, 2015, 07:16:31 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Cloudee1

Re: Using the avoid script
« Reply #38 on: May 21, 2015, 12:11:07 AM »
So I just got to thinking and I thinks this would work.

Let's say I have a little invisible actor. Whenever I click to send the ego walking... instead I position my little invisible actor wherever it is that I clicked.

Now when my room was inited let's say I told my ego to follow that little invisible actor and of course set the avoider.

Theoretically don't I now have an ego with some path finding abilities... even if he is a tad soft in the head.

As long as I white out everywhere an actor can't be anyone see any reason why this wouldn't work?
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: Using the avoid script
« Reply #39 on: May 21, 2015, 01:09:31 AM »
Ahhh.....I remember trying to use Avoid in the past to implement pathfinding but was unsuccessful. Never thought of this method, though.
Brass Lantern Prop Competition

Offline troflip

Re: Using the avoid script
« Reply #40 on: May 21, 2015, 01:27:33 AM »
So I just got to thinking and I thinks this would work.

Let's say I have a little invisible actor. Whenever I click to send the ego walking... instead I position my little invisible actor wherever it is that I clicked.

Now when my room was inited let's say I told my ego to follow that little invisible actor and of course set the avoider.

Theoretically don't I now have an ego with some path finding abilities... even if he is a tad soft in the head.

As long as I white out everywhere an actor can't be anyone see any reason why this wouldn't work?

I'm not sure what you're getting at... wouldn't the ego just walk toward the invisible actor? How is that any different than just telling the ego to MoveTo the position you clicked?

I think the bumping around that the Avoider does when it runs into obstacles might become distracting... like you don't have control over your character.

I'm not yet sure how the SCI1.1 stuff works... I imagine they send the actors along fixed prescribed paths?

You could implement an A* pathfinding algorithm if you divided the walkable area into cells, but I think that would be a lot of work.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: Using the avoid script
« Reply #41 on: May 21, 2015, 01:50:27 AM »
I'm not yet sure how the SCI1.1 stuff works... I imagine they send the actors along fixed prescribed paths?
Polygons and AvoidPath (ok, it's wrapped in classes so you can just (foo setMotion: PolyPath), but still)?

Offline gumby

Re: Using the avoid script
« Reply #42 on: January 30, 2016, 07:12:01 PM »
You could implement an A* pathfinding algorithm if you divided the walkable area into cells, but I think that would be a lot of work.

Working on this now.  I'm taking an approach similar to sciAudio, where the processing is external to the SCI engine.  Pass in the current coordinates of the actor, the X/Y coordinate of the destination, which control colors to observe and an array of coordinates are returned which can be fed into DPath.  It'll have to evaluate the room pic and find the corresponding control lines (just lines at this point).

Already have the pathfinding part complete, I grabbed an implementation from CodeProject (http://www.codeproject.com/Articles/118015/Fast-A-Star-D-Implementation-for-C).  All that remains is to trudge through the pic resource identifying all the control lines (just lines at this point) and create a bitmap which is used as input for the pathfinding.  Then just connect it up to the SCI engine utilizing file reads/writes.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Kawa

Re: Using the avoid script
« Reply #43 on: January 30, 2016, 07:41:05 PM »
Dear lord that's horrifying :D

Offline gumby

Re: Using the avoid script
« Reply #44 on: February 02, 2016, 07:08:27 AM »
Making progress on this.  Building a list of control lines from a room pic is done.  Doesn't make a difference if it's in a resource archive or 'patch' file.

EDIT:  Pathfinding is wired in, tested and working.  Wicked fast.  Now all that is left is to hook it into SCI.
« Last Edit: February 02, 2016, 08:40:24 AM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition


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

Page created in 0.053 seconds with 22 queries.