04-01-2012, 12:17
Hello
This will make that when you shot a tree, it will fall down.
Example of usage:
Code:
This will make that when you shot a tree, it will fall down.
Example of usage:
Code:
treee = spawn( "script_model", self.origin );
treee setModel( "foliage_cod5_tree_pine05_large_animated" );
treee thread CanFall();
Code:
Code:
CanFall()
{
self setCanDamage( true );
for( ; ; )
{
self waittill( "damage", damage, attacker, direction_vec, point );
if( ! isPlayer( attacker ) )
continue;
if( randomInt( 5 ) != 3 ) //Put the number inside the randomInt higher to make it stronger
continue;
break;
}
treeorg = spawn( "script_origin", self.origin );
pos1 = ( point[0], point[1], 0 );
pos2 = ( self.origin[0], self.origin[1], 0 );
treeorg.angles = vectorToAngles( pos1 - pos2 );
pos1new = ( point[0], point[1], 0 );
pos2new = ( self.origin[0], self.origin[1], 0 );
treeorg.angles = VectorToAngles( pos1new - pos2new );
self linkTo( treeorg );
treeorg rotatePitch( -90, 1.1, 0.05, 0.2 );
treeorg waittill( "rotatedone" );
treeorg rotatePitch( 5, 0.21, 0.05, 0.15 );
treeorg waittill( "rotatedone" );
treeorg rotatePitch( -5, 0.26, 0.15, 0.1 );
treeorg waittill( "rotatedone" );
self Unlink();
treeorg delete();
}