Advertisement
Janne252

How to: Infantry only mode - the code

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