Core.Object | +--Engine.Actor | +--Engine.Pawn | +--UnrealShare.ScriptedPawn | +--UnrealShare.Cow
Pawn
ScaryGuy
vector
StartLocation
float
VoicePitch
WanderRadius
bool
bForage
bHasBaby
bStayClose
BabyCow
baby
eAttitude
AttitudeToCreature(Pawn Other)
AttitudeWithFear()
void
Help(Cow Other)
/* Grazing - Cow version of wandering has longer pauses, and only starts when seeplayer Also - special support for moms and babies */
PlayChallenge()
PlayDying(name DamageType, vector HitLocation)
PlayInAir()
PlayLanded(float impactVel)
PlayPatrolStop()
PlayRangedAttack()
PlayRunning()
PlayTakeHit(float tweentime, vector HitLoc, int damage)
PlayThreatening()
PlayTurning()
PlayVictoryDance()
PlayWaiting()
PlayWaitingAmbush()
PlayWalking()
PostBeginPlay()
Step()
TweenToFalling()
TweenToFighter(float tweentime)
TweenToPatrolStop(float tweentime)
TweenToRunning(float tweentime)
TweenToWaiting(float tweentime)
TweenToWalking(float tweentime)
EndState()
BeginState()
SetTurn()
timer()
SeePlayer(Actor SeenPlayer)
AnimEnd()
PickDestination()
TestDirection(vector dir, out vector, bool bAlongWall)
SetFall()
EnemyAcquired()
Bump(Actor Other)
TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType)
00001 //============================================================================= 00002 // Cow. 00003 //============================================================================= 00004 class Cow extends ScriptedPawn; 00005 00006 #exec MESH IMPORT MESH=NaliCow ANIVFILE=MODELS\Cow_a.3D DATAFILE=MODELS\Cow_d.3D X=0 Y=0 Z=0 ZEROTEX=1 00007 #exec MESH ORIGIN MESH=NaliCow X=0 Y=-240 Z=30 YAW=64 ROLL=-64 00008 00009 #exec MESH SEQUENCE MESH=NaliCow SEQ=All STARTFRAME=0 NUMFRAMES=175 00010 #exec MESH SEQUENCE MESH=NaliCow SEQ=Breath STARTFRAME=0 NUMFRAMES=6 RATE=6 00011 #exec MESH SEQUENCE MESH=NaliCow SEQ=Chew STARTFRAME=6 NUMFRAMES=7 RATE=6 00012 #exec MESH SEQUENCE MESH=NaliCow SEQ=TakeHit STARTFRAME=16 NUMFRAMES=1 00013 #exec MESH SEQUENCE MESH=NaliCow SEQ=Dead STARTFRAME=13 NUMFRAMES=23 RATE=15 00014 #exec MESH SEQUENCE MESH=NaliCow SEQ=Shake STARTFRAME=36 NUMFRAMES=18 RATE=15 00015 #exec MESH SEQUENCE MESH=NaliCow SEQ=Swish STARTFRAME=54 NUMFRAMES=20 RATE=15 00016 #exec MESH SEQUENCE MESH=NaliCow SEQ=Walk STARTFRAME=74 NUMFRAMES=15 RATE=15 00017 #exec MESH SEQUENCE MESH=NaliCow SEQ=TakeHit2 STARTFRAME=89 NUMFRAMES=1 00018 #exec MESH SEQUENCE MESH=NaliCow SEQ=Dead2 STARTFRAME=89 NUMFRAMES=13 RATE=15 00019 #exec MESH SEQUENCE MESH=NaliCow SEQ=BigHit STARTFRAME=102 NUMFRAMES=1 00020 #exec MESH SEQUENCE MESH=NaliCow SEQ=Dead3 STARTFRAME=102 NUMFRAMES=23 RATE=15 00021 #exec MESH SEQUENCE MESH=NaliCow SEQ=Poop STARTFRAME=125 NUMFRAMES=20 RATE=15 00022 #exec MESH SEQUENCE MESH=NaliCow SEQ=Root STARTFRAME=145 NUMFRAMES=20 RATE=15 00023 #exec MESH SEQUENCE MESH=NaliCow SEQ=Landed STARTFRAME=169 NUMFRAMES=1 00024 #exec MESH SEQUENCE MESH=NaliCow SEQ=Run STARTFRAME=165 NUMFRAMES=10 RATE=15 00025 00026 #exec TEXTURE IMPORT NAME=JCow1 FILE=MODELS\Cow.PCX GROUP=Skins 00027 #exec MESHMAP SCALE MESHMAP=NaliCow X=0.08 Y=0.08 Z=0.16 00028 #exec MESHMAP SETTEXTURE MESHMAP=NaliCow NUM=0 TEXTURE=JCow1 00029 00030 #exec MESH NOTIFY MESH=NaliCow SEQ=Run TIME=0.25 FUNCTION=Step 00031 #exec MESH NOTIFY MESH=NaliCow SEQ=Run TIME=0.75 FUNCTION=Step 00032 #exec MESH NOTIFY MESH=NaliCow SEQ=Walk TIME=0.31 FUNCTION=Step 00033 #exec MESH NOTIFY MESH=NaliCow SEQ=Walk TIME=0.83 FUNCTION=Step 00034 #exec MESH NOTIFY MESH=NaliCow SEQ=Dead TIME=0.76 FUNCTION=LandThump 00035 #exec MESH NOTIFY MESH=NaliCow SEQ=Dead2 TIME=0.57 FUNCTION=LandThump 00036 #exec MESH NOTIFY MESH=NaliCow SEQ=Dead3 TIME=0.71 FUNCTION=LandThump 00037 00038 #exec AUDIO IMPORT FILE="Sounds\Cow\injurC1a.WAV" NAME="injurC1c" GROUP="Cow" 00039 #exec AUDIO IMPORT FILE="Sounds\Cow\injurC2.WAV" NAME="injurC2c" GROUP="Cow" 00040 #exec AUDIO IMPORT FILE="Sounds\Cow\cMoo1a.WAV" NAME="cMoo1c" GROUP="Cow" 00041 #exec AUDIO IMPORT FILE="Sounds\Cow\cMoo2a.WAV" NAME="cMoo2c" GROUP="Cow" 00042 #exec AUDIO IMPORT FILE="Sounds\Cow\DeathC1a.WAV" NAME="DeathC1c" GROUP="Cow" 00043 #exec AUDIO IMPORT FILE="Sounds\Cow\DeathC2a.WAV" NAME="DeathC2c" GROUP="Cow" 00044 #exec AUDIO IMPORT FILE="Sounds\Cow\ambCa.WAV" NAME="ambCow" GROUP="Cow" 00045 #exec AUDIO IMPORT FILE="Sounds\Cow\shakenc.WAV" NAME="shakeC" GROUP="Cow" 00046 #exec AUDIO IMPORT FILE="Sounds\Cow\swishnc.WAV" NAME="swishC" GROUP="Cow" 00047 #exec AUDIO IMPORT FILE="Sounds\Cow\walknc.WAV" NAME="walkC" GROUP="Cow" 00048 00049 var bool bForage; 00050 var() bool bHasBaby; 00051 var() bool bStayClose; 00052 var() float WanderRadius; 00053 var vector StartLocation; 00054 var babyCow baby; 00055 var Pawn ScaryGuy; 00056 var(Sounds) sound shake; 00057 var(Sounds) sound swish; 00058 var(Sounds) sound footstep; 00059 var float VoicePitch; 00060 00061 function eAttitude AttitudeWithFear() 00062 { 00063 return ATTITUDE_Fear; 00064 } 00065 00066 function eAttitude AttitudeToCreature(Pawn Other) 00067 { 00068 if ( Other.IsA('Cow') ) 00069 return ATTITUDE_Friendly; 00070 else if ( Other.IsA('Skaarj') ) 00071 return ATTITUDE_Fear; 00072 else 00073 return ATTITUDE_Ignore; 00074 } 00075 00076 function PostBeginPlay() 00077 { 00078 VoicePitch = 0.9 + 0.2 * FRand(); 00079 if ( BabyCow(self) != None ) 00080 VoicePitch *= 1.4; 00081 if (bHasBaby) //add baby 00082 { 00083 Destination = Location; 00084 baby = Spawn(class 'BabyCow',,, Location + vector(Rotation) * 1.5 * CollisionRadius); 00085 baby.mom = self; 00086 } 00087 Super.PostBeginPlay(); 00088 } 00089 00090 function Step() 00091 { 00092 PlaySound(Footstep, SLOT_Interact, 0.012 * Mass,, 1000); 00093 } 00094 00095 function PlayWaiting() 00096 { 00097 local float decision; 00098 local float animspeed; 00099 animspeed = 0.4 + 0.4 * FRand(); 00100 decision = FRand(); 00101 if (!bool(NextAnim)) //pick first waiting animation 00102 NextAnim = 'Breath'; 00103 00104 if (decision < 0.3) 00105 NextAnim = 'Breath'; 00106 else if (decision < 0.6) 00107 { 00108 animspeed *= 0.6; 00109 NextAnim = 'Chew'; 00110 } 00111 else if (decision < 0.73) 00112 { 00113 NextAnim = 'Root'; 00114 } 00115 else if (decision < 0.8) 00116 { 00117 PlaySound(Roam, SLOT_Talk, 0.02 * Mass,,,VoicePitch); 00118 NextAnim = 'Poop'; 00119 } 00120 else if (decision < 0.9) 00121 { 00122 PlaySound(Shake, SLOT_Talk, 0.0083 * Mass); 00123 NextAnim = 'Shake'; 00124 } 00125 else 00126 { 00127 PlaySound(Swish, SLOT_Talk, 0.0083 * Mass); 00128 NextAnim = 'Swish'; 00129 } 00130 LoopAnim(NextAnim, animspeed); 00131 } 00132 00133 function PlayPatrolStop() 00134 { 00135 PlayWaiting(); 00136 } 00137 00138 function PlayWaitingAmbush() 00139 { 00140 PlayWaiting(); 00141 } 00142 00143 function TweenToFighter(float tweentime) 00144 { 00145 TweenAnim('Breath', tweentime); 00146 } 00147 00148 function TweenToRunning(float tweentime) 00149 { 00150 if (AnimSequence != 'Run' || !bAnimLoop) 00151 TweenAnim('Run', tweentime); 00152 } 00153 00154 function TweenToWalking(float tweentime) 00155 { 00156 TweenAnim('Walk', tweentime); 00157 } 00158 00159 function TweenToWaiting(float tweentime) 00160 { 00161 TweenAnim('Breath', tweentime); 00162 } 00163 00164 function TweenToPatrolStop(float tweentime) 00165 { 00166 TweenAnim('Breath', tweentime); 00167 } 00168 00169 function PlayRunning() 00170 { 00171 LoopAnim('Run', -1.0/GroundSpeed,,0.3); 00172 } 00173 00174 function PlayWalking() 00175 { 00176 LoopAnim('Walk', -1.5/GroundSpeed,,0.3); 00177 } 00178 00179 function PlayThreatening() 00180 { 00181 local float decision; 00182 local float animspeed; 00183 animspeed = 0.4 + 0.6 * FRand(); 00184 decision = FRand(); 00185 00186 if (decision < 0.3) 00187 NextAnim = 'Breath'; 00188 else if (decision < 0.7) 00189 { 00190 PlaySound(Shake, SLOT_Talk, 0.0083 * Mass); 00191 NextAnim = 'Shake'; 00192 } 00193 else 00194 { 00195 PlaySound(Swish, SLOT_Talk, 0.0083 * Mass); 00196 NextAnim = 'Swish'; 00197 } 00198 LoopAnim(NextAnim, animspeed); 00199 } 00200 00201 function PlayTurning() 00202 { 00203 TweenAnim('Walk', 0.3); 00204 } 00205 00206 function PlayDying(name DamageType, vector HitLocation) 00207 { 00208 if ( FRand() < 0.6 ) 00209 PlaySound(Die, SLOT_Talk, 0.025 * Mass,,,VoicePitch); 00210 else 00211 PlaySound(sound'DeathC2c', SLOT_Talk, 0.025 * Mass,,,VoicePitch); 00212 00213 if ( (Velocity.Z > 200) && (FRand() < 0.75) ) 00214 PlayAnim('Dead3', 0.7, 0.1); 00215 else if (FRand() < 0.5) 00216 PlayAnim('Dead', 0.7, 0.1); 00217 else 00218 PlayAnim('Dead2', 0.7, 0.1); 00219 } 00220 00221 function TweenToFalling() 00222 { 00223 TweenAnim('BigHit', 0.5); 00224 } 00225 00226 function PlayInAir() 00227 { 00228 TweenAnim('Run',0.5); 00229 } 00230 00231 function PlayLanded(float impactVel) 00232 { 00233 TweenAnim('Landed', 0.1); 00234 } 00235 00236 function PlayTakeHit(float tweentime, vector HitLoc, int damage) 00237 { 00238 if ( FRand() < 0.5 ) 00239 PlaySound(HitSound1, SLOT_Interact, 0.02 * Mass,,,VoicePitch); 00240 else 00241 PlaySound(HitSound2, SLOT_Interact, 0.02 * Mass,,,VoicePitch); 00242 00243 if (Velocity.Z > 200 + 100 * FRand()) 00244 TweenAnim('BigHit', tweentime); 00245 else if ( FRand() < 0.5 ) 00246 TweenAnim('TakeHit2', tweentime); 00247 else 00248 TweenAnim('TakeHit', tweentime); 00249 } 00250 00251 function PlayChallenge() 00252 { 00253 PlayAnim('Breath', 1.0, 0.12); 00254 } 00255 00256 function PlayVictoryDance() 00257 { 00258 PlayAnim('Breath', 1.0, 0.12); 00259 } 00260 00261 function PlayRangedAttack() 00262 { 00263 PlaySound(Roam, SLOT_Talk, 0.02 * Mass,,,VoicePitch); 00264 PlayAnim('Poop', 0.7); 00265 } 00266 00267 /* Grazing - Cow version of wandering has longer pauses, and only starts when seeplayer 00268 Also - special support for moms and babies 00269 */ 00270 00271 function Help(Cow Other) 00272 { 00273 //only used when grazing 00274 } 00275 00276 state Grazing 00277 { 00278 function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, 00279 Vector momentum, name damageType) 00280 { 00281 Global.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType); 00282 if ( health <= 0 ) 00283 return; 00284 if ( NextState == 'TakeHit' ) 00285 { 00286 NextState = 'Attacking'; 00287 NextLabel = 'Begin'; 00288 GotoState('TakeHit'); 00289 } 00290 else 00291 EnemyAcquired(); 00292 } 00293 00294 function Bump(actor Other) 00295 { 00296 if ( (Normal(Destination - Location) Dot Normal(Other.Location - Location)) > 0.8 ) 00297 MoveTimer = -1.0; 00298 if ( (Pawn(Other) != None) && SetEnemy(Pawn(Other)) ) 00299 EnemyAcquired(); 00300 Disable('Bump'); 00301 } 00302 00303 function EnemyAcquired() 00304 { 00305 bReadyToAttack = True; 00306 PlayAcquisitionSound(); 00307 GotoState('Attacking'); 00308 } 00309 00310 function Help(Cow Other) 00311 { 00312 if ( (Enemy != None) && (AttitudeTo(Enemy) < ATTITUDE_Ignore) ) 00313 return; 00314 Enemy = Other.Enemy; 00315 if (Enemy.bIsPlayer) 00316 AttitudeToPlayer = ATTITUDE_Hate; 00317 else 00318 Hated = Enemy; 00319 Aggressiveness = 1.0; 00320 GotoState('Attacking'); 00321 } 00322 00323 function SetFall() 00324 { 00325 NextState = 'Grazing'; 00326 NextLabel = 'ContinueWander'; 00327 NextAnim = AnimSequence; 00328 GotoState('FallingState'); 00329 } 00330 00331 function bool TestDirection(vector dir, out vector pick, bool bAlongWall) 00332 { 00333 local vector HitLocation, HitNormal; 00334 local float minDist, Dist; 00335 local actor HitActor; 00336 00337 dir.Z = 0; 00338 dir = Normal(dir); 00339 minDist = FMin(180.0, 6*CollisionRadius); 00340 pick = Location + dir * (minDist + FRand() * 900); 00341 00342 HitActor = Trace(HitLocation, HitNormal, pick, Location, false); 00343 Dist = VSize(HitLocation - Location); 00344 if ( (Dist < minDist) && (HitNormal.Z < 0.7) ) 00345 { 00346 if ( !bAlongWall ) 00347 return false; 00348 pick = HitLocation - dir + (HitNormal Cross vect(0,0,1)) * 5 * CollisionRadius; 00349 HitActor = Trace(HitLocation, HitNormal, pick , Location, false); 00350 if (HitActor != None) 00351 return false; 00352 } 00353 else 00354 pick = HitLocation - 4 * CollisionRadius * dir; 00355 00356 return true; 00357 } 00358 00359 function PickDestination() 00360 { 00361 local vector pickdir; 00362 local bool success; 00363 local float XY, dist; 00364 00365 if ( (Baby != None) && (VSize(Baby.Location - Location) > 400) ) 00366 { 00367 Destination = Baby.Location; 00368 return; 00369 } 00370 00371 // don't wander too far 00372 if ( bStayClose ) 00373 { 00374 pickDir = StartLocation - Location; 00375 dist = VSize(pickDir); 00376 if ( dist > WanderRadius ) 00377 { 00378 pickdir = pickDir/dist; 00379 if ( TestDirection(pickdir, Destination, true) ) 00380 { 00381 if (Baby != None) 00382 Baby.FollowMom(); 00383 return; 00384 } 00385 } 00386 } 00387 00388 //Favor XY alignment 00389 pickdir.Z = 0; 00390 XY = FRand(); 00391 if (XY < 0.3) 00392 { 00393 pickdir.X = 1; 00394 pickdir.Y = 0; 00395 } 00396 else if (XY < 0.6) 00397 { 00398 pickdir.X = 0; 00399 pickdir.Y = 1; 00400 } 00401 else 00402 { 00403 pickdir.X = 2 * FRand() - 1; 00404 pickdir.Y = 2 * FRand() - 1; 00405 pickdir = Normal(pickdir); 00406 } 00407 00408 success = TestDirection(pickdir, Destination, false); 00409 if (!success) 00410 success = TestDirection(-1 * pickdir, Destination, true); 00411 00412 if (success) 00413 { 00414 if (Baby != None) 00415 Baby.FollowMom(); 00416 } 00417 else 00418 { 00419 Destination = Location; 00420 GotoState('Grazing', 'Turn'); 00421 } 00422 } 00423 00424 function AnimEnd() 00425 { 00426 PlayPatrolStop(); 00427 } 00428 00429 function SeePlayer(Actor SeenPlayer) 00430 { 00431 bForage = true; 00432 ScaryGuy = Pawn(SeenPlayer); 00433 if ( (Pawn(SeenPlayer).Health > 0) && SetEnemy(Pawn(SeenPlayer)) ) 00434 LastSeenPos = SeenPlayer.Location; 00435 00436 Disable('SeePlayer'); 00437 SetTimer(7.0, false); 00438 } 00439 00440 function timer() 00441 { 00442 Enable('SeePlayer'); 00443 bForage = false; 00444 } 00445 00446 function SetTurn() 00447 { 00448 local float YawErr; 00449 00450 if ( (Baby != None) && (FRand() < 0.35) ) 00451 Destination = Baby.Location; 00452 else if ( (ScaryGuy != None) && (FRand() < 0.5) ) 00453 Destination = ScaryGuy.Location; 00454 else 00455 Destination = Location + 20 * VRand(); 00456 00457 DesiredRotation = rotator(Destination - Location); 00458 DesiredRotation.Yaw = DesiredRotation.Yaw & 65535; 00459 YawErr = (DesiredRotation.Yaw - (Rotation.Yaw & 65535)) & 65535; 00460 if ( (YawErr > 16384) && (YawErr < 49151) ) 00461 { 00462 if ( YawErr > 32768 ) 00463 DesiredRotation.Yaw = DesiredRotation.Yaw + 16384; 00464 else 00465 DesiredRotation.Yaw = DesiredRotation.Yaw - 16384; 00466 Destination = Location + 20 * vector(DesiredRotation); 00467 } 00468 } 00469 00470 function BeginState() 00471 { 00472 MinHitWall = -0.2; 00473 StartLocation = Location; 00474 Enemy = None; 00475 SetAlertness(0.0); 00476 bReadyToAttack = false; 00477 bAvoidLedges = true; 00478 Disable('AnimEnd'); 00479 NextAnim = ''; 00480 JumpZ = -1; 00481 if (Enemy == None) 00482 { 00483 bForage = false; 00484 Disable('EnemyNotVisible'); 00485 Enable('SeePlayer'); 00486 } 00487 else 00488 { 00489 bForage = true; 00490 Enable('EnemyNotVisible'); 00491 Disable('SeePlayer'); 00492 } 00493 } 00494 00495 function EndState() 00496 { 00497 if ( Enemy.bIsPlayer ) 00498 MakeNoise(1.0); 00499 JumpZ = Default.JumpZ; 00500 bAvoidLedges = false; 00501 MinHitWall = Default.MinHitWall; 00502 } 00503 00504 Begin: 00505 //log(class$" Grazing"); 00506 00507 Wander: 00508 if (!bForage) 00509 Goto('Graze'); 00510 WaitForLanding(); 00511 PickDestination(); 00512 TweenToWalking(0.2); 00513 FinishAnim(); 00514 PlayWalking(); 00515 00516 Moving: 00517 Enable('Bump'); 00518 MoveTo(Destination, 0.4); 00519 Graze: 00520 Acceleration = vect(0,0,0); 00521 TweenAnim('Breath', 0.3); 00522 if (FRand() < 0.5) 00523 { 00524 FinishAnim(); 00525 PlayAnim('Root', 0.3 + 0.4*FRand()); 00526 } 00527 Enable('AnimEnd'); 00528 NextAnim = ''; 00529 Sleep(6 + 10 * FRand()); 00530 Disable('AnimEnd'); 00531 FinishAnim(); 00532 Goto('Wander'); 00533 00534 ContinueWander: 00535 FinishAnim(); 00536 PlayWalking(); 00537 Goto('Wander'); 00538 00539 Turn: 00540 Acceleration = vect(0,0,0); 00541 PlayTurning(); 00542 SetTurn(); 00543 TurnTo(Destination); 00544 Goto('Graze'); 00545 } 00546 00547 defaultproperties 00548 { 00549 bStayClose=True 00550 WanderRadius=500.000000 00551 shake=Sound'UnrealShare.Cow.shakeC' 00552 Swish=Sound'UnrealShare.Cow.swishC' 00553 footstep=Sound'UnrealShare.Cow.walkC' 00554 CarcassType=Class'UnrealShare.CowCarcass' 00555 Orders=Grazing 00556 Aggressiveness=0.500000 00557 bHasRangedAttack=True 00558 bIsWuss=True 00559 Acquire=Sound'UnrealShare.Cow.cMoo1c' 00560 Roam=Sound'UnrealShare.Cow.cMoo2c' 00561 Threaten=Sound'UnrealShare.Cow.cMoo2c' 00562 GroundSpeed=180.000000 00563 WaterSpeed=100.000000 00564 JumpZ=-1.000000 00565 MaxStepHeight=17.000000 00566 SightRadius=1500.000000 00567 PeripheralVision=-10.000000 00568 HearingThreshold=0.700000 00569 Health=60 00570 UnderWaterTime=40.000000 00571 AttitudeToPlayer=ATTITUDE_Ignore 00572 Intelligence=BRAINS_REPTILE 00573 HitSound1=Sound'UnrealShare.Cow.injurC1c' 00574 HitSound2=Sound'UnrealShare.Cow.injurC2c' 00575 Die=Sound'UnrealShare.Cow.DeathC1c' 00576 CombatStyle=-1.000000 00577 AmbientSound=Sound'UnrealShare.Cow.ambCow' 00578 DrawType=DT_Mesh 00579 Mesh=LodMesh'UnrealShare.NaliCow' 00580 CollisionRadius=48.000000 00581 CollisionHeight=32.000000 00582 Mass=120.000000 00583 RotationRate=(Pitch=2048,Yaw=30000,Roll=0) 00584 }