Jason Petho
Posts: 15009
Joined: 6/22/2004 From: Terrace, BC, Canada Status: offline
|
In the main USER.LUA file, are some common variables that are available for the scripting. They are like this: quote:
ATTACK_UNKNOWN = -1 ATTACK_NONE = 0 ATTACK_CENTER = 1 ATTACK_FORWARD = 2 ATTACK_BACKWARD = 3 ATTACK_RIGHT = 4 ATTACK_LEFT = 5 ATTACK_NORTH = 6 ATTACK_NORTHEAST = 7 ATTACK_EAST = 8 ATTACK_SOUTHEAST = 9 ATTACK_SOUTH = 10 ATTACK_SOUTHWEST = 11 ATTACK_WEST = 12 ATTACK_NORTHWEST = 13 VECTOR_UNKNOWN = -1 VECTOR_NONE = 0 VECTOR_CENTER = 1 VECTOR_FORWARD = 2 VECTOR_BACKWARD = 3 VECTOR_RIGHT = 4 VECTOR_LEFT = 5 VECTOR_NORTH = 6 VECTOR_NORTHEAST = 7 VECTOR_EAST = 8 VECTOR_SOUTHEAST = 9 VECTOR_SOUTH = 10 VECTOR_SOUTHWEST = 11 VECTOR_WEST = 12 VECTOR_NORTHWEST = 13 On turn one, each company that is coded will have a die roll which will set their general attack plan for that particular run of the game. You can see below an example of the die rolls and the attack vectors each of the companies will do during that autotest. quote:
2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_22ND_1862_ATTACK_VECTOR 1 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_22ND_1867_ATTACK_VECTOR 4 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_22ND_1872_ATTACK_VECTOR 1 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_322ND_1910_ATTACK_VECTOR 5 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_322ND_1915_ATTACK_VECTOR 5 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_322ND_1920_ATTACK_VECTOR 4 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_18TH_1947_ATTACK_VECTOR 4 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_18TH_1952_ATTACK_VECTOR 4 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_18TH_1957_ATTACK_VECTOR 5 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_54TH_1971_ATTACK_VECTOR 1 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_54TH_1976_ATTACK_VECTOR 4 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_54TH_1981_ATTACK_VECTOR 1 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_11TH_1497_ATTACK_VECTOR 4 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_11TH_1502_ATTACK_VECTOR 4 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_11TH_1507_ATTACK_VECTOR 5 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_428TH_1545_ATTACK_VECTOR 1 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_428TH_1550_ATTACK_VECTOR 1 2021-03-12 22:49:41 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_428TH_1555_ATTACK_VECTOR 1 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_130TH_1667_ATTACK_VECTOR 1 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_130TH_1672_ATTACK_VECTOR 5 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_130TH_1677_ATTACK_VECTOR 1 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_154TH_1691_ATTACK_VECTOR 1 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_154TH_1696_ATTACK_VECTOR 4 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_154TH_1701_ATTACK_VECTOR 4 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_215TH_2054_ATTACK_VECTOR 5 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_215TH_2059_ATTACK_VECTOR 4 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_215TH_2064_ATTACK_VECTOR 1 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_249TH_2139_ATTACK_VECTOR 5 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_249TH_2144_ATTACK_VECTOR 4 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_249TH_2149_ATTACK_VECTOR 5 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _1ST_250TH_2163_ATTACK_VECTOR 4 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _2ND_250TH_2168_ATTACK_VECTOR 4 2021-03-12 22:49:42 vnengine.exe: [DEBUG ID 10] (lua.cpp, line 635, l_log()) _3RD_250TH_2173_ATTACK_VECTOR 5 As I am coding a "ATTACK_LEFT, ATTACK_CENTER or ATTACK_RIGHT" option for each company, it will roll between a 1, 4 and 5. Here is an example of the complete code for the Viet Minh 3rd company of the 250th battalion (sorry about the formatting, I can't screenshot the whole block, so had to do a copy/paste. quote:
-- _3RD_250TH_2173 -- 3rd/250th do local units = join({_3RD_250TH_2173,_MEDIUM_MACHINE_GUN_2180}) _3RD_250TH_2173_ATTACK_VECTOR = _3RD_250TH_2173_ATTACK_VECTOR or random_pick({ATTACK_RIGHT, ATTACK_CENTER, ATTACK_LEFT}) if DEBUG then log(LUALOG, LOG_DEBUG, "_3RD_250TH_2173_ATTACK_VECTOR " .. _3RD_250TH_2173_ATTACK_VECTOR) end if _3RD_250TH_2173_ATTACK_VECTOR == ATTACK_RIGHT then if turn >= 1 and turn <= 18 then defend_strong(units, "27,25", NODIR, 1, 100) elseif turn >= 19 then move_fire_way_point(units, {"26,23","24,21"}, NODIR, 1, 100) if owned(OBJECTIVES[24], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[24], {UPLEFTDIR,UPDIR}, 1, 100) elseif owned(OBJECTIVES[25], VM_SIDE) then move_fire_way_point(units, {"25,20",OBJECTIVES[25]}, NODIR, 1, 100) if (units_within_count(OBJECTIVES[23], NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_nearest_to_hex(units, OBJECTIVES[23], NODIR, 1, 100, ATTACK_STRONG, true) elseif owned(OBJECTIVES[23], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[23], {DOWNDIR,DOWNRIGHTDIR}, 1, 100) elseif owned(OBJECTIVES[20], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[20], {DOWNRIGHTDIR}, 1, 100) elseif owned(OBJECTIVES[18], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[18], {UPRIGHTDIR}, 1, 100) elseif (units_within_count(OBJECTIVES[18], NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_nearest_to_hex(units, OBJECTIVES[18], NODIR, 1, 100, ATTACK_STRONG, true) end else defend_strong(units, OBJECTIVES[24], NODIR, 1, 100) end end elseif _3RD_250TH_2173_ATTACK_VECTOR == ATTACK_CENTER then if turn >= 1 and turn <= 22 then defend_strong(units, "27,25", NODIR, 1, 100) elseif turn >= 23 and turn <= 26 then move_fire_way_point(units, {"26,23","26,21"}, NODIR, 1, 100) if (units_within_count("26,21", NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_strong(units, "26,21", {UPRIGHTDIR,DOWNRIGHTDIR}, 1, 100) elseif owned(OBJECTIVES[25], VM_SIDE) then move_fire_way_point(units, {"25,20",OBJECTIVES[25]}, NODIR, 1, 100) if (units_within_count(OBJECTIVES[23], NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_nearest_to_hex(units, OBJECTIVES[23], NODIR, 1, 100, ATTACK_STRONG, true) elseif owned(OBJECTIVES[23], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[23], {DOWNDIR,DOWNRIGHTDIR}, 1, 100) elseif owned(OBJECTIVES[20], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[20], {DOWNRIGHTDIR}, 1, 100) elseif owned(OBJECTIVES[18], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[18], {UPRIGHTDIR}, 1, 100) elseif (units_within_count(OBJECTIVES[18], NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_nearest_to_hex(units, OBJECTIVES[18], NODIR, 1, 100, ATTACK_STRONG, true) end else defend_strong(units, "26,21", NODIR, 1, 100) end elseif turn >= 27 then move_fire_way_point(units, {"28,19","29,18","29,16"}, NODIR, 1, 100) if owned(OBJECTIVES[23], FRENCH_SIDE) then attack_strong(units, "25,15", {UPRIGHTDIR,DOWNRIGHTDIR}, 1, 100) elseif (units_within_count("25,15", NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_strong(units, "25,15", {UPRIGHTDIR,DOWNRIGHTDIR}, 1, 100) end end elseif _3RD_250TH_2173_ATTACK_VECTOR == ATTACK_LEFT then if turn >= 1 and turn <= 22 then defend_strong(units, "27,25", NODIR, 1, 100) elseif turn >= 23 then move_fire_way_point(units, {"27,25","27,23"}, NODIR, 1, 100) if (units_within_count("27,21", NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_strong(units, "27,21", {UPRIGHTDIR,DOWNRIGHTDIR}, 1, 100) elseif owned(OBJECTIVES[25], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[25], {DOWNDIR,DOWNRIGHTDIR}, 1, 100) elseif (units_within_count(OBJECTIVES[25], NODIR, 1, FRENCH_SIDE, true) >= 1) then attack_nearest_to_hex(units, OBJECTIVES[25], NODIR, 1, 100, ATTACK_STRONG, true) elseif owned(OBJECTIVES[23], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[23], {DOWNDIR,DOWNRIGHTDIR}, 1, 100) elseif owned(OBJECTIVES[22], FRENCH_SIDE) then attack_strong(units, OBJECTIVES[22], {DOWNRIGHTDIR}, 1, 100) elseif (units_within_count(OBJECTIVES[22], NODIR, 2, FRENCH_SIDE, true) >= 1) then attack_nearest_to_hex(units, OBJECTIVES[22], NODIR, 2, 100, ATTACK_STRONG, true) else defend_strong(units, OBJECTIVES[22], NODIR, 1, 100) end end end local hmg = _MEDIUM_MACHINE_GUN_2180 if turn >= 1 and turn <= 15 then move_norush(hmg, "30,25") if within(hmg, "30,25", NODIR, 1) then fire_direct_area(hmg, "30,25", NODIR, 3, 100, true) end elseif turn >= 11 and turn <= 20 then move_norush(hmg, "29,24") if within(hmg, "29,24", NODIR, 1) then fire_direct_area(hmg, "29,24", NODIR, 4, 100, true) end elseif turn >= 21 then if (units_within_count("26,24", NODIR, 1, FRENCH_SIDE, true) == 0) then move_norush(hmg, "26,24") if within(hmg, "26,24", NODIR, 1) then fire_direct_area(hmg, "26,24", NODIR, 3, 100, true) end elseif (units_within_count("27,21", NODIR, 2, FRENCH_SIDE, true) == 0) then move_norush(hmg, "27,21") if within(hmg, "27,21", NODIR, 1) then fire_direct_area(hmg, "27,21", NODIR, 4, 100, true) end else if owned(OBJECTIVES[25], VM_SIDE) then move_norush(hmg, OBJECTIVES[25]) if within(hmg, OBJECTIVES[25], NODIR, 1) then fire_direct_area(hmg, OBJECTIVES[25], NODIR, 3, 100, true) end end end end
< Message edited by Jason Petho -- 3/13/2021 5:49:13 PM >
_____________________________
|