how to regenerate(ability regenerate) by percentage with respect to hitpoints?

It's not easy creating an entire faction or era. Post your work and collaborate in this forum.

Moderators: Forum Moderators, Developers

ultimatux
Posts: 12
Joined: May 29th, 2012, 4:02 am

Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?

Post by ultimatux » July 25th, 2018, 7:06 am

I hope you understand what I want to do in the code.

Any help in coding? please

Code: Select all

[regenerate]
   [if]
   hitpoints>="(hitpoints*0.5)"
   [then]
     	value=5
   [/then]
   [¨else]
	value=10
   [/then]
   [/if]
   
this code is bad :augh:

ultimatux
Posts: 12
Joined: May 29th, 2012, 4:02 am

Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?

Post by ultimatux » July 25th, 2018, 7:12 am

I'm sorry, I know that I wrote some labels wrong, in the same way I corrected it and it does not work

User avatar
Ravana
Moderator
Posts: 1887
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?

Post by Ravana » July 25th, 2018, 8:58 am

[regenerate] does not allow ActionWML, so [if] does nothing.

See the formula if() function documentation.

ultimatux
Posts: 12
Joined: May 29th, 2012, 4:02 am

Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?

Post by ultimatux » July 25th, 2018, 9:48 pm

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

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

User avatar
Ravana
Moderator
Posts: 1887
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?

Post by Ravana » July 25th, 2018, 10:03 pm

This is getting closer.

[regenerate]
value="(if( hitpoints <= (max_hitpoints*0.7), 7 , 4 ))"

ultimatux
Posts: 12
Joined: May 29th, 2012, 4:02 am

Re: how to regenerate(ability regenerate) by percentage with respect to hitpoints?

Post by ultimatux » July 26th, 2018, 6:00 am

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

Post Reply