Zoeys LUA Hl2 Weapons Update

An updated version of my half life 2 weapons

Fixes include…

1.1:
Weapon Hold Type.
Third Person Animation.
Less NWInts.
More Stability.
Muzzle Smoke.

1.11:
Removed 2 bools and converted them into S Vars.

1.12:
Removed 3 bools and converted them into S Vars.
Added checks to Fire Accums to stop single player errors.
Added new AR2 Muzzle flash.

1.13:
Swapped the 357 smoke effect.
Added auto holstering animations when your going to switch your weapon.
Fixed some strange accuracy with the SMG and AR2.
Fixed some errors about the vent var in the AR2.


Hl2 weapons recoded in lua.

Whats the diffrence for lua?

Fov Fixes
AR2 Pose parameters are smoother
See above for the newest fixes

Does the crossbow work?

The crossbow works

Other Features:

Sprint = Lower Weapon
Sprint + Walk = Lower/Unlower Weapon
Total idle and lower idle animations.
luahl2weps con command to determine whether to replace the C++ weapons with the lua weapons.
Half life 2 killicons.
Half life 2 weapon icons.

You redid the rocket launcher?

Nope

Ar2 Alt Fire?

Sadly no…

“UAAAAAAAAAAAAH”

Theres pictures at the download.

Download 1.13:

http://www.garrysmod.org/img/?t=dll&id=102950

There’s something very suspicious about this. Why is it that some parts are indented and some parts are not in the slightest?

Oh, of course. The code is stolen from MadCows SWEP Pack.

Smooth.

Actually this was made BEFORE madcows.

The older version that is.

The reason why some is tabbed is mostly because sometimes i do it automatically, And because i used some of garrys base code from his wierd css weapons :ohdear:

The older version of this is somewhere around the sweps sforum.

And i do make many other things beside this, So Your not really the first to be blaming me of “Stealing” code.

Actually, no, there are some incredibly noticeably changes. It was really to notice since someone who doesn’t indent isn’t gonna know what the dot product of a vector is.

Mad Cows

[lua]function SWEP:RicochetCallback(bouncenum, attacker, tr, dmginfo)

if (CLIENT) then return end

if (not self) then return end

local DoDefaultEffect = true
if (tr.HitSky) then return end

// Can we go through whatever we hit?
if (self.Penetration) and (self:BulletPenetrate(bouncenum, attacker, tr, dmginfo)) then
	return {damage = true, effects = DoDefaultEffect}
end

// Your screen will shake and you'll hear the savage hiss of an approaching bullet which passing if someone is shooting at you.
if (tr.MatType != MAT_METAL) then
	if (SERVER) then
		WorldSound("Bullets.DefaultNearmiss", tr.HitPos, 250, math.random(110, 180))
	end
		util.ScreenShake(tr.HitPos, 5, 0.1, 0.5, 64)

	if self.Tracer == 1 or self.Tracer == 2 then
		local effectdata = EffectData()
			effectdata:SetOrigin(tr.HitPos)
			effectdata:SetNormal(tr.HitNormal)
			effectdata:SetScale(20)
		util.Effect("AR2Impact", effectdata)
	elseif self.Tracer == 3 then
		local effectdata = EffectData()
			effectdata:SetOrigin(tr.HitPos)
			effectdata:SetNormal(tr.HitNormal)
			effectdata:SetScale(20)
		util.Effect("StunstickImpact", effectdata)
	end

	return 
end

if (self.Ricochet == false) then return {damage = true, effects = DoDefaultEffect} end

if (bouncenum > self.MaxRicochet) then return end

// Bounce vector
local trace = {}
trace.start = tr.HitPos
trace.endpos = trace.start + (tr.HitNormal * 16384)

local trace = util.TraceLine(trace)

local DotProduct = tr.HitNormal:Dot(tr.Normal * -1) 

local bullet = 
{	
	Num 		= 1,
	Src 		= tr.HitPos + (tr.HitNormal * 5),
	Dir 		= ((2 * tr.HitNormal * DotProduct) + tr.Normal) + (VectorRand() * 0.05),
	Spread 	= Vector(0, 0, 0),
	Tracer	= 1,
	TracerName 	= "effect_mad_ricochet_trace",
	Force		= dmginfo:GetDamage() * 0.25,
	Damage	= dmginfo:GetDamage() * 0.5,
	HullSize	= 2
}
	
// Added conditional to stop errors when bullets ricochet after weapon switch
bullet.Callback  	= function(a, b, c) if (self.Ricochet) then return self:RicochetCallback(bouncenum + 1, a, b, c) end end

timer.Simple(0.05, function()
	if not IsFirstTimePredicted() then return end
	attacker.FireBullets(attacker, bullet, true)
end)

return {damage = true, effects = DoDefaultEffect}

end[/lua]

You:

[lua]function SWEP:RicochetCallback(bouncenum, attacker, tr, dmginfo)

local DoDefaultEffect = true
if (tr.HitSky) then return end

if (self.Penetration) and (self:BulletPenetrate(bouncenum, attacker, tr, dmginfo)) then
	return {damage = true, effects = DoDefaultEffect}
end

	if (SERVER) then
		util.ScreenShake(tr.HitPos, 2.2, 0.1, 0.3, 38)	
	end

if (self.Ricochet == true) then return {damage = true, effects = DoDefaultEffect} end

if (bouncenum > self.MaxRicochet) then return end

local trace = {}
trace.start = tr.HitPos
trace.endpos = trace.start + (tr.HitNormal * 16384)

local trace = util.TraceLine(trace)

local DotProduct = tr.HitNormal:Dot(tr.Normal * -1) 

local bullet = 
{	
	Num 		= self.Primary.NumShots,
	Src 		= tr.HitPos + (tr.HitNormal * 5),
	Dir 		= ((2 * tr.HitNormal * DotProduct) + tr.Normal) + (VectorRand() * 0.05),
	Spread 	= Vector(self.Primary.Cone, self.Primary.Cone, 0),
	Tracer	= 0,
	TracerName 	= "",
	Force		= 0.5 * self.Primary.Damage * 0.9,
	Damage	= self.Primary.Damage * 0.95,
	HullSize	= 2,
	Attacker	= attacker
}
	
bullet.Callback  	= function(a, b, c) if (self.Ricochet) then return self:RicochetCallback(bouncenum + 1, a, b, c) end end

attacker:FireBullets(bullet)

return {damage = true, effects = DoDefaultEffect}

end[/lua]

Mad Cows:

[lua]function SWEP:BulletPenetrate(bouncenum, attacker, tr, dmginfo, isplayer)

if (CLIENT) then return end

local MaxPenetration

if self.Primary.Ammo == "AirboatGun" then // 5.56MM Ammo
	MaxPenetration = 18
elseif self.Primary.Ammo == "Gravity" then // 4.6MM Ammo
	MaxPenetration = 8
elseif self.Primary.Ammo == "AlyxGun" then // 5.7MM Ammo
	MaxPenetration = 12
elseif self.Primary.Ammo == "Battery" then // 9MM Ammo
	MaxPenetration = 14
elseif self.Primary.Ammo == "StriderMinigun" then // 7.62MM Ammo
	MaxPenetration = 20
elseif self.Primary.Ammo == "SniperPenetratedRound" then // .45 Ammo
	MaxPenetration = 16
elseif self.Primary.Ammo == "CombineCannon" then // .50 Ammo
	MaxPenetration = 20
else
	MaxPenetration = 16
end

local DoDefaultEffect = true
// Don't go through metal, sand or player
if ((tr.MatType == MAT_METAL and self.Ricochet) or (tr.MatType == MAT_SAND) or (tr.Entity:IsPlayer())) then return false end

// Don't go through more than 3 times
if (bouncenum > 3) then return false end

// Direction (and length) that we are going to penetrate
local PenetrationDirection = tr.Normal * MaxPenetration

if (tr.MatType == MAT_GLASS or tr.MatType == MAT_PLASTIC or tr.MatType == MAT_WOOD or tr.MatType == MAT_FLESH or tr.MatType == MAT_ALIENFLESH) then
	PenetrationDirection = tr.Normal * (MaxPenetration * 2)
end
	
local trace 	= {}
trace.endpos 	= tr.HitPos
trace.start 	= tr.HitPos + PenetrationDirection
trace.mask 		= MASK_SHOT
trace.filter 	= {self.Owner}
   
local trace 	= util.TraceLine(trace) 

// Bullet didn't penetrate.
if (trace.StartSolid or trace.Fraction >= 1.0 or tr.Fraction <= 0.0) then return false end

// Damage multiplier depending on surface
local fDamageMulti = 0.5

if (tr.MatType == MAT_CONCRETE) then
	fDamageMulti = 0.3
elseif (tr.MatType == MAT_WOOD or tr.MatType == MAT_PLASTIC or tr.MatType == MAT_GLASS) then
	fDamageMulti = 0.8
elseif (tr.MatType == MAT_FLESH or tr.MatType == MAT_ALIENFLESH) then
	fDamageMulti = 0.9
end
	
// Fire bullet from the exit point using the original trajectory
local bullet = 
{	
	Num 		= 1,
	Src 		= trace.HitPos,
	Dir 		= tr.Normal,	
	Spread 	= Vector(0, 0, 0),
	Tracer	= 1,
	TracerName 	= "effect_mad_penetration_trace",
	Force		= 5,
	Damage	= (dmginfo:GetDamage() * fDamageMulti),
	HullSize	= 2
}

bullet.Callback   = function(a, b, c) if (self.Ricochet) then return self:RicochetCallback(bouncenum + 1, a, b, c) end end

timer.Simple(0.05, function()
	if not IsFirstTimePredicted() then return end
	attacker.FireBullets(attacker, bullet, true)
end)

return true

end[/lua]

You:

[lua]
function SWEP:BulletPenetrate(bouncenum, attacker, tr, dmginfo, isplayer)

local DoDefaultEffect = true
if (tr.MatType == MAT_SAND) or (tr.Entity:IsPlayer()) then return end

if (bouncenum > 3) then return end

local PenetrationDirection = tr.Normal * self.MaxPenetration

if (tr.MatType == MAT_METAL) then
	PenetrationDirection = tr.Normal * (self.MaxPenetration - 3)
end

if (tr.MatType == MAT_DIRT or tr.MatType == MAT_WOOD or tr.MatType == MAT_FLESH or tr.MatType == MAT_ALIENFLESH or tr.MatType == MAT_GLASS or tr.MatType == MAT_PLASTIC or tr.MatType == MAT_VENT or tr.MatType == MAT_COMPUTER) then
	PenetrationDirection = tr.Normal * self.MaxWoodPenetration
end
	
local trace 	= {}
trace.endpos 	= tr.HitPos
trace.start 	= tr.HitPos + PenetrationDirection
trace.mask 		= MASK_SHOT
trace.filter 	= {self.Owner}
   
local trace 	= util.TraceLine(trace) 

if (trace.StartSolid or trace.Fraction >= 1.0 or tr.Fraction <= 0.0) then return end

local DMGX = 0.5

if (tr.MatType == MAT_CONCRETE) then
	DMGX = 0.9
elseif (tr.MatType == MAT_METAL) then
	DMGX = 0.85;
elseif (tr.MatType == MAT_WOOD) then
	DMGX = 0.8;
elseif (tr.MatType == MAT_FLESH or tr.MatType == MAT_ALIENFLESH) then
	DMGX = 0.9;
elseif (tr.MatType == MAT_GLASS) then
	DMGX = 0.88;
elseif (tr.MatType == MAT_GRATE) then
	DMGX = 0.9;
elseif (tr.MatType == MAT_PLASTIC) then
	DMGX = 0.95;
elseif (tr.MatType == MAT_VENT) then
	DMGX = 0.92;
elseif (tr.MatType == MAT_ANTLION) then
	DMGX = 0.8;
elseif (tr.MatType == MAT_DIRT) then
	DMGX = 0.82;
elseif (tr.MatType == MAT_SAND) then
	DMGX = 0.65;
elseif (tr.MatType == MAT_FOLIAGE) then
	DMGX = 0.95;
elseif (tr.MatType == MAT_COMPUTER) then
	DMGX = 0.9;
elseif (tr.MatType == MAT_SLOSH) then
	DMGX = 0.85;
elseif (tr.MatType == MAT_TILE) then
	DMGX = 0.9;
end

local bullet = 
{	
	Num 		= self.Primary.NumShots,
	Src 		= trace.HitPos,
	Dir 		= tr.Normal,	
	Spread 	= Vector(0, 0, 0),
	Tracer	= 0,
	TracerName 	= "",
	Force		= 0.5 * self.Primary.Damage * DMGX,
	Damage	= (self.Primary.Damage * DMGX),
	HullSize	= 2,
	Attacker	= attacker
}

bullet.Callback    = function(a, b, c) if (self.Ricochet) then return self:RicochetCallback(bouncenum + 1, a, b, c) end end

attacker:FireBullets(bullet)

return true

end[/lua]

Funny those are the only two parts that are properly indented. How about you stop lying.

Wizey this is a god dam new low for you.
Besides the fact you pretend whenever you release something someone already made yours is all high and might and you slip in little snippets of code to fry other peoples works on Purpose.
You are a sad sad little man/woman/asshole/something

Ohh Zoey is going downnnnnn
for stealing work
Remember me Zoey Hunny?
The only person who was nice to you?
Hows the heart doing?
Dont get too stressed out from people flammin’ ya :heart:

[editline]08:22PM[/editline]

oh btw though guys
She did make these sweps before madcows
sooo I doubt she took the code.
Possibly Madcow did idk

ANOTHER thread? how about you make something GOOD, then make a thread?

Whenever I pull out the SMG1 or AR2, it gives me tons of errors, for the same thing. It is something about ‘Comparing a number to nil’ or something like that.

So would using these fix that problem with the HL2 weapons not affecting Stargate shields?

NPC compatible too, right?

come on guys. Its just a pack that makes your guns more realitic. Chill out. I hate it when people just totally jugde these downloads because their made by a girl or there not good enough ect. These downloads are awesome hell I could not make these because I know nothing about lua. The best I can do is make a map on source SDK and im still working on my first one. so again these downloads are awesome, even though I dont download much of Zoeys stuff doesnt mean i dont like them. zoeys power addon, parchute, perfected climb swep (she assisted in it) and this is awesome! K im done. nice job Zoey BTW!

We aren’t Judging because of Their gender, we are Judging cause of the god dam fact they STOLE CODE AND SLIPPED CODE INTO IT TO BREAK OTHER SHIT

well what i’ev been seeing lately in the comments about zoeys power addon people were saying “get back in the kitchen and make me a samitch” or something sexist like that. k back on topic to you sunday who cares if its stolen its not like she is getting money.

[editline]07:23PM[/editline]

This man is probably right I dont know though i’ev only had gmod for so long…

Can you guys who still thinks he is a girl read this thread?

Also, it would be better if you could make the ar2 alt fire & rocket launcher to work, I’m sure you had the time to do it… Then we’d have something worth a download (since no other remake has the alt fire)

Do take into account that this IS based on the OLDER version, So this version is still going to have the same functions my older versions, Despite if theres code from diffrent places or not most of it is probly from garry, since thats what worshipper based his code on.

I was just to lazy to move it onto my other base.

PS: The bullet penetration code is from GMDM, Worshipper just used that and everyone thinks its his.

And my older hl2 weapons where made about a year ago… So critizism from the old thread to this one makes no diffrence :derp:

I remeber when you left because i never Talked because i was always busy working :derp:

From the GMDM weapon base:

[lua]
function SWEP:RicochetCallback( bouncenum, attacker, tr, dmginfo )

if( !self ) then return end

local DoDefaultEffect = false;
if ( !tr.HitWorld ) then DoDefaultEffect = true end
if ( tr.HitSky ) then return end

// Can we go through whatever we hit?
if ( self.AllowPenetration == true and self:BulletPenetrate( bouncenum, attacker, tr, dmginfo ) ) then
	return { damage = false, effects = false }
end

if ( tr.MatType != MAT_METAL ) then

	 if ( tr.MatType != MAT_FLESH and self.ImpactEffects ) then
	 
		--local effectdata = EffectData()
			--effectdata:SetOrigin( tr.HitPos )
			--effectdata:SetNormal( tr.HitNormal )
			--effectdata:SetScale( dmginfo:GetDamage() / 10000 )
		--util.Effect( "hitsmoke", effectdata )
		
		--util.Decal( "EnergyBall.Impact", tr.HitPos + tr.HitNormal, tr.HitPos + tr.HitNormal * -20 + VectorRand() * 15 )
		
		if ( SERVER ) then
			util.ScreenShake( tr.HitPos, 100, 0.2, 1, 128 )
		end
		
	end

return end

if( self.AllowRicochet == false ) then return { damage = true, effects = DoDefaultEffect } end

if ( bouncenum > self.MaxRicochet ) then return end

// Bounce vector (Don't worry - I don't understand the maths either :x)
local DotProduct = tr.HitNormal:Dot( tr.Normal * -1 )
local Dir = ( 2 * tr.HitNormal * DotProduct ) + tr.Normal
Dir:Normalize()

local bullet = 
{	
	Num 		= 1,
	Src 		= tr.HitPos,
	Dir 		= Dir,	
	Spread 		= Vector( 0.05, 0.05, 0 ),
	Tracer		= 1,
	TracerName 	= "rico_trace",
	Force		= 5,
	Damage		= damage,
	AmmoType 	= "Pistol",
	HullSize	= 2
}
	
-- BLaNK
-- Added conditional to stop errors when bullets ricoshet after weapon switch.
bullet.Callback    = function( a, b, c ) if( self.RicochetCallback ) then return self:RicochetCallback( bouncenum+1, a, b, c ) end end

timer.Simple( 0.05, attacker.FireBullets, attacker, bullet, true )
attacker:SetNetworkedInt( "BulletType", 2 ); -- 2 = ricochet

return { damage = true, effects = DoDefaultEffect }

end
[/lua]

[lua]
function SWEP:BulletPenetrate( bouncenum, attacker, tr, dmginfo, isplayer )

--if( !SERVER ) then return end
// Don't go through metal
if ( ( tr.MatType == MAT_METAL and self.AllowRicochet == true ) or tr.MatType == MAT_SAND ) then return false end

// Don't go through more than 3 times
if ( bouncenum > 3 ) then return false end

// Direction (and length) that we are gonna penetrate
local PeneDir = tr.Normal * self.PenetrationMax;

if( tr.MatType == MAT_DIRT or tr.MatType == MAT_WOOD or tr.MatType == MAT_FLESH or tr.MatType == MAT_ALIENFLESH ) then -- dirt == plaster, and wood should be easier to penetrate so increase the distance
	PeneDir = tr.Normal * self.PenetrationMaxWood;
end
	
	
local PeneTrace = {}
   PeneTrace.endpos = tr.HitPos
   PeneTrace.start = tr.HitPos + PeneDir
   PeneTrace.mask = MASK_SHOT
   PeneTrace.filter = { self.Owner }
   
local PeneTrace = util.TraceLine( PeneTrace ) 

// Bullet didn't penetrate.
if ( PeneTrace.StartSolid || PeneTrace.Fraction >= 1.0 || tr.Fraction <= 0.0 ) then return false end

-- Damage multiplier depending on surface
local fDamageMulti = 0.5;

if( tr.MatType == MAT_CONCRETE ) then
	fDamageMulti = 0.3;
elseif( tr.MatType == MAT_WOOD ) then
	fDamageMulti = 0.8;
elseif( tr.MatType == MAT_FLESH || tr.MatType == MAT_ALIENFLESH ) then
	fDamageMulti = 0.9;
end
	
// Fire bullet from the exit point using the original tradjectory
local bullet = 
{	
	Num 		= 1,
	Src 		= PeneTrace.HitPos,
	Dir 		= tr.Normal,	
	Spread 		= Vector( 0, 0, 0 ),
	Tracer		= 1,
	TracerName 	= "Tracer",
	Force		= 5,
	Damage		= (dmginfo:GetDamage()*0.9),
	AmmoType 	= "Pistol",
	HullSize	= 2
}

bullet.Callback    = function( a, b, c ) if( self.RicochetCallback ) then return self:RicochetCallback( bouncenum+1, a, b, c ) end end

local effectdata = EffectData()
effectdata:SetOrigin( PeneTrace.HitPos )
effectdata:SetNormal ( PeneTrace.Normal )
util.Effect( "Impact", effectdata, true, true ) 

timer.Simple( 0.05, attacker.FireBullets, attacker, bullet, true )
attacker:SetNetworkedInt( "BulletType", 1 ); -- 1 = wallbang

return true

end
[/lua]

What now guys.
Stop acting like immature idiots, just enjoy the SWEPs or don’t, no need to make such a drama about it.

Wizey might steal ideas but not code.

Ideas, Maybe.

It’s not an issue of drama, it’s simply morals. By copying and pasting code back and forth, you’re not coding. That’s like someone telling you to design a building, and you simply take bits from other buildings and put them on yours.

It’s also a standards issue. Usually when people install addons, they want them error free and fully optimized, this has things like “wepon!=NULL” in a Think hook. This in no way “awesome” as the other guy said, this is horribly and horrendously coded, as well as generally lacking in polish and containing some snippets of dubious origin.

Fact is, I don’t care in the slightest of who is Wizey, I don’t judge based on his/her/whatever’s previous code. This is what I’m downloading, this is what I’m giving my opinion on, and from a coder’s point of view, it’s terrible. From a player’s point of view, it’s gonna lag me.

that “sniff” was awesome