PDA

View Full Version : Random scripting



serthy
9th May 2013, 13:37
This thread has no specific topic, you can add here stuff that you found out, maybe some workarounds or smth like that

i tested out some funkctions i found in the cod2_mp.exe with a HEX editor

clientannouncer( player , "TEXT" ); is the same as player iprintLnBold( "TEXT" );

announcer( "TEXT" ); >>> iPrintLnBold( "TEXT" );

grenadeExplosionEffect( position ); >>> plays the grenade fx + sound on the position, no need to precache everygrenade fx anylonger

turret useBy( player ); >>> player enters the turret

soundFade( fadetime ) >>> working, but didnt tried to fade a sound yet



modelHasTag( model , tag )
{
parts = getNumParts( model ); //return bones count

for( i = 0 ; i < parts ; i++ )
{
if( getPartName( model , i ) == tag ) //return bones_name by ID
return true;
}

assertEx( false , "Model [" + model + "] has no bone [" + tag + "] included!" ); //script error with the given message
}


trace( from , dir , hitPlayers , ignoreEnt )
{
d = 100000;
t = bulletTrace( from , from + vectorScale( dir , d ) , isDefined( hitPlayers ) && hitPlayers , ignoreEnt );
t["distance"] = d * t["fraction"];

if( !isDefined( t["normal"] ) || t["normal"] == ( 0 , 0 , 0 ) )
t["normal"] = ( 0 , 0 , 1 );

return t;
}

Tally
9th May 2013, 15:07
The getNumParts() is an interesting find. I'm wondering if it can be used as a COD2 approximation of COD4's getTagOrigin() by converting the method:


getTagOrigin( model, tag )
{
parts = getNumParts( model ); //return bones count

for( i = 0 ; i < parts ; i++ )
{
if( getPartName( model , i ) == tag ) //return bones_name by ID
return( model.origin );
}
}

If I had time I'd test it, but alas, I am snowed under with a project and behind schedule.

IzNoGoD
9th May 2013, 17:38
Please use distance(from, trace["position"]) to find the distance travelled, else you might wanna look into floating point precision. (hopefully cod uses doubles. Else max 8 significant numbers (single precision))

Does grenadeexplosion take any other arguments? I'd like to set angles on the explosion, maybe even surfacetype...

Contributing:


ent hide();
ent showtoplayer(player1);
ent showtoplayer(player2);


:D

serthy
9th May 2013, 17:39
getTagOrigin( model, tag )
{
parts = getNumParts( model ); //return bones count

for( i = 0 ; i < parts ; i++ )
{
if( getPartName( model , i ) == tag ) //return bones_name by ID
return( model.origin );
}
}

uhh, sorry

getNumParts( modelName ) & getPartName( modelName ) is the correct useage


grenadeExplosionEffect( pos ) accepted more arguments, but i dont know what to insert


bla()
{
level.fx = loadFx( "fx/explosions/grenadeExp_water.efx" );

while( 1 )
{
s = getEntArray( "mp_dm_spawn" , "classname" );

for( i = 0 ; i < s.size ; i++ )
{
wait( 1.0 );

p = s[i].origin;
t = bulletTrace( p , p - ( 0 , 0 , 10000 ) , false , undefined );
p = t["position"];
n = t["normal"];

grenadeExplosionEffect( p , n , level.fx );
// grenadeExplosionEffect( p ,level.fx , n );
}
}
}

this will play different types of the explosion for me on burgundy (wood/mud/asphalt) , i doubt you can change the fx/normal