User avatar
Kensai
Posts: 2702
Joined: Mon Sep 19, 2011 4:54 pm
Location: Freiburg, Germany

Creating a multiple choice event

Wed Dec 25, 2013 12:10 pm

All AGEOD titles provide for decisional events that allow players make (multiple) choices. Vainglory of Nations (PON), as the most complex and elaborate game by AGEOD, obviously allows these facilities. The ideal choice-event should be scripted in a way to allow for the AI to choose according to the best course of action, but let's leave this for a later attempt. Let's focus on writing a simple event that pops up a decision screen for a player.

In this tutorial, I will try to accomplish writing my own decision, as a way to learn how to do this for my Großdeutschland Mod. :)
(bear with me, I don't know yet in all its details)

I will use as an example one of the first decisions you encounter (as Japan), the summoned Daimyo Consultation after the Black Ships of Commodore Perry arrive in the Bay of Tokyo in 1853. In this event the player decides if he wants to take action against the Americans or yield.

Code: Select all

SelectFaction = $JAP
SelectRegion = $Kyoto
StartEvent = evt_nam_JAP_DaimyoConsultation1853_ON|1|1|NULL|NULL|$Kyoto|NULL

Conditions
  EvalEvent = evt_nam_JAP_BlackShipsEdo1853;=;1
  MinDate = 1852/03/01
  MaxDate = 1865/04/18
  Probability = 75

Actions
  DescEvent = evt_desc_CMN_NewDipOption
  ChangeActorPool = $gmaOptionGov;MaxUse;1;MaxChoices;2;ImageID;Contract_ON.png;Title;opt_title_JAP_DaimyoConsultation1853;MsgString;opt_desc_JAP_DaimyoConsultation1853;ToolString;opt_hint_JAP_DaimyoConsultation1853;SubType;JAP_DaimyoConsultation1853;SParam1;JAP;TextChoice1;opt_JAP_DaimyoConsultation1853_desc_Choice1;ToolChoice1;opt_JAP_DaimyoConsultation1853_hint_Choice1;TextChoice2;opt_JAP_DaimyoConsultation1853_desc_Choice2;ToolChoice2;opt_JAP_DaimyoConsultation1853_hint_Choice2;SParam2;Event-img_JAP_DaimyoConsultation1853.png

EndEvent

SelectFaction = $JAP
SelectRegion = $Kyoto
StartEvent = evt_nam_JAP_DaimyoConsultation1853_AIAcitvate|999|0|NULL|NULL|$Kyoto|NULL

Conditions
  ActorEnabled = $gmaOptionGov;JAP_DaimyoConsultation1853

CheckAILevel = 1

Actions
  DescEvent = evt_desc_CMN_NewDipOption
  ChangeOption = $gmaOptionGov;JAP_DaimyoConsultation1853;1

EndEvent

SelectFaction = $JAP
StartEvent = evt_nam_JAP_DaimyoConsultation1853_Deprecate|1|1|NULL|NULL|NULL|NULL

Conditions
  MinDate = 1865/04/18
  ActorEnabled = $gmaOptionGov;JAP_DaimyoConsultation1853

Actions
  DescEvent = evt_desc_CMN_DipOptionCancelled
  ChangeActorPool = $gmaOptionGov;MaxUse;0;SubType;JAP_DaimyoConsultation1853
  ChgVPCount = -100
  ChangeFacMorale = -5
  ChangeLoyaltyFac = $Theater_Japan;-25

SelectFaction = $REB
  ChangeLoyaltyFac = $Theater_Japan;25

EndEvent

SelectFaction = $JAP

SelectFaction = $JAP
StartEvent = evt_nam_JAP_DaimyoConsultation1853_Choice1|1|0|NULL|NULL|NULL|NULL

Conditions
  MinDate = 1852/03/01
  MaxDate = 1865/04/18
  ActorEnabled = $gmaOptionGov;JAP_DaimyoConsultation1853
  CheckOption = $gmaOptionGov;JAP_DaimyoConsultation1853;=;1

Actions
  GenTextMsg  = opt_notify_JAP_DaimyoConsultation1853_Choice1;1;NULL;NULL;NULL
  ChangeActorPool = $gmaOptionGov;MaxUse;0;SubType;JAP_DaimyoConsultation1853

EndEvent

SelectFaction = $JAP
StartEvent = evt_nam_JAP_DaimyoConsultation1853_Choice2|1|0|NULL|NULL|NULL|NULL

Conditions
  MinDate = 1852/03/01
  MaxDate = 1865/04/18
  ActorEnabled = $gmaOptionGov;JAP_DaimyoConsultation1853
  CheckOption = $gmaOptionGov;JAP_DaimyoConsultation1853;=;2

Actions
  ChgFacRelationships = USA;-10
  ChgFacRelationships = GBR;-10
  ChgFacRelationships = FRA;-10
  ChgFacRelationships = RUS;-10
  ChgFacRelationships = HOL;-10
  ChgVPCount = 100

SelectFaction = $FRA
  GenTextMsg  = opt_notify_JAP_DaimyoConsultation1853_Choice2;1;NULL;NULL;NULL
  ChangeActorPool = $gmaOptionGov;MaxUse;0;SubType;JAP_DaimyoConsultation1853

EndEvent

SelectFaction = $JAP
SelectRegion = $Edo

SelectFaction = $JAP
SelectRegion = $Edo
StartEvent = evt_nam_JAP_DaimyoConsultation1853_A|1|2|evt_txt_JAP_DaimyoConsultation1853|Event-img_JAP_DaimyoConsultation1853|$Edo|NULL

Conditions
  MinDate = 1852/03/01
  MaxDate = 1863/08/01
  EvalEvent = evt_nam_JAP_DaimyoConsultation1853_Choice1;=;1

Actions
  DescEvent = evt_desc_JAP_DaimyoConsultation1853
  ChangeFacMorale = -2

  CreateStruc
  SetType = $Fort
  SetLevel = 1
  SetName = Edo Fortifications
  Apply

SelectFaction = $JAP
SelectRegion = $Edo
  CreateGroup
  Posture = $Defensive
  SetKind = $Land
  Entranch = 4
  InCS = 1
  FixType = 999
  SetName = Edo Batteries
  Apply
  CreateUnit
  SetType = $uni_JAP_Art_1840CA
  NumCreate = 1
  SUFlavorName = Edo Battery
  SetLevel = 4
  SetName = Edo Defenses
  Apply
  CreateUnit
  SetType = $uni_JAP_Inf1840_Feudal
  NumCreate = 1
  SUFlavorName = Batteries Garrison
  SetLevel = 4
  SetName = Batteries Garrison
  Apply
  ChgFacRelationships = USA;10
  ChgFacRelationships = GBR;10
  ChgFacRelationships = FRA;10
  ChgFacRelationships = RUS;10
  ChgFacRelationships = HOL;10
  SetEvtOccurs = evt_nam_JAP_DaimyoConsultation1853_B;MaxOccurs;0

EndEvent

SelectFaction = $JAP
SelectRegion = $Edo
StartEvent = evt_nam_JAP_DaimyoConsultation1853_B|1|2|evt_txt_JAP_DaimyoConsultation1853|Event-img_JAP_DaimyoConsultation1853|$Edo|NULL

Conditions
  MinDate = 1852/03/01
  MaxDate = 1863/08/01
  EvalEvent = evt_nam_JAP_DaimyoConsultation1853_Choice2;=;1

Actions
  DescEvent = evt_desc_JAP_DaimyoConsultation1853
  ChangeFacMorale = 5

  CreateStruc
  SetType = $Fort
  SetLevel = 1
  SetName = Edo Fortifications
  Apply

SelectFaction = $JAP
SelectRegion = $Edo
  CreateGroup
  Posture = $Defensive
  SetKind = $Land
  Entranch = 4
  InCS = 1
  FixType = 999
  SetName = Edo Batteries
  Apply
  CreateUnit
  SetType = $uni_JAP_Art_1840CA
  NumCreate = 1
  SUFlavorName = Edo Battery
  SetLevel = 4
  SetName = Edo Defenses
  Apply
  CreateUnit
  SetType = $uni_JAP_Inf1840_Feudal
  NumCreate = 1
  SUFlavorName = Batteries Garrison
  SetLevel = 4
  SetName = Batteries Garrison
  Apply
  ChangeLoyaltyFac = $Theater_Japan;25

SelectFaction = $REB
  ChangeLoyaltyFac = $Theater_Japan;-25

SelectFaction = $JAP
  ChgFacRelationships = USA;-10
  ChgFacRelationships = GBR;-10
  ChgFacRelationships = FRA;-10
  ChgFacRelationships = RUS;-10
  ChgFacRelationships = HOL;-10
  SetEvtOccurs = evt_nam_JAP_DaimyoConsultation1853_A;MaxOccurs;0

EndEvent
Care to unify Germany as Austria? Recreate the Holy Roman Empire of the 20th Century:
Großdeutschland Mod
Are you tough enough to impersonate the Shogun and defy the Westerners? Prove it:
Shogun Defiance Mod (completed AAR)

User avatar
Kensai
Posts: 2702
Joined: Mon Sep 19, 2011 4:54 pm
Location: Freiburg, Germany

Wed Dec 25, 2013 12:26 pm

Some screenshots (those with acute historical observation capabilities will notice this is not the right Shogun, normal if you consider that I made the events run ahead of their time). When the event fires you get a note (in black letters, not red) that the "Daimyo Consultation" has started. This adds in the F1 screen a response button:

Image

If you click the above button you get a screen that asks for the decision the player takes. Will you accept or deny the demands of the Americans? Tiny tooltips also suggest the effects. Essentially, according to the decision, the game fires two different events (potentially more if there were more clickable answers). This is how decisions work, in a nutshell.

Image

Image

More to come, later. Merry Christmas to all of you! :hat:
Care to unify Germany as Austria? Recreate the Holy Roman Empire of the 20th Century:

Großdeutschland Mod

Are you tough enough to impersonate the Shogun and defy the Westerners? Prove it:

Shogun Defiance Mod (completed AAR)

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

Thu Dec 26, 2013 1:13 pm

thank you Kensai, couldn't happen at better time, I'm precisely trying to transform event crisis of principalties in a multiple choice for Russian player
- either he backs down, letting Principalties - AND Dobrudja- to Austrian occupation - letting down any reasonable possibilities of drive to Constantinople through Balkans for the duration of Crimean war (I'll remove the Austrian occupation at the formation of RRumania event, and let them keep Dobrudja ahead of time if Russia backs down - in game terms who needs Wallachia or Moldavia to get to Constantinople, marshes are not THAT unpassable)

- or he takes risk having Austria moving against him

will have to tinker with Paris congress too, awaiting for rules opening or closing straits ... at least Black sea fleet may be scuttled would Allies win heavily

then will have to think about how to have countries recover quicker for war losses ( affets balance, Risorgiomento, but not only, Mac Naughtion module ?)

merry Christmas to you too :)
[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
Kensai
Posts: 2702
Joined: Mon Sep 19, 2011 4:54 pm
Location: Freiburg, Germany

Thu Dec 26, 2013 4:48 pm

Good times. Now, let's analyze event-by-event what happens in a decisional scripted chain of events.

Code: Select all

SelectFaction = $JAP
SelectRegion = $Kyoto
StartEvent = evt_nam_JAP_DaimyoConsultation1853_ON|1|1|NULL|NULL|$Kyoto|NULL

Conditions
  EvalEvent = evt_nam_JAP_BlackShipsEdo1853;=;1
  MinDate = 1852/03/01
  MaxDate = 1865/04/18
  Probability = 75


The event fires only if the Black Ships appear in the Bay of Ise between 1852 and 1865, with a probability of 75% per turn, ie almost certain it will run in the first few months. The Black Ships appear in two ways, but this is not covered in this event chain. If the USA is played by a human, he has to move the ships from elsewhere to the port of Tokyo, if it is played by the AI, there is an event that spawns Perry's flotilla there. In any case, the Black Ships event fires when its prerequisites are met, and these are: some ships in the Bay of Ise sea region.

Code: Select all

Actions
  DescEvent = evt_desc_CMN_NewDipOption
  ChangeActorPool = $gmaOptionGov;MaxUse;1;MaxChoices;2;ImageID;Contract_ON.png;Title;opt_title_JAP_DaimyoConsultation1853;MsgString;opt_desc_JAP_DaimyoConsultation1853;ToolString;opt_hint_JAP_DaimyoConsultation1853;SubType;JAP_DaimyoConsultation1853;SParam1;JAP;TextChoice1;opt_JAP_DaimyoConsultation1853_desc_Choice1;ToolChoice1;opt_JAP_DaimyoConsultation1853_hint_Choice1;TextChoice2;opt_JAP_DaimyoConsultation1853_desc_Choice2;ToolChoice2;opt_JAP_DaimyoConsultation1853_hint_Choice2;SParam2;Event-img_JAP_DaimyoConsultation1853.png

EndEvent


Here you can see a description of the event and then the setting of the decisions parameters. Line by line this means:

$gmaOptionGov the decisional button will appear in the F1 screen (it could also appear in the trade, colonial, etc)
MaxUse;1 the max number of possible uses (in this case it is a unique historical decision, so it should appear once)
MaxChoices;2 the max number of potential choices (I have seen up to 4 fitting in the decision screen, maybe more possible)
ImageID;Contract_ON.png the button icon will be that of a contract (others are possible, you can imagine where these are drawn from)
Title, MsgString, ToolString, SubType are strings to give information regarding the event when you mouse over
SParam1, TextChoice1, ToolChoice1 is done for each of the answers

Remember that the strings that describe the event go to the spreadsheet file in the Settings folder that holds all descriptions and events for the game.

What I will do next is to give a practical example of this for my mod. What I want is to give a decisional event that fires when Austria (after it has formed the Catholic Southern German Federation) defeats Prussia and occupies its capital. Instead of simply annexing the kitchen sink, it should fire a decision where the player decides one of the four possible endings:

  1. form a huge Germany (annexing Prussia, keeping the Eastern non-German provinces)
  2. form a nationalistic Germany (annexing Prussia, abandoning the Eastern non-German provinces)
  3. form a Habsburgian Germany (isolating Prussia, keeping the Eastern non-German provinces)
  4. form a stricter German Confederation (isolating Prussia, abandoning the Eastern non-German provinces)


As you can imagine, instead of firing the annexation actions in the end of the Austro-Prussian war, one has to write a decisional event with four different exit scenarios and the necessary challenges it should face. In my tests, the (1) option gives for a very powerful Germanic nation that almost wins the game before the end of the 19th century. To balance it, I have to insert some instability factors and rivalries.
Care to unify Germany as Austria? Recreate the Holy Roman Empire of the 20th Century:

Großdeutschland Mod

Are you tough enough to impersonate the Shogun and defy the Westerners? Prove it:

Shogun Defiance Mod (completed AAR)

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

Mon Dec 30, 2013 6:59 pm

Kensai wrote:
Here you can see a description of the event and then the setting of the decisions parameters. Line by line this means:

$gmaOptionGov the decisional button will appear in the F1 screen (it could also appear in the trade, colonial, etc)
MaxUse;1 the max number of possible uses (in this case it is a unique historical decision, so it should appear once)
MaxChoices;2 the max number of potential choices (I have seen up to 4 fitting in the decision screen, maybe more possible)
ImageID;Contract_ON.png the button icon will be that of a contract (others are possible, you can imagine where these are drawn from)
Title, MsgString, ToolString, SubType are strings to give information regarding the event when you mouse over
SParam1, TextChoice1, ToolChoice1 is done for each of the answers

Remember that the strings that describe the event go to the spreadsheet file in the Settings folder that holds all descriptions and events for the game.



how does one obtain the csv strings from the excel LocalStrings_vgn49q.xls ? Kensai (guess we have to add our texts there) - we just save the file under (csv separation ; ), replace present one (backuping it by caution) and that is enough ?
so problem is just that we can not check the csv then (too big to open in entirety), but can checkproof the excel before ...
[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
Kensai
Posts: 2702
Joined: Mon Sep 19, 2011 4:54 pm
Location: Freiburg, Germany

Thu Jan 02, 2014 5:38 pm

I open the LocalStrings file in a spreadsheet program (Excel, etc) and do all the work manually. It's a lot of work and one has to be careful copying-pasting and changing around, but I like working close to the metal, so to speak. ;)

I created the event for Austria's decision. Instead of uniting the Northern lands once victorious against Prussia, the Austrian player will have the decision to see what to do with the rest of the Germans. I have not linked the event yet, nor populated all the strings, but it is going to the right direction. I will post all code once done. Do not worry about the image size and the dialogs, they are all up to change. If you have suggestions on what should be written, describe it in the mod's specialized thread.

Image

Image
Care to unify Germany as Austria? Recreate the Holy Roman Empire of the 20th Century:

Großdeutschland Mod

Are you tough enough to impersonate the Shogun and defy the Westerners? Prove it:

Shogun Defiance Mod (completed AAR)

Return to “Pride of Nations”

Who is online

Users browsing this forum: No registered users and 8 guests