How to use Health

jcbroo
I am making an RPG game called caves of ice, and combat works by creating an attack verb for each monster that requires an object, and based on your weapon or item choice you lost health and gained points. I have figured out how to decrease health, but not how to end the game if health reaches zero. I have tried making a turn script that activates every turn, and checks for a specific health value, but there isn't an option for that under the if script. I am using the health that you enable in the game features tab, and not a custom property or anything.

HaganeSteel
Edit: I realized my post might be too advanced. Sorry. I'm going a mile a minute. :oops:

I have nothing to add. :lol:

adammadam
when you add a new script there is an option under "game state" called "finish the game". So you have an if command if player.health (or whavever your health stat is called, vitality etc) < 0

Finish the game.
quest finish game help.png

HegemonKhan
creating~adding a global Turnscript:

click on the upper left most 'Object' in the left side's 'tree of stuff', so that it is highlighted, this ensures that the added~created Turnscript will be global (not locally ~ not limited to within a specific individual room), then (I don't know why 'Turnscript' is not a choice in the left side's 'tree of stuff' as its cousin 'Timer' is, but oh well. Go to the top of the screen, and click on the 'add' in the bar at the top of the screen, and select 'Turnscript'.

Turnscript Name: (whatever you like, I like using this label for its name: global_turnscript)

'enabled' check box: have it check in (this makes it always activated at the beginning of the game, and remains activating every single internal turn, as long as it remains 'enabled', of course)

in~for your (global) Turnscript's Script:

run as script -> add new script -> scripts -> 'if' Script -> [expression] -> player.health <= 0
-> then, -> add a script -> game state (you got to scroll way down) -> 'finish the game' script

in code, it looks like this (added in extra 'print a message' Scripts: the 'msg' Scripts):

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


the Scripts to add~decrease your health:

run as script -> add a script -> player (you got to scroll way down) -> 'increase~decrease health' Script

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

Support

Forums