Axe Software Forums
  Quest Developer Forum
  Animal Wonder Script


Author Topic:   Animal Wonder Script
Tanin posted 24-10-2002 23:10 GMT     
How could I set it up so an animal in my game wonders in random directions. Also how could I make it so that the animal doesn't wonder into say an ocean or a house.

Bare in mind Im not a coder, so spell it out for me.

Tanin posted 24-10-2002 23:14 GMT          
Also, just to see what you think of this idea, would it be possible to program this?

-A young deer wonders around, if comes across a nut it eats the nut, the nut then moves to that deers stomach(room).
-Nuts regrow after 10 minutes.
-Once deer has 10 nuts in it's stomach it grows to adult (old deer replaces young deer).
-Once it has 25 it grows into an old deer.
-Once it has 35 it dies, a new young deer is born-created.

MaDbRiT posted 25-10-2002 03:00 GMT          
Hi Tanin

It's very possible to do what you ask in Quest, In fact I wrote a demo featuring a wandering cat that the player had to feed as a 'how to do' demo for Quest 2.0 (and put it on my 'tricks and tips' website) ages ago. You require only a little bit of variation of that idea for your wandering deer.

However setting this up in QDK is going to be much trickier than writing the code by hand. I'd suggest you do this bit of your game at least with hand coding. My old "Cat" demo could serve as a guide to how to go about this.

Another option would be to make use of Quest's library function by having someone who is up to speed with Quest ASL code write you a 'deer' object that you can just add in from QDK, set a few parameters and use. I would offer to do it (it would not be hard to do) but I really don't have the time at present.

Al

Tanin posted 26-10-2002 02:55 GMT          
Thanks mad =)

Anyone who could help me with this, I'd greatly appreaciate it. Im just learning C so I basically know nothing concerning how to do this myself.

passerby posted 27-10-2002 10:09 GMT          
Tanin,

do you want the deer to do things when the player can't see it? if not, there is an easier way than using those libraries.

Simply use a function that randomly adds the deer to the room the player is in. Then call this function every time the player enters a room where the deer might possibly be.

The only problem with this idea is that the deer can't do anything when the player is not looking at it, so you can't say, have it leave deer tracks to show where it's just been.

Tanin posted 28-10-2002 03:53 GMT          
I'll take either one, so long as someone can walk me through it.

I'd like the second on the best though, but of course I'll take what I can get.

passerby posted 30-10-2002 13:32 GMT          
Well, just specify everything you want to do, make a list, and post it here, and i'll help in any way i can.

It can't give great amounts of time, though, exams are coming up.

Tanin posted 31-10-2002 08:13 GMT          
Thanks passerby

Basically all I need is a deer object that wonders around a set of pre-defined rooms.

Nothing fancy, seeing as you are busy and all.

The player needs to be able to look and examine this deer object.

Thanks.

Computer Whizz posted 01-11-2002 01:36 GMT          
We have beifly covered this before, so here goes;

The "path" the deer will take can be listed as an array (ie "deer path[0]" to "deer path[20]").

There are three ways of dealing with this issue - you can have it so the deer goes in that strict order (0 -> 20) and then re-start at 20 again (like it jumped over a gorge or something...) in a circular path...

You can have the deer wander from 0 -> 20, and then back to 0 again (0 -> 20 -> 0).

Or you can have the deer jump between the various rooms (0 -> 5 -> 2 -> 7 -> 19 -> 20 -> 3 -> ...).

Now this can be done two different ways;
When the player moves around or inputs a command, the script to move the deer can be executed.

Every 10 seconds or so the deer can be moved along or "around" the "path".

If you give me which things you would like to happen I will gladly give you "psedo"-code (spelling?) and then you can just look up the proper ASL code...

Computer Whizz

Tanin posted 03-11-2002 09:01 GMT          
I like the following choice best..

A-[You can have the deer wander from 0 -> 20, and then back to 0 again (0 -> 20 -> 0).]

and..

B-[Every 10 seconds or so the deer can be moved along or "around" the "path".]

["psedo"-code (spelling?)] ..I think it's "pseudo", not to sure though.

Thanks =)

carlii posted 03-11-2002 21:27 GMT          
I find things like these are easy to do in Quest at least. :)
passerby posted 04-11-2002 08:29 GMT          
Sorry, Tanin, i stopped posting because an assignment had be finished. But i'm (slightly more) free now, so i'll start being useful.

My original idea was not to have the deer actually moving around at all, but to make it look like it was by bringing it up randomly just after the player enters a room.

like in the 'player enters room' part, put a function (this is pseudocode):

if $rand$(1;5)=3 then
-->Add deer to room
-->print message, 'deer is here'

the random number generator here is set to give a 1 in 5 chance of the deer being in any room.

Adding the rest of it where the deer can eat nuts and get older, that's a bit harder, but i'll try to think of something else for it.

Computer Whizz posted 04-11-2002 14:30 GMT          
Yeah, assignments are annoying...
Just about to start one next week, Physics (yeeesh) but I hope to have some time before then...

Computer Whizz

Computer Whizz posted 04-11-2002 20:29 GMT          
Firstly we shall need an array, you can have it any length you want, having all the rooms you want the deer to go around...
This will be put in the startscript;

string <deer1[0]; Yard>
string <deer1[1]; Street>
string <deer1[2]; Main Road>
string <deer1[3]; Round About>
string <deer1[4]; Secret Tunnel>
string <deer1[5]; Secret Nut Store>

Any other variables we may need;
numeric <deer1Alternate; 0>
numeric <deer1Position; 0>

Then a sub routene - where we move the deer around...

I don't know if there are Ubounds or Lbounds in Quest. If there are then you may be able to use one function for ALL your moving animals - but for now we'll just use one sub for one animal.
I'm calling mine "deer1Wander_Sub" (you'll see why later).

if (%deer1Position% = 0) or (%deer1Position% = 5) then <deer1Alternate; 1 - %deer1Alternate%>
^ This line tells us if the deer has reached the limits of the array, if we didn't do this the subroutene would produce an error when it went outside our array - plus it wouldn't go back down the array...

if (%deer1Alternate% = 1) then
<deer1Position; %deer1Position% + 1>
else
<deer1Position; %deer1Position% - 1>

move deer1 to room <#deer1[deer1Position]#>
^ Do you know when you type things too many times it look wrong? Deer looks wrong to me!

Now we add a timer....
Activate it as often as you want.

do <deer1Wander_Sub>

And that's the timer.

Start the deer off in room number 0 and wait for the timer to kick in...

Oh, and if Quest doesn't announce the arrival of the animal (I might be getting confused with QuestNet) then just put the code in in the Subroutine.

Also, if you want it to eat nuts, then you have to check the room that the deer is in, I think you can have Quest do a; for every object in #deer1[deer1Position]# then check for an alias of Nut.

I hope this helps...

If you want a demo (and trust me, my demo's aren't to be trusted : ) ) then I'll have to botch one together tomorrow (If I can). Tonight I have to do some Maths stuff : ( .

Computer Whizz

Alex posted 04-11-2002 22:52 GMT          
CW said: I don't know if there are Ubounds or Lbounds in Quest

There's no lbound function as the lowest element of an array is always 0.

You can use the $ubound(array name)$ function to get the highest-numbered element in an array.

Tanin posted 06-11-2002 06:41 GMT          
Thanks computer whizz, I'll let you know if I can get it to work.