Okay, I came at the problem from a different direction and solved it:
Code:
attachments()
{
if( self.pers["class"] != "sniper" && self.pers["class"] != "engineer" ) return;
// wait until the player model is solid on spawn ( otherwise it will return an invalid player model )
wait( 1 );
if( !isDefined( self.thumbmarker ) )
{
self.thumbmarker = spawn( "script_origin", (0,0,0) );
self.thumbmarker linkto( self, "TAG_WEAPON_LEFT", (0,0,0) , (0,0,0) );
}
if( !isDefined( self.headmarker ) )
{
self.headmarker = spawn( "script_origin", (0,0,0) );
self.headmarker linkto( self, "TAG_HELMET", (0,0,0) , (0,0,0) );
}
self thread MonitorforADS();
}
/*
METHOD TO FIND PLAYER ADS
-------------------------
Origin of the script_origins is relative to character model's origin. So, when
the arm is raised, the thumbmarker is moving further away and so registers as true.
*/
MonitorforADS()
{
self endon( "death" );
self endon( "disconnect" );
self.isADS = undefined;
for( ;; )
{
if( isdefined( self.headmarker ) && isDefined( self.thumbmarker ) )
{
// check for stance changes because the hud elements flash on while changing
while( self getStance() != "stand" )
{
self perks\_binoculars::cleanBinocularHintHud();
wait( 1.75 );
continue;
}
// I can only find a workable distance if the player is standing
while( self getStance() == "stand" )
{
if( [[level.distance2d]]( self.thumbmarker.origin, self.headmarker.origin ) >= 17 )
self.isADS = true;
else
self.isADS = undefined;
wait( 0.05 );
}
}
wait( 0.05 );
}
}
It's a bit limited. You have to be standing still, standing, and not changing stance. But it does work, and allows me to do what I wanted to accomplish. And as far as I can tell by trawling all the old COD1 mods, I am the first to do it for COD1.