EDIT 2:
I have fixed the issue in a way I thought I already had but clearly I hadn’t tried the correct combination.
Every turn:
if the the current hit points of the player > the maximum hit points of the player:
say “you’re now at full health”;
now the current hit points of the player are the maximum hit points of the player.
This works perfectly and makes me think that the after rule is not designed for what I was trying to achieve.
Continuing on from the battle system I’ve been working on I’ve hit another small snag thats bothering me immensley. My main goal is to have basic working versions of all the features I wish to include before redrafting the entire code from scratch. I have successfully got a working health potion model that I need tweaked so that it cannot increase the health of the player above their maximum hit points.
I was hoping ideally to set a limit to hit points so that the maximum hit points could simply never be exceeded but the only thing that would be affected by that rule would be health potions so I have decided to tackle this issue there instead (I may want a buff potion to increase beyond max health anyway). In a nutshell I simply want any HP added over 100/Maximum hit points to be overridden and simply make the player’s current hit points 100 or equal to their maximum hit points.
I’ve tried many, many variations but I have included what I think is the most straight forward version in bold. This is compiling with no errors but simply doesn’t do anything. Perhaps its an issues with some of the definitions I’ve included. I have tried to write a few definitions as to make writing rules a bit simplier but the defintion ‘overhealed’ may be redundant. Perhaps the definitions of current and maximum hit points need work instead? (I have based these initial basic mechanics from the lanista 2 example for reference).
CODE:
Section 1 - Hit Points
A person has a number called maximum hit points.
A person has a number called current hit points.
The maximum hit points of the player is 100.
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.
Definition: a person is alive if they are not dead.
Definition: a person is injured if his current hit points are less than his maximum hit points.
Definition: a person is uninjured if his current hit points are his maximum hit points.
Definition: a person is overhealed if his current hit points are at least his maximum hit points.
Section 4 - Health Potions
A potion is a kind of thing.
A Health Potion is a kind of potion.
Instead of drinking a Health Potion:
increase the current hit points of the player by 10;
Let RHP be a random Health Potion carried by the player;
Remove RHP from play;
say “You drink the potion increasing your health by 10!” instead.
Before drinking a Health Potion:
if the player is not injured:
say “you’re already at full health”;
stop the action.
After drinking a Health Potion:
if the player is not injured:
say “you’re now at full health”;
now the current hit points of the player are 100.
END CODE.
Again, any help is much appreciated and while this is a simple issue, it’s bothering me a lot as it seems like it should be very straightforward to solve.
Cheers!
EDIT:
I should note I also have tried:
After drinking a Health Potion:
if the player is overhealed:
say “you’re now at full health”;
now the current hit points of the player are 100.
Which also compiles but does nothing.
The majority of variations I tried simply didnt compile so I haven’t included them as examples but I tried countless versions of what I could imagine the above code to be in different words.
and lastly the most recent bit of code I wrote which compiled fine and is probably the most flexible within the gameworld:
After drinking a Health Potion:
if the the current hit points of the player > the maximum hit points of the player:
say “you’re now at full health”;
now the current hit points of the player are the maximum hit points of the player.
This also had no effect.
Perhaps I’m interpreting the after rule incorrectly but when reading the example 7.5 “If an action has survived all the rules in its way, and has actually succeeded, then we need to give the player a response which acknowledges this.”
My interpretation is that the action has survived the rule therefore the after rule can be used and should simply transform the hit points to that instructed.