Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UTGame.UTWeapon


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
03245
03246
03247
03248
03249
03250
03251
03252
03253
03254
03255
03256
03257
03258
03259
03260
03261
03262
03263
03264
03265
03266
03267
03268
03269
03270
03271
03272
03273
03274
03275
03276
03277
03278
03279
03280
03281
03282
03283
03284
03285
03286
03287
03288
03289
03290
03291
03292
03293
03294
03295
03296
03297
03298
03299
03300
03301
03302
03303
03304
03305
03306
03307
03308
03309
03310
03311
03312
03313
03314
03315
03316
03317
03318
03319
03320
03321
03322
03323
03324
03325
03326
03327
03328
03329
03330
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367
03368
03369
03370
03371
03372
03373
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387
03388
03389
03390
03391
03392
03393
03394
03395
03396
03397
03398
03399
03400
03401
03402
03403
03404
03405
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420
03421
03422
03423
03424
03425
03426
03427
03428
03429
03430
03431
03432
03433
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443
03444
03445
03446
03447
03448
03449
03450
03451
03452
03453
03454
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490
03491
03492
03493
03494
03495
03496
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507
03508
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */
class UTWeapon extends GameWeapon
	native
	nativereplication
	dependson(UTPlayerController)
	config(Weapon)
	abstract;

/** if set, when this class is compiled, a menu entry for it will be automatically added/updated in its package.ini file
 * (abstract classes are skipped even if this flag is set)
 */
var bool bExportMenuData;
/** whether having this weapon in a weapon locker should generate a map check warning */
var bool bWarnIfInLocker;

/*********************************************************************************************
 Ammo / Pickups / Inventory
********************************************************************************************* */

var class<UTAmmoPickupFactory> AmmoPickupClass;

/** Current ammo count */
var databinding	repnotify int AmmoCount;

/** Initial ammo count if in weapon locker */
var databinding	int LockerAmmoCount;

/** Max ammo count */
var databinding	int MaxAmmoCount;

/** Holds the amount of ammo used for a given shot */
var databinding	array<int> ShotCost;

/** Holds the min. amount of reload time that has to pass before you can switch */
var array<float> MinReloadPct;

/** camera anim to play when firing (for camera shakes) */
var array<CameraAnim> FireCameraAnim;

/** controller rumble to play when firing. */
var ForceFeedbackWaveform WeaponFireWaveForm;

var array<name> EffectSockets;

var int IconX, IconY, IconWidth, IconHeight;

/** used when aborting a weapon switch (WeaponAbortEquip and WeaponAbortPutDown) */
var float SwitchAbortTime;

var UIRoot.TextureCoordinates IconCoordinates;
var UIRoot.TextureCoordinates CrossHairCoordinates;
var UIRoot.TextureCoordinates SimpleCrossHairCoordinates;

/** Holds the image to use for the crosshair. */
var Texture2D CrosshairImage;

/** Holds the image to use for the crosshair. */
var UIRoot.TextureCoordinates LockedCrossHairCoordinates;

/** Locked indicator current scale */
var float CurrentLockedScale;

/** Locked indicator start scale */
var float StartLockedScale;

/** Locked indicator final scale */
var float FinalLockedScale;

/** Locked indicator scale time */
var float LockedScaleTime;

/** Lock start time */
var float LockedStartTime;

var bool bWasLocked;

/** Replicated flag set when hitscan hits enemy */
var repnotify byte HitEnemy;

/** Used to decide whether to red color crosshair */
var float LastHitEnemyTime;

/** color to use when drawing the crosshair */
var config color CrosshairColor;

var float CrosshairScaling;

/** If true, use smaller 1st person weapons */
var globalconfig databinding bool bSmallWeapons;

/** offset for dropped pickup mesh */
var float DroppedPickupOffsetZ;

var config bool bUseCustomCoordinates;

var config UIRoot.TextureCoordinates CustomCrosshairCoordinates;

/*********************************************************************************************
 Zooming
********************************************************************************************* */

/** If set to non-zero, this fire mode will zoom the weapon. */
var array<byte>	bZoomedFireMode;

/** Are we zoomed */
enum EZoomState
{
	ZST_NotZoomed,
	ZST_ZoomingOut,
	ZST_ZoomingIn,
	ZST_Zoomed,
};

/** Holds the fire mode num of the zoom */
var byte 	ZoomedFireModeNum;

var float	ZoomedTargetFOV;

var float	ZoomedRate;

var float 	ZoomFadeTime;

/** Sounds to play when zooming begins/ends/etc. */
var SoundCue ZoomInSound, ZoomOutSound;

/*********************************************************************************************
 Attachments
********************************************************************************************* */

/** The class of the attachment to spawn */
var class<UTWeaponAttachment> 	AttachmentClass;

/** If true, this weapon is a super weapon.  Super Weapons have longer respawn times a different
    pickup base and never respect weaponstay */
var bool bSuperWeapon;

/** Adjust pivot of rotating pickup */
var vector	PivotTranslation;

/*********************************************************************************************
 Overlays
********************************************************************************************* */

/** mesh for overlay - Each weapon will need to add its own overlay mesh in its default props */
var protected MeshComponent OverlayMesh;
/*********************************************************************************************
 Inventory Grouping/etc.
********************************************************************************************* */

/** The weapon/inventory set, 0-9. */
var databinding	byte InventoryGroup;

/** position within inventory group. (used by prevweapon and nextweapon) */
var float GroupWeight;

/** The final inventory weight.  It's calculated in PostBeginPlay() */
var float InventoryWeight;

/** If true, this will will never accept a forwarded pending fire */
var bool bNeverForwardPendingFire;


/** The index in to the Quick Pick radial menu to use */
var int QuickPickGroup;

/** Used to sort it within a group */
var float QuickPickWeight;

/*********************************************************************************************
 Animations and Sounds
********************************************************************************************* */

var bool bSuppressSounds;

/** Animation to play when the weapon is fired */
var(Animations)	array<name>	WeaponFireAnim;
var(Animations) array<name> ArmFireAnim;
var(Animations) AnimSet ArmsAnimSet;
/** Animation to play when the weapon is Put Down */
var(Animations) name	WeaponPutDownAnim;
var(Animations) name	ArmsPutDownAnim;
/** Animation to play when the weapon is Equipped */
var(Animations) name	WeaponEquipAnim;
var(Animations) name	ArmsEquipAnim;

var(Animations) array<name> WeaponIdleAnims;
var(Animations) array<name> ArmIdleAnims;

var(Animations) bool bUsesOffhand;
/** Sound to play when the weapon is fired */
var(Sounds)	array<SoundCue>	WeaponFireSnd;

/** Sound to play when the weapon is Put Down */
var(Sounds) SoundCue 	WeaponPutDownSnd;

/** Sound to play when the weapon is Equipped */
var(Sounds) SoundCue 	WeaponEquipSnd;

/*********************************************************************************************
 First person weapon view positioning and rendering
********************************************************************************************* */

/** How much to damp view bob */
var() float	BobDamping;

/** How much to damp jump and land bob */
var() float	JumpDamping;

/** Limit for pitch lead */
var		float MaxPitchLag;

/** Limit for yaw lead */
var		float MaxYawLag;

/** Last Rotation update time for this weapon */
var		float LastRotUpdate;

/** Last Rotation update for this weapon */
var		Rotator LastRotation;

/** How far weapon was leading last tick */
var float OldLeadMag[2];

/** rotation magnitude last tick */
var int OldRotDiff[2];

/** max lead amount last tick */
var float OldMaxDiff[2];

/** Scaling faster for leading speed */
var float RotChgSpeed;

/** Scaling faster for returning speed */
var float ReturnChgSpeed;

/** If true, will be un-hidden on the next setPosition call. */
var bool bPendingShow;

/*********************************************************************************************
 Misc
********************************************************************************************* */

/** The Color used when drawing the Weapon's Name on the Hud */
var databinding	color WeaponColor;

/** Percent (from right edge) of screen space taken by weapon on x axis. */
var float WeaponCanvasXPct;

/** Percent (from bottom edge) of screen space taken by weapon on y axis. */
var float WeaponCanvasYPct;

/*********************************************************************************************
 Muzzle Flash
********************************************************************************************* */

/** Holds the name of the socket to attach a muzzle flash too */
var name					MuzzleFlashSocket;

/** Muzzle flash PSC and Templates*/
var UTParticleSystemComponent	MuzzleFlashPSC;

/** If true, always show the muzzle flash even when the weapon is hidden. */
var bool					bShowAltMuzzlePSCWhenWeaponHidden;

/** Normal Fire and Alt Fire Templates */
var ParticleSystem			MuzzleFlashPSCTemplate, MuzzleFlashAltPSCTemplate;

/** UTWeapon looks to set the color via a color parameter in the emitter */
var color					MuzzleFlashColor;

/** Set this to true if you want the flash to loop (for a rapid fire weapon like a minigun) */
var bool					bMuzzleFlashPSCLoops;

/** dynamic light */
var	UTExplosionLight		MuzzleFlashLight;

/** dynamic light class */
var class<UTExplosionLight> MuzzleFlashLightClass;

/** How long the Muzzle Flash should be there */
var() float					MuzzleFlashDuration;

/** Whether muzzleflash has been initialized */
var bool					bMuzzleFlashAttached;

/** Offset from view center */
var(FirstPerson) vector	PlayerViewOffset;

/** additional offset applied when using small weapons */
var(FirstPerson) vector SmallWeaponsOffset;

/** additional offset applied when using small weapons */
var(FirstPerson) float WideScreenOffsetScaling;

/** rotational offset only applied when in widescreen */
var rotator WidescreenRotationOffset;

/** special offset when using hidden weapons, as we need to still place the weapon for e.g. attached beams */
var vector HiddenWeaponsOffset;

var float ProjectileSpawnOffset;

/*********************************************************************************************
 Weapon locker
********************************************************************************************* */
var rotator LockerRotation;
var vector LockerOffset;

/*********************************************************************************************
 * AI Hints
 ********************************************************************************************* */

var		bool	bSplashJump;
var		bool	bRecommendSplashDamage;
var 	bool	bSniping;

/** This weapon can be used to destroy barricades */
var		bool	bCanDestroyBarricades;

/** Lead targets with this weapon (true by default, ignored for instant hit - set false for special cases like targeting with AVRiL */
var		bool	bLeadTarget;
/** Whether should consider projectile acceleration when leading targets */
var		bool	bConsiderProjectileAcceleration;
/** Whether bots should consider this a spray/fast firing weapon */
var		bool	bFastRepeater;
/** set for weapons that lock weapon rotation while firing, so bots know to retarget after each shot when shooting moving targets */
var		bool	bLockedAimWhileFiring;

/** Most recently calculated rating */
var		float	CurrentRating;

/** How much error to add to each shot */
var float AimError;

var ObjectiveAnnouncementInfo NeedToPickUpAnnouncement;

var bool bDebugWeapon;

/** Distance from target collision box to accept near miss when aiming help is enabled */
var float AimingHelpRadius[2];

/** Set for ProcessInstantHit based on whether aiminghelp was used for this shot */
var bool bUsingAimingHelp;

/** whether to allow this weapon to fire by uncontrolled pawns */
var bool bAllowFiringWithoutController;

/** If true, weapon auto recharges ammo */
var bool bAutoCharge;

/** recharge rate in ammo per second */
var float AmmoRechargeRate;

/** partial (less than 1) ammo charge */
var float PartialCharge;

/** timeseconds when last fired */
var float LastWeaponFireTime;

enum AmmoWidgetDisplayStyle
{
	EAWDS_Numeric,
	EAWDS_BarGraph,
	EAWDS_Both,
	EAWDS_None,
};

var AmmoWidgetDisplayStyle AmmoDisplayType;

//// start of adhesion friction vars
// all this needs to move to the GameWeapon

/** When the weapon is zoomed in then the turn speed is reduced by this much **/
var() config float ZoomedTurnSpeedScalePct;

/** Target friction enabled? */
var() config bool bTargetFrictionEnabled;

/** Min distance for friction */
var() config float TargetFrictionDistanceMin;

/** Peak distance for friction */
var() config float TargetFrictionDistancePeak;

/** Max distance allow for friction */
var() config float TargetFrictionDistanceMax;

/** Interp curve that allows for piece wise functions for the TargetFrictionDistance amount at different ranges **/
var() config InterpCurveFloat TargetFrictionDistanceCurve;

/** Min/Max friction multiplier applied when target acquired */
var() config Vector2d TargetFrictionMultiplierRange;

/** Amount of additional radius/height given to target cylinder when at peak distance */
var() config float TargetFrictionPeakRadiusScale;
var() config float TargetFrictionPeakHeightScale;

/** Offset to apply to friction target location (aim for the chest, etc) */
var() config vector TargetFrictionOffset;

/** Boost the Target Friction by this much when zoomed in **/
var() config float TargetFrictionZoomedBoostValue;

var() config bool bTargetAdhesionEnabled;

/** Max time to attempt adhesion to the friction target */
var() config float TargetAdhesionTimeMax;

/** Max distance to allow adhesion to still kick in */
var() config float TargetAdhesionDistanceMax;

/** Max distance from edge of cylinder for adhesion to be valid */
var() config float TargetAdhesionAimDistY;
var() config float TargetAdhesionAimDistZ;

/** Min/Max amount to scale for adhesive purposes */
var() config Vector2d TargetAdhesionScaleRange;

/** Min amount to scale for adhesive purposes */
var() config float TargetAdhesionScaleAmountMin;

/** Require the target to be moving for adhesion to kick in? */
var() config float TargetAdhesionTargetVelocityMin;

/** Require the player to be moving for adhesion to kick in? */
var() config float TargetAdhesionPlayerVelocityMin;

/** Boost the Target Adhesion by this much when zoomed in **/
var() config float TargetAdhesionZoomedBoostValue;

//// end of adhesion friction vars

var bool bForceHidden;

var bool bHasLocationSpeech;

var Array<SoundNodeWave> LocationSpeech;

/*********************************************************************************************
 * Hint strings
 ********************************************************************************************* */
var localized string PrimaryFireHintString;
var localized string SecondaryFireHintString;
var localized string JumpHintString;
var localized string CrouchHintString;
var localized string UseHintString;
var localized string AdditionalHintString;

// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)

replication
{
	// Server->Client properties
	if ( bNetOwner )
		AmmoCount, HitEnemy;
}

/** Util that makes sure the overlay component is last in the AllComponents/Components array. */
native function EnsureWeaponOverlayComponentLast();

simulated function StartFire(byte FireModeNum)
{
	if (bDebugWeapon)
	{
		LogInternal("---"@self$"."$GetStateName()$".StartFire("$FireModeNum$")");
		ScriptTrace();
	}
	Super.StartFire(FireModeNum);
}

reliable server function ServerStartFire(byte FireModeNum)
{
	if (bDebugWeapon)
	{
		LogInternal("---"@self$"."$GetStateName()$".ServerStartFire("$FireModeNum$")");
		ScriptTrace();
	}
	// don't allow firing if no controller (generally, because player entered/exited a vehicle while simultaneously pressing fire)
	if (Instigator == None || Instigator.Controller != None || bAllowFiringWithoutController)
	{
		Super.ServerStartFire(FireModeNum);
	}
}

/*********************************************************************************************
 * Initialization / System Messages / Utility
 *********************************************************************************************/

/**
 * Initialize the weapon
 */
simulated function PostBeginPlay()
{
	local UTGameReplicationInfo GRI;

	Super.PostBeginPlay();

	CalcInventoryWeight();

	// tweak firing/reload/putdown/bringup rate if on console
	GRI = UTGameReplicationInfo(WorldInfo.GRI);
	if (GRI != None && GRI.bConsoleServer)
	{
		AdjustWeaponTimingForConsole();
	}

	if ( Mesh != None )
	{
		Mesh.CastShadow = class'UTPlayerController'.default.bFirstPersonWeaponsSelfShadow;
	}

	bConsiderProjectileAcceleration = bConsiderProjectileAcceleration
										&& (((WeaponProjectiles[0] != None) && (class<UTProjectile>(WeaponProjectiles[0]).Default.AccelRate > 0))
											|| ((WeaponProjectiles[1] != None) && (class<UTProjectile>(WeaponProjectiles[1]).Default.AccelRate > 0)) );

	// make sure small weapons matches config
	// this is needed because if the UI modifies UTWeapon's defaults at runtime, it won't propagate to the child classes
	bSmallWeapons = class'UTWeapon'.default.bSmallWeapons;

	if ( bUseCustomCoordinates )
	{
		SimpleCrosshairCoordinates = CustomCrosshairCoordinates;
	}
}

/**
  * Adjust weapon equip and fire timings so they match between PC and console
  * This is important so the sounds match up.
  */
simulated function AdjustWeaponTimingForConsole()
{
	local int i;

	For ( i=0; i<FireInterval.Length; i++ )
	{
		FireInterval[i] = FireInterval[i]/1.1;
	}
	EquipTime = EquipTime/1.1;
	PutDownTime = PutDownTime/1.1;
}

simulated function CreateOverlayMesh()
{
	local SkeletalMeshComponent SKM_Source, SKM_Target;
	local StaticMeshComponent STM;
	local UTPawn P;

	if (OverlayMesh == None && WorldInfo.NetMode != NM_DedicatedServer && Mesh != None)
	{
		if ( WorldInfo.NetMode != NM_Client )
		{
			P = UTPawn(Instigator);
			if ( (P == None) || !P.bUpdateEyeHeight )
			{
				return;
			}
		}

		OverlayMesh = new(outer) Mesh.Class;
		if (OverlayMesh != None)
		{
			OverlayMesh.SetScale(1.00);
			OverlayMesh.SetOwnerNoSee(Mesh.bOwnerNoSee);
			OverlayMesh.SetOnlyOwnerSee(true);
			OverlayMesh.SetDepthPriorityGroup(SDPG_Foreground);
			OverlayMesh.CastShadow = false;

			if ( SkeletalMeshComponent(OverlayMesh) != none )
			{
				SKM_Target = SkeletalMeshComponent(OverlayMesh);
				SKM_Source = SkeletalMeshComponent(Mesh);

				SKM_Target.SetSkeletalMesh(SKM_Source.SkeletalMesh);
				SKM_Target.AnimSets = SKM_Source.AnimSets;
				SKM_Target.SetParentAnimComponent(SKM_Source);
				SKM_Target.bUpdateSkelWhenNotRendered = false;
				SKM_Target.bIgnoreControllersWhenNotRendered = true;

				if (UTSkeletalMeshComponent(SKM_Target) != none)
				{
					UTSkeletalMeshComponent(SKM_Target).SetFOV(UTSkeletalMeshComponent(SKM_Source).FOV);
				}
			}
			else if ( StaticMeshComponent(OverlayMesh) != none )
			{
				STM = StaticMeshComponent(OverlayMesh);
				STM.SetStaticMesh(StaticMeshComponent(Mesh).StaticMesh);
				STM.SetScale3D(Mesh.Scale3D);
				STM.SetTranslation(Mesh.Translation);
				STM.SetRotation(Mesh.Rotation);
			}
			OverlayMesh.SetHidden(Mesh.HiddenGame);
		}
		else
		{
			WarnInternal("Could not create Weapon Overlay mesh for" @ self @ Mesh);
		}
	}
}

simulated event ReplicatedEvent(name VarName)
{
	if ( VarName == 'AmmoCount' )
	{
		if ( !HasAnyAmmo() )
		{
			WeaponEmpty();
		}
	}
	else if ( VarName == 'HitEnemy' )
	{
		LastHitEnemyTime = WorldInfo.TimeSeconds;
	}
	else
	{
		Super.ReplicatedEvent(VarName);
	}
}


/**
 * Each Weapon needs to have a unique InventoryWeight in order for weapon switching to
 * work correctly.  This function calculates that weight using the various inventory values
 */
simulated function CalcInventoryWeight()
{
	InventoryWeight = ((InventoryGroup+1) * 1000) + (GroupWeight * 100);
	if ( Priority < 0 )
	{
		Priority = InventoryWeight;
	}
}

/**
 * returns true if this weapon is currently lower priority than InWeapon
 * used to determine whether to switch to InWeapon
 * this is the server check, so don't check clientside settings (like weapon priority) here
 */
simulated function bool ShouldSwitchTo(UTWeapon InWeapon)
{
	// if we should, but can't right now, tell InventoryManager to try again later
	if (IsFiring() || DenyClientWeaponSet())
	{
		UTInventoryManager(InvManager).RetrySwitchTo(InWeapon);
		return false;
	}
	else
	{
		return true;
	}
}

/**
 * Material control
 *
 * @Param 	NewMaterial		The new material to apply or none to clear it
 */
simulated function SetSkin(Material NewMaterial)
{
	local int i,Cnt;

	if ( NewMaterial == None )
	{
		// Clear the materials
		if ( default.Mesh.Materials.Length > 0 )
		{
			Cnt = Default.Mesh.Materials.Length;
			for (i=0;i<Cnt;i++)
			{
				Mesh.SetMaterial( i, Default.Mesh.GetMaterial(i) );
			}
		}
		else if (Mesh.Materials.Length > 0)
		{
			Cnt = Mesh.Materials.Length;
			for ( i=0; i < Cnt; i++ )
			{
				Mesh.SetMaterial(i, none);
			}
		}
	}
	else
	{
		// Set new material
		if ( default.Mesh.Materials.Length > 0 || Mesh.GetNumElements() > 0 )
		{
			Cnt = default.Mesh.Materials.Length > 0 ? default.Mesh.Materials.Length : Mesh.GetNumElements();
			for ( i=0; i < Cnt; i++ )
			{
				Mesh.SetMaterial(i, NewMaterial);
			}
		}
	}
}

/*********************************************************************************************
 * Hud/Crosshairs
 *********************************************************************************************/

/**
 * Access to HUD and Canvas.
 * Event always called when the InventoryManager considers this Inventory Item currently "Active"
 * (for example active weapon)
 *
 * @param	HUD			- HUD with canvas to draw on
 */
simulated function ActiveRenderOverlays( HUD H )
{
	local UTPlayerController PC;

	PC = UTPlayerController(Instigator.Controller);
	if ( (PC != None) && !PC.bNoCrosshair )
	{
		CrossHairCoordinates = PC.bSimpleCrosshair ? SimpleCrosshairCoordinates : default.CrosshairCoordinates;
		DrawWeaponCrosshair( H );
	}
}

/**
 * Draw the Crosshairs
 */
simulated function DrawWeaponCrosshair( Hud HUD )
{
	local vector2d CrosshairSize;
	local float x,y,PickupScale, ScreenX, ScreenY;
	local UTHUD	H;
	local UTPlayerController PC;

	H = UTHUD(HUD);
	if ( H == None )
		return;

	// Apply pickup scaling
	if ( H.LastPickupTime > WorldInfo.TimeSeconds - 0.3 )
	{
		if ( H.LastPickupTime > WorldInfo.TimeSeconds - 0.15 )
		{
			PickupScale = (1 + 5 * (WorldInfo.TimeSeconds - H.LastPickupTime));
		}
		else
		{
			PickupScale = (1 + 5 * (H.LastPickupTime + 0.3 - WorldInfo.TimeSeconds));
		}
	}
	else
	{
		PickupScale = 1.0;
	}

	PC = UTPlayerController(Instigator.Controller);
	if ( PC.bSimpleCrosshair )
	{
 		CrosshairSize.Y = H.ConfiguredCrosshairScaling * CrosshairScaling * CrossHairCoordinates.VL * PickupScale * H.Canvas.ClipY/768;
  		CrosshairSize.X = CrosshairSize.Y * ( CrossHairCoordinates.UL / CrossHairCoordinates.VL ) * H.Canvas.ClipX/1024;
	}
	else
	{
 		CrosshairSize.Y = H.ConfiguredCrosshairScaling * CrosshairScaling * CrossHairCoordinates.VL * PickupScale * H.Canvas.ClipY/768;
  		CrosshairSize.X = CrosshairSize.Y * ( CrossHairCoordinates.UL / CrossHairCoordinates.VL );
	}

	X = H.Canvas.ClipX * 0.5;
	Y = H.Canvas.ClipY * 0.5;
	ScreenX = X - (CrosshairSize.X * 0.5);
	ScreenY = Y - (CrosshairSize.Y * 0.5);
	if ( CrosshairImage != none )
	{
		// crosshair drop shadow
		H.Canvas.DrawColor = H.BlackColor;
		H.Canvas.SetPos( ScreenX+1, ScreenY+1 );
		H.Canvas.DrawTile(CrosshairImage,CrosshairSize.X, CrosshairSize.Y, CrossHairCoordinates.U, CrossHairCoordinates.V, CrossHairCoordinates.UL,CrossHairCoordinates.VL);

		CrosshairColor = H.bGreenCrosshair ? H.Default.LightGreenColor : Default.CrosshairColor;
		H.Canvas.DrawColor = (WorldInfo.TimeSeconds - LastHitEnemyTime < 0.3) ? H.RedColor : CrosshairColor;
		H.Canvas.SetPos(ScreenX, ScreenY);
		H.Canvas.DrawTile(CrosshairImage,CrosshairSize.X, CrosshairSize.Y, CrossHairCoordinates.U, CrossHairCoordinates.V, CrossHairCoordinates.UL,CrossHairCoordinates.VL);
	}
}

/**
 * Draw the locked on symbol
 */
simulated function DrawLockedOn( HUD H )
{
	local vector2d CrosshairSize;
	local float x, y, ScreenX, ScreenY, LockedOnTime;

	if ( !bWasLocked )
	{
		LockedStartTime = WorldInfo.TimeSeconds;
		CurrentLockedScale = StartLockedScale;
		bWasLocked = true;
	}
	else
	{
		LockedOnTime = WorldInfo.TimeSeconds - LockedStartTime;
		CurrentLockedScale = (LockedOnTime > LockedScaleTime) ? FinalLockedScale : (StartLockedScale * (LockedScaleTime - LockedOnTime) + FinalLockedScale * LockedOnTime)/LockedScaleTime;
	}
 	CrosshairSize.Y = UTHUD(H).ConfiguredCrosshairScaling * CurrentLockedScale * CrosshairScaling * LockedCrossHairCoordinates.VL * H.Canvas.ClipY/768;
  	CrosshairSize.X = CrosshairSize.Y * ( LockedCrossHairCoordinates.UL / LockedCrossHairCoordinates.VL );

	X = H.Canvas.ClipX * 0.5;
	Y = H.Canvas.ClipY * 0.5;
	ScreenX = X - (CrosshairSize.X * 0.5);
	ScreenY = Y - (CrosshairSize.Y * 0.5);
	if ( CrosshairImage != none )
	{
		// crosshair drop shadow
		H.Canvas.DrawColor = class'UTHUD'.default.BlackColor;
		H.Canvas.SetPos( ScreenX+1, ScreenY+1 );
		H.Canvas.DrawTile(CrosshairImage,CrosshairSize.X, CrosshairSize.Y, LockedCrossHairCoordinates.U, LockedCrossHairCoordinates.V, LockedCrossHairCoordinates.UL,LockedCrossHairCoordinates.VL);

		H.Canvas.DrawColor = CrosshairColor;
		H.Canvas.SetPos(ScreenX, ScreenY);
		H.Canvas.DrawTile(CrosshairImage,CrosshairSize.X, CrosshairSize.Y, LockedCrossHairCoordinates.U, LockedCrossHairCoordinates.V, LockedCrossHairCoordinates.UL,LockedCrossHairCoordinates.VL);
	}
}

simulated function int GetAmmoCount()
{
	return AmmoCount;
}

/**
 * list important Weapon variables on canvas.  HUD will call DisplayDebug() on the current ViewTarget when
 * the ShowDebug exec is used
 *
 * @param	HUD			- HUD with canvas to draw on
 * @input	out_YL		- Height of the current font
 * @input	out_YPos	- Y position on Canvas. out_YPos += out_YL, gives position to draw text for next debug line.
 */
simulated function DisplayDebug(HUD HUD, out float out_YL, out float out_YPos)
{
	Super.DisplayDebug(HUD, out_YL, out_YPos);

	if (UTPawn(Instigator) != None)
	{
		HUD.Canvas.DrawText("Eyeheight "$Instigator.EyeHeight$" base "$Instigator.BaseEyeheight$" landbob "$UTPawn(Instigator).Landbob$" just landed "$UTPawn(Instigator).bJustLanded$" land recover "$UTPawn(Instigator).bLandRecovery, false);
		out_YPos += out_YL;
	}

	HUD.Canvas.SetPos(4,out_YPos);
	HUD.Canvas.DrawText("Zoom State:"@GetZoomedState()@"ZoomedRate:"@ZoomedRate@"Target FOV:"@ZoomedTargetFOV);
	out_YPos+= out_YL;
}


/*********************************************************************************************
 * Attachments / Effects / etc
 *********************************************************************************************/
/**
 * Returns interval in seconds between each shot, for the firing state of FireModeNum firing mode.
 *
 * @param	FireModeNum	fire mode
 * @return	Period in seconds of firing mode
 */
simulated function float GetFireInterval( byte FireModeNum )
{
	return FireInterval[FireModeNum] * ((UTPawn(Owner)!= None) ? UTPawn(Owner).FireRateMultiplier : 1.0);
}

simulated function PlayArmAnimation( Name Sequence, float fDesiredDuration, optional bool OffHand, optional bool bLoop, optional SkeletalMeshComponent SkelMesh)
{
	local UTPawn UTP;
	local SkeletalMeshComponent ArmMeshComp;
	local AnimNodeSequence WeapNode;

	// do not play on a dedicated server or if they aren't being seen
	if( WorldInfo.NetMode == NM_DedicatedServer || Instigator == None || !Instigator.IsFirstPerson())
	{
		return;
	}
	UTP = UTPawn(Instigator);
	if(UTP == none)
	{
		return;
	}
	if(UTP.bArmsAttached)
	{
		// Choose the right arm
		if(!OffHand)
		{
			ArmMeshComp = UTP.ArmsMesh[0];
		}
		else
		{
			ArmMeshComp = UTP.ArmsMesh[1];
		}

		// Check we have access to mesh and animations
		if( ArmMeshComp == None || ArmsAnimSet == none || GetArmAnimNodeSeq() == None )
		{
			return;
		}

		// If we are not specifying a duration, use the default play rate.
		if(fDesiredDuration > 0.0)
		{
			// @todo - this should call GetWeaponAnimNodeSeq, move 'duration' code into AnimNodeSequence and use that.
			ArmMeshComp.PlayAnim(Sequence, fDesiredDuration, bLoop);
		}
		else
		{
			WeapNode = AnimNodeSequence(ArmMeshComp.Animations);
			WeapNode.SetAnim(Sequence);
			WeapNode.PlayAnim(bLoop, DefaultAnimSpeed);
		}
	}
}

simulated function PlayWeaponAnimation(name Sequence, float fDesiredDuration, optional bool bLoop, optional SkeletalMeshComponent SkelMesh)
{
	if (Mesh != None && Mesh.bAttached)
	{
		Super.PlayWeaponAnimation(Sequence, fDesiredDuration, bLoop, SkelMesh);
	}
}

/**
 * PlayFireEffects Is the root function that handles all of the effects associated with
 * a weapon.  This function creates the 1st person effects.  It should only be called
 * on a locally controlled player.
 */
simulated function PlayFireEffects( byte FireModeNum, optional vector HitLocation )
{
	// Play Weapon fire animation

	if ( FireModeNum < WeaponFireAnim.Length && WeaponFireAnim[FireModeNum] != '' )
		PlayWeaponAnimation( WeaponFireAnim[FireModeNum], GetFireInterval(FireModeNum) );
	if ( FireModeNum < ArmFireAnim.Length && ArmFireAnim[FireModeNum] != '' && ArmsAnimSet != none)
		PlayArmAnimation( ArmFireAnim[FireModeNum], GetFireInterval(FireModeNum) );

	// Start muzzle flash effect
	CauseMuzzleFlash();

	ShakeView();
}

simulated function StopFireEffects(byte FireModeNum)
{
	StopMuzzleFlash();
}

/** plays view shake on the owning client only */
simulated function ShakeView()
{
	local UTPlayerController PC;

	PC = UTPlayerController(Instigator.Controller);
	if (PC != None && LocalPlayer(PC.Player) != None && CurrentFireMode < FireCameraAnim.length && FireCameraAnim[CurrentFireMode] != None)
	{
		PC.PlayCameraAnim(FireCameraAnim[CurrentFireMode], (GetZoomedState() > ZST_ZoomingOut) ? PC.FOVAngle / PC.DefaultFOV : 1.0);
	}

	// Play controller vibration
	if( PC != None && LocalPlayer(PC.Player) != None )
	{
		// only do rumble if we are a player controller
		UTPlayerController(Instigator.Controller).ClientPlayForceFeedbackWaveform( WeaponFireWaveForm );
	}
}

simulated function WeaponPlaySound(SoundCue Sound, optional float NoiseLoudness)
{
	if (!bSuppressSounds)
	{
		Super.WeaponPlaySound(Sound, NoiseLoudness);
	}
}

/**
 * Tells the weapon to play a firing sound (uses CurrentFireMode)
 */
simulated function PlayFiringSound()
{
	if (CurrentFireMode<WeaponFireSnd.Length)
	{
		// play weapon fire sound
		if ( WeaponFireSnd[CurrentFireMode] != None )
		{
			MakeNoise(1.0);
			WeaponPlaySound( WeaponFireSnd[CurrentFireMode] );
		}
	}
}

/**
 * Turns the MuzzleFlashlight off
 */
simulated event MuzzleFlashTimer()
{
	if (MuzzleFlashPSC != none && (!bMuzzleFlashPSCLoops) )
	{
		MuzzleFlashPSC.DeactivateSystem();
	}
}

/**
 * Causes the muzzle flashlight to turn on
 */
simulated event CauseMuzzleFlashLight()
{
	if ( WorldInfo.bDropDetail )
		return;

	if ( MuzzleFlashLight != None )
	{
		MuzzleFlashLight.ResetLight();
	}
	else if ( MuzzleFlashLightClass != None )
	{
		MuzzleFlashLight = new(Outer) MuzzleFlashLightClass;
		SkeletalMeshComponent(Mesh).AttachComponentToSocket(MuzzleFlashLight,MuzzleFlashSocket);
	}
}

/**
 * Causes the muzzle flash to turn on and setup a time to
 * turn it back off again.
 */
simulated event CauseMuzzleFlash()
{
	local UTPawn P;
	local ParticleSystem MuzzleTemplate;

	if ( WorldInfo.NetMode != NM_Client )
	{
		P = UTPawn(Instigator);
		if ( (P == None) || !P.bUpdateEyeHeight )
		{
			return;
		}
	}

	CauseMuzzleFlashLight();

	if (GetHand() != HAND_Hidden || (bShowAltMuzzlePSCWhenWeaponHidden && Instigator != None && Instigator.FiringMode == 1 && MuzzleFlashAltPSCTemplate != None))
	{
		if ( !bMuzzleFlashAttached )
		{
			AttachMuzzleFlash();
		}
		if (MuzzleFlashPSC != None)
		{
			if (!bMuzzleFlashPSCLoops || (!MuzzleFlashPSC.bIsActive || MuzzleFlashPSC.bWasDeactivated))
			{
				if (Instigator != None && Instigator.FiringMode == 1 && MuzzleFlashAltPSCTemplate != None)
				{
					MuzzleTemplate = MuzzleFlashAltPSCTemplate;

					// Option to not hide alt muzzle
					MuzzleFlashPSC.SetIgnoreOwnerHidden(bShowAltMuzzlePSCWhenWeaponHidden);
				}
				else if (MuzzleFlashPSCTemplate != None)
				{
					MuzzleTemplate = MuzzleFlashPSCTemplate;
				}
				if (MuzzleTemplate != MuzzleFlashPSC.Template)
				{
					MuzzleFlashPSC.SetTemplate(MuzzleTemplate);
				}
				SetMuzzleFlashParams(MuzzleFlashPSC);
				MuzzleFlashPSC.ActivateSystem();
			}
		}

		// Set when to turn it off.
		SetTimer(MuzzleFlashDuration,false,'MuzzleFlashTimer');
	}
}

simulated event StopMuzzleFlash()
{
	ClearTimer('MuzzleFlashTimer');
	MuzzleFlashTimer();

	if ( MuzzleFlashPSC != none )
	{
		MuzzleFlashPSC.DeactivateSystem();
	}
}


/**
 * Sets the timing for putting a weapon down.  The WeaponIsDown event is trigged when expired
*/
simulated function TimeWeaponPutDown()
{
	if( Instigator.IsFirstPerson() )
	{
		PlayWeaponPutDown();
	}

	super.TimeWeaponPutDown();
}

/**
 * Show the weapon being put away
 */
simulated function PlayWeaponPutDown()
{
	// Play the animation for the weapon being put down

	if ( WeaponPutDownAnim != '' )
		PlayWeaponAnimation( WeaponPutDownAnim, PutDownTime );
	if ( ArmsPutDownAnim != '' && ArmsAnimSet != none)
	{
		PlayArmAnimation( ArmsPutDownAnim, PutDownTime );
	}

	// play any associated sound
	if ( WeaponPutDownSnd != None )
		WeaponPlaySound( WeaponPutDownSnd );
}

/**
 * Sets the timing for equipping a weapon.
 * The WeaponEquipped event is trigged when expired
 */
simulated function TimeWeaponEquipping()
{
	// The weapon is equipped, attach it to the mesh.
	AttachWeaponTo( Instigator.Mesh );

	// Play the animation
	PlayWeaponEquip();

	SetTimer( GetEquipTime() , false, 'WeaponEquipped');
}

simulated function float GetEquipTime()
{
	local float ETime;

	ETime = EquipTime>0 ? EquipTime : 0.01;
	if ( PendingFire(0) || PendingFire(1) )
	{
		ETime += 0.25;
	}
	return ETime;
}

/**
 * Show the weapon begin equipped
 */
simulated function PlayWeaponEquip()
{
	// Play the animation for the weapon being put down

	if ( WeaponEquipAnim != '' )
		PlayWeaponAnimation( WeaponEquipAnim, EquipTime );
	if ( ArmsEquipAnim != '' && ArmsAnimSet != none)
	{
		PlayArmAnimation(ArmsEquipAnim, EquipTime);
	}

	// play any assoicated sound
	if ( WeaponEquipSnd != None )
		WeaponPlaySound( WeaponEquipSnd );
}

 /**
 * Attach Weapon Mesh, Weapon MuzzleFlash and Muzzle Flash Dynamic Light to a SkeletalMesh
 *
 * @param	who is the pawn to attach to
 */
simulated function AttachWeaponTo( SkeletalMeshComponent MeshCpnt, optional Name SocketName )
{
	local UTPawn UTP;

	if ( bDebugWeapon && Instigator != none && Instigator.Controller != none && PlayerController(Instigator.Controller) != none )
	{
		LogInternal("###"@self$"."$GetOwnerName()@".AttachWeaponTo"@MeshCpnt@Instigator.IsFirstPerson());
	}

	UTP = UTPawn(Instigator);
	// Attach 1st Person Muzzle Flashes, etc,
	if ( Instigator.IsFirstPerson() )
	{
		AttachComponent(Mesh);
		EnsureWeaponOverlayComponentLast();
		SetHidden(True);
		bPendingShow = TRUE;
		Mesh.SetLightEnvironment(UTP.LightEnvironment);
		if (GetHand() == HAND_Hidden)
		{
			UTP.ArmsMesh[0].SetHidden(true);
			UTP.ArmsMesh[1].SetHidden(true);
			if (UTP.ArmsOverlay[0] != None)
			{
				UTP.ArmsOverlay[0].SetHidden(true);
				UTP.ArmsOverlay[1].SetHidden(true);
			}
		}
	}
	else
	{
		SetHidden(True);
		if (UTP != None)
		{
			Mesh.SetLightEnvironment(UTP.LightEnvironment);
			UTP.ArmsMesh[0].SetHidden(true);
			UTP.ArmsMesh[1].SetHidden(true);
			if (UTP.ArmsOverlay[0] != None)
			{
				UTP.ArmsOverlay[0].SetHidden(true);
				UTP.ArmsOverlay[1].SetHidden(true);
			}
		}
	}

	SetWeaponOverlayFlags(UTP);

	// Spawn the 3rd Person Attachment
	if (Role == ROLE_Authority && UTP != None)
	{
		UTP.CurrentWeaponAttachmentClass = AttachmentClass;
		if (WorldInfo.NetMode == NM_ListenServer || WorldInfo.NetMode == NM_Standalone || (WorldInfo.NetMode == NM_Client && Instigator.IsLocallyControlled()))
		{
			UTP.WeaponAttachmentChanged();
		}
	}

	SetSkin(UTPawn(Instigator).ReplicatedBodyMaterial);

}

/**
 * Allows a child to setup custom parameters on the muzzle flash
 */

simulated function SetMuzzleFlashParams(ParticleSystemComponent PSC)
{
	PSC.SetColorParameter('MuzzleFlashColor', MuzzleFlashColor);
	PSC.SetVectorParameter('MFlashScale',Vect(0.5,0.5,0.5));
}

/**
 * Called on a client, this function Attaches the WeaponAttachment
 * to the Mesh.
 */
simulated function AttachMuzzleFlash()
{
	local SkeletalMeshComponent SKMesh;

	// Attach the Muzzle Flash
	bMuzzleFlashAttached = true;
	SKMesh = SkeletalMeshComponent(Mesh);
	if (  SKMesh != none )
	{
		if ( (MuzzleFlashPSCTemplate != none) || (MuzzleFlashAltPSCTemplate != none) )
		{
			MuzzleFlashPSC = new(Outer) class'UTParticleSystemComponent';
			MuzzleFlashPSC.bAutoActivate = false;
			MuzzleFlashPSC.SetDepthPriorityGroup(SDPG_Foreground);
			MuzzleFlashPSC.SetFOV(UTSkeletalMeshComponent(SKMesh).FOV);
			SKMesh.AttachComponentToSocket(MuzzleFlashPSC, MuzzleFlashSocket);
		}
	}
}


/**
 * Detach weapon from skeletal mesh
 *
 * @param	SkeletalMeshComponent weapon is attached to.
 */
simulated function DetachWeapon()
{
	local UTPawn P;

	DetachComponent( Mesh );
	if (OverlayMesh != None)
	{
		DetachComponent(OverlayMesh);
	}

	SetSkin(None);

	P = UTPawn(Instigator);
	if (P != None)
	{
		if (Role == ROLE_Authority && P.CurrentWeaponAttachmentClass == AttachmentClass)
		{
			P.CurrentWeaponAttachmentClass = None;
			if (Instigator.IsLocallyControlled())
			{
				P.WeaponAttachmentChanged();
			}
		}
		P.bDualWielding = false;
	}

	SetBase(None);
	SetHidden(True);
	DetachMuzzleFlash();
	Mesh.SetLightEnvironment(None);
}

/**
 * Remove/Detach the muzzle flash components
 */
simulated function DetachMuzzleFlash()
{
	local SkeletalMeshComponent SKMesh;

	bMuzzleFlashAttached = false;
	SKMesh = SkeletalMeshComponent(Mesh);
	if (  SKMesh != none )
	{
		if (MuzzleFlashPSC != none)
			SKMesh.DetachComponent( MuzzleFlashPSC );
	}
	MuzzleFlashPSC = None;
}

/**
 * This function is called from the pawn when the visibility of the weapon changes
 */

simulated function ChangeVisibility(bool bIsVisible)
{
	local UTPawn UTP;
	local SkeletalMeshComponent SkelMesh;
	local PrimitiveComponent Primitive;

	if (Mesh != None)
	{
		if (bIsVisible && !Mesh.bAttached)
		{
			AttachComponent(Mesh);
			EnsureWeaponOverlayComponentLast();
		}
		SetHidden(!bIsVisible);
		SkelMesh = SkeletalMeshComponent(Mesh);
		if (SkelMesh != None)
		{
			foreach SkelMesh.AttachedComponents(class'PrimitiveComponent', Primitive)
			{
				Primitive.SetHidden(!bIsVisible);
			}
		}
	}
	if (ArmsAnimSet != None && GetHand() != HAND_Hidden)
	{
		UTP = UTPawn(Instigator);
		if (UTP != None && UTP.ArmsMesh[0] != None)
		{
			UTP.ArmsMesh[0].SetHidden(!bIsVisible);
			if (UTP.ArmsOverlay[0] != None)
			{
				UTP.ArmsOverlay[0].SetHidden(!bIsVisible);
			}
		}
	}

	if ( OverlayMesh != none )
	{
		OverlayMesh.SetHidden(!bIsVisible || (GetHand() == HAND_Hidden));
	}
}

/**
* Called when the pawn is changing weapons
*/
simulated function PerformWeaponChange()
{
	if ( UTPawn(Instigator) != None )
	{
		if ( Instigator.IsLocallyControlled() )
		{
			UTPawn(Instigator).WeaponChanged(self);
		}

		// If the controller has not been replicated, try again later
		else if ( Instigator.Controller == None )
		{
			SetTimer(0.01, false, 'PerformWeaponChange');
		}
	}
}

/*********************************************************************************************
 * Pawn/Controller/View functions
 *********************************************************************************************/

simulated function GetViewAxes( out vector xaxis, out vector yaxis, out vector zaxis )
{
	if ( UTVehicle(Owner) != none )
	{
		UTVehicle(Owner).GetWeaponViewAxes(self, xaxis, yaxis, zaxis);
	}
	else if ( Instigator.Controller == None )
	{
	GetAxes( Instigator.Rotation, xaxis, yaxis, zaxis );
    }
    else
    {
	GetAxes( Instigator.Controller.Rotation, xaxis, yaxis, zaxis );
    }
}

/**
 * This function is called whenever you attempt to reselect the same weapon
 */
reliable server function ServerReselectWeapon();


/**
 * Returns true if this item can be thrown out.
 */
simulated function bool CanThrow()
{
	return bCanThrow && HasAnyAmmo();
}

/**
 * Returns the current Weapon Hand
 */
simulated function EWeaponHand GetHand()
{
	local UTPlayerController PC;

	// Get the Weapon Hand from the controller or default to HAND_Right
	if (Instigator != None)
	{
		PC = UTPlayerController(Instigator.Controller);
		if (PC != None)
		{
			return PC.WeaponHand;
		}
	}
	return HAND_Right;
}
/**
 * This function aligns the gun model in the world
 */
simulated event SetPosition(UTPawn Holder)
{
	local vector DrawOffset, ViewOffset, FinalSmallWeaponsOffset, FinalLocation;
	local EWeaponHand CurrentHand;
	local rotator NewRotation, FinalRotation, SpecRotation;
	local PlayerController PC;
	local vector2D ViewportSize;
	local bool bIsWideScreen, bIsClientDemo;
	local vector SpecViewLoc;

	if ( !Holder.IsFirstPerson() )
		return;

	// Hide the weapon if hidden
	CurrentHand = GetHand();
	if ( bForceHidden || CurrentHand == HAND_Hidden)
	{
		Mesh.SetHidden(True);
		Holder.ArmsMesh[0].SetHidden(true);
		Holder.ArmsMesh[1].SetHidden(true);
		if (Holder.ArmsOverlay[0] != None)
		{
			Holder.ArmsOverlay[0].SetHidden(true);
			Holder.ArmsOverlay[1].SetHidden(true);
		}
		NewRotation = Holder.GetViewRotation();
		SetLocation(Instigator.GetPawnViewLocation() + (HiddenWeaponsOffset >> NewRotation));
		SetRotation(NewRotation);
		SetBase(Instigator);
		return;
	}

	if(bPendingShow)
	{
		SetHidden(False);
		bPendingShow = FALSE;
	}

	Mesh.SetHidden(False);

	foreach LocalPlayerControllers(class'PlayerController', PC)
	{
		LocalPlayer(PC.Player).ViewportClient.GetViewportSize(ViewportSize);
		break;
	}
	bIsWideScreen = (ViewportSize.Y > 0.f) && (ViewportSize.X/ViewportSize.Y > 1.7);

	// Adjust for the current hand
	ViewOffset = PlayerViewOffset;
	FinalSmallWeaponsOffset = SmallWeaponsOffset;

	switch ( CurrentHand )
	{
		case HAND_Left:
			Mesh.SetScale3D(default.Mesh.Scale3D * vect(1,-1,1));
			Mesh.SetRotation(rot(0,0,0) - default.Mesh.Rotation);
			if (ArmsAnimSet != None)
			{
				Holder.ArmsMesh[0].SetScale3D(Holder.default.ArmsMesh[0].Scale3D * vect(1,-1,1));
				Holder.ArmsMesh[1].SetScale3D(Holder.default.ArmsMesh[1].Scale3D * vect(1,-1,1));
				if (Holder.ArmsOverlay[0] != None)
				{
					Holder.ArmsOverlay[0].SetScale3D(Holder.ArmsMesh[0].Scale3D);
					Holder.ArmsOverlay[1].SetScale3D(Holder.ArmsMesh[1].Scale3D);
				}
			}
			ViewOffset.Y *= -1.0;
			FinalSmallWeaponsOffset.Y *= -1.0;
			break;

		case HAND_Centered:
			ViewOffset.Y = 0.0;
			FinalSmallWeaponsOffset.Y = 0.0;
			break;

		case HAND_Right:
			Mesh.SetScale3D(default.Mesh.Scale3D);
			Mesh.SetRotation(default.Mesh.Rotation);
			if (ArmsAnimSet != None)
			{
				Holder.ArmsMesh[0].SetScale3D(Holder.default.ArmsMesh[0].Scale3D);
				Holder.ArmsMesh[1].SetScale3D(Holder.default.ArmsMesh[1].Scale3D);
				if (Holder.ArmsOverlay[0] != None)
				{
					Holder.ArmsOverlay[0].SetScale3D(Holder.ArmsMesh[0].Scale3D);
					Holder.ArmsOverlay[1].SetScale3D(Holder.ArmsMesh[1].Scale3D);
				}
			}
			break;
		default:
			break;
	}

	if ( bIsWideScreen )
	{
		ViewOffset += WideScreenOffsetScaling * FinalSmallWeaponsOffset;
		if ( bSmallWeapons )
		{
			ViewOffset += 0.7 * FinalSmallWeaponsOffset;
		}
	}
	else if ( bSmallWeapons )
	{
		ViewOffset += FinalSmallWeaponsOffset;
	}

	bIsClientDemo = WorldInfo.bWithinDemoPlayback && PlayerController(Holder.Controller) != None;

	// Calculate the draw offset
	if ( (Holder.Controller == None) || bIsClientDemo )
	{
		if ( bIsClientDemo || (DemoRecSpectator(PC) != None) )
		{
			PC.GetPlayerViewPoint(SpecViewLoc, SpecRotation);
			DrawOffset = ViewOffset >> SpecRotation;
			DrawOffset += 0.1 * Holder.WeaponBob(BobDamping, JumpDamping);
			FinalLocation = SpecViewLoc + DrawOffset;
			SetLocation(FinalLocation);
			SetBase(Holder);

			// Add some rotation leading
			SpecRotation.Yaw = LagRot(SpecRotation.Yaw & 65535, LastRotation.Yaw & 65535, MaxYawLag, 0);
			SpecRotation.Pitch = LagRot(SpecRotation.Pitch & 65535, LastRotation.Pitch & 65535, MaxPitchLag, 1);
			LastRotUpdate = WorldInfo.TimeSeconds;
			LastRotation = SpecRotation;

			if ( bIsWideScreen )
			{
				SpecRotation += WidescreenRotationOffset;
			}
			SetRotation(SpecRotation);
			return;
		}
		else
		{
			DrawOffset = (ViewOffset >> Holder.GetBaseAimRotation()) + Holder.GetEyeHeight() * vect(0,0,1);
		}
	}
	else
	{
		DrawOffset.Z = Holder.GetEyeHeight();
		DrawOffset += Holder.WeaponBob(BobDamping, JumpDamping);

		if ( UTPlayerController(Holder.Controller) != None )
		{
			DrawOffset += UTPlayerController(Holder.Controller).ShakeOffset >> Holder.Controller.Rotation;
		}

		DrawOffset = DrawOffset + ( ViewOffset >> Holder.Controller.Rotation );
	}

	// Adjust it in the world
	FinalLocation = Holder.Location + DrawOffset;
	SetLocation(FinalLocation);
	SetBase(Holder);

	if (ArmsAnimSet != None)
	{
		Holder.ArmsMesh[0].SetTranslation(DrawOffset);
		Holder.ArmsMesh[1].SetTranslation(DrawOffset);
		if (Holder.ArmsOverlay[0] != None)
		{
			Holder.ArmsOverlay[0].SetTranslation(DrawOffset);
			Holder.ArmsOverlay[1].SetTranslation(DrawOffset);
		}
	}

	NewRotation = (Holder.Controller == None) ? Holder.GetBaseAimRotation() : Holder.Controller.Rotation;

	// Add some rotation leading
	if (Holder.Controller != None)
	{
		FinalRotation.Yaw = LagRot(NewRotation.Yaw & 65535, LastRotation.Yaw & 65535, MaxYawLag, 0);
		FinalRotation.Pitch = LagRot(NewRotation.Pitch & 65535, LastRotation.Pitch & 65535, MaxPitchLag, 1);
		FinalRotation.Roll = NewRotation.Roll;
	}
	else
	{
		FinalRotation = NewRotation;
	}
	LastRotUpdate = WorldInfo.TimeSeconds;
	LastRotation = NewRotation;

	if ( bIsWideScreen )
	{
		FinalRotation += WidescreenRotationOffset;
	}
	SetRotation(FinalRotation);
	if (ArmsAnimSet != None)
	{
		Holder.ArmsMesh[0].SetRotation(FinalRotation);
		Holder.ArmsMesh[1].SetRotation(FinalRotation);
		if (Holder.ArmsOverlay[0] != None)
		{
			Holder.ArmsOverlay[0].SetRotation(FinalRotation);
			Holder.ArmsOverlay[1].SetRotation(FinalRotation);
		}
	}
}

/** @return whether the weapon's rotation is allowed to lag behind the holder's rotation */
simulated function bool ShouldLagRot()
{
	return false;
}

simulated function int LagRot(int NewValue, int LastValue, float MaxDiff, int Index)
{
	local int RotDiff;
	local float LeadMag, DeltaTime;

	if ( NewValue ClockWiseFrom LastValue )
	{
		if ( LastValue > NewValue )
		{
			LastValue -= 65536;
		}
	}
	else
	{
		if ( NewValue > LastValue )
		{
			NewValue -= 65536;
		}
	}

	DeltaTime = WorldInfo.TimeSeconds - LastRotUpdate;
	RotDiff = NewValue - LastValue;
	if ( (RotDiff == 0) || (OldRotDiff[Index] == 0) )
	{
		LeadMag = ShouldLagRot() ? OldLeadMag[Index] : 0.0;
		if ( (RotDiff == 0) && (OldRotDiff[Index] == 0) )
		{
			OldMaxDiff[Index] = 0;
		}
	}
	else if ( (RotDiff > 0) == (OldRotDiff[Index] > 0) )
	{
		if (ShouldLagRot())
		{
			MaxDiff = FMin(1, Abs(RotDiff)/(12000*DeltaTime)) * MaxDiff;
			if ( OldMaxDiff[Index] != 0 )
				MaxDiff = FMax(OldMaxDiff[Index], MaxDiff);

			OldMaxDiff[Index] = MaxDiff;
			LeadMag = (NewValue > LastValue) ? -1* MaxDiff : MaxDiff;
		}
		else
		{
			LeadMag = 0;
		}
		if ( DeltaTime < 1/RotChgSpeed )
		{
			LeadMag = (1.0 - RotChgSpeed*DeltaTime)*OldLeadMag[Index] + RotChgSpeed*DeltaTime*LeadMag;
		}
		else
		{
			LeadMag = 0;
		}
	}
	else
	{
		LeadMag = 0;
		OldMaxDiff[Index] = 0;
		if ( DeltaTime < 1/ReturnChgSpeed )
		{
			LeadMag = (1 - ReturnChgSpeed*DeltaTime)*OldLeadMag[Index] + ReturnChgSpeed*DeltaTime*LeadMag;
		}
	}
	OldLeadMag[Index] = LeadMag;
	OldRotDiff[Index] = RotDiff;

	return NewValue + LeadMag;
}

/**
 * called every time owner takes damage while holding this weapon - used by shield gun
 */
function AdjustPlayerDamage( out int Damage, Controller InstigatedBy, Vector HitLocation,
			     out Vector Momentum, class<DamageType> DamageType)
{
}

/*********************************************************************************************
 * AI interface
 *********************************************************************************************/

/**
 * Returns a weight reflecting the desire to use the
 * given weapon, used for AI and player best weapon
 * selection.
 *
 * @param	Weapon W
 * @return	Weapon rating (range -1.f to 1.f)
 */
simulated function float GetWeaponRating()
{
	if ( (Instigator == None) || (UTBot(Instigator.Controller) == None) || !HasAnyAmmo() )
		CurrentRating = Priority;
	else
		CurrentRating = UTBot(Instigator.Controller).RateWeapon(self);

	return CurrentRating;
}

/**
 * return false if out of range, can't see target, etc.
 */
function bool CanAttack(Actor Other)
{
	local float Dist, CheckDist, OtherHeight;
	local vector HitLocation, HitNormal, projStart, TargetLoc;
	local Actor HitActor, TestActor;
	local class<Projectile> ProjClass;
	local int i;
	local UTBot B;

	if (Instigator == None || Instigator.Controller == None)
	{
		return false;
	}

	// check that target is within range
	Dist = VSize(Instigator.Location - Other.Location);
	if (Dist > MaxRange())
	{
		return false;
	}

	projStart = bInstantHit ? InstantFireStartTrace() : GetPhysicalFireStartLoc();

	// check that can see target
	B = UTBot(Instigator.Controller);
	if ( UTOnslaughtPowerNode(Other) != None )
	{
		if ( FastTrace(Other.GetTargetLocation(B.Pawn, false), projStart) )
		{
			B.bTargetAlternateLoc = false;
		}
		else if ( Instigator.Controller.LineOfSightTo(Other, projStart) )
		{
			B.bTargetAlternateLoc = true;
		}	
		else
		{
			return false;
		}		
	}
	else if (Instigator.Controller.LineOfSightTo(Other, projStart))
	{
		if (B != None && B.Focus == Other)
		{
			B.bTargetAlternateLoc = false;
		}
	}
	else
	{
		if (!Other.bHasAlternateTargetLocation || !Instigator.Controller.LineOfSightTo(Other, projStart, true))
		{
			return false;
		}

		if (B != None && B.Focus == Other)
		{
			B.bTargetAlternateLoc = true;
		}
	}

	if ( !bInstantHit )
	{
		ProjClass = GetProjectileClass();
		if ( ProjClass == None )
		{
			for (i = 0; i < WeaponProjectiles.length; i++)
			{
				ProjClass = WeaponProjectiles[i];
				if (ProjClass != None)
				{
					break;
				}
			}
		}
		if (ProjClass == None)
		{
			WarnInternal("No projectile class for "$self);
			CheckDist = 300;
		}
		else
		{
			CheckDist = FMax(CheckDist, 0.5 * ProjClass.default.Speed);
			CheckDist = FMax(CheckDist, 300);
			CheckDist = FMin(CheckDist, VSize(Other.Location - Location));
		}
	}

	// check that would hit target, and not a friendly
	TargetLoc = Other.GetTargetLocation(Instigator);
	if ( Pawn(Other) != None )
	{
		OtherHeight = Pawn(Other).GetCollisionHeight();
		TargetLoc.Z += 0.9 * OtherHeight;
	}

	// perform the trace
	if ( bInstantHit )
	{
		HitActor = GetTraceOwner().Trace(HitLocation, HitNormal, TargetLoc, projStart, true,,, TRACEFLAG_Bullet);
	}
	else
	{
		// for non-instant hit, ignore actors beyond a small distance that may move out of the way
		foreach GetTraceOwner().TraceActors( class'Actor', TestActor, HitLocation, HitNormal,
							TargetLoc, projStart,,, TRACEFLAG_Bullet )
		{
			if ( (TestActor.bBlockActors || TestActor.bProjTarget) &&
				(VSize(HitLocation - projStart) <= CheckDist || TestActor.IsStationary()) )
			{
				HitActor = TestActor;
				break;
			}
		}
	}

	if ( HitActor == None || HitActor == Other || (!HitActor.IsA('Pawn') && !HitActor.IsA('UTGameObjective'))
		|| !WorldInfo.GRI.OnSameTeam(Instigator, HitActor) )
	{
		return true;
	}

	return false;
}

/**
 * tell the bot how much it wants this weapon pickup
 * called when the bot is trying to decide which inventory pickup to go after next
 */
static function float BotDesireability(Actor PickupHolder, Pawn P, Controller C)
{
	local UTWeapon AlreadyHas;
	local float desire;
	local UTBot Bot;

	Bot = UTBot(C);
	if ( Bot == None )
		return 0;

	if ( UTWeaponLocker(PickupHolder) != None )
		return UTWeaponLocker(PickupHolder).BotDesireability(P, C);

	// bots adjust their desire for their favorite weapons
	desire = Default.MaxDesireability;
	if (ClassIsChildOf(default.Class, Bot.FavoriteWeapon))
	{
		desire *= 1.5;
	}

	// see if bot already has a weapon of this type
	AlreadyHas = UTWeapon(P.FindInventoryType(default.class));
	if ( AlreadyHas != None )
	{
		if ( Bot.bHuntPlayer )
			return 0;

		// can't pick it up if weapon stay is on
		if ( (UTWeaponPickupFactory(PickupHolder) != None) && !UTWeaponPickupFactory(PickupHolder).AllowPickup(Bot) )
			return 0;

		if ( AlreadyHas.AmmoMaxed(0) )
			return 0.25 * desire;

		// bot wants this weapon for the ammo it holds
		if( AlreadyHas.AmmoCount > 0 )
		{
			if ( Default.AmmoPickupClass == None )
				return 0.05;
			else
				return FMax( 0.25 * desire,
						Default.AmmoPickupClass.Default.MaxDesireability
						* FMin(1, 0.15 * AlreadyHas.MaxAmmoCount/AlreadyHas.AmmoCount) );
		}
		else
			return 0.05;
	}
	if ( Bot.bHuntPlayer && (desire * 0.833 < P.Weapon.AIRating - 0.1) )
		return 0;

	// incentivize bot to get this weapon if it doesn't have a good weapon already
	if ( (P.Weapon == None) || (P.Weapon.AIRating < 0.5) )
		return 2*desire;

	return desire;
}

/**
 * CanHeal()
 * used by bot AI should return true if this weapon is able to heal Other
 */
function bool CanHeal(Actor Other)
{
	return false;
}

/** used by bot AI to get the optimal range for shooting Target
 * can be called on friendly Targets if trying to heal it
 */
function float GetOptimalRangeFor(Actor Target)
{
	return MaxRange();
}

function FireHack();

/**
 * tells AI that it needs to release the fire button for this weapon to do anything
 */
function bool FireOnRelease()
{
	return ( ShouldFireOnRelease[CurrentFireMode] != 0 );
}

/**
 * return true if recommend jumping while firing to improve splash damage (by shooting at feet)
 * true for R.L., for example
 */
function bool SplashJump()
{
    return bSplashJump;
}

/**
 * called by AI when camping/defending
 * return true if it is useful to fire this weapon even though bot doesn't have a target
 * for example, a weapon that launches turrets or mines
 */
function bool ShouldFireWithoutTarget()
{
	return false;
}

/**
 * BestMode()
 * choose between regular or alt-fire
 */
function byte BestMode()
{
	local byte Best;
	if ( IsFiring() )
		return CurrentFireMode;

	if ( FRand() < 0.5 )
		Best = 1;

	if ( Best < bZoomedFireMode.Length && bZoomedFireMode[Best] != 0 )
		return 0;
	else
		return Best;
}

/** @return whether this is a charging weapon and is fully charged up */
function bool IsFullyCharged()
{
	return false;
}

/**
 * ReadyToFire()
 * called by NPC firing weapon.
 * bFinished should only be true if called from the Finished() function
 */
simulated function bool ReadyToFire(bool bFinished)
{
	return false;
}

simulated function bool StillFiring(byte FireMode)
{
	if ( UTBot(Instigator.Controller) != None )
	{
		ClearPendingFire(0);
		ClearPendingFire(1);
		UTBot(Instigator.Controller).WeaponFireAgain(true);
	}

	return super.StillFiring(FireMode);
}

/*********************************************************************************************
 * Ammunition / Inventory
 *********************************************************************************************/

/**
 * Consumes some of the ammo
 */
function ConsumeAmmo( byte FireModeNum )
{
	LastWeaponFireTime = WorldInfo.TimeSeconds;

	// Subtract the Ammo
	AddAmmo(-ShotCost[FireModeNum]);
}

/**
 * This function is used to add ammo back to a weapon.  It's called from the Inventory Manager
 */
function int AddAmmo( int Amount )
{
	AmmoCount = Clamp(AmmoCount + Amount,0,MaxAmmoCount);
	// check for infinite ammo
	if (AmmoCount <= 0 && (UTInventoryManager(InvManager) == None || UTInventoryManager(InvManager).bInfiniteAmmo))
	{
		AmmoCount = MaxAmmoCount;
	}

	return AmmoCount;
}

/**
 * Returns true if the ammo is maxed out
 */
simulated function bool AmmoMaxed(int mode)
{
	return (AmmoCount >= MaxAmmoCount);
}

/**
 * This function checks to see if the weapon has any ammo available for a given fire mode.
 *
 * @param	FireModeNum		- The Fire Mode to Test For
 * @param	Amount			- [Optional] Check to see if this amount is available.  If 0 it will default to checking
 *							  for the ShotCost
 */
simulated function bool HasAmmo( byte FireModeNum, optional int Amount )
{
	if (Amount==0)
		return (AmmoCount >= ShotCost[FireModeNum]);
	else
		return ( AmmoCount >= Amount );
}

/**
 * returns true if this weapon has any ammo
 */
simulated function bool HasAnyAmmo()
{
	return ( ( AmmoCount > 0 ) || (ShotCost[0]==0 && ShotCost[1]==0) );
}
/**
 * This function retuns how much of the clip is empty.
 */
simulated function float DesireAmmo(bool bDetour)
{
	return (1.f - float(AmmoCount)/MaxAmmoCount);
}

/**
 * Returns true if the current ammo count is less than the default ammo count
 */
simulated function bool NeedAmmo()
{
	return ( AmmoCount < Default.AmmoCount );
}

/**
 * Cheat Help function the loads out the weapon
 *
 * @param 	bUseWeaponMax 	- [Optional] If true, this function will load out the weapon
 *							  with the actual maximum, not 999
 */
simulated function Loaded(optional bool bUseWeaponMax)
{
	if (bUseWeaponMax)
		AmmoCount = MaxAmmoCount;
	else
		AmmoCount = 999;
}

function bool DenyPickupQuery(class<Inventory> ItemClass, Actor Pickup)
{
	local DroppedPickup DP;

	// By default, you can only carry a single item of a given class.
	if ( ItemClass == class )
	{
		DP = DroppedPickup(Pickup);
		if (DP != None)
		{
			if ( DP.Instigator == Instigator )
			{
				// weapon was dropped by this player - disallow pickup
				return true;
			}
			// take the ammo that the dropped weapon has
			AddAmmo(UTWeapon(DP.Inventory).AmmoCount);
			DP.PickedUpBy(Instigator);
			AnnouncePickup(Instigator);
		}
		else
		{
			// add the ammo that the pickup should give us, then tell it to respawn
			AddAmmo(default.AmmoCount);
			Pickup.PickedUpBy(Instigator);
			AnnouncePickup(Instigator);
		}
		return true;
	}

	return false;
}


/**
 * Called when the weapon runs out of ammo during firing
 */
simulated function WeaponEmpty()
{

	if (bDebugWeapon)
	{
		LogInternal("---"@self$"."$GetStateName()$".WeaponEmpty()"@IsFiring()@Instigator@Instigator.IsLocallyControlled());
		ScriptTrace();
	}


	// If we were firing, stop
	if ( IsFiring() )
	{
		GotoState('Active');
	}

	if ( Instigator != none && Instigator.IsLocallyControlled() )
	{
		Instigator.InvManager.SwitchToBestWeapon( true );
	}
}

/**
 * @returns false if the weapon isn't ready to be fired.  For example, if it's in the Inactive/WeaponPuttingDown states.
 */
simulated function bool bReadyToFire()
{
	return true;
}

/*********************************************************************************************
 * Firing
 *********************************************************************************************/

/**
* @returns position of trace start for instantfire()
*/
simulated function vector InstantFireStartTrace()
{
	return Instigator.GetWeaponStartTraceLocation();
}

/**
* @returns end trace position for instantfire()
*/
simulated function vector InstantFireEndTrace(vector StartTrace)
{
	return StartTrace + vector(GetAdjustedAim(StartTrace)) * GetTraceRange();
}

/**
 * Performs an 'Instant Hit' shot.
 * Also, sets up replication for remote clients,
 * and processes all the impacts to deal proper damage and play effects.
 *
 * Network: Local Player and Server
 */
simulated function InstantFire()
{
	local vector StartTrace, EndTrace;
	local Array<ImpactInfo>	ImpactList;
	local ImpactInfo RealImpact, NearImpact;
	local int i, FinalImpactIndex;

	// define range to use for CalcWeaponFire()
	StartTrace = InstantFireStartTrace();
	EndTrace = InstantFireEndTrace(StartTrace);
	bUsingAimingHelp = false;
	// Perform shot
	RealImpact = CalcWeaponFire(StartTrace, EndTrace, ImpactList);
	FinalImpactIndex = ImpactList.length - 1;

	if (FinalImpactIndex >= 0 && (ImpactList[FinalImpactIndex].HitActor == None || !ImpactList[FinalImpactIndex].HitActor.bProjTarget))
	{
		// console aiming help
		NearImpact = InstantAimHelp(StartTrace, EndTrace, RealImpact);
		if ( NearImpact.HitActor != None )
		{
			bUsingAimingHelp = true;
			ImpactList[FinalImpactIndex] = NearImpact;
		}
	}

	for (i = 0; i < ImpactList.length; i++)
	{
		ProcessInstantHit(CurrentFireMode, ImpactList[i]);
	}

	if (Role == ROLE_Authority)
	{
		// Set flash location to trigger client side effects.
		// if HitActor == None, then HitLocation represents the end of the trace (maxrange)
		// Remote clients perform another trace to retrieve the remaining Hit Information (HitActor, HitNormal, HitInfo...)
		// Here, The final impact is replicated. More complex bullet physics (bounce, penetration...)
		// would probably have to run a full simulation on remote clients.
		if ( NearImpact.HitActor != None )
		{
			SetFlashLocation(NearImpact.HitLocation);
		}
		else
		{
			SetFlashLocation(RealImpact.HitLocation);
		}
	}
}

/**
  * Look for "near miss" of target within UTPC.AimHelpModifier() * AimingHelpRadius
  * Return that target as a hit if it was a near miss
  */
simulated function ImpactInfo InstantAimHelp(vector StartTrace, vector EndTrace, ImpactInfo RealImpact)
{
	local ImpactInfo NearImpact;
	local Pawn ShotTarget;
	local UTPlayerController UTPC;
	local float AimHelpDist;
	local vector ClosestPoint;
	local bool bProvidedAimingHelp;
	local UTPawn UTP;
	local int i;
	local UTProj_SpiderMineBase Spider;

	NearImpact.HitActor = None;
	UTPC = (Instigator != None) ? UTPlayerController(Instigator.Controller) : None;
	if ( (UTPC != None) && UTPC.AimingHelp(true) && (AimingHelpRadius[Min(CurrentFireMode,1)] > 0.0) )
	{
		if ( UTPC.ShotTarget != None ) 
	{
		ShotTarget = UTPC.ShotTarget;
			// no aiming help shooting at giants
			if ( (UTPawn(ShotTarget) == None) || !UTPawn(ShotTarget).IsHero() )
			{
		if ( RealImpact.HitActor != None )
		{
			EndTrace = RealImpact.HitLocation;
		}
		if ( ((EndTrace - ShotTarget.Location) Dot (ShotTarget.Location - StartTrace)) > 0 )
		{
			PointDistToLine(ShotTarget.Location, EndTrace - StartTrace, StartTrace, ClosestPoint);
			AimHelpDist = UTPC.AimHelpModifier() * AimingHelpRadius[Min(CurrentFireMode,1)];

			// reduce help if target isn't moving
			if ( ShotTarget.Velocity == vect(0,0,0) )
				AimHelpDist *= 0.5;

			// accept near miss if within AimHelpDist
			if ( (abs(ClosestPoint.Z - ShotTarget.Location.Z) < ShotTarget.CylinderComponent.CollisionHeight + AimHelpDist)
				&& (VSize2D(ClosestPoint - ShotTarget.Location) < ShotTarget.CylinderComponent.CollisionRadius + AimHelpDist) )
			{
				NearImpact.HitActor = ShotTarget;
				NearImpact.HitLocation = ClosestPoint;
				NearImpact.HitNormal = Normal(EndTrace - StartTrace);
						bProvidedAimingHelp = true;
					}
				}
			}
		}
		if ( !bProvidedAimingHelp )
		{
			UTP = UTPawn(Instigator);
			if ( (UTP != None) && (UTP.SpiderChasers.Length > 0) )
			{
				for ( i=0; i<UTP.SpiderChasers.Length; i++ )
				{
					Spider = UTP.SpiderChasers[i];
					if ( (Spider != None) && !Spider.bDeleteMe && (Spider.TargetPawn == UTP) )
					{
						if ( RealImpact.HitActor != None )
						{
							EndTrace = RealImpact.HitLocation;
						}
						if ( ((EndTrace - Spider.Location) Dot (Spider.Location - StartTrace)) > 0 )
						{
							PointDistToLine(Spider.Location, EndTrace - StartTrace, StartTrace, ClosestPoint);
							AimHelpDist = UTPC.AimHelpModifier() * AimingHelpRadius[Min(CurrentFireMode,1)];

							// accept near miss if within AimHelpDist
							if ( (abs(ClosestPoint.Z - Spider.Location.Z) < Spider.CylinderComponent.CollisionHeight + AimHelpDist)
								&& (VSize2D(ClosestPoint - Spider.Location) < Spider.CylinderComponent.CollisionRadius + AimHelpDist) )
							{
								NearImpact.HitActor = Spider;
								NearImpact.HitLocation = ClosestPoint;
								NearImpact.HitNormal = Normal(EndTrace - StartTrace);
								break;
							}
						}
					}
				}
			}
		}
	}
	return NearImpact;
}

/**
 * Fires a projectile.
 * Spawns the projectile, but also increment the flash count for remote client effects.
 * Network: Local Player and Server
 */
simulated function Projectile ProjectileFire()
{
	local vector		RealStartLoc;
	local Projectile	SpawnedProjectile;

	// tell remote clients that we fired, to trigger effects
	IncrementFlashCount();

	if( Role == ROLE_Authority )
	{
		// this is the location where the projectile is spawned.
		RealStartLoc = GetPhysicalFireStartLoc();

		// Spawn projectile
		SpawnedProjectile = Spawn(GetProjectileClass(),,, RealStartLoc);
		if( SpawnedProjectile != None && !SpawnedProjectile.bDeleteMe )
		{
			SpawnedProjectile.Init( Vector(GetAdjustedAim( RealStartLoc )) );
		}

		// Return it up the line
		return SpawnedProjectile;
	}

	return None;
}

simulated function ProcessInstantHit( byte FiringMode, ImpactInfo Impact )
{
	local bool bFixMomentum;

	if (Impact.HitActor != None && !Impact.HitActor.bStatic && (Impact.HitActor != Instigator) )
	{
		if ( Impact.HitActor.Role == ROLE_Authority && Impact.HitActor.bProjTarget
			&& !WorldInfo.GRI.OnSameTeam(Instigator, Impact.HitActor)
			&& Impact.HitActor.Instigator != Instigator
			&& PhysicsVolume(Impact.HitActor) == None )
		{
			HitEnemy++;
			LastHitEnemyTime = WorldInfo.TimeSeconds;
		}
		if ( (UTPawn(Impact.HitActor) == None) && (InstantHitMomentum[FiringMode] == 0) )
		{
			InstantHitMomentum[FiringMode] = 1;
			bFixMomentum = true;
		}
		Super.ProcessInstantHit(FiringMode, Impact);
		if (bFixMomentum)
		{
			InstantHitMomentum[FiringMode] = 0;
		}
	}
}

/*********************************************************************************************
 * Zooming Functions
 *********************************************************************************************/

/**
 * Returns true if we are currently zoomed
 */

simulated function EZoomState GetZoomedState()
{
	local PlayerController PC;
	PC = PlayerController(Instigator.Controller);
	if ( PC != none && PC.FOVAngle != PC.DefaultFOV )
	{
		if ( PC.FOVAngle == PC.DesiredFOV )
		{
			return ZST_Zoomed;
		}

		return ( PC.FOVAngle < PC.DesiredFOV ) ? ZST_ZoomingOut : ZST_ZoomingIn;
	}
	return ZST_NotZoomed;
}

/**
 * We Override beginfire to add support for zooming.  Should only be called from BeginFire()
 *
 * @param	FireModeNum 	The current Firing Mode
 *
 * @returns true we should abort the BeginFire call
 */
simulated function bool CheckZoom(byte FireModeNum)
{
	local UTPlayerController PC;
	PC = UTPlayerController(Instigator.Controller);
	if (PC != None && LocalPlayer(PC.Player) != none && FireModeNum < bZoomedFireMode.Length && bZoomedFireMode[FireModeNum] != 0)
	{
		if (GetZoomedState() == ZST_Zoomed)
		{
			EndZoom(PC);
			EndFire(FireModeNum);		// Kill this fire command
			DemoEndFire(FireModeNum);
			return true;
		}
		else if ( GetZoomedState() == ZST_NotZoomed )
		{
			StartZoom(PC);
			ZoomedFireModeNum = FireModeNum;
		}
	}

	return false;
}

/** Called when zooming starts
 * @param PC - cast of Instigator.Controller for convenience
 */
simulated function StartZoom(UTPlayerController PC)
{
	PC.StartZoom(ZoomedTargetFOV, ZoomedRate);
	PlaySound(ZoomInSound, true);
}

/** Called when zooming ends
 * @param PC - cast of Instigator.Controller for convenience
 */
simulated function EndZoom(UTPlayerController PC)
{
	PC.EndZoom();
	PlaySound(ZoomOutSound, true);
}


client reliable simulated function ClientEndFire(byte FireModeNum)
{
	if (Role != ROLE_Authority)
	{
		ClearPendingFire(FireModeNum);
		EndFire(FireModeNum);

		// If this function was called locally, instead of replicated, then the demorec driver needs to record it
		if (GetNetFuncName() != 'ClientEndFire')
			DemoEndFire(FireModeNum);
	}
}

/**
 * We Override endfire to add support for zooming
 */

simulated function EndFire(Byte FireModeNum)
{
	local UTPlayerController PC;

	// Don't bother performing if this is a dedicated server

	if (WorldInfo.NetMode != NM_DedicatedServer && Instigator != None)
	{
		PC = UTPlayerController(Instigator.Controller);
		if (PC != None && LocalPlayer(PC.Player) != none && FireModeNum < bZoomedFireMode.Length && bZoomedFireMode[FireModeNum] != 0 )
		{
			PC.StopZoom();
		}
	}
	super.EndFire(FireModeNum);
}

/**
 * Don't send a zoomed fire mode in to a firing state
 */
simulated function SendToFiringState( byte FireModeNum )
{

	if (bDebugWeapon)
	{
		LogInternal("---"@self$"."$GetStateName()$".SendToFiringState()");
		ScriptTrace();
	}

	// Don't send if it's a zoomed firemode

	if (FireModeNum < bZoomedFireMode.Length && bZoomedFireMode[FireModeNum] != 0 )
	{
		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".SendToFiringState() Quick Exit");
		}
		return;
	}

	super.SendToFiringState(FireModeNum);
}

reliable client function ClientWeaponSet( bool bOptionalSet )
{
	local PlayerController PC;

	if (bDebugWeapon)
	{
		LogInternal("---"@self$"."$GetStateName()$".ClientWeaponSet()");
	}

	if (Instigator != None)
	{
		PC = PlayerController(Instigator.Controller);
		if ( PC != None && LocalPlayer(PC.Player) != none )
		{
			PC.FOVAngle = PC.DefaultFOV;
		}
	}
	Super.ClientWeaponSet(bOptionalSet);
}

/**
 * Deactiveate Spawn Protection
 */
simulated function FireAmmunition()
{
	if (CurrentFireMode >= bZoomedFireMode.Length || bZoomedFireMode[CurrentFireMode] == 0)
	{
		Super.FireAmmunition();

		if (UTPawn(Instigator) != None)
		{
			UTPawn(Instigator).DeactivateSpawnProtection();
		}

		InvManager.OwnerEvent('FiredWeapon');
	}
}


/*********************************************************************************************
 * state Inactive
 * This state is the default state.  It needs to make sure Zooming is reset when entering/leaving
 *********************************************************************************************/

auto simulated state Inactive
{
	simulated function BeginState(name PreviousStateName)
	{
		local PlayerController PC;

		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".BeginState("$PreviousStateName$")");
		}

		if ( Instigator != None )
		{
		  PC = PlayerController(Instigator.Controller);
		  if ( PC != None && LocalPlayer(PC.Player)!= none )
		  {
			  PC.FOVAngle = PC.DefaultFOV;
		  }
		}

		Super.BeginState(PreviousStateName);
	}

	simulated function EndState(Name NextStateName)
	{
		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".EndState("$NextStateName$")");
		}

		Super.EndState(NextStateName);
	}

	/**
	 * @returns false if the weapon isn't ready to be fired.  For example, if it's in the Inactive/WeaponPuttingDown states.
	 */
	simulated function bool bReadyToFire()
	{
		return false;
	}
}


/*********************************************************************************************
 * State WeaponFiring
 * This is the default Firing State.  It's performed on both the client and the server.
 *********************************************************************************************/
simulated state WeaponFiring
{
	simulated function EndState(Name NextStateName)
	{
		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".EndState("$NextStateName$")");
		}
		super.EndState(NextStateName);
	}

	simulated function BeginState(Name PrevStateName)
	{
		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".BeginState("$PrevStateName$")");
		}
		super.BeginState(PrevStateName);
	}

	simulated event ReplicatedEvent(name VarName)
	{
		if ( VarName == 'AmmoCount' && !HasAnyAmmo() )
		{
			return;
		}

		Global.ReplicatedEvent(VarName);
	}

	/**
	 * We override BeginFire() so that we can check for zooming and/or empty weapons
	 */

	simulated function BeginFire( Byte FireModeNum )
	{
		if ( CheckZoom(FireModeNum) )
		{
			return;
		}

		Global.BeginFire(FireModeNum);

		// No Ammo, then do a quick exit.
		if( !HasAmmo(FireModeNum) )
		{
			WeaponEmpty();
			return;
		}
	}

	/**
	 * When we are in the firing state, don't allow for a pickup to switch the weapon
	 */

	simulated function bool DenyClientWeaponSet()
	{
		return true;
	}


}

/*********************************************************************************************
 * state WeaponEquipping
 * This state is entered when a weapon is becomeing active (ie: Being brought up)
 *********************************************************************************************/

simulated state WeaponEquipping
{
	/**
	 * We want to being this state by setting up the timing and then notifying the pawn
	 * that the weapon has changed.
	 */

	simulated function BeginState(Name PreviousStateName)
	{
		super.BeginState(PreviousStateName);

		// Notify the pawn that it's weapon has changed.
		//SetupArmsAnim();

		PerformWeaponChange();
	}

	simulated function bool TryPutDown()
	{
		// We want the abort to be the same amount of time as
		// we have already spent equipping

		SwitchAbortTime = PutDownTime * GetTimerCount('WeaponEquipped') / GetTimerRate('WeaponEquipped');
		GotoState('WeaponAbortEquip');

		return true;
	}

	simulated function EndState(Name NextStateName)
	{
		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".EndState("$NextStateName$")");
		}


		if (SkeletalMeshComponent(Mesh) == none || WeaponEquipAnim == '')
		{
			Mesh.SetRotation(Default.Mesh.Rotation);
		}
		ClearTimer('WeaponEquipped');
	}
}

simulated state WeaponAbortEquip
{
	simulated function BeginState(name PrevStateName)
	{
		local AnimNodeSequence AnimNode;
		local float Rate;

		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".EndState("$PrevStateName$")");
		}


		// Time the abort
		SetTimer(FMax(SwitchAbortTime, 0.01),, 'WeaponEquipAborted');

		if (WorldInfo.NetMode != NM_DedicatedServer)
		{
			// play anim
			if (WeaponEquipAnim != '')
			{
				AnimNode = GetWeaponAnimNodeSeq();
				if (AnimNode != None && AnimNode.AnimSeq != None)
				{
					AnimNode.SetAnim(WeaponPutDownAnim);
					Rate = AnimNode.AnimSeq.SequenceLength / PutDownTime;
					AnimNode.PlayAnim(false, Rate, AnimNode.AnimSeq.SequenceLength - SwitchAbortTime * Rate);
				}

			}
			if(ArmsEquipAnim != '' && ArmsAnimSet != none && Instigator != none /* && Instigator.IsLocallyControlled() && Instigator.IsHumanControlled() */)
			{
				AnimNode = GetArmAnimNodeSeq();
				if (AnimNode != None && AnimNode.AnimSeq != None)
				{
					AnimNode.SetAnim(ArmsPutDownAnim);
					Rate = AnimNode.AnimSeq.SequenceLength/PutDownTime;
					AnimNode.PlayAnim(false, Rate, AnimNode.AnimSeq.SequenceLength - SwitchAbortTime * Rate);
				}
			}
		}
	}

	simulated function WeaponEquipAborted()
	{
		// This weapon is down, remove it from the mesh
		DetachWeapon();

		// Put weapon to sleep
		//@warning: must be before ChangedWeapon() because that can reactivate this weapon in some cases
		GotoState('Inactive');

		// switch to pending weapon
		InvManager.ChangedWeapon();
	}

	simulated function EndState(Name NextStateName)
	{
		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".EndState("$NextStateName$")");
		}

		ClearTimer('WeaponEquipAborted');
		Super.EndState(NextStateName);
	}
}

/**
  * Force streamed textures to be loaded.  Used to get MIPS streamed in before weapon comes up
  * @PARAM bForcePreload if true causes streamed textures to be force loaded, if false, clears force loading
  */
simulated function PreloadTextures(bool bForcePreload)
{
	if ( UTSkeletalMeshComponent(Mesh) != None )
	{
		UTSkeletalMeshComponent(Mesh).PreloadTextures(bForcePreload, WorldInfo.TimeSeconds + 2);
	}
}

/** called on both Instigator's current weapon and its pending weapon (if they exist)
 * @return whether Instigator is allowed to switch to NewWeapon
 */
simulated function bool AllowSwitchTo(Weapon NewWeapon)
{
	return true;
}

/**
 * When attempting to put the weapon down, look to see if our MinReloadPct has been met.  If so just put it down
 */
simulated function bool TryPutDown()
{
	local float MinTimerTarget;
	local float TimerCount;

	bWeaponPutDown = true;

	if (!IsTimerActive('RefireCheckTimer'))
	{
		PutDownWeapon();
	}
	else
	{
		MinTimerTarget = GetTimerRate('RefireCheckTimer') * MinReloadPct[CurrentFireMode];
		TimerCount = GetTimerCount('RefireCheckTimer');

		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".TryPutDown"@TimerCount@MinTimerTarget);
			ScriptTrace();
		}


		if (TimerCount >= MinTimerTarget)
		{
			PutDownWeapon();
		}
		else
		{
			// Shorten the wait time
			SetTimer(MinTimerTarget - TimerCount, false, 'FiringPutDownWeapon');
		}
	}

	return true;
}

simulated function FiringPutDownWeapon()
{
	if (bWeaponPutDown)
	{
		PutDownWeapon();
	}
}

simulated function vector GetPhysicalFireStartLoc(optional vector AimDir)
{
	local UTPlayerController PC;
	local vector FireStartLoc, HitLocation, HitNormal, FireDir, FireEnd, ProjBox;
	local Actor HitActor;
	local rotator FireRot;
	local class<Projectile> FiredProjectileClass;
	local int TraceFlags;

	if( Instigator != none )
	{
		PC = UTPlayerController(Instigator.Controller);

		FireRot = Instigator.GetViewRotation();
		FireDir = vector(FireRot);
		if (PC == none || PC.bCenteredWeaponFire || PC.WeaponHand == HAND_Centered || PC.WeaponHand == HAND_Hidden)
		{
			FireStartLoc = Instigator.GetPawnViewLocation() + (FireDir * FireOffset.X);
		}
		else if (PC.WeaponHand == HAND_Left)
		{
			FireStartLoc = Instigator.GetPawnViewLocation() + ((FireOffset * vect(1,-1,1)) >> FireRot);
		}
		else
		{
			FireStartLoc = Instigator.GetPawnViewLocation() + (FireOffset >> FireRot);
		}

		if ( (PC != None) || (CustomTimeDilation < 1.0) )
		{
			FiredProjectileClass = GetProjectileClass();
			if ( FiredProjectileClass != None )
			{
				FireEnd = FireStartLoc + FireDir * ProjectileSpawnOffset;
				TraceFlags = bCollideComplex ? TRACEFLAG_Bullet : 0;
				if ( FiredProjectileClass.default.CylinderComponent.CollisionRadius > 0 )
				{
					FireEnd += FireDir * FiredProjectileClass.default.CylinderComponent.Translation.X;
					ProjBox = FiredProjectileClass.default.CylinderComponent.CollisionRadius * vect(1,1,0);
					ProjBox.Z = FiredProjectileClass.default.CylinderComponent.CollisionHeight;
					HitActor = Trace(HitLocation, HitNormal, FireEnd, Instigator.Location, true, ProjBox,,TraceFlags);
					if ( HitActor == None )
					{
						HitActor = Trace(HitLocation, HitNormal, FireEnd, FireStartLoc, true, ProjBox,,TraceFlags);
					}
					else
					{
						FireStartLoc = Instigator.Location - FireDir*FiredProjectileClass.default.CylinderComponent.Translation.X;
						FireStartLoc.Z = FireStartLoc.Z + FMin(Instigator.EyeHeight, Instigator.CylinderComponent.CollisionHeight - FiredProjectileClass.default.CylinderComponent.CollisionHeight - 1.0);
						return FireStartLoc;
					}
				}
				else
				{
					HitActor = Trace(HitLocation, HitNormal, FireEnd, FireStartLoc, true, vect(0,0,0),,TraceFlags);
				}
				return (HitActor == None) ? FireEnd : HitLocation - 3*FireDir;
			}
		}
		return FireStartLoc;
	}

	return Location;
}

/** @return the location + offset from which to spawn effects (primarily tracers) */
simulated function vector GetEffectLocation()
{
	local vector SocketLocation;

	if (GetHand() == HAND_Hidden)
	{
		SocketLocation = Instigator.Location;
	}
	else if (SkeletalMeshComponent(Mesh) != None && EffectSockets[CurrentFireMode] != '')
	{
		if (!SkeletalMeshComponent(Mesh).GetSocketWorldLocationAndrotation(EffectSockets[CurrentFireMode], SocketLocation))
		{
			SocketLocation = Location;
		}
	}
	else if (Mesh != None)
	{
		SocketLocation = Mesh.Bounds.Origin + (vect(45,0,0) >> Rotation);
	}
	else
	{
		SocketLocation = Location;
	}

 	return SocketLocation;
}


simulated function RefireCheckTimer();

simulated function SetupArmsAnim()
{
	local UTPawn UTP;
	UTP = UTPawn(Instigator);
	if (UTP != None)
	{
		UTP.ArmsMesh[0].StopAnim(); // let's stop anything already going.
		if (ArmsAnimSet != None)
		{
			UTP.ArmsMesh[0].AnimSets[1] = ArmsAnimSet;
			UTP.ArmsMesh[0].SetHidden(false);
			UTP.ArmsMesh[0].SetLightEnvironment(UTP.LightEnvironment);
			if (UTP.ArmsOverlay[0] != None)
			{
				UTP.ArmsOverlay[0].SetHidden(false);
			}
		}
		else
		{
			UTP.ArmsMesh[0].SetHidden(true);
			UTP.ArmsMesh[1].SetHidden(true);
			if (UTP.ArmsOverlay[0] != None)
			{
				UTP.ArmsOverlay[0].SetHidden(true);
				UTP.ArmsOverlay[1].SetHidden(true);
			}
		}
	}
}
simulated state WeaponPuttingDown
{
	simulated function BeginState( Name PreviousStateName )
	{
		local UTPlayerController PC;

		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".BeginState("$PreviousStateName$")");
		}


		PC = UTPlayerController(Instigator.Controller);
		if (PC != None && LocalPlayer(PC.Player) != none )
		{
			PC.EndZoom();
		}

		TimeWeaponPutDown();
		bWeaponPutDown = false;
	}

	simulated function EndState(Name NextStateName)
	{
		if (bDebugWeapon)
		{
			LogInternal("---"@self$"."$GetStateName()$".BeginState("$NextStateName$")");
		}


		Super.EndState(NextStateName);
		if (SkeletalMeshComponent(Mesh) == none || WeaponEquipAnim == '')
		{
			Mesh.SetRotation(Default.Mesh.Rotation);
		}
	}

	simulated function Activate();

	/**
	 * @returns false if the weapon isn't ready to be fired.  For example, if it's in the Inactive/WeaponPuttingDown states.
	 */
	simulated function bool bReadyToFire()
	{
		return false;
	}
}

simulated function AnimNodeSequence GetArmAnimNodeSeq()
{
	local UTPawn P;

	P = UTPawn(Instigator);
	if (P != None && P.ArmsMesh[0] != None)
	{
		return AnimNodeSequence(P.ArmsMesh[0].Animations);
	}

	return None;
}

function GivenTo(Pawn NewOwner, bool bDoNotActivate)
{
	super(Inventory).GivenTo(NewOwner, bDoNotActivate);

	if (bDebugWeapon)
	{
		LogInternal("---"@self$"."$GetStateName()$".GivenTo("$NewOwner@bDoNotActivate$")");
	}
}

simulated event Destroyed()
{
	if (Instigator != None && Instigator.IsHumanControlled() && Instigator.IsLocallyControlled())
	{
		PreloadTextures(false);
	}
	super.Destroyed();
}

simulated state Active
{
	/**
	 * We override BeginFire() so that we can check for zooming
	 */
	simulated function BeginFire( Byte FireModeNum )
	{
		if (WorldInfo.NetMode != NM_DedicatedServer)
		{
			if ( CheckZoom(FireModeNum) )
			{
				return;
			}
		}
		Super.BeginFire(FireModeNum);
	}

	simulated event OnAnimEnd(optional AnimNodeSequence SeqNode, optional float PlayedTime, optional float ExcessTime)
	{
		local int IdleIndex;

		if ( WorldInfo.NetMode != NM_DedicatedServer && WeaponIdleAnims.Length > 0 )
		{
			IdleIndex = Rand(WeaponIdleAnims.Length);
			PlayWeaponAnimation(WeaponIdleAnims[IdleIndex], 0.0, true);
			if(ArmIdleAnims.Length > IdleIndex && ArmsAnimSet != none)
			{
				PlayArmAnimation(ArmIdleAnims[IdleIndex], 0.0,, true);
			}
		}
	}
	simulated function PlayWeaponAnimation( Name Sequence, float fDesiredDuration, optional bool bLoop, optional SkeletalMeshComponent SkelMesh)
	{
		Global.PlayWeaponAnimation(Sequence,fDesiredDuration,bLoop,SkelMesh);
		ClearTimer('OnAnimEnd');
		if (!bLoop)
		{
			SetTimer(fDesiredDuration,false,'OnAnimEnd');
		}
	}

	simulated function ChangeVisibility(bool bIsVisible)
	{
		local bool bNeedToPlayAnim;

		// if the mesh isn't attached, we skipped playing the idle anim so play it now
		bNeedToPlayAnim = !Mesh.bAttached;
		Global.ChangeVisibility(bIsVisible);
		if (bNeedToPlayAnim)
		{
			OnAnimEnd(None, 0.f, 0.f);
		}
	}

	simulated function bool ShouldLagRot()
	{
		return true;
	}

	reliable server function ServerStartFire( byte FireModeNum )
	{
		// Check to see if the weapon is active, but not the current weapon.  If it is, force the
		// client to reset
		if (Instigator != none && Instigator.Weapon != self)
		{
			LogInternal("########## WARNING: Server Received ServerStartFire on "$self$" while in the active state but not current weapon.  Attempting Realignment");
			LogInternal("##########        : "$Instigator.PlayerReplicationInfo.PlayerName);
			LogInternal("##########        : "$Instigator.Weapon@Instigator.Weapon.GetStateName());
			InvManager.ClientSyncWeapon(Instigator.Weapon);
			Global.ServerStartFire(FireModeNum);
		}
		else
		{
			Global.ServerStartFire(FireModeNum);
		}
	}

	simulated function EndState(Name NextStateName)
	{
		Super.EndState(NextStateName);
		if (bDebugWeapon)
		{
			LogInternal("---"@self@"has left the Active State"@NextStateName);
		}
	}

	/** Initialize the weapon as being active and ready to go. */
	simulated function BeginState( Name PreviousStateName )
	{
		OnAnimEnd(none, 0.f, 0.f);

		if (bDebugWeapon)
		{
			LogInternal("---"@self@"has entered the Active State"@PreviousStateName);
		}

		if ( UTBot(Instigator.Controller) != None )
		{
			if ( PendingFire(0) )
			{
				StillFiring(0);
			}
			else if ( PendingFire(1) )
			{
				StillFiring(1);
			}
		}
		Super.BeginState(PreviousStateName);

		if (InvManager != none && InvManager.LastAttemptedSwitchToWeapon != none)
		{
			if (InvManager.LastAttemptedSwitchToWeapon != self)
			{
				InvManager.LastAttemptedSwitchToWeapon.ClientWeaponSet(true);
			}
			InvManager.LastAttemptedSwitchToWeapon = none;
		}
	}
}

simulated function SetWeaponOverlayFlags(UTPawn OwnerPawn)
{
	local MaterialInterface InstanceToUse;
	local byte Flags;
	local int i;
	local UTGameReplicationInfo GRI;

	if(OwnerPawn != none)
	{
		GRI = UTGameReplicationInfo(WorldInfo.GRI);
		if (GRI != None)
		{
			Flags = OwnerPawn.WeaponOverlayFlags;
			for (i = 0; i < GRI.WeaponOverlays.length; i++)
			{
				if (GRI.WeaponOverlays[i] != None && bool(Flags & (1 << i)))
				{
					InstanceToUse = GRI.WeaponOverlays[i];
					break;
				}
			}
		}
		if (InstanceToUse != None)
		{
			CreateOverlayMesh();
		}
		if ( OverlayMesh != None )
		{
			if (InstanceToUse != none)
			{
				for (i=0;i<OverlayMesh.GetNumElements(); i++)
				{
					OverlayMesh.SetMaterial(i, InstanceToUse);
				}

				if (!OverlayMesh.bAttached)
				{
					OverlayMesh.SetHidden(Mesh.HiddenGame);
					AttachComponent(OverlayMesh);
				}
			}
			else if ( OverlayMesh.bAttached )
			{
				DetachComponent(OverlayMesh);
				OverlayMesh.SetHidden(true);
			}
		}
	}
}

static function float DetourWeight(Pawn Other, float PathWeight)
{
	local UTBot B;

	B = UTBot(Other.Controller);
	if ( B != None &&
		(B.NeedWeapon() || B.FavoriteWeapon == default.Class || (B.DefensePoint != None && B.DefensePoint.WeaponPreference == default.Class)) &&
		Other.FindInventoryType(default.Class) == None )
	{
		return (default.MaxDesireability / PathWeight);
	}
	else
	{
		return 0.0;
	}
}

/**
 * Allow the weapon to adjust the turning speed of the pawn
 * @FIXME: Add support for validation on a server
 *
 * @param	aTurn		The aTurn value from PlayerInput to throttle
 * @param	aLookup		The aLookup value from playerInput to throttle
 */
simulated function ThrottleLook(out float aTurn, out float aLookup);

simulated function Activate()
{
	SetupArmsAnim();
	super.Activate();
}

simulated function string GetOwnerName()
{
	return (Instigator==none) ? "None" : Instigator.PlayerReplicationInfo.GetPlayerAlias();
}

/**
 * This function is meant to be overridden in children.  It turns the current power percentage for
 * a weapon.  It's called mostly from the hud
 *
 * @returns	the percentage of power ( 1.0 - 0.0 )
 */
simulated event float GetPowerPerc()
{
	return 0.0;
}

function DropFrom(vector StartLocation, vector StartVelocity)
{
	if (Instigator != None && Instigator.IsHumanControlled() && Instigator.IsLocallyControlled())
	{
		PreloadTextures(false);
	}

	Super.DropFrom(StartLocation, StartVelocity);
}

reliable client function ClientWeaponThrown()
{
	if ( Instigator != none && UTPlayerController(Instigator.Controller) != none )
	{
		UTPlayerController(Instigator.Controller).EndZoom();
	}

	Super.ClientWeaponThrown();
}


/**
 * This determines whether or not the Weapon can have ViewAcceleration when Firing.
 **/
simulated function bool CanViewAccelerationWhenFiring()
{
	return FALSE;
}


/** called when Instigator enters a vehicle while we are its Weapon */
simulated function HolderEnteredVehicle();

simulated function bool CoversScreenSpace(vector ScreenLoc, Canvas Canvas)
{
	return ( (ScreenLoc.X > (1-WeaponCanvasXPct)*Canvas.ClipX)
		&& (ScreenLoc.Y > (1-WeaponCanvasYPct)*Canvas.ClipY) );
}

simulated static function DrawKillIcon(Canvas Canvas, float ScreenX, float ScreenY, float HUDScaleX, float HUDScaleY)
{
	local color CanvasColor;

	// save current canvas color
	CanvasColor = Canvas.DrawColor;

	// draw weapon shadow
	Canvas.DrawColor = class'UTHUD'.default.BlackColor;
	Canvas.DrawColor.A = CanvasColor.A;
	Canvas.SetPos( ScreenX - 2, ScreenY - 2 );
	Canvas.DrawTile(class'UTHUD'.default.AltHudTexture, 4 + HUDScaleX * 96, 4 + HUDScaleY * 64, default.IconCoordinates.U, default.IconCoordinates.V, default.IconCoordinates.UL, default.IconCoordinates.VL);

	// draw the weapon icon
	Canvas.DrawColor =  class'UTHUD'.default.WhiteColor;
	Canvas.DrawColor.A = CanvasColor.A;
	Canvas.SetPos( ScreenX, ScreenY );
	Canvas.DrawTile(class'UTHUD'.default.AltHudTexture, HUDScaleX * 96, HUDScaleY * 64, default.IconCoordinates.U, default.IconCoordinates.V, default.IconCoordinates.UL, default.IconCoordinates.VL);
	Canvas.DrawColor = CanvasColor;
}

simulated function bool EnableFriendlyWarningCrosshair()
{
	return true;
}

defaultproperties
{
   bExportMenuData=True
   bLeadTarget=True
   bConsiderProjectileAcceleration=True
   MaxAmmoCount=1
   ShotCost(0)=1
   ShotCost(1)=1
   MinReloadPct(0)=0.600000
   MinReloadPct(1)=0.600000
   WeaponFireWaveForm=ForceFeedbackWaveform'UTGame.Default__UTWeapon:ForceFeedbackWaveformShooting1'
   EffectSockets(0)="MuzzleFlashSocket"
   EffectSockets(1)="MuzzleFlashSocket"
   IconX=458
   IconY=83
   IconWidth=31
   IconHeight=45
   IconCoordinates=(U=600.000000,V=341.000000,UL=111.000000,VL=58.000000)
   CrossHairCoordinates=(U=192.000000,V=64.000000,UL=64.000000,VL=64.000000)
   SimpleCrossHairCoordinates=(U=276.000000,V=84.000000,UL=22.000000,VL=25.000000)
   CrosshairImage=Texture2D'UI_HUD.HUD.UTCrossHairs'
   LockedCrossHairCoordinates=(U=406.000000,V=320.000000,UL=76.000000,VL=77.000000)
   CurrentLockedScale=1.000000
   StartLockedScale=2.000000
   FinalLockedScale=1.000000
   LockedScaleTime=0.150000
   LastHitEnemyTime=-1000.000000
   CrosshairColor=(B=255,G=255,R=255,A=255)
   CrosshairScaling=1.000000
   ZoomInSound=SoundCue'A_Weapon_Sniper.Sniper.A_Weapon_Sniper_ZoomIn_Cue'
   ZoomOutSound=SoundCue'A_Weapon_Sniper.Sniper.A_Weapon_Sniper_ZoomOut_Cue'
   PivotTranslation=(X=0.000000,Y=-25.000000,Z=0.000000)
   QuickPickGroup=-1
   WeaponFireAnim(0)="WeaponFire"
   WeaponFireAnim(1)="WeaponFire"
   ArmFireAnim(0)="WeaponFire"
   ArmFireAnim(1)="WeaponFire"
   WeaponPutDownAnim="WeaponPutDown"
   ArmsPutDownAnim="WeaponPutDown"
   WeaponEquipAnim="WeaponEquip"
   ArmsEquipAnim="WeaponEquip"
   WeaponIdleAnims(0)="WeaponIdle"
   ArmIdleAnims(0)="WeaponIdle"
   WeaponFireSnd(0)=None
   WeaponFireSnd(1)=None
   BobDamping=0.850000
   JumpDamping=1.000000
   MaxPitchLag=600.000000
   MaxYawLag=800.000000
   RotChgSpeed=3.000000
   ReturnChgSpeed=3.000000
   WeaponColor=(B=255,G=255,R=255,A=255)
   WeaponCanvasXPct=0.350000
   WeaponCanvasYPct=0.350000
   MuzzleFlashSocket="MuzzleFlashSocket"
   MuzzleFlashDuration=0.330000
   SmallWeaponsOffset=(X=16.000000,Y=6.000000,Z=-6.000000)
   WideScreenOffsetScaling=0.800000
   WidescreenRotationOffset=(Pitch=900,Yaw=0,Roll=0)
   HiddenWeaponsOffset=(X=0.000000,Y=-50.000000,Z=-50.000000)
   ProjectileSpawnOffset=20.000000
   LockerRotation=(Pitch=16384,Yaw=0,Roll=0)
   LockerOffset=(X=0.000000,Y=0.000000,Z=-15.000000)
   CurrentRating=0.500000
   aimerror=525.000000
   NeedToPickUpAnnouncement=(AnnouncementText="Grab the Super Weapon!")
   AimingHelpRadius(0)=20.000000
   AimingHelpRadius(1)=20.000000
   AmmoRechargeRate=1.200000
   ZoomedTurnSpeedScalePct=0.850000
   TargetFrictionDistanceMin=320.000000
   TargetFrictionDistancePeak=1500.000000
   TargetFrictionDistanceMax=3000.000000
   TargetFrictionDistanceCurve=(Points=(,(InVal=320.000000),(InVal=1500.000000,OutVal=1.000000),(InVal=3000.000000,OutVal=0.300000),(InVal=7000.000000)))
   TargetFrictionMultiplierRange=(X=0.300000,Y=0.400000)
   TargetFrictionPeakRadiusScale=1.000000
   TargetFrictionPeakHeightScale=0.200000
   TargetFrictionOffset=(X=0.000000,Y=0.000000,Z=32.000000)
   TargetFrictionZoomedBoostValue=0.250000
   TargetAdhesionDistanceMax=2000.000000
   TargetAdhesionAimDistY=128.000000
   TargetAdhesionAimDistZ=96.000000
   TargetAdhesionScaleRange=(X=0.300000,Y=2.850000)
   TargetAdhesionZoomedBoostValue=0.250000
   PrimaryFireHintString="triggers the primary fire of this weapon."
   SecondaryFireHintString="triggers the alternate fire of this weapon."
   ShouldFireOnRelease(0)=0
   ShouldFireOnRelease(1)=0
   WeaponFireTypes(0)=EWFT_InstantHit
   WeaponFireTypes(1)=EWFT_InstantHit
   FiringStatesArray(0)="WeaponFiring"
   FiringStatesArray(1)="WeaponFiring"
   WeaponProjectiles(0)=None
   WeaponProjectiles(1)=None
   FireInterval(0)=1.000000
   FireInterval(1)=1.000000
   Spread(0)=0.000000
   Spread(1)=0.000000
   InstantHitDamage(0)=0.000000
   InstantHitDamage(1)=0.000000
   InstantHitMomentum(0)=0.000000
   InstantHitMomentum(1)=0.000000
   InstantHitDamageTypes(0)=Class'Engine.DamageType'
   InstantHitDamageTypes(1)=Class'Engine.DamageType'
   EquipTime=0.450000
   WeaponRange=22000.000000
   Begin Object Class=UTSkeletalMeshComponent Name=FirstPersonMesh ObjName=FirstPersonMesh Archetype=UTSkeletalMeshComponent'UTGame.Default__UTSkeletalMeshComponent'
      bOverrideAttachmentOwnerVisibility=True
      DepthPriorityGroup=SDPG_Foreground
      bOnlyOwnerSee=True
      CastShadow=False
      Name="FirstPersonMesh"
      ObjectArchetype=UTSkeletalMeshComponent'UTGame.Default__UTSkeletalMeshComponent'
   End Object
   Mesh=FirstPersonMesh
   DefaultAnimSpeed=0.900000
   MaxDesireability=0.500000
   DroppedPickupClass=Class'UTGame.UTDroppedPickup'
   Begin Object Class=SkeletalMeshComponent Name=PickupMesh ObjName=PickupMesh Archetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent'
      bForceRefpose=1
      bUpdateSkelWhenNotRendered=False
      bIgnoreControllersWhenNotRendered=True
      CullDistance=6000.000000
      CachedCullDistance=6000.000000
      bUseAsOccluder=False
      CastShadow=False
      bForceDirectLightMap=True
      bCastDynamicShadow=False
      Name="PickupMesh"
      ObjectArchetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent'
   End Object
   DroppedPickupMesh=PickupMesh
   PickupFactoryMesh=PickupMesh
   MessageClass=Class'UTGame.UTPickupMessage'
   Name="Default__UTWeapon"
   ObjectArchetype=GameWeapon'GameFramework.Default__GameWeapon'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:20.000 - Creation time: sk 18-3-2018 10:01:29.874 - Created with UnCodeX