All things are good, wasn't trying to dunk on you or anything, it was just some very confusing code. A couple of things looking at the stuff you just posted:
Your .hitag stuff is somewhat unsafe, as hitags can be altered between spawn and actor code execution. I'm pretty sure this is really only the case for hardcoded actors, but for best practices you should capture the .hitag in an event like EVENT_SPAWN. That way you also aren't checking it every gametic, which isn't exactly an expensive operation, but the fewer commands in a given tic the better. You can do this with the .cstat as well.
appendevent EVENT_SPAWN
{
ifactor LOCKPLAYER
{
cstat 32768
set COUNT 0 // not necessary, but done for safety
geta .hitag FOUNDHITAG
seta .hitag 0
}
}
endevent
Since you are using your own counter COUNT, you could change "ifcount 10240" to "ife COUNT 10240" for consistency. Also for consistency, I reversed the conditionals of the first if statement, as the 1st var should be the one that is changing and you're comparing it against the 2nd which is generally a static value. You can also combine repeated code into a state.
defstate killlock
{
set ONPARA 0
killit
}
ends
useractor notenemy LOCKPLAYER
{
add COUNT 1
set ONPARA 1
ife COUNT FOUNDHITAG
state killlock
else
ife COUNT 10240
state killlock
}
enda
Are there other values for ONPARA set other than 0 or 1? If not then you could simplify your APLAYER code by removing the second if statement like so:
ife ONPARA 1
{
setp .movement_lock 15
setp .weapon_pos 20
}
else
setp .movement_lock 0
That said, if anything else does use .movement_lock, then this will interfere with that. One way around it is having ONPARA use a third value to mean it's "at rest", where 1 means it should lock and 0 means it should release the lock. Something like:
ife ONPARA 1
{
setp .movement_lock 15
setp .weapon_pos 20
}
else
ife ONPARA 0
{
setp .movement_lock 0
set ONPARA -1
}