User avatar
Christophe.Barot
Posts: 1138
Joined: Fri Jan 26, 2007 10:55 pm
Location: Paris (France)

first script for diplomatic reaction, technical help and tips wanted

Sun Sep 01, 2013 10:52 pm

Hi folks and experienced modders
after long "i'm going to do " and "we should do", I am trying my first script to make AI reactive - was a long project, long study of orders (and i grieve having lost Mac naughton posts on Paradox beta team thread, where Mac naughton gave me unvaluable tips i diond't copy and lost , well )
If we ever want a reactive diplomatic AI, and PON or PON 2 or gold if ever ever become the massive success it deserves, we need powers to evaluate situation and react

so here's my first step, or stone - a basic one : Prussia attacks out of the blue a german state - guardian of german princes integrity, Austria must react : a) evaluate forces b) evaluate alliances c) act - help really wanted about evaluation methods and syntax
- please note we want to take alliances (and if possible support) into account
- please note too that we don't want to rush on Prussia out of the blue - that is a crisis - we first give a warning THEN we enter war if it fails - that is the way it worked in 19th century - at Olmutz and in 1875 Prussia backed down. in Crimean war for principalties and at Andrinople in 1877 war, Russia backed down, after Solferino, France backed down, so we play it the historical way, or try

any other advise and script writing tip (about conditions, dateline, effects, like taking army move rather than just war), loke Mac naughton did once is welcome
if Pocus got the posts about modding from Paradox I couldn't save, that is welcome too ;)

// event about Austria warning prussia not to invade saxony - without complying second event issued where - once set correctly, will have to be duplicated for german nations, ottoman, belgium,
//italian nations, balkan - WE SHOULD SET A CONDITION SO ONLY AI managed countries use this set of orders - event has to be followed by a declaration of war if and only if Germany persists


SelectFaction = $AUS
SelectRegion = $Oesterreich
StartEvent = evt_nam_AUS_warning-about-Saxony|999|1|evt_txt_AUS_warning-about-Saxony|Event-
img_AUS_warning-about-Saxony|$Oesterreich|NULL // I'll have to write thewarning text ("the ambassador of Austria in Berlin solemnly warned the king Prussia that, unless Prussian armies back up and peace is restored soon, her actions against an friend of Austrian will have the direst consequences") plus image


Conditions

EvalEvent = evt_nam_AUS_Compromise1867;=;1 // we have to devise some time limit, obviously once saxony is peacefully annexed, there will be no war so no event, we also assume that Hungarian compromise deflects Austrians from Germany as Hungarians could not care less, and have them concentrate on Balkans, against Russians

SelectFaction = $SAX
EvalIsAtwarWith = GER //condition an invasion of Saxony - Austria does not need to be allied to saxony actually - according to calculations, Saxony is not going to declare war on powerful Prussia

SelectFaction = $AUS
EvalIsAtPeaceWith = FRA
EvalIsAtPeaceWith = RUS
EvalIsAtPeaceWith = GBR
EvalIsAtPeaceWith = GER
Probability = 75 [color="#FF0000"]// can we replace by something more correlated to ratio of land forces and alliances, plus the commitment of Austria to Saxony - warning AI Austria is prone to remain very passive in game, which we must take into account[/color]

EvalAreaPowerRatio = LAND|$Continents_Europe|100|>=|50|25 [color="#FF0000"]// can this sort of things work - we must adapt it - question is to compare prussian and Austrian armies in Europe (fleets are here irrelevant), and if possible add their allies - who could suggest a working comparison and set of conditions - presantly I don't have the syntax to precise the powers involved in the ratio[/color]

to Austria +allies to germany and allies - does the following work ? how do we check areapowerratio or checkpowerratio between powers not yet at war

I found this in the german missions and adapted,seem to compute and compare forces but am not able to write correctly the following, comparing forces of powers and alliances in areas is the basic of any strategic actions by AI powers

SelectFaction = $AUS
RegInit = 1
SelectSubUnits = Area $Continents_Europe;FactionTags AUS;Domains $Land
SelectFaction = $PRU
RegInit = 2
SelectSubUnits = Area $Continents_Europe;FactionTags PRU;Domains $Land
RegInit = 3
RegSum = Registry 2 ;Best 1
RegEval = 1;>=;3
RegDeactivate = NULL


SelectSubUnits = Area $Continents_Europe;FactionTags GER;Domains $Land
EvalSubUnitCount = <;200



Actions

SelectFaction = $CMN
GenTextMsg = AUS_warning-about-Saxony-TEXT;1;NULL;NULL;NULL // text and image about warning to write

SelectFaction = $AUS
ChgFacRelationships = GER;-50
AddDiploItem = GER;$diCBTemp;CURRENT [color="#FF0000"]// in next event we should take into account fact that war was provoked or not, alliances and supports, presently I couldn't[/color]
AddDiploItem = SAX;$diDefensiveTreaty // duplication or to test, and if then must I separate lines with a CheckDiploItem command ?
RemDiploItem = GER;$diDefensiveTreaty // just in case there is one - in this case, Prussian "ally" behaviour is just untolerable
ChangeFacMorale = 10

SelectFaction = $SAX
ChangeFacMorale = 20

SelectFaction = $GER
ChangeFacMorale = -10 // take into account psychology, Austrians are indignant, saxon morale is boosted, prussian weary of complications

SelectFaction = $GBR
EvalDiploItem = GER;$diAllianceTreaty;NOT //Germany is the agressor, other nations approve Austria warning to keep balance and peace, but only if they are not German allied
ChgFacRelationships = AUS;10

SelectFaction = $FRA
EvalDiploItem = GER;$diAllianceTreaty;NOT
ChgFacRelationships = AUS;10

SelectFaction = $RUS
EvalDiploItem = GER;$diAllianceTreaty;NOT // is it a way to devise a choice like the options of aigun treaty or crimean crisis war ?
ChgFacRelationships = AUS;10


SelectFaction = $GER
CheckIsPlayer = NOT
SettleWhitePeace = $GER
SettleWhitePeace = $SAX // we consider AI being cautious, had they wanted a war with Austria, they would have attacked Austria alone, if Austria is weaker than Prussia, Austria won't move
[color="#FF0000"] // I am not sure about the syntax here, do i need to settle white peace for his own german AI faction ? do successive checks work ?

[/color]
SelectFaction = $GER
CheckIsPlayer = NULL
SelectFaction = $SAX
diOfferPeaceDefeat [color="#FF0000"]// automatic sending of white peace proposal to prussia, how does one do, what is the syntax - idea is to condition sending by Germany being a player sme other things to consider in syntax, like a symbolic payment ?[/color]


EndEvent
[color="#FF0000"]- (ordnance) Your Lordship, sorry to awake you, but The french are at our door !

- Alarm, alarm, how did you let this happen and not awake me ! repel them, counterattack at once !

- err, your Lordship, ahem... French are our allies, Marshal de St Arnaud is expected to attend to a conference with you !

- ahem, well, .... very well ..let them in !

(charge of the light brigade movie)
[/color]

User avatar
Christophe.Barot
Posts: 1138
Joined: Fri Jan 26, 2007 10:55 pm
Location: Paris (France)

Sun Sep 01, 2013 11:07 pm

And now If you allow, the war action proposed if Prussia does not comply to the warning :




SelectFaction = $AUS
SelectRegion = $Oesterreich
StartEvent = evt_nam_AUS_war-about-Saxony|999|1|evt_txt_AUS_warning-about-Saxony|Event-
img_AUS_warning-about-Saxony|$Oesterreich|NULL // I'll write war text "in reaction to the blatant Prussian agression agains Saxony, War is declared by Austrian Empire upon Prussia and Austrian forces have been instructed to enter german confederation territory in help for saxony" plus image

Conditions
EvalEvent = evt_nam_AUS_warning-about-Saxony;=;1
EvalIsAtPeaceWith = FRA
EvalIsAtPeaceWith = RUS
EvalIsAtPeaceWith = GBR
EvalIsAtPeaceWith = GER
Probability = 75 [color="#FF0000"]// can we replace by something more correlated to ratio of land forces and alliances, plus the commitment of Austria to Saxony - ditto comment[/color]

// evaluation of strength, must be 1:1

SelectFaction = $SAX
EvalIsAtwarWith = GER; since 3 [color="#FF0000"]//do we have time enough to have Player Germany accept peace from saxony ? is it the correct syntax ?[/color]

Actions
SelectFaction = $AUS
AddDiploItem = GER;$diWar;CURRENT
ChangeFacMorale = -5 // threat failed, it is now time to go but people is less enthusisastic, will be bloody
ChgFacRelationships = GER;-50

// no change for germany as fear of new difficulties and anger at Austrian "betrayal" compensate

SelectFaction = $SAX
ChangeFacMorale = 10 // boost, they REALLY come

SelectFaction = $RUS // other powers check if they are linked to one of the opponents ... or both, and Prussia is the agressor against a little state
EvalDiploItem = GER;$diAllianceTreaty
EvalDiploItem = AUS;$diAllianceTreaty;NOT
ChgFacRelationships = AUS;-50
AddDiploItem = AUS;$diCBTemp;CURRENT

SelectFaction = $FRA
EvalDiploItem = GER;$diAllianceTreaty
EvalDiploItem = AUS;$diAllianceTreaty;NOT
ChgFacRelationships = AUS;-50
AddDiploItem = AUS;$diCBTemp;CURRENT

SelectFaction = $ITA // just in case somebody asked, yes Piedmont/Italy was deliberately disregarded (as USA and Japan) in balance of Austrian calculations - Austria felt they could handle Italy while fighting Prussia - right or wrong - check for Britain is absolutely theorical given their interests, and Gladstone or Disraeli would never have objected Austria defending a german minor, whatever their bonds with Prussia (and if prussia is stupid enough to provoke Austria while at war with France/who else ? so be it for her and serves her well
EvalDiploItem = GER;$diAllianceTreaty
EvalDiploItem = AUS;$diAllianceTreaty;NOT
ChgFacRelationships = AUS;-50
AddDiploItem = AUS;$diCBTemp;CURRENT

EndEvent
[color="#FF0000"]- (ordnance) Your Lordship, sorry to awake you, but The french are at our door !

- Alarm, alarm, how did you let this happen and not awake me ! repel them, counterattack at once !

- err, your Lordship, ahem... French are our allies, Marshal de St Arnaud is expected to attend to a conference with you !

- ahem, well, .... very well ..let them in !

(charge of the light brigade movie)
[/color]

Return to “PON Mods”

Who is online

Users browsing this forum: No registered users and 4 guests