Adding health/hunger/thirst etc.?

LeDirt
Is there a possibility to add stats to "player", like hunger, health or thirst, which would be displayed to the player?
Which decrease by 1 in each turn?
Which could be increased if you for example "use medkit" or "eat meat".

And once you reach zero in one of them, its game over?

adammadam
yes you click on the player object on the lefthand side, then click on the attributes tab across the top, then you have an option to add attribute, you can name them hunger, health, thirst etc. Set them to integer and give them the value you want.

To make them reach zero you need a command like in this question viewtopic.php?f=10&t=5290

And for a turn counter you can see this part of the tutorial http://docs.textadventures.co.uk/quest/ ... ripts.html

I guess what you have to do is type into that instead of player.turns = player.turns + 1, player.health = player.health-1 and that might reduce it each turn.

adammadam
oh and then an object like eating some meat, you'd have a script on the meat which is "set variable or attribute" (this is one of the many options which pop up when you click on add script), and you'd put in
player.health = expression player.health + 30
or whatever number you want it to increase by

adammadam
here is adding attributes to the player
quest - adding attributes 2.png
quest - adding player attributes.png

adammadam
here is healing meat, losing health every turn (I think it will work), and player death again I think/hope it's right.
quest - losing health.png
quest - player death.png
quest - healing meat.png

LeDirt
Thank you, this did help :)

HegemonKhan
great job adammadam, the only thing I'd add is to not have two (global) Turnscripts, but only one (global) Turnscript. Have your 'death' Script(s) added first, and then your 'losing health' Script(s) added aferwards (and I don't know if he~she wants the 'losing health' to be conditional, 'if (xxx) { player.health=player.health-1 } else if (xxx) { scripts } else { scripts }', or not).

<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
} else {
player.health=player.health-1
}
]]></script>
</turnscript>

~OR, an example of a conditional for your losing health ~

<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
} else {
if (player.status_effect = "poisoned") {
player.health=player.health-1
}
}
]]></script>
</turnscript>


~ OR you can have your 'losing health' Script(s) first, and then your 'death' Script(s) ... I'm not sure which is the better design~practice to do (and it also depends on the rest of your game design too, such as: if you got a party~team and can revive dead party~team members), lol ~

<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
player.health=player.health-1
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
}
]]></script>
</turnscript>

~OR, an example of a conditional for your losing health ~

<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
if (player.status_effect = "poisoned") {
player.health=player.health-1
}
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
}
]]></script>
</turnscript>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums