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 02016 02017 02018 02019 02020 02021 02022 02023 02024 02025 02026 02027 02028 02029 02030 02031 02032 02033 02034 02035 02036 02037 02038 02039 02040 02041 02042 02043 02044 02045 02046 02047 02048 02049 02050 02051 02052 02053 02054 02055 02056 02057 02058 02059 02060 02061 02062 02063 02064 02065 02066 02067 02068 02069 02070 02071 02072 02073 02074 02075 02076 02077 02078 02079 02080 02081 02082 02083 02084 02085 02086 02087 02088 02089 02090 02091 02092 02093 02094 02095 02096 02097 02098 02099 02100 02101 02102 02103 02104 02105 02106 02107 02108 02109 02110 02111 02112 02113 02114 02115 02116 02117 02118 02119 02120 02121 02122 02123 02124 02125 02126 02127 02128 02129 02130 02131 02132 02133 02134 02135 02136 02137 02138 02139 02140 02141 02142 02143 02144 02145 02146 02147 02148 02149 02150 02151 02152 02153 02154 02155 02156 02157 02158 02159 02160 02161 02162 02163 02164 02165 02166 02167 02168 02169 02170 02171 02172 02173 02174 02175 02176 02177 02178 02179 02180 02181 02182 02183 02184 02185 02186 02187 02188 02189 02190 02191 02192 02193 02194 02195 02196 02197 02198 02199 02200 02201 02202 02203 02204 02205 02206 02207 02208 02209 02210 02211 02212 02213 02214 02215 02216 02217 02218 02219 02220 02221 02222 02223 02224 02225 02226 02227 02228 02229 02230 02231 02232 02233 02234 02235 02236 02237 02238 02239 02240 02241 02242 02243 02244 02245 02246 02247 02248 02249 02250 02251 02252 02253 02254 02255 02256 02257 02258 02259 02260 02261 02262 02263 02264 02265 02266 02267 02268 02269 02270 02271 02272 02273 02274 02275 02276 02277 02278 02279 02280 02281 02282 02283 02284 02285 02286 02287 02288 02289 02290 02291 02292 02293 02294 02295 02296 02297 02298 02299 02300 02301 02302 02303 02304 02305 02306 02307 02308 02309 02310 02311 02312 02313 02314 02315 02316 02317 02318 02319 02320 02321 02322 02323 02324 02325 02326 02327 02328 02329 02330 02331 02332 02333 02334 02335 02336 02337 02338 02339 02340 02341 02342 02343 02344 02345 02346 02347 02348 02349 02350 02351 02352 02353 02354 02355 02356 02357 02358 02359 02360 02361 02362 02363 02364 02365 02366 02367 02368 02369 02370 02371 02372 02373 02374 02375 02376 02377 02378 02379 02380 02381 02382 02383 02384 02385 02386 02387 02388 02389 02390 02391 02392 02393 02394 02395 02396 02397 02398 02399 02400 02401 02402 02403 02404 02405 02406 02407 02408 02409 02410 02411 02412 02413 02414 02415 02416 02417 02418 02419 02420 02421 02422 02423 02424 02425 02426 02427 02428 02429 02430 02431 02432 02433 02434 02435 02436 02437 02438 02439 02440 02441 02442 02443 02444 02445 02446 02447 02448 02449 02450 02451 02452 02453 02454 02455 02456 02457 02458 02459 02460 02461 02462 02463 02464 02465 02466 02467 02468 02469 02470 02471 02472 02473 02474 02475 02476 02477 02478 02479 02480 02481 02482 02483 02484 02485 02486 02487 02488 02489 02490 02491 02492 02493 02494 02495 02496 02497 02498 02499 02500 02501 02502 02503 02504 02505 02506 02507 02508 02509 02510 02511 02512 02513 02514 02515 02516 02517 02518 02519 02520 02521 02522 02523 02524 02525 02526 02527 02528 02529 02530 02531 02532 02533 02534 02535 02536 02537 02538 02539 02540 02541 02542 02543 02544 02545 02546 02547 02548 02549 02550 02551 02552 02553 02554 02555 02556 02557 02558 02559 02560 02561 02562 02563 02564 02565 02566 02567 02568 02569 02570 02571 02572 02573 02574 02575 02576 02577 02578 02579 02580 02581 02582 02583 02584 02585 02586 02587 02588 02589 02590 02591 02592 02593 02594 02595 02596 02597 02598 02599 02600 02601 02602 02603 02604 02605 02606 02607 02608 02609 02610 02611 02612 02613 02614 02615 02616 02617 02618 02619 02620 02621 02622 02623 02624 02625 02626 02627 02628 02629 02630 02631 02632 02633 02634 02635 02636 02637 02638 02639 02640 02641 02642 02643 02644 02645 02646 02647 02648 02649 02650 02651 02652 02653 02654 02655 02656 02657 02658 02659 02660 02661 02662 02663 02664 02665 02666 02667 02668 02669 02670 02671 02672 02673 02674 02675 02676 02677 02678 02679 02680 02681 02682 02683 02684 02685 02686 02687 02688 02689 02690 02691 02692 02693 02694 02695 02696 02697 02698 02699 02700 02701 02702 02703 02704 02705 02706 02707 02708 02709 02710 02711 02712 02713 02714 02715 02716 02717 02718 02719 02720 02721 02722 02723 02724 02725 02726 02727 02728 02729 02730 02731 02732 02733 02734 02735 02736 02737 02738 02739 02740 02741 02742 02743 02744 02745 02746 02747 02748 02749 02750 02751 02752 02753 02754 02755 02756 02757 02758 02759 02760 02761 02762 02763 02764 02765 02766 02767 02768 02769 02770 02771 02772 02773 02774 02775 02776 02777 02778 02779 02780 02781 02782 02783 02784 02785 02786 02787 02788 02789 02790 02791 02792 02793 02794 02795 02796 02797 02798 02799 02800 02801 02802 02803 02804 02805 02806 02807 02808 02809 02810 02811 02812 02813 02814 02815 02816 02817 02818 02819 02820 02821 02822 02823 02824 02825 02826 02827 02828 02829 02830 02831 02832 02833 02834 02835 02836 02837 02838 02839 02840 02841 02842 02843 02844 02845 02846 02847 02848 02849 02850 02851 02852 02853 02854 02855 02856 02857 02858 02859 02860 02861 02862 02863 02864 02865 02866 02867 02868 02869 02870 02871 02872 02873 02874 02875 02876 02877 02878 02879 02880 02881 02882 02883 02884 02885 02886 02887 02888 02889 02890 02891 02892 02893 02894 02895 02896 02897 02898 02899 02900 02901 02902 02903 02904 02905 02906 02907 02908 02909 02910 02911 02912 02913 02914 02915 02916 02917 02918 02919 02920 02921 02922 02923 02924 02925 02926 02927 02928 02929 02930 02931 02932 02933 02934 02935 02936 02937 02938 02939 02940 02941 02942 02943 02944 02945 02946 02947 02948 02949 02950 02951 02952 02953 02954 02955 02956 02957 02958 02959 02960 02961 02962 02963 02964 02965 02966 02967 02968 02969 02970 02971 02972 02973 02974 02975 02976 02977 02978 02979 02980 02981 02982 02983 02984 02985 02986 02987 02988 02989 02990 02991 02992 02993 02994 02995 02996 02997 02998 02999 03000 03001 03002 03003 03004 03005 03006 03007 03008 03009 03010 03011 03012 03013 03014 03015 03016 03017 03018 03019 03020 03021 03022 03023 03024 03025 03026 03027 03028 03029 03030 03031 03032 03033 03034 03035 03036 03037 03038 03039 03040 03041 03042 03043 03044 03045 03046 03047 03048 03049 03050 03051 03052 03053 03054 03055 03056 03057 03058 03059 03060 03061 03062 03063 03064 03065 03066 03067 03068 03069 03070 03071 03072 03073 03074 03075 03076 03077 03078 03079 03080 03081 03082 03083 03084 03085 03086 03087 03088 03089 03090 03091 03092 03093 03094 03095 03096 03097 03098 03099 03100 03101 03102 03103 03104 03105 03106 03107 03108 03109 03110 03111 03112 03113 03114 03115 03116 03117 03118 03119 03120 03121 03122 03123 03124 03125 03126 03127 03128 03129 03130 03131 03132 03133 03134 03135 03136 03137 03138 03139 03140 03141 03142 03143 03144 03145 03146 03147 03148 03149 03150 03151 03152 03153 03154 03155 03156 03157 03158 03159 03160 03161 03162 03163 03164 03165 03166 03167 03168 03169 03170 03171 03172 03173 03174 03175 03176 03177 03178 03179 03180 03181 03182 03183 03184 03185 03186 03187 03188 03189 03190 03191 03192 03193 03194 03195 03196 03197 03198 03199 03200 03201 03202 03203 03204 03205 03206 03207 03208 03209 03210 03211 03212 03213 03214 03215 03216 03217 03218 03219 03220 03221 03222 03223 03224 03225 03226 03227 03228 03229 03230 03231 03232 03233 03234 03235 03236 03237 03238 03239 03240 03241 03242 03243 03244 |
//============================================================================= // U2Weapon.uc // Created By: Mike Lambert // Created On: 6/14/01 // $Author: Mfox $ // $Date: 1/29/03 1:50p $ // $Revision: 157 $ //============================================================================= class U2Weapon extends Weapon native abstract; /* Current States: (they should be self-explanatory) Active DownWeapon Firing AltFiring Idle Reloading ==OVERVIEW== How the weapon works: Reloading/Unloading: Unload() and Reload() functions hide the different anims from the programmer. Reload() can be called whenever a reload is desired, either when the weapon currently has a partial clip, or it's empty. It takes care of playing OutOfAmmo if necessary, and sends it to the Reloading state to handle the animations during that time. Unload() is used to make the weapon behave as an unloaded gun, and is called after the current clip is emptied. To handle this unloaded 'state' without a real state, there are various properties such as: AmbientAnim, DownAnim, SelectAnim, which are set differently in Reload() and Unload(). All weapon logic can now be the same, and the code should just play the appropriate animation variable, ensuring that unloaded and loaded states are never confused. Selecting/PutDown: No more PlayPostSelect. Most of the logic here has still been inherited from the Weapon code. Fire/AltFire: Every weapon gets its Fire called, which calls AuthorityFire if we are on the server, and then proceeds to ALWAYS call EverywhereFire, to handle effects. In order to properly send the weapon back to the idle state, the Firing/AltFiring states are used. These states are able to handle both auto-firing weapons and single-shot weapons, and will do the appropriate logic for each. EverywhereFire is equivalent to the old ClientFire, and AuthorityFire is very similar to old Fire. Fire is now just a dispatch mechanism for all fire events. This is not done in PlayerController any longer. FireSound/AltFireSound, when used for single-shot weapons, plays once for each shot. When used in continous (bRapidFire/bRapidAltFire) weapons, it will be put in the AmbientSound. Shot Effects: They've now been moved into a base class, where you specify the appropriate type of effect in the def.props. The effect is appropriately triggered with each Fire/AltFire, and it supports different effects for both Fire and AltFire using the PGenClass and PGenEffect two-element arrays. Any triggerable actor should be put there, and it will be triggered with each Fire/AltFire. Fire corresponds to the first element, and AltFire corresponds to the second element of those arrays. In addition, if one needs to modify the spawn offsets (currently a hack while we wait to become 100%-golem-ized), there is FlashOffsetFP and FlashOffsetTP arrays for use. The FlameThrower currently does not use this interface because it wants to be the odd one out where it does not use a triggerable interface, and so it does the effects manuallly in its concrete subclass. ===ANIMATION, SOUNDS, AND SETUP=== Sequences Needed: Ambient, AmbientUnloaded, Down, DownUnloaded, Select, SelectUnloaded Fire,Fire1,Fire2,Fire3,etc, FireLastRound, FireEnd AltFire,AltFire2,AltFire3,AltFire3,etc, AltFireLastRound, AltFireEnd OutOfAmmo, Reload, Idle,Idle2,Idle3,etc All Weapons Need: Ambient/AmbientUnloaded: regular swaying of the weapon Down/DownUnloaded: bring down the weapon, in order to switch to another weapon Select/SelectUnloaded: bring up the weapon, in order to use it Reload: reloads a new clip into the weapon from an unloaded frame OutOfAmmo: drop the current partial clip in preparation for a reload Firing animation stuff: (each of the below applies equally-well to AltFire animations) Set the names of the various fire animations in the FireAnims dynamic array. If the weapon has a wind-down animation, it needs to be called FireEnd, and bNeedsWindDown should be set If the weapon has an animation for when it fires the last shot of the round/clip, it needs to be called FireLastRound. This should bring the weapon into an unloaded frame in preparation for Reload Idle animation stuff: Set the names of the various idle animations in the IdleAnims dynamic array. Variables to set: If one has a special animation for FireLastRound bHasFireLastRound/bHasAltFireLastRound should be set FireLastRound/AltFireLastRound should be the appropriate animation name for the wind-down FireEndSound/AltFireSound are the sound to be played as the weapon shoots its last shot If one has a wind-down stage: bNeedsWindDown/bAltNeedsWindDown should be set FireEndSound/AltFireSound are the sound to be played as the weapon winds down FireEnd/AltFireEnd should be the appropriate animation name for the wind-down If one wants a held-down fire key to repeat the fire loop, for stuff like the pistol/CAR: bRepeatFire/bAltRepeatFire must be set If the FireSound/FireAltSound is an ambient sound to be played for the life of the weapon's firing (from entering the firing state, to leaving it) bAmbientFireSound/bAmbientAltFireSound should be set For TraceHit Weapons: Damage, MomentumTransfer, TraceRange, TraceSpreadFire, TraceSpreadAltFire bInstantHit should be set For Projectile Weapons: ProjectileClass/AltProjectileClass MyDamageType is the type of damage ShellClass/AltShellClass WeaponAnimationType ImpactHandlerClass Shaking Weapons: ShakeMag/AltShakeMag, ShakeTime/AltShakeTime, ShakeVert/AltShakeVert Kicking Weapons: WeaponKickDirection/AltWeaponKickDirection, WeaponKickDuration/AltWeaponKickDuration, WeaponKickRecoveryDuration/AltWeaponKickRecoveryDuration Targetting Weapons with the HUD: TargetableTypes is an array of the classes which can be targetted by the weapon bRapidFire/bAltRapidFire helps the Pawn know what kind of animations it needs to play on it's end AI Vars: (MikeF may be able to fill this section in more) bWarnTarget/bAltWarnTarget bRecommendSplashDamage/bRecommendAltSplashDamage RefireRate/AltRefireRate Aiming: see AdjustAim comments. Note that TraceSpreadFire/AltFire reflects the spread of the weapon due to its firing characteristics (in degrees around the selected aim direction). This affects PCs and NPCs equally and does not affect the actual aiming of weapon (PCs do their own aiming generally and for NPCs, their accuracy is determined by the game's difficulty and various ohter factors such as whether the enemy was recently acquired or is falling etc. Sounds: FireSound, AltFireSound, CockingSound (for reload/unload), SelectSound, FireEndSound, AltFireEndSound (described above) Note: The use of PlaySound in here is intended. Since it is always called from simulated functions, it will never be replicated to anyone when called on the server. Thus, one must ensure that the logic below occurs on all clients which should hear the sound. Limitations: The U2Weapon only offers one type of ammo, and one type of reload. It cannot do different fire and altfire reloads. It cannot do simultaneous Fire/AltFire combinations ===RENDERING AND DAMAGE=== first-person: NM_Standalone: the player NM_Listen: the player NM_Dedicated: none NM_Client: the player third-person when drawn: NM_Standalone: visible pawns NM_Listen: visible pawns NM_Dedicated: none NM_Client: visible pawns third-person when not drawn: NM_Standalone: non-visible pawns NM_Listen: non-visible pawns NM_Dedicated: all pawns NM_Client: non-visible pawns (for brief periods of relevancy) Weapon Drawing: RenderOverlays() Weapon Moving: first-person: moved in RenderOverlays third-person when drawn: moved when drawn (done natively) third-person when not drawn: moved in Tick ... a rough estimate ParticleSystem Drawing: SpecialDraw() ParticleSystem Moving: first-person: moved in SpecialDraw (called from native code) third-person when drawn: moved in SpecialDraw (called from native code) third-person when not drawn: moved in Tick ... a rough estimate ParticeSystem Locations: (if visible)=> visual damage <=(if on role_authority) first-person: head head third-person when drawn: hand hand third-person when not drawn: ---- head */ #exec OBJ LOAD FILE=..\Sounds\U2WeaponsA.uax // animation support var(Firing) float FireTime, AltFireTime, FireLastDownTime, AltFireLastDownTime, FireLastReloadTime, AltFireLastReloadTime, ReloadTime, ReloadUnloadedTime, SelectTime, DownTime; // flashskin support var() Material FlashSkin; //the skin to show when we just fired, and want to make the gun appear brighter from the flash var() Material FlashSkinTP; var float FireSkinTime; //Time we set the fireskin, so we can turn it off in the next tick (using a timer caused it to be turned off before we even saw it ;) var() sound FireEndSound, AltFireEndSound; //coincides with FireEnd (the post shot die-down) or FireLastRound (the last shot) animations var() sound FireLastRoundSound, AltFireLastRoundSound; var() sound ReloadUnloadedSound; var() array<sound> GunButtSounds; var() range FirePitch, AltFirePitch; var float ProjectileSpeed, AltProjectileSpeed; // used for aiming particle-based "projectile" weapons var mesh FirstPersonMesh; // decorative effects // Fix ARL: Add support for multiple detail levels. var() array< struct native DecoEffect { var() name AnimSequence; // name of the associated animation that this effect should be triggered on var() class<Actor> DecoClass; // name of the class to spawn var() ParticleGenerator Particles; // name of the package.object to load the particle system from (optional) var() string MountNode; // name of the bone to attach to (can be left blank for attaching relative to the weapon's origin) var() vector MountOffset; // translation offset from mount location var() rotator MountRot; // rotation offset from mount orientation var() vector ThirdPersonOffset; // translation offset from weapon hand location in 3rd person (since those use staticmeshes, not golem meshes) var() bool GameplayRelevant; // effect has an effect on gameplay, such as damaging particles (will be placed at head offset) var() bool bTriggerUpdateOnly; // only update location when triggered (for effects that need to be left behind) var() bool bWorldFOV; // draw in world fov (as opposed to weapon fov) var() bool bRequiresWorldZBuffer;// if false and in a 1st-person weapon, draws after the z-buffer has been cleared and the weapon has been drawn. otherwise, draws into the world zbuffer var() bool AutoAim; // aim particle as though it was a projectile spawned via ProjectileFire. var() int AIAim; // if set, auto-aim effect for NPCs (value should be set to the speed of the projectile we're aiming -- for leading). var() float PushBack; // push the effect back up to this number of units if we're too close to anything (not evaluated for TriggerUpdateOnly effects). var Actor Effect; // instance of above described effect } > DecoEffects; var name LastTriggeredAnim; var bool bLockLocation; //DEBUG: set to stop weapon from updating it's location //DEBUG: For temporarily tweaking weapon offsets. var bool bAdjustWeaponXY; var bool bAdjustWeaponZ; var bool bAdjustWeaponPitchYaw; var bool bAdjustWeaponRoll; var int MagicKey; var float fAdjustWeaponRate; var vector LocationOffset; var rotator RotationOffset; var vector TraceFireStartLocation; var vector ProjectileFireStartLocation; var() vector FirstPersonOffset; var() bool bRepeatFire, bRepeatAltFire; //should we go directly into playing the next animation after playing this one? var() bool bAmbientFireSound, bAmbientAltFireSound; //should the FireSound/AltFireSound be played as an ambient sound? var config bool UseGlowingCrosshairs; // Allow user to disable for performance. var bool bCrosshairGlows; //crosshair should glow when it is over a targetable actor var bool bGlowing; //whether the crosshair is currently glowing var Controller.EAttitude GlowingAttitude; //attitude towards targetable actor (enemy/neutral/friend) var() protected LicenseePawn.EWeaponAnimationType WeaponAnimationType; // usual intended animation type for weapon (shoulder, small etc.) var() class<ImpactHandler> ImpactHandlerClass; // var() float Damage,AltDamage; // used for instant hit weapons var() float MomentumTransfer; // used for instant hit weapons var() float TraceRange; // range used within TraceFire() var() float TraceSpreadFire, TraceSpreadAltFire; // spread (degrees) used with TraceFire() for PCs and NPCs // weapon shake (extension of ShakeMag, ShakeTime, ShakeVert implemented in Weapon.uc) var(WeaponShake) float AltShakeMag; // var(WeaponShake) float AltShakeTime; // // shell ejection var() class<U2ShellCase> ShellClass; // var() class<U2ShellCase> AltShellClass; // var() vector ShellOffset; // // weapon dropped -- bounce handling var() sound BounceSound; var() float BounceDamping; // misc. weapon effects var float LastWaterRingTime; var bool bFiring; // firing state (used to differentiate Fire()/AltFire() handling) var bool bAltFiring; var bool bLastRound; // Crosshair stuff. var() array<name> TargetableTypes; // Types of classes we can target. var() string CrosshairFilename; var() string CrosshairName; var ComponentHandle Crosshair; // optimization support. var float LastFullUpdateTime; var bool bDisableTick; // performance testing: disable weapon tick overhead temporarily var bool bDisableFiring; // performance testing: disable weapon firing overhead temporarily //----------------------------------------------------------------------------- // U2 Weapon AI properties //----------------------------------------------------------------------------- const MaxRapidFireRate = 0.50; // firing rates <= this are considered rapid fire const MinSlowFireRate = 0.51; // firing rates >= this are considered slow fire // special weapon rating values const RatingFireNow = 100.000; // weapon wants Pawn to fire it immediately (i.e. even if no target) const RatingHighest = 90.000; // weapon thinks it would be highly effective if used now const RatingDefault = 0.000; // default const RatingLow = -5.000; // weapon is a poor choice but could be used if nothing better const RatingIneffective = -10.000; // weapon will have no effect on target in current situation const RatingDangerous = -20.000; // using weapon now will likely hurt/kill owner const RatingNoAmmo = -30.000; // not enough ammo to fire/altfire const RatingCantFire = -40.000; // can't actually fire weapon currently (not ready etc.) const RatingDisabled = -50.000; // weapon is disabled (alt and primary fire) const RatingNone = -99.999; // no rating (e.g. no weapon) const RangeUnlimited = 32767.0; // no limit to effective range of weapon (limit to reasonable size for levels) // AI !!mdf-tbd: generalize var() bool bAimFire; // whether primary fire requires owner aiming (usually true) var() bool bAimAltFire; // whether alt fire requires owner aiming (usually true) var() bool bFireEnabledForOwner; // supports disabling fire for specific weapons for specific NPCs var() bool bAltFireEnabledForOwner; // supports disabling altfire for specific weapons for specific NPCs //NOTE: AIRating still used to specify the "global" rating for a weapon vs other weapons and should be set //to Max( AIRatingFire, AIRatingAltFire ); //!!mdf-tbd: turn all of these into config vars for tweaking purposes var() float RangeMinFire; // min range to target for firing weapon (-1 = range not considered) var() float RangeIdealFire; // ideal range to target for firing weapon (-1 = range not considered) var() float RangeMaxFire; // max range to target for firing weapon (-1 = range not considered) var() float RangeLimitFire; // absolute limit of range to target for firing weapon (default is use RangeMaxFire as limit) var() float RatingInsideMinFire; // rating for firing weapon inside min range var() float RatingRangeMinFire; // rating for firing weapon at min range var() float RatingRangeIdealFire; // rating for firing weapon at ideal range var() float RatingRangeMaxFire; // rating for firing weapon at max range var() float RatingRangeLimitFire; // rating for firing weapon at limit of range var() float AIRatingFire; // default rating for firing weapon (used when range not considered or no target) var() float RangeMinAltFire; // min range to target for alt-firing weapon (-1 = range not considered) var() float RangeIdealAltFire; // ideal range to target for alt-firing weapon (-1 = range not considered) var() float RangeMaxAltFire; // max range to target for alt-firing weapon (-1 = range not considered) var() float RangeLimitAltFire; // absolute limit of range to target for alt-firing weapon (default is use RangeMaxAltFire as limit) var() float RatingInsideMinAltFire; // rating for alt-firing weapon inside min range var() float RatingRangeMinAltFire; // rating for alt-firing weapon at min range var() float RatingRangeIdealAltFire; // rating for alt-firing weapon at ideal range var() float RatingRangeMaxAltFire; // rating for alt-firing weapon at max range var() float RatingRangeLimitAltFire; // rating for alt-firing weapon at limit of range var() float AIRatingAltFire; // default rating for alt-firing weapon (used when range not considered or no target var float UpdateRangeGravityZ; // for weapons using tossed projectiles, last Z gravity used to update ranges var Ammunition UpdateRangeAmmoType; // for weapons using tossed projectiles (in case ammo type can vary) var U2PlayerController U2PCOwner; // set in XXXBeginPlay to avoid need to cast owner all over the place replication { // we use unreliable here to avoid network overflow from reliable functions // the order and guarantee of the function is not as important, // and packetloss causing ClientTraceImpact to fail is an acceptable tradeoff unreliable toall if( Role == ROLE_Authority ) ClientTraceImpact; } //DEBUG: For temporarily tweaking weapon offsets. exec function AdjustWeaponXY() { bAdjustWeaponXY =true; StartAdjust(); } exec function AdjustWeaponZ() { bAdjustWeaponZ =true; StartAdjust(); } exec function AdjustWeaponPitchYaw() { bAdjustWeaponPitchYaw =true; StartAdjust(); } exec function AdjustWeaponRoll() { bAdjustWeaponRoll =true; StartAdjust(); } exec function AdjustWeaponRate(float f) { fAdjustWeaponRate = f; } exec function StopAdjust() { bAdjustWeaponXY=false; bAdjustWeaponZ=false; bAdjustWeaponPitchYaw=false; bAdjustWeaponRoll=false; if(MagicKey!=0) class'UIConsole'.static.RemoveKeyEventListener( MagicKey ); MagicKey=0; } function StartAdjust() { MagicKey = class'UIConsole'.static.AddKeyEventListener( self, "MouseMove" ); } exec function AdjustWeaponLog() { DM ( "X="$-LocationOffset.Y @ "Y="$LocationOffset.Z @ "Z="$LocationOffset.X @ "Pitch="$RotationOffset.Pitch * 360.0 / 65536.0 @ "Yaw="$RotationOffset.Yaw * 360.0 / 65536.0 @ "Roll="$RotationOffset.Roll * 360.0 / 65536.0 ); } function bool MouseMove( Console.EInputKey Key, Console.EInputAction Action, float Delta ) { if( Action == IST_Axis ) { switch( Key ) { case IK_MouseX: if(bAdjustWeaponXY) LocationOffset.Y += fAdjustWeaponRate * Delta; if(bAdjustWeaponPitchYaw) RotationOffset.Yaw += fAdjustWeaponRate * Delta * 182.0; if(bAdjustWeaponRoll) RotationOffset.Roll += fAdjustWeaponRate * Delta * 182.0; ThirdPersonRelativeLocation = LocationOffset; return true; case IK_MouseY: if(bAdjustWeaponXY) LocationOffset.Z += fAdjustWeaponRate * Delta; if(bAdjustWeaponZ) LocationOffset.X += fAdjustWeaponRate * Delta; if(bAdjustWeaponPitchYaw) RotationOffset.Pitch += fAdjustWeaponRate * Delta * 182.0; ThirdPersonRelativeLocation = LocationOffset; return true; } } return false; } //Dummy overrides to ensure no logic from parent classes comes through simulated function Finish() {} simulated function ClientFinish() {} simulated event AnimEnd( int Channel ) {} //----------------------------------------------------------------------------- // Aiming //----------------------------------------------------------------------------- function bool AdjustTraceAim( float projSpeed, vector projStart, float FireSpread, bool bLeadTarget, bool bWarnTarget, bool bTossed, bool bTrySplash ) { return Pawn(Owner).AdjustAim( None, projSpeed, projStart, FireSpread, false, false, false, false ); } function bool AdjustProjectileAim( bool bAltFire, class<Projectile> ProjectileClass, vector projStart, float FireSpread, bool bLeadTarget, bool bWarnTarget, bool bTossed, bool bTrySplash ) { return Pawn(Owner).AdjustAim( ProjectileClass, GetProjSpeed( bAltFire ), projStart, FireSpread, bLeadTarget, bWarnTarget, bTossed, bTrySplash ); } function bool AdjustAim( bool bAltFire, bool bInstant, float FireSpread, class<projectile> ProjClass, bool bWarnTarget, bool bTrySplash ) { local bool bResult; // test for situation which doesn't require aiming (e.g. takkra alt fire) if( !bAltFire && !bAimFire ) bResult = true; else if( bAltFire && !bAimAltFire ) bResult = true; else if( bInstant ) bResult = AdjustTraceAim( 1000000, TraceFireStartLocation, FireSpread, false, false, false, false ); else bResult = AdjustProjectileAim( bAltFire, ProjClass, ProjectileFireStartLocation, FireSpread, true, bWarnTarget, ProjClass? && (ProjClass.default.Physics == PHYS_Falling), bTrySplash ); return bResult; } /*----------------------------------------------------------------------------- Most weapons use the default PreSetAimingParameters behavior (when owner begins firing the weapon, set fire start location, then set owner's aiming rotation for use when the weapon is actually fired. If false is returned, abort firing the weapon. The DP alt-fire fires its projectile when the owner *stops* alt-firing and in this case the weapon is aimed just prior to spawning the projectile (at that point it is too late to abort firing the weapon). */ function bool PreSetAimingParameters( bool bAltFire, bool bInstant, float FireSpread, class<projectile> ProjClass, bool bWarnTarget, bool bTrySplash ) { local bool bResult; SetFireStartLocations(); bResult = AdjustAim( bAltFire, bInstant, FireSpread, ProjClass, bWarnTarget, bTrySplash ); return bResult; } function PostSetAimingParameters( bool bAltFire, bool bInstant, float FireSpread, class<projectile> ProjClass, bool bWarnTarget, bool bTrySplash ) { // override to have this function do anything useful } //----------------------------------------------------------------------------- // AI Interface //----------------------------------------------------------------------------- /*----------------------------------------------------------------------------- NOTES: U2 NPCs can be set up to not use fire/altfire on a per-NPC basis (e.g. to force an NPC to use a particular weapon in a specific manner). */ //----------------------------------------------------------------------------- function final DMW( coerce string Msg ) { if( false ) DMTN( Msg ); } //----------------------------------------------------------------------------- function UpdateRanges( float Speed, float DamageRadius, out float RangeIdeal, out float RangeMax, out float RangeLimit ) { local float MaxRange; // do the calculation using the current gravity MaxRange = class'UtilGame'.static.GetMaxRange( Owner, class'Projectile', Speed ); RangeLimit = MaxRange + DamageRadius; RangeIdeal = 0.30*MaxRange; // seems about right for grenades -- maybe not for all tossed projectiles? RangeMax = 0.75*MaxRange; // seems about right for grenades -- maybe not for all tossed projectiles? //DMTNS( "ProjectileClass: " $ ProjectileClass ); //DMTNS( "Speed: " $ Speed ); //DMTNS( "DamageRadius: " $ DamageRadius ); //DMTNS( "MaxRange: " $ MaxRange ); //DMTNS( "RangeMax: " $ RangeMax ); //DMTNS( "RangeLimit: " $ RangeLimit ); } //----------------------------------------------------------------------------- function UpdatePriRanges() { if( ProjectileClass? && ProjectileClass.default.Physics == PHYS_Falling ) UpdateRanges( GetProjSpeed( false ), ProjectileClass.default.DamageRadius, RangeIdealFire, RangeMaxFire, RangeLimitFire ); } //----------------------------------------------------------------------------- function UpdateAltRanges() { if( AltProjectileClass? && AltProjectileClass.default.Physics == PHYS_Falling ) UpdateRanges( GetProjSpeed( true ), AltProjectileClass.default.DamageRadius, RangeIdealAltFire, RangeMaxAltFire, RangeLimitAltFire ); } //----------------------------------------------------------------------------- function bool HasEnoughModeAmmo( int AmmoUsed, int NumUses ) { return( !AmmoType || AmmoUsed <= 0 || AmmoType.AmmoAmount/AmmoUsed >= NumUses ); } /*----------------------------------------------------------------------------- Has enough fire or alt-fire ammo to fire the weapon at least the given number of times. !!mdf-tbd: probably need properties to indicate whether each mode of fire can actually be used to attack (e.g. don't want to return true for alt-fire of sniper rifle...) !!mdf-tbd: possible optimization -- this is potentially getting called very frequently. Could add bEnoughFireAmmo and bEnoughAltFireAmmo and just track these whenever ammo amount changes (this will happen a lot less frequently). */ function bool HasEnoughAmmo( int MinUses ) { return( HasEnoughModeAmmo( GetFireAmmoUsed(), MinUses ) || HasEnoughModeAmmo( GetAltFireAmmoUsed(), MinUses ) ); } //----------------------------------------------------------------------------- // Primary and Alt firing modes are both enabled and both were given about the // same rating. Select one or the other. function byte SelectFiringMode( Actor Target ) { // !!mdf-tbd: add a property for this return byte(FRand() < 0.5); // 50/50 fire/altfire for now } /*----------------------------------------------------------------------------- Can be used in subclasses to modify weapon's fire/altfire ratings prior to call(s) to GetModeRating for each mode and to optionally prevent GetModeRating form being called for either or both modes. NOTE: If a rating of RatingDisabled is passed in, subclasses should NOT modify that rating since this means that weapon use for this mode (primary/alt) is disabled (e.g. because bots don't know how to use that mode or because the weapon itself isn't yet functional). Subclasses can clear bGetFireRating and/or bGetAltFireRating to disable the call to GetModeRating for the primary and/or alt fire modes respectively. */ function PreModifyRatings( Actor Target, float DistanceToEnemy, out float PriFireRating, out float AltFireRating, out byte bGetFireRating, out byte bGetAltFireRating ) {} /*----------------------------------------------------------------------------- Can be used in subclasses to modify weapon's fire/altfire ratings after call(s) to GetModeRating for each mode. NOTE: If a rating of RatingDisabled is passed in, subclasses should NOT modify that rating since this means that weapon use for this mode (primary/alt) is disabled (e.g. because bots don't know how to use that mode or because the weapon itself isn't yet functional). */ function PostModifyRatings( Actor Target, float DistanceToEnemy, out float PriFireRating, out float AltFireRating ) {} //----------------------------------------------------------------------------- // Returns default Fire/AltFire rating. Subclasses can hook into this? // !!mdf-tbd: add other hooks as needed as more specific weapon rating added. function float DefaultRating( Actor Target, bool bUseAltMode ) { if( bUseAltMode ) return AIRatingAltFire; else return AIRatingFire; } //----------------------------------------------------------------------------- function float NoEnemyRating( bool bUseAltMode ) { return DefaultRating( None, bUseAltMode ); } //----------------------------------------------------------------------------- function float NotUsingRangeRating( Actor Target, bool bUseAltMode ) { return DefaultRating( Target, bUseAltMode ); } /*----------------------------------------------------------------------------- !!mdf-tbd: encourage bot to position himself in anticipation of switching to some weapon which is effective at that location (distance, snipe point etc.) while using best weapon for current distance i.e. 1) what is my best weapon for my current position 2) what is my best weapon overall if I can get into a good situation in which to use it (e.g. if many targets in one area, back off, fire singularity cannon from distance, avoid that area for a while; have shotgun -- fire current weapon while closing then blow target away from close range with shotgun (note have to factor in time to switch into decision to switch should also add code to take reloading into account... bots should reload appropriately (i.e. if Skill > x, don't wait until out of ammo) !!mdf-tbd: properties should replace magic #'s here (InsideMinRangeAIRating etc. -- e.g. with some weapons, firing weapon at target inside min range could be 100% fatal to npc !!mdf-tbd: simply usess a location-to-location dist -- take CC sizes into account? tbd: check target visibility? !!mdf-tbd: what if outside max range but rapidly closing on target? !!mdf-tbd: how to generalize increasing rating with owner's skill? !!mdf-tbd: support non linear scaling, e.g. exponential falloffs? */ // !!mdf-tbi: expose this and associated code so that any NPC can determine the effectiveness of an attack // based on distance to target even if they don't use actual weapons. function float GetModeRating( Actor Target, float DistanceToEnemy, float RangeMin, float RangeIdeal, float RangeMax, float RangeLimit, float RatingInsideMin, float RatingRangeMin, float RatingRangeIdeal, float RatingRangeMax, float RatingRangeLimit, float RatingBase, bool bUseAltMode ) { local float ReturnedRating; local float DistancePastMax, ScaleFactor; //#debug DMW( "GetModeRating -- RangeMin: " $ RangeMin $ " RangeMax: " $ RangeMax $ " DistanceToEnemy: " $ DistanceToEnemy ); if( !Target ) { // no target -- default to "raw" rating //#debug DMW( "no target" ); ReturnedRating = NoEnemyRating( bUseAltMode ); } else if( RatingBase == RatingDisabled ) { // weapon is disabled in this mode return RatingDisabled; } else if( RangeMin == -1 || RangeMax == -1 ) { // weapon not affected by range -- default to "raw" rating //#debug DMW( "not affected by range" ); ReturnedRating = NotUsingRangeRating( Target, bUseAltMode ); } else if( DistanceToEnemy < RangeMin ) { // 0..Min --> RatingIneffective //#debug DMW( "in 0..min" ); ReturnedRating = RatingInsideMin; } else if( DistanceToEnemy < RangeIdeal ) { // Min..Ideal --> RatingRangeMin..RatingRangeIdeal //#debug DMW( "in min..ideal" ); ReturnedRating = (RatingRangeIdeal-RatingRangeMin)*(DistanceToEnemy-RangeMin)/(RangeIdeal-RangeMin) + RatingRangeMin; } else if( DistanceToEnemy < RangeMax ) { // Ideal..Max --> RatingRangeIdeal to RatingRangeMax //#debug DMW( "in ideal..max: " ); ReturnedRating = ( (RatingRangeIdeal-RatingRangeMax)*(RangeMax-DistanceToEnemy)/(RangeMax-RangeIdeal) + RatingRangeMax ); } else if( DistanceToEnemy < RangeLimit ) { // Max..Limit --> RatingRangeMax..RatingRangeLimit (fall off with square of distance past max?) //#debug DMW( "in max..limit " ); DistancePastMax = (DistanceToEnemy - RangeMax)*0.10; // don't fall off too quickly (!!mdf-tbd: expose this?) ScaleFactor = FMax( 0.0, (RangeLimit-(DistanceToEnemy+DistancePastMax*DistancePastMax))/(RangeLimit-RangeMax) ); ReturnedRating = ( (RatingRangeMax-RatingRangeLimit)*ScaleFactor + RatingRangeLimit ); } else { // > Limit --> RatingIneffective (outside of range limit for weapon) //#debug DMW( "in limit.." ); ReturnedRating = RatingIneffective; } return ReturnedRating; } //----------------------------------------------------------------------------- // Use the CC to CC distance, not the location to location distance. function float GetWeaponDistanceToEnemy( Actor Target ) { if( !Target ) return -1.0; else return class'Util'.static.GetDistanceBetweenActors( Owner, Target ); } //----------------------------------------------------------------------------- function float GetWeaponRating( Actor Target, out byte bUseAltMode, bool bSupportsFire, bool bSupportsAltFire ) { local float ReturnedRating; local float DistanceToEnemy; local float PriFireRating, AltFireRating; local byte bGetFireRating, bGetAltFireRating; local float RandomizeRange; if( bSupportsFire ) { PriFireRating = RatingNone; bGetFireRating = 1; } else { PriFireRating = RatingDisabled; bGetFireRating = 0; } if( bSupportsAltFire ) { AltFireRating = RatingNone; bGetAltFireRating = 1; } else { AltFireRating = RatingDisabled; bGetAltFireRating = 0; } DistanceToEnemy = GetWeaponDistanceToEnemy( Target ); //DMTNS( "GetWeaponRating -- DistanceToEnemy: " $ DistanceToEnemy ); //DMTNS( "AmmoType: " $ AmmoType ); //DMTNS( "ProjectileClass: " $ ProjectileClass ); // if gravity changed (or first time through) redo ranges for tossed projectiles if( PhysicsVolume.Gravity.Z != UpdateRangeGravityZ || AmmoType != UpdateRangeAmmoType ) { UpdatePriRanges(); UpdateAltRanges(); UpdateRangeGravityZ = PhysicsVolume.Gravity.Z; UpdateRangeAmmoType = AmmoType; } // give weapon a chance to muck with ratings PreModifyRatings( Target, DistanceToEnemy, PriFireRating, AltFireRating, bGetFireRating, bGetAltFireRating ); if( bGetFireRating == 1 ) { // get fire rating PriFireRating = GetModeRating( Target, DistanceToEnemy, RangeMinFire, RangeIdealFire, RangeMaxFire, RangeLimitFire, RatingInsideMinFire, RatingRangeMinFire, RatingRangeIdealFire, RatingRangeMaxFire, RatingRangeLimitFire, AIRatingFire, false ); } if( bGetAltFireRating == 1 ) { // get altfire rating AltFireRating = GetModeRating( Target, DistanceToEnemy, RangeMinAltFire, RangeIdealAltFire, RangeMaxAltFire, RangeLimitAltFire, RatingInsideMinAltFire, RatingRangeMinAltFire, RatingRangeIdealAltFire, RatingRangeMaxAltFire, RatingRangeLimitAltFire, AIRatingAltFire, true ); } // now that the pri/alt ratings are known give subclasses a chance to filter pri/alt fire PostModifyRatings( Target, DistanceToEnemy, PriFireRating, AltFireRating ); // !!mdf-tbd: treat fairly close results as being the same so one of fire/altfire doesn't dominate? //#debug DMW( "GetWeaponRating -- Comparing PriFireRating " $ PriFireRating $ " with AltFireRating " $ AltFireRating ); ReturnedRating = FMax( PriFireRating, AltFireRating ); //DM( "GetWeaponRating -- Comparing PriFireRating " $ PriFireRating $ " with AltFireRating " $ AltFireRating ); bUseAltMode = 0; if( AltFireRating > PriFireRating ) { //DM( "using alt fire" ); bUseAltMode = 1; // use alt fire } else if( AltFireRating ~= PriFireRating ) { //DM( "calling SelectFiringMode" ); bUseAltMode = SelectFiringMode( Target ); } // randomize "normal" ratings somewhat (more for lower skill NPCs) if( ReturnedRating >= -1.0 && ReturnedRating <= 1.0 ) { // skill=0.0 --> range of +/- 0.2, skill=1.0 --> range of +/- 0.1 RandomizeRange = (1.0 - Instigator.Controller.GetSkill()) * 0.1 + 0.1; //DMTNS( "RandomizeRange: " $ RandomizeRange ); //DMTNS( "Rating before randomizing: " $ ReturnedRating ); ReturnedRating += ( RandomizeRange - (2 * FRand() * RandomizeRange) ); //DMTNS( "Rating after randomizing: " $ ReturnedRating ); } //#debug DMW( " GetWeaponRating -- ReturnedRating " $ ReturnedRating ); return ReturnedRating; } /*----------------------------------------------------------------------------- NOTE: basically treats alt and primary fire as 2 different weapons, evaluates each then returns the higher rating and sets bUseAltMode accordingly. NOTE: Its possible for this function to be called on a weapon belonging to a (human) player. This happens when an NPC wants to determine the relative strength of a potential target which happens to be a human player. !!mdf-support weapon suggesting firing duration and firing style (e.g. sweep vs aim, aim for head etc.)? */ function float RateSelf( Actor Target, out byte bUseAltMode ) { local float ReturnedRating; local bool bSupportsFire, bSupportsAltFire; local bool bHasEnoughAmmo, bHasEnoughAltAmmo; //#debug DMW( "RateSelf for Owner=" $ Owner $ " Target=" $ Target ); // clear in case caller passed this in set bUseAltMode = 0; // make sure Owner's Controller set if( Instigator.Controller? ) { bHasEnoughAmmo = HasEnoughModeAmmo( GetFireAmmoUsed(), 1 ); bHasEnoughAltAmmo = HasEnoughModeAmmo( GetAltFireAmmoUsed(), 1 ); if( bHasEnoughAmmo || bHasEnoughAltAmmo ) { // has enough ammo to fire the weapon in at least 1 mode bSupportsFire = (bHasEnoughAmmo && bFireEnabledForOwner); bSupportsAltFire = (bHasEnoughAltAmmo && bAltFireEnabledForOwner); if( bSupportsFire || bSupportsAltFire ) { ReturnedRating = GetWeaponRating( Target, bUseAltMode, bSupportsFire, bSupportsAltFire ); } else { //#debug DMW( "weapon fire/altfire disabled!" ); ReturnedRating = RatingDisabled; } } else { //#debug DMW( "not enough fire/altfire ammo!" ); ReturnedRating = RatingNoAmmo; } } else { //#debug DMW( "Controller not set!" ); ReturnedRating = RatingCantFire; } //#debug DMW( " RateSelf -- ReturnedRating " $ ReturnedRating ); return ReturnedRating; } //----------------------------------------------------------------------------- function float SuggestAttackStyleNoEnemy( bool bUseAltMode ) { return U2NPCController.StyleNeutral; } //----------------------------------------------------------------------------- function float SuggestAttackStyleNoRange( bool bUseAltMode ) { // generally back off? return U2NPCController.StyleBackOff; } //----------------------------------------------------------------------------- function float SuggestAttackStyleMode( Actor Target, float RangeMin, float RangeIdeal, float RangeMax, bool bUseAltMode ) { local float DistanceToEnemy; local float ReturnedStyle; DistanceToEnemy = GetWeaponDistanceToEnemy( Target ); if( !Target ) { // no Target ReturnedStyle = SuggestAttackStyleNoEnemy( bUseAltMode ); } else if( RangeMin == -1 || RangeMax == -1 ) { // not affected by range ReturnedStyle = SuggestAttackStyleNoRange( bUseAltMode ); } else if( DistanceToEnemy > RangeMax ) { // > max -- strongly encourage bot to close to ideal range ReturnedStyle = U2NPCController.StyleClose; } else if( DistanceToEnemy > RangeIdeal ) { // in ideal..max -- encourage bot to close in somewhat ReturnedStyle = 0.8*(DistanceToEnemy-RangeIdeal)/(RangeMax-RangeIdeal); } else if( DistanceToEnemy > RangeMin ) { // in Min..ideal -- encourage bot to back off somewhat ReturnedStyle = -0.8*(RangeIdeal-DistanceToEnemy)/RangeIdeal; } else if( DistanceToEnemy < RangeMin ) { // in 0..ideal -- strongly encourage bot to back off ReturnedStyle = U2NPCController.StyleBackOff; } else { // at ideal ReturnedStyle = U2NPCController.StyleNeutral; } //#debug DMW( "SuggestAttackStyleMode: " $ ReturnedStyle ); return ReturnedStyle; } /*----------------------------------------------------------------------------- Tell NPC to close/back off depending on distance to target vs weapon's ideal and max range. !!mdf-tbd: this results in modifying bot's aggression which isn't exactly what we want (even a very aggressive/timid bots should try to use the weapon correctly, no)? Default implementation tries to encourage NPCs to maintain the weapon's ideal distance, subclasses can modify this -- e.g. if alt firing GL run! !!mdf-tbd: for speed, much can be pre-calculated NOTE: AI code multiplies return value by 2. See also SuggestDefenseStyle. Both of these functions are only used to modify the NPC's aggression in the TacticalMove state. !!mdf-tbd: shouldn't weapon also affect bot's style -- e.g. if NPC has a bunch of weapons, should try to get at optimum distance for best one? Might be hard to get this to work well, especially in tight levels. !!mdf-tbd: bUseAltMode is currently always 0. But, I don't think we want to pass in the alt mode since in some (many?) cases RateSelf will be rapidly flipping between suggesting that the NPC use the alt of pri version of the weapon with the result that SuggestAttackStyle could end up returning contradictory values. It seems that the intended mode which will be used is less important than trying to get the NPC into the ideal range for the weapon as a whole (or even, for the best weapon in the NPC's inventory as a whole), no? This should just go off of the Weapon's Fire and AltFire ratings, ideal distances for those ratings and the distance to the target. But, I can also imagine situations in which the weapon needs to tell the NPC how to use it for a specific mode. */ function float SuggestAttackStyle( Actor Target ) { local float ReturnedStyle; local bool bSupportsFire, bSupportsAltFire; /* OLD crapola -- see above comment if( bUseAltMode == 0 ) ReturnedStyle = SuggestAttackStyleMode( Target, RangeMinFire, RangeIdealFire, RangeMaxFire, false ); else ReturnedStyle = SuggestAttackStyleMode( Target, RangeMinFire, RangeIdealAltFire, RangeMaxAltFire, true ); */ // check whether each mode is enabled/has enough ammo if( CanFire() ) { bSupportsFire = ( HasEnoughModeAmmo( GetFireAmmoUsed(), 1 ) && bFireEnabledForOwner ); bSupportsAltFire = ( HasEnoughModeAmmo( GetAltFireAmmoUsed(), 1 ) && bAltFireEnabledForOwner ); if( bSupportsFire && bSupportsAltFire ) { // both supported -- pick the mode with the best rating and try to get the NPC to that mode's ideal distance if( AIRatingFire >= AIRatingAltFire ) ReturnedStyle = SuggestAttackStyleMode( Target, RangeMinFire, RangeIdealFire, RangeMaxFire, false ); else ReturnedStyle = SuggestAttackStyleMode( Target, RangeMinAltFire, RangeIdealAltFire, RangeMaxAltFire, true ); } else if( bSupportsFire ) { // only primary supported ReturnedStyle = SuggestAttackStyleMode( Target, RangeMinFire, RangeIdealFire, RangeMaxFire, false ); } else if( bSupportsAltFire ) { // only alt supported ReturnedStyle = SuggestAttackStyleMode( Target, RangeMinAltFire, RangeIdealAltFire, RangeMaxAltFire, true ); } else { // neither supported -- run away! ReturnedStyle = U2NPCController.StyleRunaway; } } else { // reloading etc. ReturnedStyle = U2NPCController.StyleRunaway; } //#debug DMW( "SuggestAttackStyle: " $ ReturnedStyle ); return ReturnedStyle; } /*----------------------------------------------------------------------------- Used for recommending whether NPC should close or back-off based on current Target's weapon. Note: this isn't the inverse of SuggestAttackStyle. e.g. if an NPC is standing at the perfect distance for an Target with a flamethrower, the Target's weapon is telling him to stay put while the NPC should back off. This is tricky because if both of them have flamethrowers, then the more each backs off, the more the flamethrower will tell them to close. For now I'll try using some -ve value for situation where Target weapon is a weapon that is only effective at close distances. float RangeDefensiveFire float RangeDefensiveAltFire float RatingRangeDefensiveFire float RatingRangeDefensiveAltFire */ function float SuggestDefenseStyle( Actor Target ) { /* !!mdf-tbi: local float ReturnedStyle; local float ReturnedStyleFire; local float ReturnedStyleAltFire; // we don't know which mode the Target will use so assume the worst ReturnedStyleFire = SuggestAttackStyleMode( Other, RangeMinFire, RangeIdealFire, RangeMaxFire, false ); ReturnedStyleAltFire = SuggestAttackStyleMode( Other, RangeMinFire, RangeIdealFire, RangeMaxFire, false ); // !!mdf-tbd: seems to make sense for now: #debug DMW( "SuggestDefenseStyle: " $ ReturnedStyle ); return ReturnedStyle( Other, bUseAltMode ; */ return U2NPCController.StyleNeutral; } //----------------------------------------------------------------------------- // Overridden to implement U2-specific behavior. For example, the engine // version mucks with the weapon's rating so that NPC's will tend to stick // with the same weapon even if that weapon is out of ammo or has been given a // rating which says it is useless in the current situation. It also seems that // the decision to stick with the current weapon shouldn't be made based on // ratings -- NPCs (like players) should occasionally stick with the same // weapon even if a much better one is available (so the way in which this is // implemented in Weapon doesn't make much sense). simulated function Weapon RecommendWeapon( Actor Target, out float Rating, out byte bUseAltMode ) { local Weapon RecommendedWeapon; local Weapon OtherRecommendedWeapon; local float OtherRating; local byte bOtherUseAltMode; bUseAltMode = 0; if( PlayerController(Instigator.Controller)? ) { // player's configuration determines rating Rating = SwitchPriority(); } else { // weapon rates itself Rating = RateSelf( Target, bUseAltMode ); // !!mdf-tbr: // engine code -- if this weapon is current one and the pawn has a target and the weapon has ammo // boost its rating somewhat so it will tend to be kept -- this seems like a bad way to do this /* if( (Self == Instigator.Weapon) && Target != None && ((AmmoType == None) || (AmmoType.AmmoAmount > 0)) ) Rating += 0.21; // tend to stick with same weapon */ } RecommendedWeapon = Self; if( Inventory? ) { // get recommended weapon in rest of inventory chain OtherRecommendedWeapon = Inventory.RecommendWeapon( Target, OtherRating, bOtherUseAltMode ); if( OtherRecommendedWeapon? && OtherRating > Rating ) { // some other weapon rated higher RecommendedWeapon = OtherRecommendedWeapon; Rating = OtherRating; bUseAltMode = bOtherUseAltMode; } } return RecommendedWeapon; } //----------------------------------------------------------------------------- simulated function LicenseePawn.EWeaponAnimationType GetWeaponAnimationType() { return WeaponAnimationType; } // CDH... weapon state notification to pawn // TEMPORARY ARPROACH, this should switch to a general purpose call to the // to the pawn and/or animation controller, and let them deal with the specifics. simulated function PawnAgentEvent(name InEventName) { local vector Dummy; if( InEventName == 'Ambient' && LicenseePawn(Owner)? ) { if (LicenseePawn(Owner).GetAlert() || Owner.IsRealPlayer()) InEventName = 'AmbientAlert'; else if (Instigator != None && Instigator.Controller != None && Instigator.Controller.GetAimingLocation( Dummy )) InEventName = 'Ambient'; else InEventName = 'AmbientLowered'; } if (Pawn(Owner)?) { Pawn(Owner).MeshAgentSetInputCurValue('WeaponState', InEventName); Pawn(Owner).MeshAgentSetInputCurValue('WeaponID', StringToName(ItemID)); } } // ...CDH /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Pickup function Refresh() { local U2NPCController NPC; local int i; NPC = U2NPCController(Instigator.Controller); if( NPC? ) { bFireEnabledForOwner = NPC.SupportsWeaponFire( Self ); bAltFireEnabledForOwner = NPC.SupportsWeaponAltFire( Self ); } else { bFireEnabledForOwner = true; bAltFireEnabledForOwner = true; } //the decos could have retained bad memory, so make sure we reset them for(i=0;i<DecoEffects.length;i++) DestructDeco(i); } function GiveTo( Pawn Other, optional bool bDontTryToSwitch ) { local Controller C; //////////// //!!mdf-tbd: // Idiot check for owner already having the weapon or a super-class of the // weapon -- this totally borks using either weapon? local Inventory Inv; for( Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory ) { if( Inv.IsA( Class.Name ) || ClassIsChildOf( Class, Inv.Class ) ) DMT( "Warning (ASSERT): tried to give " $ Self $ " to " $ Other $ " where " $ Other $ " already has a " $ Inv $ "!" ); } //!!mdf-tbd: /////////// super.GiveTo( Other, bDontTryToSwitch ); U2PCOwner = U2PlayerController(Instigator.Controller); FireAdjust = 1.0; Refresh(); if( Level.Game.bTeamGame || Level.Game.NumBots > 4 ) return; //MWP (mdf) -- probably don't want to do this in singleplayer (NPCs hearing player //pick up stuff makes sense for multiplayer but not for singleplayer and adds overhead). //NOTE: NumBots isn't affected by # NPCs in a level afaik -- a possible approach //which would fix similar code might be to generalize this. // let high skill bots hear pickup if close enough for( C = Level.ControllerList; C?; C = C.NextController ) { if( AIController(C)? && C.Pawn? && VSize( C.Pawn.Location - Pawn(Owner).Location ) < 1000 ) { AIController(C).HearPickup( Pawn(Owner) ); return; } } } function bool HandlePickupQuery( Pickup Item ) { local int OldAmmo, NewAmmo; local Pawn P; local bool bAmmo,bMoreAmmo; if( Item.InventoryType == Class ) { if( WeaponPickup(Item).bWeaponStay && ( !Item.Inventory || Item.Inventory.bTossedOut ) ) { U2Ammo(AmmoType).AddMinAmmo( Weapon(Item.Inventory).PickupAmmoCount ); //NEW return true; } P = Pawn(Owner); if( AmmoType? ) { OldAmmo = AmmoType.AmmoAmount; if( Item.Inventory? ) NewAmmo = Weapon(Item.Inventory).PickupAmmoCount; else NewAmmo = class<Weapon>(Item.InventoryType).default.PickupAmmoCount; bAmmo = AmmoType.AddAmmo( default.PickupAmmoCount ); bMoreAmmo = Item.MaybeAddMoreAmmo(Self,P); if( (bAmmo || bMoreAmmo) && OldAmmo == 0 && P.Weapon.Class != Item.Class ) //ARL && !P.bNeverSwitchOnPickup ) //NEW { ClientWeaponSet( true ); } } Item.AnnouncePickup( Pawn(Owner) ); return true; } if( !Inventory ) return false; return Inventory.HandlePickupQuery(Item); } simulated function ClientWeaponSet(bool bOptionalSet) { Super.ClientWeaponSet(bOptionalSet); U2PCOwner = U2PlayerController(Instigator.Controller); if( U2PCOwner != None ) U2PCOwner.HighlightPendingWeapon( U2PCOwner.Pawn ); } function bool ShouldSwitchWeapon( Weapon CurrentWeapon, bool bOptionalSet ) { local float CurrentSwitchPriority, PendingSwitchPriority; local bool bShouldSwitch; if( Instigator.IsHumanControlled() && U2GameInfo(Level.Game).bForcedWeaponSwitch && U2XMPItem(Self) == None ) { bShouldSwitch = true; } else { PendingSwitchPriority = SwitchPriority(); if( PendingSwitchPriority > RatingIneffective ) { // pending weapon has at least some potential CurrentSwitchPriority = CurrentWeapon.SwitchPriority(); if( PendingSwitchPriority > CurrentSwitchPriority ) { // pending weapon is better than current one if( !bOptionalSet || !AIController(Instigator.Controller) || AIController(Instigator.Controller).AllowPickupWeaponSwitch( Self, CurrentSwitchPriority, PendingSwitchPriority ) ) { bShouldSwitch = true; } } } } return bShouldSwitch; } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Dropping function DropFrom(vector StartLocation) { //note: this function is only called on the server, so thet client doesn't see the unsetting of the crosshair // so the ClearWeaponEffects() is also directly handled by PlayerController's ThrowWeapon, since // there's no easy way to make it work nicely without just pasting code in there ClearWeaponEffects(); PickupAmmoCount = U2Ammo(AmmoType).ClipRoundsRemaining; AmmoType.AmmoAmount -= U2Ammo(AmmoType).ClipRoundsRemaining; U2PCOwner = None; Super.DropFrom(StartLocation); } /* simulated event Landed( vector HitNormal ) { local rotator newRot; newRot = Rotation; newRot.Pitch = 16384; SetRotation( newRot ); } */ simulated function SwitchAway() { Instigator.Controller.SwitchToBestWeapon(); } function GiveAmmo( Pawn Other ) { Super.GiveAmmo(Other); if (U2Ammo(AmmoType)?) U2Ammo(AmmoType).Reload(); } simulated function int GetClipAmount() { if( U2Ammo(AmmoType)? ) return U2Ammo(AmmoType).ClipRoundsRemaining; else return 0; } simulated function int GetClipSize() { if( U2Ammo(AmmoType)? ) return U2Ammo(AmmoType).ClipSize; else return 0; } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Reloading //this is called to reload the gun, and can be called at any point in time //it will correctly deal with reloading from the loaded and unloaded states simulated function Reload() { //mjl-tbd: ensure reloading works on third-person clients, so the sound can be heard if ( !IsInState('Reloading') && HasAmmo() && U2Ammo(AmmoType).CanReload() ) { //Pawn(Owner).Controller.StopFiring(); //Pawn(Owner).PlaySound( CockingSound, SLOT_Misc ); if (!U2Ammo(AmmoType).ReloadRequired(1)) //if we are not completely out of ammo, then drop our current clip { //OutOfAmmo } //go to the state for the duration of the reload GotoState('Reloading'); } } simulated state Reloading { ignores Fire,AltFire,Reload; function bool CanFire() { return false; } simulated event BeginState() { } simulated event EndState() { } Begin: if( U2PCOwner? ) class'UIConsole'.static.SendEvent("WeaponFlash"); PawnAgentEvent('Reload'); if( !bLastRound ) PlayAnimEx('Reload'); else { PlayAnimEx('ReloadUnloaded'); if( default.ReloadUnloadedTime!=0.0 ) ReloadTime=default.ReloadUnloadedTime; } Sleep(ReloadTime); ReloadTime=default.ReloadTime; bLastRound=false; U2Ammo(AmmoType).Reload(); GotoState('Idle'); } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Fire/AltFire simulated function NotifyPlaySoundSlot( string Slot ) { switch(Slot) { case "Fire": if(!bAmbientFireSound) Pawn(Owner).PlaySound(FireSound,SLOT_Weapon,,,,GetRand(FirePitch)); return; case "AltFire": if(!bAmbientAltFireSound) Pawn(Owner).PlaySound(AltFireSound,SLOT_Weapon,,,,GetRand(AltFirePitch)); return; case "FireEnd": if(FireEndSound?) Pawn(Owner).PlaySound(FireEndSound,SLOT_Weapon,,,,GetRand(FirePitch)); return; case "AltFireEnd": if(AltFireEndSound?) Pawn(Owner).PlaySound(AltFireEndSound,SLOT_Weapon,,,,GetRand(AltFirePitch)); return; case "FireLastRound": if(FireLastRoundSound?) Pawn(Owner).PlaySound(FireLastRoundSound,SLOT_Weapon,,,,GetRand(FirePitch)); return; case "AltFireLastRound": if(AltFireLastRoundSound?) Pawn(Owner).PlaySound(AltFireLastRoundSound,SLOT_Weapon,,,,GetRand(AltFirePitch));return; case "ReloadUnloaded": if(ReloadUnloadedSound?) Pawn(Owner).PlaySound(ReloadUnloadedSound,SLOT_Weapon,,,128); return; case "Reload": Pawn(Owner).PlaySound(CockingSound,SLOT_Weapon,,,128); return; // case "Select": PlaySound(SelectSound); return; }; } simulated function PlayFiring() { bLastRound = U2Ammo(AmmoType)? && U2Ammo(AmmoType).ReloadRequired(1); if( !bLastRound ) { PlayAnimEx('Fire'); FireTime = default.FireTime; } else if( HasAmmo() ) { PlayAnimEx('FireLastReload'); FireTime = default.FireTime; ReloadTime = default.FireLastReloadTime - default.FireTime; } else { PlayAnimEx('FireLastDown'); FireTime = default.FireLastDownTime - default.DownTime; } PawnAgentEvent('Fire'); } simulated function PlayAltFiring() { bLastRound = U2Ammo(AmmoType)? && U2Ammo(AmmoType).ReloadRequired(1); if( !bLastRound ) { PlayAnimEx('AltFire'); AltFireTime = default.AltFireTime; } else if( HasAmmo() ) { PlayAnimEx('AltFireLastReload'); AltFireTime = default.AltFireTime; ReloadTime = default.AltFireLastReloadTime - default.AltFireTime; } else { PlayAnimEx('AltFireLastDown'); AltFireTime = default.AltFireLastDownTime - default.DownTime; } PawnAgentEvent('AltFire'); } simulated state Firing { ignores Fire, AltFire; simulated function Reload(){} simulated event BeginState() { if (bAmbientFireSound) //if we are a rapid-fire weapon, then make our FireSound be the ambient sound AmbientSound = FireSound; } simulated event EndState() { bFiring = false; if (bAmbientFireSound) AmbientSound = default.AmbientSound; } Begin: //incoming animation set by EverywhereFire(). We wait for it to finish Sleep(FireTime); if (bRepeatFire) { if ( Pawn(Owner).PressingFire() ) { Global.Fire(); //if it's going to fire, code execution will jump to the Begin label //if it's going to reload/changeweapon, code execution will jump to some other state //assert(false); //whoops, apparently this assumption is invalid!! } //else, if we're done firing, and want to stop (which may be the case even if we're still holding fire -- like if you ran out of ammo) //maybe wind-down our weapon... PlayAnimEx('FireEnd'); } if( U2Ammo(AmmoType)? && U2Ammo(AmmoType).ReloadRequired( GetFireAmmoUsed() ) ) { if( HasAmmo() ) Global.Reload(); // Global since Reload is locally disabled. else if( HasAnyAmmo() ) ChangeAmmoType(); else SwitchAway(); } GotoState('Idle'); } simulated state AltFiring { ignores Fire, AltFire; simulated function Reload(){} simulated event BeginState() { if (bAmbientAltFireSound) //if we are a rapid-fire weapon, then make our AltFireSound be the ambient sound AmbientSound = AltFireSound; } simulated event EndState() { bAltFiring = false; if (bAmbientAltFireSound) AmbientSound = default.AmbientSound; } Begin: //incoming animation set by EverywhereAltFire(). We wait for it to finish Sleep(AltFireTime); if (bRepeatAltFire) { if ( Pawn(Owner).PressingAltFire() ) { Global.AltFire(); //if it's going to fire, code execution will jump to the Begin label //if it's going to reload/changeweapon, code execution will jump to some other state //assert(false); //whoops, apparently this assumption is invalid!! } //else, if we're done firing, and want to stop (which may be the case even if we're still holding fire -- like if you ran out of ammo) //maybe wind-down our weapon... PlayAnimEx('AltFireEnd'); } if( U2Ammo(AmmoType)? && U2Ammo(AmmoType).ReloadRequired( GetAltFireAmmoUsed() ) ) { if( HasAmmo() ) Global.Reload(); // Global since Reload is locally disabled. else if( HasAnyAmmo() ) ChangeAmmoType(); else SwitchAway(); } GotoState('Idle'); } simulated function Fire() { //ensures that we can control who can fire and who cannot, based upon the function. bPlayerCanFire is now useful. :) if( !Pawn(Owner).PressingFire() ) return; if( bDisableFiring ) return; bFiring = true; bAltFiring = false; if( U2Ammo(AmmoType)? && !U2Ammo(AmmoType).ReloadRequired( GetFireAmmoUsed() ) ) { // firing of the weapon can be aborted by the aiming code (e.g. due to obstacles) if( PreSetAimingParameters( false, bInstantHit, TraceSpreadFire, ProjectileClass, bWarnTarget, bRecommendSplashDamage ) ) { if (Role == ROLE_Authority) AuthorityFire(); EverywhereFire(); } } else if ( HasAmmo() ) Reload(); else if( HasAnyAmmo() ) ChangeAmmoType(); else SwitchAway(); } simulated function AltFire() { //ensures that we can control who can fire and who cannot, based upon the function. bCanAltFire is now useful. :) if( !Pawn(Owner).PressingAltFire() ) return; if( bDisableFiring ) return; bFiring = false; bAltFiring = true; if( U2Ammo(AmmoType)? && !U2Ammo(AmmoType).ReloadRequired( GetAltFireAmmoUsed() ) ) { // firing of the weapon can be aborted by the aiming code (e.g. due to obstacles) if( PreSetAimingParameters( true, bAltInstantHit, TraceSpreadAltFire, AltProjectileClass, bAltWarnTarget, bRecommendAltSplashDamage ) ) { if (Role == ROLE_Authority) AuthorityAltFire(); EverywhereAltFire(); } } else if ( HasAmmo() ) Reload(); else if( HasAnyAmmo() ) ChangeAmmoType(); else SwitchAway(); } function AuthorityFire() { if( !IsInState('Firing') ) U2Pawn(Owner).CurrentStatus.NumFires = (U2Pawn(Owner).CurrentStatus.NumFires+1) % 4; //guaranteed by ReloadRequired in Fire //NOTE (mdf): AmmoType can be None for some weapons (e.g. Takkra)? if( AmmoType? ) AmmoType.UseAmmo( GetFireAmmoUsed() ); bPointing = true; /* SERVOTBD if( bRapidFire || FiringSpeed > 0 ) Pawn(Owner).PlayRecoil( FiringSpeed ); */ // does nothing for most weapons unless shot fired when owner stops firing PostSetAimingParameters( false, bInstantHit, TraceSpreadFire, ProjectileClass, bWarnTarget, bRecommendSplashDamage ); if( bInstantHit ) { TraceFire( TraceSpreadFire ); } else if( ProjectileClass? ) { ProjectileFire( ProjectileClass ); } } function AuthorityAltFire() { if( !IsInState('AltFiring') ) U2Pawn(Owner).CurrentStatus.NumAltFires = (U2Pawn(Owner).CurrentStatus.NumAltFires+1) % 4; //guaranteed by ReloadRequired in Fire //NOTE (mdf): AmmoType can be None for some weapons (e.g. Takkra)? if( AmmoType? ) AmmoType.UseAmmo( GetAltFireAmmoUsed() ); bPointing = true; /* SERVOTBD if( bRapidAltFire || FiringSpeed > 0 ) Pawn(Owner).PlayRecoil( FiringSpeed ); */ // does nothing for most weapons unless shot fired when owner stops firing PostSetAimingParameters( true, bAltInstantHit, TraceSpreadAltFire, AltProjectileClass, bAltWarnTarget, bRecommendAltSplashDamage ); if( bAltInstantHit ) { TraceFire( TraceSpreadAltFire ); } else if( AltProjectileClass? ) { ProjectileFire( AltProjectileClass ); } } simulated function EverywhereFire() { local PlayerController P; GotoState( 'Firing' ); if( Level.NetMode != NM_DedicatedServer ) { SetFireSkin(); if( ShellClass? ) EjectShell( ShellClass ); if( Pawn(Owner)? ) P = PlayerController(Pawn(Owner).Controller); if( P? ) { if( InstFlash != 0.0 ) P.ClientInstantFlash( InstFlash, InstFog ); if( ShakeMag>0 && ShakeTime>0 ) P.ShakeView( ShakeMag, ShakeTime ); } } if( Affector? ) Affector.FireEffect(); PlayFiring(); } simulated function EverywhereAltFire() { local PlayerController P; GotoState( 'AltFiring' ); if( Level.NetMode != NM_DedicatedServer ) { SetFireSkin(); if( AltShellClass? ) EjectShell( AltShellClass ); if ( Pawn(Owner)? ) P = PlayerController(Pawn(Owner).Controller); if( P? ) { if( InstFlash != 0.0 ) P.ClientInstantFlash( InstFlash, InstFog ); if( ShakeMag>0 && ShakeTime>0 ) P.ShakeView( AltShakeMag, AltShakeTime ); } } if( Affector? ) Affector.FireEffect(); PlayAltFiring(); } simulated function int GetFireAmmoUsed() { return 1; } simulated function int GetAltFireAmmoUsed() { return 1; } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Actual Projectile/Trace Fires simulated function vector CalcDrawOffset() { local vector WeaponKickOffset; //ARL collapse WeaponKickOffset into U2Pawn.CalcDrawOffset if( U2PlayerController(Pawn(Owner).Controller)? ) { WeaponKickOffset = U2PlayerController(Pawn(Owner).Controller).WeaponKickOffset; } return Pawn(Owner).CalcDrawOffset( Self ) + WeaponKickOffset; } simulated function vector CalcFireOffset( vector X, vector Y, vector Z ) { local vector DrawOffset; DrawOffset.Z = Pawn(Owner).BaseEyeHeight; return DrawOffset + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; } simulated function vector CalcShellOffset( vector X, vector Y, vector Z ) { local vector DrawOffset; DrawOffset.Z = Pawn(Owner).BaseEyeHeight; return DrawOffset + ShellOffset.X * X + ShellOffset.Y * Y + ShellOffset.Z * Z; } simulated function EjectShell( class<U2ShellCase> ShellClass ) { local vector X, Y, Z; local U2ShellCase S; GetAxes( Pawn(Owner).GetViewRotation(), X, Y, Z ); S = Spawn( ShellClass, Pawn(Owner), '', Pawn(Owner).Location + CalcShellOffset( X, Y, Z ) ); if( S? ) { S.Eject( ( (FRand()*0.1+0.2)*X + (FRand()*0.2+0.4)*Y + (FRand()*0.2+0.4) * Z ) * 160 ); } } function MeleeAttack() { TraceFire( 0.0 ); } function AdjustTraceFireHit( out CheckResult Hit ); // allow subclasses to modify TraceFire() //----------------------------------------------------------------------------- // Sets Trace/ProjectileFireStartLocations for next shot. NOTE: sets both since // some weapons (e.g. LR) do both a trace and projectile fire. function SetFireStartLocations() { local bool bFirstPerson; bFirstPerson = ( U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson() ); // trace from weapon's fireoffset (relative to Pawn) for projectile weapons if( bFirstPerson ) { // Fix ARL: Adjust for weapon bone attachments!! // trace from eyes for hitscan weapons (for players in 1st person only?) TraceFireStartLocation = Pawn(Owner).Location; TraceFireStartLocation.Z += Pawn(Owner).BaseEyeHeight; ProjectileFireStartLocation = class'UtilGame'.static.GetRotatedFireStart( Pawn(Owner), Owner.Location, Pawn(Owner).GetViewRotation(), FireOffset + FirstPersonOffset ); } else { ProjectileFireStartLocation = class'UtilGame'.static.GetRotatedFireStart( Pawn(Owner), Owner.Location, Pawn(Owner).GetViewRotation(), FireOffset ); TraceFireStartLocation = ProjectileFireStartLocation; } } function TraceFire( float TraceSpread ) { local vector End, SpreadVector; local CheckResult Hit; local Material.CheckResult MaterialHit; local float TraceDamage; Pawn(Owner).MakeNoise( Pawn(Owner).SoundDampening ); AdjustedAim = Pawn(Owner).GetAimRotation(); SpreadVector = vector(AdjustedAim + rotator(class'Util'.static.RandomSpreadVector( TraceSpread ))); End = TraceFireStartLocation + TraceRange * SpreadVector; SingleLineCheck( Hit, Pawn(Owner), End, TraceFireStartLocation, TRACE_ProjTargets ); //ARL don't use TRACE_AllEverything, or triggers will be hit MaterialHit.Next = Hit.Next; MaterialHit.Actor = Hit.Actor; MaterialHit.Location = Hit.Location; MaterialHit.Normal = Hit.Normal; MaterialHit.Primitive = Hit.Primitive; MaterialHit.Time = Hit.Time; MaterialHit.Item = Hit.Item; MaterialHit.Material = Hit.Material; DispatchWeaponNotifies( Hit ); /* if( Owner.IsRealPlayer() ) AddArrow( TraceFireStartLocation, End, ColorBlue() ); else AddArrow( TraceFireStartLocation, End, ColorGreen() ); */ // Fix ARL: FindWaterSurface no longer exists. Improve water-hit handling -- replace with TRACE_Zone in SingleLineCheck()? /* FindWaterSurface( SurfaceLocation, TraceFireStartLocation + ( 32 * vector( AdjustedAim ) ), HitLocation ); if( Pawn(Owner).PhysicsVolume.bWaterVolume ) { HandleWaterShot( HitLocation, TraceFireStartLocation, SurfaceLocation ); } if( SurfaceLocation != vect(0,0,0) ) { Spawn( class'U2Splash',,, SurfaceLocation, -1 * rotator( HitLocation - TraceFireStartLocation ) ); HandleWaterShot( HitLocation, SurfaceLocation, HitLocation ); if( ( Level.TimeSeconds - LastWaterRingTime ) > 0.35 ) { Ring = Spawn( class'U2WaterRing', , , SurfaceLocation, rot(16384,0,0) ); Ring.SetDrawScale(0.25); LastWaterRingTime = Level.TimeSeconds; } } */ if( Hit.Actor? ) { assert( Role == ROLE_Authority ); if( bFiring ) TraceDamage = Damage; else if( bAltFiring ) TraceDamage = AltDamage; else warn("TraceFire called without bFiring or bAltFiring set!"); ProcessTraceHitEx( SpreadVector, Hit, TraceDamage ); //NEW if( ImpactHandlerClass? ) //!!ARL (mdf) causing warnings for LR primary fire? ImpactHandlerClass.static.TraceImpact( self, MaterialHit ); //HACK: FCheckResult apparently doesn't "replicate" properly... even in StandAlone mode. WTF?!? ClientTraceImpact( Hit ); /*OLD: ClientTraceImpact will need to be updated to properly account for new Hit.Material var, etc. ClientTraceImpact( Hit.Location + Hit.Normal, rotator(Hit.Normal), class'Material'.static.GetHitTextureType( MaterialHit ) ); //DM( Self$".ClientTraceImpact() SERVER "$Self@vector(Pawn(Owner).ViewRotation)@Hit.Actor@Hit.Item@Hit.Location+Hit.Normal@Hit.Normal ); */ } else TraceFireFailed( End ); } function TraceFireFailed( vector EndPoint ); function DispatchWeaponNotifies( out CheckResult Hit ) { local array<Actor> NotifyProjectiles; local int i; NotifyProjectiles = Level.GetList('TraceFireNotify'); for(i=0;i<NotifyProjectiles.length;i++) U2Projectile(NotifyProjectiles[i]).AdjustTraceFireHit(Hit); } function ProcessTraceHitEx( vector HitDirection, CheckResult Hit, float EffectiveDamage ) { Hit.Actor.TakeDamage( EffectiveDamage, Pawn(Owner), Hit.Location, MomentumTransfer * HitDirection, MyDamageType ); } //mjl-tbd: optimize this function ... pass the impacteffect class directly instead of ints and vectors and rotators? //NEW simulated function ClientTraceImpact( CheckResult Hit ) { //ImpactHandlerClass.static.TraceImpact( self, Hit ); } /*OLD simulated function ClientTraceImpact( vector HitLocation, rotator HitNormal, Material.ETextureType MaterialType ) { local CheckResult Hit; Hit.Location = HitLocation; Hit.Normal = vector(HitNormal); //DM( Self$".ClientTraceImpact() CLIENT "$Self@vector(Pawn(Owner).GetViewRotation())@Hit.Actor@Hit.Item@Hit.Location@Hit.Normal ); ImpactHandlerClass.static.TraceImpact( self, Hit, MaterialType ); } */ function Projectile ProjectileFire( class<projectile> ProjClass ) { local Projectile SpawnedProjectile; Pawn(Owner).MakeNoise( Pawn(Owner).SoundDampening ); AdjustedAim = Pawn(Owner).GetAimRotation(); SpawnedProjectile = Spawn( ProjClass, Self, , ProjectileFireStartLocation, AdjustedAim ); // NOTE (mdf): can fail, e.g. if Pawn too close to geometry return SpawnedProjectile; /* debug stuff local Projectile SpawnedProjectile; DM( "ProjectileFire: " $ Pawn(Owner) ); DM( " GetViewRotation: " $ Pawn(Owner).GetViewRotation().Yaw $ " " $ Pawn(Owner).GetViewRotation().Pitch $ " " $ Pawn(Owner).GetViewRotation().Roll ); SpawnedProjectile = Spawn( ProjClass, Self,, ProjectileFireStartLocation, AdjustedAim ); AddArrow( Owner.Location, Owner.Location + 128.0*vector(Pawn(Owner).GetViewRotation()), ColorMagenta() ); AddActor( Owner, ColorCyan() ); AddArrow( Owner.Location, ProjectileFireStartLocation, ColorRed() ); AddArrow( ProjectileFireStartLocation, ProjectileFireStartLocation + vector(AdjustedAim)*128.0, ColorGreen() ); // bots were aiming into the ground because of borked EyeHeight if( SpawnedProjectile == None ) { DMTNS( "ProjectileFire failed to spawn a " $ ProjClass $ " at " $ ProjectileFireStartLocation $ " rotation: " $ AdjustedAim ); } return SpawnedProjectile; */ } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Idle simulated state Idle // override Weapon.Idle.Begin { simulated event AnimEnd( int Channel ) { } simulated function bool PutDown() { if (Global.PutDown()) { GotoState('DownWeapon'); return true; } return false; } Begin: if( Pawn(Owner)? ) { PawnAgentEvent('Ambient'); if (Pawn(Owner).PressingFire() && bRepeatFire) Fire(); else if (Pawn(Owner).PressingAltFire() && bRepeatAltFire) AltFire(); else if ( bChangeWeapon ) GotoState('DownWeapon'); } bPointing = false; } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Select/PutDown simulated function float SwitchPriority() { local byte bTempUseAltMode; local float Priority; if( !Pawn(Owner).IsHumanControlled() && Pawn(Owner).Health > 0 ) { Priority = RateSelf( Instigator.Controller.ControllerEnemy, bTempUseAltMode ); } else if ( !HasAnyAmmo() ) { if( Pawn(Owner).Weapon == self ) Priority = -0.5; else Priority = -1; } else { Priority = AutoSwitchPriority; } return Priority; } // // Change weapon to that specificed by F matching inventory weapon's Inventory Group. simulated function Weapon WeaponChange( byte F, Weapon aChoice ) { local U2Weapon CurrentChoice; local U2Weapon CurrentWeapon; CurrentChoice = U2Weapon(aChoice); CurrentWeapon = U2Weapon(Pawn(Owner).PendingWeapon); // allow fast cycling if( CurrentWeapon == None ) CurrentWeapon = U2Weapon(Pawn(Owner).Weapon); if ( HasAnyAmmo() || SnipingWeapon() ) { if( InventoryGroup == F ) { // no current choice, we're the best so far. if( !CurrentChoice && Self != CurrentWeapon ) CurrentChoice = Self; // if current weapon isn't in this group, pick one with lowest position in group else if( !CurrentWeapon || CurrentWeapon.InventoryGroup != F ) { if( /*Self.*/LessThan(CurrentChoice)) CurrentChoice = Self; } // current weapon is in current group, pick next weapon after it else if ( !CurrentChoice || CurrentChoice.LessThan(CurrentWeapon) ) { if ( /*Self.*/LessThan(CurrentChoice) || // Self Choice Weapon /*Self.*/GreaterThan(CurrentWeapon) ) // Choice Weapon Self CurrentChoice = Self; } else if ( CurrentWeapon.LessThan(Self) && // Weapon Self Choice /*Self.*/LessThan(CurrentChoice) ) CurrentChoice = Self; } } if( Inventory? ) return Inventory.WeaponChange( F, CurrentChoice ); else return CurrentChoice; } // Compare our group and position within the group to another weapon simulated function bool LessThan( Weapon Other ) { if( Other == None ) //!!ARL (mdf) this is happening when switching from DP to an XMP item for example return false; if( InventoryGroup < Other.InventoryGroup ) return true; else if( InventoryGroup == Other.InventoryGroup ) { if( GroupOffset < Other.GroupOffset ) return true; // weapons with same tray/priority sort alphabetically // tbd - might not be the same as comparing their strings but should be consistent else if( GroupOffset == Other.GroupOffset ) if( ItemName < Other.ItemName ) return true; } return false; } simulated function bool GreaterThan( Weapon Other ) { if ( InventoryGroup > Other.InventoryGroup ) return true; else if ( InventoryGroup == Other.InventoryGroup ) { if( GroupOffset > Other.GroupOffset ) return true; // weapons with same tray/priority sort alphabetically // tbd - might not be the same as comparing their strings but should be consistent else if( GroupOffset == Other.GroupOffset ) if( ItemName > Other.ItemName ) return true; } return false; } // Find the previous weapon (using the Inventory group and the position within the group (GroupOffset) simulated function Weapon PrevWeapon(Weapon aChoice, Weapon aWeapon) { local U2Weapon CurrentChoice; local U2Weapon CurrentWeapon; CurrentChoice = U2Weapon(aChoice); CurrentWeapon = U2Weapon(aWeapon); if ( HasAnyAmmo() || SnipingWeapon() ) { if ( !CurrentChoice ) { if ( CurrentWeapon != self ) CurrentChoice = self; } else if ( /*Self.*/LessThan(CurrentWeapon) ) { if ( CurrentChoice.LessThan(Self) || // Choice Self Weapon CurrentChoice.GreaterThan(CurrentWeapon) ) // Self Weapon Choice CurrentChoice = self; } else if ( CurrentWeapon.LessThan(CurrentChoice) && // Weapon Choice Self CurrentChoice.LessThan(Self) ) CurrentChoice = self; } if ( !Inventory ) return CurrentChoice; else return Inventory.PrevWeapon(CurrentChoice,CurrentWeapon); } // Find the next weapon (using the Inventory group and the position within the group (GroupOffset) simulated function Weapon NextWeapon(Weapon aChoice, Weapon aWeapon) { local U2Weapon CurrentChoice; local U2Weapon CurrentWeapon; CurrentChoice = U2Weapon(aChoice); CurrentWeapon = U2Weapon(aWeapon); if ( HasAnyAmmo() || SnipingWeapon() ) { if ( !CurrentChoice ) { if ( CurrentWeapon != self ) CurrentChoice = self; } else if ( CurrentChoice.LessThan(CurrentWeapon) ) { if ( /*Self.*/LessThan(CurrentChoice) || // Self Choice Weapon /*Self.*/GreaterThan(CurrentWeapon) ) // Choice Weapon Self CurrentChoice = self; } else if ( CurrentWeapon.LessThan(Self) && // Weapon Self Choice /*Self.*/LessThan(CurrentChoice) ) CurrentChoice = self; } if ( !Inventory ) return CurrentChoice; else return Inventory.NextWeapon(CurrentChoice,CurrentWeapon); } simulated state DownWeapon { ignores Fire, AltFire; function bool CanFire() { return false; } simulated function bool PutDown() { return true; } //just keep putting it down simulated event BeginState() { bChangeWeapon = false; ClearWeaponEffects(); U2PCOwner = U2PlayerController(Instigator.Controller); } simulated event EndState() {} simulated event AnimEnd( int Channel ) {} Begin: PawnAgentEvent('Deactivate'); if( !bLastRound ) PlayAnimEx('DownAnim'); MeshAgentSetInputCurValueEx('Active','False'); Sleep(DownTime); Pawn(Owner).ChangedWeapon(); GotoState(''); } //to get rid of the cruft from the Active state... simulated state Active { ignores Fire, AltFire; simulated function bool PutDown() { if ( bWeaponUp || (AnimFrame < 0.75) ) GotoState('DownWeapon'); else bChangeWeapon = true; return True; } simulated event AnimEnd( int Channel ) { } simulated event EndState() { } simulated event BeginState() { } Begin: MaybePixieReload(); Sleep(SelectTime); if( bChangeWeapon ) GotoState('DownWeapon'); bWeaponUp = true; // this should never happen since you cannot select weapons with no ammo, and if you had ammo, then it got pixie loaded. // (but... the sniper rifle can be selected without ammo, and you might pick up ammo while bringing it up -- in which case we might as well auto-reload still) if( HasAmmo() && U2Ammo(AmmoType)? && U2Ammo(AmmoType).ReloadRequired( GetFireAmmoUsed() ) && U2Ammo(AmmoType).ReloadRequired( GetAltFireAmmoUsed() )) Reload(); //if none of the above checks worked, then go idle GotoState('Idle'); } // We no longer have Unloaded anim support, so just magically reload weapons on selection if you picked up some since you ran out. function MaybePixieReload() { if( HasAmmo() && U2Ammo(AmmoType)? && U2Ammo(AmmoType).ReloadRequired(GetFireAmmoUsed()) && U2Ammo(AmmoType).ReloadRequired(GetAltFireAmmoUsed()) ) U2Ammo(AmmoType).Reload(); } simulated function PlaySelect() { bForceFire = false; bForceAltFire = false; PawnAgentEvent('Activate'); PlayAnimEx('SelectAnim'); MeshAgentSetInputCurValueEx('Active','True'); //DMT( Owner @ Pawn(Owner).Controller @ self @ "WEAPON SELECT SOUND" ); if( Pawn(Owner).IsHumanControlled() ) Owner.PlayOwnedSound( SelectSound, SLOT_Misc, 1.0 ); } simulated function PlayPostSelect() {} /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Special Effects function HandleWaterShot( vector HitLocation, vector Start, vector End ) { /*!!arl -- Mike's BubbleSpawner lacks the "Start" property that Jess's U2BubbleSpawner had... replace both with a ParticleGenerator? local BubbleSpawner BubbleTrailer; BubbleTrailer = Spawn( class'BubbleSpawner', , , Start, rotator( HitLocation - Start ) ); BubbleTrailer.Start = Start; BubbleTrailer.End = End; BubbleTrailer.Bubbles(); */ } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Decorative Effects simulated event PostBeginPlay() { FirstPersonMesh = Mesh; Super.PostBeginPlay(); } simulated event Destroyed() { local int i; for (i=0;i<DecoEffects.Length;i++) DestructDeco( i ); ClearWeaponEffects(); // if( ImpactHandlerClass != None ) // ImpactHandlerClass.static.Cleanup( self ); Super.Destroyed(); } simulated function DestructDeco( int i ) { local ParticleGenerator P; if( !DecoEffects[i].Effect ) return; P = ParticleGenerator(DecoEffects[i].Effect); if (P?) { P.bManualTick = false; P.ParticleDestroy(); } else if (DecoEffects[i].Effect?) DecoEffects[i].Effect.Destroy(); DecoEffects[i].Effect = None; } simulated function ConstructDeco( int i ) { local ParticleGenerator P; //local mesh FirstPersonMesh; if( Level.NetMode == NM_DedicatedServer && !DecoEffects[i].GameplayRelevant ) return; /* if (MeshGetNodeNamed(DecoEffects[i].MountNode)==0) warn("Firstperson attachment node not found! : "$Mesh$"."$DecoEffects[i].MountNode); FirstPersonMesh = Mesh; Mesh = ThirdPersonMesh; if (MeshGetNodeNamed(DecoEffects[i].MountNode)==0) warn("Thirdperson attachment node not found! : "$Mesh$"."$DecoEffects[i].MountNode); Mesh = FirstPersonMesh; */ if (DecoEffects[i].Particles?) { P = class'ParticleGenerator'.static.CreateNew( self, DecoEffects[i].Particles ); DecoEffects[i].Effect = P; P.bManualTick = true; //mjl-tbd: handle double-particle-systems if we decide it's needed... } else { DecoEffects[i].Effect = Spawn( DecoEffects[i].DecoClass ); } if (DecoEffects[i].Effect?) { // DecoEffects[i].Effect.MountParentActor = self; DecoEffects[i].Effect.MountParentTag = Tag; DecoEffects[i].Effect.MountParentNode = DecoEffects[i].MountNode; DecoEffects[i].Effect.MountOrgLocation = DecoEffects[i].MountOffset; DecoEffects[i].Effect.MountOrgRotation = DecoEffects[i].MountRot; DecoEffects[i].Effect.MountOldLocation = DecoEffects[i].Effect.Location; DecoEffects[i].Effect.MountOldRotation = DecoEffects[i].Effect.Rotation; DecoEffects[i].Effect.Instigator = Pawn(Owner); DecoEffects[i].Effect.bRenderLater = true; DecoEffects[i].Effect.bRequiresWorldZBuffer = DecoEffects[i].bRequiresWorldZBuffer; } } // Fix ARL: Also call UnTrigger when finished to support TriggerControl effects. simulated function PlayAnimEx( name Sequence ) { local int i; LastTriggeredAnim = Sequence; switch(LastTriggeredAnim) { case 'FireLastDown': LastTriggeredAnim='Fire'; break; case 'FireLastReload': LastTriggeredAnim='Fire'; break; case 'AltFireLastDown': LastTriggeredAnim='AltFire'; break; case 'AltFireLastReload': LastTriggeredAnim='AltFire'; break; } for (i=0;i<DecoEffects.Length;i++) if (DecoEffects[i].AnimSequence==LastTriggeredAnim) { if( !DecoEffects[i].Effect ) ConstructDeco(i); if( DecoEffects[i].Effect? ) DecoEffects[i].Effect.Trigger( self, Instigator ); } //DMN("MeshAgentCallAction:"@Sequence@MeshAgentCallAction(Sequence)); MeshAgentCallActionEx(Sequence); } simulated function MeshAgentCallActionEx( name Sequence ) { local mesh OldMesh; local bool bFirstPerson; bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); OldMesh = Mesh; if (!bFirstPerson) Mesh = ThirdPersonMesh; MeshAgentCallAction(Sequence); Mesh = OldMesh; } simulated function MeshAgentSetInputCurValueEx( name Input, name Value ) { local mesh OldMesh; local bool bFirstPerson; if( !Mesh ) return; bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); OldMesh = Mesh; if (!bFirstPerson) Mesh = ThirdPersonMesh; MeshAgentSetInputCurValue(Input,Value); Mesh = OldMesh; } //make our skin show the flash of the shot simulated function SetFireSkin() { local bool bFirstPerson; if( FlashSkin? ) { bFirstPerson = true; if( FlashSkinTP? ) bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); if( bFirstPerson ) MeshSetStaticMeshAttachmentSkinsAll(FlashSkin); else MeshSetStaticMeshAttachmentSkinsAll(FlashSkinTP); } // AmbientGlow = 40; //does not look good on flamethrower: make this a per weapon variable? FireSkinTime = Level.TimeSeconds; } //note: this is copied into the native code instead of called for performance reasons (see AU2Weapon.cpp) simulated function UnsetFireSkin() { if( FlashSkin? ) MeshSetStaticMeshAttachmentSkinsAll(None); // AmbientGlow = 0; } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //DecoEffects /* mjl-tbd: implement newer, better system for weapons drawing, as described below... dependant upon the new renderer, so this is not currently possible as bad as it sounds, this has been thoroughly discussed, so there are probably going to be 'issues' with any simpler implementation issues: particlesystems always need to be ticked particlesystems need to be ticked in the correct place, if their weapon is renderered (1st or 3rd) therefore, particlesystem ticks need to be done after render doing it in the old SpecialDraw was not good, since then it required SpecialDraw to be called. and we had to make up for it with tick ticking, which got ugly very very quickly, due to the off-by-one errors Tick Render allactors allactors portalfilter renderactors trigger() ^ AL BL AL BL AR WR BT BR \---------------------------------/ \==/ | | foreach B list tick() if ShouldRender render() When ticking in the B list, it should use DeltaTime, so DeltaTime needs to be stored in the LevelInfo for global access All B actors (particlesystems) are ticked each tick, using either the accurate render location, or the semi-accurate calculated location All DecoEffects are put into the B list, render order hopefully doesn't matter for them Weapon rendering could be moved to the very front of the list, necessary such that the z-buffer is not cleared before the B-list is rendered, which needs occlusion Two possibilities: Weapon Rendering, Idea One: Turn off Z-reads Turn on Z-writes Each DecoEffect defines it's own Z-properties, since muzzle flashes should always be drawn and flame effects should not Weapon Rendering, Idea Two: Move it to the PreRender Clear the Z-buffer Turn on the stencil buffer Turn on Z-writes and reads, since there it is not rendering sorted polygons Use the stencil to write '0' into the Z-buffer Now nothing can be drawn over the weapon So BSP walls, etc will be drawn underneath, as intended Each DecoEffect can optionally choose to do Z[stencil?]-reads or not useful for effects which need to be drawn over the weapon Since I don't understand Idea One anymore, I'm going to suggest Idea Two. :) */ /* == NEW APPROACH = 01.09.2002 == make a bRequiresWorldZBuffer should this all move to native code? //UpdateWeaponPosition Timer * Sometimes tick A-List weapons. //mjl-tbd: //Not Actor-list Tick, as we need the PlayerCalcView information Tick 1st person weapon. A-List Render (includes all 3rd person weapons - includes ticking of weapons if visible) //Generate B list during UnLevTic level tick //ensure DecoEffects are not in the A-List. They are bHidden, so that works okay? //SpecialDraw..if no viewport, draw all. if viewport, draw only if bRequiresWorldZBuffer //tick all actors here B-List Tick (dependant upon weapon render/tick in A-List) //render clipped ones here: if viewactor does not own this, draw it. if viewactor owns this, only if bRequiresWorldZBuffer B-List Render //DrawWeapon Clear Z buffer Render 1st person weapon //DrawDecos..only draw if !bRequiresWorldZBuffer Render DecoEffects B-List is all DecoEffects that need to interact with the world. for other weapons, ALL effects for our weapon, just world-interacting effects A-List is everything else except first person weapon and remaining DecoEffects. */ /*ARL(moved to C++ | way too slow) simulated event Tick( float DeltaSeconds ) { local bool bFullUpdate; //optimization local bool bFirstPerson; //!!mdf-tmp: disable weapon overhead temporarily if( bDisableTick ) return; //Super.Tick(DeltaSeconds); if( Level.TimeSeconds - FireSkinTime > 0.2 ) UnsetFireSkin(); if( !Owner || !Owner.bStasis ) { // HideFirstPersonEffects(); // UpdateEffectsFOV(); HideFirstPersonEffects_and_UpdateEffectsFOV(); bFullUpdate = U2PCOwner? || (Owner? && Owner.DrawType == DT_Mesh && (Level.TimeSeconds - Owner.LastRenderTime) < 0.25) || (Level.TimeSeconds - LastFullUpdateTime) > 1.0; // bFullUpdate = true; if( bFullUpdate ) { LastFullUpdateTime = Level.TimeSeconds; MoveWeapon(); } MoveDecos(DeltaSeconds,bFullUpdate); } // Set correct mesh. bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); if (bFirstPerson) Mesh = FirstPersonMesh; else Mesh = ThirdPersonMesh; } simulated function HideFirstPersonEffects_and_UpdateEffectsFOV() { local int i; local bool bFirstPerson; bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); for(i=0;i<DecoEffects.length;i++) { if( DecoEffects[i].Effect? ) { DecoEffects[i].Effect.bHidden = bFirstPerson && !DecoEffects[i].Effect.bRequiresWorldZBuffer; if( bFirstPerson && !DecoEffects[i].bWorldFOV ) DecoEffects[i].Effect.FOV=FOV; else DecoEffects[i].Effect.FOV=0; } } } simulated function HideFirstPersonEffects() { local int i; local bool bFirstPerson; bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); for(i=0;i<DecoEffects.length;i++) if( DecoEffects[i].Effect? ) DecoEffects[i].Effect.bHidden = bFirstPerson && !DecoEffects[i].Effect.bRequiresWorldZBuffer; } simulated function UpdateEffectsFOV() { local int i; local bool bFirstPerson; bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); for(i=0;i<DecoEffects.length;i++) { if( DecoEffects[i].Effect? ) { if( bFirstPerson && !DecoEffects[i].bWorldFOV ) DecoEffects[i].Effect.FOV=FOV; else DecoEffects[i].Effect.FOV=0; } } } simulated function MoveWeapon() { local vector NextLocation; local rotator NextRotation; local bool bFirstPerson; if(bLockLocation) return; // Fix ARL: If we don't have an Owner, why do we even exist? if( !Pawn(Owner) ) return; bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); if( bFirstPerson ) { NextLocation = Pawn(Owner).Location + Pawn(Owner).CalcDrawOffset(Self); NextRotation = Pawn(Owner).GetViewRotation(); if( U2PCOwner.LeanOffset != vect(0,0,0) ) { NextLocation += U2PCOwner.LeanOffset; NextRotation.Pitch -= VSize(U2PCOwner.LeanOffset)/48.0*8192; } SetRotation( NextRotation + RotationOffset ); if( Location!=vect(0,0,0) ) NextLocation += LocationOffset >> (Rotation - RotationOffset); SetLocation( NextLocation ); } else { MountParentActor = Owner; MountParentTag = Owner.Tag; MountParentNode = MeshGetNodeWeapon(); MountOrgLocation = vect(0,0,0); MountOrgRotation = rot(0,0,0); MountOldLocation = Location; MountOldRotation = Rotation; // Fix ARL: Node isn't set yet? Need to force this or something. if( MountParentNode=="" ) MountParentNode="handpointr02"; UpdateMountPhysics(); MountParentActor = None; } } simulated function MoveDecos( float DeltaSeconds, bool bFullUpdate ) { local int i; local ParticleGenerator P; local float OldAnimFrame; local bool bFirstPerson; bFirstPerson = U2PCOwner? && Viewport(U2PCOwner.Player)? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson(); // choose correct mesh for updating attachments. if( bFirstPerson ) Mesh = FirstPersonMesh; else Mesh = ThirdPersonMesh; for(i=0;i<DecoEffects.length;i++) { if( DecoEffects[i].Effect? ) { // update attachment location for all effects except those that are bTriggerUpdateOnly (only update those the first tick after the animation has been played). if( DecoEffects[i].bTriggerUpdateOnly ) { if( LastTriggeredAnim==DecoEffects[i].AnimSequence ) { OldAnimFrame = AnimFrame; AnimFrame = 0.0; DecoEffects[i].Effect.MountParentActor = self; DecoEffects[i].Effect.UpdateMountPhysics(); DecoEffects[i].Effect.MountParentActor = none; AnimFrame = OldAnimFrame; } } else if( bFullUpdate ) { DecoEffects[i].Effect.MountParentActor = self; DecoEffects[i].Effect.UpdateMountPhysics(); DecoEffects[i].Effect.MountParentActor = none; } // Auto-aim for NPCs. if( bFullUpdate ) { if( DecoEffects[i].AIAim>0 && !U2PCOwner && Pawn(Owner)? ) DecoEffects[i].Effect.SetRotation( Pawn(Owner).AdjustAim( None, DecoEffects[i].AIAim, DecoEffects[i].Effect.Location, 0, true, false, false, false) ); } // manually tick particle systems (after their location has been updated so particles get spawned at the correct location). P = ParticleGenerator(DecoEffects[i].Effect); if( P? ) P.ManualTick( DeltaSeconds ); //{ // // don't tick particlesystems full time if they aren't world z buffer (if they don't exist in the world). gives better visuals at high deltatimes // if( !DecoEffects[i].bRequiresWorldZBuffer ) // //Fix ARL: Replace this with a 'PrimeTime' variable set either by the LD on the particlesystem, or in the DecoEffects, or as a constant, here // P.ManualTick( FMin(0.02 + FRand()*0.02, DeltaSeconds) ); // else // P.ManualTick( DeltaSeconds ); //} } } LastTriggeredAnim = ''; } */ simulated event RenderOverlays( canvas Canvas ) { //log("RenderOverlays"); if( !Pawn(Owner) ) return; if( U2PCOwner? && U2PCOwner.ViewingSelf() && !U2PCOwner.ThirdPerson() ) { if( U2PCOwner.HandlingCrosshair() ) { if( (~Crosshair)) UnSetCrosshair(); } else if( !IsInState( 'DownWeapon' ) ) //MJL push SetCrosshair() into PlayPostSelect() override { if(!(~Crosshair)) SetCrosshair(); if( (~Crosshair)) UpdateCrosshair( Canvas ); } // Zoomed in. if( U2PCOwner.DesiredFOV != U2PCOwner.DefaultFOV ) return; // 3rd person. if( U2PCOwner.ViewTarget != Pawn(Owner) || U2PCOwner.bBehindView ) return; // invisibility cheat if( Pawn(Owner).bHidden ) return; DrawWeapon( Canvas ); DrawDecos( Canvas ); } else { if( (~Crosshair)) UnsetCrosshair(); } } simulated function DrawWeapon( canvas Canvas ) { Canvas.DrawActor(self, false, true, ActorFOV); } simulated function DrawDecos( canvas Canvas ) { local int i; for(i=0;i<DecoEffects.length;i++) if( DecoEffects[i].Effect? && DecoEffects[i].Effect.bHidden ) Canvas.DrawActor( DecoEffects[i].Effect, false, false, DecoEffects[i].Effect.ActorFOV ); } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ //Crosshair/HUD //if we used to be owned by a pawn who had a viewport, and now we aren't... // then clear the weapon effects. This is the BEST way I can think of to do this simulated function PostRecvOwner() { Super.PostRecvOwner(); if( !Pawn(Owner) ) { ClearWeaponEffects(); GotoState( '' ); } if( Instigator? ) U2PCOwner = U2PlayerController(Instigator.Controller); } simulated function ClearWeaponEffects() // interface function -- override as necessary in weapon subclasses (may be called repeatedly) { UnSetCrosshair(); } simulated function UIConsole GetConsole() { local UIConsole C; local PlayerController PC; PC = PlayerController(Instigator.Controller); if( PC? ) C = UIConsole(PC.Player.Console); return C; } simulated function SetCrosshair() { if( CrosshairName!="" ) { Crosshair = class'UIConsole'.static.LoadComponent( CrosshairFilename, CrosshairName ); class'UIConsole'.static.SetOwner( Crosshair, Self ); class'UIConsole'.static.AddComponent(Crosshair); } } simulated function UnSetCrosshair() { if( ~Crosshair ) Crosshair = class'UIConsole'.static.DestroyComponent(Crosshair); } simulated function UpdateCrosshair( Canvas Canvas ) { if( bCrosshairGlows && GetConsole()? ) HandleCrosshairGlow( Canvas ); } simulated function HandleCrosshairGlow( Canvas Canvas ) { local Actor A; local vector ScreenLoc; local int i; local byte bHitTarget; local vector ViewLoc; local rotator ViewRot; local string Event; ViewLoc = Owner.Location; ViewLoc.Z += Pawn(Owner).BaseEyeHeight; ViewRot = Pawn(Owner).GetViewRotation(); A = FindTraceTarget( ViewLoc, ViewRot ); HandleTargetDetails( A, Canvas, ViewLoc, ViewRot ); if( !bGlowing && A? && IsTargetable(A) ) { bGlowing=true; if (U2PCOwner?) U2PCOwner.SendEvent("Glow"); /*OLD GlowingAttitude = GetAttitudeTo(A); if( GlowingAttitude == ATTITUDE_Enemy ) Event = "GlowEnemy"; else Event = "Glow"; // !!!ARL (mdf) tbd show friends (as opposed to neutral)? // if( GlowingAttitude == ATTITUDE_Friend ) Event = "GlowFriend"; // else Event = "Glow"; if( U2PCOwner? ) U2PCOwner.SendEvent(Event); */ } else if( bGlowing && ( !A || !IsTargetable(A) ) ) { bGlowing=false; if (U2PCOwner?) U2PCOwner.SendEvent("UnGlow"); /*OLD if( GlowingAttitude != ATTITUDE_Neutral ) Event = "UnGlowEnemy"; else Event = "UnGlow"; if( U2PCOwner? ) U2PCOwner.SendEvent(Event); */ } } simulated function Controller.EAttitude GetAttitudeTo( Actor A ) { local pawn OwnerPawn,TargetPawn; local controller TargetController; OwnerPawn = Pawn(Owner); TargetPawn = Pawn(A); if( !OwnerPawn || !TargetPawn || OwnerPawn.bHidden ) return ATTITUDE_Neutral; TargetController = TargetPawn.Controller; if( !TargetController ) return ATTITUDE_Neutral; return TargetController.GetAttitudeTo(OwnerPawn); } simulated function HandleTargetDetails( Actor A, Canvas Canvas, vector ViewLoc, rotator ViewRot ); function bool IsTargetable( Actor A ) { local int i; if( A==Owner ) return false; if( A.bHidden ) return false; if( A.Physics == PHYS_None ) // don't target carcasses & such? return false; for( i=0; i<TargetableTypes.Length; i++ ) if( A.IsA( TargetableTypes[i] ) ) return true; return false; } //------------------------------------------------------------------------------ // Returns the target that is in the player's FOV as defined by MaxAngleInDegrees // that is also the closest to the center of view. //------------------------------------------------------------------------------ // Loc: Point of origin. // ViewRot: Direction of view. // MaxAngleInDegrees: Field of view. //------------------------------------------------------------------------------ // REQUIRE: MaxAngleInDegrees < 90 //------------------------------------------------------------------------------ function Actor FindBestTarget( vector Loc, rotator ViewRot, float MaxAngleInDegrees ) { local float BestRatio; //best found ratio local Actor BestTarget; //best target discovered so far local vector ViewVec; //vector showing LOS Loc/ViewRot local Actor IterA; //iterator tmp var local vector DirVec; //direction vector from Loc to current potential target local float DistRatio; //dot product of the view direction with one-over the offset to the actor local float FOVCos; //Cos of MaxAngleInDegrees // First try a direct trace to the first targetable actor. BestTarget = FindTraceTarget( Loc, ViewRot ); if( !BestTarget || !IsTargetable( BestTarget ) ) { BestTarget = None; FOVCos = class'Util'.static.Cos( MaxAngleInDegrees * DegreesToRadians ); ViewVec = vector(ViewRot); foreach DynamicActors( class'Actor', IterA ) { if( IsTargetable(IterA) ) { DistRatio = ((IterA.Location - Loc) dot ViewVec) / VSizeSq(IterA.Location - Loc); if( DistRatio > 0 && class'UtilGame'.static.ActorCanSeeActor( Owner, IterA, FOVCos ) ) { if( !BestTarget || DistRatio > BestRatio ) { BestTarget = IterA; BestRatio = DistRatio; } } } } } return BestTarget; } function Actor FindTraceTarget( vector Loc, rotator ViewRot ) { local vector Ignored; //dummy arg // optimization if( !UseGlowingCrosshairs ) return None; //return class'Util'.static.TraceRecursive( Self, Ignored, Ignored, Loc, true,, vector(ViewRot) ); //!!ARL (mdf) above call is causing between 0.0 (look at floor) to 2.8ms (mm_waterfront) -- cap at 4K? return class'Util'.static.TraceRecursive( Self, Ignored, Ignored, Loc, true,, vector(ViewRot), 4096.0 ); } static function bool AddAmmo( Pawn Other, string AmmoClassString, int AddAmmoAmount, optional bool bMaximizeClipAmount ) { local Ammunition Ammo; local class<Ammunition> AddAmmoClass; local bool bResult; bResult = false; AddAmmoClass = class<Ammunition>(DynamicLoadObject( AmmoClassString, class'Class' )); if( AddAmmoClass? ) { Ammo = Ammunition(Other.FindInventoryType( AddAmmoClass )); if( Ammo? ) { AddAmmoAmount = Max( AddAmmoAmount, -Ammo.AmmoAmount ); Ammo.AddAmmo( AddAmmoAmount ); bResult = true; } else { Ammo = Other.Spawn( AddAmmoClass ); // Create ammo type required if( Ammo? ) { AddAmmoAmount = Max( AddAmmoAmount, 0 ); Other.AddInventory( Ammo ); // and add to player's inventory Ammo.AmmoAmount = AddAmmoAmount; Ammo.GotoState( '' ); bResult = true; } } if( U2Ammo(Ammo)? && bMaximizeClipAmount ) U2Ammo(Ammo).MaximizeClipAmount(); } return bResult; } function sound GetGunButtSound() { return GunButtSounds[ Rand( GunButtSounds.Length ) ]; } simulated function NotifyCutsceneBegin(); // override for special handling of cutscene starting. defaultproperties { FireTime=0.500000 AltFireTime=0.500000 FireLastDownTime=1.000000 AltFireLastDownTime=1.000000 FireLastReloadTime=1.000000 AltFireLastReloadTime=1.000000 ReloadTime=0.500000 SelectTime=0.600000 DownTime=0.533000 FireSkinTime=1000000000.000000 GunButtSounds(0)=Sound'U2WeaponsA.GunButt.GunButt01' GunButtSounds(1)=Sound'U2WeaponsA.GunButt.GunButt02' GunButtSounds(2)=Sound'U2WeaponsA.GunButt.GunButt03' GunButtSounds(3)=Sound'U2WeaponsA.GunButt.GunButt04' FirePitch=(A=1.000000,B=1.000000) AltFirePitch=(A=1.000000,B=1.000000) fAdjustWeaponRate=0.400000 bRepeatFire=true bRepeatAltFire=true UseGlowingCrosshairs=true WeaponAnimationType=AT_NoWeapon TraceRange=10000.000000 AltShakeMag=5.000000 AltShakeTime=0.200000 BounceDamping=0.450000 TargetableTypes(0)='Pawn' CrosshairFilename="Crosshairs" CrosshairName="Pistol_Cross" bAimFire=true bAimAltFire=true bFireEnabledForOwner=true bAltFireEnabledForOwner=true RangeMinFire=-1.000000 RangeIdealFire=-1.000000 RangeMaxFire=-1.000000 RangeLimitFire=-1.000000 RatingInsideMinFire=-10.000000 RatingRangeMinFire=-1.000000 RatingRangeIdealFire=-1.000000 RatingRangeMaxFire=-1.000000 RatingRangeLimitFire=-1.000000 AIRatingFire=-99.999001 RangeMinAltFire=-1.000000 RangeIdealAltFire=-1.000000 RangeMaxAltFire=-1.000000 RangeLimitAltFire=-1.000000 RatingInsideMinAltFire=-10.000000 RatingRangeMinAltFire=-1.000000 RatingRangeIdealAltFire=-1.000000 RatingRangeMaxAltFire=-1.000000 RatingRangeLimitAltFire=-1.000000 AIRatingAltFire=-99.999001 ShakeMag=5.000000 ShakeTime=0.200000 AIRating=-99.999001 AlignMeshTraceOffset1=(X=10.000000,Y=-5.000000,Z=-12.000000) AlignMeshTraceOffset2=(X=10.000000,Y=5.000000,Z=-12.000000) AlignMeshTraceOffset3=(X=-12.000000,Z=-12.000000) ActorFOV=60.000000 bNoSmooth=false bAutoEnableAgent=true SoundRadius=800.000000 TransientSoundRadius=800.000000 CollisionRadius=0.000000 CollisionHeight=0.000000 bBounce=true UseReticleOnEvents(0)="UseReticleText" UseReticleOnEvents(1)="UseReticleCorners" UseReticleOnEvents(2)="UseReticleTopBars" ProximityReticleOnEvents(0)="ProximityReticleCorners" ProximityReticleOnEvents(1)="ProximityReticleTopBars" } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |