Log in

View Full Version : [Submod]changed AI money assistance script [help/advice needed]



Shadowwalker
09-11-2014, 20:15
So I have been pondering about this quite for some time even before the release of EB II.
My idea has been to adjust the AI money bonus according to the factions' size.

In the following spoilers I'll don't include the whole script changes but only use one faction as an example.

The is how it is currently set by the EB team:


monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
and Treasury < 600
if I_LosingMoney f_rome
increment_kings_purse f_rome 1000
end_if
if not I_LosingMoney f_rome
console_command add_money f_rome, 400
end_if
end_monitor
;;;;;;;;;;;;;;;;;;
monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
and not LosingMoney
and Treasury > 20000
increment_kings_purse f_rome -1000
end_monitor


And this is what I changed it to:


monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
if not I_NumberOfSettlements f_rome > 6
set_kings_purse f_rome 4000
end_if
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;
monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
if I_NumberOfSettlements f_rome > 6
if not I_NumberOfSettlements f_rome > 8
set_kings_purse f_rome 2000
end_if
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
if I_NumberOfSettlements f_rome > 8
set_kings_purse f_rome 0
end_if
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
and Treasury < 600
if I_LosingMoney f_rome
console_command add_money f_rome, 2000
end_if
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;
monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
and not LosingMoney
and Treasury > 20000
console_command add_money f_rome -3000
end_monitor



(1) small factions and factions that haven't grown beyond their starting size +1 province receive a significant bonus (4000 mnai) to their income.
(2) factions that have grown a bit (stating provinces +3) still receive a moderate money bonus (2000 mnai)
(3) larger factions (>starting provinces +3) receive no automatic bonus to their income anymore, unless they are losing money.
(4) the "take away some money from the AI if they have too much" script has been altered a bit, but I didn't change the basic approach there.
(4) the slave faction hasn't been touched because they are actually developing their settlements and recruting nicely, no need to change much there in my opinion.
(5) No changes to the player setting, all the changes are affecting the AI exclusively.

In theory this is meant to provide the following changes:

Small factions (in particular all the 1-province factions) don't start with an immediate debt when AI-controlled.
Growing factions are slowed down a bit.
There is hopefully less chance (or even no chance, can't say for sure yet as the whole thing lacks serious testing so far) for factions who own only 1 or two provinces (Pergamon! Massylia! Lusotannan!) to spam 5 or even 6 stacks without doing anything.

I tested it at least a bit yet, the altered campaign script doesn't crash the game (started 3 games with different factions and hit "end turn" for 20 turns).

I ran into a really odd bug though. My changes seem to have caused the "select potential successor" script ceasing to work. Which is rather mysterious as I didn't touch that script at all. Does any of you have an idea what may have caused this?



I attach the file nevertheless, just in case you want to have a look at it.
I don't recommend using the file yet due to the mentioned bug, though.

Moros
09-12-2014, 00:00
This likely means you've broken the script. After pressing the end trun button toggle the command box and press the up key when in the ablility to type in the box. This way you can see previous console commands even those performed by script, such as the add_money command done by your script. This way you can check for sure whether this is actually working. Have you used Notepad++ to edit the file?

Also shouldn't this:
monitor_event FactionTurnStart FactionType f_rome
and IsFactionAIControlled
if I_NumberOfSettlements f_rome > 6
if not I_NumberOfSettlements f_rome > 8
set_kings_purse f_rome 2000
end_if
end_monitor

Here you don't start with an if, use multiple ifs and only use on end if. I don't know much about MTW2 scripting but this seems like a big no-no, to me.

be:


monitor_event FactionTurnStart FactionType f_rome
if IsFactionAIControlled

and I_NumberOfSettlements f_rome > 6
and not I_NumberOfSettlements f_rome > 8
set_kings_purse f_rome 2000
end_if
end_monitor


Make sure you're structure of coding is always good. One if followed by and's to set multiple conditions that need to be jointly set for following actions. Also not tab spacing. A secondary if and "and sequence" for further specification of certain event with an additionally increased indent (tab) can be set but then you also need an additional end_if. At least this is the way other parts of the script seem to be coded.

Shadowwalker
09-12-2014, 07:22
Here you don't start with an if

I just copied that part from the original EB code, as you can see in the first spoiler, there are parts that don't start with an "if" but an "and" and there are even parts that have no single "if" at all in all their conditions. ~:confused:

Main part of the problem is that I still have little idea what I'm doing, I'm just no programmer/scripter. :shrug:
I just need to read more tutorials, hehe.

Anyway, thanks a lot for the tips, Moros. :2thumbsup: