Is it heal_unit cumulative with heal or regenerate ?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Is it heal_unit cumulative with heal or regenerate ?

Post by Enchanteur »

Hi everybody,

I didn't come here from a long time ago.
I currently slightly improve my game experience with littles tweaks, and play campains of the game.

I'm modifying amla code because i just want something more exciting for game campains.
I made a abilities about giving some HP to amla level units.

I would like this give a HP bonus, independently of others life gains like heal, regenerate or villages.

So my question here :
The wml heal_unit is it cumulative or not ?
I know if a unit have the "regeneration" abilitie, the unit gain 8 HP, even if the unit is aside a unit with "heal" ability.
The unit don't get 16 HP, the unit just get the max amount between the heal abilities.

But I want my ability doing : if the abilities heal 3 HP, and the unit already have regeneration abilities, the units will get 8 + 3 HP at start of the turn.

I know how to make an ability looking like this with the wml "heal_unit", but I don't know if it's cumulative or not.

Thanks.
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by tekelili »

Heals and regenerates are not comulative abilities, not only due to game concepts, but also because both are provided by the same wml tag

Code: Select all

[abilities]
    [heals]
    [/heals]
[/abilities]
As far as I know, you should use an "[event] name=side turn" in order to overlap healing effects.

However such effect would be comulative not only with regenerates, but also with usual heals. I dont see an easy way to differenciate both concepts in wml.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Ravana
Forum Moderator
Posts: 2952
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by Ravana »

I dont think there is other way as non-eventbased ability than using separate filters for separate cases like https://github.com/ProditorMagnus/Agele ... repair.cfg.

However, [heal_unit] is part of DirectActionsWML and modifies heath directly rather than calling ability, so no normal limitations apply.
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by Enchanteur »

Hello, thank for your quick answer.
Effectively, I was wondering the ability don't work like I wanted, but my test was not revealent because I played vigourous dwarves.

I ended to do this "hard" coded ability :

Code: Select all

#define ABILITY_PROGRESSIVEVITALITY
    [dummy]
        id=progressivevitality
	   name= _ "Vitalite Progressive"
        female_name= _ "female^Vitalite"
        description=_ "Cette unite regagne 5% de ses points de vie au debut du tour, cumulable avec d'autres soins."
    [/dummy] # wmlxgettext: [abilities]
[/abilities]
[event]
    name=side turn
    first_time_only=no
	[store_unit]
		[filter]
			side=$side_number
			ability=progressivevitality
 		[/filter]
		variable=vitaliseur
	[/store_unit]

	{FOREACH vitaliseur i}
		[if] 
		[variable]  
            	name= vitaliseur[$i].max_hitpoints  
            	not_equals=$vitaliseur[$i].hitpoints  
        	[/variable]

		[then]
			{VARIABLE lifegain $vitaliseur[$i].max_hitpoints}
			{VARIABLE_OP lifegain multiply 0.05}
			 
			{VARIABLE maxgain $vitaliseur[$i].max_hitpoints}
			{VARIABLE_OP maxgain add -$vitaliseur[$i].hitpoints}
			[if]
				[variable]
					name=lifegain
					greater_than=$maxgain
				[/variable]
				[then]
					{VARIABLE lifegain $maxgain}
				[/then]
			[/if]
			{VARIABLE_OP vitaliseur[$i].hitpoints add $lifegain}			
			
			[unstore_unit]
			     variable=vitaliseur[$i]
			     {COLOR_HEAL}
			     text= _ "+$lifegain| Vital"
			     find_vacant=no
			[/unstore_unit]
			   
			{CLEAR_VARIABLE lifegain}
			{CLEAR_VARIABLE maxgain}
	    	[/then]

	[/if] 
	{NEXT i}
	{CLEAR_VARIABLE vitaliseur}
[/event]
[+abilities] # wmlxgettext: [/abilities]
#enddef
I tested it a few minutes ago, giving the ability to a elves champion.
So I badly injured the champions in some fights, and then move him on a village.
The game show 2 healing animations (quite fast), the +8 HP of the village, and then the +3 HP of the ability (the abiliy give +5% of total HP, the champions was 70 HP, so it give 3 HP). The champion HP was 39, and turn after was 50. SUCCESS !!!

Here, my current amla cfg file :

Code: Select all

#textdomain wesnoth-help
#this file contains macros for After Max Level Advancement (AMLA)

#define AMLA_DEFAULT
    # Canned definition of the default AMLA.
    [advancement]
        strict_amla=yes
        max_times=100
        id=amla_default
        description= _ "Max HP bonus +5 and +10%, Strikes and damage +10%, Max XP +10%, movement +10%, all resistances +2, all defenses +2, cumulative heal +5% lifetotal"
        image="misc/icon-amla-tough.png"
        [effect]
            apply_to=hitpoints
            increase_total=5
            heal_full=yes
        [/effect]
        [effect]
            apply_to=hitpoints
            increase_total=10%
            heal_full=yes
        [/effect]
        [effect]
            apply_to=resistance
            [resistance]
                blade=-2
                pierce=-2
                impact=-2
                fire=-2
                cold=-2
                arcane=-2
            [/resistance]
        [/effect]
	  [effect]
		apply_to=defense
		replace=no
		[defense]
			deep_water=-2
			shallow_water=-2
			reef=-2
			swamp_water=-2
			flat=-2
			sand=-2
			forest=-2
			hills=-2
			mountains=-2
			village=-2
			castle=-2
			cave=-2
			frozen=-2
			unwalkable=-2
			impassable=-2
			fungus=-2
		[/defense]
	  [/effect]
        [effect]
            apply_to=attack
            increase_damage=10%
		 increase_attacks=10%
		 increase_accuracy=2
		 increase_parry=2
        [/effect]
        [effect]
            apply_to=movement
            increase=10%
        [/effect]
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_PROGRESSIVEVITALITY}
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
        [effect]
            apply_to=status
            remove=poisoned
        [/effect]
        [effect]
            apply_to=status
            remove=slowed
        [/effect]
    [/advancement]
#enddef
It's really more funny to play with this originals campains of the game, the bonus are not unbalanced, and it's rare that an unit go more than amla +2. I like to play with a little goal like this, improve the most an unit in the campain.
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Problem with amla

Post by Enchanteur »

Hi again,

I have a big problem with abilities and amla.
I tryed the amla code you see below, or many anothers "heal" abilities variants in amla.

The abilities works well when I attach it to any unit, but when the ability is given by amla, the ability show well in the right panel, but do nothing at start of turn.
So there is no heal effect in amla conditions, anyone get an idea why and how to solve this ?
Is there something wrong or missing in my amla code about ability ?
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by tekelili »

Not sure I saw all problems, but:
1- Any [event] inside [unit] needs a key "id=" in order to work
2- You are writting [event] inside [effect] in your AMLA code, wich wont work.

Edit: As someone that had problems with give feeding to units, I would suggest avoid have all code in one macro, because in many cases you must write [event] and [abilities] in different places.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by Enchanteur »

Thank for this answer, I see what you mean.
The "event" is inside the #define ABILITY code.
I am looking at how to spare it.

I found this in wiki :
Event
This tag is a subtag of the [scenario], [unit_type] and [era] tags
So there is no way, because it need to edit every scenario and add the event into. Or do so with every unit. And Era are only MP.
I don't know if it's possible to define somewhere some "global events", events that occur for every games.

At this point, it look like no "events" abilitys can be used in any AMLA, except if you made your own campaigns and call the event in each scenario. In this case, maybe this additionnal heal ability might work, but it's not my goal, i just want use it at a default gameplay in basics campains.
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by tekelili »

[event] can be written also inside [unit]. It can also being added to a stored unit with [set_variables]. Your problem with carry events each scenario is solved if you write them inside units. This can be done in multiple ways, but I dont know your whole scenario/problem to provide more details right now.

If you interested, my add on World Conquest II uses a lot [event] inside units for different proposes like magic items or traits
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by Enchanteur »

Write it in units means I need to edit all units of the game.
My goal is to make an "amla" giving the ability to high level units.
I don't mod any new scenario or new campaigns. I just play campaigns of base game. But tweak a little the amla system.
I will look inside your code, I didn't play yet world conquest, but it look great, it's on my list ;)
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by tekelili »

I forgot something could be very usefull in your case, just write [event] inside a [modification] and will be present in every scenario of campaign if you load it.

Edit: May be it is not possible use [modification] outside [multiplayer] in BfW 1.12 (I am not sure right now and if there are workarounds)

Edit2: You could also considere just write [event] once inside your leader for every campaign, that asures presence in every scenario of that campaign (as long leader is present in scenario start).
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by Enchanteur »

Hi,
The modification method look the best one.
I tried to do so, but this don't work. I'm sure I didn't write the [modification] in the good place. Because "FOREACH" was not recognized, like if the tag was read before the macro.
Well, I don't know where to put this [modification]. In any _main.cfg ?
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by Enchanteur »

I maybe found a new way to do this, so evident and simple. After reading "Effect" wiki.
In amla, there some effect about increasing max HP of unit. But there should possible to do same with just "HP" !
I will try this and report ;)

EDIT : no, it can't work because effect happens only when amla is trigger, one time by level. But maybe i can use a Trait instead of an ability, or do something around this.
EDIT again : it can't work too, because the effect need to trigger at beggining of each turn, so go back to the event...

EDIT Re AGAIN : I finally found the best way to do what I want, and it's instructive about game structure.

In each scenario there is a call to a function "SCHEDULE". It use [Time] tag, about day and night.
Most of the time, a scenario never write the schedule directly inside and call a function because there is always the same stuff.

SO : I need to edit the schedule functions.
It's a little weird because it's not the purpose of a schedule function to call events, but shedule are at root inside [scenario].

I end to consider that there is something missing in the game code : in every scenario, a call to a function called "GLOBAL_EVENTS".
And inside this function, there is possibility to write events you want for every scenario of every campaigns.

But I willnt add it, it's to much copy-paste.
I will edit schedules functions and add a call to a GLOBAL_EVENTS function inside. And then, inside this GLOBAL_EVENTS, i will call all events I need, so the events of my ability alone, but maybe if one day I start modding BfW, I will use it again.

EDIT again again :
I made all codes and will test it into game, at first, the game don't crash and don't send any error message, it's quite a good new.

I found this also, in event wiki :
id
If an id is specified, then the event will not be added if another event with the same id already exists. An id will also allow the event to be removed, see below. Supplying a non-empty id= is mandatory in case of a [unit_type][event].
So, I put the call of GLOBAL_EVENTS in every place I saw in functions of schedule. I found some campains (like "a new order") that don't use DEFAULT_SCHEDULE. So, I can also call the function in music functions. The fact if the event is redondant it's not called twice is really nice, else, the events would multiply life gain. But to do so, it need an Id.
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by tekelili »

Enchanteur wrote:I end to consider that there is something missing in the game code : in every scenario, a call to a function called "GLOBAL_EVENTS".
And inside this function, there is possibility to write events you want for every scenario of every campaigns.
You found a good trick for your isue in BfW 1.12, however I think developers are working (or have already done) in tags like [modification] or [resource] for BfW 1.13 that will allow solve your issue in more easy and clean way in BfW 1.14
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Enchanteur
Posts: 72
Joined: September 28th, 2009, 11:05 am

Re: Is it heal_unit cumulative with heal or regenerate ?

Post by Enchanteur »

tekelili wrote:
Enchanteur wrote:I end to consider that there is something missing in the game code : in every scenario, a call to a function called "GLOBAL_EVENTS".
And inside this function, there is possibility to write events you want for every scenario of every campaigns.
You found a good trick for your isue in BfW 1.12, however I think developers are working (or have already done) in tags like [modification] or [resource] for BfW 1.13 that will allow solve your issue in more easy and clean way in BfW 1.14
Hello !
Good news,
I made the function, and call it from shedule or music functions. So this function add "global events".
I tested it and when my unit go level up amla, the ability work great.
I tested ability + unit on village or near a healer, the lifegain is cumulative like I wanted !
Next step : I will post here the code (too tired to do it now).
I will try to make the ability with "heal_unit" instead of the complicated life gain function I previously made.
I thinked "heal_unit" didn't work, but it should work, it was just the event into amla that not worked in real fact.

I'm thinking definitively about the code structure.
Base game and each custom campaign should have a call to a global event function. All event code from ability could go there.
So it's clean code, and event code of ability can always work, from amla or from unit.
It's logical, in a campaign with custom units, units will need their events ability code all along the scenarios.
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
Post Reply