/* ts_fish_jump by Tseramed, aka Ken Demarest (c) 2003 - Free to use. Must give author credit. This script will periodically make a splash within a 5' radius of any item you place that has this script in its heartbeat. The splash animation will be accompanied by a splash noise. To minimize the impact of putting this on a heartbeat, the area is checked for PCs before bothering to animate. The chance for a fish to jump is 30%. A second jump is also rolled for, just for variety, using the same chance. This script from the module 'Foreboding in Sylvani' See ts_fishing for details. */ int CHANCE_TO_JUMP = 30; float fRand( float max ) { int n = Random(10000); return IntToFloat(n) / 10000.0 * max; } void randomJump() { location loc = GetLocation( OBJECT_SELF ); vector pos = GetPositionFromLocation( loc ); float facing = fRand( 360.0 ); float splashDistance = fRand( 5.0 ); pos.x += cos(facing) * splashDistance; pos.y += sin(facing) * splashDistance; loc = Location( GetAreaFromLocation(loc), pos, facing ); effect e = EffectVisualEffect( 118 ); //93 ); ApplyEffectAtLocation( DURATION_TYPE_TEMPORARY, e, loc ); PlaySound( "as_na_splash2" ); } int anyPlayersInArea( object what ) { object pc = GetNearestCreature( CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, what ); return GetIsObjectValid(pc); } void main() { if( !anyPlayersInArea( OBJECT_SELF ) ) return; if( !GetLocalInt( OBJECT_SELF, "tsOff" ) ) { PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE); SetLocalInt( OBJECT_SELF, "tsOff", 1 ); } if( d100() < CHANCE_TO_JUMP ) { float delay = fRand(5.0); DelayCommand( delay, randomJump() ); if( d100() < CHANCE_TO_JUMP ) { float delay = fRand(2.0); DelayCommand( delay, randomJump() ); } } }