Making Partisans: A sample event

Discuss and post your mods and scenarios here for others to download.

Moderator: Vic

User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

Making Partisans: A sample event

Post by ernieschwitz »

This thread is meant as a sample thread of how you make Partisans appear with a 5% chance in each hex that was yours at the start of the game. It will hopefully help designers and coders in the future on how to code events.

Bare with me if this is too simple for you. Just read the pictures and you will get it. If however this is not the case, please read the accompanying text.
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Every code starts off with some preparation. In this case I have chosen a standard random game to work this event into. It could go into any scenario, in theory. Maybe it would need some modifications, but this works.

First you need to remove the masterfile. This is a normal procedure in scenarios that require a master file. A masterfile is a file that is used on scenarios that follow the same rules as other scenarios, in the same series. In this case it was default.at2

Here is how you do it. You click the blue arrow (marked in the picture) in the Setng menu. When it prompts you to enter a masterfile, press cancel. You have now disabled the Masterfile. This will allow us to edit some things we might otherwise be barred from.



Image
Attachments
A001Remov..sterfile.jpg
A001Remov..sterfile.jpg (125.29 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

The 2nd step in our preparations is to make a predefined unit. In the editor this is called a PreDef Unit. To make it you need to go to the Units menu in the editor. Here you select the + sign where it says Add PreDef Unit.

Image
Attachments
A003Unit..nPreDef.jpg
A003Unit..nPreDef.jpg (82.66 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Once we've done that, we can now begin making our PreDef Unit. First we give it a name (on the Picture where it says 1). We choose to call it Soviet Partisans, but any name can be chosen, and we can even rename it in the event that we will make. In other words it is just a good way to identify it, should we need to edit it later.

Once we've named it, it is time to find out what kind of SFT(s) we want in the unit (we could have up to 8 subformations (SFT = SubFormationType)). We will set it to be 10 rifle and give them 10 xp. See (2).

Finally we take a piece of paper, or open a notepad document, or similar, and type down the number of the PreDef unit. (see 3 in the picture) In this case it is 5.

Image
Attachments
A004Make..DefUnit.jpg
A004Make..DefUnit.jpg (109.1 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

More preparation time. Go into Setng, and then select the Group Names under property sheets. (See 1 on the picture). Here we locate AreaSlot 3 (not 0 as the picture says.) The reason why it is AreaSlot 3, is because it was vacant, and didn't have anything else in it. AreaSlot 0, 1 and 2, all had marked up different things (Mines and Oil, cities, etc.) so they could not be used. Once you have selected AreaSlot 3 (shown on the picture as 2), you may have to scroll a bit to find it.

Select the String button (shown as 3 in the picture) and then change the name to Original Owner. If someone (Vic) had done the same for his AreaSlots I would not have made the mistake of thinking they were empty. So always remember to name stuff appropriately.

Image
Attachments
A005NameAreaSlot.jpg
A005NameAreaSlot.jpg (166.22 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

When you have done that, Go to the map portion of the editor. Here you will find the button Pick Draw Type. (see 1) Normally you would use it to draw landscapes on the map. But that is not what we are going to do. Instead we are going to be painting Slots. Select Slots from the drop down menu (Called "What?"), as shown in (2).

Then pick the AreaSlot that says Original Owner (the one we just named) in (3). Remember we are using AreaSlot 3 not AreaSlot 0.. Then select the value 1 (shown in 4), and then click OK.

Image
Attachments
A006Paint..election.jpg
A006Paint..election.jpg (182.32 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

What you will see now is a map, that has a lot of numbers on it. These are the individual hexes that have been assigned to that value. In this case every hex has the Value 0. Now if we don't like to code, and we like to spend all evening on something, we could paint this entire map, with 1s where the regime 1 is located... and 0s where the regime 0 is located... but we are in a hurry, so we won't do that.

(Regime 0 is the nation that gets the first turn, Regime 1 is the nation that gets the 2nd turn etc.)

Image
Attachments
A007Paint..eaSlot3.jpg
A007Paint..eaSlot3.jpg (157.96 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

So now we wander into the event section of the editor. It's not a scary place, I promise.

First we scrool through the events that we see, and decide to select the number 50. Not because it is of any importance which number we select, except for one thing, Events are run in the order they are written. So event 50 comes before 51, if they are set to be Run at the same time.

So we select our event 50 as shown in (1).

Then we name the event as shown in (2). In this case we call it Set Partisan AreaSlot, cause that is what we want to do with it. We want to draw the AreaSlot that is related to partisans.

Then we add a few lines by pressing the + icon as shown in (3).

Image
Attachments
A008Codin..tingMap.jpg
A008Codin..tingMap.jpg (87.63 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

We also notice that at the bottom of the editor there are a few boxes. These boxes are the commands you can use in each line.

They are Check, which is related to End Check. Basically this is IF the condition checked is true, then do whatever is between this and End Check.

There is also a Looper and an End Looper, also related. This is a LOOP structure. It will go through the numbers in the values put into it, and then end, when reaching the final one. The increment of each value is always 1.

Then there is SetVar, which ASSIGNS a value to a variable. For instance TempVar10 can be set to 0. TempVar10 = 0 would be the code for this.

We then come to the Comment command, which is a place you can write a comment as a line, to remember yourself or others what you are doing. Useful when coming back to some code you have not written in decades.

And Finally there is the EXEC command. This is used to make things happen. It could be anything, however they are usually related to other parts of the editor. Keep this in mind. Knowing the editor in all other menus, will help you make better code.

Image
Attachments
A007aCodi..Commands.jpg
A007aCodi..Commands.jpg (16.16 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Right, time for some coding.

We are trying to make an AreaSlot map that has the values of the original owner of the hex, as its value. This will make sure we can use that, when we want to find out if a hex has been conquered.

So... first we decide that we want to look through all the hexes on the map. We do this by making two loopers. The first looper is running through the map's X-coordinates (that is the width coordinates), and the second looper is running through the map's Y-coordinates. So first we will look at 0 (X-coordinate), and then all the hexes that are in the height of the map. Then we will look at the 1 (X-cooridnate) and then the hexes that are in the height of the map... and so on, until we reach the end of the map width.

Remember to put End Loopers at the end of each of them. The First Looper will run to the Last End Looper Command, hence the indention.

Image
Attachments
A009Loopsovermap.jpg
A009Loopsovermap.jpg (51.4 KiB) Viewed 383 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Right, so that has now been put into the Event code (or small program if you will). We then want to find out who the hexes we are looking at are owned by. So we make a SetVar, TempVar10, and set it to the Check function CheckHexOwner. This can be found in one of the submenus that I was too "lazy" to include (since I wanted this sample to be shorter rather than an novel). Don't be affraid to look through all the submenus, they don't bite either, if you press one by mistake, just retype this line of code (or set the Var to something else).

The CheckHexOwner, does exactly what it sounds like. It checks what owner that a hex has currently. So we want to have that value, so we can use it to plot onto the map.

Image
Attachments
A010SetVarHexOwner.jpg
A010SetVarHexOwner.jpg (34.77 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Ok, so now we want the hex to be painted by our AreaSlot 3 value. (again 3 not 0). We use the EXEC ExecSetSlot. This is used to set the AreaSlot Value. Again there is a submenu that I was too "lazy" to include, for the same reason as above.

The ExecSetSlot, asks us for a x and y coordinate, those we have as TempVar0 and TempVar1 from our two loopers. Then it wants us to tell it what AreaSlot we want the value into, and we use 3 (NOT 0). Finally it asks us what value we might want to put in there... We answer TempVar10, which was the regime that owned the Hex.

Image
Attachments
A011SetSl..HewOwner.jpg
A011SetSl..HewOwner.jpg (39.05 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Now we are actually done with this event. We might want to clean it up a bit. Like removing those extra empty lines... Which I have done in the picture. Also note the button on the right. The yellow one. If we press that now, while marking the event, we will INSTANTLY apply it to the scenario.

So.. we could make every hex painted the exact way we wanted...

Image
Attachments
A012ApplyEvent.jpg
A012ApplyEvent.jpg (132.13 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

... And the result would look like in the picture below.

Notice how the water is set to -1. This is because that no owner is regime is the same as having the regime owner -1.

It is also nice to note that we cannot set this value to -1 in the Map editor. So we can work around the limits of what is allowed for people who have not learned code yet.

Image
Attachments
A013AreaS..Painted.jpg
A013AreaS..Painted.jpg (163.79 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Now back to the Event part of the editor.

I mentioned we didn't want to apply it (although it is a neat thing that can be done for fast edits in general). But we do want it to run. So lets add a new line, by pressing the + symbol.

We then add the EXEC BlockEvent. This is found in the submenu property sheet called Logic... (I forgot the rest of it, will need to edit if people have trouble finding it). It's function is simple. Once an event reaches this piece of code, the event that it is in, will no longer run, again. So we can make sure that our event only runs when the game starts up.

This is helpful for many things. For instance, if we want to make it part of a random game generator, then it is there and runs each time. If we want to make edits to which hexes a regime owns, before the game, and want to have the partisans appear there, then it will also be useful.

Finally change when the event is run (2). Click the button until you reach round check. In the beginning I had trouble discerning what a round was, and what a turn was. It is rather simple if you remember this sentence. A player plays his round when it is his turn. So a round check comes before a turn check. It happens when a new round starts.

Image
Attachments
A014Round..eaPaint.jpg
A014Round..eaPaint.jpg (58.08 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Ok. Now we are done with all the initial steps, before coding the event that will make the actual partisans.

First we want to use a new event, to make these partisans. I suggest event 51. It is the event just after the one we made, and it's nice to have similar things together.

So we name the Event "Check for Partisans", and we make a few lines, 10 should do it, for now at least. And then step 3, we make this event happen as an early turn check. That is at the beginning of the turn for each player.

Image
Attachments
A015Make..anEvent.jpg
A015Make..anEvent.jpg (77.32 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Now we begin fleshing out the event. We know we will check the whole map again, so lets reuse those lines of code from the first event we wrote.

Then we will have to make a variable, a TempVar, to hold a random number in... we don't want partisans showing up on every hex. CheckRandomPercent gives us a random number from 1 to 100. We need a number from 0 to 99. So we subtract one. This happens in the two new lines just shown.

Image
Attachments
A016Find..0to99.jpg
A016Find..0to99.jpg (57.75 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

We then want to have a 5% chance that a partisan springs into action, on a given hex, owned by our opponent, but which was originally ours. So, we divide our number by 5. Now ATG does not handle decimal points, which means, it rounds down, when encountering them. So we just got a number from 0 to 20, and an equal chance of each (0 to 4 divided by 5 are all 0, so 5 numbers are 0... just like 5-9 are 1s.. and there are 5 of those.. etc.)

Then we want to make it so that IF we get the result 0 out of our random function (TempVar10), then we will get a partisan. So we make a Check for exactly that conditon (TempVar10 == 0).

Remember to close the Check Sentence with a End Check, with the same indention as your Check condition.

Image
Attachments
A017Check..rcentage.jpg
A017Check..rcentage.jpg (71.38 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

Ok. Now comes the fun part. Let us add the partisan. This is done by ExecAddUnit. This will allow you to place a PreDef unit, on an x and y coordinate, belonging to the regime of your choice. Also (Not shown here) you can rename the unit, to anything you want, or not, and it will remain what the original unit was called. The order of the different variables is shown in line 6.

Image
Attachments
A018PlacePreDef.jpg
A018PlacePreDef.jpg (59.55 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
User avatar
ernieschwitz
Posts: 4240
Joined: Tue Sep 15, 2009 3:46 pm
Location: Denmark

RE: Making Partisans: A sample event

Post by ernieschwitz »

And, now the event is done.... well, wait a minute, we are missing something. Let us add a few lines, and then we will see what we are missing.

Image
Attachments
A019forge..omething.jpg
A019forge..omething.jpg (58.02 KiB) Viewed 385 times
Creator of High Quality Scenarios for:
  • Advanced Tactics Gold
    DC: Warsaw to Paris
    DC: Community Project.
Try this Global WW2 Scenario: https://www.vrdesigns.net/scenario.php?nr=280
Post Reply

Return to “Mods and Scenarios”