You can for example use a monitor_event ButtonPressed TrueCondition to check if the command works. That will fire it once you press a button.
Here so? Does not work.Originally Posted by alpaca
monitor_event monitor_event ButtonPressed TrueCondition
spawn_army
faction turks
character Bel_Kermek, named character, age 30, x 279, y 138
traits GoodCommander 2
unit ME Bodyguard exp 1 armour 0 weapon_lvl 0
unit Turkomans exp 0 armour 0 weapon_lvl 0
unit Turkish Archers exp 0 armour 0 weapon_lvl 0
end
end_monitor
Allright, I found an idea for the first scripting challenge on the TWC:
Scripting Challenge #1: Re-Emergent factions
issued on May, 20th 2007
The task is simple: Create re-emergent factions similar to those you know from the original MTW. I didn't try to do that myself, yet, so I'm not sure if it's possible. If you have a proposition, simply post it in this here thread.
The best one will be put into the script-o-rama, and I will participate, too.
It is impossible. I shall alter existing Mongols.
Thanks.
Scripting Challenge #1: Re-Emergent factionsSo I guess You have won.It's not impossible, in fact I already did it yesterday...
Congratulations man.
I hope You will share Your idea ( I dont mod M2TW yet ).
So how about that idea?
Can You elaborate?
Interesting challenge. Let's see... you can't allow anyone to really destroy a faction because it would mess up the family tree when they re-emerge, right ? Or is there a way to start them over ? I'll assume not. Also, since factions are destroyed when they have no cities, you can't pop a stack out of nowhere so... Here's my idea :
First, you create a few additional cities, somewhere inaccessible. Maybe landlocked in the americas, or on Atlantis, or in the arctic... Somewhere no-one can get in, and no one can get out. When a faction is "destroyed", fire a script that gives one of those lonesome cities to them, with just enough militia that they don't revolt. Also, start *another* script that will start a countdown, say 10 turns on VH, 50 on Easy. When that countdown is over, you pop a RandomChance trigger on every EndTurn that, if successfull, triggers a re-emergeance, which is : one pre-determined full stack of troops popping up near said faction's former capital, with the mission "take that capital in 5 turns". If they succeed, the reward is they lose their former unreachable city and start anew. If they lose, then the stack disappears, and the countdown resets.
Then again, the AI being what it is, I'm not sure it can deal coherently with a lone stack away from its borders... but hey, you never know till you've tried.
Am I close to your idea ?
EDIT : something else hit me : the Mongols and Timurids AREN'T destroyed when they first pop up and they have no city, maybe duplicating their event would do the trick in a simpler fashion ?
Last edited by Kobal2fr; 06-25-2007 at 10:26.
Anything wrong ? Blame it on me. I'm the French.
Hi Alpaca,
first of all ... great tut. you and .. er .. the gang made, as I've worked for extended periods of time with so called script-editors this was actually somewhat hard to understand (more cause I had to "un"-learn a few things ...)
anyway based on that horde-script you have in the 2nd post I'd like to ask you or anyone else that might know it a hopefully simple question(s).
-is there a way to check up on the existance of any kind of remnand from a horde-faction (my idea is to make the Mongols and Tim.. er guys regular factions and than add up the max (31 ?) factions hording factions distributed across the islam and catholic factions (eg; 3 islam hording- and 4 catholic hording-factions) wich than after say 50-ish turns start spawning near so called rebel-capitals (in the center of what once was rebel-terf.), but I'd like to say respawn them ~20-50 turns after a possible dead (to make sure no matter what the player always has some fearsome (behind the lines) enemies to deal with and ofcourse cause I'm just plain evil ... :P)
edit;
think I've already found an answer to this one .... no you cant directly, but can indirectly ...
create a trait for the horde-factions and give it when a general comes to age, check each turn for the trait and if it no longer exists in that particular faction start a random counter (or possible as the mongols are spawned, date from now)
/edit
-on a side-note, and if my memory serves me right I think impossible, but I'd rather have some expert confirm it than just abandoning it, is it somehow possible in M2 to check up on the "capital of faction x" or "get nearest settlement [faction] [ref.pos/settlement]" (for a "almost dead faction reinforcement spawn in")
I know I can just use the starting capital and place armies like in the nearest forest (auto-hiding them so you wont see them just "pop-up") just incase the settlement is no longer owned by that faction, but that leaves them with possibly small armies scattered wherever they are no longer (poss. causing a logistic nightmare for the AI)
any (on the side) advice would be much apreciated ..;)
G
Last edited by Red Spot; 07-31-2007 at 11:12.
Yeah you can probably check a FactionLeaderTrait on faction turn start (CharacterTurnStart is executed before FactionTurnStart so you can just give it in a trigger or somesuch).
There's no very good way to solve your second problem, the only thing you can do is to use SettlementTurnStart triggers together with the I_SettlementOwner condition
Thank for the reply Alpaca
I've already changed my plans somewhat, based on what I think should be both interesting and possible ..:D
Not to go too much into it I basicly want all Catholic and Islam factions to horde when they lost their last settlement, get killed, and than after some time in a sort of rebel flavour respawn like the Mongols do.
Anyway I made a script for the English wich hopefully does as intended, havent had the time to actually test it yet, but hope you might want to look at it, in particular the resetting of event counter, is that possible?
edit;Code:script declare_counter english_respawn_counter monitor_event FactionTurnStart not FactionIsLocal and FactionType england and FactionwideAncillaryExists actor false ;no English familiy members alive if I_CompareCounter english_respawn_counter == 0 add_events event counter enland_respawn date 10 25 ;timescale 0.5->20/50turns untill respawn end_add_events inc_counter english_respawn_counter 1 ;stop the event from happening each turn without terminating the monitor. end_if end_monitor monitor_event EventCounter EventCounterType england_respawn and EventCounter > 0 ;do the actuall spawning within its own monitor, like campaign script, no its not copied ..... :D if I_EventCounter england_respawn == 1 add_events event emergent_faction english date 0 region London_Province event counter enland_respawn date 1 end_add_events end_if if I_EventCounter england_respawn == 2 spawn_army faction england character William, named character, age 30, x 100, y 150, family traits GoodCommander 2 , BattleDread 4 , StrategyDread 2 , Loyal 2 unit NE Bodyguard exp 2 armour 1 weapon_lvl 1 end ;possibly "need" to spawn general in defined region(this case London) ;make sure to change some ancillary triggers to be handed out on ComingOfAge. inc_counter english_respawn_counter -1 inc_counter english_respawn -2 ;make sure we can do it again later by resetting the counters. end_if end_monitor wait_monitors end_script
dont look at the .. er .. flexibility between "england" and "english" its already changed in the original ... ;)
/edit
edit2;
I've been looking a bit closer at the examples in the main post and see the use of "set_event_counter"
guessing I should use that to change the counter of a campaign map event??
did a search through the docudemon files but they only speak about "set_counter" ....
/edit
G
Last edited by Red Spot; 08-01-2007 at 15:46.
sorry for double posting ...
I've changed the script and incorp your suggestion on factionleader trait
am just a bit confused about the diff. between.
andCode:if I_EventCounter england_respawn_event >= 3 if I_CharacterExists William
anyway the full script;Code:if I_EventCounter england_respawn_event >= 3 and I_CharacterExists William
Code:script declare_counter england_respawn_counter monitor_event FactionTurnStart not FactionIsLocal and FactionType england and FactionLeaderTrait Factionleader >= 1 if I_CompareCounter england_respawn_counter == 0 add_events event counter enland_respawn_event date 10 25 end_add_events set_counter england_respawn_counter 1 end_if end_monitor monitor_event EventCounter EventCounterType england_respawn_event and EventCounter >= 1 ;do the actuall spawning within its own monitor, like campaign script, no its not copied ..... :D if I_EventCounter england_respawn_event == 1 add_events event emergent_faction england date 0 region London_Province event counter enland_respawn_event date 1 end_add_events end_if if I_EventCounter england_respawn_event == 2 spawn_army faction england character William, named character, age 30, x 100, y 150, family traits GoodCommander 2 , BattleDread 4 , StrategyDread 2 , Loyal 2 unit NE Bodyguard exp 2 armour 1 weapon_lvl 1 end ;possibly "need" to spawn general in defined region(this case London). add_events event counter enland_respawn_event date 3 5 end_add_events end_if if I_EventCounter england_respawn_event >= 3 if I_CharacterExists William spawn_army faction england character Robert, named character, age 20, x 100, y 150, family traits GoodCommander 2 , BattleDread 4 , StrategyDread 2 , Loyal 2 unit NE Bodyguard exp 2 armour 1 weapon_lvl 1 end end_if ;possibly "need" to spawn general in defined region(this case London). set_counter england_respawn_counter 0 set_event_counter england_respawn_event 0 end_if end_monitor wait_monitors end_script
G
Hmm, very nice find on the "family" keyword alpaca! I hadn't noticed it when I was looking at the Mongols/Timurids code. But so, how does the game know how to reconstruct the family, since the relations are nowhere specified in the spawning code? Does it look at descr_strat.txt or something?
edit;
removed my query as it was again a matter of my great spelling/english ....
remember that english/england thing I had a few post back, its has become enland/england instead of what it should be england/england ...
edit2;
though in a quick and dirty aproach, I have it running, just had a full spawn cycle as it should, though had to change the FactionTurnStart to an existing faction(scotland in this case) as a dead faction has none.
If you want I can post the finished version heavilly commented ...
/edit
G
Last edited by Red Spot; 08-01-2007 at 22:01.
I pretty much did the script and more, I'll just go and double post again to show it to whoever wants to read it, imo it uses some nice trickery that could be usefull to others ...
it uses some trickerey to figure out if a faction exists or not, basicly it just resets a variable(counter) and sets it when the faction has a turn(and thus exists) and so knows that every faction that did not set the var. does not exist ..
Code:;SET FOLLOWING EVENT IN DESCR_EVENTS TO KICK-START THE RESPAWNING!!! ;faction_respawn_trigger ;Interval set at 40-80 years -> 80-160 turns. ;faction_respawn_event ==> global spawn starter event ;faction_respawn_england ==> per faction spawn event ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; script declare_counter faction_exists_england ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;COPY FOR OTHER FACTIONS!!! monitor_event FactionTurnStart FactionType england and Treasury <= 10000 if I_LocalFaction england terminate_monitor end_if console_command add_money england, 12000 end_monitor ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;COPY FOR OTHER FACTIONS!!! monitor_event FactionTurnStart FactionType england and I_EventCounter faction_respawn_event == 1 set_counter faction_exists_england 1 end_monitor ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;COPY FOR OTHER FACTIONS!!! monitor_event EventCounter EventCounterType faction_respawn_england and EventCounter >= 1 spawn_army faction england character William, named character, age 30, x 100, y 150, family traits GoodCommander 2 , Loyal 2 unit NE Bodyguard exp 2 armour 1 weapon_lvl 1 end spawn_character england Laurence Bidell, diplomat, age 42, x 101, y 150 spawn_character england Richard, spy, age 36, x 99, y 150 end_monitor ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; monitor_event EventCounter EventCounterType faction_respawn_trigger and EventCounter >= 1 add_events event counter faction_respawn_event date 2 end_add_events terminate_monitor end_monitor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; monitor_event EventCounter EventCounterType faction_respawn_event and EventCounter >= 1 if I_EventCounter faction_respawn_event == 1 ;;; ;;;COPY FOR OTHER FACTIONS!!! set_counter faction_exists_england 0 ;;; ;;; add_events event counter faction_respawn_event date 2 end_add_events end_if if I_EventCounter faction_respawn_event == 2 ;;; ;;;COPY FOR OTHER FACTIONS!!! if I_CompareCounter faction_exists_england == 0 add_events event counter faction_respawn_england date 3 25 end_add_events end_if ;;; ;;; set_event_counter faction_respawn_event 0 add_events event counter faction_respawn_event date 38 78 end_add_events end_if end_monitor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; wait_monitors end_script ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
G
Last edited by Red Spot; 08-13-2007 at 15:34.
So if I understood it correctly on a quick glance what you're doing is give england a chance to respawn every 50 years or so if they don't exist?Originally Posted by Red Spot
Wouldn't it be easier to just check "I_FactionLeaderTrait england faction_leader" (or whatever it's called) or "I_FactionLeaderAttribute england authority >= 0" (if they work, I didn't test them)?
In fact, I'd check on the FactionTurnStart of the local faction whether england exists and then do some event counter stuff to give a delayed spawn effect after some years or so - I did not yet work out a decent use for the feature
How would I do that, can I somehow specify a diff. faction within the command;
and FactionLeaderTrait Factionleader >=< #
that was basicly what prevented me doing it the way you just described and find some other way to figure out if a faction I could not get hold of still did exist, basicly using the fact I cant get hold of them for it.
G
didnt know that, it surelly isnt in the docudemon files I have ...
anyway I'll check it out and see if I can clean up the code a bit, thanks again ;)
G
Where do you think I got it without trying it out? It was added in 1.2 so you need the docudemons for that to find it. It could be it doesn't work though, so test it before using it.Originally Posted by Red Spot
Code:--------------------------------------------------- Identifier: I_FactionLeaderTrait Trigger requirements: Parameters: faction type, trait description, logic token, level Sample use: I_FactionLeaderTrait england BadCommander >= 2 Description: Test a factions leader traits Battle or Strat: Either Class: I_FACTION_LEADER_TRAIT_TEST Implemented: Yes Author: ScottL
well I've got the ones linked in this topics main post (double checked) and it surelly isnt in those files ...
I'll do a forum search to see if I can find some newer ..
edit;
ok that was easy enough, the 1.2 docudemon files;
https://forums.totalwar.org/vb/showt...ight=docudemon
https://forums.totalwar.org/vb/showthread.php?t=83119
/edit
edit2;
and a redone version;
/editCode:;SET FOLLOWING EVENT IN DESCR_EVENTS TO START THE RESPAWNING!!! ;;;event counter faction_respawn_trigger ;;;date 1 ;Interval set at 40-80 years -> 80-160 turns. ;faction_respawn_event ==> global spawn starter event ;faction_respawn_england ==> per faction spawn event ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; script ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;the trigger on a seperate event so it can be used in like EDB, kill it once it has done its job! ;;; monitor_event EventCounter EventCounterType faction_respawn_trigger and EventCounter >= 1 add_events event counter faction_respawn_event date 1 end_add_events terminate_monitor end_monitor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;COPY FOR OTHER FACTIONS!!! ;;; monitor_event FactionTurnStart FactionType england and Treasury <= 10000 if I_LocalFaction england terminate_monitor end_if console_command add_money england, 12000 end_monitor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;check after the player did his/her turn, else we could miss out on yet an other victory. ;;; monitor_event FactionTurnEnd FactionIsLocal and I_EventCounter faction_respawn_event >= 1 ;;; ;;;COPY FOR OTHER FACTIONS!!! ;;; if I_FactionLeaderTrait england Factionleader == 0 add_events event counter faction_respawn_england date 3 25 end_add_events end_if ;;; ;;; ;;;reset the counter and call the event again in order to have better control over the spawn-intervals. ;;; set_event_counter faction_respawn_event 0 add_events event counter faction_respawn_event date 38 78 end_add_events end_monitor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;COPY FOR OTHER FACTIONS!!! ;;; monitor_event EventCounter EventCounterType faction_respawn_england and EventCounter >= 1 spawn_army faction england character William, named character, age 30, x 100, y 150, family traits GoodCommander 4 , Loyal 4 , ContentGeneral 3 , BattleChivalry 3 , GoodRiskyAttacker 2 , Fertile 2 unit NE Bodyguard exp 2 armour 1 weapon_lvl 1 end end_monitor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; wait_monitors end_script ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
G
Last edited by Red Spot; 08-16-2007 at 15:32.
dont really know what you like to know so I'll make it a few more lines and leave it up to your cut and paste skills to make it into 2 lines ..;)
first of all it might be interesting to know there is only 1 skill-level at wich I play this game; Very Hard
side-effect is that some factions go bankrupt in a matter of turns on this setting, so I've included a sizeable cheat for the AI factions wich makes having a good econ. more or less a player-feature (AI does not know how nor is able to compete with the player in the area of having a decent econ.)
it is also needed for the respawned factions as I am not willing to add new (dummy) units with no upkeep.
secondly, as just about everyone knows, when you have like 12+ -ish settlements its basicly cat in the bag, you win ...
with respawning factions it means that whoever has slain a faction or at least owns their original settlements has some hard fighting to do every once in while when factions re-appear
I also find it somewhat dissapointing if I'm not at some point encountering certain factions as they have been slain before I actually really come into contact with them, now there will always be the option to face them in battle
the script; the events are dorment, I mean the script by itself does not start anything, it relies on an event in descr_events.
when this event is triggered it will trigger an event in the script that than does a check on destroyed factions the next turn and per destroyed faction calls an event to respawn the faction with a small(-ish) random interval.
at this point though the script keeps itself active, I mean it keeps calling the respawn event every [random x] turns and keeps doing so untill the game is finished, in effect keeping all factions alive though with possible "dead-intervals" :P
on a side note; no use in spawning agents with re-appearing factions as it doesnt really work, if say you have 1 town hall and 1 diplomat and than spawn a diplomat it wont spawn, when you're not at your agent-limit you can spawn one, but as when you dont own any settlements you dont have a town hall you also cant have a diplomat ...
do note; factions need the ability to horde for this to work, wich can be read about in the second post of this topic
G
Bookmarks