Shared Event Code VP for Oil and Raw (Full Version)

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



Message


E6Jarhead -> Shared Event Code VP for Oil and Raw (6/2/2015 2:30:21 AM)

This event will give 20 VP to all instances of Oil and Raw.
If you want a different VP amount changes the number "20" in lines 7 and 15

0) Comment Change VP of Raw and Oil Locations
1) CommentRaw
2) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
3) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
4) Comment Line below checks for location type #2 Raw
5) CHECK: CheckLocTypeXY(TempVar0, TempVar1) == 2
6) Comment Line below Changes VP amount of that Hex to 20
7) EXECUTE: ExecChangeVP(TempVar0, TempVar1, 20)
8) END CHECK
9) END LOOPER
10) END LOOPER
11) Comment Oil
12) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
13) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
14) CHECK: CheckLocTypeXY(TempVar0, TempVar1) == 3
15) EXECUTE: ExecChangeVP(TempVar0, TempVar1, 20)
16) END CHECK
17) END LOOPER
18) END LOOPER




ernieschwitz -> RE: Shared Event Code VP for Oil and Raw (6/2/2015 8:28:31 AM)

You could make this code shorter if you wanted to, and more efficient.

Let me show you how:

0) Comment Change VP of Raw and Oil Locations
1) Comment Raw
2) LOOPER: TempVar0 FROM 0 TO CheckMapWidth
3) LOOPER: TempVar1 FROM 0 TO CheckMapHeight
4) Comment Line below checks for location type #2 Raw
5) CHECK: CheckLocTypeXY(TempVar0, TempVar1) == 2
6) Comment Line below Changes VP amount of that Hex to 20
7) EXECUTE: ExecChangeVP(TempVar0, TempVar1, 20)
8) END CHECK
14) CHECK: CheckLocTypeXY(TempVar0, TempVar1) == 3
15) EXECUTE: ExecChangeVP(TempVar0, TempVar1, 20)
16) END CHECK
9) END LOOPER
10) END LOOPER

I´ve kept the line numbers the way you wrote them originally. Notice that I just moved the Check for Oil, into the looper for checking for raw. By doing it this way, you only run 1 looper that checks every hex on the map.




E6Jarhead -> RE: Shared Event Code VP for Oil and Raw (6/2/2015 1:02:43 PM)

Awesome....Shorter is better.....I've been lurking, playing and privately modding for years now...so a lot of my codes are not streamlined but brute force. So any suggestions are welcome!

Thanks!




ernieschwitz -> RE: Shared Event Code VP for Oil and Raw (6/2/2015 1:51:54 PM)

Also, this event could do with a BlockEvent at the end. This would cause it only to run once. No need to have VPs reset to 20 each turn...




E6Jarhead -> RE: Shared Event Code VP for Oil and Raw (6/2/2015 2:17:35 PM)

I have yet to explore the block event. I agree with you and did not know it was running this event each turn. Please keep the advise coming! Im trying hard to learn and would love to be able to contribute back in some way to the community




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.671875