## XIDCine
Class CineController2

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

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Controller
             |
             +--XIDCine.CineController2

Direct Known Subclasses:MangousteSSH1Controller

class CineController2
extends Engine.Controller

    //-----------------------------------------------------------
    // CineController2
    // Created by iKi
    // Last Modification by iKi
    //-----------------------------------------------------------

Variables
`float` | `ActualPlayerRotationSpeed`
`Plane,` | `AdjustAiming`
`name` | `CurrentAnim`
`float` | `EventDatesTab[MAX_EVENT]`
`Pawn` | `EventInstigatorsTab[MAX_EVENT]`
`NAME` | `EventNamesTab[MAX_EVENT]`
`Actor` | `EventOthersTab[MAX_EVENT]`
`FPCTarget,` | `FPCLocation`
`WaitTimeEnd,` | `JumpHight`
`Actor` | `JumpTarget`
`string` | `MoveSequence`
`int` | `WarnMemory`
`int` | `nOnJump[ON_Max]`
`nReturnIndex[16],` | `nReturnIndexIndex`
`rotator` | `rWantedRotation`

States
STA_Jumping_Down, STA_Jumping_Up, STA_Jumping_Impetus, STA_Falling, Idle, PlayingSequence, PrePlayingSequence, STA_init

Function Summary
`ROTATOR` | `AdjustAim(Ammunition FiredAmmunition, vector Start, int aimerror)`
`bool` | `CharIsNum(out string)`
`void` | `CineEvent(string Cine2Label)`
`void` | `CineGoto(out string)`
`void` | `CineMoveTo(Actor TmpTarget, optional bool)`
`void` | `CinePlayMusic(int MusicIndex)`
`void` | `CinePlaySound(int SoundIndex, string ActorName)`
`void` | `CinePlayVoice(int OnoIndex, string ActorName)`
`void` | `DamageAttitudeTo(Pawn Other, float Damage)`
`void` | `DevAni(name ani)`
`void` | `ErrorScript(string s, optional bool)`
`Actor` | `FindAnActor(string strActorName)`
    /********************/
`int` | `FindLabel(string Label)`
`string` | `GetFirstWord(out string)`
`void` | `Initialize( )`
`void` | `LoopAni(name ani, optional coerce, optional coerce)`
`void` | `OnGoto(out int)`
`void` | `PauseMove( )`
`void` | `PauseMovement()`
`void` | `PlayAni(name ani, optional coerce, optional coerce, optional int)`
`void` | `RestoreEvents( )`
`void` | `ResumeMove( )`
`ROTATOR` | `RotDiff(ROTATOR r1, ROTATOR r2, optional int)`
`void` | `SetRotationSpeed(float rspeed)`
`void` | `SetWantedSpeed(float wspeed)`
`void` | `StartDialogue(name DialTag, float firstline)`
    //##########################################################################
`void` | `StartSequence( )`
`void` | `StopDialogue(name DialTag)`
`void` | `StopMove( )`
`void` | `TeleportInFrontOf(Actor act, int distance)`
`void` | `TeleportTo(Actor act)`
`void` | `UnpauseMovement()`
`void` | `WarnActor(Actor act)`

State STA_Jumping_Down Function Summary
`Actor` | `SearchNextWaypoint()`
`bool` | `NextMove()`

State STA_Jumping_Up Function Summary

State STA_Jumping_Impetus Function Summary

State STA_Falling Function Summary
`void` | `GoJump(Actor JTarget, float deltaZ)`
    /* ############################################################################################################### */

State Idle Function Summary

State PlayingSequence Function Summary
`void` | `GoFall(Actor FallTarget, float deltaZ, float Gamma)`
`void` | `InitJump(Actor FallTarget, float deltaZ, float Gamma)`
`void` | `Interpret(string Argument)`
`void` | `RecordEvent(Name EventName, Actor Other, Pawn EventInstigator)`

State PrePlayingSequence Function Summary

State STA_init Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	// CineController2
    00003	// Created by iKi
    00004	// Last Modification by iKi
    00005	//-----------------------------------------------------------
    00006	class CineController2 extends Controller
    00007		native;
    00008
    00009	// On event goto xx && on warn goto xx
    00010	VAR int		nReturnIndex[16], nReturnIndexIndex;
    00011	VAR	bool	bMoving, bMovePaused, bAnimOnce, bAnimDev, bSubAnim, bInitialized, bCineControlAnims,
    00012				bDying, bConstrainedToGround, bFrozenPlayer;
    00013
    00014	VAR TRANSIENT	Actor					FPCTarget, FPCLocation;
    00015	VAR	TRANSIENT	Cine2					MyPawn;
    00016	VAR	TRANSIENT	string					MemoError;
    00017	VAR	TRANSIENT	XIIIPlayerController	PC;
    00018	VAR	TRANSIENT	XIIIPawn				Player;
    00019	VAR TRANSIENT	name					CurrentAnim;
    00020	VAR	TRANSIENT	int						LinesCount, Counter[4], ScriptedActionIndex, flagsPaused;
    00021	VAR				float					JumpHeight;
    00022
    00023
    00024	CONST WT_PlayerProximity= 0x00000001;
    00025	CONST WT_Event			= 0x00000002;
    00026	CONST WT_Warn			= 0x00000004;
    00027	CONST WT_DialEnd		= 0x00000008;
    00028	CONST WT_SequenceEnd	= 0x00000010;
    00029	CONST WT_SeePlayer		= 0x00000020;
    00030	CONST WT_SeenByPlayer	= 0x00000040;
    00031	CONST WT_Time			= 0x00000080;
    00032	CONST WT_AnimEnd		= 0x00000100;
    00033	CONST WT_NotSeenByPlayer= 0x00000200;
    00034	CONST WT_PlayerAway		= 0x00000400;
    00035	CONST WT_SeeCadaver		= 0x00000800;
    00036
    00037	CONST WT_Mask			= 0x00000FFF;
    00038
    00039	CONST ON_PlayerProximity= 0;
    00040	CONST ON_Event			= 1;
    00041	CONST ON_Warning		= 2;
    00042	CONST ON_DialEnd		= 3;
    00043	CONST ON_SequenceEnd	= 4;
    00044	CONST ON_SeePlayer		= 5;
    00045	CONST ON_SeenByPlayer	= 6;
    00046	CONST ON_Time			= 7;
    00047	CONST ON_AnimEnd		= 8;
    00048	CONST ON_NotSeenByPlayer= 9;
    00049	CONST ON_PlayerAway		= 10;
    00050	CONST ON_SeeCadaver		= 11;
    00051
    00052	CONST ON_Max			= 12;
    00053
    00054	VAR int		nOnJump[ON_Max];
    00055
    00056	// Move Sequence variables
    00057	VAR TRANSIENT	string	MoveSequence;
    00058	VAR	TRANSIENT	Actor	Target, LockedActor, NextTarget;
    00059	VAR TRANSIENT	vector	Plane, AdjustAiming;
    00060	VAR	TRANSIENT	float	wantedspeed, rotationspeed, AccelerationFactor, DetectionDistance, ShootDispersion, MyPawnGroundSpeed;
    00061
    00062	VAR TRANSIENT	float	TimeStamp, WaitTimeEnd, JumpHight;
    00063	VAR	TRANSIENT	DialogueManager dm;
    00064	VAR TRANSIENT	rotator rWantedRotation;
    00065
    00066	VAR TRANSIENT	Actor JumpTarget;
    00067
    00068	CONST MAX_EVENT=8;
    00069	CONST MAX_EVENTHISTORYTIME=10;
    00070	VAR TRANSIENT	NAME	EventNamesTab[MAX_EVENT];
    00071	VAR TRANSIENT	ACTOR	EventOthersTab[MAX_EVENT];
    00072	VAR TRANSIENT	PAWN	EventInstigatorsTab[MAX_EVENT];
    00073	VAR TRANSIENT	float	EventDatesTab[MAX_EVENT];
    00074	VAR TRANSIENT	int		WarnMemory;
    00075
    00076	CONST PlayerLinearSpeed=600;
    00077	CONST PlayerRotationSpeed=180;
    00078	CONST RotationAcceleration=145;
    00079	VAR TRANSIENT	float	ActualPlayerRotationSpeed;
    00080
    00081	FUNCTION Initialize( )
    00082	{
    00083		LOCAL int i;
    00084
    00085	//	LOG("CineController2 INITIALIZE :"@self);
    00086		MyPawn = Cine2( Pawn );
    00087		MyPawnGroundSpeed = Pawn.GroundSpeed;
    00088		AccelerationFactor = MyPawn.InitialAccelerationFactor;
    00089		SetWantedSpeed( MyPawn.InitialSpeed );
    00090		SetRotationSpeed( MyPawn.InitialRotationSpeed );
    00091		DetectionDistance = MyPawn.InitialDetectionDistance;
    00092		ShootDispersion = MyPawn.InitialShootDispersion;
    00093		Pawn.RotationRate.Yaw = rotationspeed * 182;
    00094		bConstrainedToGround = ( MyPawn.vMoveconstraint.Z == 0 );
    00095		rWantedRotation = Pawn.Rotation;
    00096
    00097		bInitialized=true;
    00098	}
    00099
    00100	event SeeDeadPawn(pawn other)
    00101	{
    00102		MyPawn.SeeCadaver();
    00103	}
    00104
    00105	FUNCTION ROTATOR AdjustAim(Ammunition FiredAmmunition, vector Start, int aimerror)
    00106	{
    00107		LOCAL Rotator r;
    00108
    00109		if ( LockedActor != none )
    00110			r = ROTATOR( LockedActor.Location + AdjustAiming + ShootDispersion * VRand( ) - Start );
    00111		else
    00112			if ( Focus != none )
    00113				r = ROTATOR( Focus.Location + AdjustAiming + ShootDispersion * VRand( ) - Start );
    00114			else
    00115				r = ROTATOR( vector( rotation ) + AdjustAiming + ShootDispersion * VRand( ) );
    00116
    00117		return r;
    00118	}
    00119
    00120	//##########################################################################################################################
    00121
    00122	/***********************/
    00123	/**                   **/
    00124	/** Steering behavior **/
    00125	/**                   **/
    00126	/***********************/
    00127
    00128	native FUNCTION Steering(
    00129					vector	vTargetLocation,	// wanted location
    00130					float	dt,					// time since previous frame
    00131					float	fDetectionDistance,	// detection distance
    00132		optional	bool	bDisableAvoidance,	//
    00133		optional	bool	bFinalLocation		// pawn must slow down to reach this point
    00134	);
    00135
    00136	//native FUNCTION bool IsTargetReached(vector TargetPos,float fDectectionDistance, optional vector BorderPlaneNormal);
    00137
    00138	// Event called to avoid obstacle
    00139	event AvoidObstacle( vector TargetLocation, out vector wanted_acceleration )
    00140	{
    00141	}
    00142
    00143	//##########################################################################################################################
    00144
    00145	/********************/
    00146	/**                **/
    00147	/** Tool Functions **/
    00148	/**                **/
    00149	/********************/
    00150
    00151	native static final FUNCTION Actor FindAnActor(string strActorName);
    00152	native static final FUNCTION string GetFirstWord(out string s);
    00153	native static final FUNCTION bool CharIsNum(out string s);
    00154
    00155
    00156	FUNCTION DevAni(coerce name ani)
    00157	{
    00158		AnimBlendToAlpha( 1, 0.0, 0.5 );	// Stop any animation blending smoothly
    00159		bAnimOnce = false; // ??
    00160		bAnimDev = true;
    00161		Pawn.PlayAnim( ani, , MyPawn.TweenTime );
    00162		bCineControlAnims = true;
    00163	}
    00164
    00165	FUNCTION LoopAni(coerce name ani,optional coerce float spd,optional coerce float ttime)
    00166	{
    00167	//	Log (self@"LoopAni"@ani);
    00168		if (spd==0) spd=1;
    00169		AnimBlendToAlpha( 1, 0.0, 0.5 );	// Stop any animation blending smoothly
    00170		bAnimOnce = false;
    00171		bAnimDev = false;
    00172		Pawn.LoopAnim( ani, spd , ttime );
    00173		bCineControlAnims = true;
    00174		CurrentAnim=ani;
    00175	}
    00176
    00177	FUNCTION PlayAni(coerce name ani,optional coerce float spd,optional coerce float ttime,optional int channel)
    00178	{
    00179	//	Log (self@"PlayAni"@ani);
    00180		if (spd==0) spd=1;
    00181		if (ttime==0) ttime=MyPawn.TweenTime;
    00182		if ( ani!='' )
    00183		{
    00184			AnimBlendToAlpha(1, 0.0, 0.5);	// Stop any animation blending smoothly
    00185			bAnimOnce=true;
    00186			CurrentAnim=ani;
    00187			bAnimDev = false;
    00188			Pawn.PlayAnim(ani, spd ,ttime,channel);
    00189			bCineControlAnims=true;
    00190		}
    00191		else
    00192			if ( (flagsPaused & WT_AnimEnd)!=0 ) flagsPaused = 0;
    00193
    00194	}
    00195
    00196	FUNCTION SetWantedSpeed(float wspeed)
    00197	{
    00198		wantedspeed=wspeed;
    00199		Pawn.GroundSpeed=MyPawnGroundSpeed * wantedspeed;	// MaximumSpeed
    00200		Pawn.AirSpeed=Pawn.GroundSpeed;
    00201	}
    00202
    00203	FUNCTION SetRotationSpeed(float rspeed)
    00204	{
    00205		RotationSpeed=rspeed;
    00206	}
    00207
    00208	FUNCTION ErrorScript(string s,optional bool bShowDebug)
    00209	{
    00210		LOCAL int iTemp;
    00211
    00212		if (bShowDebug)
    00213			MemoError=MemoError$"#R";
    00214		MemoError=MemoError$s$"#N";
    00215
    00216		if (LinesCount==10)
    00217		{
    00218			iTemp=InStr(MemoError,"#N");
    00219			MemoError=Mid(MemoError,iTemp+2);
    00220		}
    00221		else
    00222			LinesCount+=1;
    00223		if (bShowDebug && (XIIIGameInfo(Level.Game).PlateForme==PF_PC))
    00224		{
    00225			PC.myHud.bShowDebugInfo=true;
    00226			XIIIBaseHud(PC.myHud).ShowDebugActor=MyPawn;
    00227
} 00228 } 00229 00230 FUNCTION WarnActor(Actor act) 00231 { 00232 LOCAL cine2 c2; 00233 c2=Cine2(act); 00234 if (c2!=none) 00235 c2.CineController.CineWarn(Pawn); 00236 } 00237 00238 FUNCTION CinePlayMusic(int MusicIndex) 00239 { 00240 LOCAL sound snd; 00241 00242 if ( MusicIndex < MyPawn.Musics.Length ) 00243 snd=MyPawn.Musics[MusicIndex]; 00244 if (snd==none) 00245 ErrorScript("Can't found music at index #C"$MusicIndex,true); 00246 else 00247 PlayMusic( snd ); 00248 } 00249 00250 FUNCTION CinePlaySound(coerce int SoundIndex,coerce string ActorName) 00251 { 00252 LOCAL Actor act; 00253 LOCAL sound snd; 00254 if ( SoundIndex < MyPawn.Sounds.Length ) 00255 snd=MyPawn.Sounds[SoundIndex]; 00256 if (snd==none) 00257 ErrorScript("Can't found sound at index #C"$SoundIndex,true); 00258 else 00259 { 00260 if (ActorName=="") 00261 act=MyPawn; 00262 else 00263 act=FindAnActor(ActorName); 00264 act.PlaySound( snd ); 00265 } 00266 } 00267 00268 FUNCTION CinePlayVoice(coerce int OnoIndex,coerce string ActorName) 00269 { 00270 LOCAL Actor act; 00271 LOCAL sound snd; 00272 00273 if ( OnoIndex < MyPawn.Onomatops.Length ) 00274 snd=MyPawn.Onomatops[OnoIndex]; 00275 if (snd==none) 00276 ErrorScript("Can't found onomatop at index #C"$OnoIndex,true); 00277 else 00278 { 00279 if (ActorName=="") 00280 act=MyPawn; 00281 else 00282 act=FindAnActor(ActorName); 00283 act.PlayVoice( snd, MyPawn.CodeMesh, MyPawn.numerotimbre ); 00284 } 00285 } 00286 00287 FUNCTION CineMoveTo(Actor TmpTarget,optional bool bDontUseMovingAutomaticMovingAnim)//name TmpAnim) 00288 { 00289 00290 bCineControlAnims=bDontUseMovingAutomaticMovingAnim; 00291 00292 Target=TmpTarget; 00293 00294 if (Target!=none) 00295 { 00296 if ( Pawn.Physics == PHYS_None ) 00297 Pawn.SetPhysics( PHYS_Walking ); // Walk physics is default 00298 Plane=Normal(Target.Location-Pawn.Location); 00299 bMoving=true; 00300 } 00301 } 00302 00303 FUNCTION PauseMovement() 00304 { 00305 LOCAL name Seq0; 00306 LOCAL float Frame0, Rate0; 00307 00308 if (bMoving && !bMovePaused) 00309 { 00310 Pawn.GetAnimParams( 0, Seq0, Frame0, Rate0 ); 00311 CurrentAnim = Seq0; 00312 Pawn.Acceleration=vect(0,0,0); 00313 Pawn.Velocity=vect(0,0,0); 00314 bMovePaused=true; 00315 Pawn.RotationRate.Yaw = 0; 00316 // MyPawn.LoopAnim( MyPawn.WaitAnim, , 0.5 ); 00317 if ( !bCineControlAnims ) 00318 MyPawn.PlayMoving(); 00319 } 00320 } 00321 00322 FUNCTION UnpauseMovement() 00323 { 00324 if (bMoving && bMovePaused) 00325 { 00326 bMovePaused=false; 00327 MyPawn.LoopAnim( CurrentAnim, , MyPawn.TweenTime ); 00328 Pawn.RotationRate.Yaw = rotationspeed * 182; 00329 } 00330 } 00331 00332 FUNCTION TeleportTo(Actor act) 00333 { 00334 if (act!=none) 00335 { 00336 StopMove(); 00337 MyPawn.SetLocation(act.Location); 00338 MyPawn.SetRotation(act.Rotation); 00339 rWantedRotation=act.Rotation; 00340 FocalPoint=act.Location+51200*vector(act.Rotation); 00341 Focus=none; 00342 LockedActor=none; 00343 00344 } 00345 } 00346 00347 FUNCTION TeleportInFrontOf(Actor act,int distance) 00348 { 00349 if (act!=none) 00350 { 00351 StopMove(); 00352 MyPawn.SetLocation(act.Location+distance*vector(act.Rotation)+vect(0,0,30)); 00353 MyPawn.SetRotation(rotator(act.Location-MyPawn.Location)); 00354 MyPawn.SetPhysics( PHYS_Walking ); 00355 rWantedRotation=MyPawn.Rotation; 00356 FocalPoint=MyPawn.Location+51200*vector(MyPawn.Rotation); 00357 Focus=none; 00358 LockedActor=none; 00359 00360 } 00361 } 00362 00363 //########################################################################################################################## 00364 00365 /*******************/ 00366 /** **/ 00367 /** Initial State **/ 00368 /** **/ 00369 /*******************/ 00370 STATE STA_init 00371 { 00372 begin: 00373 do 00374 { 00375 if (XIIIGameInfo(Level.Game).MapInfo!=none) 00376 { 00377 PC=XIIIGameInfo(Level.Game).MapInfo.XIIIController; 00378 if (PC!=none) 00379 break; 00380 } 00381 sleep(0.01); 00382 } until (PC!=none); 00383 Player = XIIIPawn( PC.Pawn ); 00384 Initialize(); 00385 stop; 00386 } 00387 00388 EVENT EndOfDial(actor Other) 00389 { 00390 } 00391 00392 // Replicate some events to my pawn 00393 EVENT SeePlayer( Pawn Seen ) 00394 { 00395 MyPawn.SeeXIII( ); 00396 } 00397 00398 EVENT HearNoise( float Loudness, Actor NoiseMaker ) 00399 { 00400 LOCAL bool b; 00401 LOCAL Actor a; 00402 00403 a=NoiseMaker; 00404 00405 while ( a!=none ) 00406 { 00407 if ( a.IsA('XIIIPlayerPawn') ) 00408 { 00409 b=true; 00410 break; 00411 } 00412 a = a.Owner; 00413 } 00414 if( b )//&& Pawn(NoiseMaker).IsPlayerPawn() ) 00415 MyPawn.HearSound( ); 00416 // else 00417 // LOG(self@"IGNORE NOISE"@NoiseMaker); 00418 } 00419 00420 EVENT CineWarn(actor Other) {} 00421 00422 //########################################################################## 00423 00424 FUNCTION StartDialogue(coerce name DialTag,coerce float firstline) 00425 { 00426 if ( dm!=none && dm.OriginalTag==DialTag ) 00427 dm.ForceLine( firstline ); 00428 else 00429 { 00430 foreach DynamicActors( class'DialogueManager', dm ) 00431 { 00432 if ( DialTag == dm.OriginalTag ) 00433 { 00434 // LOG ( self@MyPawn.PawnName@"STARTING DIALOGUE"@DialTag@dm@"AT LINE"@firstline ); 00435 dm.StartDialogue(firstline); 00436 return; // First one is the good one :) 00437 } 00438 } 00439 } 00440 } 00441 00442 FUNCTION StopDialogue(coerce name DialTag) 00443 { 00444 LOCAL DialogueManager dial; 00445 00446 if (DialTag=='') 00447 { 00448 if (dm!=none) 00449 dm.Destroy(); 00450 } 00451 else 00452 { 00453 foreach DynamicActors(class'DialogueManager',dial,DialTag) 00454 { 00455 dial.Destroy(); 00456 } 00457 } 00458 } 00459 00460 //########################################################################## 00461 // My events 00462 // Event called when current target is reached 00463 EVENT EndOfMove( ) 00464 { 00465 if ( ! NextMove( ) ) 00466 { 00467 bMoving=false; 00468 Pawn.Acceleration = vect( 0, 0, 0 ); 00469 Pawn.Velocity = vect( 0, 0, 0 ); 00470 Focus = LockedActor; 00471 // log ( self@"EndOfMove"@Target); 00472 if ( Target != none ) 00473 { 00474 LockedActor=none; 00475 Focus = none; 00476 FocalPoint = Pawn.Location + Vector ( Target.Rotation ) * 51200; 00477 rWantedRotation = Target.Rotation; 00478 bCineControlAnims=true; 00479 00480 } 00481 else 00482 { 00483 rWantedRotation = Pawn.Rotation; 00484 } 00485 if (!bCineControlAnims) 00486 MyPawn.PlayMoving( ); 00487 00488 EndOfSeq( ); 00489 } 00490 } 00491 00492 EVENT EndOfSeq( ) 00493 { 00494 } 00495 00496 EVENT MayFall( ) 00497 { 00498 } 00499 00500 FUNCTION StopMove( ) 00501 { 00502 FocalPoint = Pawn.Location + 51200 * vector( Pawn.Rotation ); 00503 Focus = none; 00504 Pawn.Velocity = vect( 0, 0, 0 ); 00505 Pawn.Acceleration = vect( 0, 0, 0 ); 00506 // bMoving = false; 00507 if (!bCineControlAnims) 00508 MyPawn.PlayMoving( ); 00509 MoveSequence = ""; 00510 bMoving=false; 00511 // EndOfMove( ); 00512 } 00513 00514 FUNCTION PauseMove( ) 00515 { 00516 FocalPoint = Pawn.Location + 51200 * vector( Pawn.Rotation ); 00517 Focus = none; 00518 Pawn.Velocity = vect( 0, 0, 0 ); 00519 Pawn.Acceleration = vect( 0, 0, 0 ); 00520 // bMoving = false; 00521 if (!bCineControlAnims) 00522 MyPawn.PlayMoving( ); 00523 // MoveSequence = ""; 00524 bMoving=false; 00525 // EndOfMove( ); 00526 } 00527 00528 FUNCTION ResumeMove( ) 00529 { 00530 bMoving = true; 00531 } 00532 00533 FUNCTION StartSequence( ) 00534 { 00535 LOCAL int line,i; 00536 00537 for (i=0;i<ON_Max;i++) 00538 nOnJump[i]=-1; 00539 00540 flagsPaused = 0; 00541 00542 ScriptedActionIndex = 0; 00543 GotoState( 'PrePlayingSequence', 'Begin' ); 00544 } 00545 00546 FUNCTION int FindLabel(string Label) 00547 { 00548 LOCAL string action; 00549 LOCAL int i; 00550 00551 for (i=0;i<MyPawn.GetTabActionLength();i++) 00552 { 00553 MyPawn.GetAction(i,action); 00554 if (GetFirstWord(action)=="'") 00555 { 00556 if (GetFirstWord(action)~=Label) 00557 return i; 00558 } 00559 } 00560 return -1; 00561 } 00562 00563 STATE PrePlayingSequence 00564 { 00565 begin: 00566 while (!bScriptInitialized) 00567 sleep(0.016); 00568 GotoState('PlayingSequence'); 00569 } 00570 00571 FUNCTION CineGoto( out string label ) 00572 { 00573 LOCAL int line,i; 00574 00575 line = FindLabel( label ); 00576 // DebugLog( "CineGoto"@label@"=>"@line ); 00577 if (line!=-1) 00578 { 00579 ScriptedActionIndex=line; 00580 for (i=0;i<ON_Max;i++) 00581 nOnJump[i]=-1; 00582 flagsPaused=0; 00583 } 00584 } 00585 00586 FUNCTION CineEvent(string Cine2Label) 00587 { 00588 LOCAL CineController2 cc; 00589 00590 if ( !( Cine2Label~="none" ) ) 00591 { 00592 foreach DynamicActors(class'CineController2', cc) 00593 { 00594 if (cc!=self) 00595 cc.CineGoto( Cine2Label ); 00596 } 00597 } 00598 } 00599 00600 singular function DamageAttitudeTo(pawn Other, float Damage) 00601 { 00602 //son 00603 MyPawn.PlaySndPNJOno(PNJOno'Onomatopees.hPNJHurt',MyPawn.CodeMesh,MyPawn.NumeroTimbre); 00604 // pawn.PlayVoice(Sound'XIIISound.PNJ__Onos_Pafs.Onos_Pafs__hPNJPafs',mypawn.CodeMesh,mypawn.numerotimbre); 00605 } 00606 00607 00608 FUNCTION OnGoto(out int labelindex) 00609 { 00610 // LOG (self@"ON GOTO line"@labelindex ); 00611 // Stacking old index 00612 nReturnIndex[nReturnIndexIndex]=ScriptedActionIndex-1; 00613 nReturnIndexIndex++; 00614 ScriptedActionIndex=labelindex; 00615 labelindex=-1; 00616 flagsPaused=0; 00617 } 00618 00619 FUNCTION ROTATOR RotDiff( ROTATOR r1, ROTATOR r2, optional int fMax ) 00620 { 00621 r1 -= r2; 00622 if ( fMax == 0 ) 00623 { 00624 r1.Yaw = ( ( r1.Yaw + 32768 ) & 65535 ) - 32768; 00625 r1.Roll = ( ( r1.Roll + 32768 ) & 65535 ) - 32768; 00626 r1.Pitch = ( ( r1.Pitch + 32768 ) & 65535 ) - 32768; 00627 } 00628 else 00629 { 00630 r1.Yaw = Clamp( ( ( r1.Yaw + 32768 ) & 65535 ) - 32768, -fMax, fMax ); 00631 r1.Roll = Clamp( ( ( r1.Roll + 32768 ) & 65535 ) - 32768, -fMax, fMax ); 00632 r1.Pitch = Clamp( ( ( r1.Pitch + 32768 ) & 65535 ) - 32768, -fMax, fMax ); 00633 } 00634 00635 return r1; 00636 } 00637 00638 FUNCTION RestoreEvents( ) 00639 { 00640 LOCAL int i, n; 00641 LOCAL CineController2 C; 00642 00643 ForEach DynamicActors( class 'CineController2', C ) 00644 { 00645 if ( C==self) 00646 continue; 00647 00648 for ( i=0; i<MAX_EVENT; i++ ) 00649 { 00650 if ( C.EventNamesTab[i]==Tag ) 00651 { 00652 Trigger( C.EventOthersTab[i], C.EventInstigatorsTab[i] ); 00653 } 00654 00655 } 00656 } 00657 } 00658 00659 STATE PlayingSequence 00660 { 00661 EVENT Tick( float dt ) 00662 { 00663 LOCAL vector Plane, v; 00664 LOCAL rotator r, Roto; 00665 LOCAL int i; 00666 LOCAL string Argument; 00667 00668 Player = XIIIPawn( PC.Pawn ); 00669 00670 if ( bFrozenPlayer && !PC.IsInState( 'NoControl') ) 00671 { 00672 bFrozenPlayer = false; 00673 PC.bWeaponBlock = false; 00674 if ( PC.bWeaponMode ) 00675 { 00676 PC.Switchweapon( PC.OldWeap ); 00677 PC.Pawn.ChangedWeapon(); 00678 } 00679 else 00680 { 00681 PC.cNextItem(); 00682 XIIIPawn(PC.Pawn).PendingItem = PC.OldItem; 00683 PC.Pawn.ChangedWeapon(); 00684 } 00685 } 00686 00687 if ( WarnMemory>0 && ( ( (flagsPaused & WT_Warn )!=0 ) || ( nOnJump[ON_Warning]!=-1 ) ) ) 00688 { 00689 // LOG( MyPawn.Name@" ** REPEAT WARNING **" ); 00690 RealCineWarn( ); 00691 } 00692 00693 TimeStamp+=dt; 00694 00695 SetLocation( Pawn.Location ); 00696 00697 if ( PC.IsInState('NoControl') ) 00698 { 00699 if ( FPCLocation!=none ) 00700 { 00701 // PC.Pawn.SetLocation( PC.Pawn.Location + ( 1 - ( ( 1 - 0.01 )** (150*dt) ) ) * ( FPCLocation.Location - PC.Pawn.Location ) ); 00702 v = FPCLocation.Location-PC.Pawn.Location; 00703 v.Z = 0; 00704 v = fMin( vSize(v)/dt, PlayerLinearSpeed ) * Normal( v ); 00705 v.Z = PC.Pawn.Velocity.Z; 00706 PC.Pawn.Velocity = v ; 00707 if ( vSize( v )==0 ) 00708 FPCLocation=none; 00709 } 00710 if ( FPCTarget!=none ) 00711 { 00712 // PC.SetRotation( PC.Rotation + ( 1 - ( ( 1 - 0.01 )** (150*dt) ) ) * RotDiff( ROTATOR( FPCTarget.Location - PC.Pawn.Location ), PC.Rotation ) ); 00713 ActualPlayerRotationSpeed= fMin( PlayerRotationSpeed, ActualPlayerRotationSpeed+RotationAcceleration*dt ); 00714 Roto=ROTATOR( FPCTarget.Location+vect(0,0,10)-PC.Pawn.Location ); 00715 00716 r.Yaw = Clamp( ( ( Roto.Yaw - PC.Rotation.Yaw + 32768 ) & 65535 ) - 32768, -ActualPlayerRotationSpeed*dt*182,ActualPlayerRotationSpeed*dt*182 ); 00717 r.Roll = Clamp( ( ( Roto.Roll - PC.Rotation.Roll + 32768 ) & 65535 ) - 32768, -ActualPlayerRotationSpeed*dt*182,ActualPlayerRotationSpeed*dt*182 ); 00718 r.Pitch = Clamp( ( ( Roto.Pitch - PC.Rotation.Pitch + 32768 ) & 65535 ) - 32768, -ActualPlayerRotationSpeed*dt* 41,ActualPlayerRotationSpeed*dt* 41 ); 00719 00720 PC.SetRotation( r + PC.Rotation ); 00721 // LOG ( "ROTOTO"@r ); 00722 if ( r.Yaw==0 && r.Pitch==0 && r.Roll==0) 00723 { 00724 ActualPlayerRotationSpeed=0; 00725 // FPCTarget=none; 00726 } 00727 } 00728 } 00729 else 00730 { 00731 ActualPlayerRotationSpeed=0; 00732 } 00733 00734 00735 switch ( flagsPaused & ( WT_SeenByPlayer | WT_NotSeenByPlayer ) ) 00736 { 00737 case WT_SeenByPlayer: 00738 if ( Level.TimeSeconds-Pawn.LastRenderTime<0.1 && PC.CanSee( Pawn ) ) 00739 flagsPaused = 0; 00740 break; 00741 case WT_NotSeenByPlayer: 00742 if ( 00743 ( MyPawn.MemoBlockPlayers || MyPawn.Invisible || !MyPawn.bHidden ) 00744 && 00745 ( 00746 ( MyPawn.Invisible && ! PC.CanSee( Pawn ) ) 00747 || 00748 ( Level.TimeSeconds-Pawn.LastRenderTime>0.5 ) 00749 ) 00750 ) 00751 flagsPaused = 0; 00752 break; 00753 case WT_SeenByPlayer | WT_NotSeenByPlayer: 00754 flagsPaused = 0; 00755 break; 00756 case 0: 00757 break; 00758 } 00759 00760 if ( nOnJump[ON_SeenByPlayer]!=-1 && nOnJump[ON_NotSeenByPlayer]!=-1 ) 00761 { 00762 nOnJump[ON_SeenByPlayer]=-1; 00763 nOnJump[ON_NotSeenByPlayer]=-1; 00764 } 00765 else 00766 { 00767 if ( nOnJump[ON_SeenByPlayer]!=-1 && PC.CanSee( Pawn ) ) 00768 { 00769 OnGoto( nOnJump[ON_SeenByPlayer] ); 00770 } 00771 else if ( nOnJump[ON_NotSeenByPlayer]!=-1 && !PC.CanSee( Pawn ) ) 00772 { 00773 OnGoto( nOnJump[ON_NotSeenByPlayer] ); 00774 } 00775 00776 } 00777 // if ( ( ( flagsPaused & WT_PlayerProximity ) != 0 || nOnJump[ON_PlayerProximity]!=-1 ) || 00778 // ( ( flagsPaused & WT_PlayerAway ) != 0 || nOnJump[ON_PlayerAway]!=-1 ) ) 00779 // SetLocation( Pawn.Location ); 00780 00781 if ( bMoving && !bMovePaused ) 00782 { 00783 if ( bool( NextTarget ) ) 00784 Plane = NextTarget.Location - Target.Location; 00785 else 00786 Plane = vector( Target.Rotation ); 00787 00788 Pawn.RotationRate.Yaw = rotationspeed*182;//*3/(1+VSize(Pawn.Velocity)/(MyPawnGroundSpeed * wantedspeed)); 00789 Focus = LockedActor; 00790 FocalPoint=FocalPoint*0.80+0.20*(Pawn.Location+Normal(Pawn.Velocity)*51200); 00791 Steering( Target.Location, dt, DetectionDistance /*+ Target.CollisionRadius*/ , true, !bool(NextTarget) && MyPawn.ImposedEndMovePosition); 00792 ///* TODEL */ EndOfMove(); /* TODEL */ 00793 } 00794 else 00795 { 00796 if (bool(LockedActor)) 00797 Focus=LockedActor; 00798 if ( ( Focus == none ) && ! bMovePaused && ( Target != none ) ) 00799 { 00800 r = rWantedRotation - rotation; 00801 if (r!=rot(0,0,0)) 00802 { 00803 r.Yaw = Clamp( ( ( r.Yaw + 32768 ) & 65535 ) - 32768, -rotationspeed * dt * 182, rotationspeed * dt * 182 ); 00804 r.Roll = Clamp( ( ( r.Roll + 32768 ) & 65535 ) - 32768, -rotationspeed * dt * 182, rotationspeed * dt * 182 ); 00805 r.Pitch = Clamp( ( ( r.Pitch + 32768 ) & 65535 ) - 32768, -rotationspeed * dt * 182, rotationspeed * dt * 182 ); 00806 r += rotation; 00807 FocalPoint = ( Pawn.Location + Vector ( r ) * 51200 ); 00808 // Focus = none; 00809 } 00810 } 00811 if ( !bCineControlAnims ) 00812 Pawn.ChangeAnimation( ); 00813 // FocalPoint = Pawn.Location + Vector ( Target.Rotation ) * 250; 00814 } 00815 00816 if ( ( flagsPaused & WT_Time ) != 0 && ( TimeStamp >= WaitTimeEnd ) ) 00817 flagsPaused = 0; 00818 00819 if ( ( flagsPaused & WT_Mask ) ==0 ) 00820 if ( MyPawn.GetAction(ScriptedActionIndex,Argument) ) 00821 { 00822 for (i=0;i<ON_Max;i++) 00823 if (ScriptedActionIndex==nOnJump[i]) 00824 nOnJump[i]=-1; 00825 00826 ErrorScript("#M"$string(ScriptedActionIndex)$" - #Y"$Argument); 00827 //Log(MyPawn.PawnName@"("@MyPawn@")"@string(ScriptedActionIndex)$" - "$Argument); 00828 Interpret( Argument ); 00829 } 00830 /* else 00831 { 00832 MyPawn.CurrentScript=-1; 00833 GotoState(''); 00834 } 00835 */ 00836 } 00837 00838 EVENT Trigger( actor Other, pawn EventInstigator ) 00839 { 00840 // LOG ( self@"TRIGGERED, nOnJump[ON_Event]="@nOnJump[ON_Event]@", flagsPaused="@flagsPaused ); 00841 // Handle "ON EVENT ..." 00842 if (nOnJump[ON_Event]!=-1) 00843 OnGoto( nOnJump[ON_Event] ); 00844 // Handle "WAIT EVENT ... OR ..." 00845 else 00846 if ( bool( flagsPaused & WT_Event ) ) flagsPaused = 0; 00847 } 00848 00849 EVENT CineWarn(actor Other) 00850 { 00851 // LOG( MyPawn.Name@"** RECEIVE WARNING FROM"@Other@"**" ); 00852 WarnMemory++; 00853 RealCineWarn( ); 00854 } 00855 00856 EVENT RealCineWarn( ) 00857 { 00858 // Handle "ON WARNING ..." 00859 if (nOnJump[ON_Warning]!=-1) 00860 { 00861 // LOG( MyPawn.Name@" ** WARNING ACCEPT **.." ); 00862 OnGoto( nOnJump[ON_Warning] ); 00863 WarnMemory--; 00864 } 00865 // Handle "WAIT WARNING OR ..." 00866 else 00867 if ( bool( flagsPaused & WT_Warn) ) 00868 { 00869 // LOG( MyPawn.Name@" ** WARNING ACCEPT **." ); 00870 WarnMemory--; 00871 flagsPaused = 0; 00872 } 00873 // else 00874 // LOG( MyPawn.Name@" ** WARNING NON EXPECTED **" ); 00875 00876 } 00877 00878 EVENT TriggerEvent( Name EventName, Actor Other, Pawn EventInstigator ) 00879 { 00880 LOCAL ACTOR A; 00881 LOCAL bool b; 00882 00883 // LOG(self@"** TriggerEvent( '"$EventName$"', '"$Other$"', '"$EventInstigator$"' );" ); 00884 if ( (EventName == '') || (EventName == 'None') ) 00885 return; 00886 00887 ForEach DynamicActors( class 'Actor', A, EventName ) 00888 { 00889 A.Trigger( Other, EventInstigator ); 00890 b=true; 00891 } 00892 00893 if ( !b ) 00894 RecordEvent( EventName, Other, EventInstigator); 00895 } 00896 00897 FUNCTION RecordEvent( Name EventName, Actor Other, Pawn EventInstigator ) 00898 { 00899 LOCAL int i; 00900 for ( i=0; i<MAX_EVENT; i++ ) 00901 { 00902 if ( EventNamesTab[i]=='' ) 00903 { 00904 // LOG( MyPawn.Name@"** RECORDING EVENT :"@EventName@"AT"@Level.TimeSeconds ); 00905 EventNamesTab[i]=EventName; 00906 EventOthersTab[i]=Other; 00907 EventInstigatorsTab[i]=EventInstigator; 00908 EventDatesTab[i]=Level.TimeSeconds+MAX_EVENTHISTORYTIME; 00909 break; 00910 } 00911 } 00912 00913 if ( i==MAX_EVENT ) 00914 { 00915 for ( i=0; i<MAX_EVENT; i++ ) 00916 { 00917 if ( Level.TimeSeconds>EventDatesTab[i] ) 00918 { 00919 // LOG( MyPawn.Name@"** FORGETTING OBSOLETE EVENT :"@EventNamesTab[i]@"AT"@Level.TimeSeconds ); 00920 // LOG( MyPawn.Name@"** RECORDING EVENT :"@EventName@"AT"@Level.TimeSeconds ); 00921 EventNamesTab[i]=EventName; 00922 EventOthersTab[i]=Other; 00923 EventInstigatorsTab[i]=EventInstigator; 00924 EventDatesTab[i]=Level.TimeSeconds+MAX_EVENTHISTORYTIME; 00925 break; 00926 } 00927 } 00928 // if ( i==MAX_EVENT ) 00929 // LOG( MyPawn.Name@"** TOO MANY RECORDED EVENTS"@"AT"@Level.TimeSeconds ); 00930 } 00931 } 00932 00933 EVENT EndOfDial(actor Other) 00934 { 00935 // Handle "WAIT ENDOFDIAL OR ..." 00936 if ( bool( flagsPaused & WT_DialEnd) ) flagsPaused = 0; 00937 // else 00938 // LOG ( MyPawn.Name@"** MESSAGE ENDOFDIAL RECU MAIS NON GERE" ); 00939 } 00940 00941 EVENT Touch(actor Other) 00942 { 00943 // Handle "WAIT PLAYER OR ..." 00944 if (Other.isA('XIIIPlayerPawn')) 00945 { 00946 if ( bool( flagsPaused & WT_PlayerProximity ) ) 00947 { 00948 flagsPaused = 0; 00949 SetCollision(false,false,false); 00950 } 00951 else if ( nOnJump[ON_PlayerProximity]!=-1 ) 00952 OnGoto( nOnJump[ON_PlayerProximity] ); 00953 } 00954 } 00955 00956 EVENT UnTouch(actor Other) 00957 { 00958 // Handle "WAIT PLAYERAWAY OR ..." 00959 if (Other.isA('XIIIPlayerPawn')) 00960 { 00961 if ( bool( flagsPaused & WT_PlayerAway ) ) 00962 { 00963 flagsPaused = 0; 00964 SetCollision(false,false,false); 00965 } 00966 else if ( nOnJump[ON_PlayerAway]!=-1 ) 00967 OnGoto( nOnJump[ON_PlayerAway] ); 00968 } 00969 } 00970 00971 // Handle "WAIT SEEPLAYER OR ..." 00972 EVENT SeePlayer( Pawn Seen ) 00973 { 00974 if ( nOnJump[ON_SeePlayer]!=-1) 00975 OnGoto( nOnJump[ON_SeePlayer] ); 00976 else 00977 if ( bool( flagsPaused & WT_SeePlayer ) ) 00978 flagsPaused = 0; 00979 00980 MyPawn.SeeXIII( ); 00981 } 00982 00983 event SeeDeadPawn(pawn other) 00984 { 00985 Global.SeeDeadPawn(other); 00986 00987 if ( nOnJump[ON_SeeCadaver]!=-1) 00988 OnGoto( nOnJump[ON_SeeCadaver] ); 00989 else 00990 if ( bool( flagsPaused & WT_SeeCadaver ) ) 00991 flagsPaused = 0; 00992 } 00993 // Handle "WAIT SEENBYPLAYER OR ..." 00994 /* EVENT SeenByPlayer() 00995 { 00996 if ( bool( flagsPaused & WT_SeenByPlayer ) ) flagsPaused = 0; 00997 }*/ 00998 00999 // Handle "WAIT ENDOFSEQ OR ..." 01000 EVENT EndOfSeq() 01001 { 01002 if ( bool( flagsPaused & WT_SequenceEnd ) ) 01003 flagsPaused = 0; 01004 } 01005 01006 // Handle "ANIM ONCE ..." 01007 EVENT AnimEnd( int Channel ) 01008 { 01009 LOCAL vector v; 01010 // log(pawn@"animend"@CurrentAnim@bAnimOnce); 01011 if ( bDying && Channel==15 ) 01012 { 01013 // Log (MyPawn.PawnName@"("@self@") CC2::AnimEnd"@name@": end of dying"); 01014 MyPawn.ReduceMyCylinder(); 01015 MyPawn.GotoState('Dying'); 01016 MyPawn.bIsDead=true; 01017 MyPawn.Health=0; 01018 MyPawn.SetCollision(true,false,false); 01019 MyPawn.SetPhysics( PHYS_None ); 01020 // v=MyPawn.GetBoneCoords('X').Origin-MyPawn.Location; 01021 // v.Z=0; 01022 // MyPawn.SetLocation(MyPawn.Location+v); 01023 // 01024 // MyPawn.PrePivot-=v; 01025 // MyPawn.RecomputeBoundingVolume(true); 01026 01027 MyPawn.TakeDamage( 2000, MyPawn, MyPawn.Location, vect(0,0,0), Class'XIII.DTSureStunned'/*class<DamageType> damageType*/); 01028 } 01029 else 01030 if ( bAnimDev ) 01031 { 01032 // DebugLog (MyPawn.PawnName@"("@self@") CC2::AnimEnd"@name@": end of DevAnim"); 01033 if ( bool( flagsPaused & WT_AnimEnd ) ) flagsPaused = 0; 01034 bAnimDev = false; 01035 bCineControlAnims = false; 01036 Pawn.SetLocation( Pawn.GetBoneCoords( 'X' ).Origin ); 01037 Pawn.SetRotation( Pawn.GetBoneRotation( 'X' ) ); 01038 } 01039 else 01040 if (bAnimOnce && Channel==0) 01041 { 01042 // DebugLog (MyPawn.PawnName@"("@self@") CC2::AnimEnd"@name@": end of AnimOnce"); 01043 if ( bool( flagsPaused & WT_AnimEnd ) ) flagsPaused = 0; 01044 // LoopAni( MyPawn.WaitAnim ); 01045 bCineControlAnims = false; 01046 } 01047 else 01048 if (bSubAnim && Channel==3) 01049 { 01050 // DebugLog (MyPawn.PawnName@"("@self@") CC2::AnimEnd"@name@": end of SubAnim"); 01051 if ( bool( flagsPaused & WT_AnimEnd ) ) flagsPaused = 0; 01052 bSubAnim = false; 01053 } 01054 else 01055 if ( Channel==14 /*FIRINGCHANNEL*/ ) 01056 { 01057 Pawn.AnimBlendToAlpha(14/*FIRINGCHANNEL*/,0,0.2); 01058 // bCineControlAnims=false; 01059 // Log (self@"CC2::AnimEnd channel"@Channel); 01060 } 01061 } 01062 } 01063 01064 final function Interpret(string Argument) 01065 { 01066 LOCAL float fTemp,fTemp2; 01067 LOCAL name nTemp; 01068 LOCAL vector vTemp; 01069 LOCAL bool bWait; 01070 01071 // Log( MyPawn.Name@">> INTERPRET : "$ScriptedActionIndex$" -> '"$Argument$"'" ); 01072 switch ( GetFirstWord( Argument ) ) 01073 { 01074 // skip this line or label 01075 case "REM": case "'": break; 01076 // freeze player control 01077 case "FPC": case "FreezePlayer": 01078 PC.GotoState('NoControl'); 01079 PC.StopFiring(); 01080 FPCTarget = none; 01081 FPCLocation = none; 01082 PC.Velocity = vect(0,0,0); 01083 if ( Argument!="" ) 01084 { 01085 FPCTarget=FindAnActor(GetFirstWord(Argument)); 01086 // LOG ("Target ==>"@FPCTarget); 01087 if ( Argument!="" ) 01088 { 01089 FPCLocation=FindAnActor(GetFirstWord(Argument)); 01090 // LOG ("Location==>"@FPCLocation); 01091 } 01092 } 01093 if ( !bFrozenPlayer ) 01094 { 01095 if ( PC.bWeaponMode ) 01096 { 01097 PC.OldWeap = PC.pawn.weapon.InventoryGroup; 01098 PC.Pawn.Weapon.PutDown(); 01099 } 01100 else 01101 { 01102 PC.OldItem = XIIIItems(PC.Pawn.SelectedItem); 01103 PC.OldItem.PutDown(); 01104 } 01105 PC.bWeaponBlock = true; 01106 bFrozenPlayer = true; 01107 } 01108 break; 01109 // freeze player control 01110 case "FPL": case "FreezePlayerLocation": 01111 PC.GotoState('NoMove'); 01112 break; 01113 case "PV": 01114 Pawn.PeripheralVision=float(GetFirstWord( Argument )); 01115 break; 01116 case "SR": 01117 Pawn.SightRadius=float(GetFirstWord( Argument )); 01118 break; 01119 case "DUCK": 01120 PC.PlayerInput.bForceCrouch = true; 01121 PC.Pawn.bCanCrouch = true; 01122 break; 01123 // release player control 01124 case "RPC": case "ReleasePlayer": 01125 PC.GotoState('PlayerWalking'); 01126 PC.PlayerInput.bForceCrouch = false; 01127 FPCTarget=none; 01128 FPCLocation=none; 01129 break; 01130 case "ForceCrouch": 01131 PC.PlayerInput.bForceCrouch = true; 01132 break; 01133 // the actor must die 01134 case "Faint": 01135 case "Die": 01136 if ( Argument!="") 01137 { 01138 bDying=true; 01139 Pawn.AnimBlendParams(15,0.0,0,0,'X'); 01140 PlayAni( '' ); 01141 nTemp = name( GetFirstWord( Argument ) ); 01142 if ( Argument!="" ) 01143 { 01144 fTemp = float( GetFirstWord( Argument ) ); 01145 if ( fTemp==0 ) 01146 fTemp=1; 01147 } 01148 else 01149 fTemp = 1.0; 01150 Pawn.AnimBlendToAlpha(15,fTemp,MyPawn.TweenTime); 01151 PlayAni( nTemp, fTemp, MyPawn.TweenTime, 15 ); 01152 } 01153 else 01154 MyPawn.TakeDamage( 2000, MyPawn, MyPawn.Location, vect(0,0,0), Class'XIII.DTSureStunned'/*class<DamageType> damageType*/); 01155 break; 01156 case "BeDead": 01157 MyPawn.Health= 0; 01158 MyPawn.bIsDead= true; 01159 break; 01160 // case "Faint": 01161 // MyPawn.TakeDamage( 0, MyPawn, MyPawn.Location, vect(0,0,0), Class'XIII.DTSureStunned'/*class<DamageType> damageType*/); 01162 // break; 01163 case "Fall": 01164 GoFall(FindAnActor(GetFirstWord(Argument)),float(GetFirstWord(Argument)),float(GetFirstWord(Argument))); 01165 break; 01166 case "Jump": 01167 GoJump(FindAnActor(GetFirstWord(Argument)),float(GetFirstWord(Argument))); 01168 break; 01169 01170 // the actor will become invisibility 01171 case "BeInvisible": MyPawn.SetInvisibility(true); break; 01172 case "BeVisible": MyPawn.SetInvisibility(false); break; 01173 // set the actor collisionnability 01174 case "ColOn": case "CollisionOn": MyPawn.CollisionActivity(true); break; 01175 case "ColOff": case "CollisionOff": MyPawn.CollisionActivity(false); break; 01176 case "ColHeight": 01177 fTemp=float(GetFirstWord(Argument)); 01178 Pawn.PrePivot.Z+= Pawn.CollisionHeight-fTemp; 01179 Pawn.SetLocation(Pawn.Location-(Pawn.CollisionHeight-fTemp)*vect(0,0,1)); 01180 Pawn.SetCollisionSize( Pawn.CollisionRadius, fTemp ); 01181 break; 01182 case "PeerAt": 01183 MyPawn.PeeredActor=FindAnActor(GetFirstWord(Argument)); 01184 break; 01185 // impose a focus on this actor 01186 case "LookAtNR": 01187 Pawn.RotationRate.Yaw = rotationspeed * 182; 01188 LockedActor=none; 01189 Focus=FindAnActor(GetFirstWord(Argument)); 01190 if (Focus==self) 01191 Focus=none; 01192 break; 01193 case "LookAt": 01194 Pawn.RotationRate.Yaw = rotationspeed * 182; 01195 LockedActor=none; 01196 Focus=FindAnActor(GetFirstWord(Argument)); 01197 bCineControlAnims=false; 01198 if (Focus==self) 01199 Focus=none; 01200 break; 01201 // start/stop a move sequence (parallel process) 01202 case "MovSeq": MoveSequence=Argument; NextMove(); break; 01203 case "MovSeqB": MoveSequence=Argument; NextMove(); flagsPaused=flagsPaused | WT_SequenceEnd; break; 01204 case "StopSeq": StopMove(); break; 01205 case "ResumeSeq": ResumeMove(); break; 01206 case "PauseSeq": PauseMove(); break; 01207 01208 //case "Mesh": Mesh=Mesh(Name(GetFirstWord(Argument))); break; 01209 01210 // warn a Cine2 actor 01211 case "Warn": 01212 while (Argument!="") 01213 WarnActor(FindAnActor(GetFirstWord(Argument))); 01214 break; 01215 01216 // Script waits before moving to next action 01217 case "On": 01218 switch(GetFirstWord(Argument)) 01219 { 01220 case "Player": 01221 if (CharIsNum(Argument)) 01222 SetCollisionSize(float(GetFirstWord(Argument)),Pawn.CollisionHeight); 01223 if (vSize(Pawn.Location-PC.Pawn.Location)>CollisionRadius) 01224 { 01225 // SetLocation(Pawn.Location); 01226 SetCollision(true,false,false); 01227 // flagsPaused=flagsPaused | WT_PlayerProximity; 01228 if (CharIsNum(Argument)) 01229 nOnJump[ON_PlayerProximity]=int(GetFirstWord(Argument)); 01230 else 01231 nOnJump[ON_PlayerProximity]=FindLabel(GetFirstWord(Argument)); 01232 } 01233 else 01234 { 01235 // Already near player 01236 if (CharIsNum(Argument)) 01237 ScriptedActionIndex=int(GetFirstWord(Argument))-1; 01238 else 01239 ScriptedActionIndex=FindLabel(GetFirstWord(Argument))-1; 01240 } 01241 01242 break; 01243 case "PlayerAway": 01244 if (CharIsNum(Argument)) 01245 SetCollisionSize(float(GetFirstWord(Argument)),Pawn.CollisionHeight); 01246 if (vSize(Pawn.Location-PC.Pawn.Location)<CollisionRadius) 01247 { 01248 // SetLocation(Pawn.Location); 01249 SetCollision(true,false,false); 01250 // flagsPaused=flagsPaused | WT_PlayerProximity; 01251 if (CharIsNum(Argument)) 01252 nOnJump[ON_PlayerAway]=int(GetFirstWord(Argument)); 01253 else 01254 nOnJump[ON_PlayerAway]=FindLabel(GetFirstWord(Argument)); 01255 } 01256 else 01257 { 01258 // Already near player 01259 if (CharIsNum(Argument)) 01260 ScriptedActionIndex=int(GetFirstWord(Argument))-1; 01261 else 01262 ScriptedActionIndex=FindLabel(GetFirstWord(Argument))-1; 01263 } 01264 01265 break; 01266 case "Event": 01267 Tag = Name(GetFirstWord(Argument)); 01268 if (CharIsNum(Argument)) 01269 nOnJump[ON_Event]=int(GetFirstWord(Argument)); 01270 else 01271 nOnJump[ON_Event]=FindLabel(GetFirstWord(Argument)); 01272 RestoreEvents( ); 01273 break; 01274 case "Warning": 01275 if (CharIsNum(Argument)) 01276 nOnJump[ON_Warning]=int(GetFirstWord(Argument)); 01277 else 01278 nOnJump[ON_Warning]=FindLabel(GetFirstWord(Argument)); 01279 break; 01280 case "SeePlayer": 01281 if (CharIsNum(Argument)) 01282 nOnJump[ON_SeePlayer]=int(GetFirstWord(Argument)); 01283 else 01284 nOnJump[ON_SeePlayer]=FindLabel(GetFirstWord(Argument)); 01285 break; 01286 case "SeenByPlayer": 01287 if (CharIsNum(Argument)) 01288 nOnJump[ON_SeenByPlayer]=int(GetFirstWord(Argument)); 01289 else 01290 nOnJump[ON_SeenByPlayer]=FindLabel(GetFirstWord(Argument)); 01291 break; 01292 case "NotSeenByPlayer": 01293 if (CharIsNum(Argument)) 01294 nOnJump[ON_NotSeenByPlayer]=int(GetFirstWord(Argument)); 01295 else 01296 nOnJump[ON_NotSeenByPlayer]=FindLabel(GetFirstWord(Argument)); 01297 break; 01298 case "SeeCadaver": 01299 if (CharIsNum(Argument)) 01300 nOnJump[ON_SeeCadaver]=int(GetFirstWord(Argument)); 01301 else 01302 nOnJump[ON_SeeCadaver]=FindLabel(GetFirstWord(Argument)); 01303 break; 01304 case "Time": 01305 if (CharIsNum(Argument)) 01306 nOnJump[ON_Time]=int(GetFirstWord(Argument)); 01307 else 01308 nOnJump[ON_Time]=FindLabel(GetFirstWord(Argument)); 01309 break; 01310 } 01311 break; 01312 case "return": 01313 if ( nReturnIndexIndex != 0 ) 01314 { 01315 nReturnIndexIndex--; 01316 ScriptedActionIndex=nReturnIndex[nReturnIndexIndex]-1; 01317 } 01318 break; 01319 // Script waits before moving to next action 01320 case "Wait": 01321 bWait = true; 01322 while (bWait) 01323 { 01324 switch(GetFirstWord(Argument)) 01325 { 01326 case "Player": 01327 nOnJump[ON_PlayerProximity]=-1; 01328 if (CharIsNum(Argument)) 01329 { 01330 SetCollisionSize(float(GetFirstWord(Argument)),Pawn.CollisionHeight); 01331 // DebugLog( "WAIT PLAYER"@CollisionRadius ); 01332 } 01333 vTemp = Pawn.Location-PC.Pawn.Location; 01334 vTemp.Z = 0; 01335 if (vSize(vTemp)>CollisionRadius || Abs((Pawn.Location-PC.Pawn.Location).Z)>Pawn.CollisionHeight) 01336 { 01337 // SetLocation(Pawn.Location); 01338 SetCollision(true,false,false); 01339 flagsPaused=flagsPaused | WT_PlayerProximity; 01340 } 01341 else 01342 { 01343 bWait=false; 01344 flagsPaused=0; 01345 } 01346 break; 01347 case "PlayerAway": 01348 nOnJump[ON_PlayerAway]=-1; 01349 if (CharIsNum(Argument)) 01350 { 01351 SetCollisionSize(float(GetFirstWord(Argument)),Pawn.CollisionHeight); 01352 // DebugLog( "WAIT PLAYERWAIT"@CollisionRadius ); 01353 } 01354 vTemp = Pawn.Location-PC.Pawn.Location; 01355 vTemp.Z = 0; 01356 if (vSize(vTemp)<CollisionRadius && Abs((Pawn.Location-PC.Pawn.Location).Z)<Pawn.CollisionHeight) 01357 { 01358 // SetLocation(Pawn.Location); 01359 SetCollision(true,false,false); 01360 flagsPaused=flagsPaused | WT_PlayerAway; 01361 } 01362 else 01363 { 01364 bWait=false; 01365 flagsPaused=0; 01366 } 01367 break; 01368 case "Event": 01369 Tag = Name(GetFirstWord(Argument)); 01370 if ( Tag!='') 01371 { 01372 nOnJump[ON_Event]=-1; 01373 flagsPaused=flagsPaused | WT_Event; 01374 } 01375 else 01376 ErrorScript ("Unknown WAIT EVENT argument.",true); 01377 01378 RestoreEvents( ); 01379 01380 break; 01381 case "Warning": 01382 nOnJump[ON_Warning]=-1; 01383 flagsPaused=flagsPaused | WT_Warn; 01384 // Log( "CINE2"@self@"Wait warning" ); 01385 break; 01386 case "EndOfSpeech": 01387 case "EndOfDial": 01388 nOnJump[ON_DialEnd]=-1; 01389 flagsPaused=flagsPaused | WT_DialEnd; 01390 break; 01391 case "EndOfMove": 01392 case "EndOfSeq": 01393 if ( bMoving ) 01394 { 01395 nOnJump[ON_SequenceEnd]=-1; 01396 flagsPaused=flagsPaused | WT_SequenceEnd; 01397 } 01398 break; 01399 case "Time": 01400 nOnJump[ON_Time]=-1; 01401 WaitTimeEnd = TimeStamp + float( GetFirstWord( Argument ) ); 01402 flagsPaused=flagsPaused | WT_Time; 01403 break; 01404 case "SeePlayer": 01405 nOnJump[ON_SeePlayer]=-1; 01406 flagsPaused=flagsPaused | WT_SeePlayer; 01407 break; 01408 case "BeSeenByPlayer": 01409 nOnJump[ON_SeenByPlayer]=-1; 01410 flagsPaused=flagsPaused | WT_SeenByPlayer; 01411 break; 01412 case "NotBeSeenByPlayer": 01413 nOnJump[ON_NotSeenByPlayer]=-1; 01414 flagsPaused=flagsPaused | WT_NotSeenByPlayer; 01415 break; 01416 case "SeeCadaver": 01417 nOnJump[ON_SeeCadaver]=-1; 01418 flagsPaused=flagsPaused | WT_SeeCadaver; 01419 break; 01420 default: 01421 ErrorScript ("Unknown WAIT argument '"@Argument@"'.",true); 01422 } 01423 if (!(GetFirstWord(Argument)~="or")) 01424 { 01425 break; 01426 } 01427 } 01428 break; 01429 01430 case "Music": case "msk": CinePlayMusic(int(GetFirstWord(Argument))); break; // Play music 01431 case "Sound": case "snd": CinePlaySound(GetFirstWord(Argument),GetFirstWord(Argument)); break; // Play sound 01432 case "Onomatop": case "ono": CinePlayVoice(GetFirstWord(Argument),GetFirstWord(Argument)); break; // Play onomatopeia ( voice slider ) 01433 01434 case "Anim": 01435 // Log(self@"ANIM"@Argument); 01436 switch(GetFirstWord(Argument)) 01437 { 01438 /* case "Special": 01439 nTemp= name( GetFirstWord( Argument ) ); 01440 fTemp= float( GetFirstWord( Argument ) ); if (fTemp==0.0) fTemp=1.0; 01441 if (Argument=="") fTemp2=MyPawn.TweenTime; else fTemp2= float( GetFirstWord( Argument ) ); 01442 Pawn.AnimBlendParams(3,1.0,0,0,'x Spine1'); 01443 Pawn.LoopAnim( nTemp,fTemp,fTemp2,3 ); 01444 break;*/ 01445 case "sperot": 01446 Pawn.SetBoneRotation( 01447 name( "x"@GetFirstWord( Argument) ), 01448 rot(1,0,0)*float(GetFirstWord( Argument))+rot(0,1,0)*float(GetFirstWord( Argument))+rot(0,0,1)*float(GetFirstWord( Argument)), 01449 , 01450 1.0 ); 01451 break; 01452 case "sperotoff": 01453 Pawn.SetBoneRotation( 01454 name( "x"@GetFirstWord( Argument) ), 01455 rot(0,0,0), 01456 , 01457 0.0 ); 01458 break; 01459 case "speinit": 01460 Pawn.AnimBlendParams(3,0.0,0,0,name( Argument )); 01461 break; 01462 case "speloop": 01463 Pawn.AnimBlendToAlpha(3,1.0,0.5); 01464 nTemp= name( GetFirstWord( Argument ) ); 01465 fTemp= float( GetFirstWord( Argument ) ); if (fTemp==0.0) fTemp=1.0; 01466 if (Argument=="") fTemp2=MyPawn.TweenTime; else fTemp2= float( GetFirstWord( Argument ) ); 01467 Pawn.LoopAnim( nTemp, fTemp, fTemp2,3 ); 01468 break; 01469 case "speonce": 01470 Pawn.AnimBlendToAlpha(3,1.0,0.5); 01471 nTemp= name( GetFirstWord( Argument ) ); 01472 fTemp= float( GetFirstWord( Argument ) ); if (fTemp==0.0) fTemp=1.0; 01473 if (Argument=="") fTemp2=MyPawn.TweenTime; else fTemp2= float( GetFirstWord( Argument ) ); 01474 Pawn.PlayAnim( nTemp, fTemp, fTemp2,3 ); 01475 flagsPaused=flagsPaused | WT_AnimEnd; 01476 bSubAnim=true; 01477 break; 01478 case "speoncenb": 01479 Pawn.AnimBlendToAlpha(3,1.0,0.5); 01480 nTemp= name( GetFirstWord( Argument ) ); 01481 fTemp= float( GetFirstWord( Argument ) ); if (fTemp==0.0) fTemp=1.0; 01482 if (Argument=="") fTemp2=MyPawn.TweenTime; else fTemp2= float( GetFirstWord( Argument ) ); 01483 Pawn.PlayAnim( nTemp, fTemp, fTemp2,3 ); 01484 break; 01485 case "speoff": 01486 Pawn.AnimBlendToAlpha(3, 0.0, 0.5); 01487 break; 01488 case "tweentime": 01489 MyPawn.TweenTime= float( GetFirstWord( Argument ) ); 01490 break; 01491 01492 // PlayAni( GetFirstWord(Argument) ); flagsPaused=flagsPaused | WT_AnimEnd; break; 01493 case "Once": 01494 flagsPaused=flagsPaused | WT_AnimEnd; 01495 nTemp= name( GetFirstWord( Argument ) ); 01496 fTemp= float( GetFirstWord( Argument ) ); if (fTemp==0.0) fTemp=1.0; 01497 if (Argument=="") fTemp2=MyPawn.TweenTime; else fTemp2= float( GetFirstWord( Argument ) ); 01498 PlayAni( nTemp, fTemp, fTemp2 ); 01499 break; 01500 case "OnceNB": 01501 nTemp= name( GetFirstWord( Argument ) ); 01502 fTemp= float( GetFirstWord( Argument ) ); if (fTemp==0.0) fTemp=1.0; 01503 if (Argument=="") fTemp2=MyPawn.TweenTime; else fTemp2= float( GetFirstWord( Argument ) ); 01504 PlayAni( nTemp, fTemp, fTemp2 ); 01505 break; 01506 case "Loop": 01507 nTemp= name( GetFirstWord( Argument ) ); 01508 fTemp= float( GetFirstWord( Argument ) ); if (fTemp==0.0) fTemp=1.0; 01509 if (Argument=="") fTemp2=MyPawn.TweenTime; else fTemp2= float( GetFirstWord( Argument ) ); 01510 // log (self@"ANIM LOOP"@nTemp); 01511 LoopAni( nTemp, fTemp, fTemp2 ); 01512 break; 01513 case "SetWait": MyPawn.WaitAnim= Name(GetFirstWord(Argument)) ; break; 01514 case "SetWalk": MyPawn.WalkAnim= Name(GetFirstWord(Argument)) ; break; 01515 case "SetRun": MyPawn.RunAnim= Name(GetFirstWord(Argument)) ; break; 01516 case "Dev": flagsPaused=flagsPaused | WT_AnimEnd; DevAni( GetFirstWord(Argument) ); break; 01517 default: ErrorScript ("Unknown PLAYANIM argument '"$Argument$"'."); 01518 } 01519 break; 01520 01521 case "AL": LoopAni( GetFirstWord(Argument), 1.0, MyPawn.TweenTime ); break; // Anim loop 01522 case "DD": DetectionDistance=float(GetFirstWord(Argument)); break; // Set detection distance 01523 case "AF": AccelerationFactor=float(GetFirstWord(Argument)); break; 01524 case "SP": SetWantedSpeed(float(GetFirstWord(Argument))); break; // Set linear speed 01525 case "RS": SetRotationSpeed(float(GetFirstWord(Argument))); break; // Set rotation speed 01526 case "TP": case "TeleportTo": 01527 TeleportTo(FindAnActor(GetFirstWord(Argument))); 01528 break; 01529 case "TPInFrontOf": 01530 // This function is only use in Plage00 so I assume that Actor is always XIII 01531 GetFirstWord(Argument); 01532 XIIIGameInfo(Level.Game).MapInfo.XIIIPawn.SetRotation( XIIIGameInfo(Level.Game).MapInfo.XIIIController.Rotation ); 01533 TeleportInFrontOf(XIIIGameInfo(Level.Game).MapInfo.XIIIPawn,int(GetFirstWord(Argument))); 01534 break; 01535 case "TurnIntoSoldier": case "TIS": 01536 MyPawn.ConvertToSoldier(); 01537 Pawn=none; 01538 MyPawn=none; 01539 GotoState('',''); 01540 break; 01541 case "TIAS": 01542 MyPawn.bTurnIntoAgressiveSoldier=true; 01543 MyPawn.ConvertToSoldier(); 01544 Pawn=none; 01545 MyPawn=none; 01546 GotoState('',''); 01547 break; 01548 case "TINAS": 01549 MyPawn.bTurnIntoAgressiveSoldier=false; 01550 MyPawn.ConvertToSoldier(); 01551 Pawn=none; 01552 MyPawn=none; 01553 GotoState('',''); 01554 break; 01555 case "Event": case "EV": 01556 while (Argument!="") 01557 TriggerEvent( Name(GetFirstWord(Argument)) , self , MyPawn ); 01558 break; 01559 case "PlayerEvent": 01560 while (Argument!="") 01561 TriggerEvent( Name(GetFirstWord(Argument)) , self , PC.Pawn ); 01562 break; 01563 case "CineEvent": 01564 while (Argument!="") 01565 CineEvent( Argument ); 01566 break; 01567 case "Dial": if (CharIsNum(Argument)) 01568 { 01569 if (dm!=none) 01570 { 01571 dm.ForceLine(GetFirstWord(Argument)); 01572 } 01573 } 01574 else 01575 { 01576 StartDialogue(GetFirstWord(Argument),GetFirstWord(Argument)); 01577 } 01578 break; 01579 case "DialMan": 01580 dm = DialogueManager(FindAnActor("DialogueManager"$GetFirstWord(Argument))); 01581 01582 if (dm!=none) 01583 { 01584 if ( dm.IsSpeaking( ) ) 01585 dm.ForceLine(GetFirstWord(Argument)); 01586 else 01587 dm.StartDialogue(int(GetFirstWord(Argument))); 01588 } 01589 break; 01590 case "StopDial":StopDialogue(GetFirstWord(Argument)); 01591 break; 01592 case "OpenDoor": 01593 case "OD": MyPawn.OpenDoor(XIIIPorte(FindAnActor(GetFirstWord(Argument)))); break; 01594 case "CloseDoor": 01595 case "CD": MyPawn.CloseDoor(XIIIPorte(FindAnActor(GetFirstWord(Argument)))); break; 01596 case "UnlockDoor": 01597 case "UD": MyPawn.UnlockDoor(XIIIPorte(FindAnActor(GetFirstWord(Argument)))); break; 01598 case "LockDoor": 01599 case "LD": MyPawn.LockDoor(XIIIPorte(FindAnActor(GetFirstWord(Argument)))); break; 01600 case "Leave": MyPawn.CurrentScript=-1; GotoState(''); break; 01601 case "Give": MyPawn.GiveObject( int(GetFirstWord(Argument)), PC.Pawn ); break; 01602 case "Drop": MyPawn.DropObject( int(GetFirstWord(Argument)), PC.Pawn ); break; 01603 case "Take": /*MyPawn.GiveObject( int(GetFirstWord(Argument)), PC.Pawn );*/ break; 01604 case "Destroy": FindAnActor(GetFirstWord(Argument)).Destroy(); break; 01605 case "ViewFocus": 01606 case "VF": 01607 Pawn.RotationRate.Yaw = rotationspeed * 182; 01608 LockedActor=FindAnActor(GetFirstWord(Argument)); 01609 bCineControlAnims=false; 01610 break; 01611 case "Link": 01612 FindAnActor(GetFirstWord(Argument)).SetBase( Pawn ); 01613 break; 01614 case "SetVar": 01615 Counter[int( GetFirstWord( Argument ) )] = int( GetFirstWord( Argument ) ); 01616 break; 01617 case "IncVar": 01618 Counter[int( GetFirstWord( Argument ) )]++; 01619 break; 01620 case "IfVarEqual": 01621 if ( Counter[int( GetFirstWord( Argument ) )] == int( GetFirstWord( Argument ) ) ) 01622 { 01623 if (CharIsNum(Argument)) 01624 ScriptedActionIndex=int(GetFirstWord(Argument))-1; 01625 else 01626 ScriptedActionIndex=FindLabel(GetFirstWord(Argument))-1; 01627 } 01628 break; 01629 case "Attach": AttachSM(class<SMAttached>(DynamicLoadObject(GetFirstWord(Argument),class'class'))); break; 01630 case "Detach": if (MyPawn.mycasm!=none) { MyPawn.mycasm.Destroy(); MyPawn.mycasm=none; } break; 01631 case "Goto": if (CharIsNum(Argument)) 01632 ScriptedActionIndex=int(GetFirstWord(Argument))-1; 01633 else 01634 ScriptedActionIndex=FindLabel(GetFirstWord(Argument))-1; 01635 break; 01636 // case "ShadowScale":Pawn.Shadow.ShadowScale=float(GetFirstWord(Argument)); 01637 // break; 01638 case "RW": case "ReadyWeapon": MyPawn.ReadyWeapon( int( GetFirstWord( Argument ) ) ); break; 01639 case "Shoot": 01640 if (CharIsNum(Argument)) 01641 ShootDispersion = float(GetFirstWord(Argument)); 01642 MyPawn.Shoot( ); 01643 break; 01644 case "AltShoot": 01645 if (CharIsNum(Argument)) 01646 ShootDispersion = float(GetFirstWord(Argument)); 01647 MyPawn.AltShoot( ); 01648 break; 01649 case "StopShoot": 01650 MyPawn.StopShoot( ); 01651 break; 01652 case "AdjustZShoot": 01653 AdjustAiming.Z=float(GetFirstWord(Argument)); 01654 break; 01655 // case "Crouch": Pawn.ShouldCrouch( true ); break; 01656 // case "Uncrouch": Pawn.ShouldCrouch( false ); break; 01657 case "CancelReaction": 01658 while (Argument!="") 01659 MyPawn.CancelReaction(int(GetFirstWord(Argument))); 01660 break; 01661 case "GameOverType": 01662 switch( int(GetFirstWord(Argument)) ) 01663 { 01664 case 0: 01665 Pawn.GameOver = GO_Never ; 01666 break; 01667 case 1: 01668 Pawn.GameOver = GO_TakeDamageFromPlayer ; 01669 break; 01670 case 2: 01671 Pawn.GameOver = GO_KillByPlayer ; 01672 break; 01673 case 3: 01674 Pawn.GameOver = GO_AnyDeath ; 01675 break; 01676 } 01677 break; 01678 01679 case "": break; 01680 default: ErrorScript ("Unknown instruction",true); 01681 } 01682 ++ScriptedActionIndex; 01683 } 01684 01685 FUNCTION InitJump(Actor FallTarget,float deltaZ,float Gamma) 01686 { 01687 LOCAL vector v; 01688 LOCAL float zM, d, tf; 01689 LockedActor=none; 01690 Focus=none; 01691 if (Gamma==0) Gamma=950; 01692 zM=Pawn.Location.Z+deltaZ; 01693 01694 v.z= sqrt(2.0*Gamma*deltaZ); 01695 01696 d= 2*Gamma*(zM-FallTarget.Location.Z); 01697 01698 tf = (v.z + sqrt(d))/Gamma; 01699 01700 v.x=(FallTarget.Location.X-Pawn.Location.X)/tf; 01701 v.y=(FallTarget.Location.Y-Pawn.Location.Y)/tf; 01702 01703 Pawn.AirSpeed=vSize(v); 01704 Pawn.SetPhysics(PHYS_Falling); 01705 Pawn.Velocity=v; 01706 Pawn.Acceleration=-Gamma*vect(0,0,1); 01707 WaitTimeEnd=tf; 01708 MyPawn.StopShoot(); 01709 } 01710 01711 FUNCTION GoFall(Actor FallTarget,float deltaZ,float Gamma) 01712 { 01713 InitJump( FallTarget, deltaZ, Gamma ); 01714 GotoState('STA_Falling'); 01715 } 01716 01717 STATE Idle 01718 { 01719 EVENT Timer() 01720 { 01721 LOCAL float fTemp; 01722 01723 Pawn.SetPhysics(PHYS_Falling); 01724 01725 bControlAnimations=false; 01726 Pawn.SetCollision(true,true,true); 01727 Pawn.bCollideWorld=true; 01728 if (Pawn.Event!='') 01729 TriggerEvent(Pawn.Event,self,pawn); 01730 bDying=true; 01731 Pawn.AnimBlendParams(15,0.0,0,0,'X'); 01732 Pawn.AnimBlendToAlpha(15,1.0,0.0); 01733 PlayAni( 'DeathFalaiseFin', 1.0, MyPawn.TweenTime, 15 ); 01734 Pawn.bIsDead = true; 01735 TriggerEvent(Event, self, none); 01736 MyPawn.ReduceMyCylinder(); 01737 Pawn.GotoState('Dying'); 01738 Destroy(); 01739 } 01740 EVENT AnimEnd( int Channel ) 01741 { 01742 if ( bDying && Channel==15 ) 01743 { 01744 MyPawn.ReduceMyCylinder(); 01745 MyPawn.TakeDamage( 2000, MyPawn, MyPawn.Location, vect(0,0,0), Class'XIII.DTSureStunned'/*class<DamageType> damageType*/); 01746 return; 01747 } 01748 } 01749 EVENT BeginState() 01750 { 01751 SetTimer(WaitTimeEnd,false); 01752 } 01753 } 01754 01755 STATE STA_Falling extends Idle 01756 { 01757 EVENT AnimEnd( int Channel ) 01758 { 01759 } 01760 } 01761 01762 /* ############################################################################################################### */ 01763 01764 FUNCTION GoJump(Actor JTarget,float deltaZ) 01765 { 01766 JumpTarget=JTarget; 01767 JumpHight=deltaZ; 01768 GotoState('STA_Jumping_Impetus'); 01769 } 01770 01771 STATE STA_Jumping_Impetus 01772 { 01773 EVENT BeginState() 01774 { 01775 InitJump( JumpTarget, JumpHight, 950 ); 01776 SetTimer(WaitTimeEnd,false); 01777 Pawn.AnimBlendToAlpha( 15, 1.0, 0.25 ); 01778 // PlayAni( 'JumpUp', 1.0, 0.3 ); 01779 PlayAni( 'JumpAir', 1.0, 0.3 ); 01780 // Log(Level.TimeSeconds@GetStateName()@"BeginState()"); 01781 } 01782 /* EVENT AnimEnd( int Channel ) 01783 { 01784 Log(Level.TimeSeconds@GetStateName()@"AnimEnd("@Channel@")"); 01785 GotoState('STA_Jumping_Up'); 01786 } 01787 } 01788 01789 STATE STA_Jumping_Up 01790 { 01791 EVENT BeginState() 01792 { 01793 PlayAni( 'Jump', 1.0, 0.3 ); 01794 Log(Level.TimeSeconds@GetStateName()@"BeginState()"); 01795 } 01796 EVENT Tick( float dt ) 01797 { 01798 if ( Pawn.Velocity.Z<0 ) 01799 GotoState('STA_Jumping_Down'); 01800 } 01801 EVENT Timer() 01802 { 01803 } 01804 EVENT AnimEnd( int Channel ) 01805 { 01806 Log(GetStateName()@"AnimEnd("@Channel@")"); 01807 } 01808 } 01809 01810 STATE STA_Jumping_Down 01811 { 01812 EVENT BeginState() 01813 { 01814 PlayAni( 'JumpDown', 1.0, 0.3 ); 01815 Log(Level.TimeSeconds@GetStateName()@"BeginState()"); 01816 }*/ 01817 EVENT Tick( float dt ) 01818 { 01819 if ( Pawn.Velocity.Z==0 ) 01820 { 01821 LoopAni( MyPawn.WaitAnim, 1.0, 0.5 ); 01822 FocalPoint=MyPawn.Location+51200*vector(MyPawn.Rotation); 01823 GotoState('PlayingSequence'); 01824 } 01825 } 01826 01827 01828 } 01829 01830 /* ############################################################################################################### */ 01831 01832 FUNCTION AttachSM(class<SMAttached> sm) 01833 { 01834 if (sm!=none) 01835 { 01836 MyPawn.mycasm=Spawn(sm,Pawn); 01837 MyPawn.mycasm.AttachTo(Pawn); 01838 } 01839 } 01840 01841 FUNCTION bool NextMove() 01842 { 01843 LOCAL String Func,Arg; 01844 01845 // LOG( self@"NEXTMOVE '"$MoveSequence$"' at"@Level.TimeSeconds ); 01846 while (true) 01847 { 01848 Func = GetFirstWord( MoveSequence ); 01849 Arg = GetFirstWord( MoveSequence ); 01850 switch( Func ) 01851 { 01852 // Walk or Run 01853 case "W": case "R": 01854 // LOG( self @ Func @ Arg @ Level.TimeSeconds ); 01855 NextTarget=SearchNextWaypoint(); 01856 CineMoveTo( FindAnActor(Arg) ); 01857 return true; 01858 // Move 01859 case "M": 01860 // LOG( self @ Func @ Arg @ Level.TimeSeconds ); 01861 NextTarget=SearchNextWaypoint(); 01862 CineMoveTo(FindAnActor(Arg),true); 01863 return true; 01864 case "J": 01865 // LOG( self @ Func @ Arg @ Level.TimeSeconds ); 01866 Target=FindAnActor(Arg); 01867 NextTarget=SearchNextWaypoint(); 01868 GoJump(Target,JumpHeight); 01869 01870 bCineControlAnims=false; 01871 01872 if (Target!=none) 01873 { 01874 // if ( Pawn.Physics == PHYS_None ) 01875 // Pawn.SetPhysics( PHYS_Walking ); // Walk physics is default 01876 Plane=Normal(Target.Location-Pawn.Location); 01877 bMoving=true; 01878 } 01879 01880 return true; 01881 case "": 01882 if (!bCineControlAnims) 01883 LoopAni( MyPawn.WaitAnim, 1.0, MyPawn.TweenTime ); 01884 return false; 01885 01886 case "SP": SetWantedSpeed(float(Arg)); break; // Set speed 01887 case "RS": SetRotationSpeed(float(Arg)); break; // Set rotationspeed 01888 case "EV": TriggerEvent( Name(Arg) , self , MyPawn ); break; 01889 case "OD": MyPawn.OpenDoor(XIIIPorte(FindAnActor(Arg))); break; 01890 case "CD": MyPawn.CloseDoor(XIIIPorte(FindAnActor(Arg))); break; 01891 case "LD": MyPawn.LockDoor(XIIIPorte(FindAnActor(Arg))); break; 01892 case "UD": MyPawn.UnlockDoor(XIIIPorte(FindAnActor(Arg))); break; 01893 case "WARN":WarnActor(Cine2(FindAnActor(Arg))); break; 01894 case "DD": DetectionDistance=float(Arg); break; 01895 case "AF": AccelerationFactor=float(Arg); break; 01896 case "AL": LoopAni( name(Arg), 1.0, MyPawn.TweenTime ); break; 01897 case "TP": TeleportTo(FindAnActor(Arg)); break; 01898 case "VF": LockedActor=FindAnActor(Arg); break; 01899 case "FS": Pawn.Velocity = float(Arg)*Vector(Pawn.Rotation); break; 01900 case "msk": CinePlayMusic(int(Arg)); break; // Play music 01901 case "snd": CinePlaySound(Arg,""); break; // Play sound 01902 case "ono": CinePlayVoice(Arg,""); break; // Play onomatopeia ( voice slider ) 01903 case "JH": JumpHeight=float(Arg); break; 01904 01905 default: ErrorScript("Unknown function '"$Func$"' in move sequence",true); 01906 return false; 01907 } 01908 } 01909 01910 } 01911 01912 FUNCTION actor SearchNextWaypoint() 01913 { 01914 LOCAL String Func,Arg,MovSeq; 01915 01916 MovSeq=MoveSequence; 01917 01918 while (true) 01919 { 01920 // Found next waypoint 01921 Func=GetFirstWord(MovSeq); 01922 Arg=GetFirstWord(MovSeq); 01923 switch(Func) 01924 { 01925 case "": return none; 01926 case "M": 01927 case "W": 01928 case "R": 01929 case "J": 01930 return FindAnActor(Arg); 01931 } 01932 } 01933 } 01934 01935 01936 01937 defaultproperties 01938 { 01939 bCineControlAnims=True 01940 JumpHeight=80.000000 01941 bControlAnimations=True 01942 InitialState="STA_init" 01943 CollisionRadius=250.000000 01944 }

End Source Code