@Shadowtroid:
Here's my default weapon script, if you're still in need of one:
; -------------
; Weapon Script
; -------------
; -- Written by: Plystire
; -------------
; Description
desc = Weapon AI
; Triggers
; ------Firing Control
:state=0,isrightweap,haveweapleft=0,mouseclick=1,reloading=0:fireweapon
:state=0,isrightweap,haveweapleft=1,mouseclick=2,reloading=0:fireweapon
:state=0,isrightweap,haveweapleft=1,mouseclick=3,reloading=0:fireweapon
:state=0,isleftweap,mouseclick=1,reloading=0:fireweapon
:state=0,isleftweap,mouseclick=3,reloading=0:fireweapon
; ------Reload Control
:state=1,reloading=0:enterzoom,state=0
:state=0,plrusingreload=1,zoomed=0:reloadplrweap
:state=0,plrusingreload=1,zoomed=1:reloadplrweap,leavezoom,state=1
:state=0,reloading=1,zoomed=1:leavezoom,state=1
; ------Zoom Control
:state=0,keypressed=44 1,zoomed=0:enterzoom
:state=0,keypressed=44 1,zoomed=1:leavezoom
; Weapon Selection need not be coded
;End Script
The zoom control
shouldn't function if the weapon is not set up to zoom, so no worries there.
Here's the difference between stock control and the control the script provides:
- If reloading when zoomed, the scripts forces a zoom-out, then zooms back in automatically once finished reloading.
- Zoom is NOT right-click, it is "Z" instead
- Zoom may be engaged when dual-wielding
Something to make a note of here:
Notice that I check for "mouseclick=3". This checks for if BOTH mouse buttons are held down. If you do not perform this check then the weapon will ONLY fire if only the one button is pressed. It's necessary to make sure the weapon is able to fire when both buttons are held down (especially for dual-wielding).
You can change it to stock behavior on your own. You're good enough at scripting that I'm sure you can figure it out from this example.
Be forewarned... the weapon is not an entity. It cannot "moveto" something. Attempting to utilize commands that weapons are not meant to use will more than likely cause problems or a crash. However, weapons are capable of having a "target", so feel free to use those when needed. The "settargetreticle" command is particularly effective with weapons, since the weapon relies upon the reticle for firing anyway.
The one and only,