1,875 Posts in 546 Topics - by 1,450 Members - Latest Member: Mr Cheese (MrCheese)

Author Topic: Explosives  (Read 2792 times)

0 Members and 2 Guests are viewing this topic.

Offline Bishop Wallace (Bish)

  • MEME
  • Developer
  • Full Member
  • Date Registered: Mar 2017
  • Posts: 67
  • The or something
    • United States
    • Windows 10
    • Chrome
Explosives
« on: September 03, 2017, 02:21:05 pm »
I think we should add in 1 grenade launcher and one grenade.

I modified the files for the M79 GL (single shot grenade launcher) to do better.  It has less explosive radius than before but still does the same damage.   It would be a good single shot grenade launcher that isn't too OP and could be a cheaper alt to the current RPG.  Still expensive but not quite as expensive as the RPG.  The RPG is direct fire and can cross the map while the grenade launcher is indirect fire that is more close range. 

Code: [Select]
-- Variables that are used on both client and server
SWEP.Gun = ("m9k_m79gl") -- must be the name of your swep but NO CAPITALS!
if (GetConVar(SWEP.Gun.."_allowed")) != nil then
if not (GetConVar(SWEP.Gun.."_allowed"):GetBool()) then SWEP.Base = "bobs_blacklisted" SWEP.PrintName = SWEP.Gun return end
end
SWEP.Category = "M9K Specialties"
SWEP.Author = ""
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = ""
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.PrintName = "M79 GL" -- Weapon name (Shown on HUD)
SWEP.Slot = 4 -- Slot in the weapon selection menu
SWEP.SlotPos = 29 -- Position in the slot
SWEP.DrawAmmo = true -- Should draw the default HL2 ammo counter
SWEP.DrawWeaponInfoBox = false -- Should draw the weapon info box
SWEP.BounceWeaponIcon    = false -- Should the weapon icon bounce?
SWEP.DrawCrosshair = true -- set false if you want no crosshair
SWEP.Weight = 30 -- rank relative ot other weapons. bigger is better
SWEP.AutoSwitchTo = true -- Auto switch to if we pick it up
SWEP.AutoSwitchFrom = true -- Auto switch from if you pick up a better weapon
SWEP.HoldType = "shotgun" -- how others view you carrying the weapon
-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive
-- you're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles

SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_m79_grenadelauncher.mdl" -- Weapon view model
SWEP.WorldModel = "models/weapons/w_m79_grenadelauncher.mdl" -- Weapon world model
SWEP.ShowWorldModel = true

SWEP.Base = "bobs_shotty_base"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.FiresUnderwater = false

SWEP.Primary.Sound = Sound("40mmGrenade.Single") -- Script that calls the primary fire sound
SWEP.Primary.RPM = 15 -- This is in Rounds Per Minute
SWEP.Primary.ClipSize = 1 -- Size of a clip
SWEP.Primary.DefaultClip = 1 -- Bullets you start with
SWEP.Primary.KickUp = 0.3 -- Maximum up recoil (rise)
SWEP.Primary.KickDown = 0.3 -- Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal = 0.3 -- Maximum up recoil (stock)
SWEP.Primary.Automatic = false -- Automatic = true; Semi Auto = false
SWEP.Primary.Ammo = "40mmGrenade"

SWEP.Secondary.IronFOV = 60 -- How much you 'zoom' in. Less is more!
SWEP.Primary.Round = ("m9k_milkor_nade") --NAME OF ENTITY GOES HERE
SWEP.data = {} --The starting firemode
SWEP.data.ironsights = 1

SWEP.ShellTime = .5

SWEP.Primary.NumShots = 1 -- How many bullets to shoot per trigger pull
SWEP.Primary.Damage = 30 -- Base damage per bullet
SWEP.Primary.Spread = .025 -- Define from-the-hip accuracy (1 is terrible, .0001 is exact)
SWEP.Primary.IronAccuracy = .015 -- Ironsight accuracy, should be the same for shotguns

-- Enter iron sight info and bone mod info below
SWEP.IronSightsPos = Vector(-4.633, -7.651, 2.108)
SWEP.IronSightsAng = Vector(1.294, 0.15, 0)
SWEP.SightsPos = Vector(-4.633, -7.651, 2.108)
SWEP.SightsAng = Vector(1.294, 0.15, 0)
SWEP.RunSightsPos = Vector(3.279, -5.574, 0)
SWEP.RunSightsAng = Vector(-1.721, 49.917, 0)

-- SWEP.WElements = {
-- ["launcher"] = { type = "Model", model = "models/weapons/w_m79_grenadelauncher.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(44.681, 1.463, -11), angle = Angle(-180, -91.008, 16.164), size = Vector(1.378, 1.378, 1.378), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
-- }


function SWEP:Deploy()
if not IsValid(self) then return end
if not IsValid(self.Owner) then return end
if not self.Owner:IsPlayer() then return end

self:SetHoldType(self.HoldType)

local timerName = "ShotgunReload_" ..  self.Owner:UniqueID()
if (timer.Exists(timerName)) then
timer.Destroy(timerName)
end

self.Weapon:SendWeaponAnim(ACT_VM_DRAW)

self.Weapon:SetNextPrimaryFire(CurTime() + .25)
self.Weapon:SetNextSecondaryFire(CurTime() + .25)
self.ActionDelay = (CurTime() + .25)
-----------------------------------------self.Weapon.NextFireTime = (CurTime() + .25)

if (SERVER) then
self:SetIronsights(false)
end

self.NextReload = CurTime() + 1

return true
end

function SWEP:PrimaryAttack()
if self:CanPrimaryAttack() then ------------------------------------- and self.Weapon.NextFireTime <= CurTime() then
if !self.Owner:KeyDown(IN_SPEED) and !self.Owner:KeyDown(IN_RELOAD) then
self:FireRocket()
self.Weapon:EmitSound(self.Primary.Sound)
self.Weapon:TakePrimaryAmmo(1)
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
local fx = EffectData()
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Owner:MuzzleFlash()
self.Weapon:SetNextPrimaryFire(CurTime()+1.75)
----------------------------------------------------self.Weapon.NextFireTime = (CurTime() + 2)
else self:Reload()
end
end
self:CheckWeaponsAndAmmo()
end

function SWEP:FireRocket()
local aim = self.Owner:GetAimVector()
local side = aim:Cross(Vector(0,0,1))
local up = side:Cross(aim)
local pos = self.Owner:GetShootPos() + side * 6 + up * -5

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:Activate()
end
end


function SWEP:Reload()

if not IsValid(self) then return end
if not IsValid(self.Owner) then return end
if not self.Owner:IsPlayer() then return end

local maxcap = self.Primary.ClipSize
local spaceavail = self.Weapon:Clip1()
local shellz = (maxcap) - (spaceavail) + 1

if (timer.Exists("ShotgunReload")) or self.NextReload > CurTime() or maxcap == spaceavail then return end

if self.Owner:IsPlayer() then

self.Weapon:SetNextPrimaryFire(CurTime() + 1.75) -- wait one second before you can shoot again
self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_START) -- sending start reload anim
self.Owner:SetAnimation( PLAYER_RELOAD )

self.NextReload = CurTime() + 1

if (SERVER) then
self.Owner:SetFOV( 0, 0.15 )
self:SetIronsights(false)
end

if SERVER and self.Owner:Alive() then
local timerName = "ShotgunReload_" ..  self.Owner:UniqueID()
timer.Create(timerName,
(self.ShellTime + .05),
shellz,
function() if not IsValid(self) then return end
if IsValid(self.Owner) and IsValid(self.Weapon) then
if self.Owner:Alive() then
self:InsertShell()
end
end end)
end

elseif self.Owner:IsNPC() then
self.Weapon:DefaultReload(ACT_VM_RELOAD)
end

end

function SWEP:CheckWeaponsAndAmmo()
if SERVER and self.Weapon != nil then
if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 and (GetConVar("M9KWeaponStrip"):GetBool()) then
timer.Simple(.5, function() if SERVER then if not IsValid(self) then return end
if not IsValid(self.Owner) then return end
self.Owner:StripWeapon(self.Gun)
end end)
else
self:Reload()
end
end
end


function SWEP:Think()
if not IsValid(self) then return end
if not IsValid(self.Owner) then return end
if not self.Owner:IsPlayer() then return end

if self.InsertingShell == true and self.Owner:Alive() then
vm = self.Owner:GetViewModel()-- its a messy way to do it, but holy shit, it works!
vm:ResetSequence(vm:LookupSequence("after_reload")) -- Fuck you, garry, why the hell can't I reset a sequence in multiplayer?
vm:SetPlaybackRate(.01) -- or if I can, why does facepunch have to be such a shitty community, and your wiki have to be an unreadable goddamn mess?
self.InsertingShell = false -- You get paid for this, what's your excuse?
end

self:IronSight()

end


if GetConVar("M9KDefaultClip") == nil then
print("M9KDefaultClip is missing! You may have hit the lua limit!")
else
if GetConVar("M9KDefaultClip"):GetInt() != -1 then
SWEP.Primary.DefaultClip = SWEP.Primary.ClipSize * GetConVar("M9KDefaultClip"):GetInt()
end
end

if GetConVar("M9KUniqueSlots") != nil then
if not (GetConVar("M9KUniqueSlots"):GetBool()) then
SWEP.SlotPos = 2
end
end


Just drag and drop into the M79 GL grenade launcher code and replace all of the code in that file and it will work.  Keep the old code for the weapon backed up just in case though.



Now, onto grenades.  We could either add in the HL2 grenade or the M9k frag.  Honestly, I think the HL2 frag would be better just because if we go to change weapon bases in the future, it won't require any changing... that and you dont have to nerf it.

That two

Offline Jakob Swanson (Jakob Swanson)

  • Meme
  • New Member
  • Date Registered: Jul 2017
  • Posts: 9
  • Professional Meme Lover
    • United States
    • Windows 10
    • Chrome
Re: Explosives
« Reply #1 on: November 14, 2017, 09:12:51 pm »
I personally think that explosives in general are a bad route to go down without a stable server, and with HRPs' tenancy to crash with even the amount of props 30 people all sum up to, I highly discourage the use of this. Although, it is a wonderful idea!


Offline Bishop Wallace (Bish)

  • MEME
  • Developer
  • Full Member
  • Date Registered: Mar 2017
  • Posts: 67
  • The or something
    • United States
    • Windows 10
    • Chrome
Re: Explosives
« Reply #2 on: November 19, 2017, 09:55:17 am »
I personally think that explosives in general are a bad route to go down without a stable server, and with HRPs' tenancy to crash with even the amount of props 30 people all sum up to, I highly discourage the use of this. Although, it is a wonderful idea!
We already have an RPG.  This won't make much difference.. just more things players can buy.

That two

Zafiro

  • Guest
Re: Explosives
« Reply #3 on: November 21, 2017, 04:12:49 pm »
I don't think it would bother performance as in my experience most BMD items are barely used especially something highly expensive like explosives however, I wouldn't want the RPG to have a cheaper counterpart.


Offline Bishop Wallace (Bish)

  • MEME
  • Developer
  • Full Member
  • Date Registered: Mar 2017
  • Posts: 67
  • The or something
    • United States
    • Windows 10
    • Chrome
Re: Explosives
« Reply #4 on: November 21, 2017, 07:43:05 pm »
I don't think it would bother performance as in my experience most BMD items are barely used especially something highly expensive like explosives however, I wouldn't want the RPG to have a cheaper counterpart.
With this in place, its "Cheaper" but it doesn't do the same.  It has less damage, less radius... just will have a slightly lower cost.  The rounds themselves won't even kill in one hit if you have 100 health.

That two