Making Partisans: A sample event (Full Version)

All Forums >> [New Releases from Matrix Games] >> Advanced Tactics Series >> Mods and Scenarios



Message


ernieschwitz -> Making Partisans: A sample event (3/9/2019 3:46:27 AM)

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.




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 3:51:40 AM)

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]local://upfiles/32858/0CBD0881A78A4731BEB57BF8E89C8393.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 3:53:47 AM)

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]local://upfiles/32858/C731CBBFC8104E45891B31601B28D92C.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 3:58:51 AM)

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]local://upfiles/32858/E6DEC317296346559C9301DD47B4EE7A.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:04:38 AM)

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]local://upfiles/32858/1D0CA918B8BD46B684AD81184CE1925F.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:08:49 AM)

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]local://upfiles/32858/8945B3C9D5DC4B50B018353A8EC3C74B.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:11:44 AM)

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]local://upfiles/32858/83758BFD79CF419C82E462D7D03735CB.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:16:31 AM)

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]local://upfiles/32858/7A1053E14E7C435A869999234C357FD7.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:22:57 AM)

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]local://upfiles/32858/DF83F4B0B88C44108179C0ACFF6DC54F.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:28:40 AM)

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]local://upfiles/32858/F251394758914C60B813B5575D1D3E49.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:33:41 AM)

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]local://upfiles/32858/4AEBDD4018024544AA9A60A3D80859D8.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:38:03 AM)

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]local://upfiles/32858/F5E21D3A7E25425CA04FD70CEF2A069A.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:41:04 AM)

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]local://upfiles/32858/6F276D0A382C4441A7A8A4EF0DD31CDD.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:43:31 AM)

... 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]local://upfiles/32858/E08D582F410C47CBA40D3BFA6EA0960B.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:50:46 AM)

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]local://upfiles/32858/ABCF5BF111434855A02C108E70C40D4B.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:54:01 AM)

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]local://upfiles/32858/5193947F6CFA490EB51C28DE9E6E85EB.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 4:57:07 AM)

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]local://upfiles/32858/D6D8359DD1F94DF488F6297F2E883D0B.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 5:01:57 AM)

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]local://upfiles/32858/60A38E9755B147228142DC1BB195659E.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 5:04:35 AM)

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]local://upfiles/32858/361B1E30119943C99B6E8E1B07600B19.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 5:05:43 AM)

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]local://upfiles/32858/4B54B02CEF074C3BAEFF544781318F57.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 5:10:51 AM)

We forgot to check who is the owner of the hex, and who was the original owner.

Time to do that.

CheckHexOwner is a condition that allows us to compare the owner of the hex, with a number, a regime. The opponents regime was 0 so, lets input that, after we input the coordinates in the check function itself.

CheckSlot is a similar function, it checks what the value is in the coordinates of the AreaSlot (3 not 0) and then asks what value it should be to go further in checking this hex.

[image]local://upfiles/32858/9ECB4A57285541DA9DEFDD3526BC6E2D.jpg[/image]




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 5:13:49 AM)

Now we are done. Or so I thought. (That will teach me to code during the day, instead of the night, when I am tired). There is still one more step. I forgot something you see.

You need to add the line Check: CheckTurn == 1 before the first line. So add a line there, and type it in.

You also need an End Check at the very end of the code.

This will make the Event run only during regime 1s turn.




ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 5:15:20 AM)

I hope this has been a good little sample, of how and what to do... and also the process that goes into doing it. Not being afraid to admit you've forgotten something, and adding it in, once you realize it is gone. We don't all make perfect code on the first try, neither do I. Keep on hanging in there.. :)

And happy coding. [;)]




Jabod -> RE: Making Partisans: A sample event (3/9/2019 3:03:17 PM)

Thanks for this!

Instead of

quote:

SETVAR: TempVar10 = CheckRandomPercent
SETVAR: TempVar10 - 1
SETVAR: TempVar10/ 5
CHECK: CheckHexOwner (TempVar0, TempVar1) == 0
CHECK: CheckSlot (TempVar0, TempVar1, 3) == 1
CHECK: TempVar10 == 0
EXECUTE: ExecAddUnit (5, TempVar0, TempVar1, 1)


Why not just

CHECK: CheckHexOwner (TempVar0, TempVar1) == 0
CHECK: CheckSlot (TempVar0, TempVar1, 3) == 1
CHECK: CheckRandomPercent < 6
EXECUTE: ExecAddUnit (5, TempVar0, TempVar1, 1)








ernieschwitz -> RE: Making Partisans: A sample event (3/9/2019 3:19:15 PM)

Sure you could do that too.

I just prefer to do it the other way. :) There is no real reason I guess. Other than I got to show off how to use the SetVar option of the editor, and talk about how there is no decimal point in ATG.




Ormand -> RE: Making Partisans: A sample event (3/11/2019 12:50:48 AM)

BTW, AreaSlot 0 is also used by the event "check inundate" as part of the officer inundate action card.




ernieschwitz -> RE: Making Partisans: A sample event (3/11/2019 12:57:13 AM)

quote:

ORIGINAL: Ormand

BTW, AreaSlot 0 is also used by the event "check inundate" as part of the officer inundate action card.


:) If you have read the text, you will notice that I checked for usage of AreaSlot 0, and then did AreaSlot 3 instead . But yeah, as a designer you really need to label those AreaSlots for other designers to find out what is going on. As would have it, I am not using New Dawn with officers, but Default.at2 as masterfile :)




lion_of_judah -> RE: Making Partisans: A sample event (5/24/2019 11:52:42 PM)

Ernie
I wonder if the problem maybe that the partisan unit for Hyderabad is the same people as India, could that be the problem or is it in the coding. Because if it's the people then I see no way around it as both nations are comprised of Indians.





ernieschwitz -> RE: Making Partisans: A sample event (5/29/2019 8:32:34 PM)

quote:

ORIGINAL: lion_of_judah

Ernie
I wonder if the problem maybe that the partisan unit for Hyderabad is the same people as India, could that be the problem or is it in the coding. Because if it's the people then I see no way around it as both nations are comprised of Indians.


For the sake of clarity for everyone reading, and myself: What problem?




lion_of_judah -> RE: Making Partisans: A sample event (5/30/2019 1:33:20 AM)

It works now, had to erase and start the event from scratch.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
2.828125