The number is for how many turns the effect is applied. -1 equals infinite.
The number is for how many turns the effect is applied. -1 equals infinite.
Thanks, I think the errors must be in my tables then. Back to the tutorial!
~ Too soon old, too late smart ~
Anyone know if it is even possible to script treaties after start turn or after so many turns? I was thinking of 3 instances were I might use this type of script. 1. turning Cimmeria into a client kingdom of Pontus around probably 200 BC like it was historically at first. 2. Creating a confederacy or a similar function(defensive alliance and military access pact) between Gaul(Averni, Pictones, Namnetes, Carnutes) around 120 BC for Caesar's invasion. 3. Another "confederacy/ similar function for Germania around 25 BC.
Looks like it mess up the format just pasting it from my program...
Actually I'd rather it not be based on turn number but only if they come into contact with one another. So I think this would be the layout. You think either is possible? I noticed that there is a lua function to force_make_vassal could even go with that being vassals of arverni instead of the confederation, i'd just change up the satrapy text. I could even go with a military alliance between all of them. I just want them united in some way to make Gaul alot harder to take. If this can work I'd definitely also make this for some of the German factions.
PHP Code:
local gaul = false
function Gallic Confederation if arverni and rome faction_exist and arverni are not human and are visible/in contact to each other
(set variable gaul to true) Else continue to check each turnend
function confederationif gaul = true
namnetes force_make_confederation/force_diplomcy condefederation with arverni pictones force_make_confederation/force_diplomcy condefederation with arverni carnutes force_make_confederation/force_diplomcy condefederation with arverni arverni treasury_mod 10,000 per turnend
hi poacher
Some of what you want to do is possible but I dont think there is a way to force confederacy. Do you own Caesar in Gaul? There is script there that changes the AI's stance towards themselves and towards a mutual enemy to kind of produce what you want. In the end, it is better to copy what has been done before but you can try to do it in a new way
the CiG script uses this
scripting.game_interface:cai_strategic_stance_manager_promote_specified_stance_towards_target_faction(value:name(), nearby_factions_dislike_target[i]:name(), "CAI_STRATEGIC_STANCE_FRIENDLY")
and this
scripting.game_interface:cai_strategic_stance_manager_promote_specified_stance_towards_target_faction(nearby_factions_dislike_target[i]:name(), target_faction:name(), "CAI_STRATEGIC_STANCE_BITTER_ENEMIES")
Otherwise you can force_diplomacy an alliance
You need to look at the following pages:
Mitch has listed the currently active Lua commands here http://www.twcenter.net/forums/showt...functions-list
This Napoleon page has some of the arguments you need for force diplomacy http://www.twcenter.net/forums/showt...pting-Commands
I find the shogun 2 script o rama a fantastic resource http://www.twcenter.net/forums/showt...-Script-o-Rama
Last edited by Col.KanKrusha; February 28, 2015 at 07:42 PM.
~ Too soon old, too late smart ~
Thanks a lot. I'm definitely about to attempt it.
Have you scripted with Lua before? I am not sure from looking at what you have written. If you have not then be warned, it can be very frustrating finding why code doesn't work (usually a very hard to spot typo)
edit- if you haven't get a program called Scite for Lua (Google). It will check your code for errors
Last edited by Col.KanKrusha; March 01, 2015 at 11:50 AM.
~ Too soon old, too late smart ~
Okay, my turn. This does not work - cant see why (sigh). It is pasted in at the bottom of my scripting.lua
I originally was trying to do an Iceni-carthage-rhodes-pergamon trade route but then I wondered if it didnt work because of fog of war. above still does not workCode:local function kk_helpcarthage(context) if conditions.FactionIsLocal(context) and conditions.TurnNumber (context) == 1 then scripting.game_interface:force_make_trade_agreement ("rom_carthage", "rom_rome") scripting.game_interface:force_make_trade_agreement ("rom_carthage", "rom_etruscan") scripting.game_interface:force_make_trade_agreement ("rom_carthage", "rom_epirus") end end scripting.AddEventCallBack("FactionTurnStart", kk_helpcarthage)
Last edited by Col.KanKrusha; March 22, 2015 at 02:45 AM.
~ Too soon old, too late smart ~
Hi, Kankrusha. I think maybe you miss ";" at the end of these commonds. Otherwise you can try the commonds like this "cm:force_make_trade_agreement ("rom_carthage", "rom_rome");".I'm not sure and I haven't played it for a while so I couldn't test it for you now but more advice for you from me is that using the existing scripts as many as possible and try finding them in the other *.lua, official or mod it doesn't matter. Sometimes it's very hard to create new commonds for us self-taught.
Has anyone a good idea on how we could determine if the current season is for example "summer" in a 4 turns per year campaign ?
We know:
Spring = turn number 1
Summer = turn number 2
Autumn = turn number 3
Winter = turn number 4
currently I am using this:
WIP example
any better ideas ?
Use the season function from the model interface.
scripting.game_interface:model():season()
oh ....![]()
Thank you !
edit
interesting:
scripting.game_interface:model():season()
returns integer
1 for Summer
2 for Autumn
3 for Winter
0 for Spring
Last edited by Litharion; June 08, 2015 at 10:45 AM.
Anyone know if its possible to script a name change? For example, having rom_parthia's name set to "Parni" in the text files. Then, if they ever take control of the other 3 regions in Parthia, the script changes their name to "Arsacid Empire". Would something like this be possible?
Hello, I would like to create a Defense script similar to ones of Hannibal at Gates DLC, thats kind of scripted garrisons. At the lone difference the script should be enabled not matter if the attackers/defenders are humans or AI and not matter if they're a minor or major faction.
I've duplicated a fragment and changed locations and units, but I guess this do not work because of the function Spawn_Minor_Faction_Defenses(). Advice in the script says these scripts only apply when a minor faction human attack Rome AI or Carthage AI: "-- This script spawns and manages defenders in Carthage and Rome if the player plays as one of the minor factions, to prevent them rolling over the big cities too easily"
The function Spawn_Minor_Faction_Defenses() will work, if you call it on campaign start for example. Take a look at main_punic/factions/pun_arevaci.lua
function faction_each_sp_game_startup()
output("faction_each_sp_game_startup() called");
-- put stuff here to be initialised each time a singleplayer game loads
Start_Minor_Faction_Defenses();
end;
In HatG the function is called for the faction you play, if it is a minor one the script starts. The function itself does not contain any restrains.
This is probably only possible, if you change the UI elements containing the faction name, pretty complicated.
something like this
UIComponent(COMPOMENT containing the name):SetStateText(NEW name);
but you would need to to it for all Components containing the name...
Hi all,
Anyone knows the correct parameters for " force_rebellion_in_region " or "set_event_generation_enabled" in GAME interface?
I mean if for "force_declare_war" the correct syntax would be (as an example) : scripting.game_interface:force_declare_war ("rom_carthage", "rom_rome")
How we should syntax the above commands?
Thanks in advance for any answer.
Cheers.
EDIT
1) I found a workaround for the first.You can give a low PO for a region with "set_public_order_of_province_for_region" and the rebellion happens as a result in the next turn.
2)I think the "set_event_generation_enabled" does not enable a desired event.I think it only enables event generation.What i would really like is a way to force an event happening.You think ForceEvent in FACTION_LIST_SCRIPT_INTERFACE does that? and how?
thanks.
Hi,
has someone any experiences with the create_agent function and its parameters? I've written this in order to get a debug spy in Sicily, so I can check out how AI recruits and composes its armies:
If this works, I intend to set his actionpoints to unlimited, so I have a really universal "tool" for observation of AI behaviourCode:local function createDebugSpy(context) local player_faction = context.string; if context:faction():is_human()==true then scripting.game_interface:create_agent(player_faction, "Spy", "rom_lilybaion",X-Koordinate,Y-Koordinate,true)--Schreibweise überprüfen von Lilybaion, Spy, Koordinaten einsetzen end --end if end --end function scripting.AddEventCallBack("FactionTurnStart", createDebugSpy);
PS: please note that I just trew this together during my lunch break without access to my game files. So maybe there are some typos in it, my condern is mainly the general functionality of the script.
Last edited by Fridericus Secundus; November 20, 2015 at 05:09 AM.