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

DeusEx.DeusExWeapon


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
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518
03519
03520
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535
03536
03537
03538
03539
03540
03541
03542
03543
03544
03545
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562
03563
03564
03565
03566
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604
03605
03606
03607
03608
03609
03610
03611
03612
03613
03614
03615
03616
03617
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628
03629
03630
03631
03632
03633
03634
03635
03636
03637
03638
03639
03640
03641
03642
03643
03644
03645
03646
03647
03648
03649
03650
03651
03652
03653
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664
03665
03666
03667
03668
03669
03670
03671
03672
03673
03674
03675
03676
03677
03678
03679
03680
03681
03682
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692
03693
03694
03695
03696
03697
03698
03699
03700
03701
03702
03703
03704
03705
03706
03707
03708
03709
03710
03711
03712
03713
03714
03715
03716
03717
03718
03719
03720
03721
03722
03723
03724
03725
03726
03727
03728
03729
03730
03731
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745
03746
03747
03748
03749
03750
03751
03752
03753
03754
03755
03756
03757
03758
03759
03760
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770
03771
03772
03773
03774
03775
03776
03777
03778
03779
03780
03781
03782
03783
03784
03785
03786
03787
03788
03789
03790
03791
03792
03793
03794
03795
03796
03797
03798
03799
03800
03801
03802
03803
03804
03805
03806
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823
03824
03825
03826
03827
03828
03829
03830
03831
03832
03833
03834
03835
03836
03837
03838
03839
03840
03841
03842
03843
03844
03845
03846
03847
03848
03849
03850
03851
03852
03853
03854
03855
03856
//=============================================================================
// DeusExWeapon.
//=============================================================================
class DeusExWeapon extends Weapon
    abstract;

//
// enums for weapons (duh)
//
enum EEnemyEffective
{
    ENMEFF_All,
    ENMEFF_Organic,
    ENMEFF_Robot
};

enum EEnviroEffective
{
    ENVEFF_All,
    ENVEFF_Air,
    ENVEFF_Water,
    ENVEFF_Vacuum,
    ENVEFF_AirWater,
    ENVEFF_AirVacuum,
    ENVEFF_WaterVacuum
};

enum EConcealability
{
    CONC_None,
    CONC_Visual,
    CONC_Metal,
    CONC_All
};

enum EAreaType
{
    AOE_Point,
    AOE_Cone,
    AOE_Sphere
};

enum ELockMode
{
    LOCK_None,
    LOCK_Invalid,
    LOCK_Range,
    LOCK_Acquire,
    LOCK_Locked
};

var bool                bReadyToFire;           // true if our bullets are loaded, etc.
var() int               LowAmmoWaterMark;       // critical low ammo count
var travel int          ClipCount;              // number of bullets remaining in current clip

var() class<Skill>      GoverningSkill;         // skill that affects this weapon
var() travel float      NoiseLevel;             // amount of noise that weapon makes when fired
var() EEnemyEffective   EnemyEffective;         // type of enemies that weapon is effective against
var() EEnviroEffective  EnviroEffective;        // type of environment that weapon is effective in
var() EConcealability   Concealability;         // concealability of weapon
var() travel bool       bAutomatic;             // is this an automatic weapon?
var() travel float      ShotTime;               // number of seconds between shots
var() travel float      ReloadTime;             // number of seconds needed to reload the clip
var() int               HitDamage;              // damage done by a single shot (or for shotguns, a single slug)
var() int               MaxRange;               // absolute maximum range in world units (feet * 16)
var() travel int        AccurateRange;          // maximum accurate range in world units (feet * 16)
var() travel float      BaseAccuracy;           // base accuracy (0.0 is dead on, 1.0 is far off)

var bool                bCanHaveScope;          // can this weapon have a scope?
var() travel bool       bHasScope;              // does this weapon have a scope?
var() int               ScopeFOV;               // FOV while using scope
var bool                bZoomed;                // are we currently zoomed?
var bool                bWasZoomed;             // were we zoomed? (used during reloading)

var bool                bCanHaveLaser;          // can this weapon have a laser sight?
var() travel bool       bHasLaser;              // does this weapon have a laser sight?
var bool                bLasing;                // is the laser sight currently on?
var LaserEmitter        Emitter;                // actual laser emitter - valid only when bLasing == True

var bool                bCanHaveSilencer;       // can this weapon have a silencer?
var() travel bool       bHasSilencer;           // does this weapon have a silencer?

var() bool              bCanTrack;              // can this weapon lock on to a target?
var() float             LockTime;               // how long the target must stay targetted to lock
var float               LockTimer;              // used for lock checking
var float            MaintainLockTimer;   // Used for maintaining a lock even after moving off target.
var Actor            LockTarget;          // Used for maintaining a lock even after moving off target.
var Actor               Target;                 // actor currently targetted
var ELockMode           LockMode;               // is this target locked?
var string              TargetMessage;          // message to print during targetting
var float               TargetRange;            // range to current target
var() Sound             LockedSound;            // sound to play when locked
var() Sound             TrackingSound;          // sound to play while tracking a target
var float               SoundTimer;             // to time the sounds correctly

var() class<Ammo>       AmmoNames[3];           // three possible types of ammo per weapon
var() class<Projectile> ProjectileNames[3];     // projectile classes for different ammo
var() EAreaType         AreaOfEffect;           // area of effect of the weapon
var() bool              bPenetrating;           // shot will penetrate and cause blood
var() float             StunDuration;           // how long the shot stuns the target
var() bool              bHasMuzzleFlash;        // does this weapon have a flash when fired?
var() bool              bHandToHand;            // is this weapon hand to hand (no ammo)?
var globalconfig vector SwingOffset;     // offsets for this weapon swing.
var() travel float      recoilStrength;         // amount that the weapon kicks back after firing (0.0 is none, 1.0 is large)
var bool                bFiring;                // True while firing, used for recoil
var bool                bOwnerWillNotify;       // True if firing hand-to-hand weapons is dependent on the owner's animations
var bool                bFallbackWeapon;        // If True, only use if no other weapons are available
var bool                bNativeAttack;          // True if weapon represents a native attack
var bool                bEmitWeaponDrawn;       // True if drawing this weapon should make NPCs react
var bool                bUseWhileCrouched;      // True if NPCs should crouch while using this weapon
var bool                bUseAsDrawnWeapon;      // True if this weapon should be carried by NPCs as a drawn weapon
var bool                bWasInFiring;

var bool bNearWall;                             // used for prox. mine placement
var Vector placeLocation;                       // used for prox. mine placement
var Vector placeNormal;                         // used for prox. mine placement
var Mover placeMover;                           // used for prox. mine placement

var float ShakeTimer;
var float ShakeYaw;
var float ShakePitch;

var float AIMinRange;                           // minimum "best" range for AI; 0=default min range
var float AIMaxRange;                           // maximum "best" range for AI; 0=default max range
var float AITimeLimit;                          // maximum amount of time an NPC should hold the weapon; 0=no time limit
var float AIFireDelay;                          // Once fired, use as fallback weapon until the timeout expires; 0=no time limit

var float standingTimer;                        // how long we've been standing still (to increase accuracy)
var float currentAccuracy;                      // what the currently calculated accuracy is (updated every tick)

var MuzzleFlash flash;                          // muzzle flash actor

var float MinSpreadAcc;        // Minimum accuracy for multiple slug weapons (shotgun).  Affects only multiplayer,
                               // keeps shots from all going in same place (ruining shotgun effect)
var float MinProjSpreadAcc;
var float MinWeaponAcc;        // Minimum accuracy for a weapon at all.  Affects only multiplayer.
var bool bNeedToSetMPPickupAmmo;

var bool    bDestroyOnFinish;

var float   mpReloadTime;           
var int     mpHitDamage;
var float   mpBaseAccuracy;
var int     mpAccurateRange;
var int     mpMaxRange;
var int     mpReloadCount;
var int     mpPickupAmmoCount;

// Used to track weapon mods accurately.
var bool bCanHaveModBaseAccuracy;
var bool bCanHaveModReloadCount;
var bool bCanHaveModAccurateRange;
var bool bCanHaveModReloadTime;
var bool bCanHaveModRecoilStrength;
var travel float ModBaseAccuracy;
var travel float ModReloadCount;
var travel float ModAccurateRange;
var travel float ModReloadTime;
var travel float ModRecoilStrength;

var localized String msgCannotBeReloaded;
var localized String msgOutOf;
var localized String msgNowHas;
var localized String msgAlreadyHas;
var localized String msgNone;
var localized String msgLockInvalid;
var localized String msgLockRange;
var localized String msgLockAcquire;
var localized String msgLockLocked;
var localized String msgRangeUnit;
var localized String msgTimeUnit;
var localized String msgMassUnit;
var localized String msgNotWorking;

//
// strings for info display
//
var localized String msgInfoAmmoLoaded;
var localized String msgInfoAmmo;
var localized String msgInfoDamage;
var localized String msgInfoClip;
var localized String msgInfoROF;
var localized String msgInfoReload;
var localized String msgInfoRecoil;
var localized String msgInfoAccuracy;
var localized String msgInfoAccRange;
var localized String msgInfoMaxRange;
var localized String msgInfoMass;
var localized String msgInfoLaser;
var localized String msgInfoScope;
var localized String msgInfoSilencer;
var localized String msgInfoNA;
var localized String msgInfoYes;
var localized String msgInfoNo;
var localized String msgInfoAuto;
var localized String msgInfoSingle;
var localized String msgInfoRounds;
var localized String msgInfoRoundsPerSec;
var localized String msgInfoSkill;
var localized String msgInfoWeaponStats;

var bool        bClientReadyToFire, bClientReady, bInProcess, bFlameOn, bLooping;
var int     SimClipCount, flameShotCount, SimAmmoAmount;
var float   TimeLockSet;

//
// network replication
//
replication
{
    // server to client
    reliable if ((Role == ROLE_Authority) && (bNetOwner))
        ClipCount, bZoomed, bHasSilencer, bHasLaser, ModBaseAccuracy, ModReloadCount, ModAccurateRange, ModReloadTime, ModRecoilStrength;

    // Things the client should send to the server
    //reliable if ( (Role<ROLE_Authority) )
        //LockTimer, Target, LockMode, TargetMessage, TargetRange, bCanTrack, LockTarget;

    // Functions client calls on server
    reliable if ( Role < ROLE_Authority )
        ReloadAmmo, LoadAmmo, CycleAmmo, LaserOn, LaserOff, LaserToggle, ScopeOn, ScopeOff, ScopeToggle, PropagateLockState, ServerForceFire, 
          ServerGenerateBullet, ServerGotoFinishFire, ServerHandleNotify, StartFlame, StopFlame, ServerDoneReloading, DestroyOnFinish;

    // Functions Server calls in client
    reliable if ( Role == ROLE_Authority )
      RefreshScopeDisplay, ReadyClientToFire, SetClientAmmoParams, ClientDownWeapon, ClientActive, ClientReload;
}

// ---------------------------------------------------------------------
// PropagateLockState()
// ---------------------------------------------------------------------
simulated function PropagateLockState(ELockMode NewMode, Actor NewTarget)
{
   LockMode = NewMode;
   LockTarget = NewTarget;
}

// ---------------------------------------------------------------------
// SetLockMode()
// ---------------------------------------------------------------------
simulated function SetLockMode(ELockMode NewMode)
{
   if ((LockMode != NewMode) && (Role != ROLE_Authority))
   {
      if (NewMode != LOCK_Locked)
         PropagateLockState(NewMode, None);
      else
         PropagateLockState(NewMode, Target);
   }
    TimeLockSet = Level.Timeseconds;
   LockMode = NewMode;
}

// ---------------------------------------------------------------------
// PlayLockSound()
// Because playing a sound from a simulated function doesn't play it 
// server side.
// ---------------------------------------------------------------------
function PlayLockSound()
{
   Owner.PlaySound(LockedSound, SLOT_None);
}

//
// install the correct projectile info if needed
//
function TravelPostAccept()
{
    local int i;

    Super.TravelPostAccept();

    // make sure the AmmoName matches the currently loaded AmmoType
    if (AmmoType != None)
        AmmoName = AmmoType.Class;

    if (!bInstantHit)
    {
        if (ProjectileClass != None)
            ProjectileSpeed = ProjectileClass.Default.speed;

        // make sure the projectile info matches the actual AmmoType
        // since we can't "var travel class" (AmmoName and ProjectileClass)
        if (AmmoType != None)
        {
            FireSound = None;
            for (i=0; i<ArrayCount(AmmoNames); i++)
            {
                if (AmmoNames[i] == AmmoName)
                {
                    ProjectileClass = ProjectileNames[i];
                    break;
                }
            }
        }
    }
}


//
// PreBeginPlay
//

function PreBeginPlay()
{
    Super.PreBeginPlay();

    if ( Default.mpPickupAmmoCount == 0 )
    {
        Default.mpPickupAmmoCount = Default.PickupAmmoCount;
    }
}

//
// PostBeginPlay
//

function PostBeginPlay()
{
    Super.PostBeginPlay();
   if (Level.NetMode != NM_Standalone)
   {
      bWeaponStay = True;
      if (bNeedToSetMPPickupAmmo)
      {
         PickupAmmoCount = PickupAmmoCount * 3;
         bNeedToSetMPPickupAmmo = False;
      }
   }
}

singular function BaseChange()
{
    Super.BaseChange();

    // Make sure we fall if we don't have a base
    if ((base == None) && (Owner == None))
        SetPhysics(PHYS_Falling);
}

function bool HandlePickupQuery(Inventory Item)
{
    local DeusExWeapon W;
    local DeusExPlayer player;
    local bool bResult;
    local class<Ammo> defAmmoClass;
    local Ammo defAmmo;
    
    // make sure that if you pick up a modded weapon that you
    // already have, you get the mods
    W = DeusExWeapon(Item);
    if ((W != None) && (W.Class == Class))
    {
        if (W.ModBaseAccuracy > ModBaseAccuracy)
            ModBaseAccuracy = W.ModBaseAccuracy;
        if (W.ModReloadCount > ModReloadCount)
            ModReloadCount = W.ModReloadCount;
        if (W.ModAccurateRange > ModAccurateRange)
            ModAccurateRange = W.ModAccurateRange;

        // these are negative
        if (W.ModReloadTime < ModReloadTime)
            ModReloadTime = W.ModReloadTime;
        if (W.ModRecoilStrength < ModRecoilStrength)
            ModRecoilStrength = W.ModRecoilStrength;

        if (W.bHasLaser)
            bHasLaser = True;
        if (W.bHasSilencer)
            bHasSilencer = True;
        if (W.bHasScope)
            bHasScope = True;

        // copy the actual stats as well
        if (W.ReloadCount > ReloadCount)
            ReloadCount = W.ReloadCount;
        if (W.AccurateRange > AccurateRange)
            AccurateRange = W.AccurateRange;

        // these are negative
        if (W.BaseAccuracy < BaseAccuracy)
            BaseAccuracy = W.BaseAccuracy;
        if (W.ReloadTime < ReloadTime)
            ReloadTime = W.ReloadTime;
        if (W.RecoilStrength < RecoilStrength)
            RecoilStrength = W.RecoilStrength;
    }
    player = DeusExPlayer(Owner);

    if (Item.Class == Class)
    {
      if (!( (Weapon(item).bWeaponStay && (Level.NetMode == NM_Standalone)) && (!Weapon(item).bHeldItem || Weapon(item).bTossedOut)))
        {
            // Only add ammo of the default type
            // There was an easy way to get 32 20mm shells, buy picking up another assault rifle with 20mm ammo selected
            if ( AmmoType != None )
            {
                // Add to default ammo only
                if ( AmmoNames[0] == None )
                    defAmmoClass = AmmoName;
                else
                    defAmmoClass = AmmoNames[0];

                defAmmo = Ammo(player.FindInventoryType(defAmmoClass));
                defAmmo.AddAmmo( Weapon(Item).PickupAmmoCount );

                if ( Level.NetMode != NM_Standalone )
                {
                    if (( player != None ) && ( player.InHand != None ))
                    {
                        if ( DeusExWeapon(item).class == DeusExWeapon(player.InHand).class )
                            ReadyToFire();
                    }
                }
            }
        }
    }

    bResult = Super.HandlePickupQuery(Item);

    // Notify the object belt of the new ammo
    if (player != None)
        player.UpdateBeltText(Self);

    return bResult;
}

function BringUp()
{
    if ( Level.NetMode != NM_Standalone )
        ReadyClientToFire( False );

    // alert NPCs that I'm whipping it out
    if (!bNativeAttack && bEmitWeaponDrawn)
        AIStartEvent('WeaponDrawn', EAITYPE_Visual);

    // reset the standing still accuracy bonus
    standingTimer = 0;

    Super.BringUp();
}

function bool PutDown()
{
    if ( Level.NetMode != NM_Standalone )
        ReadyClientToFire( False );

    // alert NPCs that I'm putting away my gun
    AIEndEvent('WeaponDrawn', EAITYPE_Visual);

    // reset the standing still accuracy bonus
    standingTimer = 0;

    return Super.PutDown();
}

function ReloadAmmo()
{
    // single use or hand to hand weapon if ReloadCount == 0
    if (ReloadCount == 0)
    {
        Pawn(Owner).ClientMessage(msgCannotBeReloaded);
        return;
    }

    if (!IsInState('Reload'))
    {
        TweenAnim('Still', 0.1);
        GotoState('Reload');
    }
}

//
// Note we need to control what's calling this...but I'll get rid of the access nones for now
//
simulated function float GetWeaponSkill()
{
    local DeusExPlayer player;
    local float value;

    value = 0;

    if ( Owner != None )
    {
        player = DeusExPlayer(Owner);
        if (player != None)
        {
            if ((player.AugmentationSystem != None ) && ( player.SkillSystem != None ))
            {
                // get the target augmentation
                value = player.AugmentationSystem.GetAugLevelValue(class'AugTarget');
                if (value == -1.0)
                    value = 0;

                // get the skill
                value += player.SkillSystem.GetSkillLevelValue(GoverningSkill);
            }
        }
    }
    return value;
}

// calculate the accuracy for this weapon and the owner's damage
simulated function float CalculateAccuracy()
{
    local float accuracy;   // 0 is dead on, 1 is pretty far off
    local float tempacc, div;
   local float weapskill; // so we don't keep looking it up (slower).
    local int HealthArmRight, HealthArmLeft, HealthHead;
    local int BestArmRight, BestArmLeft, BestHead;
    local bool checkit;
    local DeusExPlayer player;

    accuracy = BaseAccuracy;        // start with the weapon's base accuracy
   weapskill = GetWeaponSkill();

    player = DeusExPlayer(Owner);

    if (player != None)
    {
        // check the player's skill
        // 0.0 = dead on, 1.0 = way off
        accuracy += weapskill;

        // get the health values for the player
        HealthArmRight = player.HealthArmRight;
        HealthArmLeft  = player.HealthArmLeft;
        HealthHead     = player.HealthHead;
        BestArmRight   = player.Default.HealthArmRight;
        BestArmLeft    = player.Default.HealthArmLeft;
        BestHead       = player.Default.HealthHead;
        checkit = True;
    }
    else if (ScriptedPawn(Owner) != None)
    {
        // update the weapon's accuracy with the ScriptedPawn's BaseAccuracy
        // (BaseAccuracy uses higher values for less accuracy, hence we add)
        accuracy += ScriptedPawn(Owner).BaseAccuracy;

        // get the health values for the NPC
        HealthArmRight = ScriptedPawn(Owner).HealthArmRight;
        HealthArmLeft  = ScriptedPawn(Owner).HealthArmLeft;
        HealthHead     = ScriptedPawn(Owner).HealthHead;
        BestArmRight   = ScriptedPawn(Owner).Default.HealthArmRight;
        BestArmLeft    = ScriptedPawn(Owner).Default.HealthArmLeft;
        BestHead       = ScriptedPawn(Owner).Default.HealthHead;
        checkit = True;
    }
    else
        checkit = False;

    // Disabled accuracy mods based on health in multiplayer
    if ( Level.NetMode != NM_Standalone )
        checkit = False;

    if (checkit)
    {
        if (HealthArmRight < 1)
            accuracy += 0.5;
        else if (HealthArmRight < BestArmRight * 0.34)
            accuracy += 0.2;
        else if (HealthArmRight < BestArmRight * 0.67)
            accuracy += 0.1;

        if (HealthArmLeft < 1)
            accuracy += 0.5;
        else if (HealthArmLeft < BestArmLeft * 0.34)
            accuracy += 0.2;
        else if (HealthArmLeft < BestArmLeft * 0.67)
            accuracy += 0.1;

        if (HealthHead < BestHead * 0.67)
            accuracy += 0.1;
    }

    // increase accuracy (decrease value) if we haven't been moving for awhile
    // this only works for the player, because NPCs don't need any more aiming help!
    if (player != None)
    {
        tempacc = accuracy;
        if (standingTimer > 0)
        {
            // higher skill makes standing bonus greater
            div = Max(15.0 + 29.0 * weapskill, 0.0);
            accuracy -= FClamp(standingTimer/div, 0.0, 0.6);
    
            // don't go too low
            if ((accuracy < 0.1) && (tempacc > 0.1))
                accuracy = 0.1;
        }
    }

    // make sure we don't go negative
    if (accuracy < 0.0)
        accuracy = 0.0;

   if (Level.NetMode != NM_Standalone)
      if (accuracy < MinWeaponAcc)
         accuracy = MinWeaponAcc;

    return accuracy;
}

//
// functions to change ammo types
//
function bool LoadAmmo(int ammoNum)
{
    local class<Ammo> newAmmoClass;
    local Ammo newAmmo;
    local Pawn P;

    if ((ammoNum < 0) || (ammoNum > 2))
        return False;

    P = Pawn(Owner);

    // sorry, only pawns can have weapons
    if (P == None)
        return False;

    newAmmoClass = AmmoNames[ammoNum];

    if (newAmmoClass != None)
    {
        if (newAmmoClass != AmmoName)
        {
            newAmmo = Ammo(P.FindInventoryType(newAmmoClass));
            if (newAmmo == None)
            {
                P.ClientMessage(Sprintf(msgOutOf, newAmmoClass.Default.ItemName));
                return False;
            }
            
            // if we don't have a projectile for this ammo type, then set instant hit
            if (ProjectileNames[ammoNum] == None)
            {
                bInstantHit = True;
                bAutomatic = Default.bAutomatic;
                ShotTime = Default.ShotTime;
                if ( Level.NetMode != NM_Standalone )
                {
                    if (HasReloadMod())
                        ReloadTime = mpReloadTime * (1.0+ModReloadTime);
                    else
                        ReloadTime = mpReloadTime;
                }
                else
                {
                    if (HasReloadMod())
                        ReloadTime = Default.ReloadTime * (1.0+ModReloadTime);
                    else
                        ReloadTime = Default.ReloadTime;
                }
                FireSound = Default.FireSound;
                ProjectileClass = None;
            }
            else
            {
                // otherwise, set us to fire projectiles
                bInstantHit = False;
                bAutomatic = False;
                ShotTime = 1.0;
                if (HasReloadMod())
                    ReloadTime = 2.0 * (1.0+ModReloadTime);
                else
                    ReloadTime = 2.0;
                FireSound = None;       // handled by the projectile
                ProjectileClass = ProjectileNames[ammoNum];
                ProjectileSpeed = ProjectileClass.Default.Speed;
            }

            AmmoName = newAmmoClass;
            AmmoType = newAmmo;

            // AlexB had a new sound for 20mm but there's no mechanism for playing alternate sounds per ammo type
            // Same for WP rocket
            if ( Ammo20mm(newAmmo) != None )
                FireSound=Sound'AssaultGunFire20mm';
            else if ( AmmoRocketWP(newAmmo) != None )
                FireSound=Sound'GEPGunFireWP';
            else if ( AmmoRocket(newAmmo) != None )
                FireSound=Sound'GEPGunFire';

            if ( Level.NetMode != NM_Standalone )
                SetClientAmmoParams( bInstantHit, bAutomatic, ShotTime, FireSound, ProjectileClass, ProjectileSpeed );

            // Notify the object belt of the new ammo
            if (DeusExPlayer(P) != None)
                DeusExPlayer(P).UpdateBeltText(Self);

            ReloadAmmo();

            P.ClientMessage(Sprintf(msgNowHas, ItemName, newAmmoClass.Default.ItemName));
            return True;
        }
        else
        {
            P.ClientMessage(Sprintf(MsgAlreadyHas, ItemName, newAmmoClass.Default.ItemName));
        }
    }

    return False;
}

// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

simulated function SetClientAmmoParams( bool bInstant, bool bAuto, float sTime, Sound FireSnd, class<projectile> pClass, float pSpeed )
{
    bInstantHit = bInstant;
    bAutomatic = bAuto;
    ShotTime = sTime;
    FireSound = FireSnd;
    ProjectileClass = pClass;
    ProjectileSpeed = pSpeed;
}

// ----------------------------------------------------------------------
// CanLoadAmmoType()
//
// Returns True if this ammo type can be used with this weapon
// ----------------------------------------------------------------------

simulated function bool CanLoadAmmoType(Ammo ammo)
{
    local int  ammoIndex;
    local bool bCanLoad;

    bCanLoad = False;

    if (ammo != None)
    {
        // First check "AmmoName"

        if (AmmoName == ammo.Class)
        {
            bCanLoad = True;
        }
        else
        {
            for (ammoIndex=0; ammoIndex<3; ammoIndex++)
            {
                if (AmmoNames[ammoIndex] == ammo.Class)
                {
                    bCanLoad = True;
                    break;
                }
            }
        }
    }

    return bCanLoad;
}

// ----------------------------------------------------------------------
// LoadAmmoType()
// 
// Load this ammo type given the actual object
// ----------------------------------------------------------------------

function LoadAmmoType(Ammo ammo)
{
    local int i;

    if (ammo != None)
        for (i=0; i<3; i++)
            if (AmmoNames[i] == ammo.Class)
                LoadAmmo(i);
}

// ----------------------------------------------------------------------
// LoadAmmoClass()
// 
// Load this ammo type given the class
// ----------------------------------------------------------------------

function LoadAmmoClass(Class<Ammo> ammoClass)
{
    local int i;

    if (ammoClass != None)
        for (i=0; i<3; i++)
            if (AmmoNames[i] == ammoClass)
                LoadAmmo(i);
}

// ----------------------------------------------------------------------
// CycleAmmo()
// ----------------------------------------------------------------------

function CycleAmmo()
{
    local int i, last;

    if (NumAmmoTypesAvailable() < 2)
        return;

    for (i=0; i<ArrayCount(AmmoNames); i++)
        if (AmmoNames[i] == AmmoName)
            break;

    last = i;

    do
    {
        if (++i >= 3)
            i = 0;

        if (LoadAmmo(i))
            break;
    } until (last == i);
}

simulated function bool CanReload()
{
    if ((ClipCount > 0) && (ReloadCount != 0) && (AmmoType != None) && (AmmoType.AmmoAmount > 0) &&
        (AmmoType.AmmoAmount > (ReloadCount-ClipCount)))
        return true;
    else
        return false;
}

simulated function bool MustReload()
{
    if ((AmmoLeftInClip() == 0) && (AmmoType != None) && (AmmoType.AmmoAmount > 0))
        return true;
    else
        return false;
}

simulated function int AmmoLeftInClip()
{
    if (ReloadCount == 0)   // if this weapon is not reloadable
        return 1;
    else if (AmmoType == None)
        return 0;
    else if (AmmoType.AmmoAmount == 0)      // if we are out of ammo
        return 0;
    else if (ReloadCount - ClipCount > AmmoType.AmmoAmount)     // if we have no clips left
        return AmmoType.AmmoAmount;
    else
        return ReloadCount - ClipCount;
}

simulated function int NumClips()
{
    if (ReloadCount == 0)  // if this weapon is not reloadable
        return 0;
    else if (AmmoType == None)
        return 0;
    else if (AmmoType.AmmoAmount == 0)  // if we are out of ammo
        return 0;
    else  // compute remaining clips
        return ((AmmoType.AmmoAmount-AmmoLeftInClip()) + (ReloadCount-1)) / ReloadCount;
}

simulated function int AmmoAvailable(int ammoNum)
{
    local class<Ammo> newAmmoClass;
    local Ammo newAmmo;
    local Pawn P;

    P = Pawn(Owner);

    // sorry, only pawns can have weapons
    if (P == None)
        return 0;

    newAmmoClass = AmmoNames[ammoNum];

    if (newAmmoClass == None)
        return 0;

    newAmmo = Ammo(P.FindInventoryType(newAmmoClass));

    if (newAmmo == None)
        return 0;

    return newAmmo.AmmoAmount;
}

simulated function int NumAmmoTypesAvailable()
{
    local int i;

    for (i=0; i<ArrayCount(AmmoNames); i++)
        if (AmmoNames[i] == None)
            break;

    // to make Al fucking happy
    if (i == 0)
        i = 1;

    return i;
}

function name WeaponDamageType()
{
    local name                    damageType;
    local Class<DeusExProjectile> projClass;

    projClass = Class<DeusExProjectile>(ProjectileClass);
    if (bInstantHit)
    {
        if (StunDuration > 0)
            damageType = 'Stunned';
        else
            damageType = 'Shot';

        if (AmmoType != None)
            if (AmmoType.IsA('AmmoSabot'))
                damageType = 'Sabot';
    }
    else if (projClass != None)
        damageType = projClass.Default.damageType;
    else
        damageType = 'None';

    return (damageType);
}


//
// target tracking info
//
simulated function Actor AcquireTarget()
{
    local vector StartTrace, EndTrace, HitLocation, HitNormal;
    local Actor hit, retval;
    local Pawn p;

    p = Pawn(Owner);
    if (p == None)
        return None;

    StartTrace = p.Location;
    if (PlayerPawn(p) != None)
        EndTrace = p.Location + (10000 * Vector(p.ViewRotation));
    else
        EndTrace = p.Location + (10000 * Vector(p.Rotation));

    // adjust for eye height
    StartTrace.Z += p.BaseEyeHeight;
    EndTrace.Z += p.BaseEyeHeight;

    foreach TraceActors(class'Actor', hit, HitLocation, HitNormal, EndTrace, StartTrace)
        if (!hit.bHidden && (hit.IsA('Decoration') || hit.IsA('Pawn')))
            return hit;

    return None;
}

//
// Used to determine if we are near (and facing) a wall for placing LAMs, etc.
//
simulated function bool NearWallCheck()
{
    local Vector StartTrace, EndTrace, HitLocation, HitNormal;
    local Actor HitActor;

    // Scripted pawns can't place LAMs
    if (ScriptedPawn(Owner) != None)
        return False;

    // Don't let players place grenades when they have something highlighted
    if ( Level.NetMode != NM_Standalone )
    {
        if ( Owner.IsA('DeusExPlayer') && (DeusExPlayer(Owner).frobTarget != None) )
        {
            if ( DeusExPlayer(Owner).IsFrobbable( DeusExPlayer(Owner).frobTarget ) )
                return False;
        }
    }

    // trace out one foot in front of the pawn
    StartTrace = Owner.Location;
    EndTrace = StartTrace + Vector(Pawn(Owner).ViewRotation) * 32;

    StartTrace.Z += Pawn(Owner).BaseEyeHeight;
    EndTrace.Z += Pawn(Owner).BaseEyeHeight;

    HitActor = Trace(HitLocation, HitNormal, EndTrace, StartTrace);
    if ((HitActor == Level) || ((HitActor != None) && HitActor.IsA('Mover')))
    {
        placeLocation = HitLocation;
        placeNormal = HitNormal;
        placeMover = Mover(HitActor);
        return True;
    }

    return False;
}

//
// used to place a grenade on the wall
//
function PlaceGrenade()
{
    local ThrownProjectile gren;
    local float dmgX;

    gren = ThrownProjectile(spawn(ProjectileClass, Owner,, placeLocation, Rotator(placeNormal)));
    if (gren != None)
    {
        AmmoType.UseAmmo(1);
        if ( AmmoType.AmmoAmount <= 0 )
            bDestroyOnFinish = True;

        gren.PlayAnim('Open');
        gren.PlaySound(gren.MiscSound, SLOT_None, 0.5+FRand()*0.5,, 512, 0.85+FRand()*0.3);
        gren.SetPhysics(PHYS_None);
        gren.bBounce = False;
        gren.bProximityTriggered = True;
        gren.bStuck = True;
        if (placeMover != None)
            gren.SetBase(placeMover);

        // up the damage based on the skill
        // returned value from GetWeaponSkill is negative, so negate it to make it positive
        // dmgX value ranges from 1.0 to 2.4 (max demo skill and max target aug)
        dmgX = -2.0 * GetWeaponSkill() + 1.0;
        gren.Damage *= dmgX;

        // Update ammo count on object belt
        if (DeusExPlayer(Owner) != None)
            DeusExPlayer(Owner).UpdateBeltText(Self);
    }
}

//
// scope, laser, and targetting updates are done here
//
simulated function Tick(float deltaTime)
{
    local vector loc;
    local rotator rot;
    local float beepspeed, recoil;
    local DeusExPlayer player;
   local Actor RealTarget;
    local Pawn pawn;

    player = DeusExPlayer(Owner);
    pawn = Pawn(Owner);

    Super.Tick(deltaTime);

    // don't do any of this if this weapon isn't currently in use
    if (pawn == None)
   {
      LockMode = LOCK_None;
      MaintainLockTimer = 0;
      LockTarget = None;
      LockTimer = 0;
        return;
   }

    if (pawn.Weapon != self)
   {
      LockMode = LOCK_None;
      MaintainLockTimer = 0;
      LockTarget = None;
      LockTimer = 0;
        return;
   }

    // all this should only happen IF you have ammo loaded
    if (ClipCount < ReloadCount)
    {
        // check for LAM or other placed mine placement
        if (bHandToHand && (ProjectileClass != None) && (!Self.IsA('WeaponShuriken')))
        {
            if (NearWallCheck())
            {
                if (( Level.NetMode != NM_Standalone ) && IsAnimating() && (AnimSequence == 'Select'))
                {
                }
                else
                {
                    if (!bNearWall || (AnimSequence == 'Select'))
                    {
                        PlayAnim('PlaceBegin',, 0.1);
                        bNearWall = True;
                    }
                }
            }
            else
            {
                if (bNearWall)
                {
                    PlayAnim('PlaceEnd',, 0.1);
                    bNearWall = False;
                }
            }
        }


      SoundTimer += deltaTime;

      if ( (Level.Netmode == NM_Standalone) || ( (Player != None) && (Player.PlayerIsClient()) ) )
      {
         if (bCanTrack)
         {
            Target = AcquireTarget();
            RealTarget = Target;
            
            // calculate the range
            if (Target != None)
               TargetRange = Abs(VSize(Target.Location - Location));
            
            // update our timers
            //SoundTimer += deltaTime;
            MaintainLockTimer -= deltaTime;
            
            // check target and range info to see what our mode is
            if ((Target == None) || IsInState('Reload'))
            {
               if (MaintainLockTimer <= 0)
               {                
                  SetLockMode(LOCK_None);
                  MaintainLockTimer = 0;
                  LockTarget = None;
               }
               else if (LockMode == LOCK_Locked)
               {
                  Target = LockTarget;
               }
            }
            else if ((Target != LockTarget) && (Target.IsA('Pawn')) && (LockMode == LOCK_Locked))
            {
               SetLockMode(LOCK_None);
               LockTarget = None;
            }
            else if (!Target.IsA('Pawn'))
            {
               if (MaintainLockTimer <=0 )
               {
                  SetLockMode(LOCK_Invalid);
               }
            }
            else if ( (Target.IsA('DeusExPlayer')) && (Target.Style == STY_Translucent) )
            {
               //DEUS_EX AMSD Don't allow locks on cloaked targets.
               SetLockMode(LOCK_Invalid);
            }
            else if ( (Target.IsA('DeusExPlayer')) && (Player.DXGame.IsA('TeamDMGame')) && (TeamDMGame(Player.DXGame).ArePlayersAllied(Player,DeusExPlayer(Target))) )
            {
               //DEUS_EX AMSD Don't allow locks on allies.
               SetLockMode(LOCK_Invalid);
            }
            else
            {
               if (TargetRange > MaxRange)
               {
                  SetLockMode(LOCK_Range);
               }
               else
               {
                  // change LockTime based on skill
                  // -0.7 = max skill
                  // DEUS_EX AMSD Only do weaponskill check here when first checking.
                  if (LockTimer == 0)
                  {
                     LockTime = FMax(Default.LockTime + 3.0 * GetWeaponSkill(), 0.0);
                     if ((Level.Netmode != NM_Standalone) && (LockTime < 0.25))
                        LockTime = 0.25;
                  }
                  
                  LockTimer += deltaTime;
                  if (LockTimer >= LockTime)
                  {
                     SetLockMode(LOCK_Locked);
                  }
                  else
                  {
                     SetLockMode(LOCK_Acquire);
                  }
               }
            }
            
            // act on the lock mode
            switch (LockMode)
            {
            case LOCK_None:
               TargetMessage = msgNone;
               LockTimer -= deltaTime;
               break;
               
            case LOCK_Invalid:
               TargetMessage = msgLockInvalid;
               LockTimer -= deltaTime;
               break;
               
            case LOCK_Range:
               TargetMessage = msgLockRange @ Int(TargetRange/16) @ msgRangeUnit;
               LockTimer -= deltaTime;
               break;
               
            case LOCK_Acquire:
               TargetMessage = msgLockAcquire @ Left(String(LockTime-LockTimer), 4) @ msgTimeUnit;
               beepspeed = FClamp((LockTime - LockTimer) / Default.LockTime, 0.2, 1.0);
               if (SoundTimer > beepspeed)
               {
                  Owner.PlaySound(TrackingSound, SLOT_None);
                  SoundTimer = 0;
               }
               break;
               
            case LOCK_Locked:
               // If maintaining a lock, or getting a new one, increment maintainlocktimer
               if ((RealTarget != None) && ((RealTarget == LockTarget) || (LockTarget == None)))
               {
                  if (Level.NetMode != NM_Standalone)
                     MaintainLockTimer = default.MaintainLockTimer;
                  else
                     MaintainLockTimer = 0;
                  LockTarget = Target;
               }
               TargetMessage = msgLockLocked @ Int(TargetRange/16) @ msgRangeUnit;
               // DEUS_EX AMSD Moved out so server can play it so that client knows for sure when locked.
               /*if (SoundTimer > 0.1)
               {
                  Owner.PlaySound(LockedSound, SLOT_None);
                  SoundTimer = 0;
               }*/
               break;
            }
         }
         else
         {
            LockMode = LOCK_None;
            TargetMessage = msgNone;
            LockTimer = 0;
            MaintainLockTimer = 0;
            LockTarget = None;
         }
         
         if (LockTimer < 0)
            LockTimer = 0;
      }
   }
   else
   {
      LockMode = LOCK_None;
      TargetMessage=msgNone;
      MaintainLockTimer = 0;
      LockTarget = None;
      LockTimer = 0;
   }

   if ((LockMode == LOCK_Locked) && (SoundTimer > 0.1) && (Role == ROLE_Authority))
   {
      PlayLockSound();
      SoundTimer = 0;
   }

    currentAccuracy = CalculateAccuracy();

    if (player != None)
    {
        // reduce the recoil based on skill
        recoil = recoilStrength + GetWeaponSkill() * 2.0;
        if (recoil < 0.0)
            recoil = 0.0;

        // simulate recoil while firing
        if (bFiring && IsAnimating() && (AnimSequence == 'Shoot') && (recoil > 0.0))
        {
            player.ViewRotation.Yaw += deltaTime * (Rand(4096) - 2048) * recoil;
            player.ViewRotation.Pitch += deltaTime * (Rand(4096) + 4096) * recoil;
            if ((player.ViewRotation.Pitch > 16384) && (player.ViewRotation.Pitch < 32768))
                player.ViewRotation.Pitch = 16384;
        }
    }

    // if were standing still, increase the timer
    if (VSize(Owner.Velocity) < 10)
        standingTimer += deltaTime;
    else    // otherwise, decrease it slowly based on velocity
        standingTimer = FMax(0, standingTimer - 0.03*deltaTime*VSize(Owner.Velocity));

    if (bLasing || bZoomed)
    {
        // shake our view to simulate poor aiming
        if (ShakeTimer > 0.25)
        {
            ShakeYaw = currentAccuracy * (Rand(4096) - 2048);
            ShakePitch = currentAccuracy * (Rand(4096) - 2048);
            ShakeTimer -= 0.25;
        }

        ShakeTimer += deltaTime;

        if (bLasing && (Emitter != None))
        {
            loc = Owner.Location;
            loc.Z += Pawn(Owner).BaseEyeHeight;

            // add a little random jitter - looks cool!
            rot = Pawn(Owner).ViewRotation;
            rot.Yaw += Rand(5) - 2;
            rot.Pitch += Rand(5) - 2;

            Emitter.SetLocation(loc);
            Emitter.SetRotation(rot);
        }

        if ((player != None) && bZoomed)
        {
            player.ViewRotation.Yaw += deltaTime * ShakeYaw;
            player.ViewRotation.Pitch += deltaTime * ShakePitch;
        }
    }
}

//
// scope functions for weapons which have them
//

function ScopeOn()
{
    if (bHasScope && !bZoomed && (Owner != None) && Owner.IsA('DeusExPlayer'))
    {
        // Show the Scope View
        bZoomed = True;
        RefreshScopeDisplay(DeusExPlayer(Owner), False, bZoomed);
    }
}

function ScopeOff()
{
    if (bHasScope && bZoomed && (Owner != None) && Owner.IsA('DeusExPlayer'))
    {
        bZoomed = False;
        // Hide the Scope View
      RefreshScopeDisplay(DeusExPlayer(Owner), False, bZoomed);
        //DeusExRootWindow(DeusExPlayer(Owner).rootWindow).scopeView.DeactivateView();
    }
}

simulated function ScopeToggle()
{
    if (IsInState('Idle'))
    {
        if (bHasScope && (Owner != None) && Owner.IsA('DeusExPlayer'))
        {
            if (bZoomed)
                ScopeOff();
            else
                ScopeOn();
        }
    }
}

// ----------------------------------------------------------------------
// RefreshScopeDisplay()
// ----------------------------------------------------------------------

simulated function RefreshScopeDisplay(DeusExPlayer player, bool bInstant, bool bScopeOn)
{
    if (bScopeOn && (player != None))
    {
        // Show the Scope View
        DeusExRootWindow(player.rootWindow).scopeView.ActivateView(ScopeFOV, False, bInstant);
    }
   else if (!bScopeOn)
   {
      DeusExrootWindow(player.rootWindow).scopeView.DeactivateView();
   }
}

//
// laser functions for weapons which have them
//

function LaserOn()
{
    if (bHasLaser && !bLasing)
    {
        // if we don't have an emitter, then spawn one
        // otherwise, just turn it on
        if (Emitter == None)
        {
            Emitter = Spawn(class'LaserEmitter', Self, , Location, Pawn(Owner).ViewRotation);
            if (Emitter != None)
            {
                Emitter.SetHiddenBeam(True);
                Emitter.AmbientSound = None;
                Emitter.TurnOn();
            }
        }
        else
            Emitter.TurnOn();

        bLasing = True;
    }
}

function LaserOff()
{
    if (bHasLaser && bLasing)
    {
        if (Emitter != None)
            Emitter.TurnOff();

        bLasing = False;
    }
}

function LaserToggle()
{
    if (IsInState('Idle'))
    {
        if (bHasLaser)
        {
            if (bLasing)
                LaserOff();
            else
                LaserOn();
        }
    }
}

simulated function SawedOffCockSound()
{
    if ((AmmoType.AmmoAmount > 0) && (WeaponSawedOffShotgun(Self) != None))
        Owner.PlaySound(SelectSound, SLOT_None,,, 1024);
}

//
// called from the MESH NOTIFY
//
simulated function SwapMuzzleFlashTexture()
{
   if (!bHasMuzzleFlash)
      return;
    if (FRand() < 0.5)
        MultiSkins[2] = Texture'FlatFXTex34';
    else
        MultiSkins[2] = Texture'FlatFXTex37';

    MuzzleFlashLight();
    SetTimer(0.1, False);
}

simulated function EraseMuzzleFlashTexture()
{
    MultiSkins[2] = None;
}

simulated function Timer()
{
    EraseMuzzleFlashTexture();
}

simulated function MuzzleFlashLight()
{
    local Vector offset, X, Y, Z;

    if (!bHasMuzzleFlash)
        return;

    if ((flash != None) && !flash.bDeleteMe)
        flash.LifeSpan = flash.Default.LifeSpan;
    else
    {
        GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
        offset = Owner.Location;
        offset += X * Owner.CollisionRadius * 2;
        flash = spawn(class'MuzzleFlash',,, offset);
        if (flash != None)
            flash.SetBase(Owner);
    }
}

function ServerHandleNotify( bool bInstantHit, class<projectile> ProjClass, float ProjSpeed, bool bWarn )
{
    if (bInstantHit)
        TraceFire(0.0);
    else
        ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);
}

//
// HandToHandAttack
// called by the MESH NOTIFY for the H2H weapons
//
simulated function HandToHandAttack()
{
    local bool bOwnerIsPlayerPawn;

    if (bOwnerWillNotify)
        return;

    // The controlling animator should be the one to do the tracefire and projfire
    if ( Level.NetMode != NM_Standalone )
    {
        bOwnerIsPlayerPawn = (DeusExPlayer(Owner) == DeusExPlayer(GetPlayerPawn()));

        if (( Role < ROLE_Authority ) && bOwnerIsPlayerPawn )
            ServerHandleNotify( bInstantHit, ProjectileClass, ProjectileSpeed, bWarnTarget );
        else if ( !bOwnerIsPlayerPawn )
            return;
    }

    if (ScriptedPawn(Owner) != None)
        ScriptedPawn(Owner).SetAttackAngle();

    if (bInstantHit)
        TraceFire(0.0);
    else
        ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);

    // if we are a thrown weapon and we run out of ammo, destroy the weapon
    if ( bHandToHand && (ReloadCount > 0) && (SimAmmoAmount <= 0))
    {
        DestroyOnFinish();
        if ( Role < ROLE_Authority )
        {
            ServerGotoFinishFire();
            GotoState('SimQuickFinish');
        }
    }
}

//
// OwnerHandToHandAttack
// called by the MESH NOTIFY for this weapon's owner
//
simulated function OwnerHandToHandAttack()
{
    local bool bOwnerIsPlayerPawn;

    if (!bOwnerWillNotify)
        return;

    // The controlling animator should be the one to do the tracefire and projfire
    if ( Level.NetMode != NM_Standalone )
    {
        bOwnerIsPlayerPawn = (DeusExPlayer(Owner) == DeusExPlayer(GetPlayerPawn()));

        if (( Role < ROLE_Authority ) && bOwnerIsPlayerPawn )
            ServerHandleNotify( bInstantHit, ProjectileClass, ProjectileSpeed, bWarnTarget );
        else if ( !bOwnerIsPlayerPawn )
            return;
    }

    if (ScriptedPawn(Owner) != None)
        ScriptedPawn(Owner).SetAttackAngle();

    if (bInstantHit)
        TraceFire(0.0);
    else
        ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);
}

function ForceFire()
{
    Fire(0);
}

function ForceAltFire()
{
    AltFire(0);
}

//
// ReadyClientToFire is called by the server telling the client it's ok to fire now
//

simulated function ReadyClientToFire( bool bReady )
{
    bClientReadyToFire = bReady;
}

//
// ClientReFire is called when the client is holding down the fire button, loop firing
//

simulated function ClientReFire( float value )
{
    bClientReadyToFire = True;
    bLooping = True;
    bInProcess = False;
    ClientFire(0);
}

function StartFlame()
{
    flameShotCount = 0;
    bFlameOn = True;
    GotoState('FlameThrowerOn');
}

function StopFlame()
{
    bFlameOn = False;
}

//
// ServerForceFire is called from the client when loop firing
//
function ServerForceFire()
{
    bClientReady = True;
    Fire(0);
}

simulated function int PlaySimSound( Sound snd, ESoundSlot Slot, float Volume, float Radius )
{
    if ( Owner != None )
    {
        if ( Level.NetMode == NM_Standalone )
            return ( Owner.PlaySound( snd, Slot, Volume, , Radius ) );
        else
        {
            Owner.PlayOwnedSound( snd, Slot, Volume, , Radius );
            return 1;
        }
    }
    return 0;
}

//
// ClientFire - Attempts to play the firing anim, sounds, and trace fire hits for instant weapons immediately
//				on the client.  The server may have a different interpretation of what actually happen, but this at least
//				cuts down on preceived lag.
//
simulated function bool ClientFire( float value )
{
    local bool bWaitOnAnim;
    local vector shake;

    // check for surrounding environment
    if ((EnviroEffective == ENVEFF_Air) || (EnviroEffective == ENVEFF_Vacuum) || (EnviroEffective == ENVEFF_AirVacuum))
    {
        if (Region.Zone.bWaterZone)
        {
            if (Pawn(Owner) != None)
            {
                Pawn(Owner).ClientMessage(msgNotWorking);
                if (!bHandToHand)
                    PlaySimSound( Misc1Sound, SLOT_None, TransientSoundVolume * 2.0, 1024 );
            }
            return false;
        }
    }

    if ( !bLooping ) // Wait on animations when not looping
    {
        bWaitOnAnim = ( IsAnimating() && ((AnimSequence == 'Select') || (AnimSequence == 'Shoot') || (AnimSequence == 'ReloadBegin') || (AnimSequence == 'Reload') || (AnimSequence == 'ReloadEnd') || (AnimSequence == 'Down')));
    }
    else
    {
        bWaitOnAnim = False;
        bLooping = False;
    }

    if ( (Owner.IsA('DeusExPlayer') && (DeusExPlayer(Owner).NintendoImmunityTimeLeft > 0.01)) ||
          (!bClientReadyToFire) || bInProcess || bWaitOnAnim )
    {
        DeusExPlayer(Owner).bJustFired = False;
        bPointing = False;
        bFiring = False;
        return false;
    }

    if ( !Self.IsA('WeaponFlamethrower') )
        ServerForceFire();

    if (bHandToHand)
    {
        SimAmmoAmount = AmmoType.AmmoAmount - 1;

        bClientReadyToFire = False;
        bInProcess = True;
        GotoState('ClientFiring');
        bPointing = True;
        if ( PlayerPawn(Owner) != None )
            PlayerPawn(Owner).PlayFiring();
        PlaySelectiveFiring();
        PlayFiringSound();
    }
    else if ((ClipCount < ReloadCount) || (ReloadCount == 0))
    {
        if ((ReloadCount == 0) || (AmmoType.AmmoAmount > 0))
        {
            SimClipCount = ClipCount + 1;

            if ( AmmoType != None )
                AmmoType.SimUseAmmo();

            bFiring = True;
            bPointing = True;
            bClientReadyToFire = False;
            bInProcess = True;
            GotoState('ClientFiring');
            if ( PlayerPawn(Owner) != None )
            {
                shake.X = 0.0;
                shake.Y = 100.0 * (ShakeTime*0.5);
                shake.Z = 100.0 * -(currentAccuracy * ShakeVert);
                PlayerPawn(Owner).ClientShake( shake );
                PlayerPawn(Owner).PlayFiring();
            }
            // Don't play firing anim for 20mm
            if ( Ammo20mm(AmmoType) == None )
                PlaySelectiveFiring();
            PlayFiringSound();

            if ( bInstantHit &&  ( Ammo20mm(AmmoType) == None ))
                TraceFire(currentAccuracy);
            else
            {
                if ( !bFlameOn && Self.IsA('WeaponFlamethrower'))
                {
                    bFlameOn = True;
                    StartFlame();
                }
                ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);
            }
        }
        else
        {
            if ( Owner.IsA('DeusExPlayer') && DeusExPlayer(Owner).bAutoReload )
            {
                if ( MustReload() && CanReload() )
                {
                    bClientReadyToFire = False;
                    bInProcess = False;
                    if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
                        CycleAmmo();

                    ReloadAmmo();
                }
            }
            PlaySimSound( Misc1Sound, SLOT_None, TransientSoundVolume * 2.0, 1024 );        // play dry fire sound
        }
    }
    else
    {
        if ( Owner.IsA('DeusExPlayer') && DeusExPlayer(Owner).bAutoReload )
        {
            if ( MustReload() && CanReload() )
            {
                bClientReadyToFire = False;
                bInProcess = False;
                if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
                    CycleAmmo();
                ReloadAmmo();
            }
        }
        PlaySimSound( Misc1Sound, SLOT_None, TransientSoundVolume * 2.0, 1024 );        // play dry fire sound
    }
    return true;
}

//
// from Weapon.uc - modified so we can have the accuracy in TraceFire
//
function Fire(float Value)
{
    local float sndVolume;
    local bool bListenClient;

    bListenClient = (Owner.IsA('DeusExPlayer') && DeusExPlayer(Owner).PlayerIsListenClient());

    sndVolume = TransientSoundVolume;

    if ( Level.NetMode != NM_Standalone )  // Turn up the sounds a bit in mulitplayer
    {
        sndVolume = TransientSoundVolume * 2.0;
        if ( Owner.IsA('DeusExPlayer') && (DeusExPlayer(Owner).NintendoImmunityTimeLeft > 0.01) || (!bClientReady && (!bListenClient)) )
        {
            DeusExPlayer(Owner).bJustFired = False;
            bReadyToFire = True;
            bPointing = False;
            bFiring = False;
            return;
        }
    }
    // check for surrounding environment
    if ((EnviroEffective == ENVEFF_Air) || (EnviroEffective == ENVEFF_Vacuum) || (EnviroEffective == ENVEFF_AirVacuum))
    {
        if (Region.Zone.bWaterZone)
        {
            if (Pawn(Owner) != None)
            {
                Pawn(Owner).ClientMessage(msgNotWorking);
                if (!bHandToHand)
                    PlaySimSound( Misc1Sound, SLOT_None, sndVolume, 1024 );     // play dry fire sound
            }
            GotoState('Idle');
            return;
        }
    }


    if (bHandToHand)
    {
        if (ReloadCount > 0)
            AmmoType.UseAmmo(1);

        if (( Level.NetMode != NM_Standalone ) && !bListenClient )
            bClientReady = False;
        bReadyToFire = False;
        GotoState('NormalFire');
        bPointing=True;
        if ( Owner.IsA('PlayerPawn') )
            PlayerPawn(Owner).PlayFiring();
        PlaySelectiveFiring();
        PlayFiringSound();
    }
    // if we are a single-use weapon, then our ReloadCount is 0 and we don't use ammo
    else if ((ClipCount < ReloadCount) || (ReloadCount == 0))
    {
        if ((ReloadCount == 0) || AmmoType.UseAmmo(1))
        {
            if (( Level.NetMode != NM_Standalone ) && !bListenClient )
                bClientReady = False;

            ClipCount++;
            bFiring = True;
            bReadyToFire = False;
            GotoState('NormalFire');
            if (( Level.NetMode == NM_Standalone ) || ( Owner.IsA('DeusExPlayer') && DeusExPlayer(Owner).PlayerIsListenClient()) )
            {
                if ( PlayerPawn(Owner) != None )        // shake us based on accuracy
                    PlayerPawn(Owner).ShakeView(ShakeTime, currentAccuracy * ShakeMag + ShakeMag, currentAccuracy * ShakeVert);
            }
            bPointing=True;
            if ( bInstantHit )
                TraceFire(currentAccuracy);
            else
                ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);

            if ( Owner.IsA('PlayerPawn') )
                PlayerPawn(Owner).PlayFiring();
            // Don't play firing anim for 20mm
            if ( Ammo20mm(AmmoType) == None )
                PlaySelectiveFiring();
            PlayFiringSound();
            if ( Owner.bHidden )
                CheckVisibility();
        }
        else
            PlaySimSound( Misc1Sound, SLOT_None, sndVolume, 1024 );     // play dry fire sound
    }
    else
        PlaySimSound( Misc1Sound, SLOT_None, sndVolume, 1024 );     // play dry fire sound

    // Update ammo count on object belt
    if (DeusExPlayer(Owner) != None)
        DeusExPlayer(Owner).UpdateBeltText(Self);
}

function ReadyToFire()
{
    if (!bReadyToFire)
    {
        // BOOGER!
        //if (ScriptedPawn(Owner) != None)
        //	ScriptedPawn(Owner).ReadyToFire();
        bReadyToFire = True;
        if ( Level.NetMode != NM_Standalone )
            ReadyClientToFire( True );
    }
}

function PlayPostSelect()
{
    // let's not zero the ammo count anymore - you must always reload
//	ClipCount = 0;		
}

simulated function PlaySelectiveFiring()
{
    local Pawn aPawn;
    local float rnd;
    local Name anim;

    anim = 'Shoot';

    if (bHandToHand)
    {
        rnd = FRand();
        if (rnd < 0.33)
            anim = 'Attack';
        else if (rnd < 0.66)
            anim = 'Attack2';
        else
            anim = 'Attack3';
    }

    if (( Level.NetMode == NM_Standalone ) || ( DeusExPlayer(Owner) == DeusExPlayer(GetPlayerPawn())) )
    {
        if (bAutomatic)
            LoopAnim(anim,, 0.1);
        else
            PlayAnim(anim,,0.1);
    }
    else if ( Role == ROLE_Authority )
    {
        for ( aPawn = Level.PawnList; aPawn != None; aPawn = aPawn.nextPawn )
        {
            if ( aPawn.IsA('DeusExPlayer') && ( DeusExPlayer(Owner) != DeusExPlayer(aPawn) ) )
            {
                // If they can't see the weapon, don't bother
                if ( DeusExPlayer(aPawn).FastTrace( DeusExPlayer(aPawn).Location, Location ))
                    DeusExPlayer(aPawn).ClientPlayAnimation( Self, anim, 0.1, bAutomatic );
            }
        }
    }
}

simulated function PlayFiringSound()
{
    if (bHasSilencer)
        PlaySimSound( Sound'StealthPistolFire', SLOT_None, TransientSoundVolume, 2048 );
    else
    {
        // The sniper rifle sound is heard to it's range in multiplayer
        if ( ( Level.NetMode != NM_Standalone ) &&  Self.IsA('WeaponRifle') )   
            PlaySimSound( FireSound, SLOT_None, TransientSoundVolume, class'WeaponRifle'.Default.mpMaxRange );
        else
            PlaySimSound( FireSound, SLOT_None, TransientSoundVolume, 2048 );
    }
}

simulated function PlayIdleAnim()
{
    local float rnd;

    if (bZoomed || bNearWall)
        return;

    rnd = FRand();

    if (rnd < 0.1)
        PlayAnim('Idle1',,0.1);
    else if (rnd < 0.2)
        PlayAnim('Idle2',,0.1);
    else if (rnd < 0.3)
        PlayAnim('Idle3',,0.1);
}

//
// SpawnBlood
//

function SpawnBlood(Vector HitLocation, Vector HitNormal)
{
   if ((DeusExMPGame(Level.Game) != None) && (!DeusExMPGame(Level.Game).bSpawnEffects))
      return;

   spawn(class'BloodSpurt',,,HitLocation+HitNormal);
    spawn(class'BloodDrop',,,HitLocation+HitNormal);
    if (FRand() < 0.5)
        spawn(class'BloodDrop',,,HitLocation+HitNormal);
}

//
// SelectiveSpawnEffects - Continues the simulated chain for the owner, and spawns the effects for other players that can see them
//			No actually spawning occurs on the server itself.
//
simulated function SelectiveSpawnEffects( Vector HitLocation, Vector HitNormal, Actor Other, float Damage)
{
    local DeusExPlayer fxOwner;
    local Pawn aPawn;

    // The normal path before there was multiplayer
    if ( Level.NetMode == NM_Standalone )
    {
        SpawnEffects(HitLocation, HitNormal, Other, Damage);
        return;
    }

    fxOwner = DeusExPlayer(Owner);

    if ( Role == ROLE_Authority )
    {
        SpawnEffectSounds(HitLocation, HitNormal, Other, Damage );

        for ( aPawn = Level.PawnList; aPawn != None; aPawn = aPawn.nextPawn )
        {
            if ( aPawn.IsA('DeusExPlayer') && ( DeusExPlayer(aPawn) != fxOwner ) )
            {
                if ( DeusExPlayer(aPawn).FastTrace( DeusExPlayer(aPawn).Location, HitLocation ))
                    DeusExPlayer(aPawn).ClientSpawnHits( bPenetrating, bHandToHand, HitLocation, HitNormal, Other, Damage );
            }
        }
    }
    if ( fxOwner == DeusExPlayer(GetPlayerPawn()) )
    {
            fxOwner.ClientSpawnHits( bPenetrating, bHandToHand, HitLocation, HitNormal, Other, Damage );
            SpawnEffectSounds( HitLocation, HitNormal, Other, Damage );
    }
}

//
//	 SpawnEffectSounds - Plays the sound for the effect owner immediately, the server will play them for the other players
//	
simulated function SpawnEffectSounds( Vector HitLocation, Vector HitNormal, Actor Other, float Damage )
{
    if (bHandToHand)
    {
        // if we are hand to hand, play an appropriate sound
        if (Other.IsA('DeusExDecoration'))
            Owner.PlayOwnedSound(Misc3Sound, SLOT_None,,, 1024);
        else if (Other.IsA('Pawn'))
            Owner.PlayOwnedSound(Misc1Sound, SLOT_None,,, 1024);
        else if (Other.IsA('BreakableGlass'))
            Owner.PlayOwnedSound(sound'GlassHit1', SLOT_None,,, 1024);
        else if (GetWallMaterial(HitLocation, HitNormal) == 'Glass')
            Owner.PlayOwnedSound(sound'BulletProofHit', SLOT_None,,, 1024);
        else
            Owner.PlayOwnedSound(Misc2Sound, SLOT_None,,, 1024);
    }
}

//
//	SpawnEffects - Spawns the effects like it did in single player
//
function SpawnEffects(Vector HitLocation, Vector HitNormal, Actor Other, float Damage)
{
   local TraceHitSpawner hitspawner;
    local Name damageType;

    damageType = WeaponDamageType();

   if (bPenetrating)
   {
      if (bHandToHand)
      {
         hitspawner = Spawn(class'TraceHitHandSpawner',Other,,HitLocation,Rotator(HitNormal));
      }
      else
      {
         hitspawner = Spawn(class'TraceHitSpawner',Other,,HitLocation,Rotator(HitNormal));
      }
   }
   else
   {
      if (bHandToHand)
      {
         hitspawner = Spawn(class'TraceHitHandNonPenSpawner',Other,,HitLocation,Rotator(HitNormal));
      }
      else
      {
         hitspawner = Spawn(class'TraceHitNonPenSpawner',Other,,HitLocation,Rotator(HitNormal));
      }
   }
   if (hitSpawner != None)
    {
      hitspawner.HitDamage = Damage;
        hitSpawner.damageType = damageType;
    }
    if (bHandToHand)
    {
        // if we are hand to hand, play an appropriate sound
        if (Other.IsA('DeusExDecoration'))
            Owner.PlaySound(Misc3Sound, SLOT_None,,, 1024);
        else if (Other.IsA('Pawn'))
            Owner.PlaySound(Misc1Sound, SLOT_None,,, 1024);
        else if (Other.IsA('BreakableGlass'))
            Owner.PlaySound(sound'GlassHit1', SLOT_None,,, 1024);
        else if (GetWallMaterial(HitLocation, HitNormal) == 'Glass')
            Owner.PlaySound(sound'BulletProofHit', SLOT_None,,, 1024);
        else
            Owner.PlaySound(Misc2Sound, SLOT_None,,, 1024);
    }
}


function name GetWallMaterial(vector HitLocation, vector HitNormal)
{
    local vector EndTrace, StartTrace;
    local actor target;
    local int texFlags;
    local name texName, texGroup;

    StartTrace = HitLocation + HitNormal*16;        // make sure we start far enough out
    EndTrace = HitLocation - HitNormal;

    foreach TraceTexture(class'Actor', target, texName, texGroup, texFlags, StartTrace, HitNormal, EndTrace)
        if ((target == Level) || target.IsA('Mover'))
            break;

    return texGroup;
}

simulated function SimGenerateBullet()
{
    if ( Role < ROLE_Authority )
    {
        if ((ClipCount < ReloadCount) && (ReloadCount != 0))
        {
            if ( AmmoType != None )
                AmmoType.SimUseAmmo();

            if ( bInstantHit )
                TraceFire(currentAccuracy);
            else
                ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);

            SimClipCount++;

            if ( !Self.IsA('WeaponFlamethrower') )
                ServerGenerateBullet();
        }
        else
            GotoState('SimFinishFire');
    }
}

function DestroyOnFinish()
{
    bDestroyOnFinish = True;
}

function ServerGotoFinishFire()
{
    GotoState('FinishFire');
}

function ServerDoneReloading()
{
    ClipCount = 0;
}

function ServerGenerateBullet()
{
    if ( ClipCount < ReloadCount )
        GenerateBullet();
}

function GenerateBullet()
{
    if (AmmoType.UseAmmo(1))
    {
        if ( bInstantHit )
            TraceFire(currentAccuracy);
        else
            ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);

        ClipCount++;
    }
    else
        GotoState('FinishFire');
}


function PlayLandingSound()
{
    if (LandSound != None)
    {
        if (Velocity.Z <= -200)
        {
            PlaySound(LandSound, SLOT_None, TransientSoundVolume,, 768);
            AISendEvent('LoudNoise', EAITYPE_Audio, TransientSoundVolume, 768);
        }
    }
}


function GetWeaponRanges(out float wMinRange,
                         out float wMaxAccurateRange,
                         out float wMaxRange)
{
    local Class<DeusExProjectile> dxProjectileClass;

    dxProjectileClass = Class<DeusExProjectile>(ProjectileClass);
    if (dxProjectileClass != None)
    {
        wMinRange         = dxProjectileClass.Default.blastRadius;
        wMaxAccurateRange = dxProjectileClass.Default.AccurateRange;
        wMaxRange         = dxProjectileClass.Default.MaxRange;
    }
    else
    {
        wMinRange         = 0;
        wMaxAccurateRange = AccurateRange;
        wMaxRange         = MaxRange;
    }
}

//
// computes the start position of a projectile/trace
//
simulated function Vector ComputeProjectileStart(Vector X, Vector Y, Vector Z)
{
    local Vector Start;

    // if we are instant-hit, non-projectile, then don't offset our starting point by PlayerViewOffset
    if (bInstantHit)
        Start = Owner.Location + Pawn(Owner).BaseEyeHeight * vect(0,0,1);// - Vector(Pawn(Owner).ViewRotation)*(0.9*Pawn(Owner).CollisionRadius);
    else
        Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;

    return Start;
}

//
// Modified to work better with scripted pawns
//
simulated function vector CalcDrawOffset()
{
    local vector        DrawOffset, WeaponBob;
    local ScriptedPawn  SPOwner;
    local Pawn          PawnOwner;

    SPOwner = ScriptedPawn(Owner);
    if (SPOwner != None)
    {
        DrawOffset = ((0.9/SPOwner.FOVAngle * PlayerViewOffset) >> SPOwner.ViewRotation);
        DrawOffset += (SPOwner.BaseEyeHeight * vect(0,0,1));
    }
    else
    {
        // copied from Engine.Inventory to not be FOVAngle dependent
        PawnOwner = Pawn(Owner);
        DrawOffset = ((0.9/PawnOwner.Default.FOVAngle * PlayerViewOffset) >> PawnOwner.ViewRotation);

        DrawOffset += (PawnOwner.EyeHeight * vect(0,0,1));
        WeaponBob = BobDamping * PawnOwner.WalkBob;
        WeaponBob.Z = (0.45 + 0.55 * BobDamping) * PawnOwner.WalkBob.Z;
        DrawOffset += WeaponBob;
    }

    return DrawOffset;
}

function GetAIVolume(out float volume, out float radius)
{
    volume = 0;
    radius = 0;

    if (!bHasSilencer && !bHandToHand)
    {
        volume = NoiseLevel*Pawn(Owner).SoundDampening;
        radius = volume * 800.0;
    }
}


//
// copied from Weapon.uc
//
simulated function Projectile ProjectileFire(class<projectile> ProjClass, float ProjSpeed, bool bWarn)
{
    local Vector Start, X, Y, Z;
    local DeusExProjectile proj;
    local float mult;
    local float volume, radius;
    local int i, numProj;
    local Pawn aPawn;

    // AugCombat increases our speed (distance) if hand to hand
    mult = 1.0;
    if (bHandToHand && (DeusExPlayer(Owner) != None))
    {
        mult = DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
        if (mult == -1.0)
            mult = 1.0;
        ProjSpeed *= mult;
    }

    // skill also affects our damage
    // GetWeaponSkill returns 0.0 to -0.7 (max skill/aug)
    mult += -2.0 * GetWeaponSkill();

    // make noise if we are not silenced
    if (!bHasSilencer && !bHandToHand)
    {
        GetAIVolume(volume, radius);
        Owner.AISendEvent('WeaponFire', EAITYPE_Audio, volume, radius);
        Owner.AISendEvent('LoudNoise', EAITYPE_Audio, volume, radius);
        if (!Owner.IsA('PlayerPawn'))
            Owner.AISendEvent('Distress', EAITYPE_Audio, volume, radius);
    }

    // should we shoot multiple projectiles in a spread?
    if (AreaOfEffect == AOE_Cone)
        numProj = 3;
    else
        numProj = 1;

    GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
    Start = ComputeProjectileStart(X, Y, Z);

    for (i=0; i<numProj; i++)
    {
      // If we have multiple slugs, then lower our accuracy a bit after the first slug so the slugs DON'T all go to the same place
      if ((i > 0) && (Level.NetMode != NM_Standalone))
         if (currentAccuracy < MinProjSpreadAcc)
            currentAccuracy = MinProjSpreadAcc;
         
        AdjustedAim = pawn(owner).AdjustAim(ProjSpeed, Start, AimError, True, bWarn);
        AdjustedAim.Yaw += currentAccuracy * (Rand(1024) - 512);
        AdjustedAim.Pitch += currentAccuracy * (Rand(1024) - 512);


        if (( Level.NetMode == NM_Standalone ) || ( Owner.IsA('DeusExPlayer') && DeusExPlayer(Owner).PlayerIsListenClient()) )
        {
            proj = DeusExProjectile(Spawn(ProjClass, Owner,, Start, AdjustedAim));
            if (proj != None)
            {
                // AugCombat increases our damage as well
                proj.Damage *= mult;

                // send the targetting information to the projectile
                if (bCanTrack && (LockTarget != None) && (LockMode == LOCK_Locked))
                {
                    proj.Target = LockTarget;
                    proj.bTracking = True;
                }
            }
        }
        else
        {
            if (( Role == ROLE_Authority ) || (DeusExPlayer(Owner) == DeusExPlayer(GetPlayerPawn())) )
            {
                // Do it the old fashioned way if it can track, or if we are a projectile that we could pick up again
                if ( bCanTrack || Self.IsA('WeaponShuriken') || Self.IsA('WeaponMiniCrossbow') || Self.IsA('WeaponLAM') || Self.IsA('WeaponEMPGrenade') || Self.IsA('WeaponGasGrenade'))
                {
                    if ( Role == ROLE_Authority )
                    {
                        proj = DeusExProjectile(Spawn(ProjClass, Owner,, Start, AdjustedAim));
                        if (proj != None)
                        {
                            // AugCombat increases our damage as well
                                proj.Damage *= mult;
                            // send the targetting information to the projectile
                            if (bCanTrack && (LockTarget != None) && (LockMode == LOCK_Locked))
                            {
                                proj.Target = LockTarget;
                                proj.bTracking = True;
                            }
                        }
                    }
                }
                else
                {
                    proj = DeusExProjectile(Spawn(ProjClass, Owner,, Start, AdjustedAim));
                    if (proj != None)
                    {
                        proj.RemoteRole = ROLE_None;
                        // AugCombat increases our damage as well
                        if ( Role == ROLE_Authority )
                            proj.Damage *= mult;
                        else
                            proj.Damage = 0;
                    }
                    if ( Role == ROLE_Authority )
                    {
                        for ( aPawn = Level.PawnList; aPawn != None; aPawn = aPawn.nextPawn )
                        {
                            if ( aPawn.IsA('DeusExPlayer') && ( DeusExPlayer(aPawn) != DeusExPlayer(Owner) ))
                                DeusExPlayer(aPawn).ClientSpawnProjectile( ProjClass, Owner, Start, AdjustedAim );
                        }
                    }
                }
            }
        }

    }
    return proj;
}

//
// copied from Weapon.uc so we can add range information
//
simulated function TraceFire( float Accuracy )
{
    local vector HitLocation, HitNormal, StartTrace, EndTrace, X, Y, Z;
    local Rotator rot;
    local actor Other;
    local float dist, alpha, degrade;
    local int i, numSlugs;
    local float volume, radius;

    // make noise if we are not silenced
    if (!bHasSilencer && !bHandToHand)
    {
        GetAIVolume(volume, radius);
        Owner.AISendEvent('WeaponFire', EAITYPE_Audio, volume, radius);
        Owner.AISendEvent('LoudNoise', EAITYPE_Audio, volume, radius);
        if (!Owner.IsA('PlayerPawn'))
            Owner.AISendEvent('Distress', EAITYPE_Audio, volume, radius);
    }

    GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
    StartTrace = ComputeProjectileStart(X, Y, Z);
    AdjustedAim = pawn(owner).AdjustAim(1000000, StartTrace, 2.75*AimError, False, False);

    // check to see if we are a shotgun-type weapon
    if (AreaOfEffect == AOE_Cone)
        numSlugs = 5;
    else
        numSlugs = 1;

    // if there is a scope, but the player isn't using it, decrease the accuracy
    // so there is an advantage to using the scope
    if (bHasScope && !bZoomed)
        Accuracy += 0.2;
    // if the laser sight is on, make this shot dead on
    // also, if the scope is on, zero the accuracy so the shake makes the shot inaccurate
    else if (bLasing || bZoomed)
        Accuracy = 0.0;


    for (i=0; i<numSlugs; i++)
    {
      // If we have multiple slugs, then lower our accuracy a bit after the first slug so the slugs DON'T all go to the same place
      if ((i > 0) && (Level.NetMode != NM_Standalone) && !(bHandToHand))
         if (Accuracy < MinSpreadAcc)
            Accuracy = MinSpreadAcc;

      // Let handtohand weapons have a better swing
      if ((bHandToHand) && (NumSlugs > 1) && (Level.NetMode != NM_Standalone))
      {
         StartTrace = ComputeProjectileStart(X,Y,Z);
         StartTrace = StartTrace + (numSlugs/2 - i) * SwingOffset;
      }

      EndTrace = StartTrace + Accuracy * (FRand()-0.5)*Y*1000 + Accuracy * (FRand()-0.5)*Z*1000 ;
      EndTrace += (FMax(1024.0, MaxRange) * vector(AdjustedAim));
      
      Other = Pawn(Owner).TraceShot(HitLocation,HitNormal,EndTrace,StartTrace);

        // randomly draw a tracer for relevant ammo types
        // don't draw tracers if we're zoomed in with a scope - looks stupid
      // DEUS_EX AMSD In multiplayer, draw tracers all the time.
        if ( ((Level.NetMode == NM_Standalone) && (!bZoomed && (numSlugs == 1) && (FRand() < 0.5))) ||
           ((Level.NetMode != NM_Standalone) && (Role == ROLE_Authority) && (numSlugs == 1)) )
        {
            if ((AmmoName == Class'Ammo10mm') || (AmmoName == Class'Ammo3006') ||
                (AmmoName == Class'Ammo762mm'))
            {
                if (VSize(HitLocation - StartTrace) > 250)
                {
                    rot = Rotator(EndTrace - StartTrace);
               if ((Level.NetMode != NM_Standalone) && (Self.IsA('WeaponRifle')))
                  Spawn(class'SniperTracer',,, StartTrace + 96 * Vector(rot), rot);
               else
                  Spawn(class'Tracer',,, StartTrace + 96 * Vector(rot), rot);
                }
            }
        }

        // check our range
        dist = Abs(VSize(HitLocation - Owner.Location));

        if (dist <= AccurateRange)      // we hit just fine
            ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
        else if (dist <= MaxRange)
        {
            // simulate gravity by lowering the bullet's hit point
            // based on the owner's distance from the ground
            alpha = (dist - AccurateRange) / (MaxRange - AccurateRange);
            degrade = 0.5 * Square(alpha);
            HitLocation.Z += degrade * (Owner.Location.Z - Owner.CollisionHeight);
            ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
        }
    }

    // otherwise we don't hit the target at all
}

simulated function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
    local float        mult;
    local name         damageType;
    local DeusExPlayer dxPlayer;

    if (Other != None)
    {
        // AugCombat increases our damage if hand to hand
        mult = 1.0;
        if (bHandToHand && (DeusExPlayer(Owner) != None))
        {
            mult = DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
            if (mult == -1.0)
                mult = 1.0;
        }

        // skill also affects our damage
        // GetWeaponSkill returns 0.0 to -0.7 (max skill/aug)
        mult += -2.0 * GetWeaponSkill();

        // Determine damage type
        damageType = WeaponDamageType();

        if (Other != None)
        {
            if (Other.bOwned)
            {
                dxPlayer = DeusExPlayer(Owner);
                if (dxPlayer != None)
                    dxPlayer.AISendEvent('Futz', EAITYPE_Visual);
            }
        }
        if ((Other == Level) || (Other.IsA('Mover')))
        {
            if ( Role == ROLE_Authority )
                Other.TakeDamage(HitDamage * mult, Pawn(Owner), HitLocation, 1000.0*X, damageType);

            SelectiveSpawnEffects( HitLocation, HitNormal, Other, HitDamage * mult);
        }
        else if ((Other != self) && (Other != Owner))
        {
            if ( Role == ROLE_Authority )
                Other.TakeDamage(HitDamage * mult, Pawn(Owner), HitLocation, 1000.0*X, damageType);
            if (bHandToHand)
                SelectiveSpawnEffects( HitLocation, HitNormal, Other, HitDamage * mult);

            if (bPenetrating && Other.IsA('Pawn') && !Other.IsA('Robot'))
                SpawnBlood(HitLocation, HitNormal);
        }
    }
   if (DeusExMPGame(Level.Game) != None)
   {
      if (DeusExPlayer(Other) != None)
         DeusExMPGame(Level.Game).TrackWeapon(self,HitDamage * mult);
      else
         DeusExMPGame(Level.Game).TrackWeapon(self,0);
   }
}

simulated function IdleFunction()
{
    PlayIdleAnim();
    bInProcess = False;
    if ( bFlameOn )
    {
        StopFlame();
        bFlameOn = False;
    }
}

simulated function SimFinish()
{
    ServerGotoFinishFire();

    bInProcess = False;
    bFiring = False;

    if ( bFlameOn )
    {
        StopFlame();
        bFlameOn = False;
    }

    if (bHasMuzzleFlash)
        EraseMuzzleFlashTexture();

    if ( Owner.IsA('DeusExPlayer') && DeusExPlayer(Owner).bAutoReload )
    {
        if ( (SimClipCount >= ReloadCount) && CanReload() )
        {
            SimClipCount = 0;
            bClientReadyToFire = False;
            bInProcess = False;
            if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
                CycleAmmo();
            ReloadAmmo();
        }
    }

    if (Pawn(Owner) == None)
    {
        GotoState('SimIdle');
        return;
    }
    if ( PlayerPawn(Owner) == None )
    {
        if ( (Pawn(Owner).bFire != 0) && (FRand() < RefireRate) )
            ClientReFire(0);
        else
            GotoState('SimIdle');
        return;
    }
    if ( Pawn(Owner).bFire != 0 )
        ClientReFire(0);
    else
        GotoState('SimIdle');
}

// Finish a firing sequence (ripped off and modified from Engine\Weapon.uc)
function Finish()
{
    if ( Level.NetMode != NM_Standalone )
        ReadyClientToFire( True );
    
    if (bHasMuzzleFlash)
        EraseMuzzleFlashTexture();

    if ( bChangeWeapon )
    {
        GotoState('DownWeapon');
        return;
    }

    if (( Level.NetMode != NM_Standalone ) && IsInState('Active'))
    {
        GotoState('Idle');
        return;
    }

    if (Pawn(Owner) == None)
    {
        GotoState('Idle');
        return;
    }
    if ( PlayerPawn(Owner) == None )
    {
        //bFireMem = false;
        //bAltFireMem = false;
        if ( ((AmmoType==None) || (AmmoType.AmmoAmount<=0)) && ReloadCount!=0 )
        {
            Pawn(Owner).StopFiring();
            Pawn(Owner).SwitchToBestWeapon();
        }
        else if ( (Pawn(Owner).bFire != 0) && (FRand() < RefireRate) )
            Global.Fire(0);
        else if ( (Pawn(Owner).bAltFire != 0) && (FRand() < AltRefireRate) )
            Global.AltFire(0);  
        else 
        {
            Pawn(Owner).StopFiring();
            GotoState('Idle');
        }
        return;
    }

    if (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient()))
    {
        GotoState('Idle');
        return;
    }

    if ( ((AmmoType==None) || (AmmoType.AmmoAmount<=0)) || (Pawn(Owner).Weapon != self) )
        GotoState('Idle');
    else if ( /*bFireMem ||*/ Pawn(Owner).bFire!=0 )
        Global.Fire(0);
    else if ( /*bAltFireMem ||*/ Pawn(Owner).bAltFire!=0 )
        Global.AltFire(0);
    else 
        GotoState('Idle');
}

// ----------------------------------------------------------------------
// UpdateInfo()
// ----------------------------------------------------------------------

simulated function bool UpdateInfo(Object winObject)
{
    local PersonaInventoryInfoWindow winInfo;
    local string str;
    local int i, dmg;
    local float mod;
    local bool bHasAmmo;
    local bool bAmmoAvailable;
    local class<DeusExAmmo> ammoClass;
    local Pawn P;
    local Ammo weaponAmmo;
    local int  ammoAmount;

    P = Pawn(Owner);
    if (P == None)
        return False;

    winInfo = PersonaInventoryInfoWindow(winObject);
    if (winInfo == None)
        return False;

    winInfo.SetTitle(itemName);
    winInfo.SetText(msgInfoWeaponStats);
    winInfo.AddLine();

    // Create the ammo buttons.  Start with the AmmoNames[] array,
    // which is used for weapons that can use more than one 
    // type of ammo.

    if (AmmoNames[0] != None)
    {
        for (i=0; i<ArrayCount(AmmoNames); i++)
        {
            if (AmmoNames[i] != None) 
            {
                // Check to make sure the player has this ammo type
                // *and* that the ammo isn't empty
                weaponAmmo = Ammo(P.FindInventoryType(AmmoNames[i]));

                if (weaponAmmo != None)
                {
                    ammoAmount = weaponAmmo.AmmoAmount;
                    bHasAmmo = (weaponAmmo.AmmoAmount > 0);
                }
                else
                {
                    ammoAmount = 0;
                    bHasAmmo = False;
                }

                winInfo.AddAmmo(AmmoNames[i], bHasAmmo, ammoAmount);
                bAmmoAvailable = True;

                if (AmmoNames[i] == AmmoName)
                {
                    winInfo.SetLoaded(AmmoName);
                    ammoClass = class<DeusExAmmo>(AmmoName);
                }
            }
        }
    }
    else
    {
        // Now peer at the AmmoName variable, but only if the AmmoNames[] 
        // array is empty
        if ((AmmoName != class'AmmoNone') && (!bHandToHand) && (ReloadCount != 0))
        {   
            weaponAmmo = Ammo(P.FindInventoryType(AmmoName));

            if (weaponAmmo != None)
            {
                ammoAmount = weaponAmmo.AmmoAmount;
                bHasAmmo = (weaponAmmo.AmmoAmount > 0);
            }
            else
            {
                ammoAmount = 0;
                bHasAmmo = False;
            }

            winInfo.AddAmmo(AmmoName, bHasAmmo, ammoAmount);
            winInfo.SetLoaded(AmmoName);
            ammoClass = class<DeusExAmmo>(AmmoName);
            bAmmoAvailable = True;
        }
    }

    // Only draw another line if we actually displayed ammo.
    if (bAmmoAvailable)
        winInfo.AddLine();  

    // Ammo loaded
    if ((AmmoName != class'AmmoNone') && (!bHandToHand) && (ReloadCount != 0))
        winInfo.AddAmmoLoadedItem(msgInfoAmmoLoaded, AmmoType.itemName);

    // ammo info
    if ((AmmoName == class'AmmoNone') || bHandToHand || (ReloadCount == 0))
        str = msgInfoNA;
    else
        str = AmmoName.Default.ItemName;
    for (i=0; i<ArrayCount(AmmoNames); i++)
        if ((AmmoNames[i] != None) && (AmmoNames[i] != AmmoName))
            str = str $ "|n" $ AmmoNames[i].Default.ItemName;

    winInfo.AddAmmoTypesItem(msgInfoAmmo, str);

    // base damage
    if (AreaOfEffect == AOE_Cone)
    {
        if (bInstantHit)
        {
            if (Level.NetMode != NM_Standalone)
                dmg = Default.mpHitDamage * 5;
            else
                dmg = Default.HitDamage * 5;
        }
        else
        {
            if (Level.NetMode != NM_Standalone)
                dmg = Default.mpHitDamage * 3;
            else
                dmg = Default.HitDamage * 3;
        }
    }
    else
    {
        if (Level.NetMode != NM_Standalone)
            dmg = Default.mpHitDamage;
        else
            dmg = Default.HitDamage;
    }

    str = String(dmg);
    mod = 1.0 - GetWeaponSkill();
    if (mod != 1.0)
    {
        str = str @ BuildPercentString(mod - 1.0);
        str = str @ "=" @ FormatFloatString(dmg * mod, 1.0);
    }

    winInfo.AddInfoItem(msgInfoDamage, str, (mod != 1.0));

    // clip size
    if ((Default.ReloadCount == 0) || bHandToHand)
        str = msgInfoNA;
    else
    {
        if ( Level.NetMode != NM_Standalone )
            str = Default.mpReloadCount @ msgInfoRounds;
        else
            str = Default.ReloadCount @ msgInfoRounds;
    }

    if (HasClipMod())
    {
        str = str @ BuildPercentString(ModReloadCount);
        str = str @ "=" @ ReloadCount @ msgInfoRounds;
    }

    winInfo.AddInfoItem(msgInfoClip, str, HasClipMod());

    // rate of fire
    if ((Default.ReloadCount == 0) || bHandToHand)
    {
        str = msgInfoNA;
    }
    else
    {
        if (bAutomatic)
            str = msgInfoAuto;
        else
            str = msgInfoSingle;

        str = str $ "," @ FormatFloatString(1.0/Default.ShotTime, 0.1) @ msgInfoRoundsPerSec;
    }
    winInfo.AddInfoItem(msgInfoROF, str);

    // reload time
    if ((Default.ReloadCount == 0) || bHandToHand)
        str = msgInfoNA;
    else
    {
        if (Level.NetMode != NM_Standalone )
            str = FormatFloatString(Default.mpReloadTime, 0.1) @ msgTimeUnit;
        else
            str = FormatFloatString(Default.ReloadTime, 0.1) @ msgTimeUnit;
    }

    if (HasReloadMod())
    {
        str = str @ BuildPercentString(ModReloadTime);
        str = str @ "=" @ FormatFloatString(ReloadTime, 0.1) @ msgTimeUnit;
    }

    winInfo.AddInfoItem(msgInfoReload, str, HasReloadMod());

    // recoil
    str = FormatFloatString(Default.recoilStrength, 0.01);
    if (HasRecoilMod())
    {
        str = str @ BuildPercentString(ModRecoilStrength);
        str = str @ "=" @ FormatFloatString(recoilStrength, 0.01);
    }

    winInfo.AddInfoItem(msgInfoRecoil, str, HasRecoilMod());

    // base accuracy (2.0 = 0%, 0.0 = 100%)
    if ( Level.NetMode != NM_Standalone )
    {
        str = Int((2.0 - Default.mpBaseAccuracy)*50.0) $ "%";
        mod = (Default.mpBaseAccuracy - (BaseAccuracy + GetWeaponSkill())) * 0.5;
        if (mod != 0.0)
        {
            str = str @ BuildPercentString(mod);
            str = str @ "=" @ Min(100, Int(100.0*mod+(2.0 - Default.mpBaseAccuracy)*50.0)) $ "%";
        }
    }
    else
    {
        str = Int((2.0 - Default.BaseAccuracy)*50.0) $ "%";
        mod = (Default.BaseAccuracy - (BaseAccuracy + GetWeaponSkill())) * 0.5;
        if (mod != 0.0)
        {
            str = str @ BuildPercentString(mod);
            str = str @ "=" @ Min(100, Int(100.0*mod+(2.0 - Default.BaseAccuracy)*50.0)) $ "%";
        }
    }
    winInfo.AddInfoItem(msgInfoAccuracy, str, (mod != 0.0));

    // accurate range
    if (bHandToHand)
        str = msgInfoNA;
    else
    {
        if ( Level.NetMode != NM_Standalone )
            str = FormatFloatString(Default.mpAccurateRange/16.0, 1.0) @ msgRangeUnit;
        else
            str = FormatFloatString(Default.AccurateRange/16.0, 1.0) @ msgRangeUnit;
    }

    if (HasRangeMod())
    {
        str = str @ BuildPercentString(ModAccurateRange);
        str = str @ "=" @ FormatFloatString(AccurateRange/16.0, 1.0) @ msgRangeUnit;
    }
    winInfo.AddInfoItem(msgInfoAccRange, str, HasRangeMod());

    // max range
    if (bHandToHand)
        str = msgInfoNA;
    else
    {
        if ( Level.NetMode != NM_Standalone )
            str = FormatFloatString(Default.mpMaxRange/16.0, 1.0) @ msgRangeUnit;
        else
            str = FormatFloatString(Default.MaxRange/16.0, 1.0) @ msgRangeUnit;
    }
    winInfo.AddInfoItem(msgInfoMaxRange, str);

    // mass
    winInfo.AddInfoItem(msgInfoMass, FormatFloatString(Default.Mass, 1.0) @ msgMassUnit);

    // laser mod
    if (bCanHaveLaser)
    {
        if (bHasLaser)
            str = msgInfoYes;
        else
            str = msgInfoNo;
    }
    else
    {
        str = msgInfoNA;
    }
    winInfo.AddInfoItem(msgInfoLaser, str, bCanHaveLaser && bHasLaser && (Default.bHasLaser != bHasLaser));

    // scope mod
    if (bCanHaveScope)
    {
        if (bHasScope)
            str = msgInfoYes;
        else
            str = msgInfoNo;
    }
    else
    {
        str = msgInfoNA;
    }
    winInfo.AddInfoItem(msgInfoScope, str, bCanHaveScope && bHasScope && (Default.bHasScope != bHasScope));

    // silencer mod
    if (bCanHaveSilencer)
    {
        if (bHasSilencer)
            str = msgInfoYes;
        else
            str = msgInfoNo;
    }
    else
    {
        str = msgInfoNA;
    }
    winInfo.AddInfoItem(msgInfoSilencer, str, bCanHaveSilencer && bHasSilencer && (Default.bHasSilencer != bHasSilencer));

    // Governing Skill
    winInfo.AddInfoItem(msgInfoSkill, GoverningSkill.default.SkillName);

    winInfo.AddLine();
    winInfo.SetText(Description);

    // If this weapon has ammo info, display it here
    if (ammoClass != None)
    {
        winInfo.AddLine();
        winInfo.AddAmmoDescription(ammoClass.Default.ItemName $ "|n" $ ammoClass.Default.description);
    }

    return True;
}

// ----------------------------------------------------------------------
// UpdateAmmoInfo()
// ----------------------------------------------------------------------

simulated function UpdateAmmoInfo(Object winObject, Class<DeusExAmmo> ammoClass)
{
    local PersonaInventoryInfoWindow winInfo;
    local string str;
    local int i;

    winInfo = PersonaInventoryInfoWindow(winObject);
    if (winInfo == None)
        return;

    // Ammo loaded
    if ((AmmoName != class'AmmoNone') && (!bHandToHand) && (ReloadCount != 0))
        winInfo.UpdateAmmoLoaded(AmmoType.itemName);

    // ammo info
    if ((AmmoName == class'AmmoNone') || bHandToHand || (ReloadCount == 0))
        str = msgInfoNA;
    else
        str = AmmoName.Default.ItemName;
    for (i=0; i<ArrayCount(AmmoNames); i++)
        if ((AmmoNames[i] != None) && (AmmoNames[i] != AmmoName))
            str = str $ "|n" $ AmmoNames[i].Default.ItemName;

    winInfo.UpdateAmmoTypes(str);

    // If this weapon has ammo info, display it here
    if (ammoClass != None)
        winInfo.UpdateAmmoDescription(ammoClass.Default.ItemName $ "|n" $ ammoClass.Default.description);
}

// ----------------------------------------------------------------------
// BuildPercentString()
// ----------------------------------------------------------------------

simulated final function String BuildPercentString(Float value)
{
    local string str;

    str = String(Int(Abs(value * 100.0)));
    if (value < 0.0)
        str = "-" $ str;
    else
        str = "+" $ str;

    return ("(" $ str $ "%)");
}

// ----------------------------------------------------------------------
// FormatFloatString()
// ----------------------------------------------------------------------

simulated function String FormatFloatString(float value, float precision)
{
    local string str;

    if (precision == 0.0)
        return "ERR";

    // build integer part
    str = String(Int(value));

    // build decimal part
    if (precision < 1.0)
    {
        value -= Int(value);
        str = str $ "." $ String(Int((0.5 * precision) + value * (1.0 / precision)));
    }

    return str;
}

// ----------------------------------------------------------------------
// CR()
// ----------------------------------------------------------------------

simulated function String CR()
{
    return Chr(13) $ Chr(10);
}

// ----------------------------------------------------------------------
// HasReloadMod()
// ----------------------------------------------------------------------

simulated function bool HasReloadMod()
{
    return (ModReloadTime != 0.0);
}

// ----------------------------------------------------------------------
// HasMaxReloadMod()
// ----------------------------------------------------------------------

simulated function bool HasMaxReloadMod()
{
    return (ModReloadTime == -0.5);
}

// ----------------------------------------------------------------------
// HasClipMod()
// ----------------------------------------------------------------------

simulated function bool HasClipMod()
{
    return (ModReloadCount != 0.0);
}

// ----------------------------------------------------------------------
// HasMaxClipMod()
// ----------------------------------------------------------------------

simulated function bool HasMaxClipMod()
{
    return (ModReloadCount == 0.5);
}

// ----------------------------------------------------------------------
// HasRangeMod()
// ----------------------------------------------------------------------

simulated function bool HasRangeMod()
{
    return (ModAccurateRange != 0.0);
}

// ----------------------------------------------------------------------
// HasMaxRangeMod()
// ----------------------------------------------------------------------

simulated function bool HasMaxRangeMod()
{
    return (ModAccurateRange == 0.5);
}

// ----------------------------------------------------------------------
// HasAccuracyMod()
// ----------------------------------------------------------------------

simulated function bool HasAccuracyMod()
{
    return (ModBaseAccuracy != 0.0);
}

// ----------------------------------------------------------------------
// HasMaxAccuracyMod()
// ----------------------------------------------------------------------

simulated function bool HasMaxAccuracyMod()
{
    return (ModBaseAccuracy == 0.5);
}

// ----------------------------------------------------------------------
// HasRecoilMod()
// ----------------------------------------------------------------------

simulated function bool HasRecoilMod()
{
    return (ModRecoilStrength != 0.0);
}

// ----------------------------------------------------------------------
// HasMaxRecoilMod()
// ----------------------------------------------------------------------

simulated function bool HasMaxRecoilMod()
{
    return (ModRecoilStrength == -0.5);
}

// ----------------------------------------------------------------------
// ClientDownWeapon()
// ----------------------------------------------------------------------

simulated function ClientDownWeapon()
{
    bWasInFiring = IsInState('ClientFiring') || IsInState('SimFinishFire');
    bClientReadyToFire = False;
    GotoState('SimDownWeapon');
}

simulated function ClientActive()
{
    bWasInFiring = IsInState('ClientFiring') || IsInState('SimFinishFire');
    bClientReadyToFire = False;
    GotoState('SimActive');
}

simulated function ClientReload()
{
    bWasInFiring = IsInState('ClientFiring') || IsInState('SimFinishFire');
    bClientReadyToFire = False;
    GotoState('SimReload');
}

//
// weapon states
//

state NormalFire
{
    function AnimEnd()
    {
        if (bAutomatic)
        {
            if ((Pawn(Owner).bFire != 0) && (AmmoType.AmmoAmount > 0))
            {
                if (PlayerPawn(Owner) != None)
                    Global.Fire(0);
                else 
                    GotoState('FinishFire');
            }
            else 
                GotoState('FinishFire');
        }
        else
        {
            // if we are a thrown weapon and we run out of ammo, destroy the weapon
            if (bHandToHand && (ReloadCount > 0) && (AmmoType.AmmoAmount <= 0))
                Destroy();
        }
    }
    function float GetShotTime()
    {
        local float mult, sTime;

        if (ScriptedPawn(Owner) != None)
            return ShotTime * (ScriptedPawn(Owner).BaseAccuracy*2+1);
        else
        {
            // AugCombat decreases shot time
            mult = 1.0;
            if (bHandToHand && DeusExPlayer(Owner) != None)
            {
                mult = 1.0 / DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
                if (mult == -1.0)
                    mult = 1.0;
            }
            sTime = ShotTime * mult;
            return (sTime);
        }
    }

Begin:
    if ((ClipCount >= ReloadCount) && (ReloadCount != 0))
    {
        if (!bAutomatic)
        {
            bFiring = False;
            FinishAnim();
        }

        if (Owner != None)
        {
            if (Owner.IsA('DeusExPlayer'))
            {
                bFiring = False;

                // should we autoreload?
                if (DeusExPlayer(Owner).bAutoReload)
                {
                    // auto switch ammo if we're out of ammo and
                    // we're not using the primary ammo
                    if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
                        CycleAmmo();
                    ReloadAmmo();
                }
                else
                {
                    if (bHasMuzzleFlash)
                        EraseMuzzleFlashTexture();
                    GotoState('Idle');
                }
            }
            else if (Owner.IsA('ScriptedPawn'))
            {
                bFiring = False;
                ReloadAmmo();
            }
        }
        else
        {
            if (bHasMuzzleFlash)
                EraseMuzzleFlashTexture();
            GotoState('Idle');
        }
    }
    if ( bAutomatic && (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient())))
        GotoState('Idle');

    Sleep(GetShotTime());
    if (bAutomatic)
    {
        GenerateBullet();   // In multiplayer bullets are generated by the client which will let the server know when
        Goto('Begin');
    }
    bFiring = False;
    FinishAnim();

    // if ReloadCount is 0 and we're not hand to hand, then this is a
    // single-use weapon so destroy it after firing once
    if ((ReloadCount == 0) && !bHandToHand)
    {
        if (DeusExPlayer(Owner) != None)
            DeusExPlayer(Owner).RemoveItemFromSlot(Self);   // remove it from the inventory grid
        Destroy();
    }
    ReadyToFire();
Done:
    bFiring = False;
    Finish();
}

state FinishFire
{
Begin:
    bFiring = False;
    if ( bDestroyOnFinish )
        Destroy();
    else
        Finish();
}

state Pickup
{
    function BeginState()
    {
        // alert NPCs that I'm putting away my gun
        AIEndEvent('WeaponDrawn', EAITYPE_Visual);

        Super.BeginState();
    }
}

state Reload
{
ignores Fire, AltFire;

    function float GetReloadTime()
    {
        local float val;

        val = ReloadTime;

        if (ScriptedPawn(Owner) != None)
        {
            val = ReloadTime * (ScriptedPawn(Owner).BaseAccuracy*2+1);
        }
        else if (DeusExPlayer(Owner) != None)
        {
            // check for skill use if we are the player
            val = GetWeaponSkill();
            val = ReloadTime + (val*ReloadTime);
        }

        return val;
    }

    function NotifyOwner(bool bStart)
    {
        local DeusExPlayer player;
        local ScriptedPawn pawn;

        player = DeusExPlayer(Owner);
        pawn   = ScriptedPawn(Owner);

        if (player != None)
        {
            if (bStart)
                player.Reloading(self, GetReloadTime()+(1.0/AnimRate));
            else
            {
                player.DoneReloading(self);
            }
        }
        else if (pawn != None)
        {
            if (bStart)
                pawn.Reloading(self, GetReloadTime()+(1.0/AnimRate));
            else
                pawn.DoneReloading(self);
        }
    }

Begin:
    FinishAnim();

    // only reload if we have ammo left
    if (AmmoType.AmmoAmount > 0)
    {
        if (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient()))
        {
            ClientReload();
            Sleep(GetReloadTime());
            ReadyClientToFire( True );
        }
        else
        {
            bWasZoomed = bZoomed;
            if (bWasZoomed)
                ScopeOff();

            Owner.PlaySound(CockingSound, SLOT_None,,, 1024);       // CockingSound is reloadbegin
            PlayAnim('ReloadBegin');
            NotifyOwner(True);
            FinishAnim();
            LoopAnim('Reload');
            Sleep(GetReloadTime());
            Owner.PlaySound(AltFireSound, SLOT_None,,, 1024);       // AltFireSound is reloadend
            PlayAnim('ReloadEnd');
            FinishAnim();
            NotifyOwner(False);

            if (bWasZoomed)
                ScopeOn();

            ClipCount = 0;
        }
    }
    GotoState('Idle');
}

simulated state ClientFiring
{
    simulated function AnimEnd()
    {
        bInProcess = False;

        if (bAutomatic)
        {
            if ((Pawn(Owner).bFire != 0) && (AmmoType.AmmoAmount > 0))
            {
                if (PlayerPawn(Owner) != None)
                    ClientReFire(0);
                else
                    GotoState('SimFinishFire');
            }
            else 
                GotoState('SimFinishFire');
        }
    }
    simulated function float GetSimShotTime()
    {
        local float mult, sTime;

        if (ScriptedPawn(Owner) != None)
            return ShotTime * (ScriptedPawn(Owner).BaseAccuracy*2+1);
        else
        {
            // AugCombat decreases shot time
            mult = 1.0;
            if (bHandToHand && DeusExPlayer(Owner) != None)
            {
                mult = 1.0 / DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
                if (mult == -1.0)
                    mult = 1.0;
            }
            sTime = ShotTime * mult;
            return (sTime);
        }
    }
Begin:
    if ((ClipCount >= ReloadCount) && (ReloadCount != 0))
    {
        if (!bAutomatic)
        {
            bFiring = False;
            FinishAnim();
        }
        if (Owner != None)
        {
            if (Owner.IsA('DeusExPlayer'))
            {
                bFiring = False;
                if (DeusExPlayer(Owner).bAutoReload)
                {
                    bClientReadyToFire = False;
                    bInProcess = False;
                    if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
                        CycleAmmo();
                    ReloadAmmo();
                    GotoState('SimQuickFinish');
                }
                else
                {
                    if (bHasMuzzleFlash)
                        EraseMuzzleFlashTexture();
                    IdleFunction();
                    GotoState('SimQuickFinish');
                }
            }
            else if (Owner.IsA('ScriptedPawn'))
            {
                bFiring = False;
            }
        }
        else
        {
            if (bHasMuzzleFlash)
                EraseMuzzleFlashTexture();
            IdleFunction();
            GotoState('SimQuickFinish');
        }
    }
    Sleep(GetSimShotTime());
    if (bAutomatic)
    {
        SimGenerateBullet();
        Goto('Begin');
    }
    bFiring = False;
    FinishAnim();
    bInProcess = False;
Done:
    bInProcess = False;
    bFiring = False;
    SimFinish();
}

simulated state SimQuickFinish
{
Begin:
    if ( IsAnimating() && (AnimSequence == 'Shoot') )
        FinishAnim();

    if (bHasMuzzleFlash)
        EraseMuzzleFlashTexture();

    bInProcess = False;
    bFiring=False;
}

simulated state SimIdle
{
    function Timer()
    {
        PlayIdleAnim();
    }
Begin:
    bInProcess = False;
    bFiring = False;
    if (!bNearWall)
        PlayAnim('Idle1',,0.1);
    SetTimer(3.0, True);
}


simulated state SimFinishFire
{
Begin:
    FinishAnim();

    if ( PlayerPawn(Owner) != None )
        PlayerPawn(Owner).FinishAnim();

    if (bHasMuzzleFlash)
        EraseMuzzleFlashTexture();

    bInProcess = False;
    bFiring=False;
    SimFinish();
}

simulated state SimDownweapon
{
ignores Fire, AltFire, ClientFire, ClientReFire;

Begin:
    if ( bWasInFiring )
    {
        if (bHasMuzzleFlash)
            EraseMuzzleFlashTexture();
        FinishAnim();
    }
    bInProcess = False;
    bFiring=False;
    TweenDown();
    FinishAnim();
}

simulated state SimActive
{
Begin:
    if ( bWasInFiring )
    {
        if (bHasMuzzleFlash)
            EraseMuzzleFlashTexture();
        FinishAnim();
    }
    bInProcess = False;
    bFiring=False;
    PlayAnim('Select',1.0,0.0);
    FinishAnim();
    SimFinish();
}

simulated state SimReload
{
ignores Fire, AltFire, ClientFire, ClientReFire;

    simulated function float GetSimReloadTime()
    {
        local float val;

        val = ReloadTime;

        if (ScriptedPawn(Owner) != None)
        {
            val = ReloadTime * (ScriptedPawn(Owner).BaseAccuracy*2+1);
        }
        else if (DeusExPlayer(Owner) != None)
        {
            // check for skill use if we are the player
            val = GetWeaponSkill();
            val = ReloadTime + (val*ReloadTime);
        }
        return val;
    }
Begin:
    if ( bWasInFiring )
    {
        if (bHasMuzzleFlash)
            EraseMuzzleFlashTexture();
        FinishAnim();
    }
    bInProcess = False;
    bFiring=False;

    bWasZoomed = bZoomed;
    if (bWasZoomed)
        ScopeOff();

    Owner.PlaySound(CockingSound, SLOT_None,,, 1024);       // CockingSound is reloadbegin
    PlayAnim('ReloadBegin');
    FinishAnim();
    LoopAnim('Reload');
    Sleep(GetSimReloadTime());
    Owner.PlaySound(AltFireSound, SLOT_None,,, 1024);       // AltFireSound is reloadend
    ServerDoneReloading();
    PlayAnim('ReloadEnd');
    FinishAnim();

    if (bWasZoomed)
        ScopeOn();

    GotoState('SimIdle');
}


state Idle
{
    function bool PutDown()
    {
        // alert NPCs that I'm putting away my gun
        AIEndEvent('WeaponDrawn', EAITYPE_Visual);

        return Super.PutDown();
    }

    function AnimEnd()
    {
    }

    function Timer()
    {
        PlayIdleAnim();
    }

Begin:
    bFiring = False;
    ReadyToFire();

    if (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient()))
    {
    }
    else
    {
        if (!bNearWall)
            PlayAnim('Idle1',,0.1);
        SetTimer(3.0, True);
    }
}

state FlameThrowerOn
{
    function float GetShotTime()
    {
        local float mult, sTime;

        if (ScriptedPawn(Owner) != None)
            return ShotTime * (ScriptedPawn(Owner).BaseAccuracy*2+1);
        else
        {
            // AugCombat decreases shot time
            mult = 1.0;
            if (bHandToHand && DeusExPlayer(Owner) != None)
            {
                mult = 1.0 / DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
                if (mult == -1.0)
                    mult = 1.0;
            }
            sTime = ShotTime * mult;
            return (sTime);
        }
    }
Begin:
    if ( (DeusExPlayer(Owner).Health > 0) && bFlameOn && (ClipCount < ReloadCount))
    {
        if (( flameShotCount == 0 ) && (Owner != None))
        {
            PlayerPawn(Owner).PlayFiring();
            PlaySelectiveFiring();
            PlayFiringSound();
            flameShotCount = 6;
        }
        else
            flameShotCount--;

        Sleep( GetShotTime() );
        GenerateBullet();
        goto('Begin');
    }
Done:
    bFlameOn = False;
    GotoState('FinishFire');
}

state Active
{
    function bool PutDown()
    {
        // alert NPCs that I'm putting away my gun
        AIEndEvent('WeaponDrawn', EAITYPE_Visual);
        return Super.PutDown();
    }

Begin:
    // Rely on client to fire if we are a multiplayer client

    if ( (Level.NetMode==NM_Standalone) || (Owner.IsA('DeusExPlayer') && DeusExPlayer(Owner).PlayerIsListenClient()) )
        bClientReady = True;
    if (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient()))
    {
        ClientActive();
        bClientReady = False;
    }

    if (!Owner.IsA('ScriptedPawn'))
        FinishAnim();
    if ( bChangeWeapon )
        GotoState('DownWeapon');

    bWeaponUp = True;
    PlayPostSelect();
    if (!Owner.IsA('ScriptedPawn'))
        FinishAnim();
    // reload the weapon if it's empty and autoreload is true
    if ((ClipCount >= ReloadCount) && (ReloadCount != 0))
    {
        if (Owner.IsA('ScriptedPawn') || ((DeusExPlayer(Owner) != None) && DeusExPlayer(Owner).bAutoReload))
            ReloadAmmo();
    }
    Finish();
}


state DownWeapon
{
ignores Fire, AltFire;

    function bool PutDown()
    {
        // alert NPCs that I'm putting away my gun
        AIEndEvent('WeaponDrawn', EAITYPE_Visual);
        return Super.PutDown();
    }

Begin:
   ScopeOff();
    LaserOff();

    if (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient()))
        ClientDownWeapon();

    TweenDown();
    FinishAnim();

    if ( Level.NetMode != NM_Standalone )
    {
        ClipCount = 0;  // Auto-reload in multiplayer (when putting away)
    }
    bOnlyOwnerSee = false;
    if (Pawn(Owner) != None)
        Pawn(Owner).ChangedWeapon();
}

// ----------------------------------------------------------------------
// TestMPBeltSpot()
// Returns true if the suggested belt location is ok for the object in mp.
// ----------------------------------------------------------------------

simulated function bool TestMPBeltSpot(int BeltSpot)
{
   return ((BeltSpot <= 3) && (BeltSpot >= 1));
}

defaultproperties
{
     bReadyToFire=True
     LowAmmoWaterMark=10
     NoiseLevel=1.000000
     ShotTime=0.500000
     reloadTime=1.000000
     HitDamage=10
     maxRange=9600
     AccurateRange=4800
     BaseAccuracy=0.500000
     ScopeFOV=10
     MaintainLockTimer=1.000000
     bPenetrating=True
     bHasMuzzleFlash=True
     bEmitWeaponDrawn=True
     bUseWhileCrouched=True
     bUseAsDrawnWeapon=True
     MinSpreadAcc=0.250000
     MinProjSpreadAcc=1.000000
     bNeedToSetMPPickupAmmo=True
     msgCannotBeReloaded="This weapon can't be reloaded"
     msgOutOf="Out of %s"
     msgNowHas="%s now has %s loaded"
     msgAlreadyHas="%s already has %s loaded"
     msgNone="NONE"
     msgLockInvalid="INVALID"
     msgLockRange="RANGE"
     msgLockAcquire="ACQUIRE"
     msgLockLocked="LOCKED"
     msgRangeUnit="FT"
     msgTimeUnit="SEC"
     msgMassUnit="LBS"
     msgNotWorking="This weapon doesn't work underwater"
     msgInfoAmmoLoaded="Ammo loaded:"
     msgInfoAmmo="Ammo type(s):"
     msgInfoDamage="Base damage:"
     msgInfoClip="Clip size:"
     msgInfoROF="Rate of fire:"
     msgInfoReload="Reload time:"
     msgInfoRecoil="Recoil:"
     msgInfoAccuracy="Base Accuracy:"
     msgInfoAccRange="Acc. range:"
     msgInfoMaxRange="Max. range:"
     msgInfoMass="Mass:"
     msgInfoLaser="Laser sight:"
     msgInfoScope="Scope:"
     msgInfoSilencer="Silencer:"
     msgInfoNA="N/A"
     msgInfoYes="YES"
     msgInfoNo="NO"
     msgInfoAuto="AUTO"
     msgInfoSingle="SINGLE"
     msgInfoRounds="RDS"
     msgInfoRoundsPerSec="RDS/SEC"
     msgInfoSkill="Skill:"
     msgInfoWeaponStats="Weapon Stats:"
     ReloadCount=10
     shakevert=10.000000
     Misc1Sound=Sound'DeusExSounds.Generic.DryFire'
     AutoSwitchPriority=0
     bRotatingPickup=False
     PickupMessage="You found"
     ItemName="DEFAULT WEAPON NAME - REPORT THIS AS A BUG"
     LandSound=Sound'DeusExSounds.Generic.DropSmallWeapon'
     bNoSmooth=False
     Mass=10.000000
     Buoyancy=5.000000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 8/11/2021 16:22:50.000 - Creation time: Mon 8/11/2021 16:31:25.966 - Created with UnCodeX