Okay, normally you should write any consequences from an event into the corresponding function.
Since your SpainJoinsWar event is a direct consequence of the Italian DOW it would belong to the DOWitaly function, no need for a new SpainJoinsWar function.
Problem here: there is no
specific function for Italian declaration of war, it is part of the standard DOW event function, so you must insert your stuff there.
Open events.lua then goto function:
Code: Select all
function StandardDOW(attacker, defender)
this is the function that defines what special stuff is happening when nations reach either 0 or 100 alignment value. This is different from the events that define what happens when a nation is attacked by another nation but for your event it does not matter how Italy got to join the war.
Insert into that function what you need, for example:
Code: Select all
local italy = game:GetFactionById(8)
if GetEvent("DOWitaly") == game.turn then
SetEvent("SpainJoinsWar", game.turn)
end
if GetEvent("SpainJoinsWar") >0
and GetEvent("SpainJoinsWar") +2 == game.turn then
if italy.alliance.id == 2 then
local luck = math.random(1,6)
if luck <= 3 then
SetFactionAlignment(15, 100)
SetEvent("SpainJoinsWar", game.turn)
elseif luck == 6 then
SetFactionAlignment(15, 0)
SetEvent("SpainJoinsWar", game.turn)
end
end
end
This will trigger the event picture for Spanish War declaration on the turn Italy joins the war, in this case pro-CP (note that the text for the Italy DOW event is not referring to what side Italy actually joined!)
2 turns later the dice will be rolled with the chances you defined (50% join Entente, 16,6% join CP).
Don't forget to provide a picture for the event with proper size (414x348 pixels) in PNG format and edit the english.txt file to provide title and text for the event.
Code: Select all
event_SpainJoinsWar_title = Ay, ay, ay, no es bueno!
event_SpainJoinsWar_descr = insert text here
If you forget to provide a picture or text (or get the syntax wrong in english.txt) the game will not start anymore without giving an error message in the logfile!
See ya.