Axe Software Forums
  Quest Developer Forum
  Very long coded demo....


Author Topic:   Very long coded demo....
Computer Whizz posted 21-08-2001 20:36 GMT     
Here.
I've fooled about with it a bit and two things are obvious from the start:

1. The timer (for reasons unknown to me!) doesn't work. Maybe I have got something like #quest.thing# wrong!
2. The arm command doesn't run. WHY??? There isn't a function or anything else. It just won't set the variable!!! And it doesn't see the object! Might be the alias....

If anyone could help me out by pointing out some wrong code :

=========START CODE========

define game <Shooting Demonstration!>
asl-version <284>
start <room1>
command <shoot #monster#> do <shoot_proc>
game version <0.9.5>
' As soon as I have worked out the bugs, this will become 1.0.1!
game author <Computer Whizz>
game copyright <hehehe.... YEAH!!! good one!>

define variable <HP>
type numeric
value <20>
onchange {
if (%HP% > 20) then {
set <HP; 20>}
if (%HP% > 15 ) then set <HP_display; GREAT>
else {
if (%HP% > 10) then set <HP_display; OK>
else {
if (%HP% > 5) then set <HP_display; CAUTION!!>
else {
if (%HP% > 0) then set <HP_display; !!DANGER!!>
else {
if (%HP% <= 0) then do <dead_proc>}
}
}
}
}
diplay <>
end define

define variable <HP_display>
type string
value <GREAT>
display <>
end define

define variable <9mm>
type numeric
value <15>
display <9mm ---- !>
end define

define variable <armed>
type string
value <>
display <Armed = !>
end define

command <shoot #monster#> do <shoot_proc>
command <hit #monster#> do <hit_proc>
command <arm #weapon#> do <arm_proc>
end define
define synonyms
use Hand Gun on = shoot
end define

define room <room1>
alias <North Hallway>
description <This is the Northern end of a Hallway that (|bYES|xb, you guessed it) carries on to the south. __
The doorway behind you (which you entered through) has been barricaded off.... how you came to be here is anyone's __
guess! The top half of the walls are decorated in a dull yellow wallpaper, while the bottom half has wood instead! __
A light grey carpet on the floor has dark patches on it, as if coffee has been spilt several times, yet they seem __
to be slightly red in colour!>
look <As you look up you spot a dead body lying over on the left hand side, next to a bench. It get's up and __
starts to walk towards you!>

south <room2>

define object <handgun>
alias <Hand Gun>
look msg <It's a bog-standard, police issue, hand gun!>
take give <handgun>
properties <POW = 5; BULLETS=9mm>

end define

define object <monster1>
alias <zombie>
look msg <AAAHHHHHH!!!!! It's a zombie!!>
properties <HP=9; STR=6; DIST=10; SPD=2; MOVING>

end define

end define

define room <room2>
alias <North-South Hallway>
description <This is the middle part of this hallway. It continues to the South and North. The room itself has the __
same yellow wallpaper and wooden finish to the walls.>

north <room1>
south <room3>

define object <vase>
look msg <It's a weird looking vase.>
take msg <You can't pick it up.>
speak {
msg <You say "Hello." to the vase.|nJust as you think you can't get any lower you hear something:>
say <Hello..... You're the first person to say that to me!>
msg <You look at the vase in amazement..... until you realise that there is a person behind it! Before you __
could stop him, he runs South!>}

end define

end define

define room <room3>
alias <South Hallway>
description <This room has light pink wallpaper with floural motefes around the edges of a window. In here there __
two hunters and one zombie and they are all after the little boy who ran down here. He jups behind you for safety __
and give's you a green herb.>
script give <herb>

north <room2>

define object <Boy>
look msg <A little boy, around the age of 10. He is wearing a blue base-ball cap and a white, striped, t-shirt.>
speak msg <Help me. KILL THOSE MONSTERS>

end define

define object <monster2>
look msg <It's a Hunter from one of those "|crResident Evil|cb" games!>
speak msg <EEEEEEEKKKKK!!!!>
take msg <You want to go and take something like |bTHAT|xb??>
properties <HP=15; STR=10; DIST=13; SPD=4; MOVING>

end define

define object <monster3>
look msg <It's a Hunter from one of those "|crResident Evil|cb" games!>
speak msg <EEEEEEEKKKKK!!!!>
take msg <You want to go and take something like |bTHAT|xb??>
properties <HP=16; STR=9; DIST=20; SPD=4; MOVING>

end define

define object <monster2>
look msg <It's a zombie which is after the boy behind you.>
speak msg <UUUURRRRGGGGGHHHHH..... |i*SLOP*|xi ..... |i*SLOP*|xi .....>
take msg <You want to go and take something like |bTHAT|xb??>
properties <HP=8; STR=5; DIST=18; SPD=3; MOVING>

end define

define object <chair>
look msg <It's a wooden chair.>
action <use chair on #monster#> {
msg <You pick up the chair and hit it over the #monster#'s head!>
property <#monster#; HP=$objectproperty(#monster#; HP)$ - 11>
if ($objectproperty(#monster#; HP)$ <= 0) then hide <#monster#>
hide <chair>}

end define

end define

define procedure <shoot_proc>
if here (#monster#) then {
if not ($lengthof(#armed#)$ = 0) then {
if (%$objectproperty(#armed#;BULLETS)$% > 0) then {
set <damage; $rand(1;$objectproperty(#armed#;POW)$)$>
property <#monster#; HP=$objectproperty(#monster#; HP)$ - %damage%>
if ($objectproperty(#monster#; HP)$ <= 0) then {
hide <#monster#>
msg <You hit the #monster# and it falls to the ground. It has stopped moving so you take no __
notice of it any more!>}
else {
msg <You shoot the #monster#>}
}
else {
msg <"Click....Click" You have no bullets left in the gun!!>}
}
else {
msg <You have no weapon armed. Type "Hit *monster*" to use your fists..... Or arm a weapon!>}
}
else {
msg <The #monster# is not here!>}

end define

define procedure <hit_proc>
if here (#monster#) then {
set <damage; $rand(1; 4)$>
property <#monster#; HP=$objectproperty(#monster#; HP)$ - %damage%>
if ($objectproperty(#monster#; HP)$ <= 0) then {
hide <#monster#>
msg <With one final punch, your hand goes into the #monster#'s brain and you kill it!>}
' This could be replaced with "do action <#monster#; punch_kill>" or "msg __
' <$objectproperty(#monster#; punch_kill)$>" so if it were a demon, you could have it evaporate __
' but if it were a dog, it would lie down and melt away, ect...
else {
msg <You hit the #monster# with your fists.>}
}
else {
msg <The #monster# is not here!>}

end define

define procedure <arm_proc>
if got (#weapon#) then {
set <armed; #weapon#>}
else {
msg <You haven't got the weapon!>}

end define

define procedure <moving_mons_proc>
for each object in <quest.currentroom> {
if property <MOVING> then {
if ($objectproperty(#quest.thing#; DIST)$ > 0) then {
property <#quest.thing#; DIST=$objectproperty(#quest.thing#; DIST)$ - $objectproperty(quest.thing; SPD)$>
msg <The #quest.thing# gets closer!!!>}
else {
msg <The #quest.thing# attacks you!>
set <damage; $rand(1; $objectproperty(#quest.thing#; STR)$)$>
set <HP; %HP% - %damage%>
property <#quest.thing#; DIST=$rand(1;10)$>}
}
}

end define

define procedure <start_proc>
set numeric <damage; 0>

end define

define procedure <dead_proc>
move <undefined>
playerlose

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define

define timer <moving_monsters>
interval <10>
action do <moving_mons_proc>
enabled

end define

=======END GAME=======

Computer Whizz

Computer Whizz posted 21-08-2001 20:39 GMT          
Aye-aye!

Just saw something..... I've got two shoot commands..... that's a bit of a bummer!

.....CORRECTING.....
50%, 80%, 95%, 99.999%, Windows crash!!
FATAL ERROR!!!
:)
....DONE!!

Computer Whizz

Alex posted 21-08-2001 20:47 GMT          
I've not run your code in Quest due to laziness but here are some things I've noticed from the code:

Answer #1. You said:

for each object in <quest.currentroom>

Our survey said (insert loud grunting bleep):

for each object in <#quest.currentroom#>

Answer #2. Yes it's probably the alias. You'll need to get disambiguating what the player types - basically, convert the name the player types into Quest's name for the object. Always in your code you need to use the Quest object name - the alias is only used for player input. The magic words are "$getobjectname(...)$ function".


And what's this in your shoot_proc:

if (%$objectproperty(#armed#;BULLETS)$% > 0)

I don't know what those % signs are doing there but it looks nasty.

Computer Whizz posted 21-08-2001 20:59 GMT          
Alex:
If you look at the object "handgun" then you'll see the property BULLETS=9mm. Now up in the status variable's you have the variable 9mm. I wanted to give others the possibility of many different bullets/guns.

I *think* that the #quest.currentroom# thing went wrong inside quest, so I re-did it to quest.currentroom. I'll have another try but....

I'm going to moan now about the alias business..... AAAARRRRGGGGGHHHHHH!!!!

Now, I'm going off to do those!

Computer Whizz

MaDbRiT posted 22-08-2001 10:48 GMT          
ALEX!! A BUG???

Playing with C W's code I sort of have it working after a fashion with some tweaks here and there, but there are a couple of odd things I spotted that look suspiciously like BUGS!

Firstly, using %% in a display string for a status variable prints -32767 (i.e. generates a missing variable) rather than printing a % sign as per the manual.

Secondly, when CW's code tries to SET the HP status variable (numeric) like so :-

set <HP; %HP% - %damage%>

it crashes Quest completely. I can't see why it should do that, but comment out the set line and Quest runs - leave it in and it crashes... fairly conclusive that!

I can't replicate this in a simple test, so there's something well weird happening here!

Oh yes CW - the timer IS working as written, the routine it calls isn't ;-)

Al

Computer Whizz posted 22-08-2001 11:31 GMT          
MaDbRiT....
Yes. I altered this, changed that, and got to the stage you are now.
Where Quest crashes when trying to re-write the HP variable!

I just thought it was a crap piece of coding that I had done in either the "onchange" or in the procedure somewhere.
Have you tried taking out the onchange?

If this allows it to work, could you have a look for me?

Here I can only get 2.19 to work :(

Computer Whizz

Computer Whizz posted 22-08-2001 11:37 GMT          
One more thing:

I tried the "arm #weapon#" command. But it comes up with some weird stuff!! Like " 'intproc~192' not found!" and stuff like "object 'armed; #weapon' not found" and all this other stuff.
I can't see anything wrong in the procedure, or the command that links it to the procedure......

Computer Whizz

MaDbRiT posted 22-08-2001 12:21 GMT          
AHA!! I think I know what is happening!

By changing the HP_display status variable in the 'onchange' of the HP status variable, you force Quest to call the onchange routines again - which then call the onchange routines again which must then call the onchange routines again..........

BLEEHHHHHH... I may be wrong, but I smell an OOZULUM ( never ending loop of recursive code ) :-(

I've not had a chance to look at the ARM bit yet.... ;-)

Al

Computer Whizz posted 22-08-2001 12:39 GMT          
What about the "if (%HP% > 20)" bit?

If, for some reason, this goes arry, and set's it to 20, that would make it do the "onchange" bit again, which would set it again, which would do the onchange again, set, onchange, set, onchange, CRASH!!!!

I'm going to remove that part when I get home.....

Computer Whizz

MaDbRiT posted 22-08-2001 12:48 GMT          
CW - I have your 'arm' routine working now - it's just that you used the wrong sort of brackets here and there....

e.g.

if got (#weapon#) then {

MUST be coded as;

if got <#weapon#> then {

the same applies to 'if here', that needs <> and not () to work ;-)

Check through these and a lot of mysteriously non working code will be cured!

The "if (%HP% > 20)" to call the die routine is fine - I presume because it doesn't alter a status variable so the 'recursive' call to 'onchange' doesn't happen.

Al

Al

Computer Whizz posted 22-08-2001 13:01 GMT          
No. Al, you're looking at "if (%HP% < 20)" and not the "if (%HP% > 20)"
I'm talking about the first IF where it sets HP to 20 if the value is OVER 20 (in theory!) but that might be causing the problem :)

Thanx for the info on the <>'s instead of the ()'s. I'd have thought they'd have been fully converted for Quest 3.0, but I'll have a go!

Computer Whizz

Computer Whizz posted 22-08-2001 13:05 GMT          
:::NOTE TO SELF:::
remove exessive else's from the HP variable's onchange bit.
--CW--
MaDbRiT posted 22-08-2001 15:08 GMT          
Sorry - misread your question - yes resetting the HP variable inside it's 'onchange' will cause a problem for sure it seems :-(

On 'losing the elses' - how about

if (%HP%<=0) then do <dead_proc>
if (%HP%>0) then set <HP_display; DANGER>
if (%HP%>5) then set <HP_display; CAUTION>
if (%HP%>10) then set <HP_display; OK>
if (%HP%>15 ) then set <HP_display; GREAT>

That WOULD work - if it wasn't for the recursion problem of changing stuff in an onchange routine that is... LOL

Al

Computer Whizz posted 22-08-2001 19:00 GMT          
Well, actually I was planning on doing it the opposite way, but now I see what you are doing, I'm going to do it that way :)

I'm still thinking that the set <HP; 20> shouldn't effect it! Because it shouldn't be above 20!!
I'll alter it to if (%HP% >= 21) and see if that works.

Computer Whizz

MaDbRiT posted 22-08-2001 20:35 GMT          
Yo! C.W.

Rather than post a whole wodge of revised code here, I've e-mailed you my hacked about version of your code which is basically functional now.

Al

Computer Whizz posted 23-08-2001 01:30 GMT          
Yep. Have got MaDbRiT!
I'll be taking a look on Saturday.....
I'm busy until then!

Computer Whizz