Based on some help I got the other night, I came up with this (a dog is guarding a doorway, it has hit points, and it won’t let you go north until you kill it with one of the weapons available, which also have damage points assigned to them):
[code]Section 1 - Hit Points
A person has a number called maximum hit points. A person has a number called current hit points.
An animal has a number called maximum hit points. An animal has a number called current hit points.
The maximum hit points of the player is 35. The maximum hit points of the animal is 5.
When play begins:
repeat with victim running through people:
now the current hit points of the victim is the maximum hit points of the victim.
Definition: a person is dead if his current hit points are less than 0.
Section 1.1 - Diagnosis
Diagnosing is an action applying to one visible thing. Understand “diagnose [something]” as diagnosing.
Check diagnosing:
if the noun is not a person, say “Only people can have diagnoses.” instead.
Carry out diagnosing:
say “[if the noun is the player]You have[otherwise][The noun] has[end if] [current hit points of the noun] out of a possible [maximum hit points of the noun] hit points remaining.”
Section 1.2 - Weapons
A weapon is a kind of thing. A weapon has a number called the maximum damage. The maximum damage of a weapon is usually 4.
The player carries a weapon called a mace. The maximum damage of the mace is 3.
Understand the commands “attack” and “punch” and “destroy” and “kill” and “murder” and “hit” and “thump” and “break” and “smash” and “torture” and “wreck” as something new.
Attacking it with is an action applying to one visible thing and one carried thing. Understand “attack [someone] with [something preferably held]” as attacking it with.
Understand the commands “punch” and “destroy” and “kill” and “murder” and “hit” and “thump” and “break” and “smash” and “torture” and “wreck” as “attack”.
The attacking it with action has a number called the damage inflicted.
Setting action variables for attacking something with something:
let the maximum attack be the maximum damage of the second noun;
now the damage inflicted is a random number between 1 and the maximum attack.
Check an actor attacking something with something (this is the can’t attack with something that isn’t a weapon rule):
if the second noun is not a weapon:
if the actor is the player, say “[The second noun] does not qualify as a weapon.”;
stop the action.
Check an actor attacking something with something (this is the can’t attack a non-person rule):
if the noun is not a person:
if the actor is the player, say “[The noun] has no life to lose.”;
stop the action.
Carry out an actor attacking something with something (this is the standard attacking it with a weapon rule):
decrease the current hit points of the noun by the damage inflicted;
if the noun is dead, remove the noun from play.
Report attacking a dead person with something (this is the death-report priority rule):
say “You attack with [the second noun], killing [the noun]!” instead.
Report attacking someone with something (this is the normal attacking report rule):
say “You attack [the noun] with [the second noun], causing [damage inflicted] point[s] of damage!” instead.
Section 2 - Scene
The Courtyard is a room. The Palace is north of the Courtyard.
The guard dog is a male animal in the Courtyard. The description is “He looks mean and nasty.”
There is a club in the Courtyard. “There’s a gnarled old club here studded with thorns.” Understand “stick” as club. The club is a weapon.
Instead of going north in the Courtyard:
if the dog is in the Courtyard:
say “The dog snarls at you and won’t let you through the door!”;
otherwise:
continue the action.
[/code]
It works for me, and is one way of doing it…
Note: I should add that the dog doesn’t fight back, because I don’t need it to in the context I’m using this code for - but in the example I copied this code from, Lanista 2 from the Recipe Book Chapter 16.3, its designed to have the monster (or whatever) attack you back, using its own weapons. Its worth checking out and learning how to adapt it to your own needs.