how to regenerate(ability regenerate) by percentage with respect to hitpoints?
Moderator: Forum Moderators
Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?
I hope you understand what I want to do in the code.
Any help in coding? please
this code is bad
Any help in coding? please
Code: Select all
[regenerate]
[if]
hitpoints>="(hitpoints*0.5)"
[then]
value=5
[/then]
[¨else]
value=10
[/then]
[/if]
Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?
I'm sorry, I know that I wrote some labels wrong, in the same way I corrected it and it does not work
Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?
[regenerate] does not allow ActionWML, so [if] does nothing.
See the formula if() function documentation.
See the formula if() function documentation.
Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?
Excuse the insistence Mr. Ravana, I used the formula uqe suggested me but when I start the game I get an error
Error loading custom game configuration files. It will try to play without loading add-ons.
Details:
Unexpected characters after the name of the variable ("," or "=" were expected)
in core / macros / abilities.cfg: 67
included from core / _main.cfg: 18
included from _main.cfg: 18
included from core / units / dunefolk / Apothecary.cfg: 12
included from core / units.cfg: 19
included from core / _main.cfg: 31
included from _main.cfg: 18
I will show you how I keep the code, to practice I am modifying the default regenerate of the game
Error loading custom game configuration files. It will try to play without loading add-ons.
Details:
Unexpected characters after the name of the variable ("," or "=" were expected)
in core / macros / abilities.cfg: 67
included from core / _main.cfg: 18
included from _main.cfg: 18
included from core / units / dunefolk / Apothecary.cfg: 12
included from core / units.cfg: 19
included from core / _main.cfg: 31
included from _main.cfg: 18
I will show you how I keep the code, to practice I am modifying the default regenerate of the game
Code: Select all
#define ABILITY_REGENERATES
# Canned definition of the Regenerate ability to be
included in an [abilities]
# clause.
[regenerate]
if ( hitpoints <= "(max_hitpoints*0.7)", value=7 , value=4 )
id=regenerates
name= _ "regenerates"
female_name= _ "female^regenerates"
description= _ "The unit will heal itself 8 HP per
turn. If it is poisoned, it will remove the poison instead of
healing."
affect_self=yes
poison=cured
[/regenerate]
#enddef
Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?
This is getting closer.
[regenerate]
value="(if( hitpoints <= (max_hitpoints*0.7), 7 , 4 ))"
[regenerate]
value="(if( hitpoints <= (max_hitpoints*0.7), 7 , 4 ))"
Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?
thank you very much ravana, the code works, also now I am more clear where should go the formulas, I guess that use "switch / case" would be in the same place where you put the formula of "if", again thanks