Permalink
Browse files

Improved Inflator miles

Inflator no longer inflate bones you are not aiming at
Inflator now has better arm/hand/leg detection to scale bones only on
certain axies ( TF2 support )
  • Loading branch information...
1 parent 08f0e5f commit 15bcd590b9e95aa02107898534733bd9b38892a8 @robotboy655 robotboy655 committed Apr 20, 2016
@@ -11,7 +11,7 @@ if ( CLIENT ) then
function TOOL.BuildCPanel( CPanel )
CPanel:AddControl( "Header", { Description = "#tool.inflator.desc" } )
-
+
end
end
@@ -28,69 +28,81 @@ local ScaleYZ = {
"ValveBiped.Bip01_Spine2",
"ValveBiped.Bip01_Spine1",
"ValveBiped.Bip01_Spine",
- "ValveBiped.Bip01_Spinebut"
+ "ValveBiped.Bip01_Spinebut",
+
+ -- Vortigaunt
+ "ValveBiped.spine4",
+ "ValveBiped.spine3",
+ "ValveBiped.spine2",
+ "ValveBiped.spine1",
+ "ValveBiped.hlp_ulna_R",
+ "ValveBiped.hlp_ulna_L",
+ "ValveBiped.arm1_L",
+ "ValveBiped.arm1_R",
+ "ValveBiped.arm2_L",
+ "ValveBiped.arm2_R",
+ "ValveBiped.leg_bone1_L",
+ "ValveBiped.leg_bone1_R",
+ "ValveBiped.leg_bone2_L",
+ "ValveBiped.leg_bone2_R",
+ "ValveBiped.leg_bone3_L",
+ "ValveBiped.leg_bone3_R",
+
+ -- Team Fortress 2
+ "bip_knee_L",
+ "bip_knee_R",
+ "bip_hip_R",
+ "bip_hip_L",
}
-local ScaleXZ = { "ValveBiped.Bip01_pelvis" }
+local ScaleXZ = {
+ "ValveBiped.Bip01_pelvis",
+
+ -- Team Fortress 2
+ "bip_upperArm_L",
+ "bip_upperArm_R",
+ "bip_lowerArm_L",
+ "bip_lowerArm_R",
+ "bip_forearm_L",
+ "bip_forearm_R",
+}
local function GetNiceBoneScale( name, scale )
- if ( table.HasValue( ScaleYZ, name ) ) then
+ if ( table.HasValue( ScaleYZ, name ) || string.find( name:lower(), "leg" ) || string.find( name:lower(), "arm" ) ) then
return Vector( 0, scale, scale )
end
-
+
if ( table.HasValue( ScaleXZ, name ) ) then
return Vector( scale, 0, scale )
end
-
- return Vector( scale, scale, scale )
-
-end
-
-local ScaleBone = nil
-
-local function ScaleNeighbourBones( Entity, Pos, Bone, Scale, type )
-
- if ( type == nil || type == 2 ) then
-
- local parent = Entity:GetBoneParent( Bone )
- if ( parent && parent >= 0 && parent != Bone ) then
- ScaleBone( Entity, Pos, parent, Scale, 2 )
- end
-
- end
-
- if ( type == nil || type == 1 ) then
-
- local children = Entity:GetChildBones( Bone )
-
- for k, v in pairs( children ) do
- ScaleBone( Entity, Pos, v, Scale, 1 )
- end
- end
+ return Vector( scale, scale, scale )
end
--[[------------------------------------------------------------
Scale the specified bone by Scale
--------------------------------------------------------------]]
-ScaleBone = function( Entity, Pos, Bone, Scale, type )
+local function ScaleBone( ent, bone, scale, type )
- --local Bone, BonePos = Entity:FindNearestBone( Pos )
- if ( !Bone ) then return false end
+ if ( !bone ) then return false end
- -- Some bones are scaled only in certain directions (like legs don't scale on length)
- local v = GetNiceBoneScale( Entity:GetBoneName( Bone ), Scale ) * 0.1
- local TargetScale = Entity:GetManipulateBoneScale( Bone ) + v * 0.1
-
- if ( TargetScale.x < 0 ) then TargetScale.x = 0 end
- if ( TargetScale.y < 0 ) then TargetScale.y = 0 end
- if ( TargetScale.z < 0 ) then TargetScale.z = 0 end
+ local physBone = ent:TranslateBoneToPhysBone( bone )
+ for i = 0, ent:GetBoneCount() do
+
+ if ( ent:TranslateBoneToPhysBone( i ) != physBone ) then continue end
+
+ -- Some bones are scaled only in certain directions (like legs don't scale on length)
+ local v = GetNiceBoneScale( ent:GetBoneName( i ), scale ) * 0.1
+ local TargetScale = ent:GetManipulateBoneScale( i ) + v * 0.1
- Entity:ManipulateBoneScale( Bone, TargetScale )
+ if ( TargetScale.x < 0 ) then TargetScale.x = 0 end
+ if ( TargetScale.y < 0 ) then TargetScale.y = 0 end
+ if ( TargetScale.z < 0 ) then TargetScale.z = 0 end
- ScaleNeighbourBones( Entity, Pos, Bone, Scale * 0.5, type )
+ ent:ManipulateBoneScale( i, TargetScale )
+ end
end
@@ -101,15 +113,15 @@ function TOOL:LeftClick( trace )
if ( IsValid( trace.Entity ) && trace.Entity:IsPlayer() ) then return false end
if ( !trace.Entity:IsNPC() && trace.Entity:GetClass() != "prop_ragdoll" ) then return false end
-
+
local Bone = trace.Entity:TranslatePhysBoneToBone( trace.PhysicsBone )
- ScaleBone( trace.Entity, trace.HitPos, Bone, 1 )
+ ScaleBone( trace.Entity, Bone, 1 )
self:GetWeapon():SetNextPrimaryFire( CurTime() + 0.01 )
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
util.Effect( "inflator_magic", effectdata )
-
+
return false
end
@@ -121,32 +133,32 @@ function TOOL:RightClick( trace )
if ( IsValid( trace.Entity ) && trace.Entity:IsPlayer() ) then return false end
if ( !trace.Entity:IsNPC() && trace.Entity:GetClass() != "prop_ragdoll" ) then return false end
-
+
local Bone = trace.Entity:TranslatePhysBoneToBone( trace.PhysicsBone )
- ScaleBone( trace.Entity, trace.HitPos, Bone, -1 )
+ ScaleBone( trace.Entity, Bone, -1 )
self:GetWeapon():SetNextSecondaryFire( CurTime() + 0.01 )
-
+
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
util.Effect( "inflator_magic", effectdata )
return false
-
+
end
--[[------------------------------------------------------------
Remove Scaling
--------------------------------------------------------------]]
function TOOL:Reload( trace )
-
+
if ( IsValid( trace.Entity ) && trace.Entity:IsPlayer() ) then return false end
if ( !trace.Entity:IsNPC() && trace.Entity:GetClass() != "prop_ragdoll" ) then return false end
if ( CLIENT ) then return false end
-
+
for i=0, trace.Entity:GetBoneCount() do
- trace.Entity:ManipulateBoneScale( i, Vector(1, 1, 1) )
+ trace.Entity:ManipulateBoneScale( i, Vector( 1, 1, 1 ) )
end
-
+
return true
-
+
end
@@ -72,7 +72,7 @@ function gmsave.SaveMap( ply )
for k, v in pairs( Ents ) do
- if ( !gmsave.ShouldSaveEntity( v, v:GetSaveTable() ) || v:IsConstraint() ) then
+ if ( !gmsave.ShouldSaveEntity( v, v:GetSaveTable() ) || v:IsConstraint() ) then
Ents[ k ] = nil
end

4 comments on commit 15bcd59

@comedinha
Contributor
comedinha commented on 15bcd59 Apr 20, 2016 edited

Have date to update?

@robotboy655
Collaborator

No. It won't be in the next update. You can copy over the code to your server/client ( for singleplayer ) if you want

@comedinha
Contributor

Oh, ok, but I need of the function SnatchModelInstance e.e

@Kefta
Contributor
Kefta commented on 15bcd59 Apr 20, 2016

That's coming next update

Please sign in to comment.