Core.Object | +--Engine.Actor | +--Engine.Inventory | +--Engine.Powerups | +--XIII.XIIIItems | +--XIII.Micro
int
FakeCharge
XIIIBaseHud
HUD
Pawn
ListenTarget
MicroState
float
ScopeFOV
bool
bActivated
bCanCauseGameOver
bMaxZoomed
bTriggeredMissInTrainMode
bZoomed
sound
hMicroSound
hZoomSound
void
EndUse()
//_____________________________________________________________________________ // Called in Beginstate of Downweapon
PutDown()
//_____________________________________________________________________________
ShouldDrawCrosshair(Canvas C)
UsedUp()
//_____________________________________________________________________________ // This is called when a usable inventory item has used up it's charge.
DisplayChrono(string str)
string
StrTime(int i)
Activate()
00001 //----------------------------------------------------------- 00002 // 00003 //----------------------------------------------------------- 00004 class Micro extends XIIIItems; 00005 00006 // Charges for the micro are the tenth of seconds you are allowed missing the target you must listen. 00007 // should be 30 = 3.0 seconds 00008 00009 var bool bZoomed; // are we zoomed. 00010 var bool bMaxZoomed; // are we zoomed as much as we can ? (used for Sound). 00011 var sound hZoomSound; // Zooming sound (param 0 = begin, 2 = stop zooming in, 1 = zoom out) 00012 var float ScopeFOV; // FOV to use in zoom 00013 var Pawn ListenTarget; // Target to listen 00014 var bool bCanCauseGameOver; // just to allow this for a period of time while spying 00015 var bool bActivated; // to allow check of sound (not causing gameover, used for training period. If not activated, no timer nor effects) 00016 00017 var sound hMicroSound; // used to handle micro sfxs 00018 var int MicroState; 00019 var int FakeCharge; // 00020 VAR XIIIBaseHud HUD; 00021 00022 // MicroState = 00023 // 0 = do nothing 00024 // 1 = Wait for didacticiel01 event to be triggered 00025 // 2 = didacticiel01 triggered 00026 00027 //var localized string sMicroTooFar; 00028 //var localized string sMicroFailure; 00029 00030 var bool bTriggeredMissInTrainMode; 00031 00032 EVENT BeginState() 00033 { 00034 // LOG("MICRO ==>"@GetStateName() @"MicroState =" @MicroState ); 00035 } 00036 00037 //_____________________________________________________________________________ 00038 // Called in Beginstate of Downweapon 00039 FUNCTION EndUse() 00040 { 00041 LOCAL Info dm; 00042 00043 if ( bCanCauseGameOver ) 00044 { 00045 Charge = 0; 00046 UsedUp(); 00047 StopVoice(); 00048 SetTimer2(0,false); 00049 Instigator.PlaySound(hMicroSound, 0 /*int(bMaxZoomed)*/, /*int(fFactor**/10000/*)*/); 00050 foreach DynamicActors(class'Info',dm) 00051 { 00052 if ( dm.IsA('DialogueManager') ) 00053 dm.Destroy(); 00054 } 00055 00056 } 00057 if (bZoomed) 00058 { 00059 // PlayerController(Instigator.Controller).ToggleZoom(); 00060 bZoomed=false; 00061 bMaxZoomed=false; 00062 } 00063 XIIIPlayerController(Pawn(Owner).Controller).EndZoom(); 00064 } 00065 00066 //_____________________________________________________________________________ 00067 FUNCTION bool ShouldDrawCrosshair(Canvas C) 00068 { 00069 return !bZoomed; 00070 } 00071 00072 //_____________________________________________________________________________ 00073 FUNCTION bool PutDown() 00074 { 00075 /* if ( bCanCauseGameOver ) 00076 { 00077 Charge = 0; 00078 UsedUp(); 00079 return false; 00080 } 00081 else 00082 {*/ 00083 bChangeItem=true; 00084 return true; 00085 // } 00086 } 00087 00088 //_____________________________________________________________________________ 00089 // This is called when a usable inventory item has used up it's charge. 00090 FUNCTION UsedUp() 00091 { 00092 SetTimer2(0.0, false); 00093 if ( bCanCauseGameOver ) 00094 { 00095 Level.Game.EndGame( XIIIPlayercontroller(XIIIPawn(Owner).controller).PlayerReplicationInfo, "GoalIncomplete" ); 00096 // GotoState('DownItem'); 00097 return; 00098 } 00099 00100 if ( Pawn(Owner) != None ) 00101 { 00102 bActivatable = false; 00103 XIIIPlayercontroller(XIIIPawn(Owner).controller).cNextItem(); 00104 if ( (XIIIPawn(Owner).PendingItem == None) || (XIIIPawn(Owner).PendingItem == self) ) 00105 XIIIPlayercontroller(XIIIPawn(Owner).controller).NextWeapon(); 00106 00107 XIIIPawn(Owner).ChangedWeapon(); 00108 if (Level.Game.StatLog != None) 00109 Level.Game.StatLog.LogItemDeactivate(Self, XIIIPawn(Owner)); 00110 Instigator.ReceiveLocalizedMessage( MessageClass, 0, None, None, Self.Class ); 00111 } 00112 Instigator.PlayRolloffSound(DeactivateSound, self); 00113 Destroy(); 00114 } 00115 00116 //_____________________________________________________________________________ 00117 State InUse 00118 { 00119 EVENT BeginState() 00120 { 00121 Global.BeginState(); // 00122 PlayUsing(); 00123 // bRendered=false; 00124 // bHidden=true; 00125 } 00126 00127 FUNCTION Activate() 00128 { 00129 } 00130 00131 EVENT AnimEnd(int Channel) 00132 { 00133 UseMe(); 00134 if ( bChangeItem ) 00135 { 00136 GotoState('DownItem'); 00137 return; 00138 } 00139 GotoState('Zooming'); 00140 } 00141 } 00142 00143 //_____________________________________________________________________________ 00144 STATE Zooming 00145 { 00146 EVENT BeginState() 00147 { 00148 Global.BeginState(); // 00149 00150 bHidden=!bHidden; 00151 RefreshDisplaying(); 00152 bRendered=false; 00153 00154 if ( bZoomed ) 00155 { 00156 PlayerController(Instigator.Controller).ToggleZoom(); 00157 Instigator.PlayRolloffSound(hZoomSound, self, 1); 00158 if ( bActivated ) 00159 GoToState('Listening'); 00160 else 00161 GotoState('Idle'); 00162 } 00163 else 00164 { 00165 PlayerController(Instigator.Controller).StartZoom(); 00166 PlayerController(Instigator.Controller).ZoomLevel = 0.3; 00167 PlayerController(Instigator.Controller).SetFov(FClamp(90.0 - (0.3 * 88.0), 1, 170)); 00168 Instigator.PlayRolloffSound(hZoomSound, self, 0); 00169 } 00170 bZoomed=false; 00171 bMaxZoomed=false; 00172 } 00173 00174 EVENT Tick(float DeltaTime) 00175 { 00176 if (PlayerController(Instigator.Controller).FovAngle < ScopeFov) 00177 { 00178 PlayerController(Instigator.Controller).StopZoom(); 00179 PlayerController(Instigator.Controller).SetFov(ScopeFov); 00180 Instigator.PlayRolloffSound(hZoomSound, self, 2); 00181 // SetTimer(0.0,False); 00182 bZoomed=true; 00183 bMaxZoomed=true; 00184 SetTimer2(0.1, true); 00185 if ( bActivated ) 00186 GoToState('Listening'); 00187 else 00188 GoToState('Idle'); 00189 } 00190 } 00191 00192 FUNCTION Activate() 00193 { 00194 } 00195 } 00196 00197 FUNCTION string StrTime( int i ) 00198 { 00199 LOCAL int iMillisec, iSec; 00200 00201 iSec = i/10; 00202 iMilliSec = i - iSec*10; 00203 return iSec$":"$iMilliSec$"0"; 00204 00205 } 00206 00207 FUNCTION DisplayChrono( string str ) 00208 { 00209 // XIIIBaseHUD(Playercontroller(Pawn(Owner).Controller).MyHud) 00210 HUD.AddChronoDisplay( str ); 00211 } 00212 00213 EVENT Timer2() 00214 { 00215 LOCAL float fFactor; 00216 LOCAL VECTOR /*X,Y,Z,*/ v2; 00217 00218 if ( !bActivated && !bCanCauseGameOver ) 00219 { 00220 // reseted, end sequence 00221 GotoState('Idle'); 00222 SetTimer2(0.0, false); 00223 } 00224 // GetAxes(Pawn(Owner).GetViewRotation(), X, Y, Z); 00225 v2 = (ListenTarget.Location + ListenTarget.EyePosition()) - (Pawn(Owner).Location + Pawn(Owner).EyePosition()); 00226 fFactor = normal(V2) dot Vector(Pawn(Owner).GetViewRotation()); 00227 fFactor *= (1-fClamp( (vSize(v2)-3100)*0.002, 0, 1)); 00228 Instigator.PlaySound(hMicroSound, int(bMaxZoomed), int(fFactor*10000)); 00229 00230 if ( bCanCauseGameOver ) 00231 { 00232 if ( (fFactor < 0.9997) || !bZoomed ) 00233 { 00234 if ( bZoomed ) 00235 Charge -= 1; 00236 else 00237 Charge -=2; 00238 00239 if (Charge >= 0) 00240 { 00241 HUD.bDrawChronoWithWarningColors=(Charge<21); 00242 DisplayChrono( StrTime( Charge ) ); 00243 } 00244 else 00245 { 00246 UsedUp(); 00247 HUD.bDrawChronoWithWarningColors=true; 00248 if ( Level.TimeSeconds-int(Level.TimeSeconds)>0.5 ) 00249 DisplayChrono( "0:00" /*sMicroFailure*/ ); 00250 else 00251 DisplayChrono( "" ); 00252 } 00253 } 00254 else 00255 { 00256 Charge = min(default.Charge, Charge+1); 00257 HUD.bDrawChronoWithWarningColors=(Charge<21); 00258 DisplayChrono( StrTime( Charge ) ); 00259 } 00260 } 00261 else 00262 { 00263 if ( MicroState == 0 ) 00264 { 00265 if ( (fFactor < 0.9997) || !bZoomed ) 00266 { 00267 SetTimer(0.0, false); 00268 HUD.bDrawChronoWithWarningColors=true; 00269 if ( Level.TimeSeconds-int(Level.TimeSeconds)>0.5 ) 00270 DisplayChrono( "?:??" /*sMicroTooFar*/ ); 00271 else 00272 DisplayChrono( "" ); 00273 } 00274 else 00275 { 00276 MicroState ++; 00277 SetTimer(0.5, false); 00278 } 00279 } 00280 else if ( (fFactor < 0.9997) || !bZoomed ) 00281 { 00282 if ( MicroState == 1 ) 00283 { 00284 FakeCharge = min(default.FakeCharge, FakeCharge+1); 00285 HUD.bDrawChronoWithWarningColors=true; 00286 if ( Level.TimeSeconds-int(Level.TimeSeconds)>0.5 ) 00287 DisplayChrono( "?:??" /*sMicroTooFar*/ ); 00288 else 00289 DisplayChrono( "" ); 00290 } 00291 else // we ARE in state 2, can't be otherwise 00292 { 00293 if ( bZoomed ) 00294 FakeCharge -= 1; 00295 else 00296 FakeCharge -=2; 00297 if (FakeCharge >= 0) 00298 { 00299 if ( !bTriggeredMissInTrainMode && FakeCharge<21 ) 00300 { 00301 bTriggeredMissInTrainMode=true; 00302 XIIIGameInfo(Level.Game).MapInfo.SetGoalComplete(97); 00303 } 00304 HUD.bDrawChronoWithWarningColors=(FakeCharge<21); 00305 DisplayChrono( StrTime( FakeCharge ) ); 00306 } 00307 else 00308 { 00309 FakeCharge=-1; 00310 HUD.bDrawChronoWithWarningColors=true; 00311 if ( Level.TimeSeconds-int(Level.TimeSeconds)>0.5 ) 00312 DisplayChrono( "0:00" /*sMicroFailure*/ ); 00313 else 00314 DisplayChrono( "" ); 00315 } 00316 } 00317 } 00318 else 00319 { 00320 FakeCharge = min(default.FakeCharge, FakeCharge+1); 00321 HUD.bDrawChronoWithWarningColors=(FakeCharge<21); 00322 DisplayChrono( StrTime( FakeCharge ) ); 00323 } 00324 } 00325 } 00326 00327 EVENT Timer() 00328 { 00329 if ( MicroState == 1 ) 00330 { 00331 MicroState ++; 00332 Fakecharge = Default.FakeCharge; 00333 TriggerEvent('Didacticiel01', self, Pawn(Owner)); 00334 } 00335 } 00336 00337 //_____________________________________________________________________________ 00338 STATE Listening extends Idle 00339 { 00340 EVENT BeginState() 00341 { 00342 Global.BeginState(); 00343 SUPER.BeginState(); 00344 FakeCharge = Default.Charge; 00345 HUD = XIIIBaseHUD(Playercontroller(Pawn(Owner).Controller).MyHud); 00346 } 00347 00348 EVENT EndState() 00349 { 00350 if ( bCanCauseGameOver ) 00351 Level.Game.EndGame( XIIIPlayercontroller(XIIIPawn(Owner).controller).PlayerReplicationInfo, "GoalIncomplete" ); 00352 } 00353 } 00354 00355 00356 00357 defaultproperties 00358 { 00359 hZoomSound=Sound'XIIIsound.Guns__Zoom.Zoom__hZoom' 00360 ScopeFOV=7.000000 00361 bCanCauseGameOver=True 00362 hMicroSound=Sound'XIIIsound.SpecActions__MicroCanon.MicroCanon__hMicroCanon' 00363 FakeCharge=30 00364 MeshName="XIIIArmes.FpsMicroM" 00365 IHand=IH_2H 00366 hSelectItemSound=Sound'XIIIsound.SpecActions__MicroCanon.MicroCanon__hDegaine' 00367 hDownItemSound=Sound'XIIIsound.SpecActions__MicroCanon.MicroCanon__hRengaine' 00368 ZCrosshair=Texture'XIIIMenu.HUD.ZMireSniperA' 00369 ZCrosshairDot=Texture'XIIIMenu.HUD.MireCouteau' 00370 IconNumber=29 00371 sItemName="Micro" 00372 bAutoActivate=True 00373 bActivatable=True 00374 ExpireMessage="Zoomer was used." 00375 InventoryGroup=8 00376 bDisplayableInv=True 00377 PickupClassName="XIII.MicroPick" 00378 Charge=30 00379 PlayerViewOffset=(X=8.600000,Y=6.000000,Z=-5.800000) 00380 BobDamping=0.975000 00381 ThirdPersonRelativeLocation=(X=27.000000,Y=-3.000000,Z=-13.000000) 00382 ThirdPersonRelativeRotation=(Roll=32768) 00383 AttachmentClass=Class'XIII.MicroAttach' 00384 ItemName="MICRO" 00385 Rotation=(Roll=-15536) 00386 }