------------ ---------------------------------------------------------------------------- -- CUSTOMIZATION CONTROL VARIABLES & DATA -- ---------------------------------------------------------------------------- -- are 4 slots per model h_slot = 0; -- helmet s_slot = 1; -- shield g_slot = 2; -- glasses (should use helmet slot) b_slot = 3; -- Hair Cuts and BinLadin beard (should use helmet slot) -- maximum_slot_value = 3; -- p_model = "The Players current Model", the default is/must be initially set in devmode.lua h_model = nil; -- helmet model file path s_model = nil; -- shield model file path g_model = nil; -- glasses model file path b_model = nil; -- hair cut / beard model file path ---------------------------------------------------------------------------- -- DEBUGGING VARIABLES -- ---------------------------------------------------------------------------- allow_change_model = 1; allow_change_extras = 1; allow_param_changes = 1; ---------------------------------------------------------------------------- -- CONTROL VARIABLES -- ---------------------------------------------------------------------------- scripts_version = 1; -- if using the original FarCry release you MUST set this to 0 ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- PlayerIsCustomized = nil; c_model = nil; traceStr = "Trace: "; Customization = {}; default_max_armor = nil; --_localplayer.cnt.max_armor; default_run_speed = nil; -- _localplayer.cnt.move_params.speed_run; default_walk_speed = nil; -- _localplayer.cnt.move_params.speed_walk; default_swim_speed = nil; -- _localplayer.cnt.move_params.speed_swim; --- temp variables for functions below --- prev_speed_walk=p_speed_walk; prev_speed_run=p_speed_run; prev_speed_walk2=p_speed_walk; prev_speed_run2=p_speed_run; default_speed_walk=p_speed_walk; default_speed_run=p_speed_run; ---------------------------------------------------------------------------- function Customization:DecreaseSpeed(pc) local wvalue = pc * default_speed_walk / 100; local rvalue = pc * default_speed_run / 100; if tonumber(p_speed_walk)>wvalue then p_speed_walk=p_speed_walk-wvalue; p_speed_run=p_speed_run-rvalue; Hud:AddMessage("Decreased player speed by "..tostring(pc).."%"); else Hud:AddMessage("You can not go any slower!"); end; end function Customization:IncreaseSpeed(pc) local wvalue = pc * default_speed_walk / 100; local rvalue = pc * default_speed_run / 100; if tonumber(p_speed_walk)<500 then p_speed_walk=p_speed_walk+wvalue; p_speed_run=p_speed_run+rvalue; Hud:AddMessage("Increased player speed by "..tostring(pc).."%"); else Hud:AddMessage("You can not go any faster!"); end; end function Customization:DefaultSpeed(noMess) p_speed_walk=default_speed_walk; p_speed_run=default_speed_run; if ( noMess == nil ) then Hud:AddMessage("Player speed reset"); end; end ---------------------------------------------------------------------------- function Customization:init(model, h, s, g, b) if ( not default_max_armor ) then default_max_armor = _localplayer.cnt.max_armor; default_run_speed = _localplayer.cnt.move_params.speed_run; default_walk_speed = _localplayer.cnt.move_params.speed_walk; default_swim_speed = _localplayer.cnt.move_params.speed_swim; end; c_model = model; h_model = h; s_model = s; g_model = g; b_model = b; if (not c_model) then c_model = p_model; end; if (c_model ~= p_model) then PlayerIsCustomized = 1; elseif (h or s or g or b) then PlayerIsCustomized = 1; else PlayerIsCustomized = nil; end; return PlayerIsCustomized; end function Customization:Trace(mess) if (mess) then local str = traceStr; traceStr = str.."+"; str = traceStr; traceStr = str..mess; else Hud:AddMessage(traceStr); traceStr = "Trace: "; end end ---------------------------------------------------------------------------- function Customization:GetSWATWeapon() if (Customization:is_SWAT_model(p_model)) then mess = "I'm a S.W.A.T. - I get a Riot Club"; Customization:AddSwatWeapons(); else mess = "You are NOT a S.W.A.T. - No Riot Club"; end Hud:AddMessage("[Cust.]: "..mess); end function Customization:LoseASwatWeapon(Name) if (Name == null) then return; end; for i, Weapon in WeaponClassesEx do if (i == Name) then local CurWeapon = _localplayer.cnt.weapon; _localplayer.cnt:MakeWeaponAvailable(Weapon.id, 0); if (CurWeapon and (CurWeapon == Weapon.id)) then _localplayer.cnt:SelectFirstWeapon(); end; local mess = "[Cust.]: S.W.A.T. "..Name.." confiscated" Hud:AddMessage(mess); return; end end end function Customization:AddSwatWeapons() --AddWeapon("Shocker"); AddWeapon("Monadnock1000"); end function Customization:LoseSwatWeapon() --Name = "Shocker"; Customization:LoseASwatWeapon("Shocker"); Customization:LoseASwatWeapon("Monadnock1000"); end ---------------------------------------------------------------------------- indoor_models = { "objects/characters/mercenaries/indoor_merc/indoor_merc_light.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_elite.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_shield.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_green.cgf", -- 5 "objects/characters/mercenaries/indoor_merc/indoor_merc_green2.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_camo.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy_green.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy_elite.cgf", -- 10 "objects/characters/mercenaries/indoor_merc/indoor_cryo_guard.cgf", "objects/characters/mercenaries/merc_medic/merc_medic_heavy.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_black.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy_black.cgf", "objects/characters/mercenaries/indoor_merc/indoor_merc_red.cgf", -- 15 "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy2.cgf", } function Customization:is_SWAT_model(model) if (not model) then model = p_model; end; for i = 1,12,1 do if ( model == indoor_models[i]) then return i; end; end; return nil; end function Customization:has_backpack( model ) if ( strfind(model, "heavy") ) then return 2; end; if ( strfind(model, "Heavy") ) then return 2; end; if ( strfind(model, "medic") ) then return 1; end; if ( strfind(model, "Medic") ) then return 1; end; if ( strfind(model, "comm.cgf") ) then return 2; end; return 0; end ---------------------------------------------------------------------------- function Customization:CustomizePlayer(model, wantMessage)-- init and change the model if ( allow_change_model ) then if (wantMessage and (wantMessage == 2)) then Game:Save('update_model_game'); Hud:AddMessage("[Cust.]: Game saved, proceeding to customize.."); end; --local force = (model == nil); if (model) then Customization:init(model, h_model, s_model, g_model, b_model); end; if (not PlayerIsCustomized) then return nil; end; p_model = c_model; if ( scripts_version == 0 ) then _localplayer.cnt.model = p_model; _localplayer:LoadCharacter(_localplayer.cnt.model,0); _localplayer["model_loaded"]=1; else _localplayer:LoadCharacter(p_model,0); local nMaterialID=Game:GetMaterialIDByName("mat_flesh"); -- _localplayer:CreateLivingEntity(self.PhysParams, nMaterialID); _localplayer:PhysicalizeCharacter(_localplayer.PhysParams.mass, nMaterialID, _localplayer.BulletImpactParams.stiffness_scale, 0); _localplayer:SetCharacterPhysicParams(0,"", PHYSICPARAM_SIMULATION,_localplayer.BulletImpactParams); -- _localplayer.isPhysicalized = 1; end; end; Customization:UpdateModel(wantMessage); return 1; end function Customization:UpdateModel(wantMessage) -- change the model if ( allow_change_extras ) then local mess = ""; if (h_model) then Customization:SetupModel(h_model, h_slot); mess = mess.." Helmet"; end; if (g_model) then Customization:SetupModel(g_model, g_slot); mess = mess.." Glasses/Goggles"; end; if (b_model) then Customization:SetupModel(b_model, b_slot); mess = mess.." Haircut"; end; if (s_model) then Customization:SetupModel(s_model, s_slot); mess = mess.." Shield"; end; if (Customization:is_SWAT_model( p_model )) then Customization:AddSwatWeapons(); mess = mess.." Riot Club"; end; Customization:AmmendArmorLevel( wantMessage ); if (wantMessage) then Hud:AddMessage("[Cust.]: applied"..mess); end; else Customization:AmmendArmorLevel( wantMessage ); end; end ---------------------------------------------------------------------------- function Customization:AmmendArmorLevel( wantMessage ) if ( not allow_param_changes ) then return; end; ---- adjust armor level ----------------------------------------------------------------------------- local addedArmor = 0; if ( h_model ) then addedArmor = addedArmor + (Customization:GetHelmetProtection( h_model ) * default_max_armor * 0.05); end; if ( s_model ) then addedArmor = addedArmor + (default_max_armor * 0.20); end; if (Customization:is_SWAT_model( p_model )) then addedArmor = addedArmor + (default_max_armor * 0.10); end; _localplayer.cnt.max_armor = default_max_armor + addedArmor; if ( _localplayer.cnt.armor > _localplayer.cnt.max_armor) then _localplayer.cnt.armor = _localplayer.cnt.max_armor; end; if ( ( _localplayer.cnt.armor == default_max_armor ) or ( _localplayer.cnt.armor > default_max_armor ) ) then _localplayer.cnt.armor = _localplayer.cnt.max_armor; -- adjust armor level to VALID maximum end; ---- adjust speed level ---- FROM DEVMODE.LUA ------------------------------------------------------------------------- local speedLoss = 0; if ( Customization:is_SWAT_model( p_model ) ) then speedLoss = speedLoss + 2; end; speedLoss = speedLoss + Customization:has_backpack( p_model ); if ( h_model ) then speedLoss = speedLoss + (Customization:GetHelmetProtection( h_model ) * 1); end; if ( s_model ) then speedLoss = speedLoss + 2; end; if ( speedLoss > 0 ) then Customization:DefaultSpeed(1); Customization:DecreaseSpeed(speedLoss); else Customization:DefaultSpeed(); end; ----------------------------------------------------------------------------------------------------- if ( wantMessage ) then Hud:AddMessage("[Cust.]: applied Extra Armor = "..tostring(addedArmor) .." giving "..tostring(_localplayer.cnt.max_armor)); end; end ---------------------------------------------------------------------------- function Customization:AddWeapon(Name) Game:AddWeapon(Name) for i, CurWeapon in WeaponClassesEx do if (i == Name) then _localplayer.cnt:MakeWeaponAvailable(CurWeapon.id); return; end end end function Customization:LoseWeapon(Name) for i, Weapon in WeaponClassesEx do if (i == Name) then local CurWeapon = _localplayer.cnt.weapon; _localplayer.cnt:MakeWeaponAvailable(Weapon.id, 0); if (CurWeapon and (CurWeapon == Weapon.id)) then _localplayer.cnt:SelectFirstWeapon(); end; return; end end end ---------------------------------------------------------------------------- function Customization:SetupModel(model, slot) if ( not allow_change_extras ) then return; end; if (not model) then return; end; if (not slot) then return; end; _localplayer:LoadObject( model, slot, 1 ); if (slot == s_slot) then _localplayer:AttachObjectToBone( slot, "Bip01 L Hand" ); else _localplayer:AttachObjectToBone( slot, "hat_bone" ); _localplayer:AttachObjectToBone( slot, "hat_bone02" ); end; end function Customization:UnsetModel(slot) if ( not allow_change_extras ) then return; end; if (not slot) then return; end; if (slot == s_slot) then _localplayer:DetachObjectToBone( "Bip01 L Hand" ); else _localplayer:DetachObjectToBone( "hat_bone" ); _localplayer:DetachObjectToBone( "hat_bone02" ); end; _localplayer:DrawObject(slot,0); --param nPos(slot number), nMode(0 = Don't draw, 1 = Draw normally, 3 = Draw near) if (slot == h_slot) then if (g_model) then Customization:SetupModel(g_model, g_slot); end; if (b_model) then Customization:SetupModel(b_model, b_slot); end; elseif (slot == g_slot) then if (h_model) then Customization:SetupModel(h_model, h_slot); end; if (b_model) then Customization:SetupModel(b_model, b_slot); end; elseif (slot == b_slot) then if (g_model) then Customization:SetupModel(g_model, g_slot); end; if (h_model) then Customization:SetupModel(h_model, h_slot); end; elseif (slot == s_slot) then end; end ---------------------------------------------------------------------------- i_index = 0; last_i_index = 0; function Customization:ChangeIndoorModel(arg, noMess) local inc = 1; local model = nil; local mess = ""; local num_models = 17; if ((arg) and (arg < 0)) then inc = -1; end; i_index = inc + i_index; if (i_index <= 0) then i_index = num_models; end; if (i_index > num_models) then i_index = 1; end; if ( i_index == 1 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_light.cgf"; if (Customization:GetHelmetNumber() ~= 1) then Customization:AddHelmet(1); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "Light SWAT Uniform"; elseif ( i_index == 2 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc.cgf"; if (Customization:GetHelmetNumber() ~= 1) then Customization:AddHelmet(1); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "Indoor SWAT Uniform"; elseif ( i_index == 3 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_elite.cgf"; if (Customization:GetHelmetNumber() ~= 2) then Customization:AddHelmet(2); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "Elite SWAT Uniform"; elseif ( i_index == 4 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_elite.cgf"; if (Customization:GetHelmetNumber() ~= 4) then local temp = p_model; p_model = model; Customization:AddHelmet(4); p_model = temp; end; mess = "SWAT Officer Uniform"; elseif ( i_index == 5 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_shield.cgf"; if (Customization:GetHelmetNumber() ~= 1) then Customization:AddHelmet(1); end; if (Customization:GetGlassesNumber() == 7) then Customization:AddGlasses(0); end; mess = "Riot Control SWAT Uniform"; if (not Customization:HasShield()) then Customization:AddShield(1); end; elseif ( i_index == 6 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_black.cgf"; if (Customization:GetHelmetNumber() ~= 7) then Customization:AddHelmet(7); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "Night SWAT Uniform"; elseif ( i_index == 7 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_green.cgf"; if (Customization:GetHelmetNumber() ~= 11) then Customization:AddHelmet(11); end; if (Customization:GetGlassesNumber() == 7) then Customization:AddGlasses(0); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "SWAT green elite Uniform"; elseif ( i_index == 8 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_camo.cgf"; if (Customization:GetHelmetNumber() ~= 3) then Customization:AddHelmet(3); end; if (Customization:GetGlassesNumber() ~= 2) then Customization:AddGlasses(-2, 1); end; mess = "SWAT Camo Uniform"; elseif ( i_index == 9 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_red.cgf"; if (Customization:GetHelmetNumber() ~= 18) then Customization:AddHelmet(18); end; if (Customization:GetGlassesNumber() ~= 2) then Customization:AddGlasses(-2, 1); end; mess = "Red Police Uniform"; elseif ( i_index == 10 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_elite.cgf"; if (Customization:GetHelmetNumber() ~= 10) then Customization:AddHelmet(10); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "SWAT Officer Uniform"; end; --- if ( i_index == 11 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy.cgf"; mess = "Heavy Indoor Merc"; elseif ( i_index == 12 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy_green.cgf"; if (Customization:GetHelmetNumber() ~= 2) then Customization:AddHelmet(2); end; mess = "Heavy Green Indoor Merc"; elseif ( i_index == 13 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy_camo.cgf"; if (Customization:GetHelmetNumber() ~= 3) then Customization:AddHelmet(3); end; if (Customization:GetGlassesNumber() ~= 2) then Customization:AddGlasses(-2, 1); end; mess = "Heavy Camo Indoor Merc"; elseif ( i_index == 14 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy_elite.cgf"; if (Customization:GetHelmetNumber() ~= 10) then Customization:AddHelmet(10); end; mess = "Heavy Elite Indoor Merc"; elseif ( i_index == 15 ) then -- if (Customization:is_SWAT_model()) then Customization:LoseSwatWeapon(); end; model = "objects/characters/mercenaries/merc_medic/merc_medic_heavy.cgf"; if (Customization:GetHelmetNumber() ~= 13) then Customization:AddHelmet(13); end; mess = "Indoor Merc Medic"; elseif ( i_index == 16 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_cryo_guard.cgf"; if (Customization:GetGlassesNumber() ~= 2) then Customization:AddGlasses(-2, 1); end; if (Customization:GetHelmetNumber() ~= 20) then Customization:AddHelmet(20); end; mess = "Indoor Cryogenics Guard"; elseif ( i_index == 17 ) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy_black.cgf"; if (Customization:GetHelmetNumber() ~= 7) then Customization:AddHelmet(7); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "Night SWAT Uniform"; elseif ( i_index == 18) then model = "objects/characters/mercenaries/indoor_merc/indoor_merc_heavy2.cgf"; if (Customization:GetHelmetNumber() ~= 11) then Customization:AddHelmet(11); end; if (Customization:GetGlassesNumber() == 7) then Customization:AddGlasses(0); end; if (Customization:GetGlassesNumber() == 2) then Customization:AddGlasses(0); end; mess = "Test Model"; end; ----- if ( Customization:HasShield() and (last_i_index == 5) and (ShieldOverride == nil) ) then Customization:AddShield(1); -- remove it --if ( _localplayer.Properties.bHasShield ) then _localplayer.Properties.bHasShield = 0; end; --ShieldOverride = nil; --s_model = nil; end; last_i_index = i_index; if (not noMess) then Hud:AddMessage("[Cust.]: "..mess); end; changing_model = 1; Customization:CustomizePlayer(model, (not noMess)); changing_model = 0; end ---------------------------------------------------------------------------- o_index = 0; function Customization:ChangeOutdoorModel(arg, noMess) local model = nil; local inc = 1; local mess = ""; local num_models = 11; if (Customization:is_SWAT_model()) then Customization:LoseSwatWeapon(); if (s_model) then s_model = nil; Customization:UnsetModel(s_slot); if (not noMess) then Hud:AddMessage("[Cust.]: S.W.A.T. Shield, Electro-Cosh, and Club confiscated"); end; end; end; if ((arg) and (arg < 0)) then inc = -1; end; o_index = inc + o_index; if (o_index <= 0) then o_index = num_models; end; if (o_index > num_models) then o_index = 1; end; if ( o_index == 1 ) then model = "objects/characters/pmodels/hero/hero.cgf"; mess = "Jack model"; elseif ( o_index == 2 ) then model = "objects/characters/mercenaries/merc_scout/merc_scout.cgf"; mess = "Scout Merc Uniform"; elseif ( o_index == 3 ) then model = "objects/characters/mercenaries/merc_rear/merc_rear.cgf"; mess = "Rear Merc Uniform"; elseif ( o_index == 4 ) then model = "objects/characters/mercenaries/merc_cover/merc_cover.cgf"; mess = "Cover Merc Uniform"; elseif ( o_index == 5 ) then model = "objects/characters/mercenaries/merc_sniper/merc_sniper.cgf"; mess = "Sniper Merc Uniform"; elseif ( o_index == 6 ) then model = "objects/characters/mercenaries/merc_Offcomm/merc_Offcomm.cgf"; mess = "OffComm Uniform"; elseif ( o_index == 7 ) then model = "objects/characters/workers/evil_worker/evil_worker.cgf"; mess = "Evil Worker suit"; elseif ( o_index == 8 ) then model = "objects/characters/mercenaries/merc_medic/merc_medic_light.cgf"; -- if (Customization:GetHelmetNumber() ~= 13) then Customization:AddHelmet(13); end; mess = "Medic Uniform"; elseif ( o_index == 9 ) then model = "objects/characters/workers/cryo_worker/cryo_worker1.cgf"; if (Customization:GetHelmetNumber() ~= 15) then Customization:AddHelmet(15); end; mess = "Cryo Worker 1 Uniform"; elseif ( o_index == 10 ) then model = "objects/characters/workers/cryo_worker/cryo_worker2.cgf"; if (Customization:GetHelmetNumber() ~= 15) then Customization:AddHelmet(15); end; mess = "Cryo Worker 2 Uniform"; else model = "objects/characters/story_characters/mertz/mertz_ingame.cgf"; mess = "Boss Crow model"; if (h_model) then -- remove any helmet Customization:UnsetModel(h_slot); h_model = nil; end; end; if (not noMess) then Hud:AddMessage("[Cust.]: "..mess); end; Customization:CustomizePlayer(model, 1); end ---------------------------------------------------------------------------- addedHair = nil; function Customization:AddHairCut(param, noMess) local mess; local model_count = 23; if (not addedHair) then addedHair = 0; end; if ( ( not param ) or ( param >= 0 ) ) then addedHair = addedHair + 1; else addedHair = addedHair - 1; end; if ( addedHair < 0 ) then addedHair = model_count; elseif ( addedHair > model_count ) then addedHair = 0; end; b_model = nil; if ( addedHair == 0 ) then -- b_model = "objects/characters/mercenaries/accessories/beard.cgf"; -- mess = "Applied Beard"; elseif ( addedHair == 1 ) then b_model = "objects/characters/mercenaries/accessories/irokez.cgf"; mess = "Applied Head Crest"; elseif ( addedHair == 2 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_crew_cut.cgf"; mess = "Crew Cut"; elseif ( addedHair == 3 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_west_point.cgf"; mess = "West Point Crew Cut"; elseif ( addedHair == 4 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_bare_top.cgf"; mess = "Flat Top haircut"; elseif ( addedHair == 5 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_mohican_narrow.cgf"; mess = "Mohican haircut"; elseif ( addedHair == 6 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_mohican_wide_blond.cgf"; mess = "Blond Mohican wide haircut"; elseif ( addedHair == 7 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_mohican_wide_brown.cgf"; mess = "Brown Mohican wide haircut"; elseif ( addedHair == 8 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_mohican_wide_dark.cgf"; mess = "Dark Mohican wide haircut"; elseif ( addedHair == 9 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_flat_top_blond.cgf"; mess = "Blond Flat Top haircut"; elseif ( addedHair == 10 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_flat_top_brown.cgf"; mess = "Brown Flat Top haircut"; elseif ( addedHair == 11 ) then b_model = "objects/characters/mercenaries/accessories/hair_cut_flat_top_dark.cgf"; mess = "Dark Flat Top haircut"; end; --- -- scatter meshes --- HIGH POLY COUNT ---- -- box hair scatter meshes --- VERY HIGH POLY COUNT ---- -- box hair 4 plane scatter meshes --- ANGLED HAIR, MEDUIM POLY COUNT ---- if ( addedHair == 12 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_west_point_black.cgf"; mess = "West Point black medium poly hairpiece"; elseif ( addedHair == 13 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_west_point_brown.cgf"; mess = "West Point brown medium poly hairpiece"; elseif ( addedHair == 14 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_west_point_blond.cgf"; mess = "West Point blond medium poly hairpiece"; elseif ( addedHair == 15 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_west_point_red.cgf"; mess = "West Point red medium poly hairpiece"; end; --- --- box hair 2 plane scatter meshes --- ANGLED HAIR, MEDUIM POLY COUNT ---- if ( addedHair == 16 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_wide_Black.cgf"; mess = "Black Mohican medium poly wide hairpiece"; elseif ( addedHair == 17 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_wide_Brown.cgf"; mess = "Brown Mohican medium poly wide hairpiece"; elseif ( addedHair == 18 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_wide_Blond.cgf"; mess = "Blond Mohican medium poly wide hairpiece"; elseif ( addedHair == 19 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_wide_Red.cgf"; mess = "Red Mohican medium poly wide hairpiece"; end; ---- if ( addedHair == 20 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_narrow_Black.cgf"; mess = "Black Mohican medium poly narrow hairpiece"; elseif ( addedHair == 21 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_narrow_Brown.cgf"; mess = "Brown Mohican medium poly narrow hairpiece"; elseif ( addedHair == 22 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_narrow_Blond.cgf"; mess = "Blond Mohican medium poly narrow hairpiece"; elseif ( addedHair == 23 ) then b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_mohican_narrow_Red.cgf"; mess = "Red Mohican medium poly narrow hairpiece"; end; ---- -- if ( addedHair == 24 ) then -- b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_Flat_Top_Black.cgf"; -- mess = "Black Flat Top medium poly hairpiece"; -- elseif ( addedHair == 25 ) then -- b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_Flat_Top_Brown.cgf"; -- mess = "Brown Flat Top medium poly hairpiece"; -- elseif ( addedHair == 26 ) then -- b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_Flat_Top_Blond.cgf"; -- mess = "Blond Flat Top medium poly hairpiece"; -- elseif ( addedHair == 27 ) then -- b_model = "objects/characters/mercenaries/accessories/hair_piece_2F_Flat_Top_Red.cgf"; -- mess = "Red Flat Top medium poly hairpiece"; -- end; --- --- COMPOSITE MESH if ( addedHair == 24 ) then b_model = "objects/characters/mercenaries/accessories/hair_Neat_Flat_Top_Black.cgf"; mess = "Neat Black Flat Top high poly hairpiece"; elseif ( addedHair == 25 ) then b_model = "objects/characters/mercenaries/accessories/hair_Neat_Flat_Top_Brown.cgf"; mess = "Neat Brown Flat Top high poly hairpiece"; elseif ( addedHair == 26 ) then b_model = "objects/characters/mercenaries/accessories/hair_Neat_Flat_Top_Blond.cgf"; mess = "Neat Blond Flat Top high poly hairpiece"; elseif ( addedHair == 27 ) then b_model = "objects/characters/mercenaries/accessories/hair_Neat_Flat_Top_Red.cgf"; mess = "Neat Red Flat Top high poly hairpiece"; end; --------------------- if ( b_model == nil ) then addedHair = 0; Customization:UnsetModel(b_slot); mess = "Removed Haircut"; else Customization:SetupModel(b_model, b_slot); end; if (not noMess) then Hud:AddMessage("[Cust.]"..mess); end; end ---------------------------------------------------------------------------- ShieldOverride = nil; function Customization:HasShield() return (s_model ~= nil); end function Customization:AddShield(noMess) if (not Customization:is_SWAT_model()) then if (not noMess) then Hud:AddMessage("[Cust.] - Only SWAT's use Shields"); end; return; end; local mess; if (s_model) then if ( _localplayer.Properties.bHasShield ) then _localplayer.Properties.bHasShield = 0; end; s_model = nil; Customization:UnsetModel(s_slot); if (not noMess) then ShieldOverride = nil; end; mess = "Shield removed"; else if ( _localplayer.Properties.bHasShield ) then _localplayer.Properties.bHasShield = 1; end; s_model = "objects/characters/mercenaries/accessories/shield.cgf"; Customization:SetupModel(s_model, s_slot); if (not noMess) then ShieldOverride = 1; end; mess = "Shield applied"; end; Customization:AmmendArmorLevel(not noMess); if (not noMess) then Hud:AddMessage("[Cust.]"..mess); end; end ---------------------------------------------------------------------------- --glasses_path = "objects/characters/mercenaries/accessories/merc_sniper_glasses.cgf"; glasses_path = "objects/characters/mercenaries/accessories/merc_glasses_clear.cgf"; goggles_path = "objects/characters/mercenaries/accessories/goggles.cgf"; function Customization:GetGlassesNumber() if (g_model == glasses_path) then return 1; elseif (g_model == goggles_path) then return 2; end; return 0; end function Customization:AddGlasses(num, noMess) local mess; local last_model = g_model; if (g_model) then if (g_model == glasses_path) then mess = "Removed Glasses"; else mess = "Removed Goggles"; end; Customization:UnsetModel(g_slot); g_model = nil; end; if (num) then if (num == 0) then return; -- have removed it elseif (abs(num) == 1) then if ((last_model ~= glasses_path) or (num < 0)) then g_model = glasses_path; mess = "Applied Glasses"; end; else if ((last_model ~= goggles_path) or (num < 0)) then g_model = goggles_path; mess = "Applied Goggles"; end; end; else if (last_model == nil) then g_model = glasses_path; mess = "Applied Glasses"; elseif (last_model == glasses_path) then g_model = goggles_path; mess = "Applied Goggles"; else -- Customization:UnsetModel(g_slot); -- g_model = nil; mess = "Removed xxx"; end; end; if (g_model) then Customization:SetupModel(g_model, g_slot); end; if (not noMess) then Hud:AddMessage("[Cust.] "..mess); end; end ---------------------------------------------------------------------------- addedHelmet=0; function Customization:GetHelmetNumber() return addedHelmet; end function Customization:GetHelmetProtection( model ) if ( not model ) then return 0; end; helmet_models = { "objects/characters/mercenaries/accessories/helmet_indoor.cgf", "objects/characters/mercenaries/accessories/helmet.cgf", "objects/characters/mercenaries/accessories/helmet_army_camo.cgf", "objects/characters/mercenaries/accessories/helmet_army.cgf", "objects/characters/mercenaries/accessories/cryohelmet.cgf", -- 5 "objects/characters/mercenaries/accessories/cryohelmet1.cgf", "objects/characters/mercenaries/accessories/cryohelmet2.cgf", "objects/characters/mercenaries/accessories/helm_blue.cgf", -- 8 }; local max_helmet_models = 8; for i = 1,max_helmet_models,1 do if ( model == helmet_models[i] ) then return 1; end; end; return 0; end function Customization:AddHelmet(h_num) local mess = ""; local doMess = 1; local max_helmets = 21; if (not addedHelmet) then addedHelmet = 0; end; if (h_num) then if (h_num >= 0) then -- request a set helmet if (h_num > max_helmets) then Hud:AddMessage("[Cust.]: Out of range helmet number"); return; end; addedHelmet = h_num; doMess = nil; else -- (h_num < 0) so cycle in reverse through helmets addedHelmet = addedHelmet-1; if (addedHelmet < 0) then addedHelmet = max_helmets; end; end; else -- cycle forward through helmets if ( ( p_model == "objects/characters/story_characters/mertz/mertz_ingame.cgf" ) or ( p_model == "objects/characters/story_characters/mertz/mertz_MP.cgf" ) ) then Hud:AddMessage("[Cust.]: different helmet not allowed"); return; end; addedHelmet = 1+addedHelmet; end; -- first clean up any prior stuff if (h_model) then Customization:UnsetModel(h_slot); end; ------------------------------------ -- now reset to defaults h_model = nil; _localplayer.hasHelmet = 1; _localplayer.Properties.bHelmetOnStart = 0; _localplayer.PropertiesInstance.bHelmetProtection = 1; ------------------------------------ if ( addedHelmet == 1 ) then h_model = "objects/characters/mercenaries/accessories/helmet_indoor.cgf"; mess = "Riot Helmet"; elseif ( addedHelmet == 2 ) then h_model = "objects/characters/mercenaries/accessories/helmet.cgf"; mess = "SWAT helmet"; elseif ( addedHelmet == 3 ) then h_model = "objects/characters/mercenaries/accessories/helmet_army_camo.cgf"; mess = "Camo Helmet"; elseif ( addedHelmet == 4 ) then if (Customization:is_SWAT_model()) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hat.cgf"; -- is wider, potentially bugged else h_model = "objects/characters/mercenaries/accessories/merc_offcomm_hat.cgf"; -- is narrower end; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Officer Cap"; elseif ( addedHelmet == 5 ) then h_model = "objects/characters/mercenaries/accessories/merc_cover_hat.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Merc Cover Beret"; elseif ( addedHelmet == 6 ) then h_model = "objects/characters/mercenaries/accessories/merc_rear_hat.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Merc Rear Hat"; elseif ( addedHelmet == 7 ) then h_model = "objects/characters/mercenaries/accessories/helmet_nightvis.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Night Vision Helmet"; elseif ( addedHelmet == 8 ) then h_model = "objects/characters/mercenaries/accessories/helmet_army.cgf"; mess = "Army Helmet"; elseif ( addedHelmet == 9 ) then -- Boss Crow has too big a head mesh h_model = "objects/characters/story_characters/mertz/mertz_hat.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Stetson"; elseif ( addedHelmet == 10 ) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hatT.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Trigen Officer Cap"; end; ----- if ( addedHelmet == 11 ) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hatT_green.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Trigen Green Cap"; elseif ( addedHelmet == 12 ) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hatT_camo.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Camo Cap"; elseif ( addedHelmet == 13 ) then h_model = "objects/characters/mercenaries/accessories/merc_medic_hatT.cgf"; _localplayer.PropertiesInstance.bHelmetProtection = 0; mess = "Medics Cap"; elseif ( addedHelmet == 14 ) then h_model = "objects/characters/mercenaries/accessories/evil_worker_hat.cgf"; mess = "Evil Worker Cap"; elseif ( addedHelmet == 15 ) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hatT_cryo.cgf"; mess = "Cryogenics Cap"; elseif ( addedHelmet == 16 ) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hatT_blue.cgf"; mess = "Blue Cap"; elseif ( addedHelmet == 17 ) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hatT_black.cgf"; mess = "Black Cap"; elseif ( addedHelmet == 18 ) then h_model = "objects/characters/mercenaries/accessories/merc_defcomm_hatT_red.cgf"; mess = "Red Cap"; elseif ( addedHelmet == 19 ) then h_model = "objects/characters/mercenaries/accessories/cryohelmet1.cgf"; mess = "Cryo Guard Helmet"; elseif ( addedHelmet == 20 ) then h_model = "objects/characters/mercenaries/accessories/cryohelmet2.cgf"; mess = "Cryo Guard / Cryo Body Helmet"; elseif ( addedHelmet == 21 ) then h_model = "objects/characters/mercenaries/accessories/helm_blue.cgf"; mess = "Blue Helmet"; end; if ( (addedHelmet == 0) or (addedHelmet > max_helmets) ) then addedHelmet = 0; _localplayer.hasHelmet = 0; _localplayer.Properties.bHelmetOnStart = 0; _localplayer.PropertiesInstance.bHelmetProtection = 0; if (doMess) then Hud:AddMessage("[Cust.]: Removed Headwear"); end; else Customization:SetupModel(h_model, h_slot); _localplayer.Properties.bHelmetOnStart = _localplayer.hasHelmet; if (doMess) then Hud:AddMessage("[Cust.]: Applied "..mess); end; end Customization:AmmendArmorLevel(1); end ---------------------------------------------------------------------------- function Customization:DumpData(no_func) local f = openfile("DumpData.txt","w"); if (f == nil) then Hud:AddMessage("Error opening DumpData file"); return; end; Hud:AddMessage("Dumping file DumpData"); local _class = _localplayer; write(f,"Dump Start\n"); g_dump_tabs=0; Customization:dump(f,_class,no_func); write(f,"\nDump End\n"); closefile(f); Hud:AddMessage("file DumpData dumped"); end g_dump_tabs=0; function Customization:dump(f,_class,no_func) if not _class then write(f, " nil","\n"); else local str=""; for n=0,g_dump_tabs,1 do str=str.." "; end for i,field in _class do -- Hud:AddMessage("Loop "..tostring(i)); if(type(field)=="table") then g_dump_tabs=g_dump_tabs+1; write(f, str.." "..i.." = {","\n"); Customization:dump(f,field,no_func); write(f, str.." }","\n"); g_dump_tabs=g_dump_tabs-1; else if(type(field)=="number" ) then write(f, " "..str.." "..i.." = "..field,"\n"); elseif(type(field) == "string") then write(f, " "..str.." "..i.." = ".."\""..field.."\"","\n"); else if(not no_func)then if(type(field)=="function")then write(f," "..str.." "..i.."()","\n"); else write(f," "..str.." "..i.." ","\n"); end end end end end end end ---------------------------------------------------------------------------- fileh = nil; function Customization:GetLine(f) local line = read(f); if (line == nil) then return nil; end; local index = strfind(line, "\""); if (index == nil) then return nil; end; local path = strsub(line, index); if (path == nil) then return nil; end; if (strlen(path) == 0) then path = nil; end; return path; end; function Customization:GetPath(f) local line = read(f); if (line == nil) then return nil; end; local index = strfind(line, "\""); if (index == nil) then return nil; end; local path = strsub(line, index+1, -2); if (path == nil) then return nil; end; if (strlen(path) == 0) then path = nil; end; return path; end; function Customization:LoadData(mess) if (fileh) then flush(fileh); closefile(fileh); end; fileh = openfile("CustPlayerData.txt", "r"); if (not fileh) then if (mess) then Hud:AddMessage("File Open failed"); end; return nil; end; --if (mess) then Hud:AddMessage("File Open Ok"); end; local model, path, index = nil, nil, 0; path = Customization:GetLine(fileh); if (path) then index = strfind(path, "\"", 2); model = strsub(path, 2, index-1); if (model and (strlen(model) == 0)) then model = nil; end; if (model) then --Hud:AddMessage("MODEL = "..model); local line = strsub(path, index+2); if (line) then --Hud:AddMessage("LINE = "..line); index = strfind(line, " "); if (index) then local temp1 = strsub(line,1, index-1); local temp2 = strsub(line, index+1); --Hud:AddMessage("INDEX = ["..temp1.."][ "..temp2.."]"); if (temp1) then i_index = tonumber(temp1); last_i_index = i_index; end; if (temp2) then o_index = tonumber(temp2); end; --Hud:AddMessage("INDEX = ["..tostring(i_index).."][ "..tostring(o_index).."]"); end; end; end; end; if (not model) then if (mess) then Hud:AddMessage("Data File empty"); end; closefile(fileh); fileh = nil; return nil; end; --Hud:AddMessage("MODEL = "..model..", "..tostring(i_index)..", "..tostring(o_index)); ----------------------- path = Customization:GetLine(fileh); if (path) then index = strfind(path, "\"", 2); h_model = strsub(path, 2, index-1); if (h_model and (strlen(h_model) == 0)) then h_model = nil; end; local temp = strsub(path, index+2); if (temp) then addedHelmet = tonumber(temp); end; end; --Hud:AddMessage("HELMET = "..h_model..", "..tostring(addedHelmet)); -------------------------- path = Customization:GetPath(fileh); --if (s_model) then AddShield(1); end; s_model = path; --------------------------- path = Customization:GetPath(fileh); --if (g_model) then AddGlasses(nil, 1); end; g_model = path; -------------------------- path = Customization:GetPath(fileh); --if (b_model) then AddHairCut(nil, 1); end; b_model = path; ---------------------------- closefile(fileh); fileh = nil; --if (mess) then Hud:AddMessage("Customization Data Read In"); end; local result = Customization:CustomizePlayer(model,1); if (mess) then if (result) then Hud:AddMessage("Customization Data Loaded"); else Hud:AddMessage("Customization Data Load FAILED"); end; end; return result; end ----------------------------------------------------------------- function Customization:SaveData(mess) if (not fileh) then fileh = openfile("CustPlayerData.txt", "w+"); if (not fileh) then if (mess) then Hud:AddMessage("File Open failed"); end; return nil; end; else seek(fileh, "set", 0); end; local s, t; s = format("p_model = %q %i %i\n", p_model, i_index, o_index); write(fileh, s); if (h_model) then t = h_model; else t=""; end; s = format("h_model = %q %i\n", t, addedHelmet); write(fileh, s); if (s_model) then t = s_model; else t=""; end; s = format("s_model = %q\n", t); write(fileh, s); if (g_model) then t = g_model; else t=""; end; s = format("g_model = %q\n", t); write(fileh, s); if (b_model) then t = b_model; else t=""; end; s = format("b_model = %q\n", t); write(fileh, s); flush(fileh); --closefile(fileh); fileh = nil; if (mess) then Hud:AddMessage("Customization Data Saved"); end; return 1; end ---------------------------------------------------------------------------- Input:BindCommandToKey("#Customization:GetSWATWeapon()","i",1); Input:BindCommandToKey("#Customization:AddHelmet(nil)","=",1); Input:BindCommandToKey("#Customization:AddHelmet(-1)","-",1); Input:BindCommandToKey("#Customization:AddGlasses(1,nil)",".",1); Input:BindCommandToKey("#Customization:AddGlasses(2,nil)",">",1); Input:BindCommandToKey("#Customization:AddShield(nil)",",",1); Input:BindCommandToKey("#Customization:AddHairCut(1,nil)","'",1); Input:BindCommandToKey("#Customization:AddHairCut(-1,nil)",";",1); Input:BindCommandToKey("#Customization:ChangeIndoorModel(-1,nil)","[",1); Input:BindCommandToKey("#Customization:ChangeIndoorModel(1,nil)","]",1); Input:BindCommandToKey("#Customization:ChangeIndoorModel(-1,nil)","{",1); Input:BindCommandToKey("#Customization:ChangeIndoorModel(1,nil)","}",1); Input:BindCommandToKey("#Customization:ChangeOutdoorModel(-1,ni)","(",1); Input:BindCommandToKey("#Customization:ChangeOutdoorModel(1,nil)",")",1); --Input:BindCommandToKey("#Customization:UpdateModel(1)","m",1); --Input:BindCommandToKey("#Customization:Trace()","#",1); Input:BindCommandToKey("#Customization:LoadData(1)","~",1); Input:BindCommandToKey("#Customization:SaveData(1)","#",1); Input:BindCommandToKey("#Customization:DumpData()","*",1); ----------------------------------------------------------------------------