Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Thanks to GDCW for an awesome RPG and entities, Failure for the MK6 model,
- //Teta_Bonita for the nuke explosion entity, and Clavus for the construction kit
- //if I missed anyone, sorry. This isn't going to be released to the public anyway.
- // Variables that are used on both client and server
- SWEP.Category = "Ultraviolence"
- SWEP.Author = "Generic Default"
- SWEP.Contact = ""
- SWEP.Purpose = ""
- SWEP.Instructions = "Hammerdown Protocol"
- SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 models
- SWEP.ShellEjectAttachment = "2" -- Should be "2" for CSS models or "1" for hl2 models
- SWEP.DrawCrosshair = false
- SWEP.ViewModelFOV = 55
- SWEP.ViewModelFlip = false
- SWEP.ViewModel = "models/weapons/v_RL7.mdl"
- SWEP.WorldModel = "models/weapons/w_GDC_RPG7.mdl"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.Primary.Round = ("gdcwa_davycrockett")
- SWEP.Primary.RPM = 20 // This is in Rounds Per Minute
- SWEP.Primary.ClipSize = 1 // Size of a clip
- SWEP.Primary.DefaultClip = 1 // Default number of bullets in a clip
- SWEP.Primary.Automatic = false // Automatic/Semi Auto
- SWEP.Primary.Ammo = "RPG_Round"
- SWEP.Secondary.ClipSize = 1 // Size of a clip
- SWEP.Secondary.DefaultClip = 1 // Default number of bullets in a clip
- SWEP.Secondary.Automatic = false // Automatic/Semi Auto
- SWEP.Secondary.Ammo = ""
- SWEP.data = {} -- The starting firemode
- SWEP.data.ironsights = 1
- SWEP.IronSightsPos = Vector (-3.7384, -5.7481, -0.2713)
- SWEP.IronSightsAng = Vector (1.1426, 0.0675, 0)
- SWEP.SightsPos = Vector (-3.7384, -5.7481, -0.2713)
- SWEP.SightsAng = Vector (1.1426, 0.0675, 0)
- SWEP.RunSightsPos = Vector (2.4946, -1.5644, 1.699)
- SWEP.RunSightsAng = Vector (-20.1104, 35.1164, -12.959)
- function SWEP:Initialize()
- if !self.Owner:IsNPC() then
- self:SetWeaponHoldType("rpg") -- Hold type style ("ar2" "pistol" "shotgun" "rpg" "normal" "melee" "grenade" "smg")
- end
- if SERVER and self.Owner:IsNPC() then
- self:SetWeaponHoldType("rpg") -- Hold type style ("ar2" "pistol" "shotgun" "rpg" "normal" "melee" "grenade" "smg")
- self:SetNPCMinBurst(1)
- self:SetNPCMaxBurst(1) // None of this really matters but you need it here anyway
- self:SetNPCFireRate(1)
- self:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_PERFECT )
- end
- if CLIENT then
- self:CreateModels(self.VElements)
- self:CreateModels(self.WElements)
- end
- end
- function SWEP:OnRemove()
- if CLIENT then
- self:RemoveModels()
- end
- end
- if CLIENT then
- SWEP.vRenderOrder = nil
- function SWEP:ViewModelDrawn()
- local vm = self.Owner:GetViewModel()
- if !ValidEntity(vm) then return end
- if (!self.VElements) then return end
- if (!self.vRenderOrder) then
- self.vRenderOrder = {}
- for k, v in pairs( self.VElements ) do
- if (v.type == "Model") then
- table.insert(self.vRenderOrder, 1, k)
- elseif (v.type == "Sprite") then
- table.insert(self.vRenderOrder, k)
- end
- end
- end
- for k, name in ipairs( self.vRenderOrder ) do
- local v = self.VElements[name]
- if (!v) then self.vRenderOrder = nil break end
- local model = v.modelEnt
- local sprite = v.spriteMaterial
- if (!v.bone) then continue end
- local bone = vm:LookupBone(v.bone)
- if (!bone) then continue end
- local pos, ang = Vector(0,0,0), Angle(0,0,0)
- local m = vm:GetBoneMatrix(bone)
- if (m) then
- pos, ang = m:GetTranslation(), m:GetAngle()
- end
- if (self.ViewModelFlip) then
- ang.r = -ang.r
- end
- if (v.type == "Model" and ValidEntity(model)) then
- model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
- ang:RotateAroundAxis(ang:Up(), v.angle.y)
- ang:RotateAroundAxis(ang:Right(), v.angle.p)
- ang:RotateAroundAxis(ang:Forward(), v.angle.r)
- model:SetAngles(ang)
- model:SetModelScale(v.size)
- if (v.material == "") then
- model:SetMaterial("")
- elseif (model:GetMaterial() != v.material) then
- model:SetMaterial( v.material )
- end
- if (v.surpresslightning) then
- render.SuppressEngineLighting(true)
- end
- render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
- render.SetBlend(v.color.a/255)
- model:DrawModel()
- render.SetBlend(1)
- render.SetColorModulation(1, 1, 1)
- if (v.surpresslightning) then
- render.SuppressEngineLighting(false)
- end
- elseif (v.type == "Sprite" and sprite) then
- local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
- render.SetMaterial(sprite)
- render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
- end
- end
- end
- SWEP.wRenderOrder = nil
- function SWEP:DrawWorldModel()
- if (!self.WElements) then return end
- if (!self.wRenderOrder) then
- self.wRenderOrder = {}
- for k, v in pairs( self.WElements ) do
- if (v.type == "Model") then
- table.insert(self.wRenderOrder, 1, k)
- elseif (v.type == "Sprite") then
- table.insert(self.wRenderOrder, k)
- end
- end
- end
- local bone_ent
- local opos, oang = self:GetPos(), self:GetAngles()
- self:DrawModel()
- if (ValidEntity(self.Owner)) then
- bone_ent = self.Owner
- else
- bone_ent = self
- end
- local bone = bone_ent:LookupBone("ValveBiped.Bip01_R_Hand")
- if (bone) then
- local m = bone_ent:GetBoneMatrix(bone)
- if (m) then
- opos, oang = m:GetTranslation(), m:GetAngle()
- end
- end
- for k, name in pairs( self.wRenderOrder ) do
- local v = self.WElements[name]
- if (!v) then self.wRenderOrder = nil break end
- local model = v.modelEnt
- local sprite = v.spriteMaterial
- local pos, ang = Vector(opos.x, opos.y, opos.z), Angle(oang.p, oang.y, oang.r)
- if (v.type == "Model" and ValidEntity(model)) then
- model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
- ang:RotateAroundAxis(ang:Up(), v.angle.y)
- ang:RotateAroundAxis(ang:Right(), v.angle.p)
- ang:RotateAroundAxis(ang:Forward(), v.angle.r)
- model:SetAngles(ang)
- model:SetModelScale(v.size)
- if (v.material == "") then
- model:SetMaterial("")
- elseif (model:GetMaterial() != v.material) then
- model:SetMaterial( v.material )
- end
- if (v.surpresslightning) then
- render.SuppressEngineLighting(true)
- end
- render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
- render.SetBlend(v.color.a/255)
- model:DrawModel()
- render.SetBlend(1)
- render.SetColorModulation(1, 1, 1)
- if (v.surpresslightning) then
- render.SuppressEngineLighting(false)
- end
- elseif (v.type == "Sprite" and sprite) then
- local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
- render.SetMaterial(sprite)
- render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
- end
- end
- end
- function SWEP:CreateModels( tab )
- if (!tab) then return end
- for k, v in pairs( tab ) do
- if (v.type == "Model" and v.model and v.model != "" and (!ValidEntity(v.modelEnt) or v.createdModel != v.model) and
- string.find(v.model, ".mdl") and file.Exists ("../"..v.model) ) then
- v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
- if (ValidEntity(v.modelEnt)) then
- v.modelEnt:SetPos(self:GetPos())
- v.modelEnt:SetAngles(self:GetAngles())
- v.modelEnt:SetParent(self)
- v.modelEnt:SetNoDraw(true)
- v.createdModel = v.model
- else
- v.modelEnt = nil
- end
- elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
- and file.Exists ("../materials/"..v.sprite..".vmt")) then
- local name = v.sprite.."-"
- local params = { ["$basetexture"] = v.sprite }
- local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
- for i, j in pairs( tocheck ) do
- if (v[j]) then
- params["$"..j] = 1
- name = name.."1"
- else
- name = name.."0"
- end
- end
- v.createdSprite = v.sprite
- v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
- end
- end
- end
- function SWEP:RemoveModels()
- if (self.VElements) then
- for k, v in pairs( self.VElements ) do
- if (ValidEntity( v.modelEnt )) then v.modelEnt:Remove() end
- end
- end
- if (self.WElements) then
- for k, v in pairs( self.WElements ) do
- if (ValidEntity( v.modelEnt )) then v.modelEnt:Remove() end
- end
- end
- self.VElements = rpgbomb
- self.WElements = nuke
- end
- end
- function SWEP:RemoveModels()
- if (self.VElements) then
- for k, v in pairs( self.VElements ) do
- if (ValidEntity( v.modelEnt )) then v.modelEnt:Remove() end
- end
- end
- if (self.WElements) then
- for k, v in pairs( self.WElements ) do
- if (ValidEntity( v.modelEnt )) then v.modelEnt:Remove() end
- end
- end
- self.VElements = rpgbomb
- self.WElements = nuke
- end
- function SWEP:Deploy()
- self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
- end
- function SWEP:Precache()
- util.PrecacheSound("RPGF.single")
- end
- function SWEP:PrimaryAttack()
- if self:CanPrimaryAttack() then
- self:FireRocket()
- self.Weapon:EmitSound("RPGF.single")
- self.Weapon:TakePrimaryAmmo(1)
- self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
- self.VElements:RemoveModels()
- local fx = EffectData()
- fx:SetEntity(self.Weapon)
- fx:SetOrigin(self.Owner:GetShootPos())
- fx:SetNormal(self.Owner:GetAimVector())
- fx:SetAttachment(self.MuzzleAttachment)
- util.Effect("gdcw_backblast",fx)
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- self.Owner:MuzzleFlash()
- self.Weapon:SetNextPrimaryFire(CurTime()+1/(self.Primary.RPM/60))
- end
- end
- function SWEP:FireRocket()
- local aim = self.Owner:GetAimVector()
- local pos = self.Owner:GetShootPos()
- if SERVER then
- local rocket = ents.Create(self.Primary.Round)
- if !rocket:IsValid() then return false end
- rocket:SetAngles(aim:Angle()+Angle(90,0,0))
- rocket:SetPos(pos)
- rocket:SetOwner(self.Owner)
- rocket:Spawn()
- rocket.owner = self.Owner
- rocket:Activate()
- end
- end
- function SWEP:SecondaryAttack()
- return false
- end
- function SWEP:Reload()
- self.Weapon:DefaultReload(ACT_VM_RELOAD)
- -- Animation when you're reloading
- self:SetIronsights(false, self.Owner)
- if ( self.Weapon:Clip1() < self.Primary.ClipSize ) and !self.Owner:IsNPC() then
- return false
- -- When the current clip < full clip and the rest of your ammo > 0, then
- end
- end
- /*---------------------------------------------------------
- IronSight
- ---------------------------------------------------------*/
- function SWEP:IronSight()
- if self.Owner:KeyDown(IN_SPEED) then // If you run then
- self.Weapon:SetNextPrimaryFire(CurTime()+0.5) // Make it so you can't shoot for another quarter second
- self:SetWeaponHoldType("passive") // Hold type styles; ar2 pistol shotgun rpg normal melee grenade smg
- self.IronSightsPos = self.RunSightsPos // Hold it down
- self.IronSightsAng = self.RunSightsAng // Hold it down
- self:SetIronsights(true, self.Owner) // Set the ironsight true
- self.Owner:SetFOV( 0, 0.3 ) // Reset FOV
- end
- if self.Owner:KeyReleased(IN_SPEED) then // If you stop running then
- self:SetWeaponHoldType("rpg") // Hold type styles; ar2 pistol shotgun rpg normal melee grenade smg slam fist melee2 passive knife
- self:SetIronsights(false, self.Owner) // Set the ironsight true
- self.Owner:SetFOV( 0, 0.3 ) // Reset FOV
- end
- if self.Owner:KeyPressed(IN_ATTACK2) then
- self.Owner:SetFOV( 40, 0.5 )
- self.IronSightsPos = self.SightsPos // Bring it up
- self.IronSightsAng = self.SightsAng // Bring it up
- self:SetIronsights(true, self.Owner)
- end
- if self.Owner:KeyReleased(IN_ATTACK2) and !self.Owner:KeyDown(IN_SPEED) then
- self.Owner:SetFOV( 0, 0.5 )
- self:SetIronsights(false, self.Owner)
- end
- end
- /*---------------------------------------------------------
- Think
- ---------------------------------------------------------*/
- function SWEP:Think()
- self:IronSight()
- end
- /*---------------------------------------------------------
- GetViewModelPosition
- ---------------------------------------------------------*/
- local IRONSIGHT_TIME = 0.5
- -- Time to enter in the ironsight mod
- function SWEP:GetViewModelPosition(pos, ang)
- if (not self.IronSightsPos) then return pos, ang end
- local bIron = self.Weapon:GetNWBool("Ironsights")
- if (bIron != self.bLastIron) then
- self.bLastIron = bIron
- self.fIronTime = CurTime()
- if (bIron) and !self.Owner:KeyDown(IN_SPEED) then // If Ironsights and NOT RUNNING then
- self.SwayScale = 0.02
- self.BobScale = 0.02
- else
- self.SwayScale = 1.0
- self.BobScale = 1.0
- end
- end
- local fIronTime = self.fIronTime or 0
- if (not bIron and fIronTime < CurTime() - IRONSIGHT_TIME) then
- return pos, ang
- end
- local Mul = 1.0
- if (fIronTime > CurTime() - IRONSIGHT_TIME) then
- Mul = math.Clamp((CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1)
- if not bIron then Mul = 1 - Mul end
- end
- local Offset = self.IronSightsPos
- if (self.IronSightsAng) then
- ang = ang * 1
- ang:RotateAroundAxis(ang:Right(), self.IronSightsAng.x * Mul)
- ang:RotateAroundAxis(ang:Up(), self.IronSightsAng.y * Mul)
- ang:RotateAroundAxis(ang:Forward(), self.IronSightsAng.z * Mul)
- end
- local Right = ang:Right()
- local Up = ang:Up()
- local Forward = ang:Forward()
- pos = pos + Offset.x * Right * Mul
- pos = pos + Offset.y * Forward * Mul
- pos = pos + Offset.z * Up * Mul
- return pos, ang
- end
- /*---------------------------------------------------------
- SetIronsights
- ---------------------------------------------------------*/
- function SWEP:SetIronsights(b)
- self.Weapon:SetNetworkedBool("Ironsights", b)
- end
- function SWEP:GetIronsights()
- return self.Weapon:GetNWBool("Ironsights")
- end
- //the madness starts here===================================================================
- // it all went here function SWEP:Initialize()
- //end
- SWEP.VElements = {
- ["rpgbomb"] = { type = "Model", model = "models/Failure/MK6/mk6.mdl", bone = "ValveBiped.SphereGizmo02.RPG.Rocket", pos = Vector(0, 5.057, -5.844), angle = Angle(0, -90, 0), size = Vector(0.372, 0.372, 0.372), color = Color(255, 255, 255, 255), surpresslightning = false, material = "models/Failure/MK6/Base"}
- }
- SWEP.WElements = {
- ["nuke"] = { type = "Model", model = "models/Failure/MK6/mk6.mdl", bone = "ValveBiped.Bip01_R_Hand", pos = Vector(30, -0.313, -17.556), angle = Angle(-9.756, 0, 0), size = Vector(0.405, 0.405, 0.405), color = Color(255, 255, 255, 255), surpresslightning = false, material = ""}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement