Page 1 of 1

How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:00 pm
by GaryChildress
I have a random map scenario with 3 regimes. I'm creating it just for my own entertainment but will be happy to release it if anyone is interested. I'd like to set it up where all players are at peace for the first 10 or so turns (or alternatively until a specific date) and then after that point all AI players will declare war on each other and the human player. That would give me a specific number of turns to prepare before all hell breaks loose. I don't want the AI to be "sleeping" during that time but rather it would be building and preparing for attack.

Is there a way to set this up in the editor? I'm not very familiar with how the "Events" screen works but I could probably figure it out with a few pointers (if it's not too complicated that is).

Thanks for any help!

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:09 pm
by ernieschwitz
Yes, I think this is doable.

If you want I could possibly code this for you. Just send me a pm, to get my email, and send me the scenario :)

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:19 pm
by GaryChildress
ORIGINAL: ernieschwitz

Yes, I think this is doable.

If you want I could possibly code this for you. Just send me a pm, to get my email, and send me the scenario :)

Great! Much thanks. PM on the way.

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:23 pm
by Tac2i
If don't mind, explain how you did it.

thanks,
ORIGINAL: ernieschwitz

Yes, I think this is doable.

If you want I could possibly code this for you. Just send me a pm, to get my email, and send me the scenario :)

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:29 pm
by ernieschwitz
I will, of course, I just work better with things in my hands :)

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:34 pm
by GaryChildress
Yes! Feel free to post the code in this thread if you want. Or maybe someone could put together a special "Coding" thread that could be stickied?

Many thanks again! [:)]

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:56 pm
by ernieschwitz
Ok, this is a three step process.

Step 1: Make all the regimes in the scenario (3 in this case) DipBlock True. This will prevent the declaration of war, alliances etc.

Here is a screenshot, taken in the Reg menu of the editor.

Image

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 4:59 pm
by ernieschwitz
Step 2:

Remove the rulevar that makes the AI declare war when it feels like it.

This step may be not needed, but I like to dot all the I´s and cross all the T´s. Also, you here have a chance to see some of the mechanics of the AI. If you want a more aggressive (war declaring) AI for instance, you could set this rulevar to a higher value.

I set it to 0. So it is diabled.


Image

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 5:12 pm
by ernieschwitz
Step 3:

Probably the most feared step. Actually making some code.

I have tried to explain what I do in the following with Green lines of explanatory text. If its complete gibberish to you, then ask me, and I will try to explain. But basically, this is what I do.

I set the event to be a Round Event, which means it will only be checked at the start of a round. (always remember, you take your turn in each round, if you remember that, then what is a round check and a turn check won´t confuse you.)

The first line of code I do checks which round it is. If it is the 10th round, then the code springs into action. If not, nothing happens. (Because everything is indented below it, it is all part of the check. You might read the line as IF round = 10, then do the indented stuff).

I then make a LOOPER, which is basically a way to do something over and over, just increasing the iteration of it once each time, until it reaches the end point (end point included). In this case it is a looper that starts at 0, and ends at CheckRegimeCount. That last piece of code is just saying to the computer, all the regimes are included.

So what do i do. I change the DipBlock status of the regimes in qusetion (all of them) to being not blocked any more. So now people can declare wars, enter alliances, go to peace, and what not.

Then i tell the computer (or event executioner if you will) that I wish to end the loop here. So it will only loop through those commands below the indention, until it reaches the End Looper.

Them comes the messy part of the code. And by that i mean i could have done it so that it could be replicated in a 4 player, 5 player or so on game. I did not.

Instead I wrote three lines of code, with all the possible combinations of wars that could be done. I changed the relationships of each regime to be at war with all other regimes. First regime 0 with 1, then regime 0 with 2 and then regime 1 with 2. All regimes are now at war.

If there had been more regimes, there would be more lines.

For instance, 5 regimes would be.

0 and 1
0 and 2
0 and 3
0 and 4
1 and 2
1 and 3
1 and 4
2 and 3
2 and 4
3 and 4

So you can see this method is quick to code for few regimes but obviously could be made better with some nifty coding (which I wasn´t in the mood for).

In any case, having done what is needed, in round 10, I now end the event code with a EndCheck, and the code is done.

Save the scenario, and test :)

Image

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 5:18 pm
by GaryChildress
Remarkable! Sheer genius! [&o][&o]
 
Much thanks again!

RE: How do you create a war declaration event?

Posted: Mon Jun 01, 2015 10:27 pm
by E6Jarhead
Gary, I too have wanted to be able to do this! Ernie, thanks for posting.

I think we should all start posting snippets of code on here so we can all copy and learn and incorporate.

Ive got quite a few simple ones that someone may be able to use. I'll start posting.