Originally Posted by
the_law
Hi guys,
First of all, this is my first attempt at making my own script modifications, so sorry if there's any dumb mistakes I made.
I'm trying to imitate MW2's weapon bob by changing bob-related client cvars:
At the end of spawnPlayer() in tdm.gsc, I inserted this:
Code:
self setClientCvar("bg_bobAmplitudeStanding", "0.028");
self setClientCvar("bg_bobAmplitudeDucked", "0.025");
self setClientCvar("bg_bobMax", "1");
This works. In game, the weapon bobs much more (approximately as much as in MW2). Only thing is that this amount of bobbing will make aiming very difficult if the player moves while ADS.
So I'm gonna try to check if the player is ADS, and if he is, the script will set those bob-related client cvars back to default values.
Clearly this should be done with a simple if/else statement right? I know it should, but I have not idea how to go about doing it.
Which game? Because those cvars are COD1's and don't work in COD2 (COD2 does not have a way to bob the head while running or walking).
Also, if it is COD1, there is no native way to check ADS. Unless you are modifying UO - in which case The function is:
If it's COD1, here is my method to find ADS (I am the first to do this):
Code:
spawnThumbMarker()
{
// 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) );
}
}
/*
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( "disconnect" );
self endon( "kill_threads" );
self.isADS = undefined;
while( isAlive( self ) )
{
if( isdefined( self.headmarker ) && isDefined( self.thumbmarker ) )
{
// check for stance changes because the hud elements flash on while changing
while( self getStance() != "stand" )
{
wait( 1.75 );
continue;
}
// I can only find a workable distance if the player is standing
while( self getStance() == "stand" )
{
if( distance2d( self.thumbmarker.origin, self.headmarker.origin ) >= 17 )
self.isADS = true;
else
self.isADS = undefined;
wait( 0.05 );
}
}
wait( 0.05 );
}
}
distance2d( a, b )
{
return( distance( (a[0],a[1],0), (b[0],b[1],0) ) );
}
run both functions from player spawn.