Prayer of Pity to the Event Gods! (Full Version)

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



Message


GunnyJarhead -> Prayer of Pity to the Event Gods! (4/16/2013 7:33:14 PM)

Hi Guys, I'm a long time player of several years now. I play exclusively single player. Anyway...there are a lot of things I have been able to mod..such as Land, LT, Units, Rule-variables (although I don't understand everyone of them!) etc... However coding still eludes me..no it doesn't elude me..it absolutely kicks my ass. Believe me when I say that I have read and reread every post in here about coding...but lord help me I'm just not wired that way!

I have created a very large world (200x160) in which I have taken the time to include Continents, Archipelagos, Mountain Ranges, rivers that follow geographic principles, swamps in the right logical places, Rain forest and rain shadows dictated by geography etc. but id love some help in other areas (such as coding) so here goes...if any of you can Teach me on the side..or just simply write a few short codes for me to insert I would be very grateful!

I have the blank map....I would like to be able to in the event screen execute the following events.

1. Random Placement of Raw and Oil for a 200x160.

2, Random placement of Cities for a 200x160.

3. Set Weather for a 200x160 ( I do not have it divided into zones...but would love to)

Please..Please..I know some of you Coders could probably write these events in your sleep...your help would make an old jarhead very happy in completing his world!

By the way I LOVE the ERR_EAI_Leaders mod...it really slows the game down to my taste yet make it very challenging to balance feeding the General and The Bean Counters.

Thanks.





ernieschwitz -> RE: Prayer of Pity to the Event Gods! (4/16/2013 8:29:04 PM)

You have posted insufficient information to do the events.

How many cities/resources should there be, how big should the be, and how well distributed... events only do what you tell them to do, and these are things they have to know exactly.

I wonīt code it btw, mostly because my expertise is not the random maps or random placements of stuff. I think there are people out there more qualified than me at that...




ernieschwitz -> RE: Prayer of Pity to the Event Gods! (4/16/2013 8:49:21 PM)

Oh yes, and then there is the issue of naming all those cities... what should they be called...




Twotribes -> RE: Prayer of Pity to the Event Gods! (4/16/2013 8:54:26 PM)


quote:

ORIGINAL: ernieschwitz

Oh yes, and then there is the issue of naming all those cities... what should they be called...

Bella woods and such )




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/16/2013 9:40:40 PM)

Hmmm...see...I told you I don't know how to code!

How many should there be..I have no idea, until it feels right i guess. LOL [:D]

I was able to "execute this event now", with the "Random : Place Crate" event on a blank map. Below.

0) SETVAR: TempVar9 = CheckMapWidth
1) SETVAR: TempVar9 * CheckMapHeight
2) SETVAR: TempVar9 / 200
3) LOOPER: TempVar10 FROM 0 TO 100
4) SETVAR: TempVar0 = CheckMapWidth
5) SETVAR: TempVar0 * CheckRandomPercent
6) SETVAR: TempVar0 / 100
7) SETVAR: TempVar1 = CheckMapHeight
8) SETVAR: TempVar1 * CheckRandomPercent
9) SETVAR: TempVar1 / 100
10) CHECK: TempVar9 > 0
11) CHECK: CheckLocTypeXY(TempVar0, TempVar1) == -1
12) CHECK: CheckLandscapeType(TempVar0, TempVar1) > 1
13) CHECK: CheckHexOwner(TempVar0, TempVar1) == -1
14) EXECUTE: ExecSetSpecial(43, 0, TempVar0, TempVar1)
15) SETVAR: TempVar9 - 1
16) EXECUTE: ExecHexActionCard(TempVar0, TempVar1, 1)
17) EXECUTE: AI_SetAIVP(TempVar0, TempVar1, -1, 1)
18) END CHECK
19) END CHECK
20) END CHECK
21) END CHECK
22) END LOOPER

It did place crates..but very few and far between. So I ran it again, and it added even more crates, I did this a few times (imagining that they were Cities instead of Crates) until I got what I thought was a good distribution. I tried to changes the code above to place cities instead of crates..but never could get it to do it.

I never could get it to place Raw and Oil doing "execute the event now" using "Random : Place Raw and Oil"...this worked to an extent. Id did place the R&O but only in a very small section of the 200x160 map. It placed it only in the upper left hand corner. Once again I could continue to execute the event until it felt right.

0) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
1) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
2) CHECK: CheckSlot(TempVar0, TempVar1, 0) == 1
3) EXECUTE: ExecChangeLocationType(TempVar0, TempVar1, 2, 8)
4) EXECUTE: ExecSetLandscape(TempVar0, TempVar1, 5)
5) EXECUTE: ExecSetSprite(TempVar0, TempVar1, 0)
6) END CHECK
7) CHECK: CheckSlot(TempVar0, TempVar1, 0) == 2
8) EXECUTE: ExecChangeLocationType(TempVar0, TempVar1, 3, 8)
9) EXECUTE: ExecSetLandscape(TempVar0, TempVar1, 0)
10) EXECUTE: ExecSetSprite(TempVar0, TempVar1, 0)
11) END CHECK
12) END LOOPER
13) END LOOPER


I think that if I knew what to change to get these to Cover the Map and could identify where to change what it places..it would be a great start.

Thanks for replying




GrumpyMel -> RE: Prayer of Pity to the Event Gods! (4/16/2013 10:02:53 PM)

Alot of details you need to map out. To point you in the right direction (I think), you would need to:

- Do a check to make sure it was the first turn, so that your event wouldn't keep getting processed every turn after that.
- Setup variables to use as counters for each location type you want to add.
- Add a loop for each location type that did the following until the counter variable reached the number that you want..
-- Generate 2 random numbers that you can use for X and Y coordinates of a hex that fits within the boundaries of your map.
-- Do whatever logic checks you need to do (right terrain type, distance from other objects, etc) to make sure the coordinates you generated are valid to plop down that location type.
--Execute  the editor function for adding that location type (you could probably use the counter for naming, if you didn't care much about being fancy...."City 1", etc)
-- Increment your counter variable by 1 and go back to the start of your loop.

I'm sure there may be more elegant methods of doing it, but the above is a brute force methodology that should with a bit of tweaking, work.

P.S. I'm also not real experienced with doing random maps and object placement. I'm used to working more with historical scenarios.






GrumpyMel -> RE: Prayer of Pity to the Event Gods! (4/16/2013 10:25:39 PM)


quote:

ORIGINAL: GunnyJarhead

Hmmm...see...I told you I don't know how to code!

How many should there be..I have no idea, until it feels right i guess. LOL [:D]

I was able to "execute this event now", with the "Random : Place Crate" event on a blank map. Below.

0) SETVAR: TempVar9 = CheckMapWidth
1) SETVAR: TempVar9 * CheckMapHeight
2) SETVAR: TempVar9 / 200
3) LOOPER: TempVar10 FROM 0 TO 100
4) SETVAR: TempVar0 = CheckMapWidth
5) SETVAR: TempVar0 * CheckRandomPercent
6) SETVAR: TempVar0 / 100
7) SETVAR: TempVar1 = CheckMapHeight
8) SETVAR: TempVar1 * CheckRandomPercent
9) SETVAR: TempVar1 / 100
10) CHECK: TempVar9 > 0
11) CHECK: CheckLocTypeXY(TempVar0, TempVar1) == -1
12) CHECK: CheckLandscapeType(TempVar0, TempVar1) > 1
13) CHECK: CheckHexOwner(TempVar0, TempVar1) == -1
14) EXECUTE: ExecSetSpecial(43, 0, TempVar0, TempVar1)
15) SETVAR: TempVar9 - 1
16) EXECUTE: ExecHexActionCard(TempVar0, TempVar1, 1)
17) EXECUTE: AI_SetAIVP(TempVar0, TempVar1, -1, 1)
18) END CHECK
19) END CHECK
20) END CHECK
21) END CHECK
22) END LOOPER

It did place crates..but very few and far between. So I ran it again, and it added even more crates, I did this a few times (imagining that they were Cities instead of Crates) until I got what I thought was a good distribution. I tried to changes the code above to place cities instead of crates..but never could get it to do it.

I never could get it to place Raw and Oil doing "execute the event now" using "Random : Place Raw and Oil"...this worked to an extent. Id did place the R&O but only in a very small section of the 200x160 map. It placed it only in the upper left hand corner. Once again I could continue to execute the event until it felt right.

0) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
1) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
2) CHECK: CheckSlot(TempVar0, TempVar1, 0) == 1
3) EXECUTE: ExecChangeLocationType(TempVar0, TempVar1, 2, 8)
4) EXECUTE: ExecSetLandscape(TempVar0, TempVar1, 5)
5) EXECUTE: ExecSetSprite(TempVar0, TempVar1, 0)
6) END CHECK
7) CHECK: CheckSlot(TempVar0, TempVar1, 0) == 2
8) EXECUTE: ExecChangeLocationType(TempVar0, TempVar1, 3, 8)
9) EXECUTE: ExecSetLandscape(TempVar0, TempVar1, 0)
10) EXECUTE: ExecSetSprite(TempVar0, TempVar1, 0)
11) END CHECK
12) END LOOPER
13) END LOOPER


I think that if I knew what to change to get these to Cover the Map and could identify where to change what it places..it would be a great start.

Thanks for replying


In your first code example TempVar10 is the counter for how many crates you are seting, so it's setup to loop through your crate setting 100 times (meaning 100 crates maximum). Tempvar9 looks like it's used to reduce that number for smaller maps to make sure that there isn't more then 1 crate for every 200 hex's on the map.

The second example looks like it's using a Slot to control which area of the map stuff gets generated...if I'm reading it right (doing this from memory) it's looking for Area 0 slots that are painted 1 or 2.....or I could have it reversed and it's Area 1 and 2 slots that are painted with a 0. Anyway, that's why it's only generating stuff on part of your map....at least I believe that's it....pretty rusty with the editor.









lancer -> RE: Prayer of Pity to the Event Gods! (4/16/2013 11:33:27 PM)

G'day Gunny,

This is actually trickier to do than it looks.

You'd need to take into account terrain as you don't want cities on top of mountains nor do you want resources in the ocean, for example.

Then you'd need to consider spacing. With a pure random distribution it would be possible to end up with your cities or resources all bunched up in one little corner of the map.

Next would be what people inhabit what cities? You'll notice on a normal random map that cities with similiar types of people are roughly grouped together. Not much good being German if all the german cities have been shotgunned here there and everywhere.

Resource distribution needs to be balanced in some manner so that all the oil isn't on one side of the map and the raw on the other.

What you're attempting to do here requires a fair bit of time and effort.

Cheers,
Lancer




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/17/2013 12:22:17 AM)

I'm willing to put in the time and effort if I just understood the jargon! Well Dang...I guess I'll keep plugging away!




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/17/2013 12:32:54 AM)

OK...small breakthrough I took the Place Raw and Oil and was able to change LocType to City and Change the Landscape Type to Urban. It placed them on the map as I was hoping.

Now..since it is a 200x10 map it is still only placing them them in a small upper left hand corner...not hitting the rest of the map. Working on trying to figure that out now.




ernieschwitz -> RE: Prayer of Pity to the Event Gods! (4/17/2013 12:52:00 AM)

Making the landscapetype to urban wonīt make them into locations. But at least youīve come some way.. I agree with Lancer this is no simple process...




lancer -> RE: Prayer of Pity to the Event Gods! (4/17/2013 3:13:57 AM)

G'day Gunny,

You have to fight your way into the editor. Put your big, ambitious plans up on the shelf and start small.

Use the default 20 x 20 map in the editor.

Write an event from scratch.

What you want is a basic loop structure that checks every hex on the map. Like this...

loop temp1 from 0 to CheckMapWidth
loop temp2 from 0 to CheckMapHeight
(inside loop structure - put your code stuff here)
end loop
end loop


Inside the loop structure you then run a quick check to see if that hex rings a bell with a random number, like this...

temp3 = checkRandomPercent
check temp3 < threshold value (eg. 10)
(inside check)
end check


Now if you're random chance comes up, in the above example, a 10% chance, you then plonk down a structure. The loop structure above gives you the hex coordinates - temp1 (x) and temp 2 (y) so this is pretty easy. You put the 'doing stuff code' inside the check as you only want it to happen when you get a random number under your threshold.

ExecSetLandscape(temp1,temp2,New LT#)


this function is found in the 'Exec' list under 'Hex and Areaslots'. The New LT# refers to the index number for the landscape type you want to use.

Find these by exiting the code part of the editor and pressing the 'Landscape' button (up the top left amongst all the other little buttons). For example Plains are '0' and sea is '1'.

Have a play around with this and see how you go. Once it's working try plonking down some 'Location types'. Find these under 'LT' (top left, all those buttons). Eg. Raw level 1 mine is '2'. Use this function to do this (found in the same place as above)...

ExecChangeLocationType(temp1,temp2,New Loctype#, People#)

People is who actually owns the location. Neutral means nobody does. Guess where you find the list of People id? The mess of little buttons again, under 'Ppl'. Everything has an Id #.


Cheers,
Lancer




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/17/2013 4:05:53 AM)

Lancer,

Thanks....I know you have other things to do...but I really appreciate the help. Your examples with explanations are helpful.

Ok I did as you said...and I understand the event code for those parts now except......that when I run the code I get a Loctypes or LandTypes placed on the map in a diagonal line. Sample 1. What I wrote is Sample 2.

Its not scattered over the map.
[image][/image]

[image]local://upfiles/42661/0894947D1A28499CACDE347F4BAD22DE.jpg[/image]




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/17/2013 4:08:34 AM)

Sample 2

[image][/image]



I'll keep playing with it that way. On another note....I have been modding some existing code...im almost there....[:D]

Thanks


[image]local://upfiles/42661/F494E32058BD4E9C9645376D99F62F5C.jpg[/image]




lancer -> RE: Prayer of Pity to the Event Gods! (4/17/2013 4:27:21 AM)

G'day Gunny,

You've got your baseball cap on backwards. Look at line 0 and line 1 above, spot the problem?

Your loop controller on Line 0 uses the same variables (eg. tempVar1) as the looper on line 1. This isn't good 'cause the variables control what the loops do. If you have the same set of variables trying to control both loops then you'll get schizophrenic results like your map above.

To fix ituse variables that are different to anything used elsewhere (as a general rule you don't want individual variables to do more than one thing at a time, they are simple folk).

Also your loops need to start at '0' 'cause that's where the hex coords start on a map (0,0)

so...

Looper temp 0 from 0 to checkmapheight
Looper temp 1 from 0 to checkmapwidth

Cheers,
Lancer




GrumpyMel -> RE: Prayer of Pity to the Event Gods! (4/17/2013 5:07:55 PM)

Lancer is right.

You are using your 2 Loops to generate the X, Y coordinates of the hex you want to work on. By using his method, you step through every hex in the map and roll a random chance to see if something is there.

So, first Loop gives you the X coordinate....

So it looks like this.. Looper [value you use to store x]  from [Hex Row you Want to start at for X] to [Hex Row you Want to End at for X]

If you know the exact size of the map you are working with, you can actualy use numbers instead of variables, if it makes it easier to understand what's going on there....

So... Looper: TempVar0 (You are using this to store X coordinate) from 0 to 20
          Looper: TempVar1 (You are using this to store Y coordinate) from 0 to 20
                     (Do something at the current X,Y coordinates)
          End Looper:
        End Looper

Each time the Looper gets to it's own End Looper (see how they are nested, one inside the other) it increments the value in the variable you were using for it by 1 and goes back to beginning of the loop and repeats the procedure....until it gets to the highest value you've told it to use, then it stops)

So if you think about what it's doing when it executes that code...

The first loop tells it to go through every row on the map starting at hex row 0 and do something....

    .....that something is to go down each column in the current row (the second loop) and do something....
              
            ......that something is to determine if something is there.

You really only need to user variables to substitute for something that you expect to change like the X,Y coordinates of the hex you are currently checking or the value of the random number you just rolled....for something that you know like the number of the hex row that you'd like to start at when checking something you can just use the actual numbers. I've found that helps make things alot easier to understand when starting to code. When you get more experienced, you can make more use of variables and other functions....which helps make it more reusable in different situations (like changing the map size) without needing to make any changes to it.

It can also help you keep track of things when you put a comment above each line of code to explain what you think it's doing. That way you can at least see if your logic is sound. When you get more experienced, you can use comments less...but they still can be very helpfull if you ever have to go back to an event that you wrote awhile back and are trying to remember exactly how it works.

Another trick I use to help me keep things straight is at the start of my event code use comments to spell out exactly what each variable I'm using will be used to store....for example

Comment: TempVar0 = The X Coordinate on the Map
Comment: TempVar1 = The Y Coordinate on the Map

That way it helps avoid mix ups about using the wrong variable when writing your code, as you always have a handy reference.




ernieschwitz -> RE: Prayer of Pity to the Event Gods! (4/17/2013 5:10:50 PM)

You can even cut some corners, if you are working with a map you donīt know the size of, or do know the size of, and simply canīt be bothered to check the maps width and height. You simply make the end x variable be CheckMapWidth, and the y end variable be CheckMapHeight.

Which i can see has been done :)




GrumpyMel -> RE: Prayer of Pity to the Event Gods! (4/17/2013 5:36:33 PM)


quote:

ORIGINAL: ernieschwitz

You can even cut some corners, if you are working with a map you donīt know the size of, or do know the size of, and simply canīt be bothered to check the maps width and height. You simply make the end x variable be CheckMapWidth, and the y end variable be CheckMapHeight.

Which i can see has been done :)


Yes, but many times I think it starts to get confusing for folks who are inexperienced and often uncomfortable with coding to see alot of functions and variables crammed onto a page.

Rather then try to learn everything at once, or even try to code things in the most efficient manner....usualy you are better off just learning one simple step, getting it to work the way you intend....and once you are comfortable with it, improve on it and make it more flexible and efficient. At least I know that's what really helped me when I first started working with code.









ernieschwitz -> RE: Prayer of Pity to the Event Gods! (4/17/2013 7:00:05 PM)

You may be right... I am too much of a perfectionist myself, so, it would be a failure in my traits i guess to require the same of others.




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/18/2013 2:58:25 AM)

Afternoon Guys,

I have made some significant progress! I am now able to:

Randomly Change a Landscape, Location, etc...I can even control where these random event occur based on several factors such as previous location or landscape type, and even based on slots! I'm slowly getting closer to what I'm after.

Now I think I'm gonna try and figure out how to rename locations, and randomly change there owners etc!

Whoo Hoo!

Thanks for the help guys! Keep it coming...please!




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/19/2013 10:43:56 PM)

This is driving me nuts. I was able to create events on a small map. They worked fine. I imported the events to my larger map and the most basic events are now riddled with errors!
grrrrrrrr




ernieschwitz -> RE: Prayer of Pity to the Event Gods! (4/19/2013 11:41:16 PM)

Donīt give up.

Nothing feels better than having completed a succesfull session of programming, and seeing the end result as you want it :)




GunnyJarhead -> RE: Prayer of Pity to the Event Gods! (4/20/2013 3:30:16 AM)

Turns out I had to have been working on a corrupted file. I switched to a copy of my big map and entered the event..they worked as expected.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.765625