ID:1565794
 
So here's something quite interesting and incredibly odd i've come across recently. I will show relevant parts of the code only.

Code:
This is part of the skill, it'll launch a simple projectile with a trail. This part works fine.

            shadow_capture
name = "Kagemane"
icon_state = "kagemane"
max_level = 3
locktime = 150
u_req = 10
Click()
..()
if( !(diag_check(usr)) ) usr.dir = turn(usr.dir, 45)

if( usr.using_shadow_capture == 1)
usr << "You've ended your Kagemane technique."
usr.using_shadow_capture = 0
usr.movement.set_freeze_static(-1)
usr.locked = max(0, usr.locked - 1)
spawn() usr.Lock(name, locktime, src)

usr.reset_targets()

else
if( click_check() || usr.Locked(name) ) return
Process(usr, 1)



Next, this is a snippet from reset_targets, resetting everything in shadow_capture_targets. This part also functions properly.
reset_targets()
if(shadow_capture_targets.len) for(var/mob/R in shadow_capture_targets)
R.movement.set_freeze_static(-1)
R.locked = max(0, R.locked - 1)
R.using_joystick = 0
shadow_capture_targets -= R
src << "[R.name] has been released from your [using_shadow_capture ? "Kagemane." : "Kage Nui."]"
R << "You're free from [name]'s [using_shadow_capture ? "Kagemane." : "Kage Nui."]"



Now here is where things get weird. The following line of code functions fully the first time it is called(When the projectile lands). However, the user will end the technique and use it again after the cooldown. The same person gets hit and the code functions EXCEPT for M.locked ++. I've put in debug messages to test after every line of code and the ++(and += 1) seems to be doing nothing. It is 0 before and 0 after M.locked ++(or += 1) every time after the first. It is also 0 when getting released from being captured.

                if("Kagemane Head", "Kage Nui Head")
has_effect = 0
if( owner && M && !(M in owner.shadow_capture_targets) )
break_projectile = 1
view(M) << "[M.name] has been captured!"
owner << "You've captured [M.name] in your [name]."
if(name == "Kagemane Head") owner.using_shadow_capture = 1
else owner.using_shadow_choke = 1

M.locked ++
M.movement.set_freeze_static(1)
M.My_Joystick = new()
M.My_Joystick.life = rand(2, 4)
M.My_Joystick.Activate(M)

owner.shadow_capture_targets += M
loc = M.loc
pixel_x = 0
pixel_y = 0
layer = MOB_LAYER - 1


There are no runtime errors, and no crashes. I have added an if statement after M.locked ++ to force set it to one only if it's equal to 0. I'm just not sure why this is happening. Any ideas?

Make sure you're not setting that variable anywhere else in your code. It's hard to tell anything from what you've posted, since most of it is relegated elsewhere and we're not given context for when it's called.