tjhkkr -> RE: Using LUA to place units in a random place on the map. (3/31/2015 2:44:36 AM)
|
This one is designed to give an incentive to destroy bridges as it stops the flow reinforcements. There are 4 bridges, the more you destroy, the less likely reinforcements will appear. It also assigns a mission depending on where the reinforcements end up on map; to the west, it goes to YankeeWest; to the East, it goes to YankeeEast. It assigns randomly whether to give the Chinese a T34-85 or a T55. ==== ScenEdit_SetKeyValue('BridgesInoperative', '0') ScenEdit_SetKeyValue('ArmChina', '1') ScenEdit_SetKeyValue('InfChina', '1') The above is set at the beginning of the game... <=== ==== numkey1 = ScenEdit_GetKeyValue('InfChina') numkey2 = ScenEdit_GetKeyValue('ArmChina') numbridgedest = ScenEdit_GetKeyValue('BridgesInoperative') UnitProf = math.random(3,5) - 1 probTrainsArrive = math.random(1,4) probTrainsArrive = probTrainsArrive - numbridgedest if probTrainsArrive => 1 then a = 0 workKey = numkey1 + 1 repeat a = a + 1 string.name1 = 'PRCArmPlat' .. workKey string.name2 = 'PRCInfPlat' .. workKey q = math.random(1, 2) if q == 1 then r = math.random(1, 100) r = r - 50 r = r / 100 longi =102.5 + r r = math.random(1, 100); r = r - 50 r = r / 100 lati =19.25 + r string.missionassigned = 'YankeeWest' else r = math.random(1, 100) r = r - 50 r = r / 100 longi =105.5 + r r = math.random(1, 100) r = r - 50 r = r / 100 lati =20.4 + r string.missionassigned = 'YankeeEast' end string.strLati = lati; string.strLongi = longi q = math.random(1, 3) if q == 1 then databasedid = 210 else databasedid = 1272 end ScenEdit_AddUnit({type = 'facility', name = string.name1, heading = 0, dbid = databasedid, side = 'Communist Forces', Latitude= string.strLati ,Longitude= string.strLongi, autodetectable="false",holdfire="false",proficiency=UnitProf}) ScenEdit_AddUnit({type = 'facility', name = string.name2, heading = 0, dbid = 369, side = 'Communist Forces', Latitude= string.strLati ,Longitude= string.strLongi, autodetectable="false",holdfire="false",proficiency=UnitProf}) ScenEdit_AssignUnitToMission(string.name1, string.missionassigned) ScenEdit_AssignUnitToMission(string.name2, string.missionassigned) workKey = workKey + 1 until a >= 8 end FinalNumKey = workKey + 1 String.StrFinalNumKey = string.format("%.1f", FinalNumKey) ScenEdit_SetKeyValue('ArmChina', String.StrFinalNumKey) ScenEdit_SetKeyValue('InfChina', String.StrFinalNumKey)
|
|
|
|