Advertisement
Janne252

How to: Infantry only mode - the code (example)

Jan 26th, 2014
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. function OnInitID()
  2.  
  3.     -- [[ Markers ]]
  4.  
  5.     -- [[ Squad Groups ]]
  6.  
  7.     -- [[ Entity Groups ]]
  8.  
  9.     local _vehicleAbilities =  {
  10.         "mechanized_grenadier_group", "supply_truck", "tiger_tank", "mortar_halftrack", "elefant_unlock", "tiger_tank_ace", "stug_short_barrel", "stug_iii_e", "armor_commander",
  11.             "mechanized_assault_group", "cmd_kv-8_unlock_mp", "cmd_advanced_t34_85_medium_tank", "cmd_t34_85_medium_tank", "cmd_isu-152", "cmd_is2_heavy_tank", "cmd_kv-1_unlock", "kv-2",
  12.         }
  13.            
  14.     local SBP_IsVehicle = function(sbp)
  15.         --Skip problematic squads (pak creates splats, panzer_iii causes an error due to not existing yet)
  16.         local _skip_sbp = {
  17.             [1] = {
  18.                 name = "pak43",
  19.                 isVehcle = false,
  20.             },
  21.             [2] = {
  22.                 name = "panzer_iii",
  23.                 isVehcle = true,
  24.             },
  25.         }
  26.         local isVehcle = false
  27.         local pos = World_Pos(-512, -512, -512)    
  28.         local skipSBP = false
  29.        
  30.         for key, _sbp in ipairs(_skip_sbp) do
  31.             if string.find(BP_GetName(sbp), _sbp.name) then
  32.                 isVehcle = _sbp.isVehcle
  33.                 skipSBP = true
  34.             end
  35.         end
  36.        
  37.         if not skipSBP then
  38.             local squad = Squad_CreateAndSpawnToward(sbp, World_GetPlayerAt(1), 1, pos, pos)
  39.             local entity = Squad_EntityAt(squad, 0)
  40.             if Entity_IsOfType(entity, "vehicle") and not Entity_IsOfType(entity, "team_weapon") then
  41.                 isVehcle = true
  42.             else
  43.                 isVehcle = false
  44.             end
  45.             Squad_Destroy(squad)
  46.         end
  47.         return isVehcle    
  48.     end
  49.      
  50.     for key, race in pairs(SBP) do
  51.         for key, sbp in pairs(race) do
  52.             if SBP_IsVehicle(sbp) then
  53.                 for i = 1, World_GetPlayerCount() do
  54.                     Player_SetSquadProductionAvailability(World_GetPlayerAt(i), sbp, ITEM_REMOVED)
  55.                 end
  56.             end
  57.         end    
  58.     end
  59.    
  60.     for key, abp in ipairs(_vehicleAbilities) do
  61.         for i = 1, World_GetPlayerCount() do
  62.             Player_SetAbilityAvailability(World_GetPlayerAt(i), BP_GetAbilityBlueprint(abp), ITEM_REMOVED)
  63.         end
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement