Skip to content

Commit

Permalink
Create the ion cannon (#65)
Browse files Browse the repository at this point in the history
* Create the ion cannon

* Stop viewmodel shake upon firing

* Disable vm shake correctly

* Reduce charge recoil

* Increase explosion radius

* Reduce damage falloff

* Improve killicon brightness

* Holy hell just disable the vm shake already

* Fix charge gun prediction

* Use bullet callback for the explosion

* Tweak explosion visuals

* Further reduce explosion visual to better match main area of damage

* Increase explosion radius

* Fix nil error

* Prevent collisions with owner

* Manually compensate lag

* Optimize

* Properly deny holster while releasing

* Add one-time hints for the ion cannon, bonk shotgun, and shaped charge

* Auto-create convars to persist hint seen status across sessions

* Add first-time hint for the trash blaster

* Default functions

* Fix owner charge step sound

* Create charge sprite

* Fix sound and step callback not running for final charge

* Fix sprite sometimes appearing full size for one tick

* Tweak ion cannon charge sprite

* Fix nil error when sprite update is late

* Force overcharge on ion cannon if fired beyond limits

* Remove dead comments

* Remove unnecessary IsValid() checks

* :Remove() already delays by a tick

* Replace anim timer with think function

* AddPAS() instead
  • Loading branch information
legokidlogan authored Jun 2, 2024
1 parent b99528c commit 2fba8c2
Show file tree
Hide file tree
Showing 70 changed files with 1,184 additions and 109 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
- [Slap swep](https://steamcommunity.com/sharedfiles/filedetails/?id=1052253533) - Workshop
- [Simple Weapons SWEP Base](https://github.com/TankNut/simple-weapons) - GitHub
- [Ithaca M37 (bonk gun model)](https://steamcommunity.com/sharedfiles/filedetails/?id=128091208) - Workshop
- [MMod Tau Cannon (ion cannon)](https://steamcommunity.com/sharedfiles/filedetails/?id=2885673816) - Workshop rip from MMod
53 changes: 53 additions & 0 deletions lua/autorun/client/cfc_pvp_weapons.lua
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
local hintConvars = {}


list.Set( "ContentCategoryIcons", "CFC", "icon16/star.png" )


-- Most reliable way on client to listen when a weapon is equipped without using net messages.
-- Only misses if the weapon is given via initial loadout on spawn, which is fine in this case.
hook.Add( "HUDWeaponPickedUp", "CFC_PvPWeapons_FirstTimeHints", function( wep )
if not IsValid( wep ) then return end

local hints = wep.CFC_FirstTimeHints
if not hints then return end

local class = wep:GetClass()
local convar = hintConvars[class]

if not convar then
convar = CreateClientConVar( "cfc_pvp_weapons_hint_seen_" .. class, "0", true, false )
hintConvars[class] = convar
end

if convar:GetInt() == 1 then return end

convar:SetInt( 1 )

local hintInd = 1

local function showHint()
local hint = hints[hintInd]
if not hint then return end

local message = hint.Message
local soundPath = hint.Sound
local duration = hint.Duration or 8
local delayNext = hint.DelayNext or 0

if soundPath == nil then
soundPath = "ambient/water/drip1.wav"
end

notification.AddLegacy( message, NOTIFY_HINT, duration )

if soundPath then
surface.PlaySound( soundPath )
end

hintInd = hintInd + 1

timer.Simple( delayNext, showHint )
end

showHint()
end )
1 change: 1 addition & 0 deletions lua/autorun/client/cfc_pvp_weapons_killicons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ local icol = Color( 255, 255, 255, 255 )

killicon.Add( "cfc_bonk_shotgun", "vgui/hud/cfc_bonk_shotgun", icol )
killicon.Add( "cfc_trash_blaster", "vgui/hud/cfc_trash_blaster", icol ) -- Sadly won't appear since the kills will attribute to generic prop kill instead
killicon.Add( "cfc_ion_cannon", "vgui/hud/cfc_ion_cannon", icol )
15 changes: 15 additions & 0 deletions lua/weapons/cfc_bonk_shotgun/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ SWEP.Primary = {
TracerName = "Tracer", -- Tracer effect, leave blank for no tracer
}

SWEP.CFC_FirstTimeHints = {
{
Message = "The Bonk Shotgun is a powerful mobility tool. Shoot downwards while in the air to launch yourself.",
Sound = "ambient/water/drip1.wav",
Duration = 10,
DelayNext = 6,
},
{
Message = "The Bonk Shotgun can also launch your enemies into walls to deal extra damage.",
Sound = "ambient/water/drip2.wav",
Duration = 8,
DelayNext = 0,
},
}

SWEP.ViewOffset = Vector( 0, 0, 0 ) -- Optional: Applies an offset to the viewmodel's position


Expand Down
Loading

0 comments on commit 2fba8c2

Please sign in to comment.