Constant Mutation
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.
Constant Mutation
I am trying to have an ability, gainable by amla, in which every side turn the unit gains a new random trait, but keeps its old ones.
I included these macros in the era, but nothing happens.
I included these macros in the era, but nothing happens.
Code: Select all
#define AMLA_MUTATE
[advancement]
id=mutate
always_display=true
image="units/mutant.png"
description="mutate"
max_times=1
[effect]
apply_to=new_ability
times=1
[abilities]
[dummy]
id=unstability
name="unstability"
description="This unit will continuously mutate, changing it's attributes."
[/dummy]
[/abilities]
[/effect]
[/advancement]
#enddef
#define CHANGE_MUTATION
[event]
name=moveto
first_time_only=no
[allow_undo]
[/allow_undo]
[filter]
[/filter]
[set_variable]
name=mutation
rand=1-9
[/set_variable]
[/event]
#enddef
#define MUTATE
[event]
name=side turn
first_time_only=no
[if]
[variable]
name=mutation
numerical_equals=1
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_STRONG}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=2
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_DEXTROUS}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=3
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_RESILIENT}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=4
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_INTELLIGENT}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=5
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_QUICK}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=6
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_WEAK}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=7
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_AGED}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=8
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_DIM}
[/modifications]
[/modify_unit]
[/then]
[/if]
[if]
[variable]
name=mutation
numerical_equals=9
[/variable]
[then]
[modify_unit]
[filter]
ability=unstability
[/filter]
[modifications]
{TRAIT_SLOW}
[/modifications]
[/modify_unit]
[/then]
[/if]
[/event]
#enddef
Last edited by Ghite on August 7th, 2013, 10:42 pm, edited 1 time in total.
Re: Constant Mutation
Does anyone have an idea to fix this?
Re: Constant Mutation
This moveto event looks like something that can cause oos.
As I hate using traits/[modification]/[modify_unit] I cant tell if that part is correct, I would use [object] to edit unit, or store/variables/unstore way.
Instead of that many [if] it is better to use [switch]
Where problem happens, you said nothing happens yet you have no debug messages in this code.
As I hate using traits/[modification]/[modify_unit] I cant tell if that part is correct, I would use [object] to edit unit, or store/variables/unstore way.
Instead of that many [if] it is better to use [switch]
Where problem happens, you said nothing happens yet you have no debug messages in this code.
Re: Constant Mutation
Code: Select all
[event]
name=new turn
first_time_only=no
[store_unit]
[filter]
# filter stuff here
[/filter]
variable=evolving
[/store_unit]
[set_variables]
name=evolving.modifications.trait
mode=append
[value]
#trait stuff here, without [trait] tag
[/value]
[/set_variables]
[unstore_unit]
variable=evolving
[/unstore_unit]
[/event]
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
Re: Constant Mutation
I for one don't like the manipulation of traits. You might want to use random abilities instead, as this is far easier to code.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Constant Mutation
Oh, yeah - that reminds me that changing traits directly hasn't worked for some time now.Heindal wrote:I for one don't like the manipulation of traits. You might want to use random abilities instead, as this is far easier to code.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
Re: Constant Mutation
Look at the mainline QUICK_4MP_LEADERS macro on how to manipulate traits.
Something like the the above should work, change at will to fit your needs. btw, it is rand=1..9 instead 1-9 (two dots not an hyphen)
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
ability=trait_mutation
[/filter]
# build an array of all available traits
[set_variables]
name=random_traits_$unit.id
[literal]
[trait]
# first trait
[/trait]
[trait]
# second trait
[/trait]
[trait]
# another trait
[/trait]
[trait]
# repeat at will
[/trait]
[/literal]
[/set_variables]
[/event]
[event]
name=side turn # this could cause OOS
first_time_only=no
[store_unit]
[filter]
ability=trait_mutation
# side=$side_number ?
[/filter]
variable=unit
[/store_unit]
{FOREACH unit i_temp}
# pick up one trait at random
{RANDOM 1..$random_traits_$unit[$i_temp].id|.trait.length}
{VARIABLE_OP random sub 1}
# add it to the unit
[set_variables]
name=unit[$i_temp].modifications.trait
mode=append # replace ?
[insert_tag]
name=literal
variable=random_traits_$unit[$i_temp].id|.trait[$random]
[/insert_tag]
[/set_variables]
# you may delete it to prevent it to be picked up twice
{CLEAR_VARIABLE random_traits_$unit[$i_temp].id|.trait[$random]}
# apply the changes
[unstore_unit]
variable=unit[$i_temp]
[/unstore_unit]
{NEXT i_temp}
{CLEAR_VARIABLE unit,random}
[/event]