Do anyone knows how to monitor the death of a name character/general?
My idea is: try to spawn a new general by game script when a general was either been killed and died naturally
Do anyone knows how to monitor the death of a name character/general?
My idea is: try to spawn a new general by game script when a general was either been killed and died naturally
There are a few character-died events but if you don't care how he died then it would be simpler just to check if he's still alive.
There's the I_CharacterExists condition but using his name is no good because someone else might have that name too, so it will say "yes" even when your character is dead.
This is the best way I think:
(Let's call him Bob.)
When he's spawned (and in descr_strat.txt if he's alive at game start) give him a trait that nobody else can get. e.g. "BobTrait".
In campaign_script.txt add this:
Code:monitor_event PreFactionTurnStart FactionType {Bob's faction} set_event_counter bob_is_alive 0 end_monitor monitor_event CharacterTurnStart Trait BobTrait > 0 ;a character with this trait is alive - it must be him set_event_counter bob_is_alive 1 end_monitor monitor_event FactionTurnStart FactionType {Bob's faction} if I_EventCounter bob_is_alive = 0 spawn_army character ... Bob ... traits BobTrait 1 unit ... end end_if end_monitor
Last edited by Withwnar; October 04, 2011 at 04:31 AM.
It's a good idea to monitor by unique trait!
but the problem is - i have to create an unique trait for every single character for the start of the campaign. As the game goes on, more general will come up so can i monitor those new born general after the game has been started?
Every single character? So no general ever truly dies?
Well, if that's what you need then yes: you will need a unique trait for each one.
If you also want to cater for generals that are 'born' by the game instead of by descr_strat or script (is that what you meant?) then it's not possible. The respawning script can't know what his name is suppose to be, even if you could somehow give them a unique trait.
Withwnar: It might be possible, if you used a non-unique trait:
Spoiler Alert, click show to read:
Then, via a script, you could count the number of generals that have the trait at the start and end of their turn:
Spoiler Alert, click show to read:
You should then be able to work out how many generals you need to spawn:
Spoiler Alert, click show to read:
This idea does assume that you would have more generals at the start of a turn than at the end. It should also accommodate the future generation of generals.![]()
Nice one TNZ.Great use of that first while loop to handle the spawn count! I think that you could combine those two PreFactionTurnStart monitors: just put the first WHILE before the second.
It will 'resurrect' dead generals but their name will be lost, replaced by a random one. But perhaps this is not a problem, now that I reread the OP.I thought the idea was to resurrect the same character when he dies, not replace him with a new general.
thanks TNZ but the idea with while loop~!
i tried it on testing and found that numerous of general were spawned in the 2nd turn (i got 10 on the inital turn). so i am wondering if the prob is related to the event sequence, i am trying to test it with other events
TNZ, still the same with this one
Later on i replaced PreFactionTurnStart with FactionTurnEnd and it WORKED!!
But there is another problem...when my generals die in the defending a siege, no generals respawn after all
i think if it is becoz the england_general_start only be increased in england's turn, and those generals died defending seige is in AI's turnwhen the new turn starts, they are not count in this turn???
![]()
I've developed several monitors base on TNZ's coding. It includes:
1. generals died in AI turn
2. spawn general when a settlement is captured by local faction(also check if general > settlement, no spawn_army will trigger even though a the faction has captured a new settlement)
NOT YET TESTED...WILL TEST IT AND SHARE THE RESULT
Code:declare_counter england_general_start declare_counter england_general_start2 ;this counter will bring the numbers of general from current turn to next turn () declare_counter england_general_start3 declare_counter england_general_start_this declare_counter england_general_start_next declare_counter england_general_end declare_counter england_general_end2 declare_counter england_settlement ;monitor_event OccupySettlement TargetFactionType England ; inc_counter england_general -1 ;end_monitor monitor_event CharacterTurnStart CharFactionType england and Trait Isgeneral = 1 inc_counter england_general_start 1 inc_counter england_general_start2 1 inc_counter england_general_start_this 1 inc_counter england_general_start_next 1 end_monitor monitor_event FactionTurnStart FactionType england ;and I_TurnNumber > 0 while I_CompareCounter england_general_start > 0 inc_counter england_general_start -1 inc_counter england_general_start2 -1 inc_counter england_general_start3 1 end_while while I_CompareCounter england_general_start3 > 0 inc_counter england_general_start3 -1 inc_counter england_general_start2 -1 end_while while I_CompareCounter england_general_start2 > 0 inc_counter england_general_start2 -1 spawn_army faction england character random_name, named character, age 18, x 101, y 219, traits LoyaltyStarter 1 unit NE Bodyguard exp 1 armour 0 weapon_lvl 0 end end_while set_counter england_general_start 0 set_counter england_general_start2 0 set_counter england_general_start3 0 end_monitor monitor_event CharacterTurnEnd CharFactionType england and Trait Isgeneral = 1 inc_counter england_general_end 1 inc_counter england_general_end2 1 end_monitor monitor_event SettlementTurnEnd FactionType england inc_counter england_settlement 1 end_monitor monitor_event FactionTurnEnd FactionType england ;and I_TurnNumber > 0 while I_CompareCounter england_general_end > 0 inc_counter england_general_end -1 inc_counter england_general_start_this -1 end_while while I_CompareCounter england_general_end2 > 0 inc_counter england_settlement -1 inc_counter england_general_end2 -1 end_while while I_CompareCounter england_settlement > 0 inc_counter england_settlement -1 inc_counter england_general_start 1 end_while while I_CompareCounter england_general_start_this > 0 inc_counter england_general_start_this -1 spawn_army faction england character random_name, named character, age 18, x 101, y 219, traits LoyaltyStarter 1 unit NE Bodyguard exp 1 armour 0 weapon_lvl 0 end end_while while I_CompareCounter england_general_start_next > 0 inc_counter england_general_start_next -1 inc_counter england_general_start2 1 end_while while I_CompareCounter england_general_start_this < 0 inc_counter england_general_start_this 1 inc_counter england_general_start2 1 end_while set_counter england_general_end 0 set_counter england_general_end2 set_counter england_general_start_this 0 set_counter england_general_start_next 0 set_counter england_settlement 0 end_monitor
Perhaps FactionTurnStart instead of PreFactionTurnStart? The sequence is:
PreFactionTurnStart
CharacterTurnStart [1..n]
FactionTurnStart
Not sure but shouldn't the spawned generals be given the IsGeneral trait too?