Advertisement
Guest User

XCEnforcer_PlayerPawn

a guest
May 24th, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 111.41 KB | None | 0 0
  1. //=============================================================================
  2. // PlayerPawn.
  3. // player controlled pawns
  4. // Note that Pawns which implement functions for the PlayerTick messages
  5. // must handle player control in these functions
  6. //=============================================================================
  7. class PlayerPawn expands Pawn
  8. config(user)
  9. native
  10. nativereplication;
  11.  
  12. // Player info.
  13. var const player Player;
  14. var globalconfig string Password; // for restarting coop savegames
  15.  
  16. var travel float DodgeClickTimer; // max double click interval for dodge move
  17. var(Movement) globalconfig float DodgeClickTime;
  18. var(Movement) globalconfig float Bob;
  19. var float LandBob, AppliedBob;
  20. var float bobtime;
  21.  
  22. // Camera info.
  23. var int ShowFlags;
  24. var int RendMap;
  25. var int Misc1;
  26. var int Misc2;
  27.  
  28. var actor ViewTarget;
  29. var vector FlashScale, FlashFog;
  30. var HUD myHUD;
  31. var ScoreBoard Scoring;
  32. var class<hud> HUDType;
  33. var class<scoreboard> ScoringType;
  34.  
  35. var float DesiredFlashScale, ConstantGlowScale, InstantFlash;
  36. var vector DesiredFlashFog, ConstantGlowFog, InstantFog;
  37. var globalconfig float DesiredFOV;
  38. var globalconfig float DefaultFOV;
  39.  
  40. // Music info.
  41. var music Song;
  42. var byte SongSection;
  43. var byte CdTrack;
  44. var EMusicTransition Transition;
  45.  
  46. var float shaketimer; // player uses this for shaking view
  47. var int shakemag; // max magnitude in degrees of shaking
  48. var float shakevert; // max vertical shake magnitude
  49. var float maxshake;
  50. var float verttimer;
  51. var(Pawn) class<carcass> CarcassType;
  52. var travel globalconfig float MyAutoAim;
  53. var travel globalconfig float Handedness;
  54. var(Sounds) sound JumpSound;
  55.  
  56. // Player control flags
  57. var bool bAdmin;
  58. var() globalconfig bool bLookUpStairs; // look up/down stairs (player)
  59. var() globalconfig bool bSnapToLevel; // Snap to level eyeheight when not mouselooking
  60. var() globalconfig bool bAlwaysMouseLook;
  61. var globalconfig bool bKeyboardLook; // no snapping when true
  62. var bool bWasForward; // used for dodge move
  63. var bool bWasBack;
  64. var bool bWasLeft;
  65. var bool bWasRight;
  66. var bool bEdgeForward;
  67. var bool bEdgeBack;
  68. var bool bEdgeLeft;
  69. var bool bEdgeRight;
  70. var bool bIsCrouching;
  71. var bool bShakeDir;
  72. var bool bAnimTransition;
  73. var bool bIsTurning;
  74. var bool bFrozen;
  75. var bool bBadConnectionAlert;
  76. var globalconfig bool bInvertMouse;
  77. var bool bShowScores;
  78. var bool bShowMenu;
  79. var bool bSpecialMenu;
  80. var bool bWokeUp;
  81. var bool bPressedJump;
  82. var bool bUpdatePosition;
  83. var bool bDelayedCommand;
  84. var bool bRising;
  85. var bool bReducedVis;
  86. var bool bCenterView;
  87. var() globalconfig bool bMaxMouseSmoothing;
  88. var bool bMouseZeroed;
  89. var bool bReadyToPlay;
  90. var globalconfig bool bNoFlash;
  91. var globalconfig bool bNoVoices;
  92. var globalconfig bool bMessageBeep;
  93. var bool bZooming;
  94. var() bool bSinglePlayer; // this class allowed in single player
  95. var bool bJustFired;
  96. var bool bJustAltFired;
  97. var bool bIsTyping;
  98. var bool bFixedCamera;
  99. var globalconfig bool bNeverAutoSwitch; // if true, don't automatically switch to picked up weapon
  100. var bool bJumpStatus; // used in net games
  101. var bool bUpdating;
  102. var bool bCheatsEnabled;
  103.  
  104. var float ZoomLevel;
  105.  
  106. var class<menu> SpecialMenu;
  107. var string DelayedCommand;
  108. var globalconfig float MouseSensitivity;
  109.  
  110. var globalconfig name WeaponPriority[50]; //weapon class priorities (9 is highest)
  111.  
  112. var float SmoothMouseX, SmoothMouseY, BorrowedMouseX, BorrowedMouseY;
  113. var() globalconfig float MouseSmoothThreshold;
  114. var float MouseZeroTime;
  115.  
  116. // Input axes.
  117. var input float
  118. aBaseX, aBaseY, aBaseZ,
  119. aMouseX, aMouseY,
  120. aForward, aTurn, aStrafe, aUp,
  121. aLookUp, aExtra4, aExtra3, aExtra2,
  122. aExtra1, aExtra0;
  123.  
  124. // Move Buffering.
  125. var SavedMove SavedMoves;
  126. var SavedMove FreeMoves;
  127. var SavedMove PendingMove;
  128. var float CurrentTimeStamp,LastUpdateTime,ServerTimeStamp,TimeMargin, ClientUpdateTime;
  129. var globalconfig float MaxTimeMargin;
  130.  
  131. // Progess Indicator.
  132. var string ProgressMessage[8];
  133. var color ProgressColor[8];
  134. var float ProgressTimeOut;
  135.  
  136. // Localized strings
  137. var localized string QuickSaveString;
  138. var localized string NoPauseMessage;
  139. var localized string ViewingFrom;
  140. var localized string OwnCamera;
  141. var localized string FailedView;
  142.  
  143. // ReplicationInfo
  144. var GameReplicationInfo GameReplicationInfo;
  145.  
  146. // ngWorldStats Logging
  147. var() globalconfig private string ngWorldSecret;
  148. var() globalconfig bool ngSecretSet;
  149. var bool ReceivedSecretChecksum;
  150.  
  151. // Remote Pawn ViewTargets
  152. var rotator TargetViewRotation;
  153. var float TargetEyeHeight;
  154. var vector TargetWeaponViewOffset;
  155.  
  156. // Demo recording view rotation
  157. var int DemoViewPitch;
  158. var int DemoViewYaw;
  159.  
  160. var float LastPlaySound;
  161. var float AccelAdjust;
  162.  
  163. replication
  164. {
  165. // Things the server should send to the client.
  166. reliable if( bNetOwner && Role==ROLE_Authority )
  167. ViewTarget, ScoringType, HUDType, GameReplicationInfo, bFixedCamera, bCheatsEnabled;
  168. unreliable if ( bNetOwner && Role==ROLE_Authority )
  169. TargetViewRotation, TargetEyeHeight, TargetWeaponViewOffset;
  170. reliable if( bDemoRecording && Role==ROLE_Authority )
  171. DemoViewPitch, DemoViewYaw;
  172.  
  173. // Things the client should send to the server
  174. reliable if ( Role<ROLE_Authority )
  175. Password, bReadyToPlay;
  176.  
  177. // Functions client can call.
  178. unreliable if( Role<ROLE_Authority )
  179. CallForHelp;
  180. reliable if( Role<ROLE_Authority )
  181. ShowPath, RememberSpot, Speech, Say, TeamSay, RestartLevel, SwitchWeapon, Pause, SetPause, ServerSetHandedness,
  182. PrevItem, ActivateItem, ShowInventory, Grab, ServerSetWeaponPriority,
  183. ChangeName, ChangeTeam, XGod, Suicide, ViewClass, ViewPlayerNum, ViewSelf, ViewPlayer, ServerSetSloMo, ServerAddBots,
  184. PlayersOnly, ThrowWeapon, ServerRestartPlayer, NeverSwitchOnPickup, BehindView, ServerNeverSwitchOnPickup,
  185. PrevWeapon, NextWeapon, GetWeapon, ServerReStartGame, ServerUpdateWeapons, ServerTaunt, ServerChangeSkin,
  186. SwitchLevel, SwitchCoopLevel, Kick, KickBan, KillAll, Summon, ActivateTranslator, Admin, AdminLogin, AdminLogout, Typing, Mutate;
  187. unreliable if( Role<ROLE_Authority )
  188. ServerMove, XFly, XWalk, XGhost;
  189.  
  190. // Functions server can call.
  191. reliable if( Role==ROLE_Authority && !bDemoRecording )
  192. ClientTravel;
  193. reliable if( Role==ROLE_Authority )
  194. ClientReliablePlaySound, ClientReplicateSkins, ClientAdjustGlow, ClientChangeTeam, ClientSetMusic, StartZoom, ToggleZoom, StopZoom, EndZoom, SetDesiredFOV, ClearProgressMessages, SetProgressColor, SetProgressMessage, SetProgressTime, ClientWeaponEvent;
  195. unreliable if( Role==ROLE_Authority )
  196. SetFOVAngle, ClientShake, ClientFlash, ClientInstantFlash;
  197. unreliable if( Role==ROLE_Authority && !bDemoRecording )
  198. ClientPlaySound;
  199. unreliable if( RemoteRole==ROLE_AutonomousProxy )//***
  200. ClientAdjustPosition;
  201. }
  202.  
  203. //
  204. // native client-side functions.
  205. //
  206. native event ClientTravel( string URL, ETravelType TravelType, bool bItems );
  207. native(544) final function ResetKeyboard();
  208. native(546) final function UpdateURL(string NewOption, string NewValue, bool bSaveDefault);
  209. native final function string GetDefaultURL(string Option);
  210. native final function LevelInfo GetEntryLevel();
  211. native final function string GetPlayerNetworkAddress();
  212. // Execute a console command in the context of this player, then forward to Actor.ConsoleCommand.
  213. native function string ConsoleCommand( string Command );
  214. native function CopyToClipboard( string Text );
  215. native function string PasteFromClipboard();
  216.  
  217. function InitPlayerReplicationInfo()
  218. {
  219. Super.InitPlayerReplicationInfo();
  220.  
  221. PlayerReplicationInfo.bAdmin = bAdmin;
  222. }
  223.  
  224. event PreClientTravel()
  225. {
  226. }
  227.  
  228. exec function Ping()
  229. {
  230. ClientMessage("Current ping is"@PlayerReplicationInfo.Ping);
  231. }
  232.  
  233. function ClientWeaponEvent(name EventType)
  234. {
  235. if ( Weapon != None )
  236. Weapon.ClientWeaponEvent(EventType);
  237. }
  238.  
  239. simulated event RenderOverlays( canvas Canvas )
  240. {
  241. if ( Weapon != None )
  242. Weapon.RenderOverlays(Canvas);
  243.  
  244. if ( myHUD != None )
  245. myHUD.RenderOverlays(Canvas);
  246. }
  247.  
  248. function ClientReplicateSkins(texture Skin1, optional texture Skin2, optional texture Skin3, optional texture Skin4)
  249. {
  250. // do nothing (just loading other player skins onto client)
  251. log("Getting "$Skin1$", "$Skin2$", "$Skin3$", "$Skin4);
  252. return;
  253. }
  254.  
  255. function CheckBob(float DeltaTime, float Speed2D, vector Y)
  256. {
  257. local float OldBobTime;
  258.  
  259. OldBobTime = BobTime;
  260. if ( Speed2D < 10 )
  261. BobTime += 0.2 * DeltaTime;
  262. else
  263. BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/GroundSpeed);
  264. WalkBob = Y * 0.65 * Bob * Speed2D * sin(6 * BobTime);
  265. AppliedBob = AppliedBob * (1 - FMin(1, 16 * deltatime));
  266. if ( LandBob > 0.01 )
  267. {
  268. AppliedBob += FMin(1, 16 * deltatime) * LandBob;
  269. LandBob *= (1 - 8*Deltatime);
  270. }
  271. if ( Speed2D < 10 )
  272. WalkBob.Z = AppliedBob + Bob * 30 * sin(12 * BobTime);
  273. else
  274. WalkBob.Z = AppliedBob + Bob * Speed2D * sin(12 * BobTime);
  275. }
  276.  
  277. exec function ViewPlayerNum(optional int num)
  278. {
  279. local Pawn P;
  280.  
  281. if ( !PlayerReplicationInfo.bIsSpectator && !Level.Game.bTeamGame )
  282. return;
  283. if ( num >= 0 )
  284. {
  285. P = Pawn(ViewTarget);
  286. if ( (P != None) && P.bIsPlayer && (P.PlayerReplicationInfo.TeamID == num) )
  287. {
  288. ViewTarget = None;
  289. bBehindView = false;
  290. return;
  291. }
  292. for ( P=Level.PawnList; P!=None; P=P.NextPawn )
  293. if ( (P.PlayerReplicationInfo != None) && (P.PlayerReplicationInfo.Team == PlayerReplicationInfo.Team)
  294. && !P.PlayerReplicationInfo.bIsSpectator
  295. && (P.PlayerReplicationInfo.TeamID == num) )
  296. {
  297. if ( P != self )
  298. {
  299. ViewTarget = P;
  300. bBehindView = true;
  301. }
  302. return;
  303. }
  304. return;
  305. }
  306. if ( Role == ROLE_Authority )
  307. {
  308. ViewClass(class'Pawn', true);
  309. While ( (ViewTarget != None)
  310. && (!Pawn(ViewTarget).bIsPlayer || Pawn(ViewTarget).PlayerReplicationInfo.bIsSpectator) )
  311. ViewClass(class'Pawn', true);
  312.  
  313. if ( ViewTarget != None )
  314. ClientMessage(ViewingFrom@Pawn(ViewTarget).PlayerReplicationInfo.PlayerName, 'Event', true);
  315. else
  316. ClientMessage(ViewingFrom@OwnCamera, 'Event', true);
  317. }
  318. }
  319.  
  320. exec function Profile()
  321. {
  322. //TEMP for performance measurement
  323.  
  324. log("Average AI Time"@Level.AvgAITime);
  325. log(" < 5% "$Level.AIProfile[0]);
  326. log(" < 10% "$Level.AIProfile[1]);
  327. log(" < 15% "$Level.AIProfile[2]);
  328. log(" < 20% "$Level.AIProfile[3]);
  329. log(" < 25% "$Level.AIProfile[4]);
  330. log(" < 30% "$Level.AIProfile[5]);
  331. log(" < 35% "$Level.AIProfile[6]);
  332. log(" > 35% "$Level.AIProfile[7]);
  333. }
  334.  
  335. // Execute an administrative console command on the server.
  336. exec function Admin( string CommandLine )
  337. {
  338. local string Result;
  339. if( bAdmin )
  340. Result = ConsoleCommand( CommandLine );
  341. if( Result!="" )
  342. ClientMessage( Result );
  343. }
  344.  
  345. // Login as the administrator.
  346. exec function AdminLogin( string Password )
  347. {
  348. Level.Game.AdminLogin( Self, Password );
  349. }
  350.  
  351. // Logout as the administrator.
  352. exec function AdminLogout()
  353. {
  354. Level.Game.AdminLogout( Self );
  355. }
  356.  
  357. exec function SShot()
  358. {
  359. local float b;
  360. b = float(ConsoleCommand("get ini:Engine.Engine.ViewportManager Brightness"));
  361. ConsoleCommand("set ini:Engine.Engine.ViewportManager Brightness 1");
  362. ConsoleCommand("flush");
  363. ConsoleCommand("shot");
  364. ConsoleCommand("set ini:Engine.Engine.ViewportManager Brightness "$string(B));
  365. ConsoleCommand("flush");
  366. }
  367.  
  368. exec function PlayerList()
  369. {
  370. local PlayerReplicationInfo PRI;
  371.  
  372. log("Player List:");
  373. ForEach AllActors(class'PlayerReplicationInfo', PRI)
  374. log(PRI.PlayerName@"( ping"@PRI.Ping$")");
  375. }
  376.  
  377. //
  378. // Native ClientSide Functions
  379. //
  380.  
  381. event ReceiveLocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
  382. {
  383. Message.Static.ClientReceive( Self, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject );
  384. }
  385.  
  386. event ClientMessage( coerce string S, optional Name Type, optional bool bBeep )
  387. {
  388. if (Player == None)
  389. return;
  390.  
  391. if (Type == '')
  392. Type = 'Event';
  393.  
  394. if (Player.Console != None)
  395. Player.Console.Message( PlayerReplicationInfo, S, Type );
  396. if (bBeep && bMessageBeep)
  397. PlayBeepSound();
  398. if ( myHUD != None )
  399. myHUD.Message( PlayerReplicationInfo, S, Type );
  400. }
  401.  
  402. event TeamMessage( PlayerReplicationInfo PRI, coerce string S, name Type, optional bool bBeep )
  403. {
  404. if (Player.Console != None)
  405. Player.Console.Message ( PRI, S, Type );
  406. if (bBeep && bMessageBeep)
  407. PlayBeepSound();
  408. if ( myHUD != None )
  409. myHUD.Message( PRI, S, Type );
  410. }
  411.  
  412. function ClientVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID)
  413. {
  414. local VoicePack V;
  415.  
  416. if ( (Sender == None) || (Sender.voicetype == None) || (Player.Console == None) )
  417. return;
  418.  
  419. V = Spawn(Sender.voicetype, self);
  420. if ( V != None )
  421. V.ClientInitialize(Sender, Recipient, messagetype, messageID);
  422. }
  423.  
  424. simulated function PlayBeepSound();
  425.  
  426. //
  427. // Send movement to the server.
  428. // Passes acceleration in components so it doesn't get rounded.
  429. //
  430. function ServerMove
  431. (
  432. float TimeStamp,
  433. vector InAccel,
  434. vector ClientLoc,
  435. bool NewbRun,
  436. bool NewbDuck,
  437. bool NewbJumpStatus,
  438. bool bFired,
  439. bool bAltFired,
  440. bool bForceFire,
  441. bool bForceAltFire,
  442. eDodgeDir DodgeMove,
  443. byte ClientRoll,
  444. int View,
  445. optional byte OldTimeDelta,
  446. optional int OldAccel
  447. )
  448. {
  449. local float DeltaTime, clientErr, OldTimeStamp;
  450. local rotator DeltaRot, Rot;
  451. local vector Accel, LocDiff;
  452. local int maxPitch, ViewPitch, ViewYaw;
  453. local actor OldBase;
  454. local bool NewbPressedJump, OldbRun, OldbDuck;
  455. local eDodgeDir OldDodgeMove;
  456.  
  457. // If this move is outdated, discard it.
  458. if ( CurrentTimeStamp >= TimeStamp )
  459. return;
  460.  
  461. // if OldTimeDelta corresponds to a lost packet, process it first
  462. if ( OldTimeDelta != 0 )
  463. {
  464. OldTimeStamp = TimeStamp - float(OldTimeDelta)/500 - 0.001;
  465. if ( CurrentTimeStamp < OldTimeStamp - 0.001 )
  466. {
  467. // split out components of lost move (approx)
  468. Accel.X = OldAccel >>> 23;
  469. if ( Accel.X > 127 )
  470. Accel.X = -1 * (Accel.X - 128);
  471. Accel.Y = (OldAccel >>> 15) & 255;
  472. if ( Accel.Y > 127 )
  473. Accel.Y = -1 * (Accel.Y - 128);
  474. Accel.Z = (OldAccel >>> 7) & 255;
  475. if ( Accel.Z > 127 )
  476. Accel.Z = -1 * (Accel.Z - 128);
  477. Accel *= 20;
  478.  
  479. OldbRun = ( (OldAccel & 64) != 0 );
  480. OldbDuck = ( (OldAccel & 32) != 0 );
  481. NewbPressedJump = ( (OldAccel & 16) != 0 );
  482. if ( NewbPressedJump )
  483. bJumpStatus = NewbJumpStatus;
  484.  
  485. switch (OldAccel & 7)
  486. {
  487. case 0:
  488. OldDodgeMove = DODGE_None;
  489. break;
  490. case 1:
  491. OldDodgeMove = DODGE_Left;
  492. break;
  493. case 2:
  494. OldDodgeMove = DODGE_Right;
  495. break;
  496. case 3:
  497. OldDodgeMove = DODGE_Forward;
  498. break;
  499. case 4:
  500. OldDodgeMove = DODGE_Back;
  501. break;
  502. }
  503. //log("Recovered move from "$OldTimeStamp$" acceleration "$Accel$" from "$OldAccel);
  504. MoveAutonomous(OldTimeStamp - CurrentTimeStamp, OldbRun, OldbDuck, NewbPressedJump, OldDodgeMove, Accel, rot(0,0,0));
  505. CurrentTimeStamp = OldTimeStamp;
  506. }
  507. }
  508.  
  509. // View components
  510. ViewPitch = View/32768;
  511. ViewYaw = 2 * (View - 32768 * ViewPitch);
  512. ViewPitch *= 2;
  513. // Make acceleration.
  514. Accel = InAccel/10;
  515.  
  516. NewbPressedJump = (bJumpStatus != NewbJumpStatus);
  517. bJumpStatus = NewbJumpStatus;
  518.  
  519. // handle firing and alt-firing
  520. if ( bFired )
  521. {
  522. if ( bForceFire && (Weapon != None) )
  523. Weapon.ForceFire();
  524. else if ( bFire == 0 )
  525. Fire(0);
  526. bFire = 1;
  527. }
  528. else
  529. bFire = 0;
  530.  
  531.  
  532. if ( bAltFired )
  533. {
  534. if ( bForceAltFire && (Weapon != None) )
  535. Weapon.ForceAltFire();
  536. else if ( bAltFire == 0 )
  537. AltFire(0);
  538. bAltFire = 1;
  539. }
  540. else
  541. bAltFire = 0;
  542.  
  543. // Save move parameters.
  544. DeltaTime = TimeStamp - CurrentTimeStamp;
  545. if ( ServerTimeStamp > 0 )
  546. {
  547. // allow 1% error
  548. TimeMargin += DeltaTime - 1.01 * (Level.TimeSeconds - ServerTimeStamp);
  549. if ( TimeMargin > MaxTimeMargin )
  550. {
  551. // player is too far ahead
  552. TimeMargin -= DeltaTime;
  553. if ( TimeMargin < 0.5 )
  554. MaxTimeMargin = Default.MaxTimeMargin;
  555. else
  556. MaxTimeMargin = 0.5;
  557. DeltaTime = 0;
  558. }
  559. }
  560.  
  561. CurrentTimeStamp = TimeStamp;
  562. ServerTimeStamp = Level.TimeSeconds;
  563. Rot.Roll = 256 * ClientRoll;
  564. Rot.Yaw = ViewYaw;
  565. if ( (Physics == PHYS_Swimming) || (Physics == PHYS_Flying) )
  566. maxPitch = 2;
  567. else
  568. maxPitch = 1;
  569. If ( (ViewPitch > maxPitch * RotationRate.Pitch) && (ViewPitch < 65536 - maxPitch * RotationRate.Pitch) )
  570. {
  571. If (ViewPitch < 32768)
  572. Rot.Pitch = maxPitch * RotationRate.Pitch;
  573. else
  574. Rot.Pitch = 65536 - maxPitch * RotationRate.Pitch;
  575. }
  576. else
  577. Rot.Pitch = ViewPitch;
  578. DeltaRot = (Rotation - Rot);
  579. ViewRotation.Pitch = ViewPitch;
  580. ViewRotation.Yaw = ViewYaw;
  581. ViewRotation.Roll = 0;
  582. SetRotation(Rot);
  583.  
  584. OldBase = Base;
  585.  
  586. // Perform actual movement.
  587. if ( (Level.Pauser == "") && (DeltaTime > 0) )
  588. MoveAutonomous(DeltaTime, NewbRun, NewbDuck, NewbPressedJump, DodgeMove, Accel, DeltaRot);
  589.  
  590. // Accumulate movement error.
  591. if ( Level.TimeSeconds - LastUpdateTime > 500.0/Player.CurrentNetSpeed )
  592. ClientErr = 10000;
  593. else if ( Level.TimeSeconds - LastUpdateTime > 180.0/Player.CurrentNetSpeed )
  594. {
  595. LocDiff = Location - ClientLoc;
  596. ClientErr = LocDiff Dot LocDiff;
  597. }
  598.  
  599. // If client has accumulated a noticeable positional error, correct him.
  600. if ( ClientErr > 3 )
  601. {
  602. if ( Mover(Base) != None )
  603. ClientLoc = Location - Base.Location;
  604. else
  605. ClientLoc = Location;
  606. //log("Client Error at "$TimeStamp$" is "$ClientErr$" with acceleration "$Accel$" LocDiff "$LocDiff$" Physics "$Physics);
  607. LastUpdateTime = Level.TimeSeconds;
  608. ClientAdjustPosition
  609. (
  610. TimeStamp,
  611. GetStateName(),
  612. Physics,
  613. ClientLoc.X,
  614. ClientLoc.Y,
  615. ClientLoc.Z,
  616. Velocity.X,
  617. Velocity.Y,
  618. Velocity.Z,
  619. Base
  620. );
  621. }
  622. //log("Server "$Role$" moved "$self$" stamp "$TimeStamp$" location "$Location$" Acceleration "$Acceleration$" Velocity "$Velocity);
  623. }
  624.  
  625. function ProcessMove ( float DeltaTime, vector newAccel, eDodgeDir DodgeMove, rotator DeltaRot)
  626. {
  627. Acceleration = newAccel;
  628. }
  629.  
  630. final function MoveAutonomous
  631. (
  632. float DeltaTime,
  633. bool NewbRun,
  634. bool NewbDuck,
  635. bool NewbPressedJump,
  636. eDodgeDir DodgeMove,
  637. vector newAccel,
  638. rotator DeltaRot
  639. )
  640. {
  641. if ( NewbRun )
  642. bRun = 1;
  643. else
  644. bRun = 0;
  645.  
  646. if ( NewbDuck )
  647. bDuck = 1;
  648. else
  649. bDuck = 0;
  650. bPressedJump = NewbPressedJump;
  651.  
  652. HandleWalking();
  653. ProcessMove(DeltaTime, newAccel, DodgeMove, DeltaRot);
  654. AutonomousPhysics(DeltaTime);
  655. //log("Role "$Role$" moveauto time "$100 * DeltaTime$" ("$Level.TimeDilation$")");
  656. }
  657.  
  658. // ClientAdjustPosition - pass newloc and newvel in components so they don't get rounded
  659.  
  660. function ClientAdjustPosition
  661. (
  662. float TimeStamp,
  663. name newState,
  664. EPhysics newPhysics,
  665. float NewLocX,
  666. float NewLocY,
  667. float NewLocZ,
  668. float NewVelX,
  669. float NewVelY,
  670. float NewVelZ,
  671. Actor NewBase
  672. )
  673. {
  674. local Decoration Carried;
  675. local vector OldLoc, NewLocation;
  676.  
  677. if ( CurrentTimeStamp > TimeStamp )
  678. return;
  679. CurrentTimeStamp = TimeStamp;
  680.  
  681. NewLocation.X = NewLocX;
  682. NewLocation.Y = NewLocY;
  683. NewLocation.Z = NewLocZ;
  684. Velocity.X = NewVelX;
  685. Velocity.Y = NewVelY;
  686. Velocity.Z = NewVelZ;
  687.  
  688. SetBase(NewBase);
  689. if ( Mover(NewBase) != None )
  690. NewLocation += NewBase.Location;
  691.  
  692. //log("Client "$Role$" adjust "$self$" stamp "$TimeStamp$" location "$Location);
  693. Carried = CarriedDecoration;
  694. OldLoc = Location;
  695. bCanTeleport = false;
  696. SetLocation(NewLocation);
  697. bCanTeleport = true;
  698. if ( Carried != None )
  699. {
  700. CarriedDecoration = Carried;
  701. CarriedDecoration.SetLocation(NewLocation + CarriedDecoration.Location - OldLoc);
  702. CarriedDecoration.SetPhysics(PHYS_None);
  703. CarriedDecoration.SetBase(self);
  704. }
  705. SetPhysics(newPhysics);
  706.  
  707. if ( !IsInState(newState) )
  708. GotoState(newState);
  709.  
  710. bUpdatePosition = true;
  711. }
  712.  
  713. function ClientUpdatePosition()
  714. {
  715. local SavedMove CurrentMove;
  716. local int realbRun, realbDuck;
  717. local bool bRealJump;
  718.  
  719. local float AdjPCol, SavedRadius, TotalTime;
  720. local pawn SavedPawn, P;
  721. local vector Dist;
  722.  
  723. bUpdatePosition = false;
  724. realbRun= bRun;
  725. realbDuck = bDuck;
  726. bRealJump = bPressedJump;
  727. CurrentMove = SavedMoves;
  728. bUpdating = true;
  729. while ( CurrentMove != None )
  730. {
  731. if ( CurrentMove.TimeStamp <= CurrentTimeStamp )
  732. {
  733. SavedMoves = CurrentMove.NextMove;
  734. CurrentMove.NextMove = FreeMoves;
  735. FreeMoves = CurrentMove;
  736. FreeMoves.Clear();
  737. CurrentMove = SavedMoves;
  738. }
  739. else
  740. {
  741. // adjust radius of nearby players with uncertain location
  742. if ( TotalTime > 0 )
  743. ForEach AllActors(class'Pawn', P)
  744. if ( (P != self) && (P.Velocity != vect(0,0,0)) && P.bBlockPlayers )
  745. {
  746. Dist = P.Location - Location;
  747. AdjPCol = 0.0004 * PlayerReplicationInfo.Ping * ((P.Velocity - Velocity) Dot Normal(Dist));
  748. if ( VSize(Dist) < AdjPCol + P.CollisionRadius + CollisionRadius + CurrentMove.Delta * GroundSpeed * (Normal(Velocity) Dot Normal(Dist)) )
  749. {
  750. SavedPawn = P;
  751. SavedRadius = P.CollisionRadius;
  752. Dist.Z = 0;
  753. P.SetCollisionSize(FClamp(AdjPCol + P.CollisionRadius, 0.5 * P.CollisionRadius, VSize(Dist) - CollisionRadius - P.CollisionRadius), P.CollisionHeight);
  754. break;
  755. }
  756. }
  757. TotalTime += CurrentMove.Delta;
  758. MoveAutonomous(CurrentMove.Delta, CurrentMove.bRun, CurrentMove.bDuck, CurrentMove.bPressedJump, CurrentMove.DodgeMove, CurrentMove.Acceleration, rot(0,0,0));
  759. CurrentMove = CurrentMove.NextMove;
  760. if ( SavedPawn != None )
  761. {
  762. SavedPawn.SetCollisionSize(SavedRadius, P.CollisionHeight);
  763. SavedPawn = None;
  764. }
  765. }
  766. }
  767. bUpdating = false;
  768. bDuck = realbDuck;
  769. bRun = realbRun;
  770. bPressedJump = bRealJump;
  771. //log("Client adjusted "$self$" stamp "$CurrentTimeStamp$" location "$Location$" dodge "$DodgeDir);
  772. }
  773.  
  774. final function SavedMove GetFreeMove()
  775. {
  776. local SavedMove s;
  777.  
  778. if ( FreeMoves == None )
  779. return Spawn(class'SavedMove');
  780. else
  781. {
  782. s = FreeMoves;
  783. FreeMoves = FreeMoves.NextMove;
  784. s.NextMove = None;
  785. return s;
  786. }
  787. }
  788.  
  789. function int CompressAccel(int C)
  790. {
  791. if ( C >= 0 )
  792. C = Min(C, 127);
  793. else
  794. C = Min(abs(C), 127) + 128;
  795. return C;
  796. }
  797.  
  798. //
  799. // Replicate this client's desired movement to the server.
  800. //
  801. function ReplicateMove
  802. (
  803. float DeltaTime,
  804. vector NewAccel,
  805. eDodgeDir DodgeMove,
  806. rotator DeltaRot
  807. )
  808. {
  809. local SavedMove NewMove, OldMove, LastMove;
  810. local byte ClientRoll;
  811. local int i;
  812. local float OldTimeDelta, TotalTime, NetMoveDelta;
  813. local int OldAccel;
  814. local vector BuildAccel, AccelNorm;
  815.  
  816. local float AdjPCol, SavedRadius;
  817. local pawn SavedPawn, P;
  818. local vector Dist;
  819.  
  820. // Get a SavedMove actor to store the movement in.
  821. if ( PendingMove != None )
  822. {
  823. //add this move to the pending move
  824. PendingMove.TimeStamp = Level.TimeSeconds;
  825. if ( VSize(NewAccel) > 3072 )
  826. NewAccel = 3072 * Normal(NewAccel);
  827. TotalTime = PendingMove.Delta + DeltaTime;
  828. PendingMove.Acceleration = (DeltaTime * NewAccel + PendingMove.Delta * PendingMove.Acceleration)/TotalTime;
  829.  
  830. // Set this move's data.
  831. if ( PendingMove.DodgeMove == DODGE_None )
  832. PendingMove.DodgeMove = DodgeMove;
  833. PendingMove.bRun = (bRun > 0);
  834. PendingMove.bDuck = (bDuck > 0);
  835. PendingMove.bPressedJump = bPressedJump || PendingMove.bPressedJump;
  836. PendingMove.bFire = PendingMove.bFire || bJustFired || (bFire != 0);
  837. PendingMove.bForceFire = PendingMove.bForceFire || bJustFired;
  838. PendingMove.bAltFire = PendingMove.bAltFire || bJustAltFired || (bAltFire != 0);
  839. PendingMove.bForceAltFire = PendingMove.bForceAltFire || bJustFired;
  840. PendingMove.Delta = TotalTime;
  841. }
  842. if ( SavedMoves != None )
  843. {
  844. NewMove = SavedMoves;
  845. AccelNorm = Normal(NewAccel);
  846. while ( NewMove.NextMove != None )
  847. {
  848. // find most recent interesting move to send redundantly
  849. if ( NewMove.bPressedJump || ((NewMove.DodgeMove != Dodge_NONE) && (NewMove.DodgeMove < 5))
  850. || ((NewMove.Acceleration != NewAccel) && ((normal(NewMove.Acceleration) Dot AccelNorm) < 0.95)) )
  851. OldMove = NewMove;
  852. NewMove = NewMove.NextMove;
  853. }
  854. if ( NewMove.bPressedJump || ((NewMove.DodgeMove != Dodge_NONE) && (NewMove.DodgeMove < 5))
  855. || ((NewMove.Acceleration != NewAccel) && ((normal(NewMove.Acceleration) Dot AccelNorm) < 0.95)) )
  856. OldMove = NewMove;
  857. }
  858.  
  859. LastMove = NewMove;
  860. NewMove = GetFreeMove();
  861. NewMove.Delta = DeltaTime;
  862. if ( VSize(NewAccel) > 3072 )
  863. NewAccel = 3072 * Normal(NewAccel);
  864. NewMove.Acceleration = NewAccel;
  865.  
  866. // Set this move's data.
  867. NewMove.DodgeMove = DodgeMove;
  868. NewMove.TimeStamp = Level.TimeSeconds;
  869. NewMove.bRun = (bRun > 0);
  870. NewMove.bDuck = (bDuck > 0);
  871. NewMove.bPressedJump = bPressedJump;
  872. NewMove.bFire = (bJustFired || (bFire != 0));
  873. NewMove.bForceFire = bJustFired;
  874. NewMove.bAltFire = (bJustAltFired || (bAltFire != 0));
  875. NewMove.bForceAltFire = bJustAltFired;
  876. if ( Weapon != None ) // approximate pointing so don't have to replicate
  877. Weapon.bPointing = ((bFire != 0) || (bAltFire != 0));
  878. bJustFired = false;
  879. bJustAltFired = false;
  880.  
  881. // adjust radius of nearby players with uncertain location
  882. ForEach AllActors(class'Pawn', P)
  883. if ( (P != self) && (P.Velocity != vect(0,0,0)) && P.bBlockPlayers )
  884. {
  885. Dist = P.Location - Location;
  886. if (PlayerReplicationInfo != None)
  887. {
  888. AdjPCol = 0.0004 * PlayerReplicationInfo.Ping * ((P.Velocity - Velocity) Dot Normal(Dist));
  889. if ( VSize(Dist) < AdjPCol + P.CollisionRadius + CollisionRadius + NewMove.Delta * GroundSpeed * (Normal(Velocity) Dot Normal(Dist)) )
  890. {
  891. SavedPawn = P;
  892. SavedRadius = P.CollisionRadius;
  893. Dist.Z = 0;
  894. P.SetCollisionSize(FClamp(AdjPCol + P.CollisionRadius, 0.5 * P.CollisionRadius, VSize(Dist) - CollisionRadius - P.CollisionRadius), P.CollisionHeight);
  895. break;
  896. }
  897. }
  898. }
  899.  
  900. // Simulate the movement locally.
  901. ProcessMove(NewMove.Delta, NewMove.Acceleration, NewMove.DodgeMove, DeltaRot);
  902. AutonomousPhysics(NewMove.Delta);
  903. if ( SavedPawn != None )
  904. SavedPawn.SetCollisionSize(SavedRadius, P.CollisionHeight);
  905.  
  906. //log("Role "$Role$" repmove at "$Level.TimeSeconds$" Move time "$100 * DeltaTime$" ("$Level.TimeDilation$")");
  907.  
  908. // Decide whether to hold off on move
  909. // send if dodge, jump, or fire unless really too soon, or if newmove.delta big enough
  910. // on client side, save extra buffered time in LastUpdateTime
  911. if ( PendingMove == None )
  912. PendingMove = NewMove;
  913. else
  914. {
  915. NewMove.NextMove = FreeMoves;
  916. FreeMoves = NewMove;
  917. FreeMoves.Clear();
  918. NewMove = PendingMove;
  919. }
  920. NetMoveDelta = FMax(64.0/Player.CurrentNetSpeed, 0.011);
  921.  
  922. if ( !PendingMove.bForceFire && !PendingMove.bForceAltFire && !PendingMove.bPressedJump
  923. && (PendingMove.Delta < NetMoveDelta - ClientUpdateTime) )
  924. {
  925. // save as pending move
  926. return;
  927. }
  928. else if ( (ClientUpdateTime < 0) && (PendingMove.Delta < NetMoveDelta - ClientUpdateTime) )
  929. return;
  930. else
  931. {
  932. ClientUpdateTime = PendingMove.Delta - NetMoveDelta;
  933. if ( SavedMoves == None )
  934. SavedMoves = PendingMove;
  935. else
  936. LastMove.NextMove = PendingMove;
  937. PendingMove = None;
  938. }
  939.  
  940. // check if need to redundantly send previous move
  941. if ( OldMove != None )
  942. {
  943. // log("Redundant send timestamp "$OldMove.TimeStamp$" accel "$OldMove.Acceleration$" at "$Level.Timeseconds$" New accel "$NewAccel);
  944. // old move important to replicate redundantly
  945. OldTimeDelta = FMin(255, (Level.TimeSeconds - OldMove.TimeStamp) * 500);
  946. BuildAccel = 0.05 * OldMove.Acceleration + vect(0.5, 0.5, 0.5);
  947. OldAccel = (CompressAccel(BuildAccel.X) << 23)
  948. + (CompressAccel(BuildAccel.Y) << 15)
  949. + (CompressAccel(BuildAccel.Z) << 7);
  950. if ( OldMove.bRun )
  951. OldAccel += 64;
  952. if ( OldMove.bDuck )
  953. OldAccel += 32;
  954. if ( OldMove.bPressedJump )
  955. OldAccel += 16;
  956. OldAccel += OldMove.DodgeMove;
  957. }
  958. //else
  959. // log("No redundant timestamp at "$Level.TimeSeconds$" with accel "$NewAccel);
  960.  
  961. // Send to the server
  962. ClientRoll = (Rotation.Roll >> 8) & 255;
  963. if ( NewMove.bPressedJump )
  964. bJumpStatus = !bJumpStatus;
  965. ServerMove
  966. (
  967. NewMove.TimeStamp,
  968. NewMove.Acceleration * 10,
  969. Location,
  970. NewMove.bRun,
  971. NewMove.bDuck,
  972. bJumpStatus,
  973. NewMove.bFire,
  974. NewMove.bAltFire,
  975. NewMove.bForceFire,
  976. NewMove.bForceAltFire,
  977. NewMove.DodgeMove,
  978. ClientRoll,
  979. (32767 & (ViewRotation.Pitch/2)) * 32768 + (32767 & (ViewRotation.Yaw/2)),
  980. OldTimeDelta,
  981. OldAccel
  982. );
  983. //log("Replicated "$self$" stamp "$NewMove.TimeStamp$" location "$Location$" dodge "$NewMove.DodgeMove$" to "$DodgeDir);
  984. }
  985.  
  986. function HandleWalking()
  987. {
  988. local rotator carried;
  989.  
  990. bIsWalking = ((bRun != 0) || (bDuck != 0)) && !Region.Zone.IsA('WarpZoneInfo');
  991. if ( CarriedDecoration != None )
  992. {
  993. if ( (Role == ROLE_Authority) && (standingcount == 0) )
  994. CarriedDecoration = None;
  995. if ( CarriedDecoration != None ) //verify its still in front
  996. {
  997. bIsWalking = true;
  998. if ( Role == ROLE_Authority )
  999. {
  1000. carried = Rotator(CarriedDecoration.Location - Location);
  1001. carried.Yaw = ((carried.Yaw & 65535) - (Rotation.Yaw & 65535)) & 65535;
  1002. if ( (carried.Yaw > 3072) && (carried.Yaw < 62463) )
  1003. DropDecoration();
  1004. }
  1005. }
  1006. }
  1007. }
  1008.  
  1009. //----------------------------------------------
  1010.  
  1011. simulated event Destroyed()
  1012. {
  1013. Super.Destroyed();
  1014. if ( myHud != None )
  1015. myHud.Destroy();
  1016. if ( Scoring != None )
  1017. Scoring.Destroy();
  1018.  
  1019. While ( FreeMoves != None )
  1020. {
  1021. FreeMoves.Destroy();
  1022. FreeMoves = FreeMoves.NextMove;
  1023. }
  1024.  
  1025. While ( SavedMoves != None )
  1026. {
  1027. SavedMoves.Destroy();
  1028. SavedMoves = SavedMoves.NextMove;
  1029. }
  1030. }
  1031.  
  1032. function ServerReStartGame()
  1033. {
  1034. }
  1035.  
  1036. function PlayHit(float Damage, vector HitLocation, name damageType, vector Momentum)
  1037. {
  1038. Level.Game.SpecialDamageString = "";
  1039. }
  1040.  
  1041. function SetFOVAngle(float newFOV)
  1042. {
  1043. FOVAngle = newFOV;
  1044. }
  1045.  
  1046. function ClientFlash( float scale, vector fog )
  1047. {
  1048. DesiredFlashScale = scale;
  1049. DesiredFlashFog = 0.001 * fog;
  1050. }
  1051.  
  1052. function ClientInstantFlash( float scale, vector fog )
  1053. {
  1054. InstantFlash = scale;
  1055. InstantFog = 0.001 * fog;
  1056. }
  1057.  
  1058. //Play a sound client side (so only client will hear it
  1059. simulated function ClientPlaySound(sound ASound, optional bool bInterrupt, optional bool bVolumeControl )
  1060. {
  1061. local actor SoundPlayer;
  1062.  
  1063. LastPlaySound = Level.TimeSeconds; // so voice messages won't overlap
  1064. if ( ViewTarget != None )
  1065. SoundPlayer = ViewTarget;
  1066. else
  1067. SoundPlayer = self;
  1068.  
  1069. SoundPlayer.PlaySound(ASound, SLOT_None, 16.0, bInterrupt);
  1070. SoundPlayer.PlaySound(ASound, SLOT_Interface, 16.0, bInterrupt);
  1071. SoundPlayer.PlaySound(ASound, SLOT_Misc, 16.0, bInterrupt);
  1072. SoundPlayer.PlaySound(ASound, SLOT_Talk, 16.0, bInterrupt);
  1073. }
  1074.  
  1075. simulated function ClientReliablePlaySound(sound ASound, optional bool bInterrupt, optional bool bVolumeControl )
  1076. {
  1077. ClientPlaySound(ASound, bInterrupt, bVolumeControl);
  1078. }
  1079.  
  1080. function ClientAdjustGlow( float scale, vector fog )
  1081. {
  1082. ConstantGlowScale += scale;
  1083. ConstantGlowFog += 0.001 * fog;
  1084. }
  1085.  
  1086. function ClientShake(vector shake)
  1087. {
  1088. if ( (shakemag < shake.X) || (shaketimer <= 0.01 * shake.Y) )
  1089. {
  1090. shakemag = shake.X;
  1091. shaketimer = 0.01 * shake.Y;
  1092. maxshake = 0.01 * shake.Z;
  1093. verttimer = 0;
  1094. ShakeVert = -1.1 * maxshake;
  1095. }
  1096. }
  1097.  
  1098. function ShakeView( float shaketime, float RollMag, float vertmag)
  1099. {
  1100. local vector shake;
  1101.  
  1102. shake.X = RollMag;
  1103. shake.Y = 100 * shaketime;
  1104. shake.Z = 100 * vertmag;
  1105. ClientShake(shake);
  1106. }
  1107.  
  1108. function ClientSetMusic( music NewSong, byte NewSection, byte NewCdTrack, EMusicTransition NewTransition )
  1109. {
  1110. Song = NewSong;
  1111. SongSection = NewSection;
  1112. CdTrack = NewCdTrack;
  1113. Transition = NewTransition;
  1114. }
  1115.  
  1116.  
  1117. function ServerSetHandedness( float hand)
  1118. {
  1119. Handedness = hand;
  1120. if ( Weapon != None )
  1121. Weapon.SetHand(Handedness);
  1122. }
  1123.  
  1124. function ServerReStartPlayer()
  1125. {
  1126. }
  1127.  
  1128. function ServerChangeSkin( coerce string SkinName, coerce string FaceName, byte TeamNum )
  1129. {
  1130. local string MeshName;
  1131.  
  1132. MeshName = GetItemName(string(Mesh));
  1133. if ( Level.Game.bCanChangeSkin )
  1134. {
  1135. Self.static.SetMultiSkin(Self, SkinName, FaceName, TeamNum );
  1136. }
  1137. }
  1138.  
  1139. //*************************************************************************************
  1140. // Normal gameplay execs
  1141. // Type the name of the exec function at the console to execute it
  1142.  
  1143. exec function ShowSpecialMenu( string ClassName )
  1144. {
  1145. local class<menu> aMenuClass;
  1146.  
  1147. aMenuClass = class<menu>( DynamicLoadObject( ClassName, class'Class' ) );
  1148. if( aMenuClass!=None )
  1149. {
  1150. bSpecialMenu = true;
  1151. SpecialMenu = aMenuClass;
  1152. ShowMenu();
  1153. }
  1154. }
  1155.  
  1156. exec function Jump( optional float F )
  1157. {
  1158. if ( !bShowMenu && (Level.Pauser == PlayerReplicationInfo.PlayerName) )
  1159. SetPause(False);
  1160. else
  1161. bPressedJump = true;
  1162. }
  1163.  
  1164. function bool CanICheat()
  1165. {
  1166. return false;
  1167. }
  1168.  
  1169.  
  1170. exec function CauseEvent( name N )
  1171. {
  1172. local actor A;
  1173. if( !CanICheat() )
  1174. return;
  1175. if( (bAdmin || (Level.Netmode == NM_Standalone)) && (N != '') )
  1176. foreach AllActors( class 'Actor', A, N )
  1177. A.Trigger( Self, Self );
  1178. }
  1179.  
  1180. exec function Taunt( name Sequence )
  1181. {
  1182. if ( GetAnimGroup(Sequence) == 'Gesture' )
  1183. {
  1184. ServerTaunt(Sequence);
  1185. PlayAnim(Sequence, 0.7, 0.2);
  1186. }
  1187. }
  1188.  
  1189. function ServerTaunt(name Sequence )
  1190. {
  1191. PlayAnim(Sequence, 0.7, 0.2);
  1192. }
  1193.  
  1194. exec function CallForHelp()
  1195. {
  1196. local Pawn P;
  1197.  
  1198. if ( !Level.Game.bTeamGame || (Enemy == None) || (Enemy.Health <= 0) )
  1199. return;
  1200.  
  1201. for ( P=Level.PawnList; P!=None; P=P.NextPawn )
  1202. if ( P.bIsPlayer && (P.PlayerReplicationInfo.Team == PlayerReplicationInfo.Team) )
  1203. P.HandleHelpMessageFrom(self);
  1204. }
  1205.  
  1206. function damageAttitudeTo(pawn Other)
  1207. {
  1208. if ( Other != Self )
  1209. Enemy = Other;
  1210. }
  1211.  
  1212. exec function Grab()
  1213. {
  1214. if (CarriedDecoration == None)
  1215. GrabDecoration();
  1216. else
  1217. DropDecoration();
  1218. }
  1219.  
  1220. // Send a voice message of a certain type to a certain player.
  1221. exec function Speech( int Type, int Index, int Callsign )
  1222. {
  1223. local VoicePack V;
  1224.  
  1225. V = Spawn( PlayerReplicationInfo.VoiceType, Self );
  1226. if (V != None)
  1227. V.PlayerSpeech( Type, Index, Callsign );
  1228. }
  1229.  
  1230. function PlayChatting();
  1231.  
  1232. function Typing( bool bTyping )
  1233. {
  1234. bIsTyping = bTyping;
  1235. if (bTyping)
  1236. {
  1237. if (Level.Game.WorldLog != None)
  1238. Level.Game.WorldLog.LogTypingEvent(True, Self);
  1239. if (Level.Game.LocalLog != None)
  1240. Level.Game.LocalLog.LogTypingEvent(True, Self);
  1241. PlayChatting();
  1242. }
  1243. else
  1244. {
  1245. if (Level.Game.WorldLog != None)
  1246. Level.Game.WorldLog.LogTypingEvent(False, Self);
  1247. if (Level.Game.LocalLog != None)
  1248. Level.Game.LocalLog.LogTypingEvent(False, Self);
  1249. }
  1250. }
  1251.  
  1252. // Send a message to all players.
  1253. exec function Say( string Msg )
  1254. {
  1255. local Pawn P;
  1256.  
  1257. if ( Level.Game.AllowsBroadcast(self, Len(Msg)) )
  1258. for( P=Level.PawnList; P!=None; P=P.nextPawn )
  1259. if( P.bIsPlayer || P.IsA('MessagingSpectator') )
  1260. {
  1261. if ( (Level.Game != None) && (Level.Game.MessageMutator != None) )
  1262. {
  1263. if ( Level.Game.MessageMutator.MutatorTeamMessage(Self, P, PlayerReplicationInfo, Msg, 'Say', true) )
  1264. P.TeamMessage( PlayerReplicationInfo, Msg, 'Say', true );
  1265. } else
  1266. P.TeamMessage( PlayerReplicationInfo, Msg, 'Say', true );
  1267. }
  1268. return;
  1269. }
  1270.  
  1271. exec function TeamSay( string Msg )
  1272. {
  1273. local Pawn P;
  1274.  
  1275. if ( !Level.Game.bTeamGame )
  1276. {
  1277. Say(Msg);
  1278. return;
  1279. }
  1280.  
  1281. if ( Msg ~= "Help" )
  1282. {
  1283. CallForHelp();
  1284. return;
  1285. }
  1286.  
  1287. if ( Level.Game.AllowsBroadcast(self, Len(Msg)) )
  1288. for( P=Level.PawnList; P!=None; P=P.nextPawn )
  1289. if( P.bIsPlayer && (P.PlayerReplicationInfo.Team == PlayerReplicationInfo.Team) )
  1290. {
  1291. if ( P.IsA('PlayerPawn') )
  1292. {
  1293. if ( (Level.Game != None) && (Level.Game.MessageMutator != None) )
  1294. {
  1295. if ( Level.Game.MessageMutator.MutatorTeamMessage(Self, P, PlayerReplicationInfo, Msg, 'TeamSay', true) )
  1296. P.TeamMessage( PlayerReplicationInfo, Msg, 'TeamSay', true );
  1297. } else
  1298. P.TeamMessage( PlayerReplicationInfo, Msg, 'TeamSay', true );
  1299. }
  1300. }
  1301. }
  1302.  
  1303. exec function RestartLevel()
  1304. {
  1305. if( bAdmin || Level.Netmode==NM_Standalone )
  1306. ClientTravel( "?restart", TRAVEL_Relative, false );
  1307. }
  1308.  
  1309. exec function LocalTravel( string URL )
  1310. {
  1311. if( bAdmin || Level.Netmode==NM_Standalone )
  1312. ClientTravel( URL, TRAVEL_Relative, true );
  1313. }
  1314.  
  1315. exec function ThrowWeapon()
  1316. {
  1317. if( Level.NetMode == NM_Client )
  1318. return;
  1319. if( Weapon==None || (Weapon.Class==Level.Game.BaseMutator.MutatedDefaultWeapon())
  1320. || !Weapon.bCanThrow )
  1321. return;
  1322. Weapon.Velocity = Vector(ViewRotation) * 500 + vect(0,0,220);
  1323. Weapon.bTossedOut = true;
  1324. TossWeapon();
  1325. if ( Weapon == None )
  1326. SwitchToBestWeapon();
  1327. }
  1328.  
  1329. function ToggleZoom()
  1330. {
  1331. if ( DefaultFOV != DesiredFOV )
  1332. EndZoom();
  1333. else
  1334. StartZoom();
  1335. }
  1336.  
  1337. function StartZoom()
  1338. {
  1339. ZoomLevel = 0.0;
  1340. bZooming = true;
  1341. }
  1342.  
  1343. function StopZoom()
  1344. {
  1345. bZooming = false;
  1346. }
  1347.  
  1348. function EndZoom()
  1349. {
  1350. bZooming = false;
  1351. DesiredFOV = DefaultFOV;
  1352. }
  1353.  
  1354. exec function FOV(float F)
  1355. {
  1356. SetDesiredFOV(F);
  1357. }
  1358.  
  1359. exec function SetDesiredFOV(float F)
  1360. {
  1361. if( (F >= 80.0) || Level.bAllowFOV || bAdmin || (Level.Netmode==NM_Standalone) )
  1362. {
  1363. DefaultFOV = FClamp(F, 1, 170);
  1364. DesiredFOV = DefaultFOV;
  1365. SaveConfig();
  1366. }
  1367. }
  1368.  
  1369. /* PrevWeapon()
  1370. - switch to previous inventory group weapon
  1371. */
  1372. exec function PrevWeapon()
  1373. {
  1374. local int prevGroup;
  1375. local Inventory inv;
  1376. local Weapon realWeapon, w, Prev;
  1377. local bool bFoundWeapon;
  1378.  
  1379. if( bShowMenu || Level.Pauser!="" )
  1380. return;
  1381. if ( Weapon == None )
  1382. {
  1383. SwitchToBestWeapon();
  1384. return;
  1385. }
  1386. prevGroup = 0;
  1387. realWeapon = Weapon;
  1388. if ( PendingWeapon != None )
  1389. Weapon = PendingWeapon;
  1390. PendingWeapon = None;
  1391.  
  1392. for (inv=Inventory; inv!=None; inv=inv.Inventory)
  1393. {
  1394. w = Weapon(inv);
  1395. if ( w != None )
  1396. {
  1397. if ( w.InventoryGroup == Weapon.InventoryGroup )
  1398. {
  1399. if ( w == Weapon )
  1400. {
  1401. bFoundWeapon = true;
  1402. if ( Prev != None )
  1403. {
  1404. PendingWeapon = Prev;
  1405. break;
  1406. }
  1407. }
  1408. else if ( !bFoundWeapon && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0)) )
  1409. Prev = W;
  1410. }
  1411. else if ( (w.InventoryGroup < Weapon.InventoryGroup)
  1412. && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0))
  1413. && (w.InventoryGroup >= prevGroup) )
  1414. {
  1415. prevGroup = w.InventoryGroup;
  1416. PendingWeapon = w;
  1417. }
  1418. }
  1419. }
  1420. bFoundWeapon = false;
  1421. prevGroup = Weapon.InventoryGroup;
  1422. if ( PendingWeapon == None )
  1423. for (inv=Inventory; inv!=None; inv=inv.Inventory)
  1424. {
  1425. w = Weapon(inv);
  1426. if ( w != None )
  1427. {
  1428. if ( w.InventoryGroup == Weapon.InventoryGroup )
  1429. {
  1430. if ( w == Weapon )
  1431. bFoundWeapon = true;
  1432. else if ( bFoundWeapon && (PendingWeapon == None) && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0)) )
  1433. PendingWeapon = W;
  1434. }
  1435. else if ( (w.InventoryGroup > PrevGroup)
  1436. && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0)) )
  1437. {
  1438. prevGroup = w.InventoryGroup;
  1439. PendingWeapon = w;
  1440. }
  1441. }
  1442. }
  1443.  
  1444. Weapon = realWeapon;
  1445. if ( PendingWeapon == None )
  1446. return;
  1447.  
  1448. Weapon.PutDown();
  1449. }
  1450.  
  1451. /* NextWeapon()
  1452. - switch to next inventory group weapon
  1453. */
  1454. exec function NextWeapon()
  1455. {
  1456. local int nextGroup;
  1457. local Inventory inv;
  1458. local Weapon realWeapon, w, Prev;
  1459. local bool bFoundWeapon;
  1460.  
  1461. if( bShowMenu || Level.Pauser!="" )
  1462. return;
  1463. if ( Weapon == None )
  1464. {
  1465. SwitchToBestWeapon();
  1466. return;
  1467. }
  1468. nextGroup = 100;
  1469. realWeapon = Weapon;
  1470. if ( PendingWeapon != None )
  1471. Weapon = PendingWeapon;
  1472. PendingWeapon = None;
  1473.  
  1474. for (inv=Inventory; inv!=None; inv=inv.Inventory)
  1475. {
  1476. w = Weapon(inv);
  1477. if ( w != None )
  1478. {
  1479. if ( w.InventoryGroup == Weapon.InventoryGroup )
  1480. {
  1481. if ( w == Weapon )
  1482. bFoundWeapon = true;
  1483. else if ( bFoundWeapon && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0)) )
  1484. {
  1485. PendingWeapon = W;
  1486. break;
  1487. }
  1488. }
  1489. else if ( (w.InventoryGroup > Weapon.InventoryGroup)
  1490. && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0))
  1491. && (w.InventoryGroup < nextGroup) )
  1492. {
  1493. nextGroup = w.InventoryGroup;
  1494. PendingWeapon = w;
  1495. }
  1496. }
  1497. }
  1498.  
  1499. bFoundWeapon = false;
  1500. nextGroup = Weapon.InventoryGroup;
  1501. if ( PendingWeapon == None )
  1502. for (inv=Inventory; inv!=None; inv=inv.Inventory)
  1503. {
  1504. w = Weapon(Inv);
  1505. if ( w != None )
  1506. {
  1507. if ( w.InventoryGroup == Weapon.InventoryGroup )
  1508. {
  1509. if ( w == Weapon )
  1510. {
  1511. bFoundWeapon = true;
  1512. if ( Prev != None )
  1513. PendingWeapon = Prev;
  1514. }
  1515. else if ( !bFoundWeapon && (PendingWeapon == None) && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0)) )
  1516. Prev = W;
  1517. }
  1518. else if ( (w.InventoryGroup < nextGroup)
  1519. && ((w.AmmoType == None) || (w.AmmoType.AmmoAmount>0)) )
  1520. {
  1521. nextGroup = w.InventoryGroup;
  1522. PendingWeapon = w;
  1523. }
  1524. }
  1525. }
  1526.  
  1527. Weapon = realWeapon;
  1528. if ( PendingWeapon == None )
  1529. return;
  1530.  
  1531. Weapon.PutDown();
  1532. }
  1533.  
  1534. exec function Mutate(string MutateString)
  1535. {
  1536. if( Level.NetMode == NM_Client )
  1537. return;
  1538. Level.Game.BaseMutator.Mutate(MutateString, Self);
  1539. }
  1540.  
  1541. exec function QuickSave()
  1542. {
  1543. if ( (Health > 0)
  1544. && (Level.NetMode == NM_Standalone)
  1545. && !Level.Game.bDeathMatch )
  1546. {
  1547. ClientMessage(QuickSaveString);
  1548. ConsoleCommand("SaveGame 9");
  1549. }
  1550. }
  1551.  
  1552. exec function QuickLoad()
  1553. {
  1554. if ( (Level.NetMode == NM_Standalone)
  1555. && !Level.Game.bDeathMatch )
  1556. ClientTravel( "?load=9", TRAVEL_Absolute, false);
  1557. }
  1558.  
  1559. exec function Kick( string S )
  1560. {
  1561. local Pawn aPawn;
  1562. if( !bAdmin )
  1563. return;
  1564. for( aPawn=Level.PawnList; aPawn!=None; aPawn=aPawn.NextPawn )
  1565. if
  1566. ( aPawn.bIsPlayer
  1567. && aPawn.PlayerReplicationInfo.PlayerName~=S
  1568. && (PlayerPawn(aPawn)==None || NetConnection(PlayerPawn(aPawn).Player)!=None ) )
  1569. {
  1570. aPawn.Destroy();
  1571. return;
  1572. }
  1573. }
  1574.  
  1575. exec function KickBan( string S )
  1576. {
  1577. local Pawn aPawn;
  1578. local string IP;
  1579. local int j;
  1580. if( !bAdmin )
  1581. return;
  1582. for( aPawn=Level.PawnList; aPawn!=None; aPawn=aPawn.NextPawn )
  1583. if
  1584. ( aPawn.bIsPlayer
  1585. && aPawn.PlayerReplicationInfo.PlayerName~=S
  1586. && (PlayerPawn(aPawn)==None || NetConnection(PlayerPawn(aPawn).Player)!=None ) )
  1587. {
  1588. IP = PlayerPawn(aPawn).GetPlayerNetworkAddress();
  1589. if(Level.Game.CheckIPPolicy(IP))
  1590. {
  1591. IP = Left(IP, InStr(IP, ":"));
  1592. Log("Adding IP Ban for: "$IP);
  1593. for(j=0;j<50;j++)
  1594. if(Level.Game.IPPolicies[j] == "")
  1595. break;
  1596. if(j < 50)
  1597. Level.Game.IPPolicies[j] = "DENY,"$IP;
  1598. Level.Game.SaveConfig();
  1599. }
  1600. aPawn.Destroy();
  1601. return;
  1602. }
  1603. }
  1604.  
  1605. // Try to set the pause state; returns success indicator.
  1606. function bool SetPause( BOOL bPause )
  1607. {
  1608. return Level.Game.SetPause(bPause, self);
  1609. }
  1610.  
  1611. exec function SetMouseSmoothThreshold( float F )
  1612. {
  1613. MouseSmoothThreshold = FClamp(F, 0, 0.1);
  1614. SaveConfig();
  1615. }
  1616.  
  1617. exec function SetMaxMouseSmoothing( bool B )
  1618. {
  1619. bMaxMouseSmoothing = B;
  1620. SaveConfig();
  1621. }
  1622.  
  1623. // Try to pause the game.
  1624. exec function Pause()
  1625. {
  1626. if ( bShowMenu )
  1627. return;
  1628. if( !SetPause(Level.Pauser=="") )
  1629. ClientMessage(NoPauseMessage);
  1630. }
  1631.  
  1632. // Activate specific inventory item
  1633. exec function ActivateInventoryItem( class InvItem )
  1634. {
  1635. local Inventory Inv;
  1636.  
  1637. Inv = FindInventoryType(InvItem);
  1638. if ( Inv != None )
  1639. Inv.Activate();
  1640. }
  1641.  
  1642. // Translator Hotkey
  1643. exec function ActivateTranslator()
  1644. {
  1645. if ( bShowMenu || Level.Pauser!="" )
  1646. return;
  1647. If (Inventory!=None) Inventory.ActivateTranslator(False);
  1648. }
  1649.  
  1650. // Translator Hotkey
  1651. exec function ActivateHint()
  1652. {
  1653. if ( bShowMenu || Level.Pauser!="" )
  1654. return;
  1655. If (Inventory!=None) Inventory.ActivateTranslator(True);
  1656. }
  1657.  
  1658. // HUD
  1659. exec function ChangeHud()
  1660. {
  1661. if ( myHud != None )
  1662. myHUD.ChangeHud(1);
  1663. myHUD.SaveConfig();
  1664. }
  1665.  
  1666. // Crosshair
  1667. exec function ChangeCrosshair()
  1668. {
  1669. if ( myHud != None )
  1670. myHUD.ChangeCrosshair(1);
  1671. myHUD.SaveConfig();
  1672. }
  1673.  
  1674.  
  1675. event PreRender( canvas Canvas )
  1676. {
  1677. if ( myHud != None )
  1678. myHUD.PreRender(Canvas);
  1679. else if ( (Viewport(Player) != None) && (HUDType != None) )
  1680. myHUD = spawn(HUDType, self);
  1681. }
  1682.  
  1683. event PostRender( canvas Canvas )
  1684. {
  1685. if ( myHud != None )
  1686. myHUD.PostRender(Canvas);
  1687. else if ( (Viewport(Player) != None) && (HUDType != None) )
  1688. myHUD = spawn(HUDType, self);
  1689. }
  1690.  
  1691. //=============================================================================
  1692. // Inventory-related input notifications.
  1693.  
  1694. // Handle function keypress for F1-F10.
  1695. exec function FunctionKey( byte Num )
  1696. {
  1697. }
  1698.  
  1699. // The player wants to switch to weapon group numer I.
  1700. exec function SwitchWeapon (byte F )
  1701. {
  1702. local weapon newWeapon;
  1703.  
  1704. if ( bShowMenu || Level.Pauser!="" )
  1705. {
  1706. if ( myHud != None )
  1707. myHud.InputNumber(F);
  1708. return;
  1709. }
  1710. if ( Inventory == None )
  1711. return;
  1712. if ( (Weapon != None) && (Weapon.Inventory != None) )
  1713. newWeapon = Weapon.Inventory.WeaponChange(F);
  1714. else
  1715. newWeapon = None;
  1716. if ( newWeapon == None )
  1717. newWeapon = Inventory.WeaponChange(F);
  1718. if ( newWeapon == None )
  1719. return;
  1720.  
  1721. if ( Weapon == None )
  1722. {
  1723. PendingWeapon = newWeapon;
  1724. ChangedWeapon();
  1725. }
  1726. else if ( Weapon != newWeapon )
  1727. {
  1728. PendingWeapon = newWeapon;
  1729. if ( !Weapon.PutDown() )
  1730. PendingWeapon = None;
  1731. }
  1732. }
  1733.  
  1734. exec function GetWeapon(class<Weapon> NewWeaponClass )
  1735. {
  1736. local Inventory Inv;
  1737.  
  1738. if ( (Inventory == None) || (NewWeaponClass == None)
  1739. || ((Weapon != None) && (Weapon.Class == NewWeaponClass)) )
  1740. return;
  1741.  
  1742. for ( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
  1743. if ( Inv.Class == NewWeaponClass )
  1744. {
  1745. PendingWeapon = Weapon(Inv);
  1746. if ( (PendingWeapon.AmmoType != None) && (PendingWeapon.AmmoType.AmmoAmount <= 0) )
  1747. {
  1748. Pawn(Owner).ClientMessage( PendingWeapon.ItemName$PendingWeapon.MessageNoAmmo );
  1749. PendingWeapon = None;
  1750. return;
  1751. }
  1752. Weapon.PutDown();
  1753. return;
  1754. }
  1755. }
  1756.  
  1757. // The player wants to select previous item
  1758. exec function PrevItem()
  1759. {
  1760. local Inventory Inv, LastItem;
  1761.  
  1762. if ( bShowMenu || Level.Pauser!="" )
  1763. return;
  1764. if (SelectedItem==None) {
  1765. SelectedItem = Inventory.SelectNext();
  1766. Return;
  1767. }
  1768. if (SelectedItem.Inventory!=None)
  1769. for( Inv=SelectedItem.Inventory; Inv!=None; Inv=Inv.Inventory ) {
  1770. if (Inv==None) Break;
  1771. if (Inv.bActivatable) LastItem=Inv;
  1772. }
  1773. for( Inv=Inventory; Inv!=SelectedItem; Inv=Inv.Inventory ) {
  1774. if (Inv==None) Break;
  1775. if (Inv.bActivatable) LastItem=Inv;
  1776. }
  1777. if (LastItem!=None) {
  1778. SelectedItem = LastItem;
  1779. ClientMessage(SelectedItem.ItemName$SelectedItem.M_Selected);
  1780. }
  1781. }
  1782.  
  1783. // The player wants to active selected item
  1784. exec function ActivateItem()
  1785. {
  1786. if( bShowMenu || Level.Pauser!="" )
  1787. return;
  1788. if (SelectedItem!=None)
  1789. SelectedItem.Activate();
  1790. }
  1791.  
  1792. // The player wants to fire.
  1793. exec function Fire( optional float F )
  1794. {
  1795. bJustFired = true;
  1796. if( bShowMenu || (Level.Pauser!="") || (Role < ROLE_Authority) )
  1797. {
  1798. if( (Role < ROLE_Authority) && (Weapon!=None) )
  1799. bJustFired = Weapon.ClientFire(F);
  1800. if ( !bShowMenu && (Level.Pauser == PlayerReplicationInfo.PlayerName) )
  1801. SetPause(False);
  1802. return;
  1803. }
  1804. if( Weapon!=None )
  1805. {
  1806. Weapon.bPointing = true;
  1807. PlayFiring();
  1808. Weapon.Fire(F);
  1809. }
  1810. }
  1811.  
  1812. // The player wants to alternate-fire.
  1813. exec function AltFire( optional float F )
  1814. {
  1815. bJustAltFired = true;
  1816. if( bShowMenu || (Level.Pauser!="") || (Role < ROLE_Authority) )
  1817. {
  1818. if( (Role < ROLE_Authority) && (Weapon!=None) )
  1819. bJustAltFired = Weapon.ClientAltFire(F);
  1820. if ( !bShowMenu && (Level.Pauser == PlayerReplicationInfo.PlayerName) )
  1821. SetPause(False);
  1822. return;
  1823. }
  1824. if( Weapon!=None )
  1825. {
  1826. Weapon.bPointing = true;
  1827. PlayFiring();
  1828. Weapon.AltFire(F);
  1829. }
  1830. }
  1831.  
  1832. //Player Jumped
  1833. function DoJump( optional float F )
  1834. {
  1835. if ( CarriedDecoration != None )
  1836. return;
  1837. if ( !bIsCrouching && (Physics == PHYS_Walking) )
  1838. {
  1839. if ( !bUpdating )
  1840. PlayOwnedSound(JumpSound, SLOT_Talk, 1.5, true, 1200, 1.0 );
  1841. if ( (Level.Game != None) && (Level.Game.Difficulty > 0) )
  1842. MakeNoise(0.1 * Level.Game.Difficulty);
  1843. PlayInAir();
  1844. if ( bCountJumps && (Role == ROLE_Authority) && (Inventory != None) )
  1845. Inventory.OwnerJumped();
  1846. Velocity.Z = JumpZ;
  1847. if ( (Base != Level) && (Base != None) )
  1848. Velocity.Z += Base.Velocity.Z;
  1849. SetPhysics(PHYS_Falling);
  1850. }
  1851. }
  1852.  
  1853. exec function Suicide()
  1854. {
  1855. KilledBy( None );
  1856. }
  1857.  
  1858. exec function AlwaysMouseLook( Bool B )
  1859. {
  1860. ChangeAlwaysMouseLook(B);
  1861. SaveConfig();
  1862. }
  1863.  
  1864. function ChangeAlwaysMouseLook(Bool B)
  1865. {
  1866. bAlwaysMouseLook = B;
  1867. if ( bAlwaysMouseLook )
  1868. bLookUpStairs = false;
  1869. }
  1870.  
  1871. exec function SnapView( bool B )
  1872. {
  1873. ChangeSnapView(B);
  1874. SaveConfig();
  1875. }
  1876.  
  1877. function ChangeSnapView( bool B )
  1878. {
  1879. bSnapToLevel = B;
  1880. }
  1881.  
  1882. exec function StairLook( bool B )
  1883. {
  1884. ChangeStairLook(B);
  1885. SaveConfig();
  1886. }
  1887.  
  1888. function ChangeStairLook( bool B )
  1889. {
  1890. bLookUpStairs = B;
  1891. if ( bLookUpStairs )
  1892. bAlwaysMouseLook = false;
  1893. }
  1894.  
  1895. exec function SetDodgeClickTime( float F )
  1896. {
  1897. ChangeDodgeClickTime(F);
  1898. SaveConfig();
  1899. }
  1900.  
  1901. function ChangeDodgeClickTime( float F )
  1902. {
  1903. DodgeClickTime = FMin(0.3, F);
  1904. }
  1905.  
  1906. final function ReplaceText(out string Text, string Replace, string With)
  1907. {
  1908. local int i;
  1909. local string Input;
  1910.  
  1911. Input = Text;
  1912. Text = "";
  1913. i = InStr(Input, Replace);
  1914. while(i != -1)
  1915. {
  1916. Text = Text $ Left(Input, i) $ With;
  1917. Input = Mid(Input, i + Len(Replace));
  1918. i = InStr(Input, Replace);
  1919. }
  1920. Text = Text $ Input;
  1921. }
  1922.  
  1923. exec function SetName( coerce string S )
  1924. {
  1925. if ( Len(S) > 28 )
  1926. S = left(S,28);
  1927. ReplaceText(S, " ", "_");
  1928. ChangeName(S);
  1929. UpdateURL("Name", S, true);
  1930. SaveConfig();
  1931. }
  1932.  
  1933. exec function Name( coerce string S )
  1934. {
  1935. SetName(S);
  1936. }
  1937.  
  1938. function ChangeName( coerce string S )
  1939. {
  1940. Level.Game.ChangeName( self, S, false );
  1941. }
  1942.  
  1943. function ChangeTeam( int N )
  1944. {
  1945. local int OldTeam;
  1946.  
  1947. OldTeam = PlayerReplicationInfo.Team;
  1948. Level.Game.ChangeTeam(self, N);
  1949. if ( Level.Game.bTeamGame && (PlayerReplicationInfo.Team != OldTeam) )
  1950. Died( None, '', Location );
  1951. }
  1952.  
  1953. function ClientChangeTeam( int N )
  1954. {
  1955. local Pawn P;
  1956.  
  1957. if ( PlayerReplicationInfo != None )
  1958. PlayerReplicationInfo.Team = N;
  1959.  
  1960. // if listen server, this may be called for non-local players that are logging in
  1961. // if so, don't update URL
  1962. if ( (Level.NetMode == NM_ListenServer) && (Player == None) )
  1963. {
  1964. // check if any other players exist
  1965. for ( P=Level.PawnList; P!=None; P=P.NextPawn )
  1966. if ( P.IsA('PlayerPawn') && (ViewPort(PlayerPawn(P).Player) != None) )
  1967. return;
  1968. }
  1969.  
  1970. UpdateURL("Team",string(N), true);
  1971. }
  1972.  
  1973. exec function SetAutoAim( float F )
  1974. {
  1975. ChangeAutoAim(F);
  1976. SaveConfig();
  1977. }
  1978.  
  1979. function ChangeAutoAim( float F )
  1980. {
  1981. MyAutoAim = FMax(Level.Game.AutoAim, F);
  1982. }
  1983.  
  1984. exec function PlayersOnly()
  1985. {
  1986. if ( Level.Netmode != NM_Standalone )
  1987. return;
  1988.  
  1989. Level.bPlayersOnly = !Level.bPlayersOnly;
  1990. }
  1991.  
  1992. exec function SetHand( string S )
  1993. {
  1994. ChangeSetHand(S);
  1995. SaveConfig();
  1996. }
  1997.  
  1998. function ChangeSetHand( string S )
  1999. {
  2000. if ( S ~= "Left" )
  2001. Handedness = 1;
  2002. else if ( S~= "Right" )
  2003. Handedness = -1;
  2004. else if ( S ~= "Center" )
  2005. Handedness = 0;
  2006. else if ( S ~= "Hidden" )
  2007. Handedness = 2;
  2008. ServerSetHandedness(Handedness);
  2009. }
  2010.  
  2011. exec function ViewPlayer( string S )
  2012. {
  2013. local pawn P;
  2014.  
  2015. for ( P=Level.pawnList; P!=None; P= P.NextPawn )
  2016. if ( P.bIsPlayer && (P.PlayerReplicationInfo.PlayerName ~= S) )
  2017. break;
  2018.  
  2019. if ( (P != None) && Level.Game.CanSpectate(self, P) )
  2020. {
  2021. ClientMessage(ViewingFrom@P.PlayerReplicationInfo.PlayerName, 'Event', true);
  2022. if ( P == self)
  2023. ViewTarget = None;
  2024. else
  2025. ViewTarget = P;
  2026. }
  2027. else
  2028. ClientMessage(FailedView);
  2029.  
  2030. bBehindView = ( ViewTarget != None );
  2031. if ( bBehindView )
  2032. ViewTarget.BecomeViewTarget();
  2033. }
  2034.  
  2035. exec function CheatView( class<actor> aClass )
  2036. {
  2037. local actor other, first;
  2038. local bool bFound;
  2039.  
  2040. if( !CanICheat() )
  2041. return;
  2042.  
  2043. if( !bAdmin && Level.NetMode!=NM_Standalone )
  2044. return;
  2045.  
  2046. first = None;
  2047. ForEach AllActors( aClass, other )
  2048. {
  2049. if ( (first == None) && (other != self) )
  2050. {
  2051. first = other;
  2052. bFound = true;
  2053. }
  2054. if ( other == ViewTarget )
  2055. first = None;
  2056. }
  2057.  
  2058. if ( first != None )
  2059. {
  2060. if ( first.IsA('Pawn') && Pawn(first).bIsPlayer && (Pawn(first).PlayerReplicationInfo.PlayerName != "") )
  2061. ClientMessage(ViewingFrom@Pawn(first).PlayerReplicationInfo.PlayerName, 'Event', true);
  2062. else
  2063. ClientMessage(ViewingFrom@first, 'Event', true);
  2064. ViewTarget = first;
  2065. }
  2066. else
  2067. {
  2068. if ( bFound )
  2069. ClientMessage(ViewingFrom@OwnCamera, 'Event', true);
  2070. else
  2071. ClientMessage(FailedView, 'Event', true);
  2072. ViewTarget = None;
  2073. }
  2074.  
  2075. bBehindView = ( ViewTarget != None );
  2076. if ( bBehindView )
  2077. ViewTarget.BecomeViewTarget();
  2078. }
  2079.  
  2080. exec function ViewSelf()
  2081. {
  2082. bBehindView = false;
  2083. Viewtarget = None;
  2084. ClientMessage(ViewingFrom@OwnCamera, 'Event', true);
  2085. }
  2086.  
  2087. exec function ViewClass( class<actor> aClass, optional bool bQuiet )
  2088. {
  2089. local actor other, first;
  2090. local bool bFound;
  2091.  
  2092. if ( (Level.Game != None) && !Level.Game.bCanViewOthers )
  2093. return;
  2094.  
  2095. first = None;
  2096. ForEach AllActors( aClass, other )
  2097. {
  2098. if ( (first == None) && (other != self)
  2099. && ( (bAdmin && Level.Game==None) || Level.Game.CanSpectate(self, other) ) )
  2100. {
  2101. first = other;
  2102. bFound = true;
  2103. }
  2104. if ( other == ViewTarget )
  2105. first = None;
  2106. }
  2107.  
  2108. if ( first != None )
  2109. {
  2110. if ( !bQuiet )
  2111. {
  2112. if ( first.IsA('Pawn') && Pawn(first).bIsPlayer && (Pawn(first).PlayerReplicationInfo.PlayerName != "") )
  2113. ClientMessage(ViewingFrom@Pawn(first).PlayerReplicationInfo.PlayerName, 'Event', true);
  2114. else
  2115. ClientMessage(ViewingFrom@first, 'Event', true);
  2116. }
  2117. ViewTarget = first;
  2118. }
  2119. else
  2120. {
  2121. if ( !bQuiet )
  2122. {
  2123. if ( bFound )
  2124. ClientMessage(ViewingFrom@OwnCamera, 'Event', true);
  2125. else
  2126. ClientMessage(FailedView, 'Event', true);
  2127. }
  2128. ViewTarget = None;
  2129. }
  2130.  
  2131. bBehindView = ( ViewTarget != None );
  2132. if ( bBehindView )
  2133. ViewTarget.BecomeViewTarget();
  2134. }
  2135.  
  2136. exec function NeverSwitchOnPickup( bool B )
  2137. {
  2138. bNeverAutoSwitch = B;
  2139. bNeverSwitchOnPickup = B;
  2140. ServerNeverSwitchOnPickup(B);
  2141. SaveConfig();
  2142. }
  2143.  
  2144. function ServerNeverSwitchOnPickup(bool B)
  2145. {
  2146. bNeverSwitchOnPickup = B;
  2147. }
  2148.  
  2149. exec function InvertMouse( bool B )
  2150. {
  2151. bInvertMouse = B;
  2152. SaveConfig();
  2153. }
  2154.  
  2155. exec function SwitchLevel( string URL )
  2156. {
  2157. if( bAdmin || Player.IsA('ViewPort') )
  2158. Level.ServerTravel( URL, false );
  2159. }
  2160.  
  2161. exec function SwitchCoopLevel( string URL )
  2162. {
  2163. if( bAdmin || Player.IsA('ViewPort') )
  2164. Level.ServerTravel( URL, true );
  2165. }
  2166.  
  2167. exec function ShowScores()
  2168. {
  2169. bShowScores = !bShowScores;
  2170. }
  2171.  
  2172. exec function ShowMenu()
  2173. {
  2174. WalkBob = vect(0,0,0);
  2175. bShowMenu = true; // menu is responsible for turning this off
  2176. Player.Console.GotoState('Menuing');
  2177.  
  2178. if( Level.Netmode == NM_Standalone )
  2179. SetPause(true);
  2180. }
  2181.  
  2182. exec function ShowLoadMenu()
  2183. {
  2184. ShowMenu();
  2185. }
  2186.  
  2187. exec function AddBots(int N)
  2188. {
  2189. ServerAddBots(N);
  2190. }
  2191.  
  2192. function ServerAddBots(int N)
  2193. {
  2194. local int i;
  2195.  
  2196. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2197. return;
  2198.  
  2199. if ( !Level.Game.bDeathMatch )
  2200. return;
  2201.  
  2202. for ( i=0; i<N; i++ )
  2203. Level.Game.ForceAddBot();
  2204. }
  2205.  
  2206.  
  2207. //*************************************************************************************
  2208. // Special purpose/cheat execs
  2209.  
  2210. exec function ClearProgressMessages()
  2211. {
  2212. local int i;
  2213.  
  2214. for (i=0; i<8; i++)
  2215. {
  2216. ProgressMessage[i] = "";
  2217. ProgressColor[i].R = 255;
  2218. ProgressColor[i].G = 255;
  2219. ProgressColor[i].B = 255;
  2220. }
  2221. }
  2222.  
  2223. exec function SetProgressMessage( string S, int Index )
  2224. {
  2225. if (Index < 8)
  2226. ProgressMessage[Index] = S;
  2227. }
  2228.  
  2229. exec function SetProgressColor( color C, int Index )
  2230. {
  2231. if (Index < 8)
  2232. ProgressColor[Index] = C;
  2233. }
  2234.  
  2235. exec function SetProgressTime( float T )
  2236. {
  2237. ProgressTimeOut = T + Level.TimeSeconds;
  2238. }
  2239.  
  2240. exec event ShowUpgradeMenu();
  2241.  
  2242. exec function Amphibious()
  2243. {
  2244. if( !CanICheat() )
  2245. return;
  2246.  
  2247. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2248. return;
  2249. UnderwaterTime = +999999.0;
  2250. }
  2251.  
  2252. exec function XFly()
  2253. {
  2254. if( !CanICheat() )
  2255. return;
  2256.  
  2257. // if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2258. // return;
  2259.  
  2260. UnderWaterTime = Default.UnderWaterTime;
  2261. ClientMessage("You feel much lighter");
  2262. SetCollision(true, true , true);
  2263. bCollideWorld = true;
  2264. GotoState('CheatFlying');
  2265. }
  2266.  
  2267. exec function SetWeaponStay( bool B)
  2268. {
  2269. local Weapon W;
  2270.  
  2271. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2272. return;
  2273.  
  2274. Level.Game.bCoopWeaponMode = B;
  2275. ForEach AllActors(class'Weapon', W)
  2276. {
  2277. W.bWeaponStay = false;
  2278. W.SetWeaponStay();
  2279. }
  2280. }
  2281.  
  2282. exec function XWalk()
  2283. {
  2284. // if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2285. // return;
  2286.  
  2287. StartWalk();
  2288. }
  2289.  
  2290. function StartWalk()
  2291. {
  2292. UnderWaterTime = Default.UnderWaterTime;
  2293. SetCollision(true, true , true);
  2294. SetPhysics(PHYS_Walking);
  2295. bCollideWorld = true;
  2296. ClientReStart();
  2297. }
  2298.  
  2299. exec function XGhost()
  2300. {
  2301. if( !CanICheat() )
  2302. return;
  2303.  
  2304. // if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2305. // return;
  2306.  
  2307. UnderWaterTime = -1.0;
  2308. ClientMessage("You feel ethereal");
  2309. SetCollision(false, false, false);
  2310. bCollideWorld = false;
  2311. GotoState('CheatFlying');
  2312. }
  2313.  
  2314. exec function ShowInventory()
  2315. {
  2316. local Inventory Inv;
  2317.  
  2318. if( Weapon!=None )
  2319. log( " Weapon: " $ Weapon.Class );
  2320. for( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
  2321. log( "Inv: "$Inv $ " state "$Inv.GetStateName());
  2322. if ( SelectedItem != None )
  2323. log( "Selected Item"@SelectedItem@"Charge"@SelectedItem.Charge );
  2324. }
  2325.  
  2326. exec function AllAmmo()
  2327. {
  2328. local Inventory Inv;
  2329.  
  2330. if( !CanICheat() )
  2331. return;
  2332.  
  2333. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2334. return;
  2335.  
  2336. for( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
  2337. if (Ammo(Inv)!=None)
  2338. {
  2339. Ammo(Inv).AmmoAmount = 999;
  2340. Ammo(Inv).MaxAmmo = 999;
  2341. }
  2342. }
  2343.  
  2344. exec function Invisible(bool B)
  2345. {
  2346. if( !CanICheat() )
  2347. return;
  2348.  
  2349. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2350. return;
  2351.  
  2352. if (B)
  2353. {
  2354. bHidden = true;
  2355. Visibility = 0;
  2356. }
  2357. else
  2358. {
  2359. bHidden = false;
  2360. Visibility = Default.Visibility;
  2361. }
  2362. }
  2363.  
  2364. exec function XGod()
  2365. {
  2366. if( !CanICheat() )
  2367. return;
  2368.  
  2369. // if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2370. // return;
  2371.  
  2372. if ( ReducedDamageType == 'All' )
  2373. {
  2374. ReducedDamageType = '';
  2375. ClientMessage("God mode off");
  2376. return;
  2377. }
  2378.  
  2379. ReducedDamageType = 'All';
  2380. ClientMessage("God Mode on");
  2381. }
  2382.  
  2383. exec function BehindView( Bool B )
  2384. {
  2385. bBehindView = B;
  2386. }
  2387.  
  2388. exec function SetBob(float F)
  2389. {
  2390. UpdateBob(F);
  2391. SaveConfig();
  2392. }
  2393.  
  2394. function UpdateBob(float F)
  2395. {
  2396. Bob = FClamp(F,0,0.032);
  2397. }
  2398.  
  2399. exec function SetSensitivity(float F)
  2400. {
  2401. UpdateSensitivity(F);
  2402. SaveConfig();
  2403. }
  2404.  
  2405. function UpdateSensitivity(float F)
  2406. {
  2407. MouseSensitivity = FMax(0,F);
  2408. }
  2409.  
  2410. exec function SloMo( float T )
  2411. {
  2412. ServerSetSloMo(T);
  2413. }
  2414.  
  2415. function ServerSetSloMo(float T)
  2416. {
  2417. if ( bAdmin || (Level.Netmode == NM_Standalone) )
  2418. {
  2419. Level.Game.SetGameSpeed(T);
  2420. Level.Game.SaveConfig();
  2421. Level.Game.GameReplicationInfo.SaveConfig();
  2422. }
  2423. }
  2424.  
  2425. exec function SetJumpZ( float F )
  2426. {
  2427. if( !CanICheat() )
  2428. return;
  2429. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2430. return;
  2431. JumpZ = F;
  2432. }
  2433.  
  2434. exec function SetFriction( float F )
  2435. {
  2436. local ZoneInfo Z;
  2437. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2438. return;
  2439. ForEach AllActors(class'ZoneInfo', Z)
  2440. Z.ZoneGroundFriction = F;
  2441. }
  2442.  
  2443. exec function SetSpeed( float F )
  2444. {
  2445. if( !CanICheat() )
  2446. return;
  2447. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2448. return;
  2449. GroundSpeed = Default.GroundSpeed * f;
  2450. WaterSpeed = Default.WaterSpeed * f;
  2451. }
  2452.  
  2453. exec function KillAll(class<actor> aClass)
  2454. {
  2455. local Actor A;
  2456.  
  2457. if( !CanICheat() )
  2458. return;
  2459. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2460. return;
  2461. ForEach AllActors(class 'Actor', A)
  2462. if ( ClassIsChildOf(A.class, aClass) )
  2463. A.Destroy();
  2464. }
  2465.  
  2466. exec function KillPawns()
  2467. {
  2468. local Pawn P;
  2469.  
  2470. if( !CanICheat() )
  2471. return;
  2472. if ( !bAdmin && (Level.Netmode != NM_Standalone) )
  2473. return;
  2474. ForEach AllActors(class 'Pawn', P)
  2475. if (PlayerPawn(P) == None)
  2476. P.Destroy();
  2477. }
  2478.  
  2479. exec function Summon( string ClassName )
  2480. {
  2481. local class<actor> NewClass;
  2482. if( !CanICheat() )
  2483. return;
  2484. if( !bAdmin && (Level.Netmode != NM_Standalone) )
  2485. return;
  2486. log( "Fabricate " $ ClassName );
  2487. NewClass = class<actor>( DynamicLoadObject( ClassName, class'Class' ) );
  2488. if( NewClass!=None )
  2489. Spawn( NewClass,,,Location + 72 * Vector(Rotation) + vect(0,0,1) * 15 );
  2490. }
  2491.  
  2492.  
  2493. //==============
  2494. // Navigation Aids
  2495. exec function ShowPath()
  2496. {
  2497. //find next path to remembered spot
  2498. local Actor node;
  2499. node = FindPathTo(Destination);
  2500. if (node != None)
  2501. {
  2502. log("found path");
  2503. Spawn(class 'WayBeacon', self, '', node.location);
  2504. }
  2505. else
  2506. log("didn't find path");
  2507. }
  2508.  
  2509. exec function RememberSpot()
  2510. {
  2511. //remember spot
  2512. Destination = Location;
  2513. }
  2514.  
  2515. //=============================================================================
  2516. // Input related functions.
  2517.  
  2518. // Postprocess the player's input.
  2519.  
  2520. event PlayerInput( float DeltaTime )
  2521. {
  2522. local float SmoothTime, FOVScale, MouseScale, AbsSmoothX, AbsSmoothY, MouseTime;
  2523.  
  2524. if ( bShowMenu && (myHud != None) )
  2525. {
  2526. if ( myHud.MainMenu != None )
  2527. myHud.MainMenu.MenuTick( DeltaTime );
  2528. // clear inputs
  2529. bEdgeForward = false;
  2530. bEdgeBack = false;
  2531. bEdgeLeft = false;
  2532. bEdgeRight = false;
  2533. bWasForward = false;
  2534. bWasBack = false;
  2535. bWasLeft = false;
  2536. bWasRight = false;
  2537. aStrafe = 0;
  2538. aTurn = 0;
  2539. aForward = 0;
  2540. aLookUp = 0;
  2541. return;
  2542. }
  2543. else if ( bDelayedCommand )
  2544. {
  2545. bDelayedCommand = false;
  2546. ConsoleCommand(DelayedCommand);
  2547. }
  2548.  
  2549. // Check for Dodge move
  2550. // flag transitions
  2551. bEdgeForward = (bWasForward ^^ (aBaseY > 0));
  2552. bEdgeBack = (bWasBack ^^ (aBaseY < 0));
  2553. bEdgeLeft = (bWasLeft ^^ (aStrafe > 0));
  2554. bEdgeRight = (bWasRight ^^ (aStrafe < 0));
  2555. bWasForward = (aBaseY > 0);
  2556. bWasBack = (aBaseY < 0);
  2557. bWasLeft = (aStrafe > 0);
  2558. bWasRight = (aStrafe < 0);
  2559.  
  2560. // Smooth and amplify mouse movement
  2561. SmoothTime = FMin(0.2, 3 * DeltaTime * Level.TimeDilation);
  2562. FOVScale = DesiredFOV * 0.01111;
  2563. MouseScale = MouseSensitivity * FOVScale;
  2564.  
  2565. aMouseX *= MouseScale;
  2566. aMouseY *= MouseScale;
  2567.  
  2568. //************************************************************************
  2569.  
  2570. //log("X "$aMouseX$" Smooth "$SmoothMouseX$" Borrowed "$BorrowedMouseX$" zero time "$(Level.TimeSeconds - MouseZeroTime)$" vs "$MouseSmoothThreshold);
  2571. AbsSmoothX = SmoothMouseX;
  2572. AbsSmoothY = SmoothMouseY;
  2573. MouseTime = (Level.TimeSeconds - MouseZeroTime)/Level.TimeDilation;
  2574. if ( bMaxMouseSmoothing && (aMouseX == 0) && (MouseTime < MouseSmoothThreshold) )
  2575. {
  2576. SmoothMouseX = 0.5 * (MouseSmoothThreshold - MouseTime) * AbsSmoothX/MouseSmoothThreshold;
  2577. BorrowedMouseX += SmoothMouseX;
  2578. }
  2579. else
  2580. {
  2581. if ( (SmoothMouseX == 0) || (aMouseX == 0)
  2582. || ((SmoothMouseX > 0) != (aMouseX > 0)) )
  2583. {
  2584. SmoothMouseX = aMouseX;
  2585. BorrowedMouseX = 0;
  2586. }
  2587. else
  2588. {
  2589. SmoothMouseX = 0.5 * (SmoothMouseX + aMouseX - BorrowedMouseX);
  2590. if ( (SmoothMouseX > 0) != (aMouseX > 0) )
  2591. {
  2592. if ( AMouseX > 0 )
  2593. SmoothMouseX = 1;
  2594. else
  2595. SmoothMouseX = -1;
  2596. }
  2597. BorrowedMouseX = SmoothMouseX - aMouseX;
  2598. }
  2599. AbsSmoothX = SmoothMouseX;
  2600. }
  2601. if ( bMaxMouseSmoothing && (aMouseY == 0) && (MouseTime < MouseSmoothThreshold) )
  2602. {
  2603. SmoothMouseY = 0.5 * (MouseSmoothThreshold - MouseTime) * AbsSmoothY/MouseSmoothThreshold;
  2604. BorrowedMouseY += SmoothMouseY;
  2605. }
  2606. else
  2607. {
  2608. if ( (SmoothMouseY == 0) || (aMouseY == 0)
  2609. || ((SmoothMouseY > 0) != (aMouseY > 0)) )
  2610. {
  2611. SmoothMouseY = aMouseY;
  2612. BorrowedMouseY = 0;
  2613. }
  2614. else
  2615. {
  2616. SmoothMouseY = 0.5 * (SmoothMouseY + aMouseY - BorrowedMouseY);
  2617. if ( (SmoothMouseY > 0) != (aMouseY > 0) )
  2618. {
  2619. if ( AMouseY > 0 )
  2620. SmoothMouseY = 1;
  2621. else
  2622. SmoothMouseY = -1;
  2623. }
  2624. BorrowedMouseY = SmoothMouseY - aMouseY;
  2625. }
  2626. AbsSmoothY = SmoothMouseY;
  2627. }
  2628. if ( (aMouseX != 0) || (aMouseY != 0) )
  2629. MouseZeroTime = Level.TimeSeconds;
  2630.  
  2631. // adjust keyboard and joystick movements
  2632. aLookUp *= FOVScale;
  2633. aTurn *= FOVScale;
  2634.  
  2635. // Remap raw x-axis movement.
  2636. if( bStrafe!=0 )
  2637. {
  2638. // Strafe.
  2639. aStrafe += aBaseX + SmoothMouseX;
  2640. aBaseX = 0;
  2641. }
  2642. else
  2643. {
  2644. // Forward.
  2645. aTurn += aBaseX * FOVScale + SmoothMouseX;
  2646. aBaseX = 0;
  2647. }
  2648.  
  2649. // Remap mouse y-axis movement.
  2650. if( (bStrafe == 0) && (bAlwaysMouseLook || (bLook!=0)) )
  2651. {
  2652. // Look up/down.
  2653. if ( bInvertMouse )
  2654. aLookUp -= SmoothMouseY;
  2655. else
  2656. aLookUp += SmoothMouseY;
  2657. }
  2658. else
  2659. {
  2660. // Move forward/backward.
  2661. aForward += SmoothMouseY;
  2662. }
  2663. SmoothMouseX = AbsSmoothX;
  2664. SmoothMouseY = AbsSmoothY;
  2665.  
  2666. if ( bSnapLevel != 0 )
  2667. {
  2668. bCenterView = true;
  2669. bKeyboardLook = false;
  2670. }
  2671. else if (aLookUp != 0)
  2672. {
  2673. bCenterView = false;
  2674. bKeyboardLook = true;
  2675. }
  2676. else if ( bSnapToLevel && !bAlwaysMouseLook )
  2677. {
  2678. bCenterView = true;
  2679. bKeyboardLook = false;
  2680. }
  2681.  
  2682. // Remap other y-axis movement.
  2683. if ( bFreeLook != 0 )
  2684. {
  2685. bKeyboardLook = true;
  2686. aLookUp += 0.5 * aBaseY * FOVScale;
  2687. }
  2688. else
  2689. aForward += aBaseY;
  2690.  
  2691. aBaseY = 0;
  2692.  
  2693. // Handle walking.
  2694. HandleWalking();
  2695. }
  2696.  
  2697. //=============================================================================
  2698. // functions.
  2699.  
  2700. event UpdateEyeHeight(float DeltaTime)
  2701. {
  2702. local float smooth, bound;
  2703.  
  2704. // smooth up/down stairs
  2705. If( (Physics==PHYS_Walking) && !bJustLanded )
  2706. {
  2707. smooth = FMin(1.0, 10.0 * DeltaTime/Level.TimeDilation);
  2708. EyeHeight = (EyeHeight - Location.Z + OldLocation.Z) * (1 - smooth) + ( ShakeVert + BaseEyeHeight) * smooth;
  2709. bound = -0.5 * CollisionHeight;
  2710. if (EyeHeight < bound)
  2711. EyeHeight = bound;
  2712. else
  2713. {
  2714. bound = CollisionHeight + FClamp((OldLocation.Z - Location.Z), 0.0, MaxStepHeight);
  2715. if ( EyeHeight > bound )
  2716. EyeHeight = bound;
  2717. }
  2718. }
  2719. else
  2720. {
  2721. smooth = FClamp(10.0 * DeltaTime/Level.TimeDilation, 0.35,1.0);
  2722. bJustLanded = false;
  2723. EyeHeight = EyeHeight * ( 1 - smooth) + (BaseEyeHeight + ShakeVert) * smooth;
  2724. }
  2725.  
  2726. // teleporters affect your FOV, so adjust it back down
  2727. if ( FOVAngle != DesiredFOV )
  2728. {
  2729. if ( FOVAngle > DesiredFOV )
  2730. FOVAngle = FOVAngle - FMax(7, 0.9 * DeltaTime * (FOVAngle - DesiredFOV));
  2731. else
  2732. FOVAngle = FOVAngle - FMin(-7, 0.9 * DeltaTime * (FOVAngle - DesiredFOV));
  2733. if ( Abs(FOVAngle - DesiredFOV) <= 10 )
  2734. FOVAngle = DesiredFOV;
  2735. }
  2736.  
  2737. // adjust FOV for weapon zooming
  2738. if ( bZooming )
  2739. {
  2740. ZoomLevel += DeltaTime * 1.0;
  2741. if (ZoomLevel > 0.9)
  2742. ZoomLevel = 0.9;
  2743. DesiredFOV = FClamp(90.0 - (ZoomLevel * 88.0), 1, 170);
  2744. }
  2745. }
  2746.  
  2747. event PlayerTimeOut()
  2748. {
  2749. if (Health > 0)
  2750. Died(None, 'Suicided', Location);
  2751. }
  2752.  
  2753. // Just changed to pendingWeapon
  2754. function ChangedWeapon()
  2755. {
  2756. Super.ChangedWeapon();
  2757. if ( PendingWeapon != None )
  2758. PendingWeapon.SetHand(Handedness);
  2759. }
  2760.  
  2761. function JumpOffPawn()
  2762. {
  2763. Velocity += 60 * VRand();
  2764. Velocity.Z = 120;
  2765. SetPhysics(PHYS_Falling);
  2766. }
  2767.  
  2768. event TravelPostAccept()
  2769. {
  2770. if ( Health <= 0 )
  2771. Health = Default.Health;
  2772. }
  2773.  
  2774. // This pawn was possessed by a player.
  2775. event Possess()
  2776. {
  2777. if ( Level.Netmode == NM_Client )
  2778. {
  2779. // replicate client weapon preferences to server
  2780. ServerNeverSwitchOnPickup(bNeverAutoSwitch);
  2781. ServerSetHandedness(Handedness);
  2782. UpdateWeaponPriorities();
  2783. }
  2784. ServerUpdateWeapons();
  2785. bIsPlayer = true;
  2786. DodgeClickTime = FMin(0.3, DodgeClickTime);
  2787. EyeHeight = BaseEyeHeight;
  2788. NetPriority = 3;
  2789. StartWalk();
  2790. }
  2791.  
  2792. function UpdateWeaponPriorities()
  2793. {
  2794. local byte i;
  2795.  
  2796. // send new priorities to server
  2797. if ( Level.Netmode == NM_Client )
  2798. for ( i=0; i<ArrayCount(WeaponPriority); i++ )
  2799. ServerSetWeaponPriority(i, WeaponPriority[i]);
  2800. }
  2801.  
  2802. function ServerSetWeaponPriority(byte i, name WeaponName )
  2803. {
  2804. local inventory inv;
  2805.  
  2806. WeaponPriority[i] = WeaponName;
  2807.  
  2808. for ( inv=Inventory; inv!=None; inv=inv.inventory )
  2809. if ( inv.class.name == WeaponName )
  2810. Weapon(inv).SetSwitchPriority(self);
  2811. }
  2812.  
  2813. // This pawn was unpossessed by a player.
  2814. event UnPossess()
  2815. {
  2816. log(Self$" being unpossessed");
  2817. if ( myHUD != None )
  2818. myHUD.Destroy();
  2819. bIsPlayer = false;
  2820. EyeHeight = 0.8 * CollisionHeight;
  2821. }
  2822.  
  2823. function Carcass SpawnCarcass()
  2824. {
  2825. local carcass carc;
  2826.  
  2827. carc = Spawn(CarcassType);
  2828. if ( carc == None )
  2829. return None;
  2830. carc.Initfor(self);
  2831. if (Player != None)
  2832. carc.bPlayerCarcass = true;
  2833. if ( !Level.Game.bGameEnded && (Carcass(ViewTarget) == None) )
  2834. ViewTarget = carc; //for Player 3rd person views
  2835. return carc;
  2836. }
  2837.  
  2838. function bool Gibbed(name damageType)
  2839. {
  2840. if ( (damageType == 'decapitated') || (damageType == 'shot') )
  2841. return false;
  2842. if ( (Health < -80) || ((Health < -40) && (FRand() < 0.6)) )
  2843. return true;
  2844. return false;
  2845. }
  2846.  
  2847. function SpawnGibbedCarcass()
  2848. {
  2849. local carcass carc;
  2850.  
  2851. carc = Spawn(CarcassType);
  2852. if ( carc != None )
  2853. {
  2854. carc.Initfor(self);
  2855. carc.ChunkUp(-1 * Health);
  2856. }
  2857. }
  2858.  
  2859. event PlayerTick( float Time );
  2860.  
  2861. //
  2862. // Called immediately before gameplay begins.
  2863. //
  2864. event PreBeginPlay()
  2865. {
  2866. bIsPlayer = true;
  2867. Super.PreBeginPlay();
  2868. }
  2869.  
  2870. event PostBeginPlay()
  2871. {
  2872. Super.PostBeginPlay();
  2873. if (Level.LevelEnterText != "" )
  2874. ClientMessage(Level.LevelEnterText);
  2875. if ( Level.NetMode != NM_Client )
  2876. {
  2877. HUDType = Level.Game.HUDType;
  2878. ScoringType = Level.Game.ScoreboardType;
  2879. MyAutoAim = FMax(MyAutoAim, Level.Game.AutoAim);
  2880. }
  2881. bIsPlayer = true;
  2882. DodgeClickTime = FMin(0.3, DodgeClickTime);
  2883. DesiredFOV = DefaultFOV;
  2884. EyeHeight = BaseEyeHeight;
  2885. if ( Level.Game.IsA('SinglePlayer') && (Level.NetMode == NM_Standalone) )
  2886. FlashScale = vect(0,0,0);
  2887. }
  2888.  
  2889. function ServerUpdateWeapons()
  2890. {
  2891. local inventory Inv;
  2892.  
  2893. For ( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
  2894. if ( Inv.IsA('Weapon') )
  2895. Weapon(Inv).SetSwitchPriority(self);
  2896. }
  2897.  
  2898. //=============================================================================
  2899. // Animation playing - should be implemented in subclass,
  2900. //
  2901.  
  2902. function PlayDodge(eDodgeDir DodgeMove)
  2903. {
  2904. PlayDuck();
  2905. }
  2906.  
  2907. function PlayTurning();
  2908.  
  2909. function PlaySwimming()
  2910. {
  2911. PlayRunning();
  2912. }
  2913.  
  2914. /* Adjust hit location - adjusts the hit location in for pawns, and returns
  2915. true if it was really a hit, and false if not (for ducking, etc.)
  2916. */
  2917. simulated function bool AdjustHitLocation(out vector HitLocation, vector TraceDir)
  2918. {
  2919. local float adjZ, maxZ;
  2920.  
  2921. TraceDir = Normal(TraceDir);
  2922. HitLocation = HitLocation + 0.5 * CollisionRadius * TraceDir;
  2923. if ( BaseEyeHeight == Default.BaseEyeHeight )
  2924. return true;
  2925.  
  2926. maxZ = Location.Z + EyeHeight + 0.25 * CollisionHeight;
  2927. if ( HitLocation.Z > maxZ )
  2928. {
  2929. if ( TraceDir.Z >= 0 )
  2930. return false;
  2931. adjZ = (maxZ - HitLocation.Z)/TraceDir.Z;
  2932. HitLocation.Z = maxZ;
  2933. HitLocation.X = HitLocation.X + TraceDir.X * adjZ;
  2934. HitLocation.Y = HitLocation.Y + TraceDir.Y * adjZ;
  2935. if ( VSize(HitLocation - Location) > CollisionRadius )
  2936. return false;
  2937. }
  2938. return true;
  2939. }
  2940.  
  2941. /* AdjustAim()
  2942. Calls this version for player aiming help.
  2943. Aimerror not used in this version.
  2944. Only adjusts aiming at pawns
  2945. */
  2946.  
  2947. function rotator AdjustAim(float projSpeed, vector projStart, int aimerror, bool bLeadTarget, bool bWarnTarget)
  2948. {
  2949. local vector FireDir, AimSpot, HitNormal, HitLocation;
  2950. local actor BestTarget;
  2951. local float bestAim, bestDist;
  2952. local actor HitActor;
  2953.  
  2954. FireDir = vector(ViewRotation);
  2955. HitActor = Trace(HitLocation, HitNormal, projStart + 4000 * FireDir, projStart, true);
  2956. if ( (HitActor != None) && HitActor.bProjTarget )
  2957. {
  2958. if ( bWarnTarget && HitActor.IsA('Pawn') )
  2959. Pawn(HitActor).WarnTarget(self, projSpeed, FireDir);
  2960. return ViewRotation;
  2961. }
  2962.  
  2963. bestAim = 0.65;//WRG FMin(0.93, MyAutoAim);
  2964. BestTarget = PickTarget(bestAim, bestDist, FireDir, projStart);
  2965.  
  2966. if ( bWarnTarget && (Pawn(BestTarget) != None) )
  2967. Pawn(BestTarget).WarnTarget(self, projSpeed, FireDir);
  2968.  
  2969. if ( (Level.NetMode != NM_Standalone) || (Level.Game.Difficulty > 2)
  2970. || bAlwaysMouseLook || ((BestTarget != None) && (bestAim < MyAutoAim)) || (MyAutoAim >= 1) )
  2971. return ViewRotation;
  2972.  
  2973. if ( BestTarget == None )
  2974. {
  2975. bestAim = MyAutoAim;
  2976. BestTarget = PickAnyTarget(bestAim, bestDist, FireDir, projStart);
  2977. if ( BestTarget == None )
  2978. return ViewRotation;
  2979. }
  2980.  
  2981. AimSpot = projStart + FireDir * bestDist;
  2982. AimSpot.Z = BestTarget.Location.Z + 0.3 * BestTarget.CollisionHeight;
  2983.  
  2984. return rotator(AimSpot - projStart);
  2985. }
  2986.  
  2987. function Falling()
  2988. {
  2989. //SetPhysics(PHYS_Falling); //Note - physics changes type to PHYS_Falling by default
  2990. //log(class$" Falling");
  2991. PlayInAir();
  2992. }
  2993.  
  2994. function Landed(vector HitNormal)
  2995. {
  2996. //Note - physics changes type to PHYS_Walking by default for landed pawns
  2997. if ( bUpdating )
  2998. return;
  2999. PlayLanded(Velocity.Z);
  3000. LandBob = FMin(50, 0.055 * Velocity.Z);
  3001. TakeFallingDamage();
  3002. bJustLanded = true;
  3003. }
  3004.  
  3005. function Died(pawn Killer, name damageType, vector HitLocation)
  3006. {
  3007. StopZoom();
  3008.  
  3009. Super.Died(Killer, damageType, HitLocation);
  3010. }
  3011.  
  3012. function eAttitude AttitudeTo(Pawn Other)
  3013. {
  3014. if (Other.bIsPlayer)
  3015. return AttitudeToPlayer;
  3016. else
  3017. return Other.AttitudeToPlayer;
  3018. }
  3019.  
  3020.  
  3021. function string KillMessage( name damageType, pawn Other )
  3022. {
  3023. return ( Level.Game.PlayerKillMessage(damageType, Other.PlayerReplicationInfo)$PlayerReplicationInfo.PlayerName );
  3024. }
  3025.  
  3026. //=============================================================================
  3027. // Player Control
  3028.  
  3029. function KilledBy( pawn EventInstigator )
  3030. {
  3031. Health = 0;
  3032. Died( EventInstigator, 'Suicided', Location );
  3033. }
  3034.  
  3035. // Player view.
  3036. // Compute the rendering viewpoint for the player.
  3037. //
  3038.  
  3039.  
  3040. function CalcBehindView(out vector CameraLocation, out rotator CameraRotation, float Dist)
  3041. {
  3042. local vector View,HitLocation,HitNormal;
  3043. local float ViewDist;
  3044.  
  3045. CameraRotation = ViewRotation;
  3046.  
  3047. View = vect(1,0,0) >> CameraRotation;
  3048.  
  3049. if( Trace( HitLocation, HitNormal, CameraLocation - (Dist + 30) * vector(CameraRotation), CameraLocation ) != None )
  3050. {
  3051. ViewDist = FMin( (CameraLocation - HitLocation) Dot View, Dist );
  3052. }
  3053. else
  3054. ViewDist = Dist;
  3055.  
  3056. CameraLocation -= (ViewDist - 30) * View;
  3057. }
  3058.  
  3059.  
  3060. event PlayerCalcView(out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )
  3061. {
  3062. local Pawn PTarget;
  3063.  
  3064. if ( ViewTarget != None )
  3065. {
  3066. ViewActor = ViewTarget;
  3067. CameraLocation = ViewTarget.Location;
  3068. CameraRotation = ViewTarget.Rotation;
  3069. PTarget = Pawn(ViewTarget);
  3070. if ( PTarget != None )
  3071. {
  3072. if ( Level.NetMode == NM_Client )
  3073. {
  3074. if ( PTarget.bIsPlayer )
  3075. PTarget.ViewRotation = TargetViewRotation;
  3076. PTarget.EyeHeight = TargetEyeHeight;
  3077. if ( PTarget.Weapon != None )
  3078. PTarget.Weapon.PlayerViewOffset = TargetWeaponViewOffset;
  3079. }
  3080. if ( PTarget.bIsPlayer )
  3081. CameraRotation = PTarget.ViewRotation;
  3082. if ( !bBehindView )
  3083. CameraLocation.Z += PTarget.EyeHeight;
  3084. }
  3085.  
  3086. if ( bBehindView )
  3087. CalcBehindView(CameraLocation, CameraRotation, 180);
  3088. return;
  3089. }
  3090.  
  3091. ViewActor = Self;
  3092. CameraLocation = Location;
  3093.  
  3094. if( bCollideWorld ) //up and behind
  3095. CalcBehindView(CameraLocation, CameraRotation, 150);
  3096. else
  3097. {
  3098. // First-person view.
  3099. CameraRotation = ViewRotation;
  3100. CameraLocation.Z += EyeHeight;
  3101. CameraLocation += WalkBob;
  3102. }
  3103. }
  3104.  
  3105. exec function SetViewFlash(bool B)
  3106. {
  3107. bNoFlash = !B;
  3108. }
  3109.  
  3110. function ViewFlash(float DeltaTime)
  3111. {
  3112. local vector goalFog;
  3113. local float goalscale, delta;
  3114.  
  3115. if ( bNoFlash )
  3116. {
  3117. InstantFlash = 0;
  3118. InstantFog = vect(0,0,0);
  3119. }
  3120.  
  3121. delta = FMin(0.1, DeltaTime);
  3122. goalScale = 1 + DesiredFlashScale + ConstantGlowScale + HeadRegion.Zone.ViewFlash.X;
  3123. goalFog = DesiredFlashFog + ConstantGlowFog + HeadRegion.Zone.ViewFog;
  3124. DesiredFlashScale -= DesiredFlashScale * 2 * delta;
  3125. DesiredFlashFog -= DesiredFlashFog * 2 * delta;
  3126. FlashScale.X += (goalScale - FlashScale.X + InstantFlash) * 10 * delta;
  3127. FlashFog += (goalFog - FlashFog + InstantFog) * 10 * delta;
  3128. InstantFlash = 0;
  3129. InstantFog = vect(0,0,0);
  3130.  
  3131. if ( FlashScale.X > 0.981 )
  3132. FlashScale.X = 1;
  3133. FlashScale = FlashScale.X * vect(1,1,1);
  3134.  
  3135. if ( FlashFog.X < 0.019 )
  3136. FlashFog.X = 0;
  3137. if ( FlashFog.Y < 0.019 )
  3138. FlashFog.Y = 0;
  3139. if ( FlashFog.Z < 0.019 )
  3140. FlashFog.Z = 0;
  3141. }
  3142.  
  3143. function ViewShake(float DeltaTime)
  3144. {
  3145. if (shaketimer > 0.0) //shake view
  3146. {
  3147. shaketimer -= DeltaTime;
  3148. if ( verttimer == 0 )
  3149. {
  3150. verttimer = 0.1;
  3151. ShakeVert = -1.1 * maxshake;
  3152. }
  3153. else
  3154. {
  3155. verttimer -= DeltaTime;
  3156. if ( verttimer < 0 )
  3157. {
  3158. verttimer = 0.2 * FRand();
  3159. shakeVert = (2 * FRand() - 1) * maxshake;
  3160. }
  3161. }
  3162. ViewRotation.Roll = ViewRotation.Roll & 65535;
  3163. if (bShakeDir)
  3164. {
  3165. ViewRotation.Roll += Int( 10 * shakemag * FMin(0.1, DeltaTime));
  3166. bShakeDir = (ViewRotation.Roll > 32768) || (ViewRotation.Roll < (0.5 + FRand()) * shakemag);
  3167. if ( (ViewRotation.Roll < 32768) && (ViewRotation.Roll > 1.3 * shakemag) )
  3168. {
  3169. ViewRotation.Roll = 1.3 * shakemag;
  3170. bShakeDir = false;
  3171. }
  3172. else if (FRand() < 3 * DeltaTime)
  3173. bShakeDir = !bShakeDir;
  3174. }
  3175. else
  3176. {
  3177. ViewRotation.Roll -= Int( 10 * shakemag * FMin(0.1, DeltaTime));
  3178. bShakeDir = (ViewRotation.Roll > 32768) && (ViewRotation.Roll < 65535 - (0.5 + FRand()) * shakemag);
  3179. if ( (ViewRotation.Roll > 32768) && (ViewRotation.Roll < 65535 - 1.3 * shakemag) )
  3180. {
  3181. ViewRotation.Roll = 65535 - 1.3 * shakemag;
  3182. bShakeDir = true;
  3183. }
  3184. else if (FRand() < 3 * DeltaTime)
  3185. bShakeDir = !bShakeDir;
  3186. }
  3187. }
  3188. else
  3189. {
  3190. ShakeVert = 0;
  3191. ViewRotation.Roll = ViewRotation.Roll & 65535;
  3192. if (ViewRotation.Roll < 32768)
  3193. {
  3194. if ( ViewRotation.Roll > 0 )
  3195. ViewRotation.Roll = Max(0, ViewRotation.Roll - (Max(ViewRotation.Roll,500) * 10 * FMin(0.1,DeltaTime)));
  3196. }
  3197. else
  3198. {
  3199. ViewRotation.Roll += ((65536 - Max(500,ViewRotation.Roll)) * 10 * FMin(0.1,DeltaTime));
  3200. if ( ViewRotation.Roll > 65534 )
  3201. ViewRotation.Roll = 0;
  3202. }
  3203. }
  3204. }
  3205.  
  3206. function UpdateRotation(float DeltaTime, float maxPitch)
  3207. {
  3208. local rotator newRotation;
  3209.  
  3210. DesiredRotation = ViewRotation; //save old rotation
  3211. ViewRotation.Pitch += 32.0 * DeltaTime * aLookUp;
  3212. ViewRotation.Pitch = ViewRotation.Pitch & 65535;
  3213. If ((ViewRotation.Pitch > 18000) && (ViewRotation.Pitch < 49152))
  3214. {
  3215. If (aLookUp > 0)
  3216. ViewRotation.Pitch = 18000;
  3217. else
  3218. ViewRotation.Pitch = 49152;
  3219. }
  3220. ViewRotation.Yaw += 32.0 * DeltaTime * aTurn;
  3221. ViewShake(deltaTime);
  3222. ViewFlash(deltaTime);
  3223.  
  3224. newRotation = Rotation;
  3225. newRotation.Yaw = ViewRotation.Yaw;
  3226. newRotation.Pitch = ViewRotation.Pitch;
  3227. If ( (newRotation.Pitch > maxPitch * RotationRate.Pitch) && (newRotation.Pitch < 65536 - maxPitch * RotationRate.Pitch) )
  3228. {
  3229. If (ViewRotation.Pitch < 32768)
  3230. newRotation.Pitch = maxPitch * RotationRate.Pitch;
  3231. else
  3232. newRotation.Pitch = 65536 - maxPitch * RotationRate.Pitch;
  3233. }
  3234. setRotation(newRotation);
  3235. }
  3236.  
  3237. function SwimAnimUpdate(bool bNotForward)
  3238. {
  3239. if ( !bAnimTransition && (GetAnimGroup(AnimSequence) != 'Gesture') )
  3240. {
  3241. if ( bNotForward )
  3242. {
  3243. if ( GetAnimGroup(AnimSequence) != 'Waiting' )
  3244. TweenToWaiting(0.1);
  3245. }
  3246. else if ( GetAnimGroup(AnimSequence) == 'Waiting' )
  3247. TweenToSwimming(0.1);
  3248. }
  3249. }
  3250.  
  3251. auto state InvalidState
  3252. {
  3253. event PlayerTick( float DeltaTime )
  3254. {
  3255. log(self$" invalid state");
  3256. if ( bUpdatePosition )
  3257. ClientUpdatePosition();
  3258.  
  3259. PlayerMove(DeltaTime);
  3260. }
  3261.  
  3262. function PlayerMove( float DeltaTime )
  3263. {
  3264. if ( Role < ROLE_Authority ) // then save this move and replicate it
  3265. ReplicateMove(DeltaTime, vect(0,0,0), Dodge_None, rot(0,0,0));
  3266. }
  3267. }
  3268.  
  3269. // Player movement.
  3270. // Player Standing, walking, running, falling.
  3271. state PlayerWalking
  3272. {
  3273. ignores SeePlayer, HearNoise;
  3274.  
  3275. function ZoneChange( ZoneInfo NewZone )
  3276. {
  3277. if (NewZone.bWaterZone)
  3278. {
  3279. setPhysics(PHYS_Swimming);
  3280. GotoState('PlayerSwimming');
  3281. }
  3282. }
  3283.  
  3284. function AnimEnd()
  3285. {
  3286. local name MyAnimGroup;
  3287.  
  3288. bAnimTransition = false;
  3289. if (Physics == PHYS_Walking)
  3290. {
  3291. if (bIsCrouching)
  3292. {
  3293. if ( !bIsTurning && ((Velocity.X * Velocity.X + Velocity.Y * Velocity.Y) < 1000) )
  3294. PlayDuck();
  3295. else
  3296. PlayCrawling();
  3297. }
  3298. else
  3299. {
  3300. MyAnimGroup = GetAnimGroup(AnimSequence);
  3301. if ((Velocity.X * Velocity.X + Velocity.Y * Velocity.Y) < 1000)
  3302. {
  3303. if ( MyAnimGroup == 'Waiting' )
  3304. PlayWaiting();
  3305. else
  3306. {
  3307. bAnimTransition = true;
  3308. TweenToWaiting(0.2);
  3309. }
  3310. }
  3311. else if (bIsWalking)
  3312. {
  3313. if ( (MyAnimGroup == 'Waiting') || (MyAnimGroup == 'Landing') || (MyAnimGroup == 'Gesture') || (MyAnimGroup == 'TakeHit') )
  3314. {
  3315. TweenToWalking(0.1);
  3316. bAnimTransition = true;
  3317. }
  3318. else
  3319. PlayWalking();
  3320. }
  3321. else
  3322. {
  3323. if ( (MyAnimGroup == 'Waiting') || (MyAnimGroup == 'Landing') || (MyAnimGroup == 'Gesture') || (MyAnimGroup == 'TakeHit') )
  3324. {
  3325. bAnimTransition = true;
  3326. TweenToRunning(0.1);
  3327. }
  3328. else
  3329. PlayRunning();
  3330. }
  3331. }
  3332. }
  3333. else
  3334. PlayInAir();
  3335. }
  3336.  
  3337. function Landed(vector HitNormal)
  3338. {
  3339. Global.Landed(HitNormal);
  3340. if (DodgeDir == DODGE_Active)
  3341. {
  3342. DodgeDir = DODGE_Done;
  3343. DodgeClickTimer = 0.0;
  3344. Velocity *= 0.1;
  3345. }
  3346. else
  3347. DodgeDir = DODGE_None;
  3348. }
  3349.  
  3350. function Dodge(eDodgeDir DodgeMove)
  3351. {
  3352. local vector X,Y,Z;
  3353.  
  3354. if ( bIsCrouching || (Physics != PHYS_Walking) )
  3355. return;
  3356.  
  3357. GetAxes(Rotation,X,Y,Z);
  3358. if (DodgeMove == DODGE_Forward)
  3359. Velocity = 1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
  3360. else if (DodgeMove == DODGE_Back)
  3361. Velocity = -1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
  3362. else if (DodgeMove == DODGE_Left)
  3363. Velocity = 1.5*GroundSpeed*Y + (Velocity Dot X)*X;
  3364. else if (DodgeMove == DODGE_Right)
  3365. Velocity = -1.5*GroundSpeed*Y + (Velocity Dot X)*X;
  3366.  
  3367. Velocity.Z = 160;
  3368. PlayOwnedSound(JumpSound, SLOT_Talk, 1.0, true, 800, 1.0 );
  3369. PlayDodge(DodgeMove);
  3370. DodgeDir = DODGE_Active;
  3371. SetPhysics(PHYS_Falling);
  3372. }
  3373.  
  3374. function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
  3375. {
  3376. local vector OldAccel;
  3377.  
  3378. OldAccel = Acceleration;
  3379. Acceleration = NewAccel;
  3380. bIsTurning = ( Abs(DeltaRot.Yaw/DeltaTime) > 5000 );
  3381.  
  3382. // old time shift!!!
  3383. /*
  3384. if (AccelAdjust > 1.0)
  3385. {
  3386. Acceleration = NewAccel;
  3387. Velocity = NewAccel;
  3388. DodgeMove = DODGE_None;
  3389. // return;
  3390. }
  3391. */
  3392. if ( (DodgeMove == DODGE_Active) && (Physics == PHYS_Falling) )
  3393. DodgeDir = DODGE_Active;
  3394. else if ( (DodgeMove != DODGE_None) && (DodgeMove < DODGE_Active) )
  3395. Dodge(DodgeMove);
  3396.  
  3397.  
  3398. if ( bPressedJump )
  3399. DoJump();
  3400. if ( (Physics == PHYS_Walking) && (GetAnimGroup(AnimSequence) != 'Dodge') )
  3401. {
  3402. if (!bIsCrouching)
  3403. {
  3404. if (bDuck != 0)
  3405. {
  3406. bIsCrouching = true;
  3407. PlayDuck();
  3408. }
  3409. }
  3410. else if (bDuck == 0)
  3411. {
  3412. OldAccel = vect(0,0,0);
  3413. bIsCrouching = false;
  3414. TweenToRunning(0.1);
  3415. }
  3416.  
  3417. if ( !bIsCrouching )
  3418. {
  3419. if ( (!bAnimTransition || (AnimFrame > 0)) && (GetAnimGroup(AnimSequence) != 'Landing') )
  3420. {
  3421. if ( Acceleration != vect(0,0,0) )
  3422. {
  3423. if ( (GetAnimGroup(AnimSequence) == 'Waiting') || (GetAnimGroup(AnimSequence) == 'Gesture') || (GetAnimGroup(AnimSequence) == 'TakeHit') )
  3424. {
  3425. bAnimTransition = true;
  3426. TweenToRunning(0.1);
  3427. }
  3428. }
  3429. else if ( (Velocity.X * Velocity.X + Velocity.Y * Velocity.Y < 1000)
  3430. && (GetAnimGroup(AnimSequence) != 'Gesture') )
  3431. {
  3432. if ( GetAnimGroup(AnimSequence) == 'Waiting' )
  3433. {
  3434. if ( bIsTurning && (AnimFrame >= 0) )
  3435. {
  3436. bAnimTransition = true;
  3437. PlayTurning();
  3438. }
  3439. }
  3440. else if ( !bIsTurning )
  3441. {
  3442. bAnimTransition = true;
  3443. TweenToWaiting(0.2);
  3444. }
  3445. }
  3446. }
  3447. }
  3448. else
  3449. {
  3450. if ( (OldAccel == vect(0,0,0)) && (Acceleration != vect(0,0,0)) )
  3451. PlayCrawling();
  3452. else if ( !bIsTurning && (Acceleration == vect(0,0,0)) && (AnimFrame > 0.1) )
  3453. PlayDuck();
  3454. }
  3455. }
  3456. }
  3457.  
  3458. event PlayerTick( float DeltaTime )
  3459. {
  3460. if ( bUpdatePosition )
  3461. ClientUpdatePosition();
  3462.  
  3463. PlayerMove(DeltaTime);
  3464. }
  3465.  
  3466. function PlayerMove( float DeltaTime )
  3467. {
  3468. local vector X,Y,Z, NewAccel;
  3469. local EDodgeDir OldDodge;
  3470. local eDodgeDir DodgeMove;
  3471. local rotator OldRotation;
  3472. local float Speed2D;
  3473. local bool bSaveJump;
  3474. local name AnimGroupName;
  3475.  
  3476. GetAxes(Rotation,X,Y,Z);
  3477.  
  3478. aForward *= 0.4;
  3479. aStrafe *= 0.4;
  3480. aLookup *= 0.24;
  3481. aTurn *= 0.24;
  3482.  
  3483. // Update acceleration. - time shift adjustment
  3484. NewAccel = aForward*X + aStrafe*Y;
  3485. NewAccel.Z = 0;
  3486.  
  3487. /* puke trick!!!!!!!
  3488. if (AccelAdjust > 1.0)
  3489. Velocity *= AccelAdjust;
  3490. */
  3491.  
  3492. // Check for Dodge move
  3493. if ( DodgeDir == DODGE_Active )
  3494. DodgeMove = DODGE_Active;
  3495. else
  3496. DodgeMove = DODGE_None;
  3497. if (DodgeClickTime > 0.0)
  3498. {
  3499. if ( DodgeDir < DODGE_Active )
  3500. {
  3501. OldDodge = DodgeDir;
  3502. DodgeDir = DODGE_None;
  3503. if (bEdgeForward && bWasForward)
  3504. DodgeDir = DODGE_Forward;
  3505. if (bEdgeBack && bWasBack)
  3506. DodgeDir = DODGE_Back;
  3507. if (bEdgeLeft && bWasLeft)
  3508. DodgeDir = DODGE_Left;
  3509. if (bEdgeRight && bWasRight)
  3510. DodgeDir = DODGE_Right;
  3511. if ( DodgeDir == DODGE_None)
  3512. DodgeDir = OldDodge;
  3513. else if ( DodgeDir != OldDodge )
  3514. DodgeClickTimer = DodgeClickTime + 0.5 * DeltaTime;
  3515. else
  3516. DodgeMove = DodgeDir;
  3517. }
  3518.  
  3519. if (DodgeDir == DODGE_Done)
  3520. {
  3521. DodgeClickTimer -= DeltaTime;
  3522. if (DodgeClickTimer < -0.35)
  3523. {
  3524. DodgeDir = DODGE_None;
  3525. DodgeClickTimer = DodgeClickTime;
  3526. }
  3527. }
  3528. else if ((DodgeDir != DODGE_None) && (DodgeDir != DODGE_Active))
  3529. {
  3530. DodgeClickTimer -= DeltaTime;
  3531. if (DodgeClickTimer < 0)
  3532. {
  3533. DodgeDir = DODGE_None;
  3534. DodgeClickTimer = DodgeClickTime;
  3535. }
  3536. }
  3537. }
  3538.  
  3539. AnimGroupName = GetAnimGroup(AnimSequence);
  3540. if ( (Physics == PHYS_Walking) && (AnimGroupName != 'Dodge') )
  3541. {
  3542. //if walking, look up/down stairs - unless player is rotating view
  3543. if ( !bKeyboardLook && (bLook == 0) )
  3544. {
  3545. if ( bLookUpStairs )
  3546. ViewRotation.Pitch = FindStairRotation(deltaTime);
  3547. else if ( bCenterView )
  3548. {
  3549. ViewRotation.Pitch = ViewRotation.Pitch & 65535;
  3550. if (ViewRotation.Pitch > 32768)
  3551. ViewRotation.Pitch -= 65536;
  3552. ViewRotation.Pitch = ViewRotation.Pitch * (1 - 12 * FMin(0.0833, deltaTime));
  3553. if ( Abs(ViewRotation.Pitch) < 1000 )
  3554. ViewRotation.Pitch = 0;
  3555. }
  3556. }
  3557.  
  3558. Speed2D = Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y);
  3559. //add bobbing when walking
  3560. if ( !bShowMenu )
  3561. CheckBob(DeltaTime, Speed2D, Y);
  3562. }
  3563. else if ( !bShowMenu )
  3564. {
  3565. BobTime = 0;
  3566. WalkBob = WalkBob * (1 - FMin(1, 8 * deltatime));
  3567. }
  3568.  
  3569. // Update rotation.
  3570. OldRotation = Rotation;
  3571. UpdateRotation(DeltaTime, 1);
  3572.  
  3573. if ( bPressedJump && (AnimGroupName == 'Dodge') )
  3574. {
  3575. bSaveJump = true;
  3576. bPressedJump = false;
  3577. }
  3578. else
  3579. bSaveJump = false;
  3580.  
  3581. if ( Role < ROLE_Authority ) // then save this move and replicate it
  3582. ReplicateMove(DeltaTime, NewAccel, DodgeMove, OldRotation - Rotation);
  3583. else
  3584. ProcessMove(DeltaTime, NewAccel, DodgeMove, OldRotation - Rotation);
  3585. bPressedJump = bSaveJump;
  3586. }
  3587.  
  3588. function BeginState()
  3589. {
  3590. if ( Mesh == None )
  3591. SetMesh();
  3592. WalkBob = vect(0,0,0);
  3593. DodgeDir = DODGE_None;
  3594. bIsCrouching = false;
  3595. bIsTurning = false;
  3596. bPressedJump = false;
  3597. if (Physics != PHYS_Falling) SetPhysics(PHYS_Walking);
  3598. if ( !IsAnimating() )
  3599. PlayWaiting();
  3600. }
  3601.  
  3602. function EndState()
  3603. {
  3604. WalkBob = vect(0,0,0);
  3605. bIsCrouching = false;
  3606. }
  3607. }
  3608.  
  3609. state FeigningDeath
  3610. {
  3611. ignores SeePlayer, HearNoise, Bump;
  3612.  
  3613. function ZoneChange( ZoneInfo NewZone )
  3614. {
  3615. if (NewZone.bWaterZone)
  3616. {
  3617. setPhysics(PHYS_Swimming);
  3618. GotoState('PlayerSwimming');
  3619. }
  3620. }
  3621.  
  3622. exec function Fire( optional float F )
  3623. {
  3624. bJustFired = true;
  3625. }
  3626.  
  3627. // exec function AltFire( optional float F )
  3628. // {
  3629. // bJustFired = true;
  3630. // }
  3631.  
  3632. function PlayChatting()
  3633. {
  3634. }
  3635.  
  3636. exec function Taunt( name Sequence )
  3637. {
  3638. }
  3639.  
  3640. function AnimEnd()
  3641. {
  3642. if ( Role < ROLE_Authority )
  3643. return;
  3644. if ( Health <= 0 )
  3645. {
  3646. GotoState('Dying');
  3647. return;
  3648. }
  3649. GotoState('PlayerWalking');
  3650. PendingWeapon.SetDefaultDisplayProperties();
  3651. ChangedWeapon();
  3652. }
  3653.  
  3654. function Landed(vector HitNormal)
  3655. {
  3656. if ( Role == ROLE_Authority )
  3657. PlaySound(Land, SLOT_Interact, 0.3, false, 800, 1.0);
  3658. if ( bUpdating )
  3659. return;
  3660. TakeFallingDamage();
  3661. bJustLanded = true;
  3662. }
  3663.  
  3664. function Rise()
  3665. {
  3666. if ( (Role == ROLE_Authority) && (Health <= 0) )
  3667. {
  3668. GotoState('Dying');
  3669. return;
  3670. }
  3671. if ( !bRising )
  3672. {
  3673. Enable('AnimEnd');
  3674. BaseEyeHeight = Default.BaseEyeHeight;
  3675. bRising = true;
  3676. }
  3677. }
  3678.  
  3679. function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
  3680. {
  3681. if ( bJustFired || bPressedJump || (NewAccel.Z > 0) )
  3682. Rise();
  3683. Acceleration = vect(0,0,0);
  3684. }
  3685.  
  3686. event PlayerTick( float DeltaTime )
  3687. {
  3688. Weapon = None; // in case client confused because of weapon switch just before feign death
  3689. if ( bUpdatePosition )
  3690. ClientUpdatePosition();
  3691.  
  3692. PlayerMove(DeltaTime);
  3693. }
  3694.  
  3695. function ServerMove
  3696. (
  3697. float TimeStamp,
  3698. vector Accel,
  3699. vector ClientLoc,
  3700. bool NewbRun,
  3701. bool NewbDuck,
  3702. bool NewbJumpStatus,
  3703. bool bFired,
  3704. bool bAltFired,
  3705. bool bForceFire,
  3706. bool bForceAltFire,
  3707. eDodgeDir DodgeMove,
  3708. byte ClientRoll,
  3709. int View,
  3710. optional byte OldTimeDelta,
  3711. optional int OldAccel
  3712. )
  3713. {
  3714. Global.ServerMove(TimeStamp, Accel, ClientLoc, NewbRun, NewbDuck, NewbJumpStatus,
  3715. bFired, bAltFired, bForceFire, bForceAltFire, DodgeMove, ClientRoll, (32767 & (Rotation.Pitch/2)) * 32768 + (32767 & (Rotation.Yaw/2)));
  3716. }
  3717.  
  3718. function PlayerMove( float DeltaTime)
  3719. {
  3720. local rotator currentRot;
  3721. local vector NewAccel;
  3722.  
  3723. aLookup *= 0.24;
  3724. aTurn *= 0.24;
  3725.  
  3726. // Update acceleration.
  3727. if ( !IsAnimating() && (aForward != 0) || (aStrafe != 0) )
  3728. NewAccel = vect(0,0,1);
  3729. else
  3730. NewAccel = vect(0,0,0);
  3731.  
  3732. // Update view rotation.
  3733. currentRot = Rotation;
  3734. UpdateRotation(DeltaTime, 1);
  3735. SetRotation(currentRot);
  3736.  
  3737. if ( Role < ROLE_Authority ) // then save this move and replicate it
  3738. ReplicateMove(DeltaTime, NewAccel, DODGE_None, Rot(0,0,0));
  3739. else
  3740. ProcessMove(DeltaTime, NewAccel, DODGE_None, Rot(0,0,0));
  3741. bPressedJump = false;
  3742. }
  3743.  
  3744. function PlayTakeHit(float tweentime, vector HitLoc, int Damage)
  3745. {
  3746. if ( IsAnimating() )
  3747. {
  3748. Enable('AnimEnd');
  3749. Global.PlayTakeHit(tweentime, HitLoc, Damage);
  3750. }
  3751. }
  3752.  
  3753. function PlayDying(name DamageType, vector HitLocation)
  3754. {
  3755. BaseEyeHeight = Default.BaseEyeHeight;
  3756. if ( bRising || IsAnimating() )
  3757. Global.PlayDying(DamageType, HitLocation);
  3758. }
  3759.  
  3760. function ChangedWeapon()
  3761. {
  3762. Weapon = None;
  3763. Inventory.ChangedWeapon();
  3764. }
  3765.  
  3766. function EndState()
  3767. {
  3768. bJustFired = false;
  3769. PlayerReplicationInfo.bFeigningDeath = false;
  3770. }
  3771.  
  3772. function BeginState()
  3773. {
  3774. local rotator NewRot;
  3775. if ( carriedDecoration != None )
  3776. DropDecoration();
  3777. NewRot = Rotation;
  3778. NewRot.Pitch = 0;
  3779. SetRotation(NewRot);
  3780. BaseEyeHeight = -0.5 * CollisionHeight;
  3781. bIsCrouching = false;
  3782. bPressedJump = false;
  3783. bJustFired = false;
  3784. bRising = false;
  3785. Disable('AnimEnd');
  3786. PlayerReplicationInfo.bFeigningDeath = true;
  3787. }
  3788. }
  3789.  
  3790. // Player movement.
  3791. // Player Swimming
  3792. state PlayerSwimming
  3793. {
  3794. ignores SeePlayer, HearNoise, Bump;
  3795.  
  3796. event UpdateEyeHeight(float DeltaTime)
  3797. {
  3798. local float smooth, bound;
  3799.  
  3800. // smooth up/down stairs
  3801. if( !bJustLanded )
  3802. {
  3803. smooth = FMin(1.0, 10.0 * DeltaTime/Level.TimeDilation);
  3804. EyeHeight = (EyeHeight - Location.Z + OldLocation.Z) * (1 - smooth) + ( ShakeVert + BaseEyeHeight) * smooth;
  3805. bound = -0.5 * CollisionHeight;
  3806. if (EyeHeight < bound)
  3807. EyeHeight = bound;
  3808. else
  3809. {
  3810. bound = CollisionHeight + FClamp((OldLocation.Z - Location.Z), 0.0, MaxStepHeight);
  3811. if ( EyeHeight > bound )
  3812. EyeHeight = bound;
  3813. }
  3814. }
  3815. else
  3816. {
  3817. smooth = FClamp(10.0 * DeltaTime/Level.TimeDilation, 0.35, 1.0);
  3818. bJustLanded = false;
  3819. EyeHeight = EyeHeight * ( 1 - smooth) + (BaseEyeHeight + ShakeVert) * smooth;
  3820. }
  3821.  
  3822. // teleporters affect your FOV, so adjust it back down
  3823. if ( FOVAngle != DesiredFOV )
  3824. {
  3825. if ( FOVAngle > DesiredFOV )
  3826. FOVAngle = FOVAngle - FMax(7, 0.9 * DeltaTime * (FOVAngle - DesiredFOV));
  3827. else
  3828. FOVAngle = FOVAngle - FMin(-7, 0.9 * DeltaTime * (FOVAngle - DesiredFOV));
  3829. if ( Abs(FOVAngle - DesiredFOV) <= 10 )
  3830. FOVAngle = DesiredFOV;
  3831. }
  3832.  
  3833. // adjust FOV for weapon zooming
  3834. if ( bZooming )
  3835. {
  3836. ZoomLevel += DeltaTime * 1.0;
  3837. if (ZoomLevel > 0.9)
  3838. ZoomLevel = 0.9;
  3839. DesiredFOV = FClamp(90.0 - (ZoomLevel * 88.0), 1, 170);
  3840. }
  3841. }
  3842.  
  3843. function Landed(vector HitNormal)
  3844. {
  3845. if ( !bUpdating )
  3846. {
  3847. //log(class$" Landed while swimming");
  3848. PlayLanded(Velocity.Z);
  3849. TakeFallingDamage();
  3850. bJustLanded = true;
  3851. }
  3852. if ( Region.Zone.bWaterZone )
  3853. SetPhysics(PHYS_Swimming);
  3854. else
  3855. {
  3856. GotoState('PlayerWalking');
  3857. AnimEnd();
  3858. }
  3859. }
  3860.  
  3861. function AnimEnd()
  3862. {
  3863. local vector X,Y,Z;
  3864. GetAxes(Rotation, X,Y,Z);
  3865. if ( (Acceleration Dot X) <= 0 )
  3866. {
  3867. if ( GetAnimGroup(AnimSequence) == 'TakeHit' )
  3868. {
  3869. bAnimTransition = true;
  3870. TweenToWaiting(0.2);
  3871. }
  3872. else
  3873. PlayWaiting();
  3874. }
  3875. else
  3876. {
  3877. if ( GetAnimGroup(AnimSequence) == 'TakeHit' )
  3878. {
  3879. bAnimTransition = true;
  3880. TweenToSwimming(0.2);
  3881. }
  3882. else
  3883. PlaySwimming();
  3884. }
  3885. }
  3886.  
  3887. function ZoneChange( ZoneInfo NewZone )
  3888. {
  3889. local actor HitActor;
  3890. local vector HitLocation, HitNormal, checkpoint;
  3891.  
  3892. if (!NewZone.bWaterZone)
  3893. {
  3894. SetPhysics(PHYS_Falling);
  3895. if (bUpAndOut && CheckWaterJump(HitNormal)) //check for waterjump
  3896. {
  3897. velocity.Z = 330 + 2 * CollisionRadius; //set here so physics uses this for remainder of tick
  3898. PlayDuck();
  3899. GotoState('PlayerWalking');
  3900. }
  3901. else if (!FootRegion.Zone.bWaterZone || (Velocity.Z > 160) )
  3902. {
  3903. GotoState('PlayerWalking');
  3904. AnimEnd();
  3905. }
  3906. else //check if in deep water
  3907. {
  3908. checkpoint = Location;
  3909. checkpoint.Z -= (CollisionHeight + 6.0);
  3910. HitActor = Trace(HitLocation, HitNormal, checkpoint, Location, false);
  3911. if (HitActor != None)
  3912. {
  3913. GotoState('PlayerWalking');
  3914. AnimEnd();
  3915. }
  3916. else
  3917. {
  3918. Enable('Timer');
  3919. SetTimer(0.7,false);
  3920. }
  3921. }
  3922. //log("Out of water");
  3923. }
  3924. else
  3925. {
  3926. Disable('Timer');
  3927. SetPhysics(PHYS_Swimming);
  3928. }
  3929. }
  3930.  
  3931. function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
  3932. {
  3933. local vector X,Y,Z, Temp;
  3934.  
  3935. GetAxes(ViewRotation,X,Y,Z);
  3936. Acceleration = NewAccel;
  3937.  
  3938. SwimAnimUpdate( (X Dot Acceleration) <= 0 );
  3939.  
  3940. bUpAndOut = ((X Dot Acceleration) > 0) && ((Acceleration.Z > 0) || (ViewRotation.Pitch > 2048));
  3941. if ( bUpAndOut && !Region.Zone.bWaterZone && CheckWaterJump(Temp) ) //check for waterjump
  3942. {
  3943. velocity.Z = 330 + 2 * CollisionRadius; //set here so physics uses this for remainder of tick
  3944. PlayDuck();
  3945. GotoState('PlayerWalking');
  3946. }
  3947. }
  3948.  
  3949. event PlayerTick( float DeltaTime )
  3950. {
  3951. if ( bUpdatePosition )
  3952. ClientUpdatePosition();
  3953.  
  3954. PlayerMove(DeltaTime);
  3955. }
  3956.  
  3957. function PlayerMove(float DeltaTime)
  3958. {
  3959. local rotator oldRotation;
  3960. local vector X,Y,Z, NewAccel;
  3961. local float Speed2D;
  3962.  
  3963. GetAxes(ViewRotation,X,Y,Z);
  3964.  
  3965. aForward *= 0.2;
  3966. aStrafe *= 0.1;
  3967. aLookup *= 0.24;
  3968. aTurn *= 0.24;
  3969. aUp *= 0.1;
  3970.  
  3971. NewAccel = aForward*X + aStrafe*Y + aUp*vect(0,0,1);
  3972.  
  3973. //add bobbing when swimming
  3974. if ( !bShowMenu )
  3975. {
  3976. Speed2D = Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y);
  3977. WalkBob = Y * Bob * 0.5 * Speed2D * sin(4.0 * Level.TimeSeconds);
  3978. WalkBob.Z = Bob * 1.5 * Speed2D * sin(8.0 * Level.TimeSeconds);
  3979. }
  3980.  
  3981. // Update rotation.
  3982. oldRotation = Rotation;
  3983. UpdateRotation(DeltaTime, 2);
  3984.  
  3985. if ( Role < ROLE_Authority ) // then save this move and replicate it
  3986. ReplicateMove(DeltaTime, NewAccel, DODGE_None, OldRotation - Rotation);
  3987. else
  3988. ProcessMove(DeltaTime, NewAccel, DODGE_None, OldRotation - Rotation);
  3989. bPressedJump = false;
  3990. }
  3991.  
  3992. function Timer()
  3993. {
  3994. if ( !Region.Zone.bWaterZone && (Role == ROLE_Authority) )
  3995. {
  3996. //log("timer out of water");
  3997. GotoState('PlayerWalking');
  3998. AnimEnd();
  3999. }
  4000.  
  4001. Disable('Timer');
  4002. }
  4003.  
  4004. function BeginState()
  4005. {
  4006. Disable('Timer');
  4007. if ( !IsAnimating() )
  4008. TweenToWaiting(0.3);
  4009. //log("player swimming");
  4010. }
  4011. }
  4012.  
  4013. state PlayerFlying
  4014. {
  4015. ignores SeePlayer, HearNoise, Bump;
  4016.  
  4017. function AnimEnd()
  4018. {
  4019. PlaySwimming();
  4020. }
  4021.  
  4022. event PlayerTick( float DeltaTime )
  4023. {
  4024. if ( bUpdatePosition )
  4025. ClientUpdatePosition();
  4026.  
  4027. PlayerMove(DeltaTime);
  4028. }
  4029.  
  4030. function PlayerMove(float DeltaTime)
  4031. {
  4032. local rotator newRotation;
  4033. local vector X,Y,Z;
  4034.  
  4035. GetAxes(Rotation,X,Y,Z);
  4036.  
  4037. aForward *= 0.2;
  4038. aStrafe *= 0.2;
  4039. aLookup *= 0.24;
  4040. aTurn *= 0.24;
  4041.  
  4042. Acceleration = aForward*X + aStrafe*Y;
  4043. // Update rotation.
  4044. UpdateRotation(DeltaTime, 2);
  4045.  
  4046. if ( Role < ROLE_Authority ) // then save this move and replicate it
  4047. ReplicateMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4048. else
  4049. ProcessMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4050. }
  4051.  
  4052. function BeginState()
  4053. {
  4054. SetPhysics(PHYS_Flying);
  4055. if ( !IsAnimating() ) PlayWalking();
  4056. //log("player flying");
  4057. }
  4058. }
  4059.  
  4060. state CheatFlying
  4061. {
  4062. ignores SeePlayer, HearNoise, Bump, TakeDamage;
  4063.  
  4064. function AnimEnd()
  4065. {
  4066. PlaySwimming();
  4067. }
  4068.  
  4069. function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
  4070. {
  4071. Acceleration = Normal(NewAccel);
  4072. Velocity = Normal(NewAccel) * 300;
  4073. AutonomousPhysics(DeltaTime);
  4074. }
  4075.  
  4076. event PlayerTick( float DeltaTime )
  4077. {
  4078. if ( bUpdatePosition )
  4079. ClientUpdatePosition();
  4080.  
  4081. PlayerMove(DeltaTime);
  4082. }
  4083.  
  4084. function PlayerMove(float DeltaTime)
  4085. {
  4086. local rotator newRotation;
  4087. local vector X,Y,Z;
  4088.  
  4089. GetAxes(ViewRotation,X,Y,Z);
  4090.  
  4091. aForward *= 0.1;
  4092. aStrafe *= 0.1;
  4093. aLookup *= 0.24;
  4094. aTurn *= 0.24;
  4095. aUp *= 0.1;
  4096.  
  4097. Acceleration = aForward*X + aStrafe*Y + aUp*vect(0,0,1);
  4098.  
  4099. UpdateRotation(DeltaTime, 1);
  4100.  
  4101. if ( Role < ROLE_Authority ) // then save this move and replicate it
  4102. ReplicateMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4103. else
  4104. ProcessMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4105. }
  4106.  
  4107. function BeginState()
  4108. {
  4109. EyeHeight = BaseEyeHeight;
  4110. SetPhysics(PHYS_Flying);
  4111. if ( !IsAnimating() ) PlaySwimming();
  4112. // log("cheat flying");
  4113. }
  4114. }
  4115.  
  4116. state PlayerWaiting
  4117. {
  4118. ignores SeePlayer, HearNoise, Bump, TakeDamage, Died, ZoneChange, FootZoneChange;
  4119.  
  4120. exec function Jump( optional float F )
  4121. {
  4122. }
  4123.  
  4124. exec function Suicide()
  4125. {
  4126. }
  4127.  
  4128. function ChangeTeam( int N )
  4129. {
  4130. Level.Game.ChangeTeam(self, N);
  4131. }
  4132.  
  4133. exec function Fire(optional float F)
  4134. {
  4135. bReadyToPlay = true;
  4136. }
  4137.  
  4138. exec function AltFire(optional float F)
  4139. {
  4140. bReadyToPlay = true;
  4141. }
  4142.  
  4143. function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
  4144. {
  4145. Acceleration = NewAccel;
  4146. MoveSmooth(Acceleration * DeltaTime);
  4147. }
  4148.  
  4149. function PlayWaiting() {}
  4150.  
  4151. event PlayerTick( float DeltaTime )
  4152. {
  4153. if ( bUpdatePosition )
  4154. ClientUpdatePosition();
  4155.  
  4156. PlayerMove(DeltaTime);
  4157. }
  4158.  
  4159. function PlayerMove(float DeltaTime)
  4160. {
  4161. local rotator newRotation;
  4162. local vector X,Y,Z;
  4163.  
  4164. GetAxes(ViewRotation,X,Y,Z);
  4165.  
  4166. aForward *= 0.1;
  4167. aStrafe *= 0.1;
  4168. aLookup *= 0.24;
  4169. aTurn *= 0.24;
  4170. aUp *= 0.1;
  4171.  
  4172. Acceleration = aForward*X + aStrafe*Y + aUp*vect(0,0,1);
  4173.  
  4174. UpdateRotation(DeltaTime, 1);
  4175.  
  4176. if ( Role < ROLE_Authority ) // then save this move and replicate it
  4177. ReplicateMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4178. else
  4179. ProcessMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4180. }
  4181.  
  4182. function EndState()
  4183. {
  4184. SetMesh();
  4185. PlayerReplicationInfo.bIsSpectator = false;
  4186. PlayerReplicationInfo.bWaitingPlayer = false;
  4187. SetCollision(true,true,true);
  4188. }
  4189.  
  4190. function BeginState()
  4191. {
  4192. Mesh = None;
  4193. if ( PlayerReplicationInfo != None )
  4194. {
  4195. PlayerReplicationInfo.bIsSpectator = true;
  4196. PlayerReplicationInfo.bWaitingPlayer = true;
  4197. }
  4198. SetCollision(false,false,false);
  4199. EyeHeight = BaseEyeHeight;
  4200. SetPhysics(PHYS_None);
  4201. }
  4202. }
  4203.  
  4204. state PlayerSpectating
  4205. {
  4206. ignores SeePlayer, HearNoise, Bump, TakeDamage, Died, ZoneChange, FootZoneChange;
  4207.  
  4208. exec function Suicide()
  4209. {
  4210. }
  4211.  
  4212. function SendVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID, name broadcasttype)
  4213. {
  4214. }
  4215.  
  4216. exec function AltFire( optional float F )
  4217. {
  4218. bBehindView = false;
  4219. Viewtarget = None;
  4220. ClientMessage(ViewingFrom@OwnCamera, 'Event', true);
  4221. }
  4222.  
  4223. function ChangeTeam( int N )
  4224. {
  4225. Level.Game.ChangeTeam(self, N);
  4226. }
  4227.  
  4228. exec function Fire( optional float F )
  4229. {
  4230. if ( Role == ROLE_Authority )
  4231. {
  4232. ViewPlayerNum(-1);
  4233. bBehindView = true;
  4234. }
  4235. }
  4236.  
  4237. function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
  4238. {
  4239. Acceleration = NewAccel;
  4240. MoveSmooth(Acceleration * DeltaTime);
  4241. }
  4242.  
  4243. event PlayerTick( float DeltaTime )
  4244. {
  4245. if ( bUpdatePosition )
  4246. ClientUpdatePosition();
  4247.  
  4248. PlayerMove(DeltaTime);
  4249. }
  4250.  
  4251. function PlayerMove(float DeltaTime)
  4252. {
  4253. local rotator newRotation;
  4254. local vector X,Y,Z;
  4255.  
  4256. GetAxes(ViewRotation,X,Y,Z);
  4257.  
  4258. aForward *= 0.1;
  4259. aStrafe *= 0.1;
  4260. aLookup *= 0.24;
  4261. aTurn *= 0.24;
  4262. aUp *= 0.1;
  4263.  
  4264. Acceleration = aForward*X + aStrafe*Y + aUp*vect(0,0,1);
  4265.  
  4266. UpdateRotation(DeltaTime, 1);
  4267.  
  4268. if ( Role < ROLE_Authority ) // then save this move and replicate it
  4269. ReplicateMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4270. else
  4271. ProcessMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
  4272. }
  4273.  
  4274. function EndState()
  4275. {
  4276. PlayerReplicationInfo.bIsSpectator = false;
  4277. PlayerReplicationInfo.bWaitingPlayer = false;
  4278. SetMesh();
  4279. SetCollision(true,true,true);
  4280. }
  4281.  
  4282. function BeginState()
  4283. {
  4284. PlayerReplicationInfo.bIsSpectator = true;
  4285. PlayerReplicationInfo.bWaitingPlayer = true;
  4286. bShowScores = true;
  4287. Mesh = None;
  4288. SetCollision(false,false,false);
  4289. EyeHeight = Default.BaseEyeHeight;
  4290. SetPhysics(PHYS_None);
  4291. }
  4292. }
  4293. //===============================================================================
  4294. state PlayerWaking
  4295. {
  4296. ignores SeePlayer, HearNoise, KilledBy, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, SwitchWeapon, Falling;
  4297.  
  4298. function Timer()
  4299. {
  4300. BaseEyeHeight = Default.BaseEyeHeight;
  4301. }
  4302.  
  4303. event PlayerTick( float DeltaTime )
  4304. {
  4305. if ( bUpdatePosition )
  4306. ClientUpdatePosition();
  4307.  
  4308. PlayerMove(DeltaTime);
  4309. }
  4310.  
  4311. function PlayerMove(Float DeltaTime)
  4312. {
  4313. ViewFlash(deltaTime * 0.5);
  4314. if ( TimerRate == 0 )
  4315. {
  4316. ViewRotation.Pitch -= DeltaTime * 12000;
  4317. if ( ViewRotation.Pitch < 0 )
  4318. {
  4319. ViewRotation.Pitch = 0;
  4320. GotoState('PlayerWalking');
  4321. }
  4322. }
  4323.  
  4324. if ( Role < ROLE_Authority ) // then save this move and replicate it
  4325. ReplicateMove(DeltaTime, vect(0,0,0), DODGE_None, rot(0,0,0));
  4326. else
  4327. ProcessMove(DeltaTime, vect(0,0,0), DODGE_None, rot(0,0,0));
  4328. }
  4329.  
  4330. function BeginState()
  4331. {
  4332. if ( bWokeUp )
  4333. {
  4334. ViewRotation.Pitch = 0;
  4335. SetTimer(0, false);
  4336. return;
  4337. }
  4338. BaseEyeHeight = 0;
  4339. EyeHeight = 0;
  4340. SetTimer(3.0, false);
  4341. bWokeUp = true;
  4342. }
  4343. }
  4344.  
  4345. state Dying
  4346. {
  4347. ignores SeePlayer, HearNoise, KilledBy, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, SwitchWeapon, Falling, PainTimer;
  4348.  
  4349. function ServerReStartPlayer()
  4350. {
  4351. //log("calling restartplayer in dying with netmode "$Level.NetMode);
  4352. if ( Level.NetMode == NM_Client )
  4353. return;
  4354. if( Level.Game.RestartPlayer(self) )
  4355. {
  4356. ServerTimeStamp = 0;
  4357. TimeMargin = 0;
  4358. Enemy = None;
  4359. Level.Game.StartPlayer(self);
  4360. if ( Mesh != None )
  4361. PlayWaiting();
  4362. ClientReStart();
  4363. }
  4364. else
  4365. log("Restartplayer failed");
  4366. }
  4367.  
  4368. exec function Fire( optional float F )
  4369. {
  4370. if ( (Level.NetMode == NM_Standalone) && !Level.Game.bDeathMatch )
  4371. {
  4372. if ( bFrozen )
  4373. return;
  4374. ShowLoadMenu();
  4375. }
  4376. else if ( !bFrozen || (FRand() < 0.2) )
  4377. ServerReStartPlayer();
  4378. }
  4379.  
  4380. exec function AltFire( optional float F )
  4381. {
  4382. Fire(F);
  4383. }
  4384.  
  4385. function PlayChatting()
  4386. {
  4387. }
  4388.  
  4389. exec function Taunt( name Sequence )
  4390. {
  4391. }
  4392.  
  4393. function ServerMove
  4394. (
  4395. float TimeStamp,
  4396. vector Accel,
  4397. vector ClientLoc,
  4398. bool NewbRun,
  4399. bool NewbDuck,
  4400. bool NewbJumpStatus,
  4401. bool bFired,
  4402. bool bAltFired,
  4403. bool bForceFire,
  4404. bool bForceAltFire,
  4405. eDodgeDir DodgeMove,
  4406. byte ClientRoll,
  4407. int View,
  4408. optional byte OldTimeDelta,
  4409. optional int OldAccel
  4410. )
  4411. {
  4412. Global.ServerMove(
  4413. TimeStamp,
  4414. Accel,
  4415. ClientLoc,
  4416. false,
  4417. false,
  4418. false,
  4419. false,
  4420. false,
  4421. false,
  4422. false,
  4423. DodgeMove,
  4424. ClientRoll,
  4425. View);
  4426. }
  4427.  
  4428. function PlayerCalcView(out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )
  4429. {
  4430. local vector View,HitLocation,HitNormal, FirstHit, spot;
  4431. local float DesiredDist, ViewDist, WallOutDist;
  4432. local actor HitActor;
  4433. local Pawn PTarget;
  4434.  
  4435. if ( ViewTarget != None )
  4436. {
  4437. ViewActor = ViewTarget;
  4438. CameraLocation = ViewTarget.Location;
  4439. CameraRotation = ViewTarget.Rotation;
  4440. PTarget = Pawn(ViewTarget);
  4441. if ( PTarget != None )
  4442. {
  4443. if ( Level.NetMode == NM_Client )
  4444. {
  4445. if ( PTarget.bIsPlayer )
  4446. PTarget.ViewRotation = TargetViewRotation;
  4447. PTarget.EyeHeight = TargetEyeHeight;
  4448. if ( PTarget.Weapon != None )
  4449. PTarget.Weapon.PlayerViewOffset = TargetWeaponViewOffset;
  4450. }
  4451. if ( PTarget.bIsPlayer )
  4452. CameraRotation = PTarget.ViewRotation;
  4453. CameraLocation.Z += PTarget.EyeHeight;
  4454. }
  4455.  
  4456. if ( Carcass(ViewTarget) != None )
  4457. {
  4458. if ( bBehindView || (ViewTarget.Physics == PHYS_None) )
  4459. CameraRotation = ViewRotation;
  4460. else
  4461. ViewRotation = CameraRotation;
  4462. if ( bBehindView )
  4463. CalcBehindView(CameraLocation, CameraRotation, 190);
  4464. }
  4465. else if ( bBehindView )
  4466. CalcBehindView(CameraLocation, CameraRotation, 180);
  4467.  
  4468. return;
  4469. }
  4470.  
  4471. // View rotation.
  4472. CameraRotation = ViewRotation;
  4473. DesiredFOV = DefaultFOV;
  4474. ViewActor = self;
  4475. if( bBehindView ) //up and behind (for death scene)
  4476. CalcBehindView(CameraLocation, CameraRotation, 180);
  4477. else
  4478. {
  4479. // First-person view.
  4480. CameraLocation = Location;
  4481. CameraLocation.Z += Default.BaseEyeHeight;
  4482. }
  4483. }
  4484.  
  4485. event PlayerTick( float DeltaTime )
  4486. {
  4487. if ( bUpdatePosition )
  4488. ClientUpdatePosition();
  4489.  
  4490. PlayerMove(DeltaTime);
  4491. }
  4492.  
  4493. function PlayerMove(float DeltaTime)
  4494. {
  4495. local vector X,Y,Z;
  4496.  
  4497. if ( !bFrozen )
  4498. {
  4499. if ( bPressedJump )
  4500. {
  4501. Fire(0);
  4502. bPressedJump = false;
  4503. }
  4504. GetAxes(ViewRotation,X,Y,Z);
  4505. // Update view rotation.
  4506. aLookup *= 0.24;
  4507. aTurn *= 0.24;
  4508. ViewRotation.Yaw += 32.0 * DeltaTime * aTurn;
  4509. ViewRotation.Pitch += 32.0 * DeltaTime * aLookUp;
  4510. ViewRotation.Pitch = ViewRotation.Pitch & 65535;
  4511. If ((ViewRotation.Pitch > 18000) && (ViewRotation.Pitch < 49152))
  4512. {
  4513. If (aLookUp > 0)
  4514. ViewRotation.Pitch = 18000;
  4515. else
  4516. ViewRotation.Pitch = 49152;
  4517. }
  4518. if ( Role < ROLE_Authority ) // then save this move and replicate it
  4519. ReplicateMove(DeltaTime, vect(0,0,0), DODGE_None, rot(0,0,0));
  4520. }
  4521. ViewShake(DeltaTime);
  4522. ViewFlash(DeltaTime);
  4523. }
  4524.  
  4525. function FindGoodView()
  4526. {
  4527. local vector cameraLoc;
  4528. local rotator cameraRot;
  4529. local int tries, besttry;
  4530. local float bestdist, newdist;
  4531. local int startYaw;
  4532. local actor ViewActor;
  4533.  
  4534. //fixme - try to pick view with killer visible
  4535. //fixme - also try varying starting pitch
  4536. ////log("Find good death scene view");
  4537. ViewRotation.Pitch = 56000;
  4538. tries = 0;
  4539. besttry = 0;
  4540. bestdist = 0.0;
  4541. startYaw = ViewRotation.Yaw;
  4542.  
  4543. for (tries=0; tries<16; tries++)
  4544. {
  4545. cameraLoc = Location;
  4546. PlayerCalcView(ViewActor, cameraLoc, cameraRot);
  4547. newdist = VSize(cameraLoc - Location);
  4548. if (newdist > bestdist)
  4549. {
  4550. bestdist = newdist;
  4551. besttry = tries;
  4552. }
  4553. ViewRotation.Yaw += 4096;
  4554. }
  4555.  
  4556. ViewRotation.Yaw = startYaw + besttry * 4096;
  4557. }
  4558.  
  4559. function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
  4560. Vector momentum, name damageType)
  4561. {
  4562. if ( !bHidden )
  4563. Super.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
  4564. }
  4565.  
  4566. function Timer()
  4567. {
  4568. bFrozen = false;
  4569. bShowScores = true;
  4570. bPressedJump = false;
  4571. }
  4572.  
  4573. function BeginState()
  4574. {
  4575. BaseEyeheight = Default.BaseEyeHeight;
  4576. EyeHeight = BaseEyeHeight;
  4577. if ( Carcass(ViewTarget) == None )
  4578. bBehindView = true;
  4579. bFrozen = true;
  4580. bPressedJump = false;
  4581. bJustFired = false;
  4582. bJustAltFired = false;
  4583. FindGoodView();
  4584. if ( (Role == ROLE_Authority) && !bHidden )
  4585. Super.Timer();
  4586. SetTimer(1.0, false);
  4587.  
  4588. // clean out saved moves
  4589. while ( SavedMoves != None )
  4590. {
  4591. SavedMoves.Destroy();
  4592. SavedMoves = SavedMoves.NextMove;
  4593. }
  4594. if ( PendingMove != None )
  4595. {
  4596. PendingMove.Destroy();
  4597. PendingMove = None;
  4598. }
  4599. }
  4600.  
  4601. function EndState()
  4602. {
  4603. // clean out saved moves
  4604. while ( SavedMoves != None )
  4605. {
  4606. SavedMoves.Destroy();
  4607. SavedMoves = SavedMoves.NextMove;
  4608. }
  4609. if ( PendingMove != None )
  4610. {
  4611. PendingMove.Destroy();
  4612. PendingMove = None;
  4613. }
  4614. Velocity = vect(0,0,0);
  4615. Acceleration = vect(0,0,0);
  4616. bBehindView = false;
  4617. bShowScores = false;
  4618. bJustFired = false;
  4619. bJustAltFired = false;
  4620. bPressedJump = false;
  4621. if ( Carcass(ViewTarget) != None )
  4622. ViewTarget = None;
  4623. //Log(self$" exiting dying with remote role "$RemoteRole$" and role "$Role);
  4624. }
  4625. }
  4626.  
  4627. state GameEnded
  4628. {
  4629. ignores SeePlayer, HearNoise, KilledBy, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, Falling, TakeDamage, PainTimer, Died, Suicide;
  4630.  
  4631. exec function ThrowWeapon()
  4632. {
  4633. }
  4634.  
  4635. exec function Taunt( name Sequence )
  4636. {
  4637. if ( Health > 0 )
  4638. Global.Taunt(Sequence);
  4639. }
  4640.  
  4641. exec function ViewClass( class<actor> aClass, optional bool bQuiet )
  4642. {
  4643. }
  4644. exec function ViewPlayer( string S )
  4645. {
  4646. }
  4647.  
  4648.  
  4649. function ServerReStartGame()
  4650. {
  4651. Level.Game.RestartGame();
  4652. }
  4653.  
  4654. exec function Fire( optional float F )
  4655. {
  4656. if ( Role < ROLE_Authority)
  4657. return;
  4658. if ( !bFrozen )
  4659. ServerReStartGame();
  4660. else if ( TimerRate <= 0 )
  4661. SetTimer(1.5, false);
  4662. }
  4663.  
  4664. exec function AltFire( optional float F )
  4665. {
  4666. Fire(F);
  4667. }
  4668.  
  4669. event PlayerTick( float DeltaTime )
  4670. {
  4671. if ( bUpdatePosition )
  4672. ClientUpdatePosition();
  4673.  
  4674. PlayerMove(DeltaTime);
  4675. }
  4676.  
  4677. function PlayerMove(float DeltaTime)
  4678. {
  4679. local vector X,Y,Z;
  4680.  
  4681. GetAxes(ViewRotation,X,Y,Z);
  4682. // Update view rotation.
  4683.  
  4684. if ( !bFixedCamera )
  4685. {
  4686. aLookup *= 0.24;
  4687. aTurn *= 0.24;
  4688. ViewRotation.Yaw += 32.0 * DeltaTime * aTurn;
  4689. ViewRotation.Pitch += 32.0 * DeltaTime * aLookUp;
  4690. ViewRotation.Pitch = ViewRotation.Pitch & 65535;
  4691. If ((ViewRotation.Pitch > 18000) && (ViewRotation.Pitch < 49152))
  4692. {
  4693. If (aLookUp > 0)
  4694. ViewRotation.Pitch = 18000;
  4695. else
  4696. ViewRotation.Pitch = 49152;
  4697. }
  4698. }
  4699. else if ( ViewTarget != None )
  4700. ViewRotation = ViewTarget.Rotation;
  4701.  
  4702. ViewShake(DeltaTime);
  4703. ViewFlash(DeltaTime);
  4704.  
  4705. if ( Role < ROLE_Authority ) // then save this move and replicate it
  4706. ReplicateMove(DeltaTime, vect(0,0,0), DODGE_None, rot(0,0,0));
  4707. else
  4708. ProcessMove(DeltaTime, vect(0,0,0), DODGE_None, rot(0,0,0));
  4709. bPressedJump = false;
  4710. }
  4711.  
  4712. function ServerMove
  4713. (
  4714. float TimeStamp,
  4715. vector InAccel,
  4716. vector ClientLoc,
  4717. bool NewbRun,
  4718. bool NewbDuck,
  4719. bool NewbJumpStatus,
  4720. bool bFired,
  4721. bool bAltFired,
  4722. bool bForceFire,
  4723. bool bForceAltFire,
  4724. eDodgeDir DodgeMove,
  4725. byte ClientRoll,
  4726. int View,
  4727. optional byte OldTimeDelta,
  4728. optional int OldAccel
  4729. )
  4730. {
  4731. Global.ServerMove(TimeStamp, InAccel, ClientLoc, NewbRun, NewbDuck, NewbJumpStatus,
  4732. bFired, bAltFired, bForceFire, bForceAltFire, DodgeMove, ClientRoll, (32767 & (ViewRotation.Pitch/2)) * 32768 + (32767 & (ViewRotation.Yaw/2)) );
  4733.  
  4734. }
  4735.  
  4736. function FindGoodView()
  4737. {
  4738. local vector cameraLoc;
  4739. local rotator cameraRot;
  4740. local int tries, besttry;
  4741. local float bestdist, newdist;
  4742. local int startYaw;
  4743. local actor ViewActor;
  4744.  
  4745. ViewRotation.Pitch = 56000;
  4746. tries = 0;
  4747. besttry = 0;
  4748. bestdist = 0.0;
  4749. startYaw = ViewRotation.Yaw;
  4750.  
  4751. for (tries=0; tries<16; tries++)
  4752. {
  4753. if ( ViewTarget != None )
  4754. cameraLoc = ViewTarget.Location;
  4755. else
  4756. cameraLoc = Location;
  4757. PlayerCalcView(ViewActor, cameraLoc, cameraRot);
  4758. newdist = VSize(cameraLoc - Location);
  4759. if (newdist > bestdist)
  4760. {
  4761. bestdist = newdist;
  4762. besttry = tries;
  4763. }
  4764. ViewRotation.Yaw += 4096;
  4765. }
  4766.  
  4767. ViewRotation.Yaw = startYaw + besttry * 4096;
  4768. }
  4769.  
  4770. function Timer()
  4771. {
  4772. bFrozen = false;
  4773. }
  4774.  
  4775. function BeginState()
  4776. {
  4777. local Pawn P;
  4778.  
  4779. EndZoom();
  4780. AnimRate = 0.0;
  4781. SimAnim.Y = 0;
  4782. bFire = 0;
  4783. bAltFire = 0;
  4784. SetCollision(false,false,false);
  4785. bShowScores = true;
  4786. bFrozen = true;
  4787. if ( !bFixedCamera )
  4788. {
  4789. FindGoodView();
  4790. bBehindView = true;
  4791. }
  4792. SetTimer(1.5, false);
  4793. SetPhysics(PHYS_None);
  4794. ForEach AllActors(class'Pawn', P)
  4795. {
  4796. P.Velocity = vect(0,0,0);
  4797. P.SetPhysics(PHYS_None);
  4798. }
  4799. }
  4800. }
  4801.  
  4802. // ngStats Accessors
  4803. function string GetNGSecret()
  4804. {
  4805. return ngWorldSecret;
  4806. }
  4807.  
  4808. function SetNGSecret(string newSecret)
  4809. {
  4810. ngWorldSecret = newSecret;
  4811. }
  4812.  
  4813.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement