Not tuned-up real good but IT WORKS! (most of the time)
Had to do things a little different because some of my initial assumptions were wrong. It hasn't been stress tested, so it's probably pretty easy to mess it up by doing random things which can break the script. I'm not going to spend the time making it bullet-proof though because I don't have time. If you need clarification on why I did things a certian way, just ask.
When it breaks, it usually breaks at state 12/13. This is likely some timing or framerate fluctuations causing plrtake lag (or not enough lag). If that can be smoothed out it should be pretty OK. It seems a little more stable if PBUM is running in optimized mode.
If it breaks/hangs between states 12/13 (the G36 will be putaway but the knife not come out), you can scroll to the knife and it will autoattack and reset the script.
You can also break it by spamming the F key.
Anyhow...
Combat Knife Gunspec (gunspec.txt)
;v1.101s Enhanced for AirMod, interim PBUM/Ply'sMod DW, tweaked for much faster response times. Weapon script.
usescript=autoknife.fpi
;GUN Model File Requirements
;GUN Settings
damage = 20
damagetype = 1
scorchtype = 3
reloadqty = 0
range = 65
;GUN Visuals
textured =
effect = effectbank\BumpCubeReflectAlpha\BumpCubeReflectAlpha.fx
transparency = 1
weapontype = 0
;GUN Sounds
sound1 = fire.wav
sound2 = retrieve.wav
sound3 = putaway.wav
fireloop = 9000
;HUD muzzleflash position
;horiz = 0
horiz = 1
vert = 0
forward = 3
alignx = 0
aligny = -50
alignz = 0
;HUD animation frames list
keyframe ratio = 1
;select = 9,19
select = 15,19
idle = 20,59
move = 60,84
;stabbing animation
;start fire 2 = 85,93
;end fire 2 = 94,112
start fire 2 = 92,93
end fire 2 = 94,98
;stabbing animation
;start fire 3 = 85,93
;end fire 3 = 94,112
start fire 3 = 92,93
end fire 3 = 94,98
;backslashing animation
;start fire = 135,141
;end fire = 142,150
start fire = 139,140
end fire = 142,146
;block = 120,134
block = 124,132
putaway = 113,118
;HUD sound frames list
soundframes = 4
sframe0 = 91,1
sframe1 = 9,2
sframe2 = 94,1
sframe3 = 142,1
;sframe2 = 115,3
;sframe3 = 137,1
;AirMod Settings
noscorch = 1
recoily = 0
recoilyreturn = 0
recoilx = 15
recoilxreturn = 100
gunlagspeed = 14
gunlagxmax = 30
gunlagymax = 10
;Ply's Mod/PBUM
candual = 1
Combat Knife Weapon Script (autoknife.fpi)
; -------------
;//Weapon Script
; -------------
;//Description
desc = Weapon AI for autoknife
;//Triggers
;//Firing Control
:varequal=plrweaplock 0,isrightweap,haveweapleft=0,mouseclick=1:fireweapon
:varequal=plrweaplock 0,isrightweap,haveweapleft=1,mouseclick=2:fireweapon
:varequal=plrweaplock 0,isleftweap,haveweapright=0,mouseclick=1:fireweapon
:varequal=plrweaplock 0,isleftweap,haveweapright=1,mouseclick=1:fireweapon
;//External Control
:varequal=plrforcefire 1:fireweapon
;End Script
Combat Knife Pickup Entity Script (eai_autoknife_pickup.fpi)
Set to always active with max respawn and minimum spawn delay.
;Artificial Intelligence Script
;Header
desc = Var. triggered Weapon Pickup (autoknife)
;Triggers
:varequal=giveautoknife 1:playertake,coloff
;End of Script
And finally, assign the actual script to a dynamic light(eai_autoknife.fpi)
desc = swap, use and swap back
;//Vars
;//plrweaplock locks out weapon input from player to prevent interruption
:state=0:dimvar=plrweaplock,setvar=plrweaplock 0
;//plrforcefire fires the current weapon via script trigger
:state=0:dimvar=giveautoknife,setvar=giveautoknife 0
;//plrforcefire fires the current weapon via script trigger
:state=0:dimvar=plrforcefire,setvar=plrforcefire 0
:state=0:state=10
;//stow current weapon and clear kife from inv. if present
:state=10,varequal=plrweaplock 0,haveweap=1,keypressed=33 1:removeweap=eai\combatknife,state=11
:state=11,keypressed=33 0:setvar=plrweaplock 1,hideplrweapon,state=12
;//give knife
:state=12,haveweap=0:setvar=giveautoknife 1,state=13
:state=13,haveweap=eai\combatknife:setvar=giveautoknife 0,state=14,etimerstart
;//use knife
:state=14,haveweap=eai\combatknife:setvar=plrforcefire 1,state=16
;//restore original weapon
:state=16,etimergreater=700:setvar=plrforcefire 0,showplrweapon,state=17
;//remove knife from inventory
:state=17:removeweap=eai\combatknife,setvar=plrweaplock 0,state=10
;//test/debug-----------------------------------------------------------------------------
;//forcefire manual test
:state=10,keypressed=34 1:setvar=plrforcefire 1,state=50
:state=50,keypressed=34 0:state=51
:state=51:setvar=plrforcefire 0,state=10
;//debug
:varequal=plrforcefire 0:setcursor=10 710,printstr=ready
:varequal=plrforcefire 1:setcursor=10 710,printstr=forcefire
::setcursor=10 690,printstr=giveweap
::setcursor=100 690,printval=%giveautoknife
:haveweap=eai\combatknife:setcursor=10 670,printstr=knife
;//End Script
(SCAR and the other things are off the table for now unless the money is irresistable- Just no time ATM. I shouldn't have even messed with this but I'm procrastinating.)