Letting actor drown in the ocean. - TADS3

I have included some code that, among other things, should let my actor drown and die if he goes ‘ne’,'nw, or ‘w’ of if he tries to swim in the ocean. I just can’t get this to work if I try the ‘swim’ verb. Would appreciate any help on this.

My player is on a beach near the ocean. I want him to drown if he goes
north, northeast, or northwest or ‘swims’, The code I’ve included does
not not recognize the command swim. Need some help with this. Here’s
the code:

/* (Room001) The player begins the game at this location/room.
****************/

startroom : OutdoorRoom ‘On the Beach’ ‘The Beach’
roomFirstDesc()
{
"The rocky beach continues north and south. Toward the westward
directions, is
the vast, blue ocean which stretches as far as the eye can see. The
many-sized
rocks, jutting out of the beach and the ocean, look quite dangerous
to
explore. A wide, inviting path heads east into the dense
forest. ";
beachAchievement.awardPointsOnce();
}
shortDesc = "You are at the rocky beach. "

north : FakeConnector {
“As much as you would want to explore the beach, you can’t. For one
thing, the
forest seems to tug at you relentlessly. Besides, you are a
professional
explorer and are being paid to get this stuff done. The sooner, the
better.”
}
south : FakeConnector {
“I know that you would like to roam up and down the beach. You will
be
disappointed. There’s nothing to be found but sand, rock, the ocean
and the
barrier of the dense forest. You should stick to your task. "
}
northwest : FakeConnector {
" << me.swim >>”
}
west : FakeConnector {
" << me.swim >>"
}
southwest : FakeConnector {
" << me.swim >>"
}
swim asExit (west);

east : DynamicTravelMessage
{
->path
"You head into the path and are shocked to see that it seems more worn
than you
could have imagined; as if someone has been through here recently.
This isn’t a
fact that your new employers chose to reveal. "
“You enter the eastern path.”
}
beachAchievement : Achievement { +5 "reaching the beach " }
;

/* Define the sound of the beach
**********************************************/

  • SimpleNoise ‘ocean/wave/waves’ ‘waves’
    "You hear the slapping of the water against unyielding rocks. "
    ;

  • SimpleOdor ‘salty’ ‘salty’
    "You smell the salty odor of the ocean. "
    ;

/* Define Player Character
****************************************************/

+me: BagOfHolding, Actor
vocabWords = ‘tom thomas tom/thomas/leavens’
desc
{
“You are Thomas Leavens; also known as Doctor Tom to all your
friends
and by all of your enemies. Your ex-wife calls you names that
could
never be repeated. You graduated from college with a Doctorate
in
biology and a minor in world history. Shortly after, as part of
your
first job, you became involved in exploring cave systems
(spelunking).
This quickly evolved into self-employment in all types of world-
wide
exploration. Your intelligence and expertise in many fields
makes you a
greatly sought after scientist and explorer.”;

 /* Show my Posture. */
  "<.p>";
  postureDesc;
  "<.p>";

 /* Show my Inventory. */
  holdingDesc;
}

bulk = 10
goingToOcean = 1
swim
{
switch (me.goingToOcean)
{
case 1:
“As much as you would want to take a much needed break and go for a
swim, the
water seems dangerous.”;
me.goingToOcean++;
break;
case 2:
“You step to the edge of the shore and consider jumping into the
ocean. However,
the strength, speed and size of the waves make you step back, shaking
your
head.”;
me.goingToOcean++;
break;
case 3:
“Delaying your quest,for the moment, you remove everything and throw
it onto the
sand. Having done that, you jump into the water and immediately are
buffeted
against the hard rocks by wave after wave. You begin to struggle and
scream in
your last moments, but it is too late.”;
finishGameMsg(ftDeath, [finishOptionUndo, finishOptionFullScore]);
}
}
;

My T3 is real rusty, but I can see a couple of problems here. First, I don’t think it will work to define:

swim asExit(west)

on the room, because swim isn’t a direction property that the library will ever use. Thus, the asExit macro won’t do anything. In addition, I don’t think you want a semicolon after that line, because the semicolon will terminate the room definition.

Second, I don’t think “<<me.swim>>” will do what you want, because the me object doesn’t have a swim property. All that will do is call the swim property on the me object – it won’t generate a new action. I’ve been poking through “Learning T3” to try to find the syntax for triggering a new action, and I can’t find it, but I don’t think that’s it.

In any case, the library doesn’t define a SwimAction. (Nor does it define a SwimInAction, which you’re also going to want.) You’ll need to define that and then do some other stuff, which I’ll work out later if nobody else has replied.

–JA

Okay, here’s an example that I think does basically what you’re thinking of. It should be pretty easy to adapt to your game.

[code]DefineIAction(Swim)
execAction() { "There is no large body of water nearby. ";
}
;
VerbRule(Swim)
‘swim’
: SwimAction
verbPhrase = ‘swim/swimming’
;
DefineTAction(SwimIn);
VerbRule(SwimIn)
‘swim’ ‘in’ singleDobj
: SwimInAction
verbPhrase = ‘swim/swimming in (what)’
;
modify Thing
dobjFor(SwimIn) {
verify() {
illogical (’{You/he} can’t swim in {that dobj/him}. ');
}
}
;

beach: Room ‘Beach’
"You’re at the beach. There’s some ocean here. "
east = forest
roomBeforeAction() {
if (gActionIn(North, South, West, Swim, SwimIn)) {
drown;
exit;
}
}
drown { “Glub, glub, glub…”; }
;

  • me: Actor
    ;

  • ocean: Fixture ‘ocean’ ‘ocean’
    dobjFor(SwimIn) {
    verify() {
    logical;
    }
    }
    ;[/code]
    Just put whatever code you want in the drown routine, including killing the player, and you should be good to go.

Thanks for your thoughts. Looks like the answer is there. Will give it all a try as soon as I’m able.

Ron