Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 |
//============================================================================= // U2PawnBase.uc // Created By: Mike Fox // Created On: 8/01/00 // $Author: Mfox $ // $Date: 12/12/02 12:57p $ // $Revision: 46 $ //============================================================================= class U2PawnBase extends U2Pawn abstract; //----------------------------------------------------------------------------- // some NPCs handle their own movement sounds var(Pawn) array<string> StepSounds; var(Pawn) float StepSoundVolume; var(Pawn) float StepSoundRadius; var(Pawn) float StepSoundPitch; var(Pawn) float StepShakeRadius; var(Pawn) float StepShakeMagnitude; var(Pawn) float StepShakeDuration; // some NPCs handle their own landed sounds var(Pawn) array<string> LandSounds; var(Pawn) ESoundSlot LandSoundSlot; var(Pawn) float LandSoundRadius; var(Pawn) float LandSoundPitch; var(Pawn) float LandShakeRadius; var(Pawn) float LandShakeMagnitude; var(Pawn) float LandShakeDuration; var(Movement) int RotationRateYawScripted; var(Movement) int RotationRateYawScriptedDialog; //----------------------------------------------------------------------------- var float StrafingAbility; var(AI) float BecomeAggressiveHealthRatio; // if NPC's Health/InitialHealth falls below this ratio, bAmbientCreature -> false var bool bCanStrafeScripted; // (false) bCanStrafe is set to this while NPC is scripted //!!mdf-move into Pawn so can be used in native code? var(AI) float AlertOthersRadius; // if NPC acquires an Enemy, NPCs on same team within this radius are alerted var(AI) bool bAlertOthersRequiresLOS; // whether alerting others requires LOS between NPC and Other var(AI) bool bLookForAlertFriends; // whether will look for and react to alert teammate (slow) var(AI) bool bAvoidFriendlyBumps; // if true, NPC will get out of way of friendly bumps //----------------------------------------------------------------------------- // wandering properties //!!mdf - add support for forcing turn towards left/right/up/down? (min/max spread?) var bool bCanWanderOffLedges; // if true, ledges are ignored when wandering (up to 2*CollisionHeight + MaxStepHeight) var bool bDistressedWandering; // whether NPC moves more erratically when hurt/alert var bool bWanderCanKillIfStuck; // if true, and NPC gets stuck while wandering can kill NPC off var bool bWanderCanTeleportIfStuck; // if true, and NPC gets stuck while wandering can try to teleport NPC var bool bWanderEndRotation; // NPC has a different rotation rate when not wandering var bool bWanderLookAtDestination; // whether NPC rotates to look at destination (usually true) var float WanderAvoidObstructionOdds; // odds of trying to turn away from obstructions (higher for smarter NPCs). Should probably never be zero.. var float WanderAvoidPawnDiffDistance; // wandering NPCs will try to stay at least this far away from other Pawns var float WanderAvoidPawnSameDistance; // wandering NPCs will try to stay at least this far away from other Pawns of the same class var float WanderCantMoveWaitTime; // could find a wander direction -- sleeps for this long before trying again (min 0.1) var float WanderDistMax; // max distance to try to wander (if <= 0.0 set in PreBeginPlay) var float WanderDistMin; // min distance to try to wander (if <= 0.0 set in PreBeginPlay) var float WanderMaxZComponent; // !!mdf - replace with WanderSpreadVerticalAngle? max vertical component of wander direction for flying/walking creatures var float WanderMinAdustedSize; // when obstructed by geometry (defaults to collisionradius -- with anything less NPC might never move) var float WanderPauseOdds; // odds that NPC will pause after reaching wander destination var float WanderPauseMin; // min time to pause after reaching wander destination (pausing stops NPC movement) var float WanderPauseMax; // max time to pause after reaching wander destination (pausing stops NPC movement) var float WanderSpeedMin; // min pct of movement speed used when relaxed and wandering var float WanderSpeedMax; // max pct of movement speed used when relaxed and wandering var float WanderSpreadAngle; // angle spread used when choosing a wander direction (0..360 degrees) var float WanderTurnToDestinationOdds; // odds that NPC will turn to wander destination before moving towards it (generally high for walking NPCs or large flyers or swimmers, low for NPCs that can "hover" or back up etc.) -- hmm actually seems to look better if they don't do this... var float WanderViewBlockedDistance; // distance used to check for view blocked (defaults to CollisionRadius) var float WanderViewBlockedTurnOdds; // odds NPC will rotate away from walls when wandering and view obstructed within WanderViewObstructedDistance units var rotator WanderEndRotationRate; // rotation rate to use when not wandering (optional) var float WanderMaxAvoidDistance; // largest avoid distance -- computed in PreBeginPlay //----------------------------------------------------------------------------- function SetWanderParameters() { if( WanderCantMoveWaitTime < 0.2 ) WanderCantMoveWaitTime = 0.2; if( WanderDistMax <= 0.0 ) WanderDistMax = FMax( 128.0, 4*CollisionRadius ); //!!mdf-tbd: correlate with movement speed to minimize timeouts during move? if( WanderDistMin <= 0.0 ) WanderDistMin = 2*CollisionRadius; if( WanderViewBlockedDistance <= 0.0 ) WanderViewBlockedDistance = CollisionRadius + 1.0; // +1.0 so should detect wall before trying to wander into it WanderMaxAvoidDistance = FMax( WanderAvoidPawnDiffDistance, WanderAvoidPawnSameDistance ); if( WanderMinAdustedSize <= 0.0 ) WanderMinAdustedSize = CollisionRadius; } //----------------------------------------------------------------------------- event PreBeginPlay() { Super.PreBeginPlay(); SetWanderParameters(); } //----------------------------------------------------------------------------- event PostBeginPlay() { local class<AIController> NewControllerClass; // if no mesh use collision cylinder as "mesh" if( (DrawType == DT_Mesh && Mesh == None) || (DrawType == DT_StaticMesh && StaticMesh == None) ) SpecialDisplayFlags = SpecialDisplayFlags | DF_Collision; //!!mdf-tbr: support for switching NPC controllers to/from U2AINew equivalent if( ControllerClass != None ) { if( InStr( GetCommandLine(), "newai" ) != -1 ) { switch( ControllerClass.Name ) { case 'U2NPCControllerBaseOld': NewControllerClass = class'U2AI.U2NPCControllerBase'; break; case 'U2NPCControllerBasicOld': NewControllerClass = class'U2AI.U2NPCControllerBasic'; break; case 'U2NPCControllerAdvancedOld': NewControllerClass = class'U2AI.U2NPCControllerAdvanced'; break; /* new bot code not functional case class'U2AI.U2NPCControllerBotOld': NewControllerClass = class'U2AI.U2NPCControllerBot'; break; */ case 'AtlantisControllerOld': NewControllerClass = class<AIController>(DynamicLoadObject( "U2Pawns.AtlantisController", class'Class' )); break; default: break; } } else if( InStr( GetCommandLine(), "oldai" ) != -1 ) { switch( ControllerClass.Name ) { case 'U2NPCControllerBase': NewControllerClass = class<AIController>(DynamicLoadObject( "U2AIOld.U2NPCControllerBaseOld", class'class' )); break; case 'U2NPCControllerBasic': NewControllerClass = class<AIController>(DynamicLoadObject( "U2AIOld.U2NPCControllerBasicOld", class'class' )); break; case 'U2NPCControllerAdvanced': NewControllerClass = class<AIController>(DynamicLoadObject( "U2AIOld.U2NPCControllerAdvancedOld", class'class' )); break; case 'U2NPCControllerBot': NewControllerClass = class<AIController>(DynamicLoadObject( "U2AIOld.U2NPCControllerBotOld", class'class' )); break; case 'AtlantisController': NewControllerClass = class<AIController>(DynamicLoadObject( "U2Pawns.AtlantisControllerOld", class'Class' )); break; default: break; } } if( NewControllerClass != None ) { DM( "Swapping AI controller: " $ ControllerClass $ " --> " $ NewControllerClass ); ControllerClass = NewControllerClass; } } Super.PostBeginPlay(); } //----------------------------------------------------------------------------- simulated function PlayMovementSound() { if( StepSounds.Length != 0 ) { if( StepSoundRadius <= 0.0 ) StepSoundRadius = TransientSoundRadius; if( StepSoundPitch <= 0 ) StepSoundPitch = 1.0; PlaySound( Sound(DynamicLoadObject( StepSounds[ Rand( StepSounds.Length ) ], class'Sound' )), /*Slot*/, StepSoundVolume, /*bNoOverride*/, StepSoundRadius, StepSoundPitch ); } else { Super.PlayMovementSound(); } if( StepShakeRadius > 0.0 ) class'UtilGame'.static.MakeShake( Self, Location, StepShakeRadius, StepShakeMagnitude, StepShakeDuration ); } //----------------------------------------------------------------------------- function LandedOnTexture( float ImpactSpeed ) { if( LandSounds.Length != 0 ) { if( LandSoundRadius <= 0.0 ) LandSoundRadius = TransientSoundRadius; if( LandSoundPitch <= 0 ) LandSoundPitch = 1.0; PlaySound( Sound(DynamicLoadObject( LandSounds[ Rand( LandSounds.Length ) ], class'Sound' )), LandSoundSlot, Abs(ImpactSpeed) / 450.0, false, LandSoundRadius, LandSoundPitch ); } else { Super.LandedOnTexture( ImpactSpeed ); } if( LandShakeRadius > 0.0 ) class'UtilGame'.static.MakeShake( Self, Location, LandShakeRadius * Abs(ImpactSpeed) / 450.0, LandShakeMagnitude, LandShakeDuration ); } //----------------------------------------------------------------------------- defaultproperties { StepSoundVolume=1.000000 LandSoundSlot=SLOT_Misc RotationRateYawScripted=30000 RotationRateYawScriptedDialog=30000 AlertOthersRadius=1024.000000 bAlertOthersRequiresLOS=true bLookForAlertFriends=true bAvoidFriendlyBumps=true bCanWanderOffLedges=true bDistressedWandering=true bWanderCanKillIfStuck=true bWanderCanTeleportIfStuck=true bWanderLookAtDestination=true WanderAvoidObstructionOdds=1.000000 WanderCantMoveWaitTime=1.000000 WanderDistMax=-1.000000 WanderDistMin=-1.000000 WanderMaxZComponent=0.707000 WanderMinAdustedSize=-1.000000 WanderPauseOdds=1.000000 WanderSpeedMin=0.400000 WanderSpeedMax=0.500000 WanderSpreadAngle=180.000000 WanderViewBlockedDistance=-1.000000 bCanOpenDoors=false bCanDoSpecial=false bAmbientCreature=true ControllerClass=Class'U2AI.U2NPCControllerBase' TeamNumber=85 UseReticleOnEvents(0)="UseReticleText" UseReticleOnEvents(1)="UseReticleCorners" UseReticleOnEvents(2)="UseReticleSideBars" ProximityReticleOnEvents(0)="ProximityReticleCorners" ProximityReticleOnEvents(1)="ProximityReticleSideBars" } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |