Hello. I don't trust the [I]What Do You Need Help With Thread V3[/I]. I've been having problems with this for a while. I am trying to create replicas of the HL2 weapons, but change some of how they act (as if a NPC were using them). They will also kick a little differently, and be more realistic.
Could someone please help me? :tinfoil:
[lua]SWEP.Author = "LuaVirusFree"SWEP.Contact = "sabarbee@wccnet.edu"
SWEP.Purpose = "Aim, shoot, dispatch."
SWEP.Instructions = "Primary shoots."
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.Primary.ClipSize = 18
SWEP.Primary.DefaultClip = 0 -- We don't want to start loaded.
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "AlyxGun"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
local ShootSound = Sound( "Weapon_Pistol.NPC_Single" )
local ReloadSound = Sound( "Weapon_Pistol.NPC_Reload" )
local EmptySound = Sound( "Weapon_Pistol.Empty" )
local BurstSound = Sound( "Weapon_Pistol.Burst" )
local SwitchSingleSound = Sound( "Weapon_Pistol.Special1" )
local SwitchBurstSound = Sound( "Weapon_Pistol.Special2" )
/*---------------------------------------------------------
Reload reloads.
---------------------------------------------------------*/
function SWEP:Reload()
if self:Clip1() == 18 then self.Clip1 = 19 end
self.Weapon:EmitSound( ReloadSound )
self:DefaultReload( ACT_VM_RELOAD )
end
local ReloadTime = CurTime()
/*---------------------------------------------------------
Think reloads
---------------------------------------------------------*/
local ReloadTime = CurTime()
function SWEP:Think()
if self:Clip1() < 18 && CurTime() > ReloadTime then
self.Owner:SetAmmo( 19, "Pistol" )
self:Reload()
end
if self.Owner:KeyPressed( IN_ATTACK ) then
ReloadTime = CurTime() + 7
end
end
--function SWEP:CanPrimaryAttack()
-- if self:Clip1 < 8 then return false end
--end
/*---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
if !self:CanPrimaryAttack() then self.Weapon:EmitSound( EmptySound ) return end
-- TODO: Make and shoot bullet entity. Reduce ammo.
if !BurstFireMode then
local Player = self.Owner
Player:TakePrimaryAmmo(1)
local Bullet = {}
if SERVER then
Bullet.Nine = ents.Create( "bullet_Nine" )
Bullet.Nine:SetPos( Player:GetShootPos() ) -- TODO: Get the world model's muzzle?
Bullet.Nine:SetAngles( self.Owner:GetAngles() )
Bullet.Nine:Spawn()
Bullet.Nine:Activate()
Bullet.Nine:SetOwner( Player )
local bulPhy = Bullet.Nine:GetPhysicsObject()
bulPhy:SetVelocity((self.Owner:GetAngles()+ Angle(1, 0, 0)):Forward() * 33600 ) -- 5.7mm Muzzle Velocity.
Bullet.Nine:SetVar("Velocity",33600)
-- Bullet.Nine:SetVar("Acceleration",accel)
-- local Force = Angle:__add(Player:GetAimVector(), Angle(-30, 0, 0) )*256
-- bulPhy:SetVelocity((self.Owner:GetAngles()+ Angle(45, 0, 0)):Forward() * 1 * CurTime() * 1)
end
-- Bullet.AngTr = Angle(self.Owner:GetAngles()+ Angle(45, 0, 0))--:Forward()
-- Bullet.AngTr2 = Angle(self.Owner:GetAngles()+Angle(-45, 0, 0))--:Forward()
self.Weapon:EmitSound( ShootSound )
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
-- timer.Simple( 0.3, self.Weapon.SendWeaponAnim, self, ACT_VM_IDLE )
self.Weapon:SetNextPrimaryFire( CurTime()+0.4 )
self.Weapon:SetNextSecondaryFire( CurTime()+2 )
self:ApplyRecoil(0.93,NewSpray)
elseif BurstFireMode then
local Player = self.Owner
local Bullet = {}
local function ShootBurret()
if self:Clip1() < 1 then return end
if self:Clip1() < 3 then
self:EmitSound( ShootSound )
end
Player:TakePrimaryAmmo(1)
if SERVER then
Bullet.Nine = ents.Create( "bullet_Nine" )
Bullet.Nine:SetPos( Player:GetShootPos() ) -- TODO: Get the world model's muzzle?
Bullet.Nine:SetAngles( self.Owner:GetAngles() )
Bullet.Nine:Spawn()
Bullet.Nine:Activate()
Bullet.Nine:SetOwner( Player )
local bulPhy = Bullet.Nine:GetPhysicsObject()
bulPhy:SetVelocity((self.Owner:GetAngles()+ Angle(1, 0, 0)):Forward() * 33600 )
end
self:ApplyRecoil(0.73,NewSpray) -- Lil less kick for burst.
end
ShootBurret()
timer.Simple(0.1, ShootBurret())
timer.Simple(0.2, ShootBurret())
if self:Clip1() >= 3 then
self.Weapon:EmitSound( BurstSound )
end
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Weapon:SetNextPrimaryFire( CurTime()+0.4 )
self.Weapon:SetNextSecondaryFire( CurTime()+2 )
end
if self:Clip1()-1 <= 0 then timer.Simple(0.4, self:Reload()) end
eBullet:SetPos(PlayerPos)
eBullet:SetVar("Velocity",Velocity)
eBullet:SetVar("Acceleration",accel)
local tBullet = {} -- This is the bullet our bullet SENT will be firing when it hits something. Everything except force and damage is determined by the bullet SENT
tBullet.Force = 0.15*3
tBullet.Damage = 3
local tTrace = {} --This is the trace the bullet SENT uses to see if it has hit something
tTrace.filter = filter or {self.Owner,eBullet}
tTrace.mask = mask
eBullet:SetVar("Bullet",tBullet)
eBullet:SetVar("Trace",tTrace)
eBullet:SetVar("Owner",self.Owner)
eBullet:Spawn()
eBullet:Spawn()
end
function SWEP:ApplyRecoil(recoil) -- Kick your view.
if self.OwnerIsNPC or (SERVER and not self.Owner:IsListenServerHost()) then return end
local EyeAng = Angle(
recoil*math.Rand(-1,-0.7), -- Up/Down recoil
recoil*math.Rand(-0.4,0.4), -- Left/Right recoil
0)
-- Punch the player's view
self.Owner:ViewPunch(EyeAng) -- This smooths out the player's screen movement when recoil is applied
self.Owner:SetEyeAngles(self.Owner:EyeAngles() + EyeAng)
end
--[[
function SWEP:DoDMG(EntHit)
local OldHealth = EntHit:GetHealth()
local dmginfo = DamageInfo()
local DMGToDo=math.min(OldHealth-1,ATKPower)
local LostDmg = OldHealth-DMGToDo
dmginfo:SetDamage( DMGToDo ) -- 7 damage or whatever is left-1
dmginfo:SetDamageType( DMG_STUN ) --Stun damage
dmginfo:SetAttacker( self.Owner ) --You.
dmginfo:SetSetInflictor( self )
dmginfo:SetDamageForce( self.Owner:EyeAngles()*20 ) --Launch away
local HealSteps=OldHealth-LostDmg
EntHit:TakeDamageInfo( dmginfo )
Player:GiveAmmo( ATKPower, "GaussEnergy", true )
for i=1,HealSteps do
timer.Simple(0.05*i,function() EntHit:SetHealth( OldHealth + 1*i end ) ) -- In at most 0.65 seconds, replenish health damage. TODO? Is it dead?
end
end
]]--
/*---------------------------------------------------------
SecondaryAttack switches fire mode.
---------------------------------------------------------*/
local BurstFireMode = false
function SWEP:SecondaryAttack()
if !BurstFireMode then
BurstFireMode = true
self.Weapon:EmitSound( SwitchBurstSound )
end
if BurstFireMode then
BurstFireMode = false
self.Weapon:EmitSound( SwitchSingleSound )
end
self.Weapon:SetNextPrimaryFire( CurTime()+0.4 )
self.Weapon:SetNextSecondaryFire( CurTime()+2 )
end
function SWEP
So I guess that makes this Help Me Because My Problems Are More Important V1.
No. The WDYNHW thread is moving way too slowly. Also, it fills up so fast that I can't even find my answers. If people could always use the quote function, that would help.
[QUOTE=luavirusfree;39292553]No. The WDYNHW thread is moving way too slowly. Also, it fills up so fast that I can't even find my answers. If people could always use the quote function, that would help.[/QUOTE]
Seriously, stop fucking spamming the forum with your errors, if someone wants to help you they'll help you.
Making another thread won't draw attention to your problem with 'your' code, it will only draw attention to how impatient and how immature you are to even wait for someone to help you.
[QUOTE=brandonj4;39292584]Seriously, stop fucking spamming the forum with your errors, if someone wants to help you they'll help you.
Making another thread won't draw attention to your problem with 'your' code, it will only draw attention to how impatient and how immature you are to even wait for someone to help you.[/QUOTE]
I.
Hate.
You.
Please.
Go.
Away.
Seriously, I'm not going to listen to anything you say. And I don't spam, but with so many pages, I don't expect anyone else to look backwards through it. I just want to make sure my problem is seen =P
Any they should want to help the guy with half of a brain because of a car accident...
[QUOTE=luavirusfree;39292636]Any they should want to help the guy with half of a brain because of a car accident...[/QUOTE]
Don't make random appeals for pity.
You made this thread because you were unwilling to play fair to the other people with problems, instead deciding to contribute to the plague of simple errors that is this section of facepunch.
Oh, really, if it's such a simple error then prove it. Tell me what's wrong.
well
you are acting like a big ass morron
YOU are the one who isnt welcome here
so until you change your attitude no one is going to help you at all
And let's be honest, if you can't figure out these simple swep errors, there's no way you could make a game mode as complex as you're pitching. All you've done is post ideas, I think it's time to throw in the towel
[QUOTE=Ericson666;39294297]And let's be honest, if you can't figure out these simple swep errors, there's no way you could make a game mode as complex as you're pitching. All you've done is post ideas, I think it's time to throw in the towel[/QUOTE]
A lot of people don't even consider thinking, "Hmm, What's the difference between this line and the other lines".
I think they decide to just come to the community and ask for help because they're so ungodly lazy it just hurts to think about it.
Again, if it's such a simple problem, please enlighten me. And after my injury... I have become more aggressive. For that matter, before it happened I didn't get these kinds of errors. Either tell me what's wrong, or how to figure it out.
[QUOTE=luavirusfree;39295322]Again, if it's such a simple problem, please enlighten me. And after my injury... I have become more aggressive. For that matter, before it happened I didn't get these kinds of errors. Either tell me what's wrong, or how to figure it out.[/QUOTE]
After you're injury?
I'm sorry, But should i waltz in here, And say.
Hey guys, I need help with this, I have tachycardia, Chronic hallucinations, Locomotion problems, and a horrible heart condition.
The answer is no, I shouldn't, Because despite my problems, Everyone is an equal being to another, And we should be treated as such.
Idiot. I got a BRAIN INJURY in a CAR ACCIDENT. out of 1-10, 1 being a smack to the head and 10 being having no more brain than what I need, it would have ranked at an 8!
At first, I wasn't able to walk, talk, or even control my body. Actually, at the very first month afterwords, I would have died if I was talked to.
lol no
now you are just using a very lame excuse i got a lot of friends and fimilar who had brain injuries and all of them are perfectly ok
also if you truly had a brain injury wouldnt you have some sort of ACTUAL problem? becouse right now it looks like ..you know... an lame excuse
so get out
FUCK OFF! It's serious you fucking twat. And I will be perfectly fine AFTER my rehab. As for lua, rehab doesn't help with that. Read my edit. It's amazing that I'm even able to press the keys on my keyboard.
[editline]20th January 2013[/editline]
And the fact that I am giving myself the challenge of making such a gamemode is just my way of seeing how well I am now.
[highlight](User was banned for this post ("Flaming" - Ninja101))[/highlight]
[QUOTE=luavirusfree;39295601]FUCK OFF! It's serious you fucking twat. And I will be perfectly fine AFTER my rehab. As for lua, rehab doesn't help with that. Read my edit. It's amazing that I'm even able to press the keys on my keyboard.
[editline]20th January 2013[/editline]
And the fact that I am giving myself the challenge of making such a gamemode is just my way of seeing how well I am now.[/QUOTE]
Do you need to resort to such language to express yourself?
Chill out for a minute and just think about what your saying.
Let me see... right now I have Physical Therapy, Speech Therapy and Occupational Therapy all in rehab, as well as a psychologist to help repair my brain in more ways. Also, I have recreational therapy to reintegrate myself into the community. If you want me to get a list of all of my problems, I will try my hardest.
[editline]20th January 2013[/editline]
Yea... should I add that the brain injury has caused me to get angry more easily, and be more aggressive? I'm taking medicine for that, but it doesn't fix the problem.
[QUOTE=luavirusfree;39295640]Let me see... right now I have Physical Therapy, Speech Therapy and Occupational Therapy all in rehab, as well as a psychologist to help repair my brain in more ways. Also, I have recreational therapy to reintegrate myself into the community. If you want me to get a list of all of my problems, I will try my hardest.[/QUOTE]
If you want to waste your time trying to get me to pity you, Then go ahead.
I had just graduated high school before the accident happened. I forgot almost 2 years of my life.
Stop pulling the brain damage card, no one feels bad for you, you said yourself you got it from driving drunk/high at 90MPH, and you got a friend hurt. It's your own damn fault, stop trying to guilt us
[QUOTE=Ericson666;39295676]Stop pulling the brain damage card, no one feels bad for you, you said yourself you got it from driving drunk/high at 90MPH, and you got a friend hurt. It's your own damn fault, stop trying to guilt us[/QUOTE]
You're reading my mind~
No, I don't want your pity, I just want everyone at this forum to understand my situation. I should be dead. I only had a 40% chance of surviving, and a 60% chance of dying, before I got the surgery to repair my leg (which was broken in half at the calf). Please, can people stop calling me dumb or stupid, and just get a grasp of this concept? I want to live my life as I would've if nothing had happened at all.
If you're unable to post without aggressiveness, perhaps you should refrain for some time
In this state, no one's going to be able, or willing to help. It's not as if we aren't willing, but calling every other person in the thread an idiot isn't going to make things better
You're the one who keeps bringing it up bro
You are honestly making a joke out of yourself, nobody is believing this "brain damage" thing, it's just so hilariously pathetic.
On the other hand, someone must be somewhat retarded to not realize how much you fucked up on these forums.
And even IF your story was true, you shouldn't post on a forum like this, hell, you shouldn't be ANYWHERE in the internet right now.
So in any case, please, for the love of god, get out.
I'm not trying to guilt you! I just want you to understand, and stop reticuling me for it!
[QUOTE=luavirusfree;39295695]I want to live my life as I would've if nothing had happened at all.[/QUOTE]
Then stop bringing it up, End of story.
First of all Luavirusfree, welcome to the internet. A lot of people are dicks, and it'll stay that way forever. And secondly, talking about your condition won't help. People don't give a brown shit about it.
SERIOUSLY! FUCK OFF! IT REALLY HAPPENED AND I ALMOST DIED!!!!!!!!! I'm fucking glad that I am actually alive, and I don't actually remember it AT ALL. I just know I was drunk. How I got drunk? I don't know. Do I recall getting in the car? NO! Do I recall the events right before the accident? NO! STOP IT AND JUST ACCEPT IT because there is NO WAY IN HELL I can convince you with speech, I have no skill. If this were fallout, all of my skills are at 10 or lower.
[editline]20th January 2013[/editline]
I'm sorry, self-proclaimed ass holes, but seriously, please help me! I want to return to how I was, and I can't do that without my Lua skills that I had before.
Please, just stop. This isn't the way to get anybody to help you.
Sorry, you need to Log In to post a reply to this thread.