Code:
--Create squad with race based fx
function Squad_CFRB( playerIndex, sgName, Blueprint, markerOrPos, numsquads, loadout )
--check for errors
if playerIndex >= World_GetPlayerCount() then
error"player index can range from 0 to total player count minus 1"
end
SGroup_CreateIfNotFound( sgName )
if ( loadout == nil or loadout == 0 ) then loadout = Squad_GetMaxFromName( Blueprint ) end
local squad_id = nil
local fx = nil
emRace = nil
local playerId = World_GetPlayerAt( playerIndex )
-- check teh race
if Player_GetRaceName( playerId ) == "npc_race" then
if string.find( Blueprint, "chaos" ) ~= nil then
emRace = "chaos_marine_race"
elseif string.find( Blueprint, "eldar" ) ~= nil then
emRace = "eldar_race"
elseif string.find( Blueprint, "guard" ) ~= nil then
emRace = "guard_race"
elseif string.find( Blueprint, "necron" ) ~= nil then
emRace = "necron_race"
elseif string.find( Blueprint, "ork" ) ~= nil then
emRace = "ork_race"
elseif string.find( Blueprint, "space_marine" ) ~= nil then
emRace = "space_marine_race"
elseif string.find( Blueprint, "tau" ) ~= nil then
emRace = "tau_race"
else emRace = "space_marine_race" print"unexpected squad blueprint"
end
else
emRace = Player_GetRaceName( playerId )
end
print("race custom "..emRace)
local sgID = SGroup_FromName( sgName )
-- determine spawn event
if emRace == "chaos_marine_race" then fx = "data:Art/events/unit_ability_fx/chaos_deep_strike_unit"
elseif emRace == "eldar_race" then fx = "Data:art\events\unit_ability_fx\eldar_warp_in"
elseif emRace == "guard_race" then fx = "Data:art\events\unit_upgrade_morale_fx\reinforce_trooper"
elseif emRace == "necron_race" then fx = "Data:art\events\unit_upgrade_morale_fx\reinforce_necron_trooper"
elseif emRace == "ork_race" then fx = "Data:art\events\unit_ability_fx\ork_turbo_boost_stormboyz"
elseif emRace == "space_marine_race" then
fx = function()
local z = SGroup_Count( sgID )
if first_time == true then
for i = 1, z do
SGroup_Add( SGroup_CreateIfNotFound("__dp_squad"..dp_called), SGroup_GetSpawnedSquadAt( sgID, i ) )
end
first_time = false
else
SGroup_Add( SGroup_CreateIfNotFound("__dp_squad"..dp_called), SGroup_GetSpawnedSquadAt( sgID, z ) )
end
Util_DropPodMarker( "__dp_squad"..dp_called, markerOrPos )
dp_called = dp_called + 1
end
elseif emRace == "tau_race" then
fx = function()
Entity_CMWA( playerId, "eg_orcaShip"..called, "tau_orca_dropship", markerOrPos, "sp_land" ) called = called + 1
Util_StartIntel( ENTS.x( playerId, sgName, Blueprint, markerOrPos, numsquads ) )
squad_id = sgName
end
end
if _accepter(playerIndex) == true then
print(fx)
squad_id = Squad_CreateWithFMRE( playerId, sgName, Blueprint, markerOrPos, fx, numsquads, loadout )
elseif emRace == "space_marine_race" then
print"dpIngame"
squad_id = Util_CreateSquadsAtMarkerEx( playerId, sgName, Blueprint, markerOrPos, numsquads, loadout )
SGroup_ForEach( sgID, fx )
end
return squad_id
end