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 |
//===================================================================== // AI_ReactToFireSensor // Trigger the ReactToFire goal? // Value (int): on/off? //===================================================================== class AI_ReactToFireSensor extends AI_Sensor implements IHearingNotification; //===================================================================== // Constants enum TriggerCategories { RTF_PAIN, RTF_NEAR_MISS, RTF_MOVEMENT_SOUND, RTF_COMBAT_SOUND }; //===================================================================== // Variables var Pawn attacker; // who was responsible for triggering this sensor? var TriggerCategories triggerCategory; // what triggered the ReactToFireSensor? var AI_PainSensor painSensor; // sub-sensor var AI_NearMissSensor nearMissSensor; // another sub-sensor var Rook rook; //===================================================================== // Functions //--------------------------------------------------------------------- // convenience function to set all the variables (and the sensor value itself) function setValue( Pawn anAttacker, TriggerCategories trigger ) { attacker = anAttacker; triggerCategory = trigger; setIntegerValue( 1 ); // trigger goal activation } //--------------------------------------------------------------------- // Sensor callback (from painSensor) function onSensorMessage( AI_Sensor sensor, AI_SensorData value, Object userData ) { local Rook shooter; //log( name @ "sensorMessage called by" @ sensor.name @ "with value" @ value.integerData @ value.objectData ); //log( name @ "Alertness:" @ rook.getAlertnessLevel() ); if ( sensor.IsA( 'AI_PainSensor' ) && painSensor.InstigatedBy != None && painSensor.InstigatedBy != rook ) // pain caused by another rook { setValue( painSensor.InstigatedBy, RTF_PAIN ); } if ( sensor.IsA( 'AI_NearMissSensor' ) ) { shooter = Projectile(value.objectData).rookAttacker; if ( !rook.isFriendly( shooter ) ) // ignore near misses by friendlies { setValue( shooter, RTF_NEAR_MISS ); } } } //--------------------------------------------------------------------- // sound callback function OnListenerHeardNoise(Pawn Listener, Actor SoundMaker, vector SoundOrigin, Name SoundCategory ) { local Rook r; local bool bCombatSound; // try to determine the pawn responsible for the sound r = Rook(SoundMaker); if ( r == None && SoundMaker.isA( 'Projectile' )) { r = Projectile(SoundMaker).rookAttacker; bCombatSound = true; } if ( r == None && SoundMaker.isA( 'Weapon' )) { r = Weapon(SoundMaker).rookOwner; bCombatSound = true; } if ( r != None && !rook.isFriendly( r ) && !rook.vision.isVisible( r ) ) { //log( "!!!" @ Listener.name @ SoundMaker.name @ SoundCategory @ SoundOrigin @ bCombatSound ); if ( bCombatSound ) setValue( r, RTF_COMBAT_SOUND ); else setValue( r, RTF_MOVEMENT_SOUND ); } } //--------------------------------------------------------------------- // perform sensor-specific startup initializations when sensor is activated function begin() { rook = sensorAction.resource.localRook(); rook.RegisterHearingNotification( self ); painSensor = AI_PainSensor(class'AI_Sensor'.static.activateSensor( self, class'AI_PainSensor', sensorAction.resource, 1, 1000, )); nearMissSensor = AI_NearMissSensor(class'AI_Sensor'.static.activateSensor( self, class'AI_NearMissSensor', sensorAction.resource,, class'AI_Sensor'.const.ONLY_NON_NONE_VALUE, )); } //--------------------------------------------------------------------- // perform sensor-specific cleanup when sensor is deactivated function cleanup() { sensorAction.resource.localRook().UnregisterHearingNotification( self ); if ( painSensor != None ) { painSensor.deactivateSensor( self ); painSensor = None; } if ( nearMissSensor != None ) { nearMissSensor.deactivateSensor( self ); nearMissSensor = None; } } //===================================================================== |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |