Could cursor actions be modified to allow selecting AI characters/settlements? If so then EnemyCharacterSelected might fire after all. (Not that this helps your problem Gigantus.)
e_select_character is really flaky unless used in a CharacterSelected event monitor. And still only works for the player faction I believe.
FactionWideTrait: tricky but it looks like this works...
Script:
Code:
declare_counter faction_has_trait_xxx
monitor_event PreFactionTurnStart
set_counter faction_has_trait_xxx 0
end_monitor
monitor_event CharacterTurnStart Trait xxx > 0
set_counter faction_has_trait_xxx 1
end_monitor
monitor_event CharacterTurnEnd
set_event_counter give_trait_xxx 0
end_monitor
monitor_event CharacterTurnEnd I_CompareCounter faction_has_trait_xxx = 0
and TrueCondition
set_event_counter give_trait_xxx 1
set_counter faction_has_trait_xxx 1
end_monitor
EDCT:
Code:
(a Trait "xxx" with one level of threshold = 1)
;------------------------------------------
Trigger give_trait_xxx_trigger1
WhenToTest CharacterTurnEnd
Condition I_EventCounter give_trait_xxx = 1
and TrueCondition
Affects xxx 1 Chance 100
At the start of the turn it sets faction_has_trait_xxx to 1 if the trait currently exists (0 if not).
At the end of the turn, for each character:
a) give_trait_xxx set to 0
b) give_trait_xxx set to 1 only if the faction does not already have it AND the character meets specific conditions (see below) ... at which time faction_has_trait_xxx is also set to 1 (they don't yet but will in the next step)
c) EDCT's trigger fires only if give_trait_xxx = 1, i.e. was set to 1 in the previous step, giving him the trait
So if a character does get it then nobody else will for that faction in that turn end because the character getting it set faction_has_trait_xxx = 1 (fourth monitor) which means that the fourth monitor will not fire for anybody else, due to its "faction_has_trait_xxx = 0" condition, thus give_trait_xxx remains as 0 for everybody else and therefore fails the EDCT conditions.
The fourth script monitor and the EDCT trigger must have the same conditions, the part highlighted in blue. Replace "and TrueCondition" with whatever conditions are actually needed. They must be identical otherwise script might think that the EDCT trigger will be firing when it actually isn't (or vice versa) which breaks everything.
Also, be wary of the "Characters" attribute of the trait: make sure that it is not introducing a condition (character type) which the script's monitor doesn't also have. Otherwise, again, the script might think that the trait is about to be awarded when in fact it isn't due to character's type not matching the trait's "Characters" type.
One last thing: say this is the player's faction and the character with the trait dies in battle during the player's turn. faction_has_trait_xxx is still 1 for this faction (as it's set at turn start) so during turn end nobody will get the trait ... not until the turn end of the next turn. So the trait will be absent this turn (after his death) and the next, then appear the turn after that. No way to avoid that that I can see.
I tested it but not with any special additional conditions.
It should work for all factions - player and AI - but I didn't test the AI.