// September 2015 // Levee Patroller / Dijk Patrouille // This source file is (c) by Deltares. This source file is open source but only available to select users. Do not redistribute without written permission of Stichting Deltares, Delft, The Netherlands. // This header has been automatically generated. class GeoAISheep extends Pawn placeable; var Actor HurtingActor; // An Actor to get away from. var vector OldLocation; // Used to determine if stuck. var int DamageTaken; // Most recent damage amount. var bool bStartled; // Recently startled. var float RndOffset; // Random offset to the target point, to give more variation.. instead of having fixed points all the time. var float OldZ; // Previous height. var float prevtime; /// previous update var name CrouchIdle; /// Smoothing normals: var array znormals[64]; // List of the last X Hitnormal.z's var int arcount; var int arindex; var vector HitNormal; var bool goingdown; // PostBeginPlay() is originally defined in Actor(). // We will use it to make sure an AIController is spawned for our NaliCow. event PostBeginPlay() { Super.PostBeginPlay(); if ( ( ControllerClass != None ) && ( Controller == None ) ) Controller = spawn( ControllerClass ); if ( Controller != None ) Controller.Possess( self ); prevtime = 0; // isrotating = false; //rotationfactor = 0.1f; // rotateprogress = 0.0f; arcount = 0; arindex = 0; } // DisplayBehavior() takes a BehaviorIndex value and sets the appropriate animation and sound. // Degrees of behavior will be taken into account via an optional arguement. function DisplayBehavior( int BehaviorIndex, optional int Degree ) { //Acting( 'Walk', sound'SkaarjPack_rc.WalkC', true ); break; //Acting( 'Walk', sound'SkaarjPack_rc.WalkC', true ); break; } // Acting() loops the given animation sequence name and plays the given sound. // For Replication purposes, animation is normally looped. Sequences may be interupted each AnimEnd(). function Acting( name Anim, sound Soundname, bool bLoop ) { } // MoveCheck() deals with periodic checks for bStartled, DamageTaken and falling. // Then moves the character in direction of Rotation and at speed of SpeedRatio. function MoveCheck( float SpeedRatio ) { DamageTaken = 0; // Reset most recent damage memory. if ( Controller.MoveTarget == None ) ReachedDestination( self ); if ( VSize( Controller.MoveTarget.Location - Location ) < 64 ) ReachedDestination( Controller.MoveTarget ); if ( VSize( OldLocation - Location ) < 60 ) ReachedDestination( Controller.MoveTarget ); OldLocation = Location; RotationRate.Yaw = SpeedRatio * 6000; Velocity = ( SpeedRatio * GroundSpeed ) * vector( Rotation ); Acceleration = Velocity; } simulated function PlayWaiting() { LoopAnim(CrouchIdle, 1.0, 0.2); } // ReachedDestination() is originally defined in Pawn. // MoveTarget and other relevant properties are defined in Controller. function bool ReachedDestination( Actor OldTarget ) { local Actor NewTarget, A; local NavigationPoint NP; local bool found; forEach VisibleActors( class'Actor', A ) if ( A != OldTarget && A != HurtingActor ) { NewTarget = A; break; } forEach RadiusActors( class'NavigationPoint', NP, 1024 ) if ( FRand() > 0.5 && NP != OldTarget && FastTrace( NP.Location ) ) { A = NP; NewTarget = A; found = true; break; } if ( NewTarget != None ) { Controller.MoveTarget = NewTarget; Controller.Destination = NewTarget.Location; Controller.FocalPoint = NewTarget.Location; Controller.Focus = NewTarget; RndOffset = FRand() * 32; } else { //Find random point. forEach RadiusActors( class'NavigationPoint', NP, 1024 ) if ( NP != OldTarget ) { A = NP; NewTarget = A; RndOffset = FRand() * 32; found = true; break; } Controller.MoveTarget = NewTarget; Controller.Destination = NewTarget.Location; Controller.FocalPoint = NewTarget.Location; Controller.Focus = NewTarget; } return found; } // Trigger() is originally defined in Actor. function Trigger( Actor Other, Pawn EventInstigator ) { } // Touch() is originally defined in Actor. function Touch( Actor Other ) { //if (Other.IsA('GeoAISheep')) //{ /// Boing... ReachedDestination( Controller.MoveTarget ); } // Bump() is originally defined in Actor. function Bump( Actor Other ) { GotoState('Walk'); } // TakeDamage() is originally defined in Actor. function TakeDamage(int Damage, Pawn InstigatedBy, Vector HitLocation, Vector Momentum, class DamageType) { } // Died() is originally defined in Pawn. function Died( Controller Killer, class DamageType, vector HitLocation ) { //TakeDamage( Health, None, Location, vect(0,0,-1), class'Crushed' ); } // TornOff() is originally defined in Actor. event TornOff() { if ( PlayerCanSeeMe() ) DeRez(); else Destroy(); } // DeRez() will signal removal of the dead NaliCow. simulated function DeRez() { if ( Level.NetMode == NM_DedicatedServer ) return; Skins.length = 0; //Skins[0] = Material'DeRez.Shaders.DeRezFinalBody'; } auto state Walk { function Tick( float DeltaTime ) { local int maxlength; local int x, total; local vector HitLocation; local rotator newrot; local bool found; local float diff; local bool prevgoingdown; found = false; Velocity = ( 0.5 * GroundSpeed ) * vector( Rotation ); Acceleration = Velocity; if ( VSize( Controller.MoveTarget.Location - Location ) < 64 + RndOffset ) found = ReachedDestination( Controller.MoveTarget ); if ( found == false && VSize( OldLocation - Location ) < 48 + RndOffset ) found = ReachedDestination( Controller.MoveTarget ); if ( FRand() > 0.9998 ) found = ReachedDestination( Controller.MoveTarget ); //We are NOT rotating, check new coordinates. // Trace(HitLocation,HitNormal,vect(0,0,-1)*256+ Location, Location, true); // Trace(HitLocation,HitNormal2,vect(0,0,-1)*256+ (Location- (vector(Rotation)*30)), Location - (vector(Rotation)*30), true); diff = Location.z - OldZ; ///Invert: maxlength = 64; newrot = rotator(HitNormal); //rotator(Location - HitLocation); if (HitNormal.z != 0 ) { if (goingdown) { newrot.Pitch = newrot.Pitch - (32768 / 2); } else{ //going UP!! newrot.Pitch = -(newrot.Pitch - (32768 / 2)); //(32768 / 2) - newrot.Pitch; } } else { /// We didn't trace anything... newrot.Pitch = 0; } znormals[arindex] = newrot.Pitch; arcount++; arindex++; if (arindex >= maxlength) { arindex = 0; } if (arcount >= maxlength) { arcount = maxlength; for(x=0; x 1.4) { OldZ = Location.z; prevtime = Level.TimeSeconds; Trace(HitLocation,HitNormal,vect(0,0,-1)*256+Location, Location, true); } } event AnimEnd( int Channel ) { } Begin: // DisplayBehavior( 7 ); MoveCheck( 0.5 ); } defaultproperties { CrouchIdle="Walk" GroundSpeed=110.000000 CrouchHeight=58.000000 Physics=PHYS_Walking bReplicateAnimations=True Mesh=SkeletalMesh'AnimalA.Sheep' SoundRadius=512.000000 CollisionRadius=75.000000 CollisionHeight=58.000000 bRotateToDesired=False RotationRate=(Pitch=0) }