Thanks! It's a mixture between a loop script for the map itself, and some custom states in the railgun's FSM. In the loop script, I wrote:
// find out what weapon the player is holding
player check heldweapon global.curweap
if $global.curweap != 6 {
global.scoping = 3
}
//hides scope image if player is already scoping
if $global.scoping == 1 {
hud image railgunscope 0 0 1 HUD/railgunscope.png
player zoom 80
player speed 20
player camspeed 0.1
global.scoping = 2
}
// shows scope image if player isn't scoping
if $global.scoping == 3 {
hud image railgunscope
player zoom 0
player speed 128
player camspeed 1
global.scoping = 0
}
And in the FSM for the railgun, there's two additional states that can be triggered if the player right clicks (alt fires):
state ALTATTACK IDLE 0
frame 1 0.0167 0 0 0 NONE
frame 1 0.0167 0 0 0 INCREMENT global.scoping 1
frame 1 0.25 0 0 0 JUMPIFEQUALS global.scoping 1 SCOPING
frame 1 0.25 0 0 0 JUMPIFEQUALS global.scoping 3 UNSCOPE
state SCOPING IDLE 0
frame 1 0.0167 0 0 0 NONE
frame 1 0.0167 0 0 0 READY
state UNSCOPE IDLE 0
frame 1 0.0167 0 0 0 NONE
frame 1 0.0167 0 0 0 READY
It's not a perfect system, but it's OK for now!