Overview | Package | Class | Source | Class tree | Glossary | Deus Ex 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 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 |
//============================================================================= // SecurityCamera. //============================================================================= class SecurityCamera extends HackableDevices; var() bool bSwing; var() int swingAngle; var() float swingPeriod; var() int cameraFOV; var() int cameraRange; var float memoryTime; var() bool bActive; var() bool bNoAlarm; // if True, does NOT sound alarm var Rotator origRot; var Rotator ReplicatedRotation; // for net propagation var bool bTrackPlayer; var bool bPlayerSeen; var bool bEventTriggered; var bool bFoundCurPlayer; // in multiplayer, if we found a player this tick. var float lastSeenTimer; var float playerCheckTimer; var float swingTimer; var bool bConfused; // used when hit by EMP var float confusionTimer; // how long until camera resumes normal operation var float confusionDuration; // how long does EMP hit last? var float triggerDelay; // how long after seeing the player does it trigger? var float triggerTimer; // timer used for above var vector playerLocation; // last seen position of player // DEUS_EX AMSD Used for multiplayer target acquisition. var Actor curTarget; // current view target var Actor prevTarget; // target we had last tick. var Pawn safeTarget; // in multiplayer, this actor is strictly off-limits // Usually for the player who activated the turret. var localized string msgActivated; var localized string msgDeactivated; var int team; // Keep track of team the camera is on // ------------------------------------------------------------------------------------ // Network replication // ------------------------------------------------------------------------------------ replication { //server to client var reliable if (Role == ROLE_Authority) bActive, ReplicatedRotation, team, safeTarget; } function HackAction(Actor Hacker, bool bHacked) { local ComputerSecurity CompOwner; local ComputerSecurity TempComp; local AutoTurret turret; local name Turrettag; local int ViewIndex; if (bConfused) return; Super.HackAction(Hacker, bHacked); if (bHacked) { if (Level.NetMode == NM_Standalone) { if (bActive) UnTrigger(Hacker, Pawn(Hacker)); else Trigger(Hacker, Pawn(Hacker)); } else { //DEUS_EX AMSD Reset the hackstrength afterwards if (hackStrength == 0.0) hackStrength = 0.6; if (bActive) UnTrigger(Hacker, Pawn(Hacker)); //Find the associated computer. foreach AllActors(class'ComputerSecurity',TempComp) { for (ViewIndex = 0; ViewIndex < ArrayCount(TempComp.Views); ViewIndex++) { if (TempComp.Views[ViewIndex].cameraTag == self.Tag) { CompOwner = TempComp; //find associated turret Turrettag = TempComp.Views[ViewIndex].Turrettag; if (Turrettag != '') { foreach AllActors(class'AutoTurret', turret, TurretTag) { break; } } } } } if (CompOwner != None) { //Turn off the associated turret as well if ( (Hacker.IsA('DeusExPlayer')) && (Turret != None)) { Turret.bDisabled = True; Turret.gun.HackStrength = 0.6; } } } } } function Trigger(Actor Other, Pawn Instigator) { if (bConfused) return; Super.Trigger(Other, Instigator); if (!bActive) { if (Instigator != None) Instigator.ClientMessage(msgActivated); bActive = True; LightType = LT_Steady; LightHue = 80; MultiSkins[2] = Texture'GreenLightTex'; AmbientSound = sound'CameraHum'; } } function UnTrigger(Actor Other, Pawn Instigator) { if (bConfused) return; Super.UnTrigger(Other, Instigator); if (bActive) { if (Instigator != None) Instigator.ClientMessage(msgDeactivated); TriggerEvent(False); bActive = False; LightType = LT_None; AmbientSound = None; DesiredRotation = origRot; hackStrength = 0.0; } } function TriggerEvent(bool bTrigger) { bEventTriggered = bTrigger; bTrackPlayer = bTrigger; triggerTimer = 0; // now, the camera sounds its own alarm if (bTrigger) { AmbientSound = Sound'Klaxon2'; SoundVolume = 128; SoundRadius = 64; LightHue = 0; MultiSkins[2] = Texture'RedLightTex'; AIStartEvent('Alarm', EAITYPE_Audio, SoundVolume/255.0, 25*(SoundRadius+1)); // make sure we can't go into stasis while we're alarming bStasis = False; } else { AmbientSound = Sound'CameraHum'; SoundRadius = 48; SoundVolume = 192; LightHue = 80; MultiSkins[2] = Texture'GreenLightTex'; AIEndEvent('Alarm', EAITYPE_Audio); // reset our stasis info bStasis = Default.bStasis; } } function CheckPlayerVisibility(DeusExPlayer player) { local float yaw, pitch, dist; local Actor hit; local Vector HitLocation, HitNormal; local Rotator rot; if (player == None) return; dist = Abs(VSize(player.Location - Location)); // if the player is in range if (player.bDetectable && !player.bIgnore && (dist <= cameraRange)) { hit = Trace(HitLocation, HitNormal, player.Location, Location, True); if (hit == player) { // If the player's RadarTrans aug is on, the camera can't see him // DEUS_EX AMSD In multiplayer, we've already done this test with // AcquireMultiplayerTarget if (Level.Netmode == NM_Standalone) { if (player.AugmentationSystem.GetAugLevelValue(class'AugRadarTrans') != -1.0) return; } // figure out if we can see the player rot = Rotator(player.Location - Location); rot.Roll = 0; yaw = (Abs(Rotation.Yaw - rot.Yaw)) % 65536; pitch = (Abs(Rotation.Pitch - rot.Pitch)) % 65536; // center the angles around zero if (yaw > 32767) yaw -= 65536; if (pitch > 32767) pitch -= 65536; // if we are in the camera's FOV if ((Abs(yaw) < cameraFOV) && (Abs(pitch) < cameraFOV)) { // rotate to face the player if (bTrackPlayer) DesiredRotation = rot; lastSeenTimer = 0; bPlayerSeen = True; bTrackPlayer = True; bFoundCurPlayer = True; playerLocation = player.Location - vect(0,0,1)*(player.CollisionHeight-5); // trigger the event if we haven't yet for this sighting if (!bEventTriggered && (triggerTimer >= triggerDelay) && (Level.Netmode == NM_Standalone)) TriggerEvent(True); return; } } } } function Tick(float deltaTime) { local float ang; local Rotator rot; local DeusExPlayer curplayer; Super.Tick(deltaTime); curTarget = None; // if this camera is not active, get out if (!bActive) { // DEUS_EX AMSD For multiplayer ReplicatedRotation = DesiredRotation; MultiSkins[2] = Texture'BlackMaskTex'; return; } // if we've been EMP'ed, act confused if (bConfused) { confusionTimer += deltaTime; // pick a random facing at random if (confusionTimer % 0.25 > 0.2) { DesiredRotation.Pitch = origRot.Pitch + 0.5*swingAngle - Rand(swingAngle); DesiredRotation.Yaw = origRot.Yaw + 0.5*swingAngle - Rand(swingAngle); } if (confusionTimer > confusionDuration) { bConfused = False; confusionTimer = 0; confusionDuration = Default.confusionDuration; LightHue = 80; MultiSkins[2] = Texture'GreenLightTex'; SoundPitch = 64; DesiredRotation = origRot; } return; } // check the player's visibility every 0.1 seconds if (!bNoAlarm) { playerCheckTimer += deltaTime; if (playerCheckTimer > 0.1) { playerCheckTimer = 0; if (Level.NetMode == NM_Standalone) CheckPlayerVisibility(DeusExPlayer(GetPlayerPawn())); else { curPlayer = DeusExPlayer(AcquireMultiplayerTarget()); if (curPlayer != None) CheckPlayerVisibility(curPlayer); } } } // forget about the player after a set amount of time if (bPlayerSeen) { // if the player has been seen, but the camera hasn't triggered yet, // provide some feedback to the player (light and sound) if (!bEventTriggered) { triggerTimer += deltaTime; if (triggerTimer % 0.5 > 0.4) { LightHue = 0; MultiSkins[2] = Texture'RedLightTex'; PlaySound(Sound'Beep6',,,, 1280); } else { LightHue = 80; MultiSkins[2] = Texture'GreenLightTex'; } } if (lastSeenTimer < memoryTime) lastSeenTimer += deltaTime; else { lastSeenTimer = 0; bPlayerSeen = False; // untrigger the event TriggerEvent(False); } return; } swingTimer += deltaTime; MultiSkins[2] = Texture'GreenLightTex'; // swing back and forth if all is well if (bSwing && !bTrackPlayer) { ang = 2 * Pi * swingTimer / swingPeriod; rot = origRot; rot.Yaw += Sin(ang) * swingAngle; DesiredRotation = rot; } // DEUS_EX AMSD For multiplayer ReplicatedRotation = DesiredRotation; } auto state Active { function TakeDamage(int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, name DamageType) { local float mindmg; if (DamageType == 'EMP') { // duration is based on daamge // 10 seconds min to 30 seconds max mindmg = Max(Damage - 15.0, 0.0); confusionDuration += mindmg / 5.0; confusionTimer = 0; if (!bConfused) { bConfused = True; LightHue = 40; MultiSkins[2] = Texture'YellowLightTex'; SoundPitch = 128; PlaySound(sound'EMPZap', SLOT_None,,, 1280); } return; } if (( Level.NetMode != NM_Standalone ) && (EventInstigator.IsA('DeusExPlayer'))) DeusExPlayer(EventInstigator).ServerConditionalNotifyMsg( DeusExPlayer(EventInstigator).MPMSG_CameraInv ); Super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType); } } function BeginPlay() { Super.BeginPlay(); origRot = Rotation; DesiredRotation = origRot; playerLocation = Location; if (Level.NetMode != NM_Standalone) { bInvincible=True; HackStrength = 0.6; } } // ------------------------------------------------------------------------ // AcquireMultiplayerTarget() // DEUS_EX AMSD Copied from Turret so that cameras will track enemy players // in multiplayer. // ------------------------------------------------------------------------ function Actor AcquireMultiplayerTarget() { local Pawn apawn; local DeusExPlayer aplayer; local Vector dist; //DEUS_EX AMSD See if our old target is still valid. if ((prevtarget != None) && (prevtarget != safetarget) && (Pawn(prevtarget) != None)) { if (Pawn(prevtarget).AICanSee(self, 1.0, false, false, false, true) > 0) { if (DeusExPlayer(prevtarget) == None) { curtarget = prevtarget; return curtarget; } else { if (DeusExPlayer(prevtarget).AugmentationSystem.GetAugLevelValue(class'AugRadarTrans') == -1.0) { curtarget = prevtarget; return curtarget; } } } } // MB Optimized to use pawn list, previous way used foreach VisibleActors apawn = Level.PawnList; while ( apawn != None ) { if (apawn.bDetectable && !apawn.bIgnore && apawn.IsA('DeusExPlayer')) { aplayer = DeusExPlayer(apawn); dist = aplayer.Location - Location; if ( VSize(dist) < CameraRange ) { // Only players we can see if ( aplayer.FastTrace( aplayer.Location, Location )) { //only track players who aren't the safetarget. //we already know prevtarget not valid. if ((aplayer != safeTarget) && (aplayer != prevTarget)) { if (! ( (TeamDMGame(aplayer.DXGame) != None) && (safeTarget != None) && (TeamDMGame(aplayer.DXGame).ArePlayersAllied( DeusExPlayer(safeTarget),aplayer)) ) ) { // If the player's RadarTrans aug is off, the turret can see him if (aplayer.AugmentationSystem.GetAugLevelValue(class'AugRadarTrans') == -1.0) { curTarget = apawn; break; } } } } } } apawn = apawn.nextPawn; } return curtarget; } defaultproperties { swingAngle=8192 swingPeriod=8.000000 cameraFOV=4096 cameraRange=1024 memoryTime=5.000000 bActive=True confusionDuration=10.000000 triggerDelay=4.000000 msgActivated="Camera activated" msgDeactivated="Camera deactivated" Team=-1 HitPoints=50 minDamageThreshold=50 bInvincible=False FragType=Class'DeusEx.MetalFragment' ItemName="Surveillance Camera" Physics=PHYS_Rotating Texture=Texture'DeusExDeco.Skins.SecurityCameraTex2' Mesh=LodMesh'DeusExDeco.SecurityCamera' SoundRadius=48 SoundVolume=192 AmbientSound=Sound'DeusExSounds.Generic.CameraHum' CollisionRadius=10.720000 CollisionHeight=11.000000 LightType=LT_Steady LightBrightness=120 LightHue=80 LightSaturation=100 LightRadius=1 bRotateToDesired=True Mass=20.000000 Buoyancy=5.000000 RotationRate=(Pitch=65535,Yaw=65535) bVisionImportant=True } |
Overview | Package | Class | Source | Class tree | Glossary | Deus Ex UnrealScript Documentation |
previous class next class | frames no frames |