Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 00665 00666 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 00685 00686 00687 00688 00689 00690 00691 00692 00693 00694 00695 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 00706 00707 00708 00709 00710 00711 00712 00713 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 00748 00749 00750 00751 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 00768 00769 00770 00771 00772 00773 00774 00775 00776 00777 00778 00779 00780 00781 00782 00783 00784 00785 00786 00787 00788 00789 00790 00791 00792 00793 00794 00795 00796 00797 00798 00799 00800 00801 00802 00803 00804 00805 00806 00807 00808 00809 00810 00811 00812 00813 00814 00815 00816 00817 00818 00819 00820 00821 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 00849 00850 00851 00852 00853 00854 00855 00856 00857 00858 00859 00860 00861 00862 00863 00864 00865 00866 00867 00868 00869 00870 00871 00872 00873 00874 00875 00876 00877 00878 00879 00880 00881 00882 00883 00884 00885 00886 00887 00888 00889 00890 00891 00892 00893 00894 00895 00896 00897 00898 00899 00900 00901 00902 00903 00904 00905 00906 00907 00908 00909 00910 00911 00912 00913 00914 00915 00916 00917 00918 00919 00920 00921 00922 00923 00924 00925 00926 00927 00928 00929 00930 00931 00932 00933 00934 00935 00936 00937 00938 00939 00940 00941 00942 00943 00944 00945 00946 00947 00948 00949 00950 00951 00952 00953 00954 00955 00956 00957 00958 00959 00960 00961 00962 00963 00964 00965 00966 00967 00968 00969 00970 00971 00972 00973 00974 00975 00976 00977 00978 00979 00980 00981 00982 00983 00984 00985 00986 00987 00988 00989 00990 00991 00992 00993 00994 00995 00996 00997 00998 00999 01000 01001 01002 01003 01004 01005 01006 01007 01008 01009 01010 01011 01012 01013 01014 01015 01016 01017 01018 01019 01020 01021 01022 01023 01024 01025 01026 01027 01028 01029 01030 01031 01032 01033 01034 01035 01036 01037 01038 01039 01040 01041 01042 01043 01044 01045 01046 01047 01048 01049 01050 01051 01052 01053 01054 01055 01056 01057 01058 01059 01060 01061 01062 01063 01064 01065 01066 01067 01068 01069 01070 01071 01072 01073 01074 01075 01076 01077 01078 01079 01080 01081 01082 01083 01084 01085 01086 01087 01088 01089 01090 01091 01092 01093 01094 01095 01096 01097 01098 01099 01100 01101 01102 01103 01104 01105 01106 01107 01108 01109 01110 01111 01112 01113 01114 01115 01116 01117 01118 01119 01120 01121 01122 01123 01124 01125 01126 01127 01128 01129 01130 01131 01132 01133 01134 01135 01136 01137 01138 01139 01140 01141 01142 01143 01144 01145 01146 01147 01148 01149 01150 01151 01152 01153 01154 01155 01156 01157 01158 01159 01160 01161 01162 01163 01164 01165 01166 01167 01168 01169 01170 01171 01172 01173 01174 01175 01176 01177 01178 01179 01180 01181 01182 01183 01184 01185 01186 01187 01188 01189 01190 01191 01192 01193 01194 01195 01196 01197 01198 01199 01200 01201 01202 01203 01204 01205 01206 01207 01208 01209 01210 01211 01212 01213 01214 01215 01216 01217 01218 01219 01220 01221 01222 01223 01224 01225 01226 01227 01228 01229 01230 01231 01232 01233 01234 01235 01236 01237 01238 01239 01240 01241 01242 01243 01244 01245 01246 01247 01248 01249 01250 01251 01252 01253 01254 01255 01256 01257 01258 01259 01260 01261 01262 01263 01264 01265 01266 01267 01268 01269 01270 01271 01272 01273 01274 01275 01276 01277 01278 01279 01280 01281 01282 01283 01284 01285 01286 01287 01288 01289 01290 01291 01292 01293 01294 01295 01296 01297 01298 01299 01300 01301 01302 01303 01304 01305 01306 01307 01308 01309 01310 01311 01312 01313 01314 01315 01316 01317 01318 01319 01320 01321 01322 01323 01324 01325 01326 01327 01328 01329 01330 01331 01332 01333 01334 01335 01336 01337 01338 01339 01340 01341 01342 01343 01344 01345 01346 01347 01348 01349 01350 01351 01352 01353 01354 01355 01356 01357 01358 01359 01360 01361 01362 01363 01364 01365 01366 01367 01368 01369 01370 01371 01372 01373 01374 01375 01376 01377 01378 01379 01380 01381 01382 01383 01384 01385 01386 01387 01388 01389 01390 01391 01392 01393 01394 01395 01396 01397 01398 01399 01400 01401 01402 01403 01404 01405 01406 01407 01408 01409 01410 01411 01412 01413 01414 01415 01416 01417 01418 01419 01420 01421 01422 01423 01424 01425 01426 01427 01428 01429 01430 01431 01432 01433 01434 01435 01436 01437 01438 01439 01440 01441 01442 01443 01444 01445 01446 01447 01448 01449 01450 01451 01452 01453 01454 01455 01456 01457 01458 01459 01460 01461 01462 01463 01464 01465 01466 01467 01468 01469 01470 01471 01472 01473 01474 01475 01476 01477 01478 01479 01480 01481 01482 01483 01484 01485 01486 01487 01488 01489 01490 01491 01492 01493 01494 01495 01496 01497 01498 01499 01500 01501 01502 01503 01504 01505 01506 01507 01508 01509 01510 01511 01512 01513 01514 01515 01516 01517 01518 01519 01520 01521 01522 01523 01524 01525 01526 01527 01528 01529 01530 01531 01532 01533 01534 01535 01536 01537 01538 01539 01540 01541 01542 01543 01544 01545 01546 01547 01548 01549 01550 01551 01552 01553 01554 01555 01556 01557 01558 01559 01560 01561 01562 01563 01564 01565 01566 01567 01568 01569 01570 01571 01572 01573 01574 01575 01576 01577 01578 01579 01580 01581 01582 01583 01584 01585 01586 01587 01588 01589 01590 01591 01592 01593 01594 01595 01596 01597 01598 01599 01600 01601 01602 01603 01604 01605 01606 01607 01608 01609 01610 01611 01612 01613 01614 01615 01616 01617 01618 01619 01620 01621 01622 01623 01624 01625 01626 01627 01628 01629 01630 01631 01632 01633 01634 01635 01636 01637 01638 01639 01640 01641 01642 01643 01644 01645 01646 01647 01648 01649 01650 01651 01652 01653 01654 01655 01656 01657 01658 01659 01660 01661 01662 01663 01664 01665 01666 01667 01668 01669 01670 01671 01672 01673 01674 01675 01676 01677 01678 01679 01680 01681 01682 01683 01684 01685 01686 01687 01688 01689 01690 01691 01692 01693 01694 01695 01696 01697 01698 01699 01700 01701 01702 01703 01704 01705 01706 01707 01708 01709 01710 01711 01712 01713 01714 01715 01716 01717 01718 01719 01720 01721 01722 01723 01724 01725 01726 01727 01728 01729 01730 01731 01732 01733 01734 01735 01736 01737 01738 01739 01740 01741 01742 01743 01744 01745 01746 01747 01748 01749 01750 01751 01752 01753 01754 01755 01756 01757 01758 01759 01760 01761 01762 01763 01764 01765 01766 01767 01768 01769 01770 01771 01772 01773 01774 01775 01776 01777 01778 01779 01780 01781 01782 01783 01784 01785 01786 01787 01788 01789 01790 01791 01792 01793 01794 01795 01796 01797 01798 01799 01800 01801 01802 01803 01804 01805 01806 01807 01808 01809 01810 01811 01812 01813 01814 01815 01816 01817 01818 01819 01820 01821 01822 01823 01824 01825 01826 01827 01828 01829 01830 01831 01832 01833 01834 01835 01836 01837 01838 01839 01840 01841 01842 01843 01844 01845 01846 01847 01848 01849 01850 01851 01852 01853 01854 01855 01856 01857 01858 01859 01860 01861 01862 01863 01864 01865 01866 01867 01868 01869 01870 01871 01872 01873 01874 01875 01876 01877 01878 01879 01880 01881 01882 01883 01884 01885 01886 01887 01888 01889 01890 01891 01892 01893 01894 01895 01896 01897 01898 01899 01900 01901 01902 01903 01904 01905 01906 01907 01908 01909 01910 01911 01912 01913 01914 01915 01916 01917 01918 01919 01920 01921 01922 01923 01924 01925 01926 01927 01928 01929 01930 01931 01932 01933 01934 01935 01936 01937 01938 01939 01940 01941 01942 01943 01944 01945 01946 01947 01948 01949 01950 01951 01952 01953 01954 01955 01956 01957 01958 01959 01960 01961 01962 01963 01964 01965 01966 01967 01968 01969 01970 01971 01972 01973 01974 01975 01976 01977 01978 01979 01980 01981 01982 01983 01984 01985 01986 01987 01988 01989 01990 01991 01992 01993 01994 01995 01996 01997 01998 01999 02000 02001 02002 02003 02004 02005 02006 02007 02008 02009 02010 02011 02012 02013 02014 02015 |
//============================================================================= // Vehicle // this abstract base class contains gameplay and AI code for vehicles //============================================================================= class Vehicle extends Pawn native nativereplication abstract; var globalconfig bool bVehicleShadows; // Global config option for vehicle shadows var bool bDriving; // Vehicle is being driven var bool bOldDriving; var bool bDrawVehicleShadow; // Vehicle Shadow var (Vehicle) bool bDrawDriverInTP; // Whether to draw the driver when in 3rd person mode. var (Vehicle) bool bDriverCollideActors; // if driver is drawn in vehicle, is Driver.bCollideActors true ? var (Vehicle) bool bRelativeExitPos; // relative vector to vehicle? var bool bDefensive; // should be used by defenders var bool bAutoTurret; // controlled by AI if no player controlling (FIXME Move to subclass) var bool bRemoteControlled; // destroying vehicle won't kill player var bool bEjectDriver; // If vehicle is destroyed, don't kill and eject driver(s) var bool bTurnInPlace; // whether vehicle can turn in place var bool bFollowLookDir; // used by AI to know that controller's rotation determines vehicle rotation var bool bNonHumanControl; // Cannot be controlled by humans var bool bStalled; // Vehicle is stalled (can't apply acceleration) var bool bVehicleDestroyed; // Vehicle has been destroyed (no more need to simulate special vehicle physics) var bool bShowDamageOverlay; // Vehicle should display the normal pawn damage overlay when hit by a weapon var bool bDropDetail; // Vehicle should reduce its detail level var bool bNoFriendlyFire; // FriendlyFire disabled for this vehicle var bool bCanHover; // Actor can hover above water var bool bCanDoTrickJumps; // AI hint // Cameras var (Vehicle) bool bDrawMeshInFP; // Whether to draw the vehicle mesh when in 1st person mode. var (Vehicle) bool bZeroPCRotOnEntry; // If true, set camera rotation to zero on entering vehicle. If false, set it to the vehicle rotation. var bool bPCRelativeFPRotation; // In 1st person, PlayerController rotation is relative to vehicle rotation var bool bWeaponisFiring; var bool bWeaponisAltFiring; var bool bTeamLocked; // Team defines which players are allowed to enter the vehicle var bool bEnterringUnlocks; // Vehicle is unlocked when a player enterred it.. var bool bCanFlip; var bool bAllowViewChange; var bool bAllowWeaponToss; //if the driver dies, will he toss his weapon? var(Vehicle) bool bHUDTrackVehicle; // If true, Vehicle will tracked on HUD. (For Objectives in Assault) var bool bHasRadar; var bool bHasHandbrake; // hint for AI var bool bScriptedRise; // hint for AI var bool bKeyVehicle; // hint for AI var bool bSeparateTurretFocus; // hint for AI (for tank type turreted vehicles) var() bool bHighScoreKill; // vehicle is considered important, and awards 5 points upon destruction. var bool bAdjustDriversHead; // rotate driver's head depending on view rotation var bool bEnemyLockedOn; var config bool bDesiredBehindView; var bool bHideRemoteDriver; // If Set to true, the remote controlling driver will be hidden var bool bShowChargingBar; var bool bDriverHoldsFlag; var bool bCanCarryFlag; var bool bSpawnProtected; // Cannot be destroyed by a player before its been possessed. var() bool bFPNoZFromCameraPitch; // Ignore any vehicle-space Z due to FPCamViewOffset (so looking up and down doesn't change camera Z rel to vehicle) var byte StuckCount; // used by AI var() byte Team; var byte OldTeam, PrevTeam; // OldTeam is used for replication purposes, PrevTeam is the team of the previous driver. var Rotator PlayerEnterredRotation; // Original rotation when player enterred vehicle var float EjectMomentum; var class<Controller> AutoTurretControllerClass; // generic controls (set by controller, used by concrete derived classes) var (Vehicle) float Steering; // between -1 and 1 var (Vehicle) float Throttle; // between -1 and 1 var (Vehicle) float Rise; // between -1 and 1 var int DriverViewPitch; // The driver's view pitch var int DriverViewYaw; // The driver's view yaw var float ThrottleTime; // last time at which throttle was 0 (used by AI) var float StuckTime; var float VehicleMovingTime; // used by AI C++ var (Vehicle) vector DrivePos; // Position (rel to vehicle) to put player while driving. var (Vehicle) rotator DriveRot; // Rotation (rel to vehicle) to put driver while driving. var (Vehicle) name DriveAnim; // Animation to play while driving. //Info for EntryPositions var (Vehicle) array<vector> ExitPositions; // Positions (rel to vehicle) to try putting the player when exiting. var (Vehicle) vector EntryPosition; // Offset for the entry trigger var (Vehicle) float EntryRadius; // Radius for the entry trigger var (Vehicle) vector FPCamPos; // Position of camera when driving first person. var (Vehicle) vector FPCamViewOffset; // Offset in reference frame of camera. //clientside settings var config float TPCamDistance; // force feedback var string CenterSpringForce; var int CenterSpringRangePitch; var int CenterSpringRangeRoll; var (Vehicle) vector TPCamLookat; // Look at location in vehicle space var (Vehicle) vector TPCamWorldOffset; // Applied in world space after vehicle transform. var float DesiredTPCamDistance, LastCameraCalcTime, CameraSpeed; //for smoothly interpolating TPCamDistance to new value var (Vehicle) Range TPCamDistRange; var (Vehicle) int MaxViewYaw; // Maximum amount you can look left and right var (Vehicle) int MaxViewPitch; // Maximum amount you can look up and down var Pawn Driver; // Can be None if Controller spawns right away with vehicle var SVehicleFactory ParentFactory; // FX var String TransEffects[2]; // Spawning effects var ShadowProjector VehicleShadow; // Shadow projector var float ShadowMaxTraceDist; var float ShadowCullDistance; var float MomentumMult; //damage momentum multiplied by this value before being applied to vehicle var float DriverDamageMult; //damage to the driver is multiplied by this value // Missle warning var String LockOnClassString; var float LastLockWarningTime; var float LockWarningInterval; var Vehicle NextVehicle; var localized string VehiclePositionString; var localized cache string VehicleNameString; var localized cache string VehicleDescription; var Texture TeamBeaconTexture, NoEntryTexture; var Material TeamBeaconBorderMaterial; var AIMarker myMarker; // used for stationary turrets //VEHICULAR MANSLAUGHTER var float MinRunOverSpeed; //speed must be greater than this for running into someone to do damage var class<DamageType> RanOverDamageType, CrushedDamageType; var sound RanOverSound; var name StolenAnnouncement; var sound StolenSound; var float LinkHealMult; // If > 0, Link Gun secondary heals an amount equal to its damage times this var float OldSteering; var float VehicleLostTime, TeamUseTime, PlayerStartTime; var float MaxDesireability; var const float AIMoveCheckTime; var float ObjectiveGetOutDist; //if AI controlled and bot needs to trigger an objective not triggerable by vehicles, it will try to get out this far away var name FlagBone; var vector FlagOffset; var rotator FlagRotation; var float WheelsScale; // HORN var array<sound> HornSounds; var float LastHornTime; // BULLET HITS var() array<sound> BulletSounds; // WATER DAMAGE var() float WaterDamage; var class<DamageType> VehicleDrowningDamType; // HUD OVERLAY var class<Actor> HUDOverlayClass; var Actor HUDOverlay; var() vector HUDOverlayOffset; var() float HUDOverlayFOV; // SPAWN OVERLAY MATERIAL var() Material SpawnOverlay[2]; struct native SVehicleIcon { var Material Material; var float X, Y, SizeX, SizeY; var bool bIsGreyScale; }; var SVehicleIcon VehicleIcon; cpptext { virtual void PreNetReceive(); virtual void PostNetReceive(); void performPhysics(FLOAT DeltaSeconds); virtual UBOOL moveToward(const FVector &Dest, AActor *GoalActor); virtual void rotateToward(AActor *Focus, FVector FocalPoint); virtual void PostRender(FLevelSceneNode* SceneNode, FRenderInterface* RI); virtual UBOOL IsStuck(); INT* GetOptimizedRepList(BYTE* Recent, FPropertyRetirement* Retire, INT* Ptr, UPackageMap* Map, UActorChannel* Channel); INT AddMyMarker(AActor *S); void SteerVehicle(FVector Direction); UBOOL IsNetRelevantFor( APlayerController* RealViewer, AActor* Viewer, FVector SrcLocation ); virtual FVector GetDestination(AController *C); virtual void setMoveTimer(FVector MoveDir); virtual UBOOL Tick(FLOAT DeltaTime, enum ELevelTick TickType); virtual UBOOL AdjustFlight(FLOAT ZDiff, UBOOL bFlyingDown, FLOAT Distance, AActor* GoalActor); } replication { reliable if ( Role==ROLE_Authority ) ClientKDriverEnter, ClientKDriverLeave, FixPCRotation, ClientClearController; unreliable if( bNetDirty && Role==ROLE_Authority ) bDriving, bTeamLocked, Driver, Team, bVehicleDestroyed, WheelsScale; unreliable if( bNetInitial && Role==ROLE_Authority ) bHUDTrackVehicle; reliable if ( Role < ROLE_Authority ) VehicleFire, VehicleCeaseFire; } function PreBeginPlay() { if ( !Level.Game.bAllowVehicles && !bDeleteMe ) { Destroy(); return; } Super.PreBeginPlay(); } function PlayerChangedTeam() { if ( Driver != None ) Driver.KilledBy(Driver); else Super.PlayerChangedTeam(); } simulated function SetBaseEyeheight() { BaseEyeheight = Default.BaseEyeheight; Eyeheight = BaseEyeheight; } simulated function string GetVehiclePositionString() { return VehiclePositionString; } function Suicide() { if ( Driver != None ) Driver.KilledBy(Driver); else KilledBy(self); } function bool CheatWalk() { return false; } function bool CheatGhost() { return false; } function bool CheatFly() { return false; } simulated function PostBeginPlay() { local controller NewController; super.PostBeginPlay(); if ( bDeleteMe ) return; // Glue a shadow projector on if ( bVehicleShadows && bDrawVehicleShadow && (Level.NetMode != NM_DedicatedServer) ) { VehicleShadow = Spawn(class'ShadowProjector', self, '', Location); VehicleShadow.ShadowActor = Self; VehicleShadow.bBlobShadow = false; VehicleShadow.LightDirection = Normal(vect(1,1,6)); VehicleShadow.LightDistance = 1200; VehicleShadow.MaxTraceDistance = ShadowMaxTraceDist; VehicleShadow.CullDistance = ShadowCullDistance; VehicleShadow.InitShadow(); } if ( Role == Role_Authority ) { if ( bAutoTurret && (Controller == None) && (AutoTurretControllerClass != None) ) { NewController = spawn(AutoTurretControllerClass); if ( NewController != None ) NewController.Possess(self); } if ( !bAutoTurret && !bNonHumanControl && IndependentVehicle() ) Level.Game.RegisterVehicle(self); } OldTeam = Team; PrevTeam = Team; } simulated event SetInitialState() { Super.SetInitialState(); Disable('Tick'); } function bool StronglyRecommended(Actor S, int TeamIndex, Actor Objective) { return bKeyVehicle; } //return a value indicating how useful this vehicle is to bots function float BotDesireability(Actor S, int TeamIndex, Actor Objective) { local bool bSameTeam; local PlayerController P; bSameTeam = ( GetTeamNum() == TeamIndex ); if ( bSameTeam ) { if ( Level.TimeSeconds < TeamUseTime ) return 0; if ( !bKeyVehicle && (Level.TimeSeconds < PlayerStartTime) ) { P = Level.GetLocalPlayerController(); if ( (P == None) || ((P.Pawn != None) && (Vehicle(P.Pawn) == None)) ) return 0; } } if ( !bKeyVehicle && !bStationary && (Level.TimeSeconds < VehicleLostTime) ) return 0; else if (Health <= 0 || Occupied() || (bTeamLocked && !bSameTeam)) return 0; if (bKeyVehicle) return 100; return ((MaxDesireability * 0.5) + (MaxDesireability * 0.5 * (float(Health) / HealthMax))); } simulated function Destroyed() { local Vehicle V, Prev; if ( ParentFactory != None ) ParentFactory.VehicleDestroyed( Self ); // Notify parent factory of death if ( VehicleShadow != None ) VehicleShadow.Destroy(); // Destroy shadow projector if ( bAutoTurret && (Controller != None) && ClassIsChildOf(Controller.Class, AutoTurretControllerClass) && !Controller.bDeleteMe ) { Controller.Destroy(); Controller = None; } if ( Driver != None ) Destroyed_HandleDriver(); if ( Level.Game != None ) { if ( Level.Game.VehicleList == Self ) Level.Game.VehicleList = NextVehicle; else { Prev = Level.Game.VehicleList; if ( Prev != None ) for ( V=Level.Game.VehicleList.NextVehicle; V!=None; V=V.NextVehicle ) { if ( V == self ) { Prev.NextVehicle = NextVehicle; break; } else Prev = V; } } } super.Destroyed(); } simulated function Destroyed_HandleDriver() { local Pawn OldDriver; Driver.LastRenderTime = LastRenderTime; if ( Role == ROLE_Authority ) { // if Driver wasn't visible in vehicle, destroy it if ( Driver != None && !bRemoteControlled && !bEjectDriver && !bDrawDriverInTP && Driver.Health > 0 ) { OldDriver = Driver; Driver = None; OldDriver.DrivenVehicle = None; if ( !OldDriver.bDeleteMe ) OldDriver.Destroy(); } else if ( !bRemoteControlled && !bEjectDriver ) { // otherwise spawn dead karma body if (!bDrawDriverInTP && PlaceExitingDriver()) { Driver.StopDriving(self); Driver.DrivenVehicle = self; } Driver.TearOffMomentum = Velocity * 0.25; Driver.Died(Controller, class'DamRanOver', Driver.Location); } } else if ( Driver.DrivenVehicle == self ) Driver.StopDriving(self); } simulated function vector GetCameraLocationStart() { return Location; } simulated function SpecialCalcBehindView(PlayerController PC, out actor ViewActor, out vector CameraLocation, out rotator CameraRotation ) { local vector CamLookAt, HitLocation, HitNormal, OffsetVector; local Actor HitActor; local vector x, y, z; if (DesiredTPCamDistance < TPCamDistance) TPCamDistance = FMax(DesiredTPCamDistance, TPCamDistance - CameraSpeed * (Level.TimeSeconds - LastCameraCalcTime)); else if (DesiredTPCamDistance > TPCamDistance) TPCamDistance = FMin(DesiredTPCamDistance, TPCamDistance + CameraSpeed * (Level.TimeSeconds - LastCameraCalcTime)); GetAxes(PC.Rotation, x, y, z); ViewActor = self; CamLookAt = GetCameraLocationStart() + (TPCamLookat >> Rotation) + TPCamWorldOffset; OffsetVector = vect(0, 0, 0); OffsetVector.X = -1.0 * TPCamDistance; CameraLocation = CamLookAt + (OffsetVector >> PC.Rotation); HitActor = Trace(HitLocation, HitNormal, CameraLocation, CamLookAt, true, vect(40, 40, 40)); if ( HitActor != None && (HitActor.bWorldGeometry || HitActor == GetVehicleBase() || Trace(HitLocation, HitNormal, CameraLocation, CamLookAt, false, vect(40, 40, 40)) != None) ) CameraLocation = HitLocation; CameraRotation = Normalize(PC.Rotation + PC.ShakeRot); CameraLocation = CameraLocation + PC.ShakeOffset.X * x + PC.ShakeOffset.Y * y + PC.ShakeOffset.Z * z; } simulated function SpecialCalcFirstPersonView(PlayerController PC, out actor ViewActor, out vector CameraLocation, out rotator CameraRotation ) { local quat CarQuat, LookQuat, ResultQuat; local vector VehicleZ, CamViewOffsetWorld, x, y, z; local float CamViewOffsetZAmount; GetAxes(PC.Rotation, x, y, z); ViewActor = self; if (bPCRelativeFPRotation) { CarQuat = QuatFromRotator(Rotation); CameraRotation = Normalize(PC.Rotation); LookQuat = QuatFromRotator(CameraRotation); ResultQuat = QuatProduct(LookQuat, CarQuat); CameraRotation = QuatToRotator(ResultQuat); } else CameraRotation = PC.Rotation; // Camera position is locked to car CamViewOffsetWorld = FPCamViewOffset >> CameraRotation; CameraLocation = GetCameraLocationStart() + (FPCamPos >> Rotation) + CamViewOffsetWorld; if(bFPNoZFromCameraPitch) { VehicleZ = vect(0,0,1) >> Rotation; CamViewOffsetZAmount = CamViewOffsetWorld Dot VehicleZ; CameraLocation -= CamViewOffsetZAmount * VehicleZ; } CameraRotation = Normalize(CameraRotation + PC.ShakeRot); CameraLocation = CameraLocation + PC.ShakeOffset.X * x + PC.ShakeOffset.Y * y + PC.ShakeOffset.Z * z; } // Special calc-view for vehicles simulated function bool SpecialCalcView(out actor ViewActor, out vector CameraLocation, out rotator CameraRotation ) { local PlayerController pc; pc = PlayerController(Controller); // Only do this mode we have a playercontroller if( (pc == None) || (pc.Viewtarget != self) ) return false; if( pc.bBehindView ) SpecialCalcBehindView(PC,ViewActor,CameraLocation,CameraRotation); else SpecialCalcFirstPersonView(PC,ViewActor,CameraLocation,CameraRotation); LastCameraCalcTime = Level.TimeSeconds; return true; } simulated function bool SpectatorSpecialCalcView(PlayerController Viewer, out Actor ViewActor, out vector CameraLocation, out rotator CameraRotation) { local rotator DummyRotation; if (Viewer.ViewTarget != self) return false; if (Viewer.bBehindView) { DesiredTPCamDistance = (TPCamDistRange.Max - TPCamDistRange.Min) * (Viewer.CameraDist / Viewer.CameraDistRange.Max) + TPCamDistRange.Min; SpecialCalcBehindView(Viewer, ViewActor, CameraLocation, CameraRotation); } else SpecialCalcFirstPersonView(Viewer, ViewActor, CameraLocation, DummyRotation); //use rotation set by playercontroller LastCameraCalcTime = Level.TimeSeconds; Viewer.SetLocation(CameraLocation); return true; } // Events called on driver entering/leaving vehicle function Vehicle FindEntryVehicle(Pawn P) { if ( AIController(P.Controller) != None ) return self; if (VSize(P.Location - (Location + (EntryPosition >> Rotation))) < EntryRadius) return self; return None; } // The pawn Driver has tried to take control of this vehicle function bool TryToDrive(Pawn P) { if ( P.bIsCrouched || bNonHumanControl || (P.Controller == None) || (Driver != None) || (P.DrivenVehicle != None) || !P.Controller.bIsPlayer || P.IsA('Vehicle') || Health <= 0 ) return false; if( !Level.Game.CanEnterVehicle(self, P) ) return false; // Check vehicle Locking.... if ( !bTeamLocked || P.GetTeamNum() == Team ) { if ( bEnterringUnlocks && bTeamLocked ) bTeamLocked = false; KDriverEnter( P ); return true; } else { VehicleLocked( P ); return false; } } event VehicleLocked( Pawn P ); // Pawn tried to enter vehicle, but it's locked!! function PossessedBy(Controller C) { local PlayerController PC; if ( bAutoTurret && (Controller != None) && ClassIsChildOf(Controller.Class, AutoTurretControllerClass) && !Controller.bDeleteMe ) { Controller.Destroy(); Controller = None; } super.PossessedBy( C ); // Stole another team's vehicle, so set Team to new owner's team if ( C.GetTeamNum() != Team ) { //add stat tracking event/variable here? if ( Team != 255 && PlayerController(C) != None ) { if( StolenAnnouncement != '' ) PlayerController(C).PlayRewardAnnouncement(StolenAnnouncement, 1); if( StolenSound != None ) PlaySound( StolenSound,, 2.5*TransientSoundVolume,, 400); } if ( C.GetTeamNum() != 255 ) SetTeamNum( C.GetTeamNum() ); } NetPriority = 3; NetUpdateFrequency = 100; ThrottleTime = Level.TimeSeconds; bSpawnProtected = false; PC = PlayerController(C); if ( PC != None ) ClientKDriverEnter( PC ); if ( ParentFactory != None && ( !bAutoTurret || !ClassIsChildOf(C.Class, AutoTurretControllerClass) ) ) ParentFactory.VehiclePossessed( Self ); // Notify parent factory } function UnPossessed() { local PlayerController PC; local Controller NewController; local bool bWasPlayer; StopWeaponFiring(); PC = PlayerController(Controller); if ( PC != None ) { bWasPlayer = true; ClientKDriverLeave(PC); if (bPCRelativeFPRotation && !PC.bBehindView) FixPCRotation(PC); } else ClientClearController(); NetPriority = Default.NetPriority; // restore original netpriority changed when possessing NetUpdateTime = Level.TimeSeconds - 1; NetUpdateFrequency = 8; super.UnPossessed(); if ( ParentFactory != None && ( !bAutoTurret || (Controller == None) || !ClassIsChildOf(Controller.Class, AutoTurretControllerClass) ) ) ParentFactory.VehicleUnPossessed( Self ); // Notify parent of UnPossessed() if ( Health > 0 && !bDeleteMe ) { if ( bWasPlayer && bAutoTurret && (AutoTurretControllerClass != None) ) { Controller = None; NewController = spawn(AutoTurretControllerClass); if ( NewController != None ) NewController.Possess( Self ); } } } function KDriverEnter(Pawn P) { local Controller C; bDriving = True; StuckCount = 0; // We don't have pre-defined exit positions here, so we use the original player location as an exit point if ( !bRelativeExitPos ) { PlayerEnterredRotation = P.Rotation; ExitPositions[0] = P.Location + Vect(0,0,16); } // Set pawns current controller to control the vehicle pawn instead C = P.Controller; if ( !bCanCarryFlag && (C.PlayerReplicationInfo.HasFlag != None) ) P.DropFlag(); Driver = P; Driver.StartDriving( Self ); // Disconnect PlayerController from Driver and connect to SVehicle. C.bVehicleTransition = true; // to keep Bots from doing Restart() C.Unpossess(); Driver.SetOwner( Self ); // This keeps the driver relevant. C.Possess( Self ); C.bVehicleTransition = false; DrivingStatusChanged(); if ( PlayerController(C) != None ) VehicleLostTime = 0; AttachFlag(PlayerReplicationInfo.HasFlag); Level.Game.DriverEnteredVehicle(self, P); } function AttachFlag(Actor FlagActor) { if ( !bDriverHoldsFlag && (FlagActor != None) ) { AttachToBone(FlagActor,FlagBone); FlagActor.SetRelativeRotation(FlagRotation); FlagActor.SetRelativeLocation(FlagOffset); } } simulated event SetWheelsScale(float NewScale) { WheelsScale = NewScale; } // Called from the PlayerController when player wants to get out. event bool KDriverLeave( bool bForceLeave ) { local Controller C; local PlayerController PC; local bool havePlaced; if( !bForceLeave && !Level.Game.CanLeaveVehicle(self, Driver) ) return false; if ( (PlayerReplicationInfo != None) && (PlayerReplicationInfo.HasFlag != None) ) Driver.HoldFlag(PlayerReplicationInfo.HasFlag); // Do nothing if we're not being driven if (Controller == None ) return false; // Before we can exit, we need to find a place to put the driver. // Iterate over array of possible exit locations. if ( (Driver != None) && (!bRemoteControlled || bHideRemoteDriver) ) { Driver.bHardAttach = false; Driver.bCollideWorld = true; Driver.SetCollision(true, true); havePlaced = PlaceExitingDriver(); // If we could not find a place to put the driver, leave driver inside as before. if (!havePlaced && !bForceLeave ) { Driver.bHardAttach = true; Driver.bCollideWorld = false; Driver.SetCollision(false, false); return false; } } bDriving = False; // Reconnect Controller to Driver. C = Controller; if (C.RouteGoal == self) C.RouteGoal = None; if (C.MoveTarget == self) C.MoveTarget = None; C.bVehicleTransition = true; Controller.UnPossess(); if ( (Driver != None) && (Driver.Health > 0) ) { Driver.SetOwner( C ); C.Possess( Driver ); PC = PlayerController(C); if ( PC != None ) PC.ClientSetViewTarget( Driver ); // Set playercontroller to view the person that got out Driver.StopDriving( Self ); } C.bVehicleTransition = false; if ( C == Controller ) // If controller didn't change, clear it... Controller = None; Level.Game.DriverLeftVehicle(self, Driver); // Car now has no driver Driver = None; DriverLeft(); // Put brakes on before you get out :) Throttle = 0; Steering = 0; Rise = 0; return true; } // DriverLeft() called by KDriverLeave() function DriverLeft() { DrivingStatusChanged(); } simulated event UpdateTiltForceFeedback() { local rotator SpringCenter; local float pitch, roll; local PlayerController PC; PC = PlayerController(Controller); if ( PC != None ) { SpringCenter = rotation; pitch = Clamp(SpringCenter.Pitch, -CenterSpringRangePitch, CenterSpringRangePitch); roll = Clamp(SpringCenter.Roll, -CenterSpringRangeRoll, CenterSpringRangeRoll); pitch /= CenterSpringRangePitch; roll /= CenterSpringRangeRoll; PC.ChangeSpringFeedbackEffect(CenterSpringForce, roll, pitch); } } simulated function ClientKDriverEnter(PlayerController PC) { // PC.bFreeCamera = true; // Set rotation of camera when getting into vehicle based on bZeroPCRotOnEntry if ( bZeroPCRotOnEntry ) PC.SetRotation( rot(0, 0, 0) ); //set starting camera distance to local player's preferences TPCamDistance = default.TPCamDistance; DesiredTPCamDistance = TPCamDistance; if (!PC.bBehindView) ActivateOverlay(True); if ( PC.bEnableGUIForceFeedback && PC.bForceFeedbackSupported && (Viewport(PC.Player) != None) ) { if ( (CenterSpringRangePitch > 0) && (CenterSpringRangeRoll > 0) ) UpdateTiltForceFeedback(); PC.ClientPlayForceFeedback(CenterSpringForce); } if (Driver!=None) { Driver.AmbientSound=none; if (Driver.Weapon!=None) Driver.Weapon.AmbientSound=none; } } simulated function ClientClearController() { ActivateOverlay(False); } simulated function ClientKDriverLeave(PlayerController PC) { // PC.bFreeCamera = false; // Stop messing with bOwnerNoSee if ( Driver != None ) Driver.bOwnerNoSee = Driver.default.bOwnerNoSee; if (PC.bEnableGUIForceFeedback) PC.StopForceFeedback(CenterSpringForce); bWeaponisFiring = False; bWeaponisAltFiring = False; ActivateOverlay(False); } simulated function ActivateOverlay(bool bActive) { if (bActive) { if (HUDOverlayClass != None && HUDOverlay == None) HUDOverlay = spawn(HUDOverlayClass); } else if (HUDOverlay != None) HUDOverlay.Destroy(); } //seperate replicated function called from UnPossessed() to make PC rotation no longer relative to vehicle //needed because PC.bBehindView will get screwed around with as a result of unpossessing vehicle and repossessing Driver simulated function FixPCRotation(PlayerController PC) { PC.SetRotation(rotator(vector(PC.Rotation) >> Rotation)); } simulated function AttachDriver(Pawn P) { local vector AttachPos; P.bHardAttach = true; AttachPos = Location + (DrivePos >> Rotation); P.SetLocation( AttachPos ); P.SetPhysics( PHYS_None ); P.SetBase( Self ); P.SetRelativeRotation( DriveRot ); } simulated function DetachDriver(Pawn P) {} function bool PlaceExitingDriver() { local int i, j; local vector tryPlace, Extent, HitLocation, HitNormal, ZOffset, RandomSphereLoc; local float BestDir, NewDir; if ( Driver == None ) return false; Extent = Driver.default.CollisionRadius * vect(1,1,0); Extent.Z = Driver.default.CollisionHeight; ZOffset = Driver.default.CollisionHeight * vect(0,0,1); //avoid running driver over by placing in direction perpendicular to velocity if ( VSize(Velocity) > 100 ) { tryPlace = Normal(Velocity cross vect(0,0,1)) * (CollisionRadius + Driver.default.CollisionRadius ) * 1.25 ; if ( (Controller != None) && (Controller.DirectionHint != vect(0,0,0)) ) { if ( (tryPlace dot Controller.DirectionHint) < 0 ) tryPlace *= -1; } else if ( FRand() < 0.5 ) tryPlace *= -1; //randomly prefer other side if ( (Trace(HitLocation, HitNormal, Location + tryPlace + ZOffset, Location + ZOffset, false, Extent) == None && Driver.SetLocation(Location + tryPlace + ZOffset)) || (Trace(HitLocation, HitNormal, Location - tryPlace + ZOffset, Location + ZOffset, false, Extent) == None && Driver.SetLocation(Location - tryPlace + ZOffset)) ) return true; } if ( (Controller != None) && (Controller.DirectionHint != vect(0,0,0)) ) { // first try best position tryPlace = Location; BestDir = 0; for( i=0; i<ExitPositions.Length; i++) { NewDir = Normal(ExitPositions[i] - Location) Dot Controller.DirectionHint; if ( NewDir > BestDir ) { BestDir = NewDir; tryPlace = ExitPositions[i]; } } Controller.DirectionHint = vect(0,0,0); if ( tryPlace != Location ) { if ( bRelativeExitPos ) { if ( ExitPositions[0].Z != 0 ) ZOffset = Vect(0,0,1) * ExitPositions[0].Z; else ZOffset = Driver.default.CollisionHeight * vect(0,0,2); tryPlace = Location + ( (tryPlace-ZOffset) >> Rotation) + ZOffset; // First, do a line check (stops us passing through things on exit). if ( (Trace(HitLocation, HitNormal, tryPlace, Location + ZOffset, false, Extent) == None) && Driver.SetLocation(tryPlace) ) return true; } else if ( Driver.SetLocation(tryPlace) ) return true; } } if ( !bRelativeExitPos ) { for( i=0; i<ExitPositions.Length; i++) { tryPlace = ExitPositions[i]; if ( Driver.SetLocation(tryPlace) ) return true; else { for (j=0; j<10; j++) // try random positions in a sphere... { RandomSphereLoc = VRand()*200* FMax(FRand(),0.5); RandomSphereLoc.Z = Extent.Z * FRand(); // First, do a line check (stops us passing through things on exit). if ( Trace(HitLocation, HitNormal, tryPlace+RandomSphereLoc, tryPlace, false, Extent) == None ) { if ( Driver.SetLocation(tryPlace+RandomSphereLoc) ) return true; } else if ( Driver.SetLocation(HitLocation) ) return true; } } } return false; } for( i=0; i<ExitPositions.Length; i++) { if ( ExitPositions[0].Z != 0 ) ZOffset = Vect(0,0,1) * ExitPositions[0].Z; else ZOffset = Driver.default.CollisionHeight * vect(0,0,2); tryPlace = Location + ( (ExitPositions[i]-ZOffset) >> Rotation) + ZOffset; // First, do a line check (stops us passing through things on exit). if ( Trace(HitLocation, HitNormal, tryPlace, Location + ZOffset, false, Extent) != None ) continue; // Then see if we can place the player there. if ( !Driver.SetLocation(tryPlace) ) continue; return true; } return false; } function Pawn CheckForHeadShot(Vector loc, Vector ray, float AdditionalScale) { return None; } function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType) { local int ActualDamage; local Controller Killer; // Spawn Protection: Cannot be destroyed by a player until possessed if ( bSpawnProtected && instigatedBy != None && instigatedBy != Self ) return; NetUpdateTime = Level.TimeSeconds - 1; // force quick net update if (DamageType != None) { if ((instigatedBy == None || instigatedBy.Controller == None) && DamageType.default.bDelayedDamage && DelayedDamageInstigatorController != None) instigatedBy = DelayedDamageInstigatorController.Pawn; Damage *= DamageType.default.VehicleDamageScaling; momentum *= DamageType.default.VehicleMomentumScaling * MomentumMult; if (bShowDamageOverlay && DamageType.default.DamageOverlayMaterial != None && Damage > 0 ) SetOverlayMaterial( DamageType.default.DamageOverlayMaterial, DamageType.default.DamageOverlayTime, false ); } if (bRemoteControlled && Driver!=None) { ActualDamage = Damage; if (Weapon != None) Weapon.AdjustPlayerDamage(ActualDamage, InstigatedBy, HitLocation, Momentum, DamageType ); if (InstigatedBy != None && InstigatedBy.HasUDamage()) ActualDamage *= 2; ActualDamage = Level.Game.ReduceDamage(ActualDamage, self, instigatedBy, HitLocation, Momentum, DamageType); if (Health - ActualDamage <= 0) KDriverLeave(false); } if ( Physics != PHYS_Karma ) { super.TakeDamage(Damage,InstigatedBy,HitLocation,Momentum,DamageType); return; } if (Weapon != None) Weapon.AdjustPlayerDamage(Damage, InstigatedBy, HitLocation, Momentum, DamageType ); if (InstigatedBy != None && InstigatedBy.HasUDamage()) Damage *= 2; ActualDamage = Level.Game.ReduceDamage(Damage, self, instigatedBy, HitLocation, Momentum, DamageType); Health -= ActualDamage; PlayHit(actualDamage, InstigatedBy, hitLocation, damageType, Momentum); // The vehicle is dead! if ( Health <= 0 ) { if ( Driver!=None && (bEjectDriver || bRemoteControlled) ) { if ( bEjectDriver ) EjectDriver(); else KDriverLeave( false ); } // pawn died if ( instigatedBy != None ) Killer = instigatedBy.GetKillerController(); if ( Killer == None && (DamageType != None) && DamageType.Default.bDelayedDamage ) Killer = DelayedDamageInstigatorController; Died(Killer, damageType, HitLocation); } else if ( Controller != None ) Controller.NotifyTakeHit(instigatedBy, HitLocation, actualDamage, DamageType, Momentum); MakeNoise(1.0); if ( !bDeleteMe ) { if ( Location.Z > Level.StallZ ) Momentum.Z = FMin(Momentum.Z, 0); KAddImpulse(Momentum, hitlocation); } } function bool HealDamage(int Amount, Controller Healer, class<DamageType> DamageType) { if ( PlayerController(Healer) != None ) PlayerStartTime = Level.TimeSeconds + 3; if (Health <= 0 || Health >= HealthMax || Amount <= 0 || Healer == None || !TeamLink(Healer.GetTeamNum())) return false; Health = Min(Health + (Amount * LinkHealMult), HealthMax); NetUpdateTime = Level.TimeSeconds - 1; return true; } //determine if radius damage that hit the vehicle should damage the driver function DriverRadiusDamage(float DamageAmount, float DamageRadius, Controller EventInstigator, class<DamageType> DamageType, float Momentum, vector HitLocation) { local float damageScale, dist; local vector dir; //if driver has collision, whatever is causing the radius damage will hit the driver by itself if (EventInstigator == None || Driver == None || Driver.bCollideActors || bRemoteControlled) return; dir = Driver.Location - HitLocation; dist = FMax(1, VSize(dir)); dir = dir/dist; damageScale = 1 - FMax(0,(dist - Driver.CollisionRadius)/DamageRadius); if (damageScale <= 0) return; Driver.SetDelayedDamageInstigatorController(EventInstigator); Driver.TakeDamage( damageScale * DamageAmount, EventInstigator.Pawn, Driver.Location - 0.5 * (Driver.CollisionHeight + Driver.CollisionRadius) * dir, damageScale * Momentum * dir, DamageType ); } function DriverDied() { local Controller C; Level.Game.DiscardInventory( Driver ); if (PlayerReplicationInfo != None && PlayerReplicationInfo.HasFlag != None) PlayerReplicationInfo.HasFlag.Drop(0.5 * Velocity); if ( Driver == None ) return; C = Controller; Driver.StopDriving( Self ); Driver.Controller = C; Driver.DrivenVehicle = self; //for in game stats, so it knows pawn was killed inside a vehicle if ( Controller == None ) return; if ( PlayerController(Controller) != None ) { Controller.SetLocation(Location); PlayerController(Controller).SetViewTarget( Driver ); PlayerController(Controller).ClientSetViewTarget( Driver ); } Controller.Unpossess(); if ( Controller == C ) Controller = None; C.Pawn = Driver; Level.Game.DriverLeftVehicle(self, Driver); // Car now has no driver Driver = None; bDriving = false; // Put brakes on before you get out :) Throttle = 0; Steering = 0; Rise = 0; } function Died(Controller Killer, class<DamageType> damageType, vector HitLocation) { local PlayerController PC; local Controller C; if ( bDeleteMe || Level.bLevelChange ) return; // already destroyed, or level is being cleaned up if ( Physics != PHYS_Karma ) { super.Died(Killer, damageType, HitLocation); return; } if ( Level.Game.PreventDeath(self, Killer, damageType, HitLocation) ) { Health = max(Health, 1); //mutator should set this higher return; } Health = Min(0, Health); if ( Controller != None ) { C = Controller; C.WasKilledBy(Killer); Level.Game.Killed(Killer, C, self, damageType); if( C.bIsPlayer ) { PC = PlayerController(C); if ( PC != None ) ClientKDriverLeave(PC); // Just to reset HUD etc. else ClientClearController(); if ( (bRemoteControlled || bEjectDriver) && (Driver != None) && (Driver.Health > 0) ) { C.Unpossess(); C.Possess(Driver); if ( bEjectDriver ) EjectDriver(); Driver = None; } else C.PawnDied(self); } if ( !C.bIsPlayer && !C.bDeleteMe ) C.Destroy(); } else Level.Game.Killed(Killer, Controller(Owner), self, damageType); if ( Killer != None ) TriggerEvent(Event, self, Killer.Pawn); else TriggerEvent(Event, self, None); if ( IsHumanControlled() ) PlayerController(Controller).ForceDeathUpdate(); if ( !bDeleteMe ) Destroy(); // Destroy the vehicle itself (see Destroyed) } function AdjustDriverDamage(out int Damage, Pawn InstigatedBy, Vector HitLocation, out Vector Momentum, class<DamageType> DamageType) { if ( InGodMode() ) Damage = 0; else Damage *= DriverDamageMult; } function EjectDriver() { local Pawn OldPawn; local vector EjectVel; OldPawn = Driver; KDriverLeave( true ); if ( OldPawn == None ) return; EjectVel = VRand(); EjectVel.Z = 0; EjectVel = (Normal(EjectVel)*0.2 + Vect(0,0,1)) * EjectMomentum; OldPawn.Velocity = EjectVel; // Spawn Protection OldPawn.SpawnTime = Level.TimeSeconds; OldPawn.PlayTeleportEffect( false, false); } // Input function UsedBy( Pawn user ) { if ( Driver != None ) return; // Enter vehicle code TryToDrive( User ); } function Fire( optional float F ) { VehicleFire( false ); bWeaponIsFiring = true; } function AltFire( optional float F ) { VehicleFire( true ); bWeaponIsAltFiring = true; } function ClientVehicleCeaseFire(bool bWasAltFire) { if (bWasAltFire) bWeaponIsAltFiring = false; else bWeaponIsFiring = false; VehicleCeaseFire(bWasAltFire); } // Do some server-side vehicle firing stuff function VehicleFire(bool bWasAltFire) { if ( bWasAltFire ) bWeaponIsAltFiring = true; else bWeaponIsFiring = true; } function VehicleCeaseFire(bool bWasAltFire) { if ( bWasAltFire ) bWeaponIsAltFiring = false; else bWeaponIsFiring = false; } state UnDeployed { function VehicleFire(bool bWasAltFire) { Global.VehicleFire(bWasAltFire); } function VehicleCeaseFire(bool bWasAltFire) { Global.VehicleCeaseFire(bWasAltFire); } } state Deployed { function VehicleFire(bool bWasAltFire) { Global.VehicleFire(bWasAltFire); } function VehicleCeaseFire(bool bWasAltFire) { Global.VehicleCeaseFire(bWasAltFire); } } function bool StopWeaponFiring() { local bool bResult; if ( bWeaponIsFiring ) { ClientVehicleCeaseFire( false ); bWeaponIsFiring = false; bResult = true; } if ( bWeaponIsAltFiring ) { ClientVehicleCeaseFire( true ); bWeaponIsAltFiring = false; bResult = true; } return bResult; } event UpdateEyeHeight( float DeltaTime ) { local Controller C; if ( Controller != None && Controller.IsA('PlayerController') ) Controller.AdjustView( DeltaTime ); for ( C=Level.ControllerList; C!=None; C=C.NextController ) if ( C.IsA('PlayerController') && (PlayerController(C).ViewTarget == self) ) return; bUpdateEyeHeight =false; Eyeheight = BaseEyeheight; } // Vehicles ignore 'face rotation'. simulated function FaceRotation( rotator NewRotation, float DeltaTime ) {} simulated event SetAnimAction(name NewAction) { if ( bDrawDriverInTP && (Driver != None) ) Driver.SetAnimAction(NewAction); } // Vehicles dont get telefragged. event EncroachedBy(Actor Other) {} // RanInto() called for encroaching actors which successfully moved the other actor out of the way event RanInto(Actor Other) { local vector Momentum; local float Speed; if (Pawn(Other) == None || Vehicle(Other) != None || Other == Instigator || Other.Role != ROLE_Authority) return; Speed = VSize(Velocity); if (Speed > MinRunOverSpeed) { Momentum = Velocity * 0.25 * Other.Mass; if (Controller != None && Controller.SameTeamAs(Pawn(Other).Controller)) Momentum += Speed * 0.25 * Other.Mass * Normal(Velocity cross vect(0,0,1)); if (RanOverSound != None) PlaySound(RanOverSound,,TransientSoundVolume*2.5); Other.TakeDamage(int(Speed * 0.075), Instigator, Other.Location, Momentum, RanOverDamageType); } } // This will get called if we couldn't move a pawn out of the way. function bool EncroachingOn(Actor Other) { if ( Other == None || Other == Instigator || Other.Role != ROLE_Authority || (!Other.bCollideActors && !Other.bBlockActors) || VSize(Velocity) < 10 ) return false; // If its a non-vehicle pawn, do lots of damage. if( (Pawn(Other) != None) && (Vehicle(Other) == None) ) { Other.TakeDamage(10000, Instigator, Other.Location, Velocity * Other.Mass, CrushedDamageType); return false; } } simulated function bool FindValidTaunt( out name Sequence ) { if ( !bDrawDriverInTP || (Driver == None) ) return false; return Driver.FindValidTaunt(Sequence); } simulated function bool CheckTauntValid( name Sequence ) { if ( !bDrawDriverInTP || (Driver == None) ) return false; return Driver.CheckTauntValid(Sequence); } // AI code function bool Occupied() { return ( Controller != None ); } function float ReservationCostMultiplier() { return 1.0; } function float NewReservationCostMultiplier(Pawn P) { return ReservationCostMultiplier(); } function bool ChangedReservation(Pawn P) { return false; } function bool SpokenFor(Controller C) { return false; } function SetReservation(controller C); function Vehicle OpenPositionFor(Pawn P) { if ( Controller == None ) return self; return None; } simulated function bool IndependentVehicle() { return true; } function Actor GetBestEntry(Pawn P) { return self; } function Vehicle GetMoveTargetFor(Pawn P) { return self; } simulated event DrivingStatusChanged() { local PlayerController PC; PC = Level.GetLocalPlayerController(); if (bDriving && PC != None && (PC.ViewTarget == None || !(PC.ViewTarget.IsJoinedTo(self)))) bDropDetail = (Level.bDropDetail || (Level.DetailMode == DM_Low)); else bDropDetail = False; if (bDriving) Enable('Tick'); else Disable('Tick'); } // TakeWaterDamage() called every tick when WaterDamage>0 and PhysicsVolume.bWaterVolume=true event TakeWaterDamage(float DeltaTime) { local vector HitLocation,HitNormal; local actor EntryActor; TakeDamage(WaterDamage * DeltaTime, Self, vect(0,0,0), vect(0,0,0), VehicleDrowningDamType); if ( (Level.TimeSeconds - SplashTime > 0.3) && (PhysicsVolume.PawnEntryActor != None) && !Level.bDropDetail && (Level.DetailMode != DM_Low) && EffectIsRelevant(Location,false) && (VSize(Velocity) > 300) ) { SplashTime = Level.TimeSeconds; if ( !PhysicsVolume.TraceThisActor(HitLocation, HitNormal, Location - CollisionHeight*vect(0,0,1), Location + CollisionHeight*vect(0,0,1)) ) { EntryActor = Spawn(PhysicsVolume.PawnEntryActor,self,,HitLocation,rot(16384,0,0)); } } } // LockOnWarning() called every LockWarningInterval when bEnemyLockedOn is true (on server/standalone) event LockOnWarning() { local class<LocalMessage> LockOnClass; LockOnClass = class<LocalMessage>(DynamicLoadObject(LockOnClassString, class'class')); PlayerController(Controller).ReceiveLocalizedMessage(LockOnClass, 12); LastLockWarningTime = Level.TimeSeconds; } /* PointOfView() called by controller when possessing this pawn false = 1st person, true = 3rd person */ simulated function bool PointOfView() { if (!bAllowViewChange) return true; return default.bDesiredBehindView; } // Spawn FX function PlayTeleportEffect( bool bOut, bool bSound) { local Actor A; local class<Actor> TransEffect; if ( (GetTeam() == None) || (GetTeam().TeamIndex == 0) ) TransEffect = class<Actor>(DynamicLoadObject(TransEffects[0], class'Class')); else TransEffect = class<Actor>(DynamicLoadObject(TransEffects[1], class'Class')); if ( TransEffect != None ) A = Spawn(TransEffect,,,Location + CollisionHeight * vect(0,0,0.75)); // for fast moving vehicles, make the effect sticky if ( A != None ) A.SetBase( Self ); super.PlayTeleportEffect( bOut, bSound ); } simulated event PlayDying(class<DamageType> DamageType, vector HitLoc) {} simulated function int GetTeamNum() { if ( Role == Role_Authority && Team == 255 && (Controller != None) ) SetTeamNum( Controller.GetTeamNum() ); return Team; } //Notify vehicle that an enemy has locked on to it event NotifyEnemyLockedOn() { bEnemyLockedOn = true; } function IncomingMissile(Projectile P); //Notify vehicle that an enemy has lost the lock event NotifyEnemyLostLock() { bEnemyLockedOn = false; } /* Team is changed when vehicle is possessed and PrevTeam is restored when vehicle is unpossessed */ function SetTeamNum(byte T) { PrevTeam = Team; Team = T; if ( PrevTeam != Team ) TeamChanged(); } simulated event TeamChanged() {} simulated function DisplayDebug(Canvas Canvas, out float YL, out float YPos) { super.DisplayDebug(Canvas, YL, YPos); Canvas.SetDrawColor(255,255,255); Canvas.DrawText("Steering "$Steering$" throttle "$Throttle$" rise "$Rise); if ( Driver != None ) { YPos += YL; YPos += YL; Canvas.SetPos(0, YPos); Canvas.SetDrawColor(0,0,255); Canvas.DrawText("--- DRIVER"); Canvas.SetPos(4, YPos); Driver.DisplayDebug( Canvas, YL, YPos ); } } function Actor ShootSpecial(Actor A) { local Controller OldController; if ( !Controller.bCanDoSpecial || (Weapon == None) ) return None; Controller = OldController; if ( KDriverLeave(false) && (OldController.Pawn != None) ) { OldController.Pawn.SetRotation(rotator(A.Location - OldController.Pawn.Location)); OldController.Focus = A; OldController.FireWeaponAt(A); } return A; } //Vehicles stall when they go above the level's StallZ simulated event Stalled(); simulated event UnStalled(); simulated function NextWeapon() { local PlayerController PC; if ( Level.Pauser != None ) return; PC = PlayerController(Controller); if (PC == None) return; if (!PC.bBehindView) { PC.BehindView(true); DesiredTPCamDistance = TPCamDistRange.Min; TPCamDistance = DesiredTPCamDistance; } else DesiredTPCamDistance = Min(DesiredTPCamDistance + 100, TPCamDistRange.Max); default.TPCamDistance = DesiredTPCamDistance; StaticSaveConfig(); } simulated function PrevWeapon() { local PlayerController PC; if ( Level.Pauser != None ) return; PC = PlayerController(Controller); if (PC == None || !PC.bBehindView) return; if (DesiredTPCamDistance ~= TPCamDistRange.Min) PC.BehindView(false); else { DesiredTPCamDistance = Max(DesiredTPCamDistance - 100, TPCamDistRange.Min); default.TPCamDistance = DesiredTPCamDistance; StaticSaveConfig(); } } function bool TeamLink(int TeamNum) { return (LinkHealMult > 0 && Team == TeamNum && Health > 0); } event bool NeedsFlip() { local vector worldUp, gravUp; local float GravMag; GravMag = VSize(PhysicsVolume.Gravity); if( GravMag < 0.1 ) gravUp = vect(0,0,1); else gravUp = -1.0 * (PhysicsVolume.Gravity/GravMag); worldUp = vect(0,0,1) >> Rotation; if (worldUp Dot gravUp < -0.5) return true; return false; } function Flip(vector HitNormal, float ForceScale); simulated function float ChargeBar(); simulated function ClientPlayForceFeedback( String EffectName ) { local PlayerController PC; PC = PlayerController(Controller); //if ( PC != None && PC.bEnableVehicleForceFeedback ) if ( PC != None && PC.bEnableGUIForceFeedback ) { PC.ClientPlayForceFeedback( EffectName ); } } simulated function StopForceFeedback( String EffectName ) { local PlayerController PC; PC = PlayerController(Controller); //if ( PC != None && PC.bEnableVehicleForceFeedback ) if ( PC != None && PC.bEnableGUIForceFeedback ) { PC.StopForceFeedback( EffectName ); } } function ServerPlayHorn(int HornIndex) { if( (Level.TimeSeconds - LastHornTime > 3.0) && (HornIndex >= 0) && (HornIndex < HornSounds.Length) ) { PlaySound( HornSounds[HornIndex],, 3.5*TransientSoundVolume,, 800); LastHornTime = Level.TimeSeconds; } } simulated function int NumPassengers() { if ( Driver != None ) return 1; return 0; } function Pawn GetInstigator() { return Self; } function AIController GetBotPassenger() { return AIController(Controller); } event bool IsVehicleEmpty() { return (Driver == None); } function bool HasOccupiedTurret() { return false; } function float AdjustedStrength() { if (bStationary && bDefensive) return 1.0; return 0; } static function StaticPrecache(LevelInfo L); function int GetSpree() { if (Driver != None) return Driver.GetSpree(); return 0; } function IncrementSpree() { if (Driver != None) Driver.IncrementSpree(); } simulated function POVChanged(PlayerController PC, bool bBehindViewChanged) { if (PC.bBehindView) { if (bBehindViewChanged && bPCRelativeFPRotation) PC.SetRotation(rotator(vector(PC.Rotation) >> Rotation)); bOwnerNoSee = false; if (Driver != None) { if (bDrawDriverInTP) Driver.bOwnerNoSee = false; else Driver.bOwnerNoSee = true; } if (PC == Controller) // No overlays for spectators ActivateOverlay(False); } else { if (bPCRelativeFPRotation) PC.SetRotation(rotator(vector(PC.Rotation) << Rotation)); if (bDrawMeshInFP) bOwnerNoSee = false; else bOwnerNoSee = true; if (Driver != None) { Driver.bOwnerNoSee = true; } if (bDriving && PC == Controller) // No overlays for spectators ActivateOverlay(True); } } function PlayTakeHit(vector HitLocation, int Damage, class<DamageType> DamageType) { local int SoundNum; if (IndependentVehicle() && DamageType.Default.bBulletHit && BulletSounds.Length > 0) { SoundNum = Rand(BulletSounds.Length); if (Controller != None && Controller == Level.GetLocalPlayerController()) PlayOwnedSound(BulletSounds[SoundNum], SLOT_None, 2.0, False, 400); else PlayOwnedSound(BulletSounds[SoundNum], SLOT_None, 2.0, False, 100); } } function array<Vehicle> GetTurrets(); function CheckSuperBerserk(); // Used to override locking actors. Returns who the aggressor really should lock on to event bool VerifyLock(actor Aggressor, out actor NewTarget) { return true; } // Returns any alternate target actor for this vehicle if it has one simulated function actor AlternateTarget() { return None; } function ShouldTargetMissile(Projectile P) { local AIController C; C = AIController(Controller); if (C != None && C.Skill >= 5.0 && (C.Enemy == None || !C.LineOfSightTo(C.Enemy)) ) ShootMissile(P); } function ShootMissile(Projectile P) { Controller.Focus = P; Controller.FireWeaponAt(P); } function bool ImportantVehicle() { return false; } function bool IsArtillery() { return false; } //============================================================================= // defaultproperties //============================================================================= defaultproperties { bAdjustDriversHead=true LandMovementState=PlayerDriving bVehicleShadows=true bDrawVehicleShadow=true bDontPossess=true bUseCompressedPosition=false bCanPickupInventory=false Team=255 OldTeam=255 PrevTeam=255 Steering=0 Throttle=0 EjectMomentum=1000 ExitPositions(0)=(X=0,Y=0,Z=0) EntryPosition=(X=0,Y=0,Z=0) EntryRadius=100.0 DrivePos=(X=0,Y=0,Z=0) bZeroPCRotOnEntry=true bRelativeExitPos=true bPCRelativeFPRotation=true TPCamLookat=(X=-100,Y=0,Z=100) TPCamWorldOffset=(X=0,Y=0,Z=0) TPCamDistance=600 TPCamDistRange=(Min=50,Max=1500) CameraSpeed=500 bDesiredBehindView=true MaxViewYaw=16000 MaxViewPitch=16000 TransEffects(0)="XEffects.TransEffectRed" TransEffects(1)="XEffects.TransEffectBlue" DriveAnim=Vehicle_Driving CollisionRadius=+120.0 CollisionHeight=+50.0 SightRadius=+15000.0 ShadowMaxTraceDist=+350 ShadowCullDistance=1500.0 bForceSkelUpdate=true bCanBeBaseForPawns=True MomentumMult=4.0 DriverDamageMult=1.0 VehiclePositionString="in a vehicle" VehicleNameString="Vehicle" LockOnClassString="Onslaught.ONSOnslaughtMessage" RanOverDamageType=class'DamRanOver' CrushedDamageType=class'Crushed' bAllowViewChange=true LinkHealMult=0.35 VehicleLostTime=0.0 NetUpdateFrequency=4 NetPriority=1 CenterSpringForce="SpringONSHoverBike" CenterSpringRangePitch=2000 CenterSpringRangeRoll=2000 bDriverHoldsFlag=true bCanCarryFlag=true WalkingPct=+1.0 CrouchedPct=+1.0 MaxDesireability=0.5 ObjectiveGetOutDist=1000.0 WaterDamage=0.0 LockWarningInterval=+1.5 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |