Assigning Multiple Traits via Options is not working
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.
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Assigning Multiple Traits via Options is not working
Hi I am currently working on a scenario where players get to pick several options and then according to the options they receive custom traits that are basically assigned as dummy traits. The traits work, however each time the player chooses the next option that assigns another trait, the previous one is overridden. I want the previous traits to remain so that players will be able to know the options they picked in the past. How would I fix this?
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Assigning Multiple Traits via Options is not working
Apparently, you have a bug in your code. But, it's really hard for us to help you find it if you don't show us the code. Without that, we would have to guess how you might have written it and what kind of mistakes you might have made.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Re: Assigning Multiple Traits via Options is not working
Here is the first set of traits and choices that have the traits overwritten keeps getting overwrittenbeetlenaut wrote: ↑September 4th, 2018, 4:03 am Apparently, you have a bug in your code. But, it's really hard for us to help you find it if you don't show us the code. Without that, we would have to guess how you might have written it and what kind of mistakes you might have made.
Code: Select all
#define LA_CLASS_FIGHTER
[trait]
id=la_class_fighter
male_name= _ "Class: Fighter"
female_name= _ "female^Class: Fighter"
description= _ "This Hero has chosen the Fighter Class."
help_text= _ ""
[/trait]
#enddef
#define LA_CLASS_RANGER
[trait]
id=la_class_ranger
male_name= _ "Class: Ranger"
female_name= _ "female^Class: Ranger"
description= _ "This Hero has chosen the Ranger Class."
help_text= _ ""
[/trait]
#enddef
#define LA_CLASS_MAGICIAN
[trait]
id=la_class_magician
male_name= _ "Class: Magician"
female_name= _ "female^Class: Magician"
description= _ "This Hero has chosen the Magician Class."
help_text= _ ""
[/trait]
#enddef
#define LA_CLASS_BRUISER
[trait]
id=la_class_bruiser
male_name= _ "Class: Bruiser"
female_name= _ "female^Class: Bruiser"
description= _ "This Hero has chosen the Bruiser Class."
help_text= _ ""
[/trait]
#enddef
#define LA_CLASS_ROGUE
[trait]
id=la_class_rogue
male_name= _ "Class: Rogue"
female_name= _ "female^Class: Rogue"
description= _ "This Hero has chosen the Rogue Class."
help_text= _ ""
[/trait]
#enddef
{LA_SET_HERO_CLASS_OPTION "sword" "Fighter (FIGHTER)" fighter "fighter desc" elf elf_sword bow {LA_CLASS_FIGHTER}}
{LA_SET_HERO_CLASS_OPTION "bow" "Ranger (RANGER)" ranger "ranger desc" elf bow dagger {LA_CLASS_RANGER}}
{LA_SET_HERO_CLASS_OPTION3 "magestaff" "Druid (MAGICIAN)" magician "druid desc" elf elf_magic none ({VARIABLE_OP la_hero[$side_number].magic.chosen add 1}) {LA_CLASS_MAGICIAN}}
#define LA_SET_HERO_CLASS_OPTION IMAGE CLASS_DESCRIPTION CLASS DESCRIPTION RACE WEAPON1 WEAPON2 TRAIT
{LA_OPTION_IMAGE_SHOW_IF "units/$la_hero[$side_number].race/{IMAGE}.png" "<span color='#00FF00' weight='bold'>{CLASS_DESCRIPTION}</span>
<span size='x-small'>{DESCRIPTION}</span>
<span color='#FF8000' size='xx-small'>PRIMARY: $la_weapons.{WEAPON1}_2.name
SECONDARY: $la_weapons.{WEAPON2}_1.name</span>" ({VARIABLE_CONDITIONAL la_hero[$side_number].race equals {RACE}}) (
[modify_unit]
[filter]
side=$side_number
[/filter]
side=$side_number
canrecruit=yes
[modifications]
{TRAIT}
[/modifications]
[/modify_unit]
{VARIABLE la_inventory[$side_number].potion.red_small 3}
{VARIABLE la_inventory[$side_number].potion.red_medium 1}
{VARIABLE la_inventory[$side_number].potion_blue_tiny 1}
{VARIABLE la_inventory[$side_number].{WEAPON1}_2 1}
{VARIABLE la_inventory[$side_number].{WEAPON2}_1 1}
{VARIABLE la_hero[$side_number].class_description "{CLASS_DESCRIPTION}"}
{VARIABLE la_hero[$side_number].class {CLASS}})}
#enddef
Code: Select all
#define LA_BLOODLINE_CHOICE
[message]
speaker=narrator
message={LA_HERO_INVENTORY_STATS_MESSAGE}
#{LA_OPTION_IMAGE "None" "icons/check.png" ()}
{LA_BLOODLINE_OPTION "Veromos - god of Vitality
Gifted with the power of self healing, the descendants of Veromos rest heal even if they were in combat the previous turn as well as start with +1 hitpoint and gain +2 hitpoints per level." "gods/veromos.png" {LA_BLOODLINE_VEROMOS} veromos (
[object]
silent=yes
duration=forever
[filter]
side=$side_number
canrecruit=yes
[/filter]
[effect]
apply_to=hitpoints
increase_total=1
[/effect]
[effect]
apply_to=hitpoints
times=per level
increase_total=2
[/effect]
[effect]
apply_to=hitpoints
increase=3
[/effect]
[/object])}
{LA_BLOODLINE_OPTION "Psamathe - god of Magic
Known for his impeccable magical talent, the descendants of Psamathe gain an extra 2 Magic Points upon an reaching max experience as well as starting with 10% less required experience to level up." "gods/psamathe.png" {LA_BLOODLINE_PSAMATHE} psamathe (
[object]
silent=yes
duration=forever
[filter]
side=$side_number
canrecruit=yes
[/filter]
[effect]
apply_to=max_experience
increase=-10%
[/effect]
[/object])}
{LA_BLOODLINE_OPTION "Ritesh - god of Riches
Known for his love of gold, the descendants of Ritesh start with an extra 25 gold and gain +1 more gold per kill." "gods/ritesh.png" {LA_BLOODLINE_RITESH} ritesh (
[store_unit]
[filter]
side=$side_number
canrecruit=yes
[/filter]
variable=ritesh
[/store_unit]
[unstore_unit]
variable=ritesh
text=+25 gold
red,green,blue=255,255,0
[/unstore_unit]
[sound]
name=gold.ogg
[/sound]
[gold]
side=$side_number
amount=25
[/gold]
{CLEAR_VARIABLE ritesh})}
[/message]
#enddef
#define LA_BLOODLINE_OPTION MESSAGE IMAGE TRAIT VAR WML
{LA_OPTION_IMAGE {MESSAGE} {IMAGE} ([modify_unit]
[filter]
side=$side_number
[/filter]
side=$side_number
canrecruit=yes
[modifications]
{TRAIT}
[/modifications]
[/modify_unit]
{VARIABLE la_hero[$side_number].bloodline_chosen {VAR}}
{WML})}
#enddef
#define LA_BLOODLINE_VEROMOS
[trait]
id=la_veromos
male_name= _ "Veromos"
female_name= _ "female^Veromos"
description= _ "Descendants of Vermos always rest heal"
help_text= _ "Known for his powers of self regeneration, descendants of Veromos always rest heal." + _ "
<italic>text='Veromos'</italic> heroes have 1 additional hitpoint, and gain 2 more per level. They will also heal 2 hitpoints each turn, regardless of whether they engaged in combat the turn before."
[effect]
apply_to="healthy"
[/effect]
[effect]
apply_to=hitpoints
increase_total=1
[/effect]
[effect]
apply_to=hitpoints
times=per level
increase_total=2
[/effect]
[/trait]
#enddef
#define LA_BLOODLINE_RITESH
[trait]
id=la_ritesh
male_name= _ "Ritesh"
female_name= _ "female^Ritesh"
description= _ "Descendants of Ritesh start with an extra 25 gold and gain +1 more gold per kill."
help_text= _ "Known for his obsession with gold, the descendants of Ritesh start with an extra 25 gold and gain an extra 1 gold per kill."
[/trait]
#enddef
#define LA_BLOODLINE_PSAMATHE
[trait]
id=la_psamathe
male_name= _ "Psamathe"
female_name= _ "female^Psamathe"
description= _ "Descendants of Psamathe gain 2 extra Magic Points upon an reaching max experience as well as starting with 10% less required experience to level up."
help_text= _ "Known for his immpecable magical prowess, the descendants of Psamathe gain 2 extra Magic Points upon an reaching max experience as well as starting with 10% less required experience to level up."
[effect]
apply_to=max_experience
increase=-10%
[/effect]
[/trait]
#enddef
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Assigning Multiple Traits via Options is not working
Traits are stored as an array under [modifications]. If you replace the [modifications] tag like you are doing, you rewrite the whole traits array with the one trait you are currently adding. Try using [modify_unit] tag without [modifications]. Put the [trait] block in at the top level of the tag. That should automatically add the new trait to the array.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Re: Assigning Multiple Traits via Options is not working
Thanks! It worked!beetlenaut wrote: ↑September 4th, 2018, 4:53 am Traits are stored as an array under [modifications]. If you replace the [modifications] tag like you are doing, you rewrite the whole traits array with the one trait you are currently adding. Try using [modify_unit] tag without [modifications]. Put the [trait] block in at the top level of the tag. That should automatically add the new trait to the array.
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Assigning Multiple Traits via Options is not working
That's not actually what that code does, as far as I know. Rather, it replaces your first trait with the new trait while leaving any other traits untouched. This is because thebeetlenaut wrote: ↑September 4th, 2018, 4:53 am If you replace the [modifications] tag like you are doing, you rewrite the whole traits array with the one trait you are currently adding.
[modify_unit]
tag merges subtags rather than overwriting them.- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Assigning Multiple Traits via Options is not working
Oh! Thanks for the correction.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide