Changing Entity's Mass?

So I downloaded durgz mod (drugs mod) but the cocaine weighs over 9000 pounds supposedly. I have version 2.1, and it is supposed to fix that bug, but ENT.MASS does not change the entity’s mass! I tried changing heroin’s mass to 9000, but it didn’t change its mass at all.

post the drug code

Here are the lua files for the cocaine entity.

init.lua



AddCSLuaFile("shared.lua")
include("shared.lua")


ENT.MODEL = "models/cocn.mdl"

ENT.MASS = 2; --the model is too heavy so we have to override it with THIS

ENT.LASTINGEFFECT = 45; --how long the high lasts in seconds


function ENT:High(activator,caller)
	--cut health in half and double the speed
	activator:SetHealth(activator:Health()/2)
	if( activator:Health() > 1 )then
		
	end
	
	self.MakeHigh = false;
	local ss = activator:GetNetworkedFloat("SprintSpeed")
	local ws = activator:GetNetworkedFloat("WalkSpeed")
	if activator:GetNetworkedFloat("durgz_cocaine_high_end") < CurTime() &&  ( !activator:GetNetworkedFloat("durgz_oldSprintSpeed") || activator:GetNetworkedFloat("durgz_oldSprintSpeed") == 0 || activator:GetNetworkedFloat( "durgz_oldSprintSpeed") == ss ) then
		self.MakeHigh = true;
	end
end

function ENT:AfterHigh(activator, caller)
	
	--kill them if they're weak
	if( activator:Health() <=1 )then
		activator:Kill()
		for id,pl in pairs(player.GetAll())do
			pl:PrintMessage(HUD_PRINTTALK, activator:Nick().." died of a heart attack (too much cocaine).")
		end
	return
	end
	
	local ss = activator:GetNetworkedFloat("SprintSpeed")
	local ws = activator:GetNetworkedFloat("WalkSpeed")
	if( self.MakeHigh )then
		activator:SetNetworkedFloat( "durgz_oldSprintSpeed", ss)
		activator:SetNetworkedFloat( "durgz_oldWalkSpeed", ws)
		
		activator:SetRunSpeed(ss*6)
		activator:SetWalkSpeed(ws*6)
	end
end

--set speed back to normal once your high is over 
local function ResetSpeed()
	for id,pl in pairs(player.GetAll())do
	
		if pl:GetNetworkedFloat("durgz_cocaine_high_end") < CurTime() && pl:GetNetworkedFloat("durgz_cocaine_high_end") + 0.5 > CurTime() && ( pl:GetNetworkedFloat( "durgz_oldSprintSpeed" ) && pl:GetNetworkedFloat("durgz_oldSprintSpeed") != 0)then
			pl:SetWalkSpeed(pl:GetNetworkedFloat( "durgz_oldWalkSpeed" ))
			pl:SetRunSpeed(pl:GetNetworkedFloat( "durgz_oldSprintSpeed" ))
		end
		
	end
end
hook.Add("Think", "durgz_cocaine_resetspeed", ResetSpeed)

	



function ENT:SpawnFunction( ply, tr ) 
   
 	if ( !tr.Hit ) then return end 
 	 
 	local SpawnPos = tr.HitPos + tr.HitNormal * 16 
 	 
 	local ent = ents.Create( self.Classname ) 
 		ent:SetPos( SpawnPos ) 
 	ent:Spawn() 
 	ent:Activate() 

 	return ent 
 	 
 end 


shared.lua



ENT.Type = "anim"
ENT.Base = "durgz_base"
ENT.PrintName = "Cocaine"
ENT.Nicknames = {"coke", "cocaine", "candy cane", "the big C"}
ENT.OverdosePhrase = {"overdosed on", "snorted too much", "took too much"}
ENT.Author = "cheesylard (inspired by ninjers)"
ENT.Category = "Drugs"
ENT.Spawnable = true
ENT.AdminSpawnable = true
ENT.Information	 = "Looks like sugar to me..." 

--function for high visuals

ENT.TRANSITION_TIME = 5


if(CLIENT)then
	local cdw, cdw2, cdw3
	cdw2 = -1
	local TRANSITION_TIME = ENT.TRANSITION_TIME; --transition effect from sober to high, high to sober, in seconds how long it will take etc.
	local HIGH_INTENSITY = 0.8; --1 is max, 0 is nothing at all
	local STROBE_PACE = 1
	
	local function DoCocaine()
		--self:SetNetworkedFloat( "SprintSpeed"
		local pl = LocalPlayer();
		local pf;
		
		local tab = {}
		tab[ "$pp_colour_addr" ] = 0
		tab[ "$pp_colour_addg" ] = 0
		tab[ "$pp_colour_addb" ] = 0
		tab[ "$pp_colour_brightness" ] = 0
		tab[ "$pp_colour_contrast" ] = 1
		tab[ "$pp_colour_mulr" ] = 0
		tab[ "$pp_colour_mulg" ] = 0
		tab[ "$pp_colour_mulb" ] = 0
		
		
		if( pl:GetNetworkedFloat("durgz_cocaine_high_start") && pl:GetNetworkedFloat("durgz_cocaine_high_end") > CurTime() )then
		
			if( pl:GetNetworkedFloat("durgz_cocaine_high_start") + TRANSITION_TIME > CurTime() )then
			
				local s = pl:GetNetworkedFloat("durgz_cocaine_high_start");
				local e = s + TRANSITION_TIME;
				local c = CurTime();
				pf = (c-s) / (e-s);
				
				pf = pf*HIGH_INTENSITY
				
				
				
			elseif( pl:GetNetworkedFloat("durgz_cocaine_high_end") - TRANSITION_TIME < CurTime() )then
			
				local e = pl:GetNetworkedFloat("durgz_cocaine_high_end");
				local s = e - TRANSITION_TIME;
				local c = CurTime();
				pf = 1 - (c-s) / (e-s);
				
				pf = pf*HIGH_INTENSITY
				
				pl:SetDSP(1)
				
				
				
			else
			
				
				pf = HIGH_INTENSITY;
				
			end
			
			
				
			if( !cdw || cdw < CurTime() )then
				cdw = CurTime() + STROBE_PACE
				cdw2 = cdw2*-1
			end
			if( cdw2 == -1 )then
				cdw3 = 2
			else
				cdw3 = 0
			end
			local ich = (cdw2*((cdw - CurTime())*(2/STROBE_PACE)))+cdw3 - 1
			
			DrawMaterialOverlay("models/shadertest/shader3",  pf*ich*0.05	)
			DrawSharpen(pf*ich*5, 2) 
			
		end
	end
	hook.Add("RenderScreenspaceEffects", "durgz_cocaine_high", DoCocaine)
end


ent:SetMass(9000)

That didn’t seem to work either:



AddCSLuaFile("shared.lua")
include("shared.lua")


ENT.MODEL = "models/cocn.mdl"

ent:SetMass(2)

ENT.LASTINGEFFECT = 45; --how long the high lasts in seconds


function ENT:High(activator,caller)
	--cut health in half and double the speed
	activator:SetHealth(activator:Health()/2)
	if( activator:Health() > 1 )then
		
	end
	
	self.MakeHigh = false;
	local ss = activator:GetNetworkedFloat("SprintSpeed")
	local ws = activator:GetNetworkedFloat("WalkSpeed")
	if activator:GetNetworkedFloat("durgz_cocaine_high_end") < CurTime() &&  ( !activator:GetNetworkedFloat("durgz_oldSprintSpeed") || activator:GetNetworkedFloat("durgz_oldSprintSpeed") == 0 || activator:GetNetworkedFloat( "durgz_oldSprintSpeed") == ss ) then
		self.MakeHigh = true;
	end
end

function ENT:AfterHigh(activator, caller)
	
	--kill them if they're weak
	if( activator:Health() <=1 )then
		activator:Kill()
		for id,pl in pairs(player.GetAll())do
			pl:PrintMessage(HUD_PRINTTALK, activator:Nick().." died of a heart attack (too much cocaine).")
		end
	return
	end
	
	local ss = activator:GetNetworkedFloat("SprintSpeed")
	local ws = activator:GetNetworkedFloat("WalkSpeed")
	if( self.MakeHigh )then
		activator:SetNetworkedFloat( "durgz_oldSprintSpeed", ss)
		activator:SetNetworkedFloat( "durgz_oldWalkSpeed", ws)
		
		activator:SetRunSpeed(ss*6)
		activator:SetWalkSpeed(ws*6)
	end
end

--set speed back to normal once your high is over 
local function ResetSpeed()
	for id,pl in pairs(player.GetAll())do
	
		if pl:GetNetworkedFloat("durgz_cocaine_high_end") < CurTime() && pl:GetNetworkedFloat("durgz_cocaine_high_end") + 0.5 > CurTime() && ( pl:GetNetworkedFloat( "durgz_oldSprintSpeed" ) && pl:GetNetworkedFloat("durgz_oldSprintSpeed") != 0)then
			pl:SetWalkSpeed(pl:GetNetworkedFloat( "durgz_oldWalkSpeed" ))
			pl:SetRunSpeed(pl:GetNetworkedFloat( "durgz_oldSprintSpeed" ))
		end
		
	end
end
hook.Add("Think", "durgz_cocaine_resetspeed", ResetSpeed)

	



function ENT:SpawnFunction( ply, tr ) 
   
 	if ( !tr.Hit ) then return end 
 	 
 	local SpawnPos = tr.HitPos + tr.HitNormal * 16 
 	 
 	local ent = ents.Create( self.Classname ) 
 		ent:SetPos( SpawnPos ) 
 	ent:Spawn() 
 	ent:Activate() 
 	 
 	return ent 
 	 
 end 


=\

[lua]AddCSLuaFile(“shared.lua”)
include(“shared.lua”)

ENT.MODEL = “models/cocn.mdl”

ENT.LASTINGEFFECT = 45; --how long the high lasts in seconds

function ENT:High(activator,caller)
–cut health in half and double the speed
activator:SetHealth(activator:Health()/2)
if( activator:Health() > 1 )then

end

self.MakeHigh = false;
local ss = activator:GetNetworkedFloat("SprintSpeed")
local ws = activator:GetNetworkedFloat("WalkSpeed")
if activator:GetNetworkedFloat("durgz_cocaine_high_end") &lt; CurTime() &&  ( !activator:GetNetworkedFloat("durgz_oldSprintSpeed") || activator:GetNetworkedFloat("durgz_oldSprintSpeed") == 0 || activator:GetNetworkedFloat( "durgz_oldSprintSpeed") == ss ) then
	self.MakeHigh = true;
end

end

function ENT:AfterHigh(activator, caller)

--kill them if they're weak
if( activator:Health() &lt;=1 )then
	activator:Kill()
	for id,pl in pairs(player.GetAll())do
		pl:PrintMessage(HUD_PRINTTALK, activator:Nick().." died of a heart attack (too much cocaine).")
	end
return
end

local ss = activator:GetNetworkedFloat("SprintSpeed")
local ws = activator:GetNetworkedFloat("WalkSpeed")
if( self.MakeHigh )then
	activator:SetNetworkedFloat( "durgz_oldSprintSpeed", ss)
	activator:SetNetworkedFloat( "durgz_oldWalkSpeed", ws)
	
	activator:SetRunSpeed(ss*6)
	activator:SetWalkSpeed(ws*6)
end

end

–set speed back to normal once your high is over
local function ResetSpeed()
for id,pl in pairs(player.GetAll())do

	if pl:GetNetworkedFloat("durgz_cocaine_high_end") &lt; CurTime() && pl:GetNetworkedFloat("durgz_cocaine_high_end") + 0.5 &gt; CurTime() && ( pl:GetNetworkedFloat( "durgz_oldSprintSpeed" ) && pl:GetNetworkedFloat("durgz_oldSprintSpeed") != 0)then
		pl:SetWalkSpeed(pl:GetNetworkedFloat( "durgz_oldWalkSpeed" ))
		pl:SetRunSpeed(pl:GetNetworkedFloat( "durgz_oldSprintSpeed" ))
	end
	
end

end
hook.Add(“Think”, “durgz_cocaine_resetspeed”, ResetSpeed)

function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end 
 
local SpawnPos = tr.HitPos + tr.HitNormal * 16 
 
local ent = ents.Create( self.Classname ) 
	ent:SetPos( SpawnPos ) 
ent:Spawn() 
ent:Activate() 
 ent:GetPhysicsObject():SetMass(2)
 
return ent 

end[/lua]

Nope, tried that and the mass is still rediculously high. I don’t understand!

maybe put in the ENT:Intalisize? < yes i wrote it wrong, else you need to check your GMod since its quite messed up 0_o

Nothing. Maybe I just need to manually change the model’s mass with a model editor perhaps?

Jamie, you should know better. :frown:

A quick look at the wiki would’ve fixed it for all of you, SetMass() is to be called on the physics object of an entity. So :
[lua]ent:GetPhysicsObject():SetMass(2)[/lua]

Cough I forgot to look at the wiki :V
I updated the code.

uhhhh then my GMod is fucked lawl, works as ent:SetMass(*) for me also :smiley:

did you try “ent:SetMass(#)”? that should do it

EDIT:
Jeez that was posted right above me…