## XIDCine
Class Cine2

source: C:\XIII\XIDCine\Classes\Cine2.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Pawn
             |
             +--XIII.XIIIPawn
                |
                +--XIDPawn.BaseSoldier
                   |
                   +--XIDCine.Cine2

Direct Known Subclasses:ChoPawn, MangousteSSH1Pawn

class Cine2
extends XIDPawn.BaseSoldier

    //-=-=-=-=-=-=-=-=-=-=-=-
    // Cine2 Created by iKi
    //-=-=-=-=-=-=-=-=-=-=-=-

Variables
`MyYPos,` | `BlinkEndTime`
`CineController2` | `CineController`
`MyOldRotYaw,` | `HeadYaw`
`Canvas` | `MyCanvas`
`XIIIPlayerController` | `PC`
`BumpedActor,` | `PeeredActor`
`MapInfo` | `mi`
`SMAttached` | `mycasm`

States
CineInit

Function Summary
`void` | `CancelReaction(int i)`
`void` | `CollisionActivity(bool B)`
`bool` | `GetAction(int i, out string)`
`int` | `GetTabActionLength()`
`void` | `HearSound()`
`void` | `InitCheckPoint()`
`void` | `Play(ECineStimulus CS_Key)`
`void` | `RenderOverlays(Canvas Canvas)`
`void` | `SeeCadaver()`
`void` | `SeeXIII()`
`void` | `SetInvisibility(bool B)`

State CineInit Function Summary
`Inventory` | `DropObject(int ItemIndex, Pawn P)`
`Inventory` | `GiveObject(int ItemIndex, Pawn P)`
`void` | `StopShoot( )`
`void` | `AltShoot( )`
`void` | `Shoot( )`
`void` | `ReadyWeapon(int WeaponIndex)`
    //#################################################################
`void` | `PrintC(string str)`
    //#################################################################
`void` | `LockDoor(XIIIPorte door)`
`void` | `UnlockDoor(XIIIPorte door)`
`void` | `CloseDoor(XIIIPorte door)`
`void` | `OpenDoor(XIIIPorte door)`
`void` | `ConvertToSoldier()`
`void` | `PostBeginPlay()`
`bool` | `Collide(Actor p)`
`bool` | `ChangeToBestWeapon()`
`void` | `PlayMoving()`
`void` | `HearSound()`
`void` | `SeeCadaver( )`
`void` | `SeeXIII( )`

Source Code

    00001	//-=-=-=-=-=-=-=-=-=-=-=-
    00002	// Cine2 Created by iKi
    00003	//-=-=-=-=-=-=-=-=-=-=-=-
    00004	class Cine2 extends BaseSoldier
    00005		HideCategories(AnimTweaks, Force, LightColor, Lightning)
    00006		placeable
    00007		native;
    00008
    00009	ENUM ECineStimulus
    00010	{
    00011		CS_None, CS_SeeCadaver, CS_Trigger, CS_SeePlayer, CS_TakeDamage, CS_MapStart,
    00012		CS_HearNoise, CS_OutOfOrder_PlayerMove, CS_OutOfOrder_SeenByPlayer
    00013	};
    00014
    00015	STRUCT StructReaction
    00016	{
    00017		VAR()	ECineStimulus	eCS_Stimulus;
    00018		VAR()	int				TabActionIndex; // 0 or 1 : tabActions, 2 : tabActions2, etc...
    00019		VAR()	bool			bUneSeuleFois, bInterruptive;
    00020	};
    00021
    00022	STRUCT StructSave
    00023	{
    00024		VAR()	Actor Position;
    00025		VAR()	Actor Target;
    00026		VAR()	int tabAction;
    00027		VAR()	string Label;
    00028	};
    00029
    00030	VAR(Cine_Save)	Array<StructSave>		CheckPoints;
    00031
    00032	VAR(Cine_Anim)	name					DefaultAnim, WalkAnim, RunAnim, WaitAnim;
    00033	VAR(Cine_Anim)	Array<MeshAnimation>	SpecificAnimations;
    00034	VAR(Cine_Anim)	float					TweenTime;
    00035	VAR(Cine_Anim)	float					WalkAnimVelocity, WalkRunLimitVelocity, RunAnimVelocity;
    00036
    00037	VAR(Cine_Script)	Array<StructReaction>	Reaction;
    00038	VAR(Cine_Script)	Array<string>			tabActions, tabActions2, tabActions3;
    00039
    00040	VAR(Cine_Sound)		Array<Sound>	Musics, Sounds, Onomatops;
    00041
    00042	VAR(Cine_Misc)		Array< class<SMAttached> >	AttachedArtefacts;
    00043	VAR(Cine_Shoot)		float	InitialShootDispersion;
    00044	VAR(Cine_Movement)	float	InitialSpeed,InitialRotationSpeed,InitialAccelerationFactor,InitialDetectionDistance;
    00045	VAR(Cine_Movement)	vector	vMoveconstraint;
    00046	//VAR(Cine_Movement)	bool	bUseRotationAnimations;
    00047
    00048	VAR			class<CineController2>	CineControllerClass;
    00049
    00050	VAR			int						CurrentScript;
    00051
    00052	VAR TRANSIENT	MapInfo				mi;
    00053
    00054	// boolean variables
    00055	VAR(Cine_Movement)	bool	bPauseMovementIfBumped, ImposedEndMovePosition;
    00056	VAR(Cine_Misc)		bool	Invisible, bBlindWhenInvisible, bDeafWhenInvisible;
    00057	VAR(Cine_Shoot)		bool	bArmed;
    00058	VAR					bool	bPaused, MemoColActors, MemoBlockActors, MemoBlockPlayers, bBlinking, bInitialized;
    00059	VAR					int		cpn; // CheckPointNumber
    00060
    00061	VAR TRANSIENT	CineController2			CineController;
    00062	VAR TRANSIENT	Canvas					MyCanvas;
    00063	VAR TRANSIENT	float					MyYL, MyYPos, BlinkEndTime;
    00064	VAR TRANSIENT	XIIIPlayerController	PC;
    00065	VAR TRANSIENT	int						CurrentTabActionIndex, MyOldRotYaw, HeadYaw;
    00066	VAR TRANSIENT	actor					BumpedActor, PeeredActor;
    00067	//VAR TRANSIENT	DialogueManager			MyDialogueManager;
    00068	VAR TRANSIENT	SMAttached				mycasm;
    00069
    00070	native FUNCTION OnTheSpotRotation( /*float dt*/ );
    00071
    00072	FUNCTION Died(Controller Killer, class<DamageType> damageType, vector HitLocCode)
    00073	{
    00074		LOCAL xiiigameinfo gameinf;
    00075		LOCAL int i;
    00076
    00077		ReleaseAnimControl();
    00078
    00079		if ( class<XIIIDamageType>(damageType).default.bDieInSilencePlease )
    00080			PlaySndDeathOno(deathono'Onomatopees.hPNJDeath2',CodeMesh,NumeroTimbre);
    00081		else
    00082			PlaySndDeathOno(deathono'Onomatopees.hPNJDeath1',CodeMesh,NumeroTimbre);
    00083
    00084		if (Controller!=none && Controller.IsA('IAController'))
    00085		{
    00086			gameinf=xiiigameinfo(level.game);
    00087			switch (IAController(controller).NiveauALerte)
    00088			{
    00089			case 0:
    00090				level.decattente();
    00091				// Iacontroller(controller).genalerte.nbattente--;
    00092				//log("decattente "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque);
    00093				break;
    00094			case 1:
    00095				level.decAlerte();
    00096				// Iacontroller(controller).genalerte.nbalerte--;
    00097				// log("decalerte "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque);
    00098				break;
    00099			case 2:
    00100				level.decAttaque();
    00101				//Iacontroller(controller).genalerte.nbattaque--;
    00102				//log("decattaque "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque);
    00103				break;
    00104			}
    00105			//suprresion de la liste des basesoldiers
    00106			for (i = 0; i < gameinf.BaseSoldierList.Length; i++)
    00107			{
    00108				if (gameinf.BaseSoldierList[i] == self )
    00109				{
    00110					gameinf.BaseSoldierList.Remove(i,1);
    00111					break;
    00112				}
    00113			}
    00114			controller.gotostate('mort');
    00115		}
    00116		Super(XIIIPAwn).Died( Killer, damageType, HitLocCode);
    00117	}
    00118
    00119	function RenderOverlays(Canvas Canvas)
    00120	{
    00121		LOCAL HUD h;
    00122		LOCAL Vector Start, End;
    00123
    00124		h=mi.XIIIController.MyHud;
    00125
    00126		if ( CineController!=none)
    00127		{
    00128			if ( CineController.Target!=none)
    00129			{
    00130				h.Draw3DLine( Location, CineController.Target.Location, class'Canvas'.Static.MakeColor(255,255,255));
    00131				if ( CineController.NextTarget!=none)
    00132					h.Draw3DLine( CineController.Target.Location, CineController.Target.Location , class'Canvas'.Static.MakeColor(255,0,255));
    00133
    00134			}
    00135			if ( CineController.Focus!=none)
    00136				h.Draw3DLine( Location, CineController.Focus.Location, class'Canvas'.Static.MakeColor(255,0,0));
    00137			else
    00138				h.Draw3DLine( Location, CineController.FocalPoint, class'Canvas'.Static.MakeColor(255,128,128));
    00139
    00140			if ( Weapon!=none && CineController.LockedActor!=none )
    00141			{
    00142				Start = Location + EyePosition() + ( Weapon.FireOffset >> GetViewRotation( ) );
    00143				End = CineController.LockedActor.Location + CineController.AdjustAiming;
    00144				h.Draw3DLine( Start, End, class'Canvas'.Static.MakeColor(255,128,0));
    00145			}
    00146		}
    00147	}
    00148
    00149	EVENT SetInitialState( )
    00150	{
    00151		MemoColActors =		bCollideActors;
    00152		MemoBlockActors =	bBlockActors;
    00153		MemoBlockPlayers =	bBlockPlayers;
    00154
    00155		bScriptInitialized = true;
    00156		MyOldRotYaw = Rotation.Yaw;
    00157	//	AnimBlendParams( 2, 0.0, 0.0, 0.0, 'X R THIGH' );
    00158	//	AnimBlendParams( 3, 0.0, 0.0, 0.0, 'X L THIGH' );
    00159		AnimBlendParams( 2, 0.0, 0.0, 0.0, 'X PELVIS' );
    00160		AnimBlendParams( 3, 0.0, 0.0, 0.0, 'X PELVIS' );
    00161
    00162		GotoState( 'CineInit' );
    00163	}
    00164
    00165	FUNCTION Play( ECineStimulus CS_Key )
    00166	{
    00167		LOCAL int i;
    00168
    00169		if ( !bInitialized )
    00170			return;
    00171
    00172		for (i=0;i<Reaction.Length;++i)
    00173		{
    00174			if  (
    00175					( ( CurrentScript == -1 ) || ( ( Reaction[ i ].bInterruptive ) && ( i >= CurrentScript ) ) )
    00176				&&
    00177					( Reaction[ i ].eCS_Stimulus == CS_Key )
    00178				)
    00179			{
    00180	// Interrupt previous script if there is one: TODO save current script context
    00181				if ( CurrentScript != -1 )
    00182					CineController.StopMove();
    00183				CurrentScript=i;
    00184
    00185	// Start my cine controller sequence
    00186				CurrentTabActionIndex = Reaction[ i ].TabActionIndex;
    00187
    00188				if ( CurrentTabActionIndex == -1)
    00189				{
    00190	/*::iKi::=>*/
    00191	/*				switch ( CS_Key )
    00192					{
    00193					case CS_None:
    00194						LOG ("TIS CS_None");
    00195						break;
    00196					case CS_SeeCadaver:
    00197						LOG ("TIS CS_SeeCadaver");
    00198						break;
    00199					case CS_Trigger:
    00200						LOG ("TIS CS_Trigger");
    00201						break;
    00202					case CS_SeePlayer:
    00203						LOG ("TIS CS_SeePlayer");
    00204						break;
    00205					case CS_TakeDamage:
    00206						LOG ("TIS CS_TakeDamage");
    00207						break;
    00208					case CS_MapStart:
    00209						LOG ("TIS CS_MapStart");
    00210						break;
    00211					case CS_HearNoise:
    00212						LOG ("TIS CS_HearNoise");
    00213						break;
    00214					case CS_OutOfOrder_PlayerMove:
    00215						LOG ("TIS CS_OutOfOrder_PlayerMove");
    00216						break;
    00217					case CS_OutOfOrder_SeenByPlayer:
    00218						LOG ("TIS CS_OutOfOrder_SeenByPlayer");
    00219						break;
    00220					}
    00221	*/
    00222	/*<=::iKi::*/
    00223					ConvertToSoldier( );
    00224				}
    00225				else if ( CurrentTabActionIndex < 4 )
    00226				{
    00227	//				LOG( self@"PLAY REACTION n°"$i@", STIMULUS CODE :"@CS_Key @", TabAction :"@Reaction[ i ].TabActionIndex);
    00228					if ( Reaction[ i ].bUneSeuleFois )
    00229						Reaction[ i ].eCS_Stimulus = CS_None;
    00230					CineController.StartSequence( );
    00231				}
    00232
    00233			}
    00234		}
    00235	}
    00236
    00237	FUNCTION CancelReaction(int i)
    00238	{
    00239		if ( i>=0 && i<Reaction.Length )
    00240			Reaction[ i ].eCS_Stimulus = CS_None;
    00241
} 00242 00243 FUNCTION int GetTabActionLength() 00244 { 00245 switch (CurrentTabActionIndex) 00246 { 00247 case 0: case 1: 00248 return tabActions.Length; 00249 case 2: 00250 return tabActions2.Length; 00251 case 3: 00252 return tabActions3.Length; 00253 } 00254 return 0; 00255 } 00256 00257 FUNCTION bool GetAction(int i,out string str) 00258 { 00259 if (CurrentTabActionIndex==0 || CurrentTabActionIndex==1) 00260 { 00261 if (i<tabActions.Length) { str=tabActions[i]; return true; } 00262 else return false; 00263 } 00264 else if (CurrentTabActionIndex==2) 00265 { 00266 if (i<tabActions2.Length) { str=tabActions2[i]; return true; } 00267 else return false; 00268 } 00269 else if (CurrentTabActionIndex==3) 00270 { 00271 if (i<tabActions3.Length) { str=tabActions3[i]; return true; } 00272 else return false; 00273 } 00274 } 00275 00276 FUNCTION HearSound() {} 00277 FUNCTION SeeXIII() {} 00278 FUNCTION SeeCadaver() { } 00279 00280 FUNCTION SetInvisibility(bool B) 00281 { 00282 bHidden = B; 00283 Invisible = B; 00284 if (B) 00285 { 00286 Visibility = 0; 00287 SetCollision( false, false, false ); 00288 Velocity = vect( 0, 0, 0 ); 00289 Acceleration = vect( 0, 0, 0 ); 00290 } 00291 else 00292 { 00293 Visibility = Default.Visibility; 00294 SetCollision( MemoColActors, MemoBlockActors, MemoBlockPlayers ); 00295 bBlockActors = MemoBlockActors; 00296 } 00297 RefreshDisplaying( ); 00298 } 00299 00300 FUNCTION CollisionActivity(bool B) 00301 { 00302 bCollideWorld=B; 00303 if (B) 00304 SetCollision(MemoColActors,MemoBlockActors,MemoBlockPlayers); 00305 else 00306 SetCollision(false,false,false); 00307 } 00308 00309 FUNCTION InitCheckPoint() 00310 { 00311 cpn=XIIIGameInfo(Level.Game).CheckPointNumber-2; 00312 // LOG ( self@"("$PawnName$") -> CHECKPOINT NUMBER"@cpn ); 00313 if ( cpn>=0 && cpn<CheckPoints.Length) 00314 { 00315 // LOG ( self@"LOADING CHECKPOINT"@cpn ); 00316 00317 if ( CheckPoints[cpn].Position!=none ) 00318 SetLocation( CheckPoints[cpn].Position.Location ); 00319 if ( CheckPoints[cpn].Target!=none ) 00320 { 00321 SetRotation( ROTATOR( CheckPoints[cpn].Target.Location - Location ) ); 00322 CineController.SetRotation( rotation ) ; 00323 } 00324 } 00325 else 00326 { 00327 cpn=-1; 00328 // LOG ( self@"FAILS TO LOAD CHECKPOINT"@cpn ); 00329 } 00330 } 00331 00332 // ################################################################################################################ 00333 AUTO STATE CineInit 00334 { 00335 EVENT BeginState() 00336 { 00337 if ( Mesh!=none ) 00338 { 00339 AnimBlendParams( 1, 0.0, 0.0, 0.0, 'X' ); 00340 SetTimer(0.033,true); 00341 } 00342 // else 00343 // { 00344 // Disable('Tick'); 00345 // return; 00346 // } 00347 // SetCollision( true, true, false ); 00348 } 00349 00350 EVENT EndState( ) 00351 { 00352 SetTimer(0,false); 00353 } 00354 00355 EVENT Tick( float dT ) 00356 { 00357 LOCAL VECTOR vTemp; 00358 00359 if ( !MemoBlockPlayers && !Invisible && PC!=none && PC.Pawn!=none ) 00360 { 00361 vTemp= PC.Pawn.Location-Location; 00362 vTemp.Z= 0; 00363 bHidden = (vSize( vTemp )<24) && !bIsDead; 00364 RefreshDisplaying(); 00365 } 00366 00367 Super.Tick( dt ); 00368 } 00369 00370 EVENT Timer() 00371 { 00372 LOCAL Rotator rl, r; 00373 LOCAL int n; 00374 00375 if ( bIsDead ) 00376 { 00377 SetBoneScalePerAxis( 16, 1, , , 'x BLINK' ); 00378 SetBoneRotation('X HEAD',rl,,0.0); 00379 SetTimer( 0.0, false ); 00380 return; 00381 } 00382 if ( !bHidden ) 00383 { 00384 if ( bBlinking ) 00385 { 00386 if ( Level.TimeSeconds > BlinkEndTime ) 00387 { 00388 SetBoneScalePerAxis( 16, 1, , , 'x BLINK' ); 00389 bBlinking = false; 00390 BlinkEndTime = Level.TimeSeconds + 1 + 4*FRand( ); 00391 } 00392 } 00393 else 00394 { 00395 if ( Level.TimeSeconds > BlinkEndTime ) 00396 { 00397 SetBoneScalePerAxis( 16, 0, , , 'x BLINK' ); 00398 bBlinking = true; 00399 BlinkEndTime = Level.TimeSeconds + 0.10 + 0.10*FRand( ); 00400 } 00401 } 00402 00403 if ( PeeredActor!=none ) 00404 { 00405 rl=rotator(PeeredActor.Location-Location)-Rotation; 00406 00407 n=rl.Yaw;//-16384; 00408 n=((n+32768)&65535)-32768; 00409 00410 if ((15000>n) && (n>-15000)) 00411 { 00412 HeadYaw = HeadYaw*0.9+0.1*n; 00413 rl.Yaw=0; 00414 rl.Pitch=0; 00415 rl.Roll=HeadYaw; 00416 SetBoneRotation('X HEAD',rl,,0.75); 00417 } 00418 else 00419 { 00420 HeadYaw = HeadYaw*0.98; 00421 rl.Yaw=0; 00422 rl.Pitch=0; 00423 rl.Roll= HeadYaw; 00424 SetBoneRotation('X HEAD',rl,,0.75); 00425 } 00426 } 00427 else 00428 { 00429 if ( HeadYaw!=0 ) 00430 { 00431 HeadYaw = HeadYaw*0.98; 00432 if ( HeadYaw > 100 ) 00433 { 00434 rl.Yaw=0; 00435 rl.Pitch=0; 00436 rl.Roll= HeadYaw; 00437 SetBoneRotation('X HEAD',rl,,0.75); 00438 } 00439 else 00440 { 00441 HeadYaw=0; 00442 rl.Yaw=0; 00443 rl.Pitch=0; 00444 rl.Roll= 0; 00445 SetBoneRotation('X HEAD',rl,,0.0); 00446 } 00447 } 00448 } 00449 } 00450 00451 } 00452 EVENT Trigger( actor Other, pawn EventInstigator ) 00453 { 00454 Play(CS_Trigger); 00455 } 00456 00457 FUNCTION SeeXIII( ) 00458 { 00459 if ( !bBlindWhenInvisible || !Invisible ) 00460 Play(CS_SeePlayer); 00461 } 00462 00463 FUNCTION SeeCadaver( ) 00464 { 00465 // Log("CINEINIT::SeeCadaver"); 00466 if ( !bBlindWhenInvisible || !Invisible ) 00467 Play(CS_SeeCadaver); 00468 } 00469 00470 EVENT Bump(Actor Other) 00471 { 00472 if (bPauseMovementIfBumped && CineController.bMoving && (Pawn(Other)!=none && Pawn(Other).IsPlayerPawn()) && !CineController.bMovePaused && ((Velocity dot (Other.Location-Location))>0)) 00473 { 00474 CineController.PauseMovement(); 00475 } 00476 BumpedActor=Other; 00477 } 00478 00479 FUNCTION HearSound() 00480 { 00481 if ( !bDeafWhenInvisible || !Invisible ) 00482 Play(CS_HearNoise); 00483 } 00484 00485 EVENT TakeDamage(int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType) 00486 { 00487 LOCAL bool bKilled; 00488 00489 if (!CineController.bDying) 00490 { 00491 if ( !bHidden ) 00492 Super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType); 00493 if ( Health<=0 ) 00494 { 00495 CineController.Pawn=none; 00496 CineController.MyPawn=none; 00497 CineController.GotoState('',''); 00498 } 00499 } 00500 00501 bKilled = (Health<=0) && ((DamageType != class'DTFisted') && (DamageType != class'DTCouDCross') && (DamageType != class'DTStunned') && (DamageType != class'DTSureStunned') && (DamageType != class'DTDropAfterStun')); 00502 00503 if ( ( EventInstigator.IsPlayerPawn() && ( (GameOver==GO_TakeDamageFromPlayer) || ( GameOver==GO_KillByPlayer && bKilled ) ) ) || ( GameOver==GO_AnyDeath && bKilled ) ) 00504 { 00505 if ( GameOverGoal>=0) 00506 { 00507 if (GameOverGoal>=90) 00508 { 00509 mi.SetGoalComplete(GameOverGoal); 00510 } 00511 else 00512 if ( mi.Objectif[GameOverGoal].bPrimary ) 00513 { 00514 mi.SetGoalComplete(GameOverGoal); 00515 } 00516 } 00517 else 00518 Level.Game.EndGame( PC.PlayerReplicationInfo, "GoalIncomplete" ); 00519 return; 00520 } 00521 00522 if ( EventInstigator!=self ) 00523 { 00524 if ( Health>0 ) 00525 Play( CS_TakeDamage ); 00526 } 00527 } 00528 00529 EVENT AnimEnd(int Channel){} 00530 00531 simulated function DisplayDebug(Canvas Canvas, out float YL, out float YPos) 00532 { 00533 LOCAL float XL; 00534 LOCAL int i; 00535 00536 Canvas.SetPos(4,4); 00537 Canvas.Style = ERenderStyle.STY_Alpha; 00538 Canvas.DrawColor.A=128; 00539 Canvas.DrawTile( Texture'Engine.ConsoleBK', 400, 348, 0, 0, 8, 8 ); 00540 00541 Canvas.Style = ERenderStyle.STY_Normal; 00542 Canvas.StrLen("TEST", XL, YL); 00543 Canvas.SetPos(4,YPos); 00544 00545 MyCanvas=Canvas; 00546 MyYL=YL; 00547 MyYPos=YPos; 00548 00549 if ( bDeleteMe ) 00550 PrintC("#R"$GetItemName(string(self))$" #YDELETED"); 00551 else 00552 PrintC("#R"$GetItemName(string(self))); 00553 00554 PrintC("#WName #Y"$Name$" #WControllerName #Y"$Controller.Name$" #WPawnname #Y"$PawnName); 00555 PrintC("#WTag #Y"$Tag$" #WState #Y"$GetStateName()); 00556 PrintC("#WLocation #Y"$Location$" #WRotation #Y"$Rotation); 00557 PrintC("#WMoveSequence #Y"$CineController.MoveSequence); 00558 PrintC("#RCONTROLLER"); 00559 PrintC("#WRotation #Y"$Controller.Rotation$" #WRotationSpeed #Y"$CineController.RotationSpeed); 00560 PrintC("#WFocus #Y"$CineController.Focus$" #WLockedActor #Y"$CineController.LockedActor); 00561 PrintC("#WScriptedActionIndex #Y"$CineController.ScriptedActionIndex); 00562 PrintC("#WLast Error #Y#N"$CineController.MemoError); 00563 00564 YPos=MyYPos; 00565 } 00566 simulated event ChangeAnimation() 00567 { 00568 if (!bIsDead && !bHidden) 00569 PlayMoving(); 00570 } 00571 Function PlayMoving() 00572 { 00573 LOCAL float fSpeed, TurnRate, StepSize; 00574 LOCAL bool bTurningRight, bTurningLeft; 00575 LOCAL float RotYaw; 00576 00577 StepSize = 0.1; //0.033/0.25; //BlendChangeTime; 00578 00579 if ( CurrentScript != -1 ) 00580 { 00581 if ( Velocity!=vect(0,0,0) ) 00582 { 00583 fSpeed=vSize(Velocity); 00584 00585 if ( CineController.MyPawnGroundSpeed * CineController.wantedspeed > WalkRunLimitVelocity ) 00586 { 00587 // iKi :: Grrrrrrrr.... foutu bug de m..... 00588 // if ( SimAnim.AnimRate==0 || SimAnim.AnimSequence!=RunAnim ) 00589 LoopAnim( RunAnim, fSpeed/RunAnimVelocity, 0.5 ); 00590 } 00591 else 00592 { 00593 // if ( SimAnim.AnimRate==0 || SimAnim.AnimSequence!=WalkAnim ) 00594 LoopAnim( WalkAnim, fSpeed/WalkAnimVelocity, 0.5 ); 00595 } 00596 } 00597 else 00598 { 00599 RotYaw = ( ( Rotation.Yaw - MyOldRotYaw + 32768 ) & 65535 ) - 32768 ; 00600 00601 // if ( bUseRotationAnimations ) 00602 // { 00603 TurnRate = RotYaw*30; 00604 bTurningRight = ( TurnRate > 1000.f ); 00605 bTurningLeft = ( TurnRate < -1000.f ); 00606 00607 if ( TurnRate > 1000.f ) 00608 LoopAnim( 'RotationD', Abs(TurnRate)/10000.f, 0.2 ); 00609 else if ( TurnRate < -1000.f ) 00610 LoopAnim( 'RotationG', Abs(-TurnRate)/10000.f, 0.2 ); 00611 else 00612 LoopAnim( WaitAnim, , 0.2 ); 00613 // } 00614 } 00615 } 00616 //RotationRate.Yaw=182*30; 00617 MyOldRotYaw = Rotation.Yaw; 00618 00619 } 00620 FUNCTION bool ChangeToBestWeapon() 00621 { 00622 local float rating; 00623 00624 // LOG( PawnName@"-> ChangeToBestWeapon at"@Level.TimeSeconds ); 00625 00626 if ( Inventory == None ) 00627 return false; 00628 00629 PendingWeapon = Inventory.RecommendWeapon(rating); 00630 if (PendingWeapon == Weapon ) 00631 PendingWeapon = None; 00632 if (PendingWeapon == None ) 00633 return false; 00634 00635 00636 if (Weapon == None ) 00637 ChangedWeapon(); 00638 else if ( Weapon != PendingWeapon ) 00639 Weapon.PutDown(); 00640 return true; 00641 } 00642 00643 EVENT Destroyed() 00644 { 00645 if (CineController!=none) 00646 CineController.Destroy(); 00647 if ( Shadow!=none ) 00648 Shadow.Destroy(); 00649 super.Destroyed(); 00650 } 00651 00652 EVENT PlayFootStep() 00653 { 00654 LOCAL material M; 00655 LOCAL actor A; 00656 LOCAL vector HitLoc, HitNorm; 00657 LOCAL int MemSoundStepCategory; 00658 00659 if ( (base == none) || (CineController==none) || !CineController.bMoving ) 00660 { 00661 /* if (base == none) 00662 Log( "&&& PlayFootStep"@Self@"BASE==none" ); 00663 if (CineController == none) 00664 Log( "&&& PlayFootStep"@Self@"CineController==none" ); 00665 if ( !CineController.bMoving ) 00666 LOG ( "&&& PlayFootStep"@Self@"!CineController.bMoving" );*/ 00667 return; 00668 } 00669 00670 M = LastCollidedMaterial; 00671 00672 if (M != none) 00673 { 00674 if ( Level.bReplaceHXScripts ) 00675 PlaySndPNJStep(M.PNJSndStep, vsize(velocity), SoundStepCategory, false ); 00676 else 00677 PlaySound(M.FootstepSound, int(vsize(velocity)), SoundStepCategory, 0 ); 00678 Instigator = self; 00679 00680 MakeNoise(1.0); 00681 } 00682 /* else 00683 LOG ( "&&& PlayFootStep"@Self@"M == none" );*/ 00684 00685 } 00686 00687 begin: 00688 do 00689 { 00690 sleep(0.03); 00691 if ( XIIIGameInfo(Level.Game) != none ) 00692 { 00693 mi = XIIIGameInfo(Level.Game).MapInfo; 00694 if ( mi!=none ) 00695 PC = mi.XIIIController; 00696 } 00697 } until (PC!=none); 00698 00699 while (CineController==none || !CineController.bInitialized) { sleep(0.03); } 00700 00701 InitializeInventory(); 00702 if (bArmed) 00703 { 00704 ChangeToBestWeapon(); 00705 AnimBlendToAlpha(FIRINGCHANNEL,0.0,0.0); 00706 } 00707 00708 InitCheckPoint(); 00709 00710 SetInvisibility(Invisible); 00711 00712 if ( XIIIGameInfo(Level.Game).CheckPointNumber<2 ) 00713 while ( ! mi.EndCartoonEffect ) 00714 sleep( 0.03 ); 00715 00716 sleep( 0.03 ); 00717 bInitialized = true; 00718 00719 MyOldRotYaw = Rotation.Yaw; 00720 00721 if ( XIIIGameInfo(Level.Game).CheckPointNumber<2 ) 00722 Play(CS_MapStart); 00723 else 00724 if ( cpn>=0 && CheckPoints[cpn].Label!="") 00725 { 00726 CurrentScript=0; 00727 CurrentTabActionIndex=CheckPoints[cpn].tabAction; 00728 CineController.bCineControlAnims=false; 00729 // LoopAnim(WaitAnim); 00730 CineController.CineGoto( CheckPoints[cpn].Label ); 00731 CineController.GotoState( 'PrePlayingSequence', 'Begin' ); 00732 } 00733 00734 if (!bPauseMovementIfBumped) 00735 stop; 00736 00737 00738 loop: 00739 if (CineController!=none && CineController.bMovePaused) 00740 { 00741 if (((BumpedActor==none) || !Collide(BumpedActor)))// || (Vector(Rotation) dot (BumpedActor.Location-Location)>0)) 00742 CineController.UnPauseMovement(); 00743 } 00744 sleep(0.20); 00745 goto('loop'); 00746 } 00747 00748 FUNCTION bool Collide(Actor p) 00749 { 00750 LOCAL vector v; 00751 LOCAL float f; 00752 00753 v=p.Location-Location; 00754 f=p.CollisionRadius+CollisionRadius+20; 00755 f*=f; 00756 00757 return ((v.X*v.X+v.Y*v.Y)<f); 00758 00759 } 00760 00761 FUNCTION PostBeginPlay() 00762 { 00763 LOCAL int i; 00764 LOCAL SMAttached casm; 00765 00766 Super.PostBeginPlay(); 00767 00768 // LOAD SPECIFIC ANIMATIONS 00769 for (i=0;i<SpecificAnimations.Length;++i) 00770 LinkSkelAnim ( SpecificAnimations[i] ); 00771 00772 LoopAnim(DefaultAnim); 00773 00774 if ( (CineControllerClass != None) && (CineController == None) ) 00775 CineController = spawn(CineControllerClass); 00776 if ( CineController != None ) 00777 CineController.Possess(self); 00778 00779 Controller = CineController; 00780 CineController.Pawn=Self; 00781 CineController.MyPawn=Self; 00782 CineController.PC=XIIIPlayerController(Level.ControllerList); 00783 00784 for (i=0;i<AttachedArtefacts.Length;++i) 00785 { 00786 if (AttachedArtefacts[i]!=none) 00787 { 00788 casm=Spawn(AttachedArtefacts[i]); 00789 casm.AttachTo(self); 00790 } 00791 } 00792 } 00793 00794 FUNCTION ConvertToSoldier() 00795 { 00796 LOCAL XIIIGameInfo xgi; 00797 00798 if ( (ControllerClass != None) && !bisdead && (Controller==none || Controller.IsA('CineController2')) ) 00799 { 00800 if ( bHidden ) 00801 { 00802 bHidden=false; 00803 RefreshDisplaying(); 00804 // LOG( self@"TIS SUR UN PERSO INVISIBLE : FORCING DISPLAY !!" ); 00805 } 00806 00807 SetBoneRotation('X HEAD',rot(0,0,0),,0); 00808 00809 Controller = spawn(ControllerClass); 00810 if (Controller!=none) 00811 { 00812 Controller.Possess(self); 00813 if ( CineController != none ) 00814 { 00815 CineController.Destroy(); 00816 } 00817 00818 xgi = XIIIGameInfo(Level.Game); 00819 xgi.BaseSoldierList.Insert( 0, 1 ); 00820 xgi.BaseSoldierList[0] = self; 00821 bPhysicsAnimUpdate=true; 00822 GotoState(''); 00823 } 00824 // else 00825 // Log(name@"can not be convert to a soldier"); 00826 } 00827 } 00828 00829 FUNCTION OpenDoor(XIIIPorte door) 00830 { 00831 if (door!=none) 00832 { 00833 if (!door.IsInState('PlayerTriggerToggle' )) 00834 { 00835 door.GotoState( 'PlayerTriggerToggle' ); 00836 } 00837 if (!door.bOpened) 00838 { 00839 door.PlayerTrigger(self,self); 00840 } 00841 } 00842 } 00843 00844 FUNCTION CloseDoor(XIIIPorte door) 00845 { 00846 if ( door!=none && !door.bClosed ) 00847 door.PlayerTrigger(self,self); 00848 } 00849 00850 static FUNCTION UnlockDoor(XIIIPorte door) 00851 { 00852 if (door!=none && door.IsInState('Locked' )) 00853 door.GotoState( 'PlayerTriggerToggle' ); 00854 } 00855 00856 static FUNCTION LockDoor(XIIIPorte door) 00857 { 00858 if (door!=none && door.IsInState('PlayerTriggerToggle' )) 00859 door.GotoState( 'Locked' ); 00860 } 00861 00862 //################################################################# 00863 FUNCTION PrintC(string str) 00864 { 00865 LOCAL int i; 00866 LOCAL string buff; 00867 00868 i=InStr( str, "#" ); 00869 00870 if (i!=-1) 00871 { 00872 if (i!=0) 00873 { 00874 buff = Left(str, i); 00875 MyCanvas.DrawText(buff, false); 00876 MyCanvas.CurY -= MyYL; 00877 } 00878 switch(Mid(str, i+1,1)) 00879 { 00880 Case "W": MyCanvas.SetDrawColor(255,255,255); break; 00881 Case "Y": MyCanvas.SetDrawColor(255,255,000); break; 00882 Case "R": MyCanvas.SetDrawColor(255,000,000); break; 00883 Case "M": MyCanvas.SetDrawColor(255,000,255); break; 00884 Case "C": MyCanvas.SetDrawColor(000,255,255); break; 00885 Case "N": MyYPos += MyYL; MyCanvas.SetPos(4,MyYPos); break; 00886 } 00887 PrintC(Mid(str, i+2)); 00888 } 00889 else 00890 { 00891 MyCanvas.DrawText(str); 00892 MyYPos += MyYL; 00893 MyCanvas.SetPos(4,MyYPos); 00894 } 00895 } 00896 //################################################################# 00897 00898 FUNCTION ReadyWeapon( int WeaponIndex ) 00899 { 00900 LOCAL class<XIIIWeapon> WeaponClass; 00901 LOCAL Inventory inv; 00902 00903 if ( WeaponIndex >= 0 && WeaponIndex < 8 ) 00904 { 00905 WeaponClass = class<XIIIWeapon>( InitialInventory[ WeaponIndex ].Inventory ); 00906 00907 if ( WeaponClass!=none ) 00908 { 00909 inv = FindInventoryType( WeaponClass ); 00910 00911 if ( inv.IsA( 'XIIIWeapon' ) ) 00912 { 00913 PendingWeapon = XIIIWeapon( inv ); 00914 00915 if ( Weapon!=none ) 00916 { 00917 if ( Weapon != PendingWeapon ) 00918 Weapon.PutDown( ); 00919 } 00920 else 00921 { 00922 ChangedWeapon( ); 00923 } 00924 } 00925 } 00926 } 00927 else 00928 { 00929 PendingWeapon = XIIIWeapon( FindInventoryType( class'fists' ) ); 00930 if ( Weapon != PendingWeapon ) 00931 { 00932 Weapon.PutDown( ); 00933 } 00934 } 00935 AnimBlendToAlpha( FIRINGCHANNEL, 0.0, 0.0 ); 00936 } 00937 00938 FUNCTION Shoot( ) 00939 { 00940 if ( Weapon!=none ) 00941 { 00942 Controller.bFire=1; 00943 Weapon.Fire(0); 00944 } 00945 } 00946 00947 FUNCTION AltShoot( ) 00948 { 00949 if ( Weapon!=none ) 00950 { 00951 Controller.bAltFire=1; 00952 Weapon.AltFire(0); 00953 } 00954 } 00955 00956 FUNCTION StopShoot( ) 00957 { 00958 if ( Weapon!=none ) 00959 { 00960 Controller.bAltFire=0; 00961 Controller.bFire=0; 00962 AnimBlendToAlpha( FIRINGCHANNEL, 0.0, 0.5 ); 00963 } 00964 } 00965 00966 FUNCTION Inventory GiveObject(int ItemIndex, Pawn P) 00967 { 00968 LOCAL Inventory NewItem; 00969 LOCAL class<Inventory> ItemClass; 00970 LOCAL class<Ammunition> AmmunitionClass; 00971 LOCAL Inventory inv; 00972 00973 ItemClass=InitialInventory[ItemIndex].Inventory; 00974 00975 // log ( "===========================================================" ); 00976 // log ( "ItemClass :"@ItemClass ); 00977 00978 if (ItemClass!=none) 00979 { 00980 inv=FindInventoryType(ItemClass); 00981 if (inv!=none) 00982 { 00983 if( P.FindInventoryType(ItemClass)==None ) 00984 { 00985 /* if( inv.IsA( 'Weapon' ) ) 00986 { 00987 NewItem = Spawn(ItemClass,,,P.Location); 00988 Weapon(NewItem).GiveAmmo(P); 00989 // Weapon(NewItem).AmmoType.AmmoAmount = Weapon(Inv).AmmoType.AmmoAmount; 00990 NewItem.GiveTo(P); 00991 // log ( "inv :"@inv@Weapon(inv).AmmoType@Weapon(inv).AmmoType.AmmoAmount ); 00992 // log ( "NewItem :"@NewItem@Weapon(NewItem).AmmoType@Weapon(NewItem).AmmoType.AmmoAmount ); 00993 // Weapon(NewItem).AmmoType = Weapon(inv).AmmoType; 00994 } 00995 else 00996 {*/ 00997 NewItem = Spawn(ItemClass,,,P.Location); 00998 00999 if( NewItem != None ) 01000 { 01001 NewItem.GiveTo(P); 01002 /* ELR NOT OK 01003 if( inv.IsA( 'Weapon' ) ) 01004 { 01005 NewItem = Spawn(ItemClass,,,P.Location); 01006 Weapon(NewItem).GiveAmmo(P); 01007 if ( Weapon(NewItem).AmmoType!=none && Weapon(Inv).AmmoType!=none ) 01008 Weapon(NewItem).AmmoType.AmmoAmount = Weapon(Inv).AmmoType.AmmoAmount; 01009 } 01010 ELR END*/ 01011 if ( NewItem.IsA('Weapon') && (Weapon(NewItem).AmmoType!=none) && (Weapon(Inv).AmmoType!=none) ) 01012 Weapon(NewItem).AmmoType.AmmoAmount = Weapon(Inv).AmmoType.AmmoAmount; 01013 } 01014 // } 01015 } 01016 else 01017 { 01018 AmmunitionClass = Class<Ammunition>(ItemClass); 01019 01020 if ( AmmunitionClass != none ) 01021 { 01022 NewItem = P.FindInventoryType(ItemClass); 01023 if (NewItem != None) 01024 Ammunition(NewItem).AmmoAmount += AmmunitionClass.default.AmmoAmount; 01025 } 01026 } 01027 inv.Destroy(); // Destroy my item 01028 } 01029 // else 01030 // { 01031 // LOG ("Sorry, but I ("$name$") don't have any object of kind '"$ItemClass$"' to give :-/"); 01032 // } 01033 } 01034 // log ( "===========================================================" ); 01035 PC.ReceiveLocalizedMessage( NewItem.PickupClass.default.MessageClass, 0, None, None, NewItem.PickupClass ); 01036 return NewItem; 01037 } 01038 01039 FUNCTION Inventory DropObject(int ItemIndex, Pawn P) 01040 { 01041 LOCAL Inventory NewItem; 01042 LOCAL class<Inventory> ItemClass; 01043 LOCAL Inventory inv; 01044 01045 ItemClass=InitialInventory[ItemIndex].Inventory; 01046 01047 if (ItemClass!=none) 01048 { 01049 inv=FindInventoryType(ItemClass); 01050 if (inv!=none) 01051 { 01052 inv.DropFrom( Location + 20 * Vector( Rotation ) ); 01053 } 01054 // else 01055 // { 01056 // LOG ("Sorry, but I ("$name$") don't have any object of kind '"$ItemClass$"' to drop :-/"); 01057 // } 01058 } 01059 PC.ReceiveLocalizedMessage( NewItem.PickupClass.default.MessageClass, 0, None, None, NewItem.PickupClass ); 01060 return NewItem; 01061 } 01062 01063 01064 01065 defaultproperties 01066 { 01067 DefaultAnim="WaitNeutre" 01068 WalkAnim="Walk" 01069 RunAnim="Run" 01070 WaitAnim="WaitNeutre" 01071 TweenTime=0.500000 01072 WalkAnimVelocity=140.000000 01073 WalkRunLimitVelocity=280.000000 01074 RunAnimVelocity=472.000000 01075 Reaction(0)=(eCS_Stimulus=CS_MapStart,TabActionIndex=1,bUneSeuleFois=True) 01076 InitialShootDispersion=100.000000 01077 InitialSpeed=0.320000 01078 InitialRotationSpeed=180.000000 01079 InitialAccelerationFactor=1.000000 01080 vMoveconstraint=(X=1.000000,Y=1.000000) 01081 CineControllerClass=Class'XIDCine.CineController2' 01082 CurrentScript=-1 01083 ImposedEndMovePosition=True 01084 bCanStrafe=True 01085 bDontPossess=True 01086 bIsPafable=False 01087 bCanBeGrabbed=False 01088 PeripheralVision=0.700000 01089 GroundSpeed=600.000000 01090 bPhysicsAnimUpdate=False 01091 Physics=PHYS_Walking 01092 RotationRate=(Pitch=0,Yaw=32768,Roll=0) 01093 }

End Source Code