So I've been trying to create trait triggers with multipel outcomes but I have come to a dead end. Issue is, effect.trait("...", "...", x, x, context) simply does not fire when there are more then one, which is interesting because in Attila lua code I'm seeing lots of trait triggers parented by same functions. Lua structure of Rome2 and Attila seems pretty much same to my novice eyes, which leads me to believe either I'm doing something dumb or I'm straightforward dumb to think they are similar...
Here is an example to make it more clear, this is from Attila. Upon creation, script assigns a character "humble" or "arrogant" trait by chance.
Code:
function att_trig_general_parent_has_trait_personality_all_innate_arrogant_impl (context)
return char_is_general(context:character()) and context:character():has_father() and context:character():father():has_trait("att_trait_general_personality_all_innate_arrogant")
end
events.CharacterCreated[#events.CharacterCreated+1] =
function (context)
if att_trig_general_parent_has_trait_personality_all_innate_arrogant_impl(context) then
effect.trait("att_trait_general_personality_all_innate_humble", "agent", 3, 40, context)
effect.trait("att_trait_general_personality_all_innate_arrogant", "agent", 3, 40, context)
return true
end
return false
end
Attempting to mimic the code in Rome2 however, results in absence of whole function.
Code:
function dei_physical_att_trait_impl (context)
return char_is_general(context:character()) and not context:character():has_trait("dei_physical_young_frail") and not context:character():has_trait("dei_physical_young_vigorous")
end
events.CharacterCreated[#events.CharacterCreated+1] =
function (context)
if dei_physical_attri_trait_impl(context) then
effect.trait("dei_physical_young_frail", "agent", 1, 50, context)
effect.trait("dei_physical_young_vigorous", "agent", 1, 50, context)
return true
end
return false
end
In any case how would it be possible to implement this concept of assigning random traits via events? Tried Kankrusha's method of creating a table and assigning with math.random but I haven't had any luck.