So I’ve been working on some combat in a game I’m making. Here is the source in question:
A person has a number called maximum hit points. A person has a number called current hit points. A person has a number called max damage.
The maximum hit points of the player is 45. The maximum hit points of the Boy is 25.
The current hit points of the player is 35. The current hit points of the Boy is 25.
The max damage of the player is 10. The max damage of the Boy is 8.
Instead of attacking someone:
let the damage be a random number between 2 and the max damage of the player;
say "You attack [the noun], causing [damage] points of damage!";
decrease the current hit points of the noun by the damage;
if the current hit points of the noun is less than 0:
say "[line break][The noun] dies, and falls to the ground!";
remove the noun from play;
stop the action;
So, for that chunk of code that should be like the new default for attacking someone. If I add a new person, I can choose their max damage, maximum hit points, and current hit points. So If I were to compile this (Of course, with more code) and I were to attack someone they just get attacked and don’t back. And it works, so that’s good. But, there is more. The person “the boy” is a person who fights back. So here’s the code for him:
The Bedroom Two is north of the Upstairs Hallway. "This is a bedroom. The exit is to the south. The room smells terrible, and I would recommend leaving immediately." The Boy is a man in Bedroom Two. "A tall scary looking boy looks down on you."
Every turn:
if the location of the boy is the location of the player:
After attacking someone:
let the enemy damage be a random number between 2 and the max damage of the noun;
say "[line break]The boy attacks you, causing [enemy damage] points of damage!";
decrease the current hit points of the player by the enemy damage;
if the current hit points of the player is less than 0:
say "Their final blow knocks you back and you fall to the ground.";
end the game in death.
And adding this (Of course, with many other rooms and stuff.) creates this problem:
Problem. The phrase or rule definition ‘Instead of attacking someone’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘let the damage be a random number between 2 and the max damage of the player’ , in case that helps.
This sometimes happens even when the code looks about right, to the eye, if rows of spaces have been used to indent phrases instead of tabs.
Can somebody try to tell me what I’m doing wrong?
I am using inform 7.