• I need to fix a T pose...
    7 replies, posted
Alright, I'm pretty sure there is a much easier way to do what I'm trying to do... and maybe even a way that works better, I probably could have done better if I had reviewed the inflator tool's code. I'm almost embarrassed to post my yet-to-be-finished code for this... but I can't figure out a way to fix this. When I try to draw the Player's model in GM/PrePlayerDraw or in GM/PostPlayerDraw it crashes the game. Here's an image of my problem: https://files.facepunch.com/forum/upload/337562/15f91731-d05c-4eec-aeaa-83598248c615/20181201142348_11.jpg and here is the entire Lua file's code: --[[ Armor for body parts: Head Chest Gut Left Arm Right Arm Left Leg Right Leg 7 parts means I need a bitflag that can cover 7 values. 0000000 1111111 111 011 001 101 010 100 110 ]] local PLAYER = FindMetaTable( "Player" ) CreateConVar( "ddl_bodyarmor_base", "50", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "INTEGER - For BodyArmor powerup, the base armor health value." ) CreateConVar( "ddl_bodyarmor_limb", "0.6", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, the default mult for arm and leg armor health." ) CreateConVar( "ddl_bodyarmor_head", "0.8", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, the default mult for helmet armor health." ) CreateConVar( "ddl_bodyarmor_body", "1.0", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, the default mult for chest and gut armor health." ) CreateConVar( "ddl_bodyarmor_rebel", "0.4", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, type 0 (Rebel) base value scalar." ) CreateConVar( "ddl_bodyarmor_metro", "0.6", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, type 1 (Metro) base value scalar." ) CreateConVar( "ddl_bodyarmor_troop", "0.8", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, type 2 (Soldier) base value scalar." ) CreateConVar( "ddl_bodyarmor_guard", "1.0", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, type 2 (PrisonGuard) base value scalar." ) CreateConVar( "ddl_bodyarmor_elite", "2.0", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "FLOAT - For BodyArmor powerup, type 2 (Elite Soldier) base value scalar." ) CreateConVar( "ddl_bodyarmor_dtype", "0", FCVAR_NOTIFY+FCVAR_SERVER_CAN_EXECUTE+FCVAR_REPLICATED+FCVAR_ARCHIVE, "INTEGER - For BodyArmor powerup, what is the default armor type if not specified when acquired?" ) hook.Add( "PlayerSpawn", "ddl_init_ba_system", function(ply) local pData = { ["pLeftArm" ] = 10 , ["pRiteArm" ] = 10 , ["pLeftLeg" ] = 10 , ["pRiteLeg" ] = 10 , ["pVisor" ] = 0 , ["pChest" ] = 10 , ["pBelly" ] = 10 } local pDataJSON = util.TableToJSON( pData ) ply:SetNWString( "ddl_pdata_ba", pDataJSON ) end ) --function PLAYER:EquipBodyArmor(tParts,bForce) function PLAYER:EquipBodyArmor( fMagnitudeTorso, fMagnitudeHeads, fMagnitudeLimbs, iType, bNoHelmet ) local defaultType = GetConVar("ddl_bodyarmor_dtype"):GetInt() or 0 if type(fMagnitudeTorso) != "number" then fMagnitudeTorso = nil end if type(fMagnitudeHeads) != "number" then fMagnitudeHeads = nil end if type(fMagnitudeLimbs) != "number" then fMagnitudeLimbs = nil end if type(iType) != "number" then iType = defaultType else iType = math.Clamp( math.floor( iType ), 0, 4 ) end if bNoHelmet && type(bNoHelmet) !="boolean" then bNoHelmet = true end -- if bNoHelmet is set, but it's not a boolean value (true or false), then force it to be false. If it's not set, it will be true. --[[  Armor Types  ]]-- --     0 = Rebel     -- --     1 = Metro     -- --    2 = Soldier    -- --  3 = PrisonGuard  -- -- 4 = Elite Soldier -- local scalarRebel = GetConVar("ddl_bodyarmor_rebel"):GetFloat() or 0.4 local scalarMetro = GetConVar("ddl_bodyarmor_metro"):GetFloat() or 0.6 local scalarTroop = GetConVar("ddl_bodyarmor_troop"):GetFloat() or 0.8 local scalarGuard = GetConVar("ddl_bodyarmor_guard"):GetFloat() or 1.0 local scalarElite = GetConVar("ddl_bodyarmor_elite"):GetFloat() or 2.0 local scalarTable = { [0] = scalarRebel, [1] = scalarMetro, [2] = scalarTroop, [3] = scalarGuard, [4] = scalarElite } local fScalar = scalarTable[iType] local baseVar = GetConVar("ddl_bodyarmor_base"):GetInt() or 50 baseVar = math.floor( baseVar * fScalar ) local bodyVar = GetConVar("ddl_bodyarmor_body"):GetFloat() or 1.0 local headVar = GetConVar("ddl_bodyarmor_head"):GetFloat() or 0.8 local limbVar = GetConVar("ddl_bodyarmor_limb"):GetFloat() or 0.6 if iType == 0 or bNoHelmet then headVar = 0 end -- BodyArmor type 0 has no helmet fMagnitudeTorso = fMagnitudeTorso or bodyVar -- If base == 50 then 1.0 = 50 fMagnitudeHeads = fMagnitudeHeads or headVar -- If base == 50 then 0.8 = 40 fMagnitudeLimbs = fMagnitudeLimbs or limbVar -- If base == 50 then 0.6 = 30 local pData = { -- Default Values are set here ["pLeftArm" ] = math.Clamp( math.ceil( baseVar*fMagnitudeLimbs ), 0, ( baseVar * 4 ) ) , ["pRiteArm" ] = math.Clamp( math.ceil( baseVar*fMagnitudeLimbs ), 0, ( baseVar * 4 ) ) , ["pLeftLeg" ] = math.Clamp( math.ceil( baseVar*fMagnitudeLimbs ), 0, ( baseVar * 4 ) ) , ["pRiteLeg" ] = math.Clamp( math.ceil( baseVar*fMagnitudeLimbs ), 0, ( baseVar * 4 ) ) , ["pVisor" ] = math.Clamp( math.ceil( baseVar*fMagnitudeHeads ), 0, ( baseVar * 4 ) ) , ["pChest" ] = math.Clamp( math.ceil( baseVar*fMagnitudeTorso ), 0, ( baseVar * 4 ) ) , ["pBelly" ] = math.Clamp( math.ceil( baseVar*fMagnitudeTorso ), 0, ( baseVar * 4 ) ) } local pDataJSON = util.TableToJSON( pData ) ply:SetNWString( "ddl_pdata_ba", pDataJSON ) ply:SetNWInt( "ddl_pdata_ba_type", iType ) end -- Draw BodyArmor Scale BaseModel -- hook.Add( "PrePlayerDraw" , "ddl_draw_ba_scale_bm" , function( ply ) hook.Add( "PostDrawTranslucentRenderables" , "ddl_draw_ba_scale_bm" , function() if CLIENT then local ply = LocalPlayer() -- ToDo: Force a Player's model to an appropriate "dead" model if they die. local DeadModel = { ["name"] = "models/player/skeleton.mdl", ["burn"] = "models/player/charple.mdl", ["skin"] = 2, -- Default skin for dead skeleton. ["vape"] = 1 -- Skin if death was caused by dissolve damage. } -- Skin 0 is a clean-ish yellow skeleton. Skin 3 is a spotty or dirty skeleton that looks like it's been dead for a while. local pDataDefault = util.TableToJSON( { ["pLeftArm" ] = 10 , ["pRiteArm" ] = 10 , ["pLeftLeg" ] = 10 , ["pRiteLeg" ] = 10 , ["pVisor" ] = 0 , ["pChest" ] = 10 , ["pBelly" ] = 10 } ) local ddl_pdata_ba = util.JSONToTable( ply:GetNWString( "ddl_pdata_ba", pDataDefault ) ) local ddl_pdata_ba_type = ply:GetNWInt("ddl_pdata_ba_type",0) -- Find the index for important bones -- Head Armor -- local head = ply:LookupBone( "ValveBiped.Bip01_Head1" ) local neck = ply:LookupBone( "ValveBiped.Bip01_Neck1" ) local hchild = ply:GetChildBones( neck ) -- Chest Armor local spine2 = ply:LookupBone( "ValveBiped.Bip01_Spine2" ) local spine4 = ply:LookupBone( "ValveBiped.Bip01_Spine4" ) local clavR = ply:LookupBone( "ValveBiped.Bip01_R_Clavicle" ) local clavL = ply:LookupBone( "ValveBiped.Bip01_L_Clavicle" ) -- Gut Armor local spine = ply:LookupBone( "ValveBiped.Bip01_Spine" ) local spine1 = ply:LookupBone( "ValveBiped.Bip01_Spine1" ) local pussy = ply:LookupBone( "ValveBiped.Bip01_Pelvis" ) -- Right Arm Armor local uparmR = ply:LookupBone( "ValveBiped.Bip01_R_UpperArm" ) local handsR = ply:LookupBone( "ValveBiped.Bip01_R_Hand" ) local RAchil = ply:GetChildBones( uparmR ) local RHchil = ply:GetChildBones( handsR ) -- Left Arm Armor local uparmL = ply:LookupBone( "ValveBiped.Bip01_L_UpperArm" ) local handsL = ply:LookupBone( "ValveBiped.Bip01_L_Hand" ) local LAchil = ply:GetChildBones( uparmL ) local LHchil = ply:GetChildBones( handsL ) -- Right Leg Armor local uplegR = ply:LookupBone( "ValveBiped.Bip01_R_Thigh" ) local feetsR = ply:LookupBone( "ValveBiped.Bip01_R_Foot" ) local RLchil = ply:GetChildBones( uplegR ) -- Left Leg Armor local uplegL = ply:LookupBone( "ValveBiped.Bip01_L_Thigh" ) local feetsL = ply:LookupBone( "ValveBiped.Bip01_L_Foot" ) local LLchil = ply:GetChildBones( uplegL ) -- HEAD -- if ddl_pdata_ba["pVisor"] > 0 then -- ply:ManipulateBoneScale( head, Vector(0,0,0) ) ply:ManipulateBoneScale( neck, Vector(0,0,0) ) for k, v in pairs(hchild) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) -- print( "Head BA - Scaling x0 child bone: "..ply:GetBoneName(v) ) end else -- ply:ManipulateBoneScale( head, Vector(1,1,1) ) ply:ManipulateBoneScale( neck, Vector(1,1,1) ) for k, v in pairs(hchild) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) -- print( "Head BA - Scaling x1 child bone: "..ply:GetBoneName(v) ) end end -- CHEST AND GUT -- if ddl_pdata_ba["pChest"] > 0 then ply:ManipulateBoneScale( spine2, Vector(0,0,0) ) ply:ManipulateBoneScale( spine4, Vector(0,0,0) ) ply:ManipulateBoneScale( clavL , Vector(0,0,0) ) ply:ManipulateBoneScale( clavR , Vector(0,0,0) ) else ply:ManipulateBoneScale( spine2, Vector(1,1,1) ) ply:ManipulateBoneScale( spine4, Vector(1,1,1) ) ply:ManipulateBoneScale( clavL , Vector(1,1,1) ) ply:ManipulateBoneScale( clavR , Vector(1,1,1) ) end if ddl_pdata_ba["pBelly"] > 0 then ply:ManipulateBoneScale( spine , Vector(0,0,0) ) ply:ManipulateBoneScale( spine1, Vector(0,0,0) ) ply:ManipulateBoneScale( pussy , Vector(0,0,0) ) else ply:ManipulateBoneScale( spine , Vector(1,1,1) ) ply:ManipulateBoneScale( spine1, Vector(1,1,1) ) ply:ManipulateBoneScale( pussy , Vector(1,1,1) ) end -- ARMS -- if ddl_pdata_ba["pLeftArm"] > 0 then ply:ManipulateBoneScale( uparmL, Vector(0,0,0) ) ply:ManipulateBoneScale( handsL, Vector(1,1,1) ) for k, v in pairs(LAchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end for k, v in pairs(LHchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end else ply:ManipulateBoneScale( uparmL, Vector(1,1,1) ) ply:ManipulateBoneScale( handsL, Vector(1,1,1) ) for k, v in pairs(LAchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end for k, v in pairs(LHchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end end if ddl_pdata_ba["pRiteArm"] > 0 then ply:ManipulateBoneScale( uparmR, Vector(0,0,0) ) ply:ManipulateBoneScale( handsR, Vector(1,1,1) ) for k, v in pairs(RAchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end for k, v in pairs(RHchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end else ply:ManipulateBoneScale( uparmR, Vector(1,1,1) ) ply:ManipulateBoneScale( handsR, Vector(1,1,1) ) for k, v in pairs(RAchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end for k, v in pairs(RHchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end end -- LEGS -- if ddl_pdata_ba["pLeftLeg"] > 0 then ply:ManipulateBoneScale( uplegL, Vector(0,0,0) ) ply:ManipulateBoneScale( feetsL, Vector(0,0,0) ) for k, v in pairs(LLchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end else ply:ManipulateBoneScale( feetsL, Vector(1,1,1) ) ply:ManipulateBoneScale( uplegL, Vector(1,1,1) ) for k, v in pairs(LLchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end end if ddl_pdata_ba["pRiteLeg"] > 0 then ply:ManipulateBoneScale( uplegR, Vector(0,0,0) ) ply:ManipulateBoneScale( feetsR, Vector(0,0,0) ) for k, v in pairs(RLchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end else ply:ManipulateBoneScale( feetsR, Vector(1,1,1) ) ply:ManipulateBoneScale( uplegR, Vector(1,1,1) ) for k, v in pairs(RLchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end end -- ply:InvalidateBoneCache() -- ply:SetupBones() ply:DrawModel() -- ply:InvalidateBoneCache() ply:ddl_DrawArmorModel() -- return true end end ) -- Draw BodyArmor Models function PLAYER:ddl_DrawArmorModel() if CLIENT then local ply = LocalPlayer() local LastPlyModel = ply:GetModel() local pDataDefault = util.TableToJSON( { ["pLeftArm" ] = 10 , ["pRiteArm" ] = 10 , ["pLeftLeg" ] = 10 , ["pRiteLeg" ] = 10 , ["pVisor" ] = 0 , ["pChest" ] = 10 , ["pBelly" ] = 10 } ) local ddl_pdata_ba = util.JSONToTable( ply:GetNWString( "ddl_pdata_ba", pDataDefault ) ) local ddl_pdata_ba_type = ply:GetNWInt("ddl_pdata_ba_type",0) local tBodyArmorModels = { [0] = "models/player/group03/male_05.mdl", [1] = "models/player/police.mdl", [2] = "models/player/combine_soldier.mdl", [3] = "models/player/combine_soldier_prisonguard.mdl", [4] = "models/player/combine_super_soldier.mdl" } -- 0 = Rebel = models/player/group03/male_05.mdl -- 1 = Metrocop = models/player/police.mdl -- 2 = Soldier = models/player/combine_soldier.mdl -- 3 = Prisonguard = models/player/combine_soldier_prisonguard.mdl -- 4 = Elite Soldier = models/player/combine_super_soldier.mdl local ArmorModel = "models/player/group03/male_05.mdl" ArmorModel = tBodyArmorModels[ddl_pdata_ba_type] -- Find the index for important bones -- Head Armor -- local head = ply:LookupBone( "ValveBiped.Bip01_Head1" ) local neck = ply:LookupBone( "ValveBiped.Bip01_Neck1" ) local hchild = ply:GetChildBones( neck ) -- Chest Armor local spine2 = ply:LookupBone( "ValveBiped.Bip01_Spine2" ) local spine4 = ply:LookupBone( "ValveBiped.Bip01_Spine4" ) local clavR = ply:LookupBone( "ValveBiped.Bip01_R_Clavicle" ) local clavL = ply:LookupBone( "ValveBiped.Bip01_L_Clavicle" ) -- Gut Armor local spine = ply:LookupBone( "ValveBiped.Bip01_Spine" ) local spine1 = ply:LookupBone( "ValveBiped.Bip01_Spine1" ) local pussy = ply:LookupBone( "ValveBiped.Bip01_Pelvis" ) -- Right Arm Armor local uparmR = ply:LookupBone( "ValveBiped.Bip01_R_UpperArm" ) local handsR = ply:LookupBone( "ValveBiped.Bip01_R_Hand" ) local RAchil = ply:GetChildBones( uparmR ) local RHchil = ply:GetChildBones( handsR ) -- Left Arm Armor local uparmL = ply:LookupBone( "ValveBiped.Bip01_L_UpperArm" ) local handsL = ply:LookupBone( "ValveBiped.Bip01_L_Hand" ) local LAchil = ply:GetChildBones( uparmL ) local LHchil = ply:GetChildBones( handsL ) -- Right Leg Armor local uplegR = ply:LookupBone( "ValveBiped.Bip01_R_Thigh" ) local feetsR = ply:LookupBone( "ValveBiped.Bip01_R_Foot" ) local RLchil = ply:GetChildBones( uplegR ) -- Left Leg Armor local uplegL = ply:LookupBone( "ValveBiped.Bip01_L_Thigh" ) local feetsL = ply:LookupBone( "ValveBiped.Bip01_L_Foot" ) local LLchil = ply:GetChildBones( uplegL ) -- HEAD -- if ddl_pdata_ba["pVisor"] > 0 then -- ply:ManipulateBoneScale( head, Vector(0,0,0) ) ply:ManipulateBoneScale( neck, Vector(1,1,1) ) for k, v in pairs(hchild) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) -- print( "Head BA - Scaling x0 child bone: "..ply:GetBoneName(v) ) end else -- ply:ManipulateBoneScale( head, Vector(1,1,1) ) ply:ManipulateBoneScale( neck, Vector(0,0,0) ) for k, v in pairs(hchild) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) -- print( "Head BA - Scaling x1 child bone: "..ply:GetBoneName(v) ) end end -- CHEST AND GUT -- if ddl_pdata_ba["pChest"] > 0 then ply:ManipulateBoneScale( spine2, Vector(1,1,1) ) ply:ManipulateBoneScale( spine4, Vector(1,1,1) ) ply:ManipulateBoneScale( clavL , Vector(1,1,1) ) ply:ManipulateBoneScale( clavR , Vector(1,1,1) ) else ply:ManipulateBoneScale( spine2, Vector(0,0,0) ) ply:ManipulateBoneScale( spine4, Vector(0,0,0) ) ply:ManipulateBoneScale( clavL , Vector(0,0,0) ) ply:ManipulateBoneScale( clavR , Vector(0,0,0) ) end if ddl_pdata_ba["pBelly"] > 0 then ply:ManipulateBoneScale( spine , Vector(1,1,1) ) ply:ManipulateBoneScale( spine1, Vector(1,1,1) ) ply:ManipulateBoneScale( pussy , Vector(1,1,1) ) else ply:ManipulateBoneScale( spine , Vector(0,0,0) ) ply:ManipulateBoneScale( spine1, Vector(0,0,0) ) ply:ManipulateBoneScale( pussy , Vector(0,0,0) ) end -- ARMS -- if ddl_pdata_ba["pLeftArm"] > 0 then ply:ManipulateBoneScale( uparmL, Vector(1,1,1) ) ply:ManipulateBoneScale( handsL, Vector(1,1,1) ) for k, v in pairs(LAchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end for k, v in pairs(LHchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end else ply:ManipulateBoneScale( uparmL, Vector(0,0,0) ) ply:ManipulateBoneScale( handsL, Vector(0,0,0) ) for k, v in pairs(LAchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end for k, v in pairs(LHchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end end if ddl_pdata_ba["pRiteArm"] > 0 then ply:ManipulateBoneScale( uparmR, Vector(1,1,1) ) ply:ManipulateBoneScale( handsR, Vector(1,1,1) ) for k, v in pairs(RAchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end for k, v in pairs(RHchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end else ply:ManipulateBoneScale( uparmR, Vector(0,0,0) ) ply:ManipulateBoneScale( handsR, Vector(0,0,0) ) for k, v in pairs(RAchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end for k, v in pairs(RHchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end end -- LEGS -- if ddl_pdata_ba["pLeftLeg"] > 0 then ply:ManipulateBoneScale( uplegL, Vector(1,1,1) ) ply:ManipulateBoneScale( feetsL, Vector(1,1,1) ) for k, v in pairs(LLchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end else ply:ManipulateBoneScale( feetsL, Vector(0,0,0) ) ply:ManipulateBoneScale( uplegL, Vector(0,0,0) ) for k, v in pairs(LLchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end end if ddl_pdata_ba["pRiteLeg"] > 0 then ply:ManipulateBoneScale( uplegR, Vector(1,1,1) ) ply:ManipulateBoneScale( feetsR, Vector(1,1,1) ) for k, v in pairs(RLchil) do ply:ManipulateBoneScale( v, Vector(1,1,1) ) end else ply:ManipulateBoneScale( feetsR, Vector(0,0,0) ) ply:ManipulateBoneScale( uplegR, Vector(0,0,0) ) for k, v in pairs(RLchil) do ply:ManipulateBoneScale( v, Vector(0,0,0) ) end end -- ply:InvalidateBoneCache() -- ply:SetupBones() ply:SetModel(ArmorModel) ply:DrawModel() -- ply:InvalidateBoneCache() ply:SetModel(LastPlyModel) end end Please help
The reason it is crashing is because drawing a player in Pre/PostPlayerDraw causes an infinite loop, correct me if I am wrong.
I figured that was why, which is why in the code I posted... that's not how I'm doing it. However, I think this is why I'm T-Posing
Can you explain more in-depth what you want to do? I assume its wearing parts of 'armor'.
You assume right, but I'll go into more detail. I want to create individual armor for certain regions of a player's body. Left arm, right arm, left leg, right leg, gut, chest and head. I'll modify my hooks handling damage so that, as long as a body part has more than 0 points of this type of armor, the armor value will change while the player takes no real damage. I want to illustrate what parts still have armor by hiding that part of the player's base model, and showing the respective armor model's part instead. I plan for 5 types of armor; Basic Rebel armor, no helmet. Metrocop Armor, with helmet. Combine Soldier Armor, with helmet. Prison Guard Armor, with helmet. Elite Soldier Armor, with helmet. I have scalars for the base assumed armor strengths of each, and I've created convars to control those values, for testing purposes. So, the reason I want to draw the player twice, with two different models, is to illustrate this armor. For some reason, doing this in PostDrawTranslucentRenderables is forcing a T-Pose.
Okay I've found at least one thing out. When I call the function that draws the armor player model that's when I T-pose. So... when I do ply:ddl_DrawArmorModel() I T-pose. It's being called within a GM/PostDrawTranslucentRenderables hook So I'm assuming the problem has something to do with the following code snippet; -- ply:InvalidateBoneCache() ply:SetupBones() ply:SetModel(ArmorModel) ply:DrawModel() -- ply:InvalidateBoneCache() ply:SetModel(LastPlyModel) I wonder what I'm doing wrong, what I should be doing...
What you probably want is to bonemerge the armor onto the player and draw that. Toy around with Entity/AddEffects using EF_BONEMERGE or EF_BONEMERGE_FASTCULL. You will need to set the Player as the ClientsideModel (armor)'s parent using armor:SetParent(ply). That will basically put the armor model onto the player as long as the bone names match (which they do). However, I am not sure if changing the bone scale of the player also affects the bone scale of the bonemerged model, so you will need to experiment with it.
If I knew how to bone merge that would have been my first approach at doing this, so. Thanks for the advise on that. I've done something similar to this once before and I didn't do a bonemerge, but I forgot how I did it. What I'm talking about I've done more than once in the past couple of years, but I don't think I still have the code anywhere. I would apply the EMP tool electric texture to the player model and I scaled the model as a whole at the time; based on "Shield" points, armor points where I had manually calculated damage if the player had armor, to prevent health damage. I should start backing up my work somewhere more permanent... (Like maybe even uploading it to the workshop) If I use a clientsidemodel instead of using the player... I think I should be able to scale its bones after bone-merging. Idk if or why that might also change the player model's scales again
Sorry, you need to Log In to post a reply to this thread.