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

ROEngine.ROPawn


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
03857
03858
03859
03860
03861
03862
03863
03864
03865
03866
03867
03868
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884
03885
03886
03887
03888
03889
03890
03891
03892
03893
03894
03895
03896
03897
03898
03899
03900
03901
03902
03903
03904
03905
03906
03907
03908
03909
03910
03911
03912
03913
03914
03915
03916
03917
03918
03919
03920
03921
03922
03923
03924
03925
03926
03927
03928
03929
03930
03931
03932
03933
03934
03935
03936
03937
03938
03939
03940
03941
03942
03943
03944
03945
03946
03947
03948
03949
03950
03951
03952
03953
03954
03955
03956
03957
03958
03959
03960
03961
03962
03963
03964
03965
03966
03967
03968
03969
03970
03971
03972
03973
03974
03975
03976
03977
03978
03979
03980
03981
03982
03983
03984
03985
03986
03987
03988
03989
03990
03991
03992
03993
03994
03995
03996
03997
03998
03999
04000
04001
04002
04003
04004
04005
04006
04007
04008
04009
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019
04020
04021
04022
04023
04024
04025
04026
04027
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039
04040
04041
04042
04043
04044
04045
04046
04047
04048
04049
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063
04064
04065
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088
04089
04090
04091
04092
04093
04094
04095
04096
04097
04098
04099
04100
04101
04102
04103
04104
04105
04106
04107
04108
04109
04110
04111
04112
04113
04114
04115
04116
04117
04118
04119
04120
04121
04122
04123
04124
04125
04126
04127
04128
04129
04130
04131
04132
04133
04134
04135
04136
04137
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147
04148
04149
04150
04151
04152
04153
04154
04155
04156
04157
04158
04159
04160
04161
04162
04163
04164
04165
04166
04167
04168
04169
04170
04171
04172
04173
04174
04175
04176
04177
04178
04179
04180
04181
04182
04183
04184
04185
04186
04187
04188
04189
04190
04191
04192
04193
04194
04195
04196
04197
04198
04199
04200
04201
04202
04203
04204
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215
04216
04217
04218
04219
04220
04221
04222
04223
04224
04225
04226
04227
04228
04229
04230
04231
04232
04233
04234
04235
04236
04237
04238
04239
04240
04241
04242
04243
04244
04245
04246
04247
04248
04249
04250
04251
04252
04253
04254
04255
04256
04257
04258
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268
04269
04270
04271
04272
04273
04274
04275
04276
04277
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288
04289
04290
04291
04292
04293
04294
04295
04296
04297
04298
04299
04300
04301
04302
04303
04304
04305
04306
04307
04308
04309
04310
04311
04312
04313
04314
04315
04316
04317
04318
04319
04320
04321
04322
04323
04324
04325
04326
04327
04328
04329
04330
04331
04332
04333
04334
04335
04336
04337
04338
04339
04340
04341
04342
04343
04344
04345
04346
04347
04348
04349
04350
04351
04352
04353
04354
04355
04356
04357
04358
04359
04360
04361
04362
04363
04364
04365
04366
04367
04368
04369
04370
04371
04372
04373
04374
04375
04376
04377
04378
04379
04380
04381
04382
04383
04384
04385
04386
04387
04388
04389
04390
04391
04392
04393
04394
04395
04396
04397
04398
04399
04400
04401
04402
04403
04404
04405
04406
04407
04408
04409
04410
04411
04412
04413
04414
04415
04416
04417
04418
04419
04420
04421
04422
04423
04424
04425
04426
04427
04428
04429
04430
04431
04432
04433
04434
04435
04436
04437
04438
04439
04440
04441
04442
04443
04444
04445
04446
04447
04448
04449
04450
04451
04452
04453
04454
04455
04456
04457
04458
04459
04460
04461
04462
04463
04464
04465
04466
04467
04468
04469
04470
04471
04472
04473
04474
04475
04476
04477
04478
04479
04480
04481
04482
04483
04484
04485
04486
04487
04488
04489
04490
04491
04492
04493
04494
04495
04496
04497
04498
04499
04500
04501
04502
04503
04504
04505
04506
04507
04508
04509
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519
04520
04521
04522
04523
04524
04525
04526
04527
04528
04529
04530
04531
04532
04533
04534
04535
04536
04537
04538
04539
04540
04541
04542
04543
04544
04545
04546
04547
04548
04549
04550
04551
04552
04553
04554
04555
04556
04557
04558
04559
04560
04561
04562
04563
04564
04565
04566
04567
04568
04569
04570
04571
04572
04573
04574
04575
04576
04577
04578
04579
04580
04581
04582
04583
04584
04585
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597
04598
04599
04600
04601
04602
04603
04604
04605
04606
04607
04608
04609
04610
04611
04612
04613
04614
04615
04616
04617
04618
04619
04620
04621
04622
04623
04624
04625
04626
04627
04628
04629
04630
04631
04632
04633
04634
04635
04636
04637
04638
04639
04640
04641
04642
04643
04644
04645
04646
04647
04648
04649
04650
04651
04652
04653
04654
04655
04656
04657
04658
04659
04660
04661
04662
04663
04664
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675
04676
04677
04678
04679
04680
04681
04682
04683
04684
04685
04686
04687
04688
04689
04690
04691
04692
04693
04694
04695
04696
04697
04698
04699
04700
04701
04702
04703
04704
04705
04706
04707
04708
04709
04710
04711
04712
04713
04714
04715
04716
04717
04718
04719
04720
04721
04722
04723
04724
04725
04726
04727
04728
04729
04730
04731
04732
04733
04734
04735
04736
04737
04738
04739
04740
04741
04742
04743
04744
04745
04746
04747
04748
04749
04750
04751
04752
04753
04754
04755
04756
04757
04758
04759
04760
04761
04762
04763
04764
04765
04766
04767
04768
04769
04770
04771
04772
04773
04774
04775
04776
04777
04778
04779
04780
04781
04782
04783
04784
04785
04786
04787
04788
04789
04790
04791
04792
04793
04794
04795
04796
04797
04798
04799
04800
04801
04802
04803
04804
04805
04806
04807
04808
04809
04810
04811
04812
04813
04814
04815
04816
04817
04818
04819
04820
04821
04822
04823
04824
04825
04826
04827
04828
04829
04830
04831
04832
04833
04834
04835
04836
04837
04838
04839
04840
04841
04842
04843
04844
04845
04846
04847
04848
04849
04850
04851
04852
04853
04854
04855
04856
04857
04858
04859
04860
04861
04862
04863
04864
04865
04866
04867
04868
04869
04870
04871
04872
04873
04874
04875
04876
04877
04878
04879
04880
04881
04882
04883
04884
04885
04886
04887
04888
04889
04890
04891
04892
04893
04894
04895
04896
04897
04898
04899
04900
04901
04902
04903
04904
04905
04906
04907
04908
04909
04910
04911
04912
04913
04914
04915
04916
04917
04918
04919
04920
04921
04922
04923
04924
04925
04926
04927
04928
04929
04930
04931
04932
04933
04934
04935
04936
04937
04938
04939
04940
04941
04942
04943
04944
04945
04946
04947
04948
04949
04950
04951
04952
04953
04954
04955
04956
04957
04958
04959
04960
04961
04962
04963
04964
04965
04966
04967
04968
04969
04970
04971
04972
04973
04974
04975
04976
04977
04978
04979
04980
04981
04982
04983
04984
04985
04986
04987
04988
04989
04990
04991
04992
04993
04994
04995
04996
04997
04998
04999
05000
05001
05002
05003
05004
05005
05006
05007
05008
05009
05010
05011
05012
05013
05014
05015
05016
05017
05018
05019
05020
05021
05022
05023
05024
05025
05026
05027
05028
05029
05030
05031
05032
05033
05034
05035
05036
05037
05038
05039
05040
05041
05042
05043
05044
05045
05046
05047
05048
05049
05050
05051
05052
05053
05054
05055
05056
05057
05058
05059
05060
05061
05062
05063
05064
05065
05066
05067
05068
05069
05070
05071
05072
05073
05074
05075
05076
05077
05078
05079
05080
05081
05082
05083
05084
05085
05086
05087
05088
05089
05090
05091
05092
05093
05094
05095
05096
05097
05098
05099
05100
05101
05102
05103
05104
05105
05106
05107
05108
05109
05110
05111
05112
05113
05114
05115
05116
05117
05118
05119
05120
05121
05122
05123
05124
05125
05126
05127
05128
05129
05130
05131
05132
05133
05134
05135
05136
05137
05138
05139
05140
05141
05142
05143
05144
05145
05146
05147
05148
05149
05150
05151
05152
05153
05154
05155
05156
05157
05158
05159
05160
05161
05162
05163
05164
05165
05166
05167
05168
05169
05170
05171
05172
05173
05174
05175
05176
05177
05178
05179
05180
05181
05182
05183
05184
05185
05186
05187
05188
05189
05190
05191
05192
05193
05194
05195
05196
05197
05198
05199
05200
05201
05202
05203
05204
05205
05206
05207
05208
05209
05210
05211
05212
05213
05214
05215
05216
05217
05218
05219
05220
05221
05222
05223
05224
05225
05226
05227
05228
05229
05230
05231
05232
05233
05234
05235
05236
05237
05238
05239
05240
05241
05242
05243
05244
05245
05246
05247
05248
05249
05250
05251
05252
05253
05254
05255
05256
05257
05258
05259
05260
05261
05262
05263
05264
05265
05266
05267
05268
05269
05270
05271
05272
05273
05274
05275
05276
05277
05278
05279
05280
05281
05282
05283
05284
05285
05286
05287
05288
05289
05290
05291
05292
05293
05294
05295
05296
05297
05298
05299
05300
05301
05302
05303
05304
05305
05306
05307
05308
05309
05310
05311
05312
05313
05314
05315
05316
05317
05318
05319
05320
05321
05322
05323
05324
05325
05326
05327
05328
05329
05330
05331
05332
05333
05334
05335
05336
05337
05338
05339
05340
05341
05342
05343
05344
05345
05346
05347
05348
05349
05350
05351
05352
05353
05354
05355
05356
05357
05358
05359
05360
05361
05362
05363
05364
05365
05366
05367
05368
05369
05370
05371
05372
05373
05374
05375
05376
05377
05378
05379
05380
05381
05382
05383
05384
05385
05386
05387
05388
05389
05390
05391
05392
05393
05394
05395
05396
05397
05398
05399
05400
05401
05402
05403
05404
05405
05406
05407
05408
05409
05410
05411
05412
05413
05414
05415
05416
05417
05418
05419
05420
05421
05422
05423
05424
05425
05426
05427
05428
05429
05430
05431
05432
05433
05434
05435
05436
05437
05438
05439
05440
05441
05442
05443
05444
05445
05446
05447
05448
05449
05450
05451
05452
05453
05454
05455
05456
05457
05458
05459
05460
05461
05462
05463
05464
05465
05466
05467
05468
05469
05470
05471
05472
05473
05474
05475
05476
05477
05478
05479
05480
05481
05482
05483
05484
05485
05486
05487
05488
05489
05490
05491
05492
05493
05494
05495
05496
05497
05498
05499
05500
05501
05502
05503
05504
05505
05506
05507
05508
05509
05510
05511
05512
05513
05514
05515
05516
05517
05518
05519
05520
05521
05522
05523
05524
05525
05526
05527
05528
05529
05530
05531
05532
05533
05534
05535
05536
05537
05538
05539
05540
05541
05542
05543
05544
05545
05546
05547
05548
05549
05550
05551
05552
05553
05554
05555
05556
05557
05558
05559
05560
05561
05562
05563
05564
05565
05566
05567
05568
05569
05570
05571
05572
05573
05574
05575
05576
05577
05578
05579
05580
05581
05582
05583
05584
05585
05586
05587
05588
05589
05590
05591
05592
05593
05594
05595
05596
05597
05598
05599
05600
05601
05602
05603
05604
05605
05606
05607
05608
05609
05610
05611
05612
05613
05614
05615
05616
05617
05618
05619
05620
05621
05622
05623
05624
05625
05626
05627
05628
05629
05630
05631
05632
05633
05634
05635
05636
05637
05638
05639
05640
05641
05642
05643
05644
05645
05646
05647
05648
05649
05650
05651
05652
05653
05654
05655
05656
05657
05658
05659
05660
05661
05662
05663
05664
05665
05666
05667
05668
05669
05670
05671
05672
05673
05674
05675
05676
05677
05678
05679
05680
05681
05682
05683
05684
05685
05686
05687
05688
05689
05690
05691
05692
05693
05694
05695
05696
05697
05698
05699
05700
05701
05702
05703
05704
05705
05706
05707
05708
05709
05710
05711
05712
05713
05714
05715
05716
05717
05718
05719
05720
05721
05722
05723
05724
05725
05726
05727
05728
05729
05730
05731
05732
05733
05734
05735
05736
05737
05738
05739
05740
05741
05742
05743
05744
05745
05746
05747
05748
05749
05750
05751
05752
05753
05754
05755
05756
05757
05758
05759
05760
05761
05762
05763
05764
05765
05766
05767
05768
05769
05770
05771
05772
05773
05774
05775
05776
05777
05778
05779
05780
05781
05782
05783
05784
05785
05786
05787
05788
05789
05790
05791
05792
05793
05794
05795
05796
05797
05798
05799
05800
05801
05802
05803
05804
05805
05806
05807
05808
05809
05810
05811
05812
05813
05814
05815
05816
05817
05818
05819
05820
05821
05822
05823
05824
05825
05826
05827
05828
05829
05830
05831
05832
05833
05834
05835
05836
05837
05838
05839
05840
05841
05842
05843
05844
05845
05846
05847
05848
05849
05850
05851
05852
05853
05854
05855
05856
05857
05858
05859
05860
05861
05862
05863
05864
05865
05866
05867
05868
05869
05870
05871
05872
05873
05874
05875
05876
05877
05878
05879
05880
05881
05882
05883
05884
05885
05886
05887
05888
05889
05890
05891
05892
05893
05894
05895
05896
05897
05898
05899
05900
05901
05902
05903
05904
05905
05906
05907
05908
05909
05910
05911
05912
05913
05914
05915
05916
05917
05918
05919
05920
05921
05922
05923
05924
05925
05926
05927
05928
05929
05930
05931
05932
05933
05934
05935
05936
05937
05938
05939
05940
05941
05942
05943
05944
05945
05946
05947
05948
05949
05950
05951
05952
05953
05954
05955
05956
05957
05958
05959
05960
05961
05962
05963
05964
05965
05966
05967
05968
05969
05970
05971
05972
05973
05974
05975
05976
05977
05978
05979
05980
05981
05982
05983
05984
05985
05986
05987
05988
05989
05990
05991
05992
05993
05994
05995
05996
05997
05998
05999
06000
06001
06002
06003
06004
06005
06006
06007
06008
06009
06010
06011
06012
06013
06014
06015
06016
06017
06018
06019
06020
06021
06022
06023
06024
06025
06026
06027
06028
06029
06030
06031
06032
06033
06034
06035
06036
06037
06038
06039
06040
06041
06042
06043
06044
06045
06046
06047
06048
06049
06050
06051
06052
06053
06054
06055
06056
06057
06058
06059
06060
06061
06062
06063
06064
06065
06066
06067
06068
06069
06070
06071
06072
06073
06074
06075
06076
06077
06078
06079
06080
06081
06082
06083
06084
06085
06086
06087
06088
06089
06090
06091
06092
06093
06094
06095
06096
06097
06098
06099
06100
06101
06102
06103
06104
06105
06106
06107
06108
06109
06110
06111
06112
06113
06114
06115
06116
06117
06118
06119
06120
06121
06122
06123
06124
06125
06126
06127
06128
06129
06130
06131
06132
06133
06134
06135
06136
06137
06138
06139
06140
06141
06142
06143
06144
06145
06146
06147
06148
06149
06150
06151
06152
06153
06154
06155
06156
06157
06158
06159
06160
06161
06162
06163
06164
06165
06166
06167
06168
06169
06170
06171
06172
06173
06174
06175
06176
06177
06178
06179
06180
06181
06182
06183
06184
06185
06186
06187
06188
06189
06190
06191
06192
06193
06194
06195
06196
06197
06198
06199
06200
06201
06202
06203
06204
06205
06206
06207
06208
06209
06210
06211
06212
06213
06214
06215
06216
06217
06218
06219
06220
06221
06222
06223
06224
06225
06226
06227
06228
06229
06230
06231
06232
06233
06234
06235
06236
06237
06238
06239
06240
06241
06242
06243
06244
06245
06246
06247
06248
06249
06250
06251
06252
06253
06254
06255
06256
06257
06258
06259
06260
06261
06262
06263
06264
06265
06266
06267
06268
06269
06270
06271
06272
06273
06274
06275
06276
06277
06278
06279
06280
06281
06282
06283
06284
06285
06286
06287
06288
06289
06290
06291
06292
06293
06294
06295
06296
06297
06298
06299
06300
06301
06302
06303
06304
06305
06306
06307
06308
06309
06310
06311
06312
06313
06314
06315
06316
06317
06318
06319
06320
06321
06322
06323
06324
06325
06326
06327
06328
06329
06330
06331
06332
06333
06334
06335
06336
06337
06338
06339
06340
06341
06342
06343
06344
06345
06346
06347
06348
06349
06350
06351
06352
06353
06354
06355
06356
06357
06358
06359
06360
06361
06362
06363
06364
06365
06366
06367
06368
06369
06370
06371
06372
06373
06374
06375
06376
06377
06378
06379
06380
06381
06382
06383
06384
06385
06386
06387
06388
06389
06390
06391
06392
06393
06394
06395
06396
06397
06398
06399
06400
06401
06402
06403
06404
06405
06406
06407
06408
06409
06410
06411
06412
06413
06414
06415
06416
06417
06418
06419
06420
06421
06422
06423
06424
06425
06426
06427
06428
06429
06430
06431
06432
06433
06434
06435
06436
06437
06438
06439
06440
06441
06442
06443
06444
06445
06446
06447
06448
06449
06450
06451
06452
06453
06454
06455
06456
06457
06458
06459
06460
06461
06462
06463
06464
06465
06466
06467
06468
06469
06470
06471
06472
06473
06474
06475
06476
06477
06478
06479
06480
06481
06482
06483
06484
06485
06486
06487
06488
06489
06490
06491
06492
06493
06494
06495
06496
06497
06498
06499
06500
06501
06502
06503
06504
06505
06506
06507
06508
06509
06510
06511
06512
06513
06514
06515
06516
06517
06518
06519
06520
06521
06522
06523
06524
06525
06526
06527
06528
06529
06530
06531
06532
06533
06534
06535
06536
06537
06538
06539
06540
06541
06542
06543
06544
06545
06546
06547
06548
06549
06550
06551
06552
06553
06554
06555
06556
06557
06558
06559
06560
06561
06562
06563
06564
06565
06566
06567
06568
06569
06570
06571
06572
06573
06574
06575
06576
06577
06578
06579
06580
06581
06582
06583
06584
06585
06586
06587
06588
06589
06590
06591
06592
06593
06594
06595
06596
06597
06598
06599
06600
06601
06602
06603
06604
06605
06606
06607
06608
06609
06610
06611
06612
06613
06614
06615
06616
06617
06618
06619
06620
06621
06622
06623
06624
06625
06626
06627
06628
06629
06630
06631
06632
06633
06634
06635
06636
06637
06638
06639
06640
06641
06642
06643
06644
06645
06646
06647
06648
06649
06650
06651
06652
06653
06654
06655
06656
06657
06658
06659
06660
06661
06662
06663
06664
06665
06666
06667
06668
06669
06670
06671
06672
06673
06674
06675
06676
06677
06678
06679
06680
06681
06682
06683
06684
06685
06686
06687
06688
06689
06690
06691
06692
06693
06694
06695
06696
06697
06698
06699
06700
06701
06702
06703
06704
06705
06706
06707
06708
06709
06710
06711
06712
06713
06714
06715
06716
06717
06718
06719
06720
06721
06722
06723
06724
06725
06726
06727
06728
06729
06730
06731
06732
06733
06734
06735
06736
06737
06738
06739
06740
06741
06742
06743
06744
06745
06746
06747
06748
06749
06750
06751
06752
06753
06754
06755
06756
06757
06758
06759
06760
06761
06762
06763
06764
06765
06766
06767
06768
06769
06770
06771
06772
06773
06774
06775
06776
06777
06778
06779
06780
06781
06782
06783
06784
06785
06786
06787
06788
06789
06790
06791
06792
06793
06794
06795
06796
06797
06798
06799
06800
06801
06802
06803
06804
06805
06806
06807
06808
06809
06810
06811
06812
06813
06814
06815
06816
06817
06818
06819
06820
06821
06822
06823
06824
06825
06826
06827
06828
06829
06830
06831
06832
06833
06834
06835
06836
06837
06838
06839
06840
06841
06842
06843
06844
06845
06846
06847
06848
06849
06850
06851
06852
06853
06854
06855
06856
06857
06858
06859
06860
06861
06862
06863
06864
06865
06866
06867
06868
06869
06870
06871
06872
06873
06874
06875
06876
06877
06878
06879
06880
06881
06882
06883
06884
06885
06886
06887
06888
06889
06890
06891
06892
06893
06894
06895
06896
06897
06898
06899
06900
06901
06902
06903
06904
06905
06906
06907
06908
06909
06910
06911
06912
06913
06914
06915
06916
06917
06918
06919
06920
06921
06922
06923
06924
06925
06926
06927
06928
06929
06930
06931
06932
06933
06934
06935
06936
06937
06938
06939
06940
06941
06942
06943
06944
06945
06946
06947
06948
06949
06950
06951
06952
06953
06954
06955
06956
06957
06958
06959
06960
06961
06962
06963
06964
06965
06966
06967
06968
06969
06970
06971
06972
06973
06974
06975
06976
06977
06978
06979
06980
06981
06982
06983
06984
06985
06986
06987
06988
06989
06990
06991
06992
06993
06994
06995
06996
06997
06998
06999
07000
07001
07002
07003
07004
07005
07006
07007
07008
07009
07010
07011
07012
07013
07014
07015
07016
07017
07018
07019
07020
07021
07022
07023
07024
07025
07026
07027
07028
07029
07030
07031
07032
07033
07034
07035
07036
07037
07038
07039
07040
07041
07042
07043
07044
07045
07046
07047
07048
07049
07050
07051
07052
07053
07054
07055
07056
07057
07058
07059
07060
07061
07062
07063
07064
07065
07066
07067
07068
07069
07070
07071
07072
07073
07074
07075
07076
07077
07078
07079
07080
07081
07082
07083
07084
07085
07086
07087
07088
07089
07090
07091
07092
07093
07094
07095
07096
07097
07098
07099
07100
07101
07102
07103
07104
07105
07106
07107
07108
07109
07110
07111
07112
07113
07114
07115
07116
07117
07118
07119
07120
07121
07122
07123
07124
07125
07126
07127
07128
07129
07130
07131
07132
07133
07134
07135
07136
07137
07138
07139
07140
07141
07142
07143
07144
07145
07146
07147
07148
07149
07150
07151
07152
07153
07154
07155
07156
07157
07158
07159
07160
07161
07162
07163
07164
07165
07166
07167
07168
07169
07170
07171
07172
07173
07174
07175
07176
07177
07178
07179
07180
07181
07182
07183
07184
07185
07186
07187
07188
07189
07190
07191
07192
07193
07194
07195
07196
07197
07198
07199
07200
07201
07202
07203
07204
07205
07206
07207
07208
07209
07210
07211
07212
07213
07214
07215
07216
07217
07218
07219
07220
07221
07222
07223
07224
07225
07226
07227
07228
07229
07230
07231
07232
07233
07234
07235
07236
07237
07238
07239
07240
07241
07242
07243
07244
07245
07246
07247
07248
07249
07250
07251
07252
07253
07254
07255
07256
07257
07258
07259
07260
07261
07262
07263
07264
07265
07266
07267
07268
07269
07270
07271
07272
07273
07274
07275
07276
07277
07278
07279
07280
07281
07282
07283
07284
07285
07286
07287
07288
07289
07290
07291
07292
07293
07294
07295
07296
07297
07298
07299
07300
07301
07302
07303
07304
07305
07306
07307
07308
07309
07310
07311
07312
07313
07314
07315
07316
07317
07318
07319
07320
07321
07322
07323
07324
07325
07326
07327
07328
07329
07330
07331
07332
07333
07334
07335
07336
07337
07338
07339
07340
07341
07342
07343
07344
07345
07346
07347
07348
07349
07350
07351
07352
07353
07354
07355
07356
07357
07358
07359
07360
07361
07362
07363
07364
07365
07366
07367
07368
07369
07370
07371
07372
07373
07374
07375
07376
07377
07378
07379
07380
07381
07382
07383
07384
07385
07386
07387
07388
07389
07390
07391
07392
07393
07394
07395
07396
07397
07398
07399
07400
07401
07402
07403
07404
07405
07406
07407
07408
07409
07410
07411
07412
07413
07414
07415
07416
07417
07418
07419
07420
07421
07422
07423
07424
07425
07426
07427
07428
07429
07430
07431
07432
07433
07434
07435
07436
07437
07438
07439
07440
07441
07442
07443
07444
07445
07446
07447
07448
07449
07450
07451
07452
07453
07454
07455
07456
07457
07458
07459
07460
07461
07462
07463
07464
07465
07466
07467
07468
07469
07470
07471
07472
07473
07474
07475
07476
07477
07478
07479
07480
07481
07482
07483
07484
07485
07486
07487
07488
07489
07490
07491
07492
07493
07494
07495
07496
07497
07498
07499
07500
07501
07502
07503
07504
07505
07506
07507
07508
07509
07510
07511
07512
07513
07514
07515
07516
07517
07518
07519
07520
07521
07522
07523
07524
07525
07526
07527
07528
07529
07530
07531
07532
07533
07534
07535
07536
07537
07538
07539
07540
07541
07542
07543
07544
07545
07546
07547
07548
07549
07550
07551
07552
07553
07554
07555
07556
07557
07558
07559
07560
07561
07562
07563
07564
07565
07566
07567
//=============================================================================
// ROPawn
//=============================================================================
// Pawn class for Red Orchestra
//=============================================================================
// Red Orchestra Source
// Copyright (C) 2005 John Gibson
//=============================================================================

class ROPawn extends Pawn
	native
	placeable
	config(User)
	exportstructs
	dependsOn(xUtil)
	dependsOn(ROPawnSoundGroup);

//#exec OBJ LOAD FILE=Inf_Player.uax
//#exec OBJ LOAD FILE=Miscsounds.uax
//#exec OBJ LOAD FILE=Inf_Weapons_Foley.uax

// UnrealPawn vars

var	() bool		bNoDefaultInventory;	// don't spawn default inventory for this guy
var bool		bAcceptAllInventory;	// can pick up anything
var(AI) bool	bIsSquadLeader;			// only used as startup property
var bool		bSoakDebug;				// use less verbose version of debug display
var bool		bKeepTaunting;
var config bool bPlayOwnFootsteps;
var byte		LoadOut;

var		float	AttackSuitability;		// range 0 to 1, 0 = pure defender, 1 = pure attacker
var		float	LastFootStepTime;

var eDoubleClickDir CurrentDir;
var vector			GameObjOffset;
var rotator			GameObjRot;
var(AI) name		SquadName;			// only used as startup property

// allowed voices
var string VoiceType;

var globalconfig bool bPlayerShadows;
var globalconfig bool bBlobShadow;

var int spree;

// Xpawn vars
var bool bGibbed;
var bool bAlreadySetup;
var bool bSpawnDone;
var bool bClearWeaponOffsets;		// for certain custom player models

var class<SpeciesType> Species;

var float DeResTime;
var bool bDeRes;

var(Sounds) float GruntVolume;
var(Sounds) float FootstepVolume;

var transient int   SimHitFxTicker;

var float MinTimeBetweenPainSounds;

// Common sounds

var(Sounds) sound   SoundFootsteps[20]; // Indexed by ESurfaceTypes (sorry about the literal).
var(Sounds) class<ROPawnSoundGroup> SoundGroupClass;

var ROWeaponAttachment WeaponAttachment;
var ROWeaponAttachment OldWeaponAttachment; // Used by the native code for animations

var	Weapon SwapWeapon; // Used to keep track of the weapon being swapped during the PutWeaponAway state.

var ShadowProjector PlayerShadow;

var(Karma) float RagdollLifeSpan; // MAXIMUM time the ragdoll will be around. De-res's early if it comes to rest.
var(Karma) float RagInvInertia; // Use to work out how much 'spin' ragdoll gets on death.
var(Karma) float RagDeathVel; // How fast ragdoll moves upon death
var(Karma) float RagShootStrength; // How much effect shooting ragdolls has. Be careful!
var(Karma) float RagSpinScale; // Increase propensity to spin around Z (up).
var(Karma) float RagMaxSpinAmount; // The max we'll scale up spin amount for locational hit damage
var(Karma) float RagDeathUpKick; // Amount of upwards kick ragdolls get when they die
var(Karma) float RagGravScale;

var(Karma) material RagConvulseMaterial;

// Ragdoll impact sounds.
var(Karma) sound			RagImpactSound;
var(Karma) float			RagImpactSoundInterval;
var transient float			RagLastSoundTime;

var string RagdollOverride;

var Controller OldController;

var class<TeamVoicePack> VoiceClass;

var(AI) globalconfig string PlacedCharacterName;
var globalconfig string PlacedFemaleCharacterName;

var byte TeamSkin;		// what team's skin is currently set

var name FireRootBone;
//=============================================================================
// RO Variables
//=============================================================================

// Damage
var					byte		DamageList[15]; // An array that tracks what areas of the body are damaged. Correlates to Hitpoints Array (-1)
var                 int         LastHitIndex;

// Gore
var	SeveredAppendageAttachment 	SeveredLeftArm; // The meaty attachments that get attached when body parts are blown off
var	SeveredAppendageAttachment 	SeveredRightArm;// The meaty attachments that get attached when body parts are blown off
var	SeveredAppendageAttachment 	SeveredLeftLeg; // The meaty attachments that get attached when body parts are blown off
var	SeveredAppendageAttachment 	SeveredRightLeg;// The meaty attachments that get attached when body parts are blown off
var	SeveredAppendageAttachment 	SeveredHead;// The meaty attachments that get attached when body parts are blown off

var	class<SeveredAppendageAttachment> SeveredArmAttachClass; // class of the severed arm for this role
var	class<SeveredAppendageAttachment> SeveredLegAttachClass; // class of the severed arm for this role
var	class<SeveredAppendageAttachment> SeveredHeadAttachClass; // class of the severed arm for this role

var class <ROBloodSpurt>		 BleedingEmitterClass;		// class of the bleeding emitter
var class <ProjectileBloodSplat> ProjectileBloodSplatClass;	// class of the wall bloodsplat from a projectile's impact
var class <SeveredAppendage>	DetachedArmClass;		// class of detached arm to spawn for this pawn. Modified by the RoleInfo to match the player model
var class <SeveredAppendage>	DetachedLegClass;		// class of detached arm to spawn for this pawn. Modified by the RoleInfo to match the player model
var			bool				bLeftArmGibbed;			// LeftArm is already blown off
var			bool				bRightArmGibbed;		// RightArm is already blown off
var			bool				bLeftLegGibbed;			// LeftLeg is already blown off
var			bool				bRightLegGibbed;		// RightLeg is already blown off
var class <Emitter>				ObliteratedEffectClass;	// class of detached arm to spawn for this pawn. Modified by the RoleInfo to match the player model


// Collision
var		ROBulletWhipAttachment  AuxCollisionCylinder;   // Additional collision cylinder for detecting bullets passing by
var 				bool 		SavedAuxCollision;     	// Saved aux collision cylinder status
// Used by physics to set the player's distance from the floor.
var 				const float ROMinFloorDist;
var 				const float ROMaxFloorDist;

const FRONTROTATIONCHECKDIST = 40.0; 					// How far forward to check when prone to determine the rotation of the floor in front of the player

// Stamina
var()				float		Stamina;                // How many second of stamina the player has
var             	byte 		SavedBreathSound;     	// Tracks the old breathing sound
var()				float		JumpStaminaDrain;       // How much stamina is lost by jumping
var() 				float 		StaminaRecoveryRate; 	// How much stamina to recover normally per second
var() 				float 		CrouchStaminaRecoveryRate;// How much stamina to recover per second while crouching
var() 				float 		ProneStaminaRecoveryRate;// How much stamina to recover per second while proning
var() 				float		SlowStaminaRecoveryRate;// How much stamina to recover per second when moving
var					bool		bOldSprinting; 			// Helper flag for SetSprinting(). Since we simulate sprinting and stamina on both client and server, this flag is used to keep track of the local sprinting flags.

// Momentum
var()				InterpCurve	MomentumCurve; 			// The amount of momentum to apply based on an input velocity
var()				float		FrictionScale;			// Used by the native physics to scale the friction when the player is moving. This makes the player feel less like he "sticks" to the the ground


var()				int			PronePitchUpLimit;		// Pitch up limit while prone
var()				int			PronePitchDownLimit;    // Pitch down limit while prone
var()				int			CrawlingPitchUpLimit;	// Pitch up limit while crawling forward or back
var()				int			CrawlingPitchDownLimit; // Pitch down limit while crawling forward or back

var					int			CrawlPitchTweenRate;	// Tween to pitch limit speed  = CrawlingPitchDownLimit-PronePitchDownLimit/NumSecondsToTween(0.15)

// Animation
var 				bool		bPlayTypingAnims;		// Whether or not to play a typing animation when the player is typing
var(ROAnimations)	name 		ProneIdleRestAnim;		// Idling for a long time while prone
var(ROAnimations)	name 		CrouchIdleRestAnim;     // Idling for a long time while crouched

// MG deployed anims
var(ROAnimations)	name 		IdleProneDeployedAnim;
var(ROAnimations)	name        IdleCrouchDeployedAnim;
var(ROAnimations)	name        IdleStandingDeployedAnim;

// Prone Anims
var(ROAnimations)	name		ProneAnims[8];
var(ROAnimations) 	name		IdleProneAnim;
var(ROAnimations) 	name		ProneTurnRightAnim;
var(ROAnimations) 	name		ProneTurnLeftAnim;
var(ROAnimations) 	name		StandToProneAnim;
var(ROAnimations) 	name		ProneToStandAnim;
var(ROAnimations) 	name		CrouchToProneAnim;
var(ROAnimations) 	name		ProneToCrouchAnim;
var(ROAnimations) 	name		DiveToProneStartAnim;
var(ROAnimations) 	name		DiveToProneEndAnim;

// Sprint Anims
var(ROAnimations) 	name		SprintAnims[8];
var(ROAnimations) 	name		SprintCrouchAnims[8];

// Iron Sight Anims
var(ROAnimations) 	name		WalkIronAnims[8];
var(ROAnimations) 	name		IdleIronRestAnim;
var(ROAnimations) 	name		IdleIronWeaponAnim;
var(ROAnimations) 	name		IdleCrouchIronWeaponAnim;
var(ROAnimations) 	name		TurnIronRightAnim;
var(ROAnimations) 	name		TurnIronLeftAnim;
var(ROAnimations) 	name		CrouchTurnIronRightAnim;
var(ROAnimations) 	name		CrouchTurnIronLeftAnim;

// Hit Anims
var(ROAnimations) 	name		HitFAnim;
var(ROAnimations) 	name		HitBAnim;
var(ROAnimations) 	name		HitLAnim;
var(ROAnimations) 	name		HitRAnim;
var(ROAnimations) 	name		HitLLegAnim;
var(ROAnimations) 	name		HitRLegAnim;
var(ROAnimations) 	name		ProneHitAnim;
var(ROAnimations) 	name		CrouchHitUpAnim;
var(ROAnimations) 	name		CrouchHitDownAnim;

var(ROAnimations) 	name		LimpAnims[8];

// General

var				float			NextJumpTime;
// Ramm: Refactor
// These two arent being used properly
var				float			LastLandTime;			// we'll use this for a settling time.  If someone jumps, they'll need a few seconds to settle
var				float			LandRecoveryTime;		// time it takes to recover from a jump to do whatever action, maybe change when injured

// Limping
var				float			LimpTime; 				// How long the player will limp for

// Ramm: Refactor
// Rather than have an entire actor, or array of actors, how about just using a mesh attachment?
var		array<ROAmmoPouch>		AmmoPouches;
var		class<ROAmmoPouch>		AmmoPouchClasses[3];

var		ROHeadgear				Headgear;
var		class<ROHeadgear>		HeadgearClass;

var		BackAttachment			AttachedBackItem;		// Weapon attachment on player's back

var				bool			bInitializedPlayer;

// Objectives
var				byte			CurrentCapArea;
var				byte			CurrentCapProgress;
//var			byte			CurrentCapPlayers;
var             byte            CurrentCapAxisCappers;
var             byte            CurrentCapAlliesCappers;

enum EWeaponState
{
	GS_None,
	GS_Ready,
	GS_FireSingle,
	GS_FireLooped,
	GS_PreReload,
	GS_ReloadSingle,
	GS_ReloadLooped,
	GS_BayonetAttach,
	GS_BayonetDetach,
	GS_GrenadePullBack,
	GS_GrenadeHoldBack,
	GS_IgnoreAnimend,
};

var		EWeaponState			WeaponState;

// MG resupply
// TEMP VARIABLE - put here because I didn't know where else to since I'm in a hurry
// This variable is referenced in ROHud and ROPlayer
var				bool			bCanResupply;
var				bool			bUsedCarriedMGAmmo; 	// have they already resupplied another gunner?

var				bool			bWeaponCanBeResupplied;	// True if the weapon the pawn is holding can be resupplied by other players (ie giving an MGer ammo)
var				bool			bWeaponNeedsResupply;	// True if the weapon the pawn is holding needs to be resupplied

var				Actor			SavedBase; 				// Last base this pawn was on

var 			float			SprintAccelRate;		// How fast the player accelerates when they are sprinting

// Footstep sounds
var()			float 			FootStepSoundRadius;	// The radius that footstep sounds can be heard
var()			float			QuietFootStepVolume;	// The amount to scale footstepsounds when the player is walking slowly

var() 			float			CrouchEyeHeightMod; 	// Modifier for eyeheight while crouched
var() 			float			CrouchMoveEyeHeightMod; // Modifier for eyeheight while crouched and moving
var() 			float			ProneEyeHeight; 		// ProneEyeHeight
var()			float			ProneEyeDist;			// Distance offset from location to put prone camera.
var const 		rotator			OldProneRotation;		// Used by phyics to help smooth prone rotation
var	const		float			DeployedEyeHeight;		// Calculated by physics to determine what the player's eye height should be

var(Camera)     name 			CameraBone;				// The bone used for the camera position during certain transitions (prone)

// For lean
var 			float 			LeanMax;
var 			float 			LeanFactor;
var 			float			LeanAmount;    			// Positive is right, negative is left, zero is center
var 			bool			bLeaningRight, bLeaningLeft;//Is in the process of leaning or stopping leaning or is actually leaning :P
var 			bool			bLeanRight, bLeanLeft;	//True if lean is pressed
var(Lean)		vector			LeanLViewOffset;		// Eyeposition offset for leaning left
var(Lean)		vector			LeanRViewOffset;		// Eyeposition offset for leaning right
var(Lean)		vector			LeanLCrouchViewOffset;	// Eyeposition offset for leaning left
var(Lean)		vector			LeanRCrouchViewOffset;	// Eyeposition offset for leaning right
var(Lean)		vector			LeanLProneViewOffset;	// Eyeposition offset for leaning left
var(Lean)		vector			LeanRProneViewOffset;	// Eyeposition offset for leaning right

var()			int				AnimPitchUpLimit;			// Pitch up limit for third person torso twist
var()			int				AnimPitchDownLimit;    		// Pitch down limit for third person torso twist
var()			int				ProneAnimPitchUpLimit;		// Pitch up limit for third person torso twist while prone
var()			int				ProneAnimPitchDownLimit;    // Pitch down limit for third person torso twist while prone

// Bone settings for the player animation while leaning
var(Lean) 		name			LeanBones[8];
var(Lean)		rotator			LeanLeftStanding[8];
var(Lean)		rotator			LeanRightStanding[8];
var(Lean)		rotator			LeanLeftCrouch[8];
var(Lean)		rotator			LeanRightCrouch[8];
var(Lean)		rotator			LeanLeftProne[8];
var(Lean)		rotator			LeanRightProne[8];
var				rotator 		CurrentRotators[8];

// auto tracing
var 			Actor			AutoTraceActor;			// The actor that this pawn is currently looking at (has selected)

// Deployment system
var				int				OldLookYaw;   			// The last yaw rotation of the player. used for calculating the rotation speed
var 			float 			CantRestWeapTime;       // The last time we were in a position where the weapon could not be rested
var				rotator			InitialDeployedRotation;// The rotation of the player when the weapon is initially bipod deployed
var()			int				DeployedPitchUpLimit;	// The pitch limit when bipod deployed
var()			int				DeployedPitchDownLimit;	// The pitch limit when bipod deployed
var()			int				DeployedPositiveYawLimit;// The yaw limit when bipod deployed
var()			int				DeployedNegativeYawLimit;// The yaw limit when bipod deployed
var const		float 			LastMoveTime;		     // The last time this player moved. Used for calculating crouched eye height

// Stance transition sounds
var             sound           CrouchToProneSound;
var             sound           CrouchToStandSound;
var             sound           ProneToCrouchSound;
var             sound           ProneToStandSound;
var             sound           StandToCrouchSound;
var             sound           StandToProneSound;

var             bool            bPreventWeaponFire;     // Used to prevent firing the weapon during certain pawn transitions

// Breathing sounds
var             sound           BreatheLightSound;
var             sound           BreatheMediumSound;
var             sound           BreatheHeavySound;
var             sound           BreatheExhaustedSound;

// Net code
var()			float			NetSoundRadiusSquared; // The relevant radius for certain pawn sounds to be heard by other net players. If this pawn is doing particular actions (reloading, footstepping, etc) it will be relevant to other pawns within this radius
var				bool			bInitializedWeaponAttachment;// The weapon attachment has completed initial replication


// Hit detection debugging - Only use when debugging
/*var vector DrawLocation;
var rotator DrawRotation;
var int DrawIndex;
var vector HitStart;
var vector HitEnd;
var byte HitPointDebugByte;
var byte OldHitPointDebugByte;*/

var				bool			bRecievedInitialLoadout; // Initial weapon loadout has finished replicating

//=============================================================================
// replication
//=============================================================================

replication
{
	reliable if (bNetDirty && Role == ROLE_Authority)
		bLeanRight, bLeanLeft;

	reliable if (bNetDirty && Role == ROLE_Authority)
		AmmoPouchClasses, HeadgearClass, DetachedArmClass, DetachedLegClass;

	reliable if (bNetDirty && bNetOwner && Role == ROLE_Authority)
		CurrentCapArea, CurrentCapProgress, CurrentCapAxisCappers, CurrentCapAlliesCappers,
		bUsedCarriedMGAmmo, bPreventWeaponFire;

	reliable if (Role == ROLE_Authority)
		ClientUpdateDamageList, ClientForceStaminaUpdate;

    reliable if ( bNetDirty && !bNetOwner && (Role == ROLE_Authority) )
    	bWeaponCanBeResupplied, bWeaponNeedsResupply;

    // Hit detection debugging - Only use when debugging
    //reliable if (Role == ROLE_Authority)
	///	DrawLocation,DrawRotation,DrawIndex,HitPointDebugByte,HitStart,HitEnd;
}

/*==========================================
* Natives
*=========================================*/

simulated native function int Get8WayDirection();

simulated event HandleWhizSound()
{
 	// Don't play whizz sounds for bots, or from other players
	if ( IsHumanControlled() && IsLocallyControlled() )
	{
		Spawn(class'ROBulletWhiz',,, mWhizSoundLocation);
		ROPlayer(Controller).PlayerWhizzed(VSizeSquared(Location - mWhizSoundLocation));
	}
}

// Blend the upper body back to full body animation.
// Called by the native code when AnimBlendTime counts down to zero
simulated event AnimBlendTimer()
{
	AnimBlendToAlpha(1, 0.0, 0.12);
	WeaponState = GS_Ready;
}
/*==========================================
* ROPawn functions
*=========================================*/

// test execs
/*
exec function TestEye()
{
	local rotator myrot;
    local Vector X,Y,Z;

	if( !class'ROEngine.ROLevelInfo'.static.RODebugMode() )
		return;


    GetAxes( Controller.rotation, X, Y, Z );

	myrot = Controller.rotation;

    ClearStayingDebugLines();
    DrawStayingDebugLine((EyePosition() + Location), (EyePosition() + Location)+500* X, 0,0,255);
    DrawStayingDebugLine((EyePosition() + Location), (EyePosition() + Location)+200* Y, 0,255,0);
}*/

//-----------------------------------------------------------------------------
// Empty
//-----------------------------------------------------------------------------

//=============================================================
// Initialization
//=============================================================

// Precache pawn related content
static function StaticPrecache(LevelInfo L)
{
 	default.ProjectileBloodSplatClass.static.PrecacheContent(L);
 	default.SeveredArmAttachClass.static.PrecacheContent(L);
 	default.SeveredLegAttachClass.static.PrecacheContent(L);
 	default.SeveredHeadAttachClass.static.PrecacheContent(L);
 	default.BleedingEmitterClass.static.PrecacheContent(L);
 	// TODO: Precache all the blood emitter's texture's when they are done
}

// Little Easter Egg here
function PlayDyingSound()
{
    if( Level.Netmode == NM_Client )
    {
        return;
    }

	if ( bGibbed )
	{
        // Do nothing for now
		//PlaySound(GibGroupClass.static.GibSound(), SLOT_Pain,3.5*TransientSoundVolume,true,500);
		return;
	}

    if ( HeadVolume.bWaterVolume )
    {
        PlaySound(GetSound(EST_Drown), SLOT_Pain,2.5*TransientSoundVolume,true,500);
        return;
    }

//    if (FRand() < 0.001)
//    {
//          PlaySound(sound'Miscsounds.DeanScream', SLOT_Pain,2.5*TransientSoundVolume, true,500);
//    }
//    else
//    {
		PlaySound(SoundGroupClass.static.GetDeathSound(LastHitIndex), SLOT_Pain,1.30, true,525);
//    }
}

//-----------------------------------------------------------------------------
// PostBeginPlay
//-----------------------------------------------------------------------------

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();

    // From UnrealPawn
	if ( Level.bStartup && !bNoDefaultInventory )
		AddDefaultInventory();

    AssignInitialPose();

    UpdateShadow();

	// end from UnrealPawn

    SavedBreathSound = 0;

	if (  AuxCollisionCylinder == none )
	{
		AuxCollisionCylinder = Spawn(class 'ROBulletWhipAttachment',self);
		AttachToBone(AuxCollisionCylinder, 'spine');
	}
	SavedAuxCollision = AuxCollisionCylinder.bCollideActors;

	LastResupplyTime = Level.TimeSeconds - 1;
	bTouchingResupply=false;
}

simulated function UpdateShadow()
{
    if (bActorShadows && bPlayerShadows && (Level.NetMode != NM_DedicatedServer))
    {
        if (PlayerShadow != none)
            PlayerShadow.Destroy();

        PlayerShadow = Spawn(class'ShadowProjector',Self,'',Location);
        PlayerShadow.ShadowActor = self;
        PlayerShadow.bBlobShadow = bBlobShadow;
        PlayerShadow.LightDirection = Normal(vect(1,1,3));
        PlayerShadow.LightDistance = 320;
        PlayerShadow.MaxTraceDistance = 350;
        PlayerShadow.InitShadow();
    }
    else if (PlayerShadow != none && Level.NetMode != NM_DedicatedServer)
    {
        PlayerShadow.Destroy();
        PlayerShadow = none;
    }
}

//-----------------------------------------------------------------------------
// PostNetBeginPlay - Create dummy attachments on client
//-----------------------------------------------------------------------------

simulated function PostNetBeginPlay()
{
	local int i;
 	local SquadAI S;
	local RosterEntry R;

	Super.PostNetBeginPlay();


	// From UnrealPawn
	if ( (Role == ROLE_Authority) && Level.bStartup )
	{
		if ( UnrealMPGameInfo(Level.Game) == None )
		{
			if ( Bot(Controller) != None )
			{
				foreach DynamicActors(class'SquadAI',S,SquadName)
					break;
				if ( S == None )
					S = spawn(class'SquadAI');
				S.Tag = SquadName;
				if ( bIsSquadLeader || (S.SquadLeader == None) )
					S.SetLeader(Controller);
				S.AddBot(Bot(Controller));
			}
		}
		else
		{
			R = GetPlacedRoster();
			UnrealMPGameInfo(Level.Game).InitPlacedBot(Controller,R);
		}
	}
    // End from UnrealPawn

	// MergeTODO: Maybe refactor this
	if (Role < ROLE_Authority)
	{
		if (HeadgearClass != None)
			Headgear = Spawn(HeadgearClass, self);

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

			AmmoPouches[AmmoPouches.Length] = Spawn(AmmoPouchClasses[i], self);
		}
	}
}

//-----------------------------------------------------------------------------
// PossessedBy - Figure out what dummy attachments are needed
//-----------------------------------------------------------------------------

function PossessedBy(Controller C)
{
	local array<class<ROAmmoPouch> > AmmoClasses;
	local int i, Prim, Sec, Gren;

	Super.PossessedBy(C);

	// From XPawn
	if ( Controller != None )
		OldController = Controller;

	// MergeTODO: Refactor this, I don't think this is the best place to spawn attachments

	// Handle dummy attachments
	if (Role == ROLE_Authority)
	{
		ClientForceStaminaUpdate(Stamina);

		if (ROPlayer(Controller) != None)
		{
			Prim = ROPlayer(Controller).PrimaryWeapon;
			Sec = ROPlayer(Controller).SecondaryWeapon;
			Gren = ROPlayer(Controller).GrenadeWeapon;
		}
		else if (ROBot(Controller) != None)
		{
			Prim = ROBot(Controller).PrimaryWeapon;
			Sec = ROBot(Controller).SecondaryWeapon;
			Gren = ROBot(Controller).GrenadeWeapon;
		}

		HeadgearClass = ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo.GetHeadgear();
		ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo.GetAmmoPouches(AmmoClasses, Prim, Sec, Gren);

		if( ROPlayerReplicationInfo(PlayerReplicationInfo) != none &&
			ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo != none )
		{
			DetachedArmClass = ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo.static.GetArmClass();
			DetachedLegClass = ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo.static.GetLegClass();
		}
		else
		{
			log("Error!!! Possess with no RoleInfo!!!");
		}

		for (i = 0; i < AmmoClasses.Length; i++)
			AmmoPouchClasses[i] = AmmoClasses[i];

		// These don't need to exist on dedicated servers at the moment, though they might if the ammo
		// holding functionality of the pouch is put in - Erik
		if (Level.NetMode != NM_DedicatedServer)
		{
			if (HeadgearClass != None)
				Headgear = Spawn(HeadgearClass, self);

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

				AmmoPouches[AmmoPouches.Length] = Spawn(AmmoPouchClasses[i], self);
			}
		}
	}

	// Send the info to the client now to make sure RoleInfo is replicated quickly
	NetUpdateTime = Level.TimeSeconds - 1;
}

//=============================================================
// Setters
//=============================================================

// Setters for extra collision cylinders
// MergeTODO: Verify we even need these once we have the new native trace support
simulated function ToggleAuxCollision(bool newbCollision)
{
	if ( !newbCollision )
	{
		SavedAuxCollision = AuxCollisionCylinder.bCollideActors;

		AuxCollisionCylinder.SetCollision(false);
	}
	else
	{
		AuxCollisionCylinder.SetCollision(SavedAuxCollision);
	}
}

// Set the player to limping for a time
function SetLimping(float Duration)
{
	bIsLimping = true;
	LimpTime = Duration;
}

// Handle changing Stamina Based breathing sounds - Ramm
function SetBreathingSound(byte NewSound)
{
	if (NewSound == 1)
	{
		if (AmbientSound != BreatheExhaustedSound)
			AmbientSound = BreatheExhaustedSound;
	}
	else if (NewSound == 2)
	{
		if (AmbientSound != BreatheHeavySound)
			AmbientSound = BreatheHeavySound;
	}
	else if (NewSound == 3)
	{
		if (AmbientSound != BreatheHeavySound)
			AmbientSound = BreatheMediumSound;
	}
	else if (NewSound == 4)
	{
		AmbientSound = BreatheLightSound;
	}
	else if (NewSound == 5 )
	{
		if (AmbientSound != None)
		{
			AmbientSound = None;
		}
	}

	SavedBreathSound = NewSound;
}

//-----------------------------------------------------------------------------
// SetSprinting - Enables and disables sprinting
//-----------------------------------------------------------------------------
function SetSprinting(bool bNewIsSprinting)
{
	if (bNewIsSprinting != (bIsSprinting || bOldSprinting) )
	{
		if( bNewIsSprinting && (!AllowSprint() || !bCanStartSprint) )
		{
			return;
		}

		bIsSprinting = bNewIsSprinting;

		SetWalking(false);

		if (bIsSprinting)
		{
			StartSprint();
		}
		else
		{
			EndSprint();
		}

        bOldSprinting = bIsSprinting;
	}
}

function SetWalking(bool bNewIsWalking)
{
	if (bNewIsWalking != bIsWalking)
	{
		bIsWalking = bNewIsWalking;
	}
}

//=============================================================
// Drawing
//=============================================================

//-----------------------------------------------------------------------------
// CalcDrawOffset - Overriden to prevent the player from disabling bobbing
//-----------------------------------------------------------------------------
simulated function vector CalcDrawOffset(inventory Inv)
{
	local vector DrawOffset;

	if ( Controller == None )
		return (Inv.PlayerViewOffset >> Rotation) + BaseEyeHeight * vect(0,0,1);

	DrawOffset = ((0.9/Weapon.DisplayFOV * 100 * ModifiedPlayerViewOffset(Inv)) >> GetViewRotation() );
	if ( !IsLocallyControlled() )
		DrawOffset.Z += BaseEyeHeight;
	else
	{
		// Added these for proneing and leaning
		DrawOffset.Z += EyePosition().Z;
		DrawOffset.X += EyePosition().X;
		DrawOffset.Y += EyePosition().Y;

	    DrawOffset += WeaponBob(Inv.BobDamping);
        DrawOffset += CameraShake();
	}
	return DrawOffset;
}

//-----------------------------------------------------------------------------
// CheckBob - Overriden to prevent the player from disabling bobbing and
// to handle playing footstep sounds in other movement states
//-----------------------------------------------------------------------------
function CheckBob(float DeltaTime, vector Y)
{
	local float Speed2D;
	local float OldBobTime;
	local int m,n;
	local float BobModifier;


	OldBobTime = BobTime;

	Bob = FClamp(Bob, -0.01, 0.01);
    BobModifier = 1.0;

	// Modify the amount of bob based on the movement state
	if( bIsSprinting )
	{
		BobModifier = 1.75;
	}
	else if( bIsCrawling && !bIronSights)
	{
		BobModifier = 2.5;
	}
	else if( bIsCrouched )
	{
		BobModifier = 2.5;
	}

	if (Physics == PHYS_Walking )
	{
		Speed2D = VSize(Velocity);

		if( bIsCrawling && !bIronSights )
		{
			BobTime += DeltaTime * ((0.3 + 0.7 * Speed2D/(GroundSpeed*PronePct))/2);
		}
		else if( bIsSprinting )
		{
			if ( Speed2D < 10 )
				BobTime += 0.2 * DeltaTime;
			else
			{
				if ( bIsCrouched )
				{
					BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/((GroundSpeed*CrouchedSprintPct)/1.25));
				}
				else
				{
					BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/((GroundSpeed*SprintPct)/1.25));
				}
			}
		}
		else
		{
			if ( Speed2D < 10 )
				BobTime += 0.2 * DeltaTime;
			else
				BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/GroundSpeed);
		}
		WalkBob = Y * (Bob * BobModifier) * Speed2D * sin(8 * BobTime);
		AppliedBob = AppliedBob * (1 - FMin(1, 16 * deltatime));
		WalkBob.Z = AppliedBob;
		if ( Speed2D > 10 )
			WalkBob.Z = WalkBob.Z + 0.75 * (Bob * BobModifier) * Speed2D * sin(16 * BobTime);
		if ( LandBob > 0.01 )
		{
			AppliedBob += FMin(1, 16 * deltatime) * LandBob;
			LandBob *= (1 - 8*Deltatime);
		}
	}
	else if ( Physics == PHYS_Swimming )
	{
		Speed2D = Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y);
		WalkBob = Y * Bob *  0.5 * Speed2D * sin(4.0 * Level.TimeSeconds);
		WalkBob.Z = Bob * 1.5 * Speed2D * sin(8.0 * Level.TimeSeconds);
	}
	else
	{
		BobTime = 0;
		WalkBob = WalkBob * (1 - FMin(1, 8 * deltatime));
	}

	if ( (Physics != PHYS_Walking) || (VSize(Velocity) < 10)
		|| ((PlayerController(Controller) != None) && PlayerController(Controller).bBehindView) )
		return;

	m = int(0.5 * Pi + 9.0 * OldBobTime/Pi);
	n = int(0.5 * Pi + 9.0 * BobTime/Pi);

	if ( (m != n) && !bIsCrawling)
		FootStepping(0);
}

// Footstep sound checking for non local player or non player bots
// This function is only called on non owned network clients or bots
simulated function CheckFootSteps(float DeltaTime)
{
	local float Speed2D;
	local float OldBobTime;
	local int m,n;

	OldBobTime = BobTime;

	if (Physics == PHYS_Walking )
	{
		Speed2D = VSize(Velocity);

		if( bIsCrawling && !bIronSights )
		{
			BobTime += DeltaTime * ((0.3 + 0.7 * Speed2D/(GroundSpeed*PronePct))/2);
		}
		else if( bIsSprinting )
		{
			if ( Speed2D < 10 )
				BobTime += 0.2 * DeltaTime;
			else
			{
				if ( bIsCrouched )
				{
					BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/((GroundSpeed*CrouchedSprintPct)/1.25));
				}
				else
				{
					BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/((GroundSpeed*SprintPct)/1.25));
				}
			}
		}
		else
		{
			if ( Speed2D < 10 )
				BobTime += 0.2 * DeltaTime;
			else
				BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/GroundSpeed);
		}
	}
	else
	{
		BobTime = 0;
	}

	if ( (Physics != PHYS_Walking) || (VSize(Velocity) < 10) )
		return;

	m = int(0.5 * Pi + 9.0 * OldBobTime/Pi);
	n = int(0.5 * Pi + 9.0 * BobTime/Pi);

	if ( (m != n) && !bIsCrawling)
		FootStepping(0);
}

//-----------------------------------------------------------------------------
// DisplayDebug - Used to display important debugging info on the hud
// - with bullet debugging and functionality from unrealpawn
//-----------------------------------------------------------------------------
simulated function DisplayDebug(Canvas Canvas, out float YL, out float YPos)
{
	local string T;
	local float XL;

	local int	i;
	local name  Sequence;
	local float Frame, Rate;



	// From Unrealpawn
	/*
	if ( !bSoakDebug )
	{
		Super.DisplayDebug(Canvas, YL, YPos);
		return;
	}*/

	Super.DisplayDebug(Canvas, YL, YPos);

    if ( bSoakDebug )
	{

		Canvas.Style = ERenderStyle.STY_Normal;
		Canvas.StrLen("TEST", XL, YL);
		YPos = YPos + 8*YL;
		Canvas.SetPos(4,YPos);
		Canvas.SetDrawColor(255,255,0);
		T = GetDebugName();
		if ( bDeleteMe )
			T = T$" DELETED (bDeleteMe == true)";
		Canvas.DrawText(T, false);
		YPos += 3 * YL;
		Canvas.SetPos(4,YPos);

		if ( Controller == None )
		{
			Canvas.SetDrawColor(255,0,0);
			Canvas.DrawText("NO CONTROLLER");
			YPos += YL;
			Canvas.SetPos(4,YPos);
		}
		else
			Controller.DisplayDebug(Canvas,YL,YPos);

		YPos += 2*YL;
		Canvas.SetPos(4,YPos);
		Canvas.SetDrawColor(0,255,255);
		Canvas.DrawText("Anchor "$Anchor$" Serpentine Dist "$SerpentineDist$" Time "$SerpentineTime);
		YPos += YL;
		Canvas.SetPos(4,YPos);

		T = "Floor "$Floor$" DesiredSpeed "$DesiredSpeed$" Crouched "$bIsCrouched$" Try to uncrouch "$UncrouchTime;
		if ( (OnLadder != None) || (Physics == PHYS_Ladder) )
			T=T$" on ladder "$OnLadder;
		Canvas.DrawText(T);
		YPos += YL;
		Canvas.SetPos(4,YPos);
		// End from Unrealpawn
	}

	Canvas.SetDrawColor(255,255,255);

    Canvas.DrawText("ROWeapon state is " $GetEnum( enum'EWeaponState', WeaponState));
    YPos += YL;
    Canvas.SetPos(4,YPos);

	Canvas.DrawText("Stamina:"@Stamina);
	YPos += YL;
	Canvas.SetPos(4,YPos);

	for( i = 0; i < 16; i++ )
	{
		if( IsAnimating( i ) )
		{
			GetAnimParams( i, Sequence, Frame, Rate );
			Canvas.DrawText("Anim:: Channel("@i@") Frame("@Frame@") Rate("@Rate@") Name("@Sequence@")");
			YPos += YL;
			Canvas.SetPos(4,YPos);
		}
	}

	if (WeaponAttachment != None)
	{
			WeaponAttachment.GetAnimParams( 0, Sequence, Frame, Rate );
			Canvas.DrawText("WeaponAttachment Anim: Frame("@Frame@") Rate("@Rate@") Name("@Sequence@")");
			YPos += YL;
			Canvas.SetPos(4,YPos);
	}

	if (Weapon != None)
	{
			Weapon.GetAnimParams( 0, Sequence, Frame, Rate );
			Canvas.DrawText("Weapon Anim: Frame("@Frame@") Rate("@Rate@") Name("@Sequence@")");
			YPos += YL;
			Canvas.SetPos(4,YPos);
	}

//	Canvas.DrawText("CanBipodDeploy: "@bCanBipodDeploy$" BipodDeployed: "@bBipodDeployed);
//	YPos += YL;
//	Canvas.SetPos(4,YPos);

//	Canvas.DrawText("BaseEyeHeight: "$default.BaseEyeHeight$"DeployedEyeHeight: "@DeployedEyeHeight$" ProneEyeHeight: "@ProneEyeHeight$" CrouchEyeHeight: "$(CrouchEyeHeightMod * CrouchHeight)$" CrouchMoveEyeHeight "$(CrouchMoveEyeHeightMod * CrouchHeight));
//	YPos += YL;
//	Canvas.SetPos(4,YPos);



/*	Canvas.DrawText("PrePivot:"@PrePivot);
	YPos += YL;
	Canvas.SetPos(4,YPos); */

/*	Canvas.DrawText("maxyaw is "@maxyaw@" minyaw is "@minyaw);
	YPos += YL;
	Canvas.SetPos(4,YPos);

	Canvas.DrawText("bUsedCarriedMGAmmo is "@bUsedCarriedMGAmmo);
	YPos += YL;
	Canvas.SetPos(4,YPos);


	Canvas.DrawText("debugPitchUpLimit is "@debugPitchUpLimit@" debugPitchDownLimit is "@debugPitchDownLimit);
	YPos += YL;
	Canvas.SetPos(4,YPos);*/
}

//=============================================================
// Animation
//=============================================================

//-----------------------------------------------------------------------------
// SetIronSightAnims - Sets the proper player animations for aiming and non-aiming
//-----------------------------------------------------------------------------
function SetIronSightAnims(bool bNewIronSights)
{
	bIronSights = bNewIronSights;
}

//-----------------------------------------------------------------------------
// SetMeleeHoldAnims - Sets the proper player animations melee attacks
//-----------------------------------------------------------------------------
function SetMeleeHoldAnims(bool bNewMeleeHold)
{
	bMeleeHolding = bNewMeleeHold;
}

//-----------------------------------------------------------------------------
// SetMeleeHoldAnims - Sets the proper player animations prepping to fire an explosive weapon
//-----------------------------------------------------------------------------
function SetExplosiveHoldAnims(bool bNewExplosiveHold)
{
	bExplosiveHolding = bNewExplosiveHold;
}

//-----------------------------------------------------------------------------
// SetIronSightAnims - Sets the proper player animations for aiming and non-aiming
//-----------------------------------------------------------------------------
function SetBipodDeployed(bool bNewDeployed)
{
	if( !bNewDeployed && bBipodDeployed )
	{
	 	bBipodDeployed = false;
	 	InitialDeployedRotation = rot(0,0,0);

	 	if( bIsCrawling )
	 	{
		 	BaseEyeHeight = ProneEyeHeight;
		}
		else if ( bIsCrouched )
		{
  			BaseEyeHeight = CrouchEyeHeightMod * CrouchHeight;
		}
		else
		{
			BaseEyeHeight = default.BaseEyeHeight;
		}

	 	if( Role == ROLE_Authority )
	 	{
	 		SetAnimAction('DoBipodUnDeploy');
	 	}
	}
	else if( bNewDeployed )
	{
		bBipodDeployed = true;
		InitialDeployedRotation.Pitch = Rotation.Pitch & 65535;
		InitialDeployedRotation.Yaw = Rotation.Yaw;

		if ( !bIsCrouched && !bIsCrawling && DeployedEyeHeight < 30 )
		{
			BaseEyeHeight = DeployedEyeHeight + 10;
			ROPlayer(Controller).Crouch();
		}
		else if ( !bIsCrawling )
		{
        	BaseEyeHeight = DeployedEyeHeight;
        }

	 	if( Role == ROLE_Authority )
	 	{
	 		SetAnimAction('DoBipodDeploy');
	 	}
	}
}


// Returns true if TestAnim is an animation for
// drawing a weapon
simulated function bool IsDrawAnim(name TestAnim)
{
	switch( TestAnim )
    {
        case 'stand_draw_kar':
        case 'stand_draw_nade':
        case 'stand_nadefromrifle':
        case 'stand_riflefromnade':
        case 'stand_pistolfromrifle':
        case 'stand_riflefrompistol':
        case 'stand_nadefrompistol':
        case 'stand_pistolfromnade':
        case 'prone_draw_kar':
        case 'prone_draw_nade':
        case 'prone_nadefromrifle':
        case 'prone_riflefromnade':
        case 'prone_pistolfromrifle':
        case 'prone_riflefrompistol':
        case 'prone_nadefrompistol':
        case 'prone_pistolfromnade':
			return true;
            break;
    }

    return false;
}

// Returns true if TestAnim is an animation for
// putting away a weapon
simulated function bool IsPutAwayAnim(name TestAnim)
{
	switch( TestAnim )
    {
        case 'stand_putaway_kar':
        case 'stand_putaway_nade':
        case 'stand_putaway_pistol':
        case 'prone_putaway_kar':
        case 'prone_putaway_nade':
        case 'prone_putaway_pistol':
			return true;
            break;
    }

    return false;
}

// This function plays an upper body anim that will blend back to full body
// after the animation finishes. Must set the paramaters with an AnimBlendParams()
// call before calling this function
simulated function PlayUpperBodyAnim( name NewAnim, optional float InRate, optional float TweenTime, optional float InBlendTime )
{
	local float Rate;
	local float BlendTime;

	if ( InRate == 0 )
	{
		Rate = 1.0;
	}
	else
	{
		Rate = InRate;
	}

	if ( InBlendTime == 0 )
	{
		BlendTime = GetAnimDuration(NewAnim, Rate) + TweenTime;
	}
	else
	{
		BlendTime = InBlendTime;
	}

    PlayAnim(NewAnim,Rate, TweenTime, 1);
    AnimBlendTime = BlendTime;
}

// Get the alernate animaction name for a given animaction
simulated function name GetAltName(name TestName)
{
	switch( TestName )
    {
        case 'DoStandardReload':
        	return 'DoStandardReloadA';
        	break;
        case 'DoBoltAction':
        	return 'DoBoltActionA';
        	break;
    }

    return GetAnimActionName(TestName);
}

// Get the standard animaction name for a given alternate animaction
simulated function name GetAnimActionName(name TestName)
{
	switch( TestName )
    {
        case 'DoStandardReloadA':
        	return 'DoStandardReload';
        	break;
        case 'DoBoltActionA':
        	return 'DoBoltAction';
        	break;
    }

    return TestName;
}

//-----------------------------------------------------------------------------
// SetAnimAction - Checks WeaponState (new enum for added anim capabilities) instead of FiringState
//-----------------------------------------------------------------------------
// MergeTODO: The way this is done right now is pretty buggy. Lets try and clean this up
simulated event SetAnimAction(name NewAction)
{
	local name UsedAction;

    if (!bWaitForAnim)
    {
		// Since you can't call SetAnimAction for the same action twice in a row (it won't get replicated)
		// For animations that need to happen twice in a row (such as working the bolt of a rifle)
		// we alternate animaction names for these actions so they replicate properly
		if( Level.Netmode == NM_Client )
		{
			UsedAction = GetAnimActionName(NewAction);
		}
		else
		{
			UsedAction = NewAction;

			if( AnimAction == NewAction )
			{
				NewAction = GetAltName(NewAction);
			}
		}


	    AnimAction = NewAction;

	    // Weapon switching actions
		if ( IsDrawAnim(UsedAction) )
        {
            AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
            AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);
            PlayUpperBodyAnim( UsedAction, 1.0, 0.0 );
         }
        else if ( IsPutAwayAnim(UsedAction) )
        {
            AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
            AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);
            WeaponState = GS_IgnoreAnimend;
            PlayUpperBodyAnim( UsedAction, 1.0, 0.1, GetAnimDuration(AnimAction,1.0) * 2);

        }
		else if ( UsedAction == 'ClearAnims' )
		{
   			AnimBlendToAlpha(1, 0.0, 0.12);
		}
		else if ( UsedAction == 'TossedWeapon' )
		{
			SetWeaponAttachment(none);
		}
		else if ( UsedAction == 'DoStandardReload' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayStandardReload();
		}
		else if ( UsedAction == 'DoBayoAttach' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayBayonetAttach();
		}
		else if ( UsedAction == 'DoBayoDetach' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayBayonetDetach();
		}
		else if ( UsedAction == 'DoBipodDeploy' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayBipodDeploy();
		}
		else if ( UsedAction == 'DoBipodUnDeploy' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayBipodUnDeploy();
		}
		else if ( UsedAction == 'DoBoltAction' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayBoltAction();
		}
		else if ( UsedAction == 'DoLoopingReload' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayStartReloading();
		}
		else if ( UsedAction == 'DoReloadEnd' )
		{
			if( Level.NetMode != NM_DedicatedServer )
				PlayStopReloading();
		}
        else if ( UsedAction == 'StartCrawling')
        {
        	bWaitForAnim = true;
        	GotoState('StartProning');
        }
        else if ( UsedAction == 'EndCrawling')
        {
        	bWaitForAnim = true;
        	GotoState('EndProning');
        }
        else if ( UsedAction == 'DiveToProne')
        {
        	bWaitForAnim = true;
        	GotoState('DivingToProne');
        }
        else if ( UsedAction == 'ProneToCrouch')
        {
        	bWaitForAnim = true;
        	GotoState('CrouchingFromProne');
        }
        else if ( UsedAction == 'CrouchToProne')
        {
        	bWaitForAnim = true;
        	GotoState('ProningFromCrouch');
        }
        else if ( (Physics == PHYS_None)
			|| ((Level.Game != None) && Level.Game.IsInState('MatchOver')) )
        {
            PlayAnim(UsedAction,,0.1);
			AnimBlendToAlpha(1,0.0,0.05);
        }
        else if ( (Physics == PHYS_Falling) || ((Physics == PHYS_Walking) && (Velocity.Z != 0)) )
		{
			if ( CheckTauntValid(UsedAction) )
			{
				if (WeaponState == GS_None || WeaponState == GS_Ready)
				{
					AnimBlendParams(1, 1.0, 0.0, 0.2, FireRootBone);
					PlayAnim(UsedAction,, 0.1, 1);
					WeaponState = GS_Ready;
				}
			}
			else if ( PlayAnim(UsedAction) )
			{
				if ( Physics != PHYS_None )
				{
					bWaitForAnim = true;
				}
			}
			else
			{
				AnimAction = '';
			}
		}
        else if (bIsIdle && !bIsCrouched && (Bot(Controller) == None) ) // standing taunt
        {
            PlayAnim(UsedAction,,0.1);
			AnimBlendToAlpha(1,0.0,0.05);
        }
        else // running taunt
        {
            if (WeaponState == GS_None || WeaponState == GS_Ready)
            {
                AnimBlendParams(1, 1.0, 0.0, 0.2, FireRootBone);
                PlayAnim(UsedAction,, 0.1, 1);
                WeaponState = GS_Ready;
            }
        }
    }
}

// Called on the server. Sends a message to the client to let them know to play the bayoattach
function HandleBoltAction()
{
	SetAnimAction('DoBoltAction');
}

//-----------------------------------------------------------------------------
// PlayBayonetAttach - Bayonet anims
//-----------------------------------------------------------------------------

simulated function PlayBoltAction()
{
	local name Anim;
	local bool bIsMoving;

	bIsMoving = VSizeSquared(Velocity) > 25;

	if (WeaponAttachment != None)
	{
		if (bIsCrawling)
		{
			Anim = WeaponAttachment.PA_ProneBoltActionAnim;
		}
		else if( bIsCrouched )
		{
			if( bIsMoving || bIronSights )
			{
				Anim = WeaponAttachment.PA_CrouchIronBoltActionAnim;
			}
			else
			{
				Anim = WeaponAttachment.PA_CrouchBoltActionAnim;
			}
		}
		else
		{
			if( bIronSights )
			{
				Anim = WeaponAttachment.PA_StandIronBoltActionAnim;
			}
			else
			{
				Anim = WeaponAttachment.PA_StandBoltActionAnim;
			}
		}

        AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
        AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);

		PlayAnim(Anim,, 0.1, 1);
	// TODO: Plug in the weapons animation
		if (WeaponAttachment.bBayonetAttached)
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_BayonetWorkBolt,, 0.1);
		else
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_WorkBolt,, 0.1);

		AnimBlendTime = GetAnimDuration(Anim, 1.0) + 0.1;
	}
}


// Called on the server. Sends a message to the client to let them know to play the bayoattach
function HandleBayoAttach()
{
	SetAnimAction('DoBayoAttach');
}

//-----------------------------------------------------------------------------
// PlayBayonetAttach - Bayonet anims
//-----------------------------------------------------------------------------

simulated function PlayBayonetAttach()
{
	local name Anim, WeapAnim;

	if (WeaponAttachment != None)
	{
		if (bIsCrawling)
			Anim = WeaponAttachment.PA_ProneBayonetAttachAnim;
		else
			Anim = WeaponAttachment.PA_BayonetAttachAnim;

        AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
        AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);

		PlayAnim(Anim,, 0.1, 1);

		if( bIsCrawling )
		{
			WeapAnim = WeaponAttachment.WA_BayonetAttachProne;
		}
		else
		{
		   	WeapAnim = WeaponAttachment.WA_BayonetAttach;
		}

 		WeaponAttachment.PlayAnim(WeapAnim,, 0.1);

		AnimBlendTime = GetAnimDuration(Anim, 1.0)+0.1;
	}
}

// Called on the server. Sends a message to the client to let them know to play the bayoattach
function HandleBayoDetach()
{
	SetAnimAction('DoBayoDetach');
}

//-----------------------------------------------------------------------------
// PlayBayonetDetach - Bayonet anims
//-----------------------------------------------------------------------------

simulated function PlayBayonetDetach()
{
	local name Anim, WeapAnim;

	if (WeaponAttachment != None)
	{
		if (bIsCrawling)
			Anim = WeaponAttachment.PA_ProneBayonetDetachAnim;
		else
			Anim = WeaponAttachment.PA_BayonetDetachAnim;

        AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
        AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);

		PlayAnim(Anim,, 0.1, 1);
		if( bIsCrawling )
		{
			WeapAnim = WeaponAttachment.WA_BayonetDetachProne;
		}
		else
		{
		   	WeapAnim = WeaponAttachment.WA_BayonetDetach;
		}

 		WeaponAttachment.PlayAnim(WeapAnim,, 0.1);

		AnimBlendTime = GetAnimDuration(Anim, 1.0)+0.1;
	}
}

//------------------------------------------------------------------------------
// PlayWeaponDeploy - Plays weapon and player deployment animations
//------------------------------------------------------------------------------
simulated function PlayBipodDeploy()
{
	local name Anim;

	if( WeaponAttachment != none )
	{
		if( bIsCrawling )
		{
			Anim = WeaponAttachment.PA_ProneWeaponDeployAnim;
		}
		else
		{
			Anim = WeaponAttachment.PA_StandWeaponDeployAnim;
		}

        AnimBlendParams(1,1.0, 0.0, 0.2, FireRootBone);
		PlayAnim(Anim,, 0.1, 1);

		// Replaceme when we get actual transition anims
		AnimBlendTime = 0.02;//GetAnimDuration(Anim, 1.0)+0.1;

		if( WeaponAttachment.HasAnim(WeaponAttachment.WA_WeaponDeploy) )
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_WeaponDeploy,, 0.1);
	}
}

//------------------------------------------------------------------------------
// PlayWeaponUnDeploy - Plays weapon and player un-deployment animations
//------------------------------------------------------------------------------
simulated function PlayBipodUnDeploy()
{
	local name Anim;

	if( WeaponAttachment != none )
	{
		if( bIsCrawling )
		{
			Anim = WeaponAttachment.PA_ProneWeaponUnDeployAnim;
		}
		else
		{
			Anim = WeaponAttachment.PA_StandWeaponUnDeployAnim;
		}

        AnimBlendParams(1,1.0, 0.0, 0.2, FireRootBone);
		PlayAnim(Anim,, 0.1, 1);

		// Replaceme when we get actual transition anims
		AnimBlendTime = 0.02;//GetAnimDuration(Anim, 1.0)+0.1;

		if( WeaponAttachment.HasAnim(WeaponAttachment.WA_WeaponUnDeploy) )
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_WeaponUnDeploy,, 0.1);
	}
}

//-----------------------------------------------------------------------------
// PlayStartCrawling - Plays the anim going into prone
//-----------------------------------------------------------------------------
simulated function PlayStartCrawling()
{
	local name Anim;
	local float AnimTimer;

	if (bIsCrouched)
	{
		if (WeaponAttachment != None)
			Anim = WeaponAttachment.PA_CrouchToProneAnim;
		else
			Anim = CrouchToProneAnim;

		PlayOwnedSound(CrouchToProneSound, SLOT_Interact, 1.0,, 10);
	}
	else
	{
		if (WeaponAttachment != None)
			Anim = WeaponAttachment.PA_StandToProneAnim;
		else
			Anim = StandToProneAnim;

		PlayOwnedSound(StandToProneSound, SLOT_Interact, 1.0,, 10);
	}

    AnimTimer = GetAnimDuration(Anim, 1.0);

    // Have the server finish the prone transition state slightly before the client (fixes some client/server sync issues)
	if( Level.NetMode == NM_DedicatedServer || (Level.NetMode == NM_ListenServer && !Instigator.IsLocallyControlled()))
		SetTimer(AnimTimer - (AnimTimer * 0.1),false);
	else
		SetTimer(AnimTimer,false);

	if (bIsIdle && !bIsCrouched)
	{
		PlayAnim(Anim,1.0,0.0,0);
	}
	else
	{
		PlayAnim(Anim,1.0,0.0,0);
		WeaponState = GS_Ready;
	}
}

//-----------------------------------------------------------------------------
// PlayEndCrawling - Plays the anim going out of prone
//-----------------------------------------------------------------------------
simulated function PlayEndCrawling()
{
	local name Anim;
	local float AnimTimer;

	if (bIsCrouched)
	{
		if (WeaponAttachment != None)
			Anim = WeaponAttachment.PA_ProneToCrouchAnim;
		else
			Anim = ProneToCrouchAnim;

		PlayOwnedSound(ProneToCrouchSound, SLOT_Interact, 1.0,, 10);
	}
	else
	{
		if (WeaponAttachment != None)
			Anim = WeaponAttachment.PA_ProneToStandAnim;
		else
			Anim = ProneToStandAnim;

		PlayOwnedSound(ProneToStandSound, SLOT_Interact, 1.0,, 10);
	}

    AnimTimer = GetAnimDuration(Anim, 1.0);

    // Have the server finish the prone transition state slightly before the client (fixes some client/server sync issues)
	if( Level.NetMode == NM_DedicatedServer || (Level.NetMode == NM_ListenServer && !Instigator.IsLocallyControlled()))
		SetTimer(AnimTimer - (AnimTimer * 0.1),false);
	else
		SetTimer(AnimTimer,false);


	if (bIsIdle && !bIsCrouched)
	{
		PlayAnim(Anim,1.0,0.0,0);
	}
        else
	{
		PlayAnim(Anim,1.0,0.0,0);
		WeaponState = GS_Ready;
	}
}

//-----------------------------------------------------------------------------
// PlayProningFromCrouch - Plays the anim going into prone from crouched
//-----------------------------------------------------------------------------
simulated function PlayProningFromCrouch()
{
	local name Anim;
	local float AnimTimer;

	if (WeaponAttachment != None)
		Anim = WeaponAttachment.PA_CrouchToProneAnim;
	else
		Anim = CrouchToProneAnim;

	PlayOwnedSound(CrouchToProneSound, SLOT_Interact, 1.0,, 10);

    AnimTimer = GetAnimDuration(Anim, 1.0);

    // Have the server finish the prone transition state slightly before the client (fixes some client/server sync issues)
	if( Level.NetMode == NM_DedicatedServer || (Level.NetMode == NM_ListenServer && !Instigator.IsLocallyControlled()))
		SetTimer(AnimTimer - (AnimTimer * 0.1),false);
	else
		SetTimer(AnimTimer,false);
	PlayAnim(Anim,1.0,0.0,0);
}

//-----------------------------------------------------------------------------
// PlayCrouchingFromProne - Plays the anim going out of prone to crouch
//-----------------------------------------------------------------------------
simulated function PlayCrouchingFromProne()
{
	local name Anim;
	local float AnimTimer;

	if (WeaponAttachment != None)
		Anim = WeaponAttachment.PA_ProneToCrouchAnim;
	else
		Anim = ProneToCrouchAnim;

	PlayOwnedSound(ProneToCrouchSound, SLOT_Interact, 1.0,, 10);

	AnimTimer = GetAnimDuration(Anim, 1.0);

    // Have the server finish the prone transition state slightly before the client (fixes some client/server sync issues)
	if( Level.NetMode == NM_DedicatedServer || (Level.NetMode == NM_ListenServer && !Instigator.IsLocallyControlled()))
		SetTimer(AnimTimer - (AnimTimer * 0.1),false);
	else
		SetTimer(AnimTimer,false);
	PlayAnim(Anim,1.0,0.0,0);
}


//-----------------------------------------------------------------------------
// PlayGrenadeBack
//-----------------------------------------------------------------------------

simulated function PlayGrenadeBack()
{
	AnimBlendParams(1, 1.0, 0.0, 0.2, FireRootBone);

	if (bIsCrawling)
		PlayAnim('prone_pullpin_nade',, 0.0, 1);
	else
		PlayAnim('stand_pullpin_nade',, 0.0, 1);

	WeaponState = GS_GrenadePullBack;
}

//-----------------------------------------------------------------------------
// SetWeaponAttachment - Update anims to match attachment
//-----------------------------------------------------------------------------
simulated function SetWeaponAttachment(ROWeaponAttachment NewAtt)
{
	WeaponAttachment = NewAtt;

	if (!bInitializedWeaponAttachment && NewAtt != none)
		bInitializedWeaponAttachment = true;

	if( WeaponAttachment == none )
		return;

	if( ROProjectileWeapon(Weapon) != none )
		WeaponAttachment.bBayonetAttached = ROProjectileWeapon(Weapon).bBayonetMounted;
	WeaponAttachment.AnimEnd(0);
}

//-----------------------------------------------------------------------------
// CheckWeaponAttachment - Occasionally the packets that tell the
// clients when a new weaponattachment should be set arrive out of
// order. The destroy function of ROWeaponAttachment called this
// function to correct that problem (since a destroyed weapon
// attachement should pretty much never be the current weapon
// attachement.
//-----------------------------------------------------------------------------
simulated function CheckWeaponAttachment(ROWeaponAttachment TestAtt)
{
	local int i;

	if( WeaponAttachment == TestAtt )
	{
		// Try and find weapon attachement
	    for( i = 0; i < Attached.length; i++ )
	    {
	        if( Attached[i].IsA('ROWeaponAttachment') && Attached[i] != TestAtt)
	        {
	        	SetWeaponAttachment(ROWeaponAttachment(Attached[i]));
	        	break;
	        }
	    }
    }
}


//-----------------------------------------------------------------------------
// AnimEnd - Figure out what to do with the weapon anims
//-----------------------------------------------------------------------------
// MergeTODO: This looks like a TERRIBLE way to handle reloads and firing anims. Lets refactor this
simulated event AnimEnd(int Channel)
{
	local name WeapAnim, PlayerAnim;
	local bool bIsMoving;
	local name Anim;
	local float frame, rate;

	bIsMoving = VSizeSquared(Velocity) > 25;

	if( DrivenVehicle != none )
	{
		PlayAnim(DrivenVehicle.DriveAnim,1.0,, 1);
	}
	else if (Channel == 1 && WeaponState != GS_IgnoreAnimend)
	{
		if (WeaponState == GS_Ready)
		{
			AnimBlendToAlpha(1, 0.0, 0.12);
			WeaponState = GS_None;
		}
		else if (WeaponState == GS_FireSingle || WeaponState == GS_ReloadSingle)
		{
		 	// This used to play the idle animation after the firing anim was played
		 	// and then set the weaponstate to GS_Ready, which would handle resetting
		 	// the upperbody blending params when the animation ended. That didn't
		 	// work well for us, so now we do that here - Ramm

			// Stop the rapid fire anim from looping
            AnimStopLooping(1);

			if( bIsMoving )
			{
				AnimBlendToAlpha(1, 0.0, 0.12);
				WeaponState = GS_None;
			}
			else
			{
                AnimBlendToAlpha(1, 0.0, 0.12);

				WeaponState = GS_None;
				IdleTime = Level.TimeSeconds;
			}

			if (WeaponAttachment != none)
			{
				WeaponAttachment.GetAnimParams(0, Anim, frame, rate);

				if (WeaponAttachment.bBayonetAttached)
				{
					if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_BayonetIdleEmpty != '' && Anim != WeaponAttachment.WA_BayonetReloadEmpty)
						WeaponAttachment.LoopAnim(WeaponAttachment.WA_BayonetIdleEmpty);
					else if (WeaponAttachment.WA_BayonetIdle != '')
						WeaponAttachment.LoopAnim(WeaponAttachment.WA_BayonetIdle);
				}
				else
				{
					if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_IdleEmpty != '' && Anim != WeaponAttachment.WA_ReloadEmpty)
						WeaponAttachment.LoopAnim(WeaponAttachment.WA_IdleEmpty);
					else
						WeaponAttachment.LoopAnim(WeaponAttachment.WA_Idle);
				}
			}
		}
		else if (WeaponState == GS_GrenadePullBack)
		{
			if (bIsCrawling)
				LoopAnim('prone_hold_nade',, 0.0, 1);
			else
				LoopAnim('stand_hold_nade',, 0.0, 1);

			WeaponState = GS_GrenadeHoldBack;
			IdleTime = Level.TimeSeconds;
		}
		else if (WeaponState == GS_PreReload && WeaponAttachment != None)
		{
	        AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
	        AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);

			if (WeaponAttachment.bOutOfAmmo)
			{
				if (bIsCrawling)
					PlayerAnim = WeaponAttachment.PA_ProneReloadEmptyAnim;
				else
					PlayerAnim = WeaponAttachment.PA_ReloadEmptyAnim;
			}
			else
			{
				if (bIsCrawling)
					PlayerAnim = WeaponAttachment.PA_ProneReloadAnim;
				else
					PlayerAnim = WeaponAttachment.PA_ReloadAnim;
			}

			LoopAnim(PlayerAnim,, 0.0, 1);
			WeaponState = GS_ReloadLooped;
			IdleTime = Level.TimeSeconds;

			if (WeaponAttachment.bBayonetAttached)
			{
				if( bIsCrawling )
				{
					if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_BayonetProneReloadEmpty != '')
						WeapAnim = WeaponAttachment.WA_BayonetProneReloadEmpty;
					else if (WeaponAttachment.WA_BayonetProneReload != '')
						WeapAnim = WeaponAttachment.WA_BayonetProneReload;
				}
				else
				{
					if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_BayonetReloadEmpty != '')
						WeapAnim = WeaponAttachment.WA_BayonetReloadEmpty;
					else if (WeaponAttachment.WA_BayonetReload != '')
						WeapAnim = WeaponAttachment.WA_BayonetReload;
				}
			}
			else
			{
				if( bIsCrawling )
				{
					if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_ProneReloadEmpty != '')
						WeapAnim = WeaponAttachment.WA_ProneReloadEmpty;
					else if (WeaponAttachment.WA_ProneReload != '')
						WeapAnim = WeaponAttachment.WA_ProneReload;
				}
				else
				{
					if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_ReloadEmpty != '')
						WeapAnim = WeaponAttachment.WA_ReloadEmpty;
					else
						WeapAnim = WeaponAttachment.WA_Reload;
				}
			}

			WeaponAttachment.LoopAnim(WeapAnim);
		}
		else if (WeaponState != GS_ReloadLooped && WeaponState != GS_GrenadeHoldBack && WeaponState != GS_FireLooped)
		{
			//Level.Game.Broadcast(self, "In the else in AnimEnd()");
			AnimBlendToAlpha(1, 0.0, 0.12);
		}
	}
	else if ( bKeepTaunting && (Channel == 0) )
		PlayVictoryAnimation();
}

//-----------------------------------------------------------------------------
// PlayHit - Redone again since butto hacked it up - Ramm
//-----------------------------------------------------------------------------
// MergeTODO: Work on the gore part of this to make it better
function PlayHit(float Damage, Pawn InstigatedBy, vector HitLocation, class<DamageType> damageType, vector Momentum, optional int HitIndex)
{
    local Vector HitNormal;
    local Name HitBone;
    local float HitBoneDist;
    local PlayerController PC;
	local bool bShowEffects, bRecentHit;
	local ProjectileBloodSplat BloodHit;
	local rotator SplatRot;

	bRecentHit = Level.TimeSeconds - LastPainTime < 0.2;

	// Call the modified version of the original Pawn playhit
	OldPlayHit(Damage,InstigatedBy,HitLocation,DamageType,Momentum);

	if ( Damage <= 0 )
		return;

    PC = PlayerController(Controller);
	bShowEffects = ( (Level.NetMode != NM_Standalone) || (Level.TimeSeconds - LastRenderTime < 2.5)
					|| ((InstigatedBy != None) && (PlayerController(InstigatedBy.Controller) != None))
					|| (PC != None) );
	if ( !bShowEffects )
		return;

    if( DamageType.default.bLocationalHit )
    {
        HitBone = GetHitBoneFromIndex(HitIndex);
        HitBoneDist = 0.0f;
    }
    else
    {
        HitLocation = Location;
        HitBone = 'None';
        HitBoneDist = 0.0f;
    }

    if( DamageType.default.bAlwaysSevers && DamageType.default.bSpecial )
        HitBone = 'head';

	if( InstigatedBy != None )
		HitNormal = Normal( Normal(InstigatedBy.Location-HitLocation) + VRand() * 0.2 + vect(0,0,2.8) );
	else
		HitNormal = Normal( Vect(0,0,1) + VRand() * 0.2 + vect(0,0,2.8) );

	if ( DamageType.Default.bCausesBlood && (!bRecentHit || (bRecentHit && (FRand() > 0.8))))
	{
		if ( !class'GameInfo'.static.NoBlood() ) //class'GameInfo'.static.UseLowGore()
		{
        	if ( Momentum != vect(0,0,0) )
				SplatRot = rotator(Normal(Momentum));
			else
			{
				if ( InstigatedBy != None )
					SplatRot = rotator(Normal(Location - InstigatedBy.Location));
				else
					SplatRot = rotator(Normal(Location - HitLocation));
			}

		 	BloodHit = Spawn(ProjectileBloodSplatClass,InstigatedBy,, HitLocation, SplatRot);
		}
	}

	DoDamageFX( HitBone, Damage, DamageType, Rotator(HitNormal) );

	if (DamageType.default.DamageOverlayMaterial != None && Damage > 0 ) // additional check in case shield absorbed
				SetOverlayMaterial( DamageType.default.DamageOverlayMaterial, DamageType.default.DamageOverlayTime, false );
}

// Modified version of the original Pawn playhit. Set up because we want our blood puffs to be directional based
// On the momentum of the bullet, not out from the center of the player
function OldPlayHit(float Damage, Pawn InstigatedBy, vector HitLocation, class<DamageType> damageType, vector Momentum, optional int HitIndex)
{
    local Vector HitNormal;
	local vector BloodOffset, Mo;
	local class<Effects> DesiredEffect;
	local class<Emitter> DesiredEmitter;
	local PlayerController Hearer;

	if ( DamageType == None )
		return;
	if ( (Damage <= 0) && ((Controller == None) || !Controller.bGodMode) )
		return;

	if (Damage > DamageType.Default.DamageThreshold) //spawn some blood
	{

		HitNormal = Normal(HitLocation - Location);

		// Play any set effect
		if ( EffectIsRelevant(Location,true) )
		{
			DesiredEffect = DamageType.static.GetPawnDamageEffect(HitLocation, Damage, Momentum, self, (Level.bDropDetail || Level.DetailMode == DM_Low));

			if ( DesiredEffect != None )
			{
				BloodOffset = 0.2 * CollisionRadius * HitNormal;
				BloodOffset.Z = BloodOffset.Z * 0.5;

				Mo = Momentum;
				if ( Mo.Z > 0 )
					Mo.Z *= 0.5;
				spawn(DesiredEffect,self,,HitLocation + BloodOffset, rotator(Mo));
			}

			// Spawn any preset emitter

			DesiredEmitter = DamageType.Static.GetPawnDamageEmitter(HitLocation, Damage, Momentum, self, (Level.bDropDetail || Level.DetailMode == DM_Low));
			if (DesiredEmitter != None)
			{
			    if( InstigatedBy != none )
			        HitNormal = Normal((InstigatedBy.Location+(vect(0,0,1)*InstigatedBy.EyeHeight))-HitLocation);

				spawn(DesiredEmitter,,,HitLocation+HitNormal, Rotator(HitNormal));
			}
		}
	}
	if ( Health <= 0 )
	{
		if ( PhysicsVolume.bDestructive && (PhysicsVolume.ExitActor != None) )
			Spawn(PhysicsVolume.ExitActor);
		return;
	}

	if ( Level.TimeSeconds - LastPainTime > 0.1 )
	{
		if ( InstigatedBy != None && (DamageType != None) && DamageType.default.bDirectDamage )
			Hearer = PlayerController(InstigatedBy.Controller);
		if ( Hearer != None )
			Hearer.bAcuteHearing = true;
		PlayTakeHit(HitLocation,Damage,damageType);
		if ( Hearer != None )
			Hearer.bAcuteHearing = false;
		LastPainTime = Level.TimeSeconds;
	}
}

// Returns the bone name for a given hitpoint index
simulated function name GetHitBoneFromIndex(int HitIndex)
{
	// Just return the spine if its out of bounds for the array
	if( HitIndex < 1 || HitIndex > 15 )
	{
		return 'Spine';
	}
	else
	{
		return HitPoints[HitIndex].PointBone;
	}
}

simulated function PlayDirectionalDeath(Vector HitLoc)
{
	local Vector X,Y,Z, Dir;

	GetAxes(Rotation, X,Y,Z);
	HitLoc.Z = Location.Z;

	// random
	if ( VSize(Velocity) < 10.0 && VSize(Location - HitLoc) < 1.0 )
	{
		Dir = VRand();
	}
	// velocity based
	else if ( VSize(Velocity) > 0.0 )
	{
		Dir = Normal(Velocity*Vect(1,1,0));
	}
	// hit location based
	else
	{
		Dir = -Normal(Location - HitLoc);
	}

	// MergeTODO: Need these missing anims
	if ( Dir Dot X > 0.7 || Dir == vect(0,0,0))
		PlayAnim('DeathB',, 0.2);
	else if ( Dir Dot X < -0.7 )
		 PlayAnim('DeathF',, 0.2);
	else if ( Dir Dot Y > 0 )
		PlayAnim('DeathL',, 0.2);
	else
		PlayAnim('DeathR',, 0.2);
}

// MergeTODO: This needs work, it really doesn't work properly for a prone player
simulated function PlayDirectionalHit(Vector HitLoc)
{
	local Vector X,Y,Z, Dir;
	local bool bLegHit;

	GetAxes(Rotation, X,Y,Z);

	bLegHit = Location.Z - HitLoc.Z < CollisionHeight * 0.7;

	HitLoc.Z = Location.Z;

	// random
	if ( VSize(Location - HitLoc) < 1.0 )
	{
		Dir = VRand();
	}
	// hit location based
	else
	{
		Dir = -Normal(Location - HitLoc);
	}

	if (bIsCrawling)
	{
		if (WeaponAttachment != None)
			PlayAnim(WeaponAttachment.PA_ProneHitAnim,, 0.1);
		else
			PlayAnim(ProneHitAnim,, 0.1);

		return;
	}
	else if (bIsCrouched)
	{
		if (bLegHit)
		{
			if (WeaponAttachment != None)
				PlayAnim(WeaponAttachment.PA_CrouchHitUpAnim,, 0.1);
			else
				PlayAnim(CrouchHitUpAnim,, 0.1);
		}
		else
		{
			if (WeaponAttachment != None)
				PlayAnim(WeaponAttachment.PA_CrouchHitDownAnim,, 0.1);
			else
				PlayAnim(CrouchHitDownAnim,, 0.1);
		}
	}

	if ( Dir Dot X > 0.7 || Dir == vect(0,0,0))
	{
		if (WeaponAttachment != None)
			PlayAnim(WeaponAttachment.PA_HitFAnim,, 0.1);
		else
			PlayAnim(HitFAnim,, 0.1);
	}
	else if ( Dir Dot X < -0.7 )
	{
		if (WeaponAttachment != None)
			PlayAnim(WeaponAttachment.PA_HitBAnim,, 0.1);
		else
			PlayAnim(HitBAnim,, 0.1);
	}
	else if ( Dir Dot Y > 0 )
	{
		if (bLegHit)
		{
			if (WeaponAttachment != None)
				PlayAnim(WeaponAttachment.PA_HitRLegAnim,, 0.1);
			else
				PlayAnim(HitRLegAnim,, 0.1);
		}
		else
		{
			if (WeaponAttachment != None)
				PlayAnim(WeaponAttachment.PA_HitRAnim,, 0.1);
			else
				PlayAnim(HitRAnim,, 0.1);
		}
	}
	else
	{
		if (bLegHit)
		{
			if (WeaponAttachment != None)
				PlayAnim(WeaponAttachment.PA_HitLLegAnim,, 0.1);
			else
				PlayAnim(HitLLegAnim,, 0.1);
		}
		else
		{
			if (WeaponAttachment != None)
				PlayAnim(WeaponAttachment.PA_HitLAnim,, 0.1);
			else
				PlayAnim(HitLAnim,, 0.1);
		}
	}
}

//=============================================================
// Weapons/Inventory
//=============================================================

// Overriden to set the weapon attachment to none when the weapon
// is thrown out. This will cause the correct animations to played
// by the physics system.
function DeleteInventory( inventory Item )
{
	super.DeleteInventory( Item );

	// Don't set the weaponattachment to none because we've already switched to another weapon
	if( WeaponAttachment != none && Item.AttachmentClass != WeaponAttachment.Class )
	{
		return;
	}

	if( Item.IsA('Weapon'))
	{
		SetAnimAction('TossedWeapon');
	}
}


//-----------------------------------------------------------------------------
// AddDefaultInventory - Add inventory based on role and weapons choices
//-----------------------------------------------------------------------------
// MergeTODO: This doesn't seem too bad, except we need to turn nades back on for bots at some point
function AddDefaultInventory()
{
	local int i;
	local string S;
	local ROPlayer P;
	local ROBot B;
	local RORoleInfo RI;

	if (Controller == None)
		return;

	P = ROPlayer(Controller);
	B = ROBot(Controller);

	if (IsLocallyControlled())
	{
		if (P != None)
		{
			S = P.GetPrimaryWeapon();

			if (S != "")
				CreateInventory(S);

			S = P.GetSecondaryWeapon();

			if (S != "")
				CreateInventory(S);

			S = P.GetGrenadeWeapon();

			if (S != "")
				CreateInventory(S);

			RI = P.GetRoleInfo();

			if (RI != None)
			{
				for (i = 0; i < RI.GivenItems.Length; i++)
					CreateInventory(RI.GivenItems[i]);
			}
		}
		else if (B != None)
		{
			S = B.GetPrimaryWeapon();

			if (S != "")
				CreateInventory(S);

			S = B.GetSecondaryWeapon();

			if (S != "")
				CreateInventory(S);

            // Not letting bots have nades till we get code in so bots can use them well - Ramm
/*			S = B.GetGrenadeWeapon();

			if (S != "")
				CreateInventory(S); */

			RI = B.GetRoleInfo();

			if (RI != None)
			{
				for (i = 0; i < RI.GivenItems.Length; i++)
					CreateInventory(RI.GivenItems[i]);
			}
		}

		Level.Game.AddGameSpecificInventory(self);
	}
	else
	{
		Level.Game.AddGameSpecificInventory(self);

		if (P != None)
		{
			RI = P.GetRoleInfo();

			if (RI != None)
			{
				for (i = RI.GivenItems.Length - 1; i >= 0; i--)
					CreateInventory(RI.GivenItems[i]);
			}

			S = P.GetGrenadeWeapon();

			if (S != "")
				CreateInventory(S);

			S = P.GetSecondaryWeapon();

			if (S != "")
				CreateInventory(S);

			S = P.GetPrimaryWeapon();

			if (S != "")
				CreateInventory(S);
		}
	}

    NetUpdateTime = Level.TimeSeconds - 1;

	// HACK FIXME
	if (Inventory != None)
		Inventory.OwnerEvent('LoadOut');

	if( Level.Netmode == NM_Standalone || Level.Netmode == NM_ListenServer && IsLocallyControlled())
	{
		bRecievedInitialLoadout = true;
		Controller.ClientSwitchToBestWeapon();
	}
}

// Hacked in so ammo supply volumes give explosive weapons as well
function bool ResupplyExplosiveWeapons()
{
	local int i;
	local string S;
	local ROPlayer P;
	local RORoleInfo RI;
	local bool bDidResupply;
	local class<Inventory> InventoryClass;

	if (Controller == None)
		return false;

	P = ROPlayer(Controller);

	// For now we don't give bots nades until they know how to use them
	if( P == none )
		return false;

	S = P.GetGrenadeWeapon();

	if( S != "" )
		InventoryClass = Level.Game.BaseMutator.GetInventoryClass(S);

	if( (InventoryClass!=None) && (FindInventoryType(InventoryClass)==None) )
	{
		CreateInventory(S);
		bDidResupply=true;
	}

	RI = P.GetRoleInfo();

	if (RI != None)
	{
		for (i = RI.GivenItems.Length - 1; i >= 0; i--)
		{
			InventoryClass = none;
			InventoryClass = Level.Game.BaseMutator.GetInventoryClass(RI.GivenItems[i]);

			if(	(InventoryClass!=None) && (FindInventoryType(InventoryClass)==None)  )
			{
				CreateInventory(RI.GivenItems[i]);
				bDidResupply=true;
			}
		}
	}

	return bDidResupply;
}

//-----------------------------------------------------------------------------
// CanSwitchWeapon
//-----------------------------------------------------------------------------
simulated function bool CanSwitchWeapon()
{
	if( IsInState('StartProning') || IsInState('EndProning') || IsInState('DiveToProne') )
		return false;

	if (bIsCrawling && Acceleration != vect(0,0,0))
		return false;

    // If the weapon is busy, don't allow a switch
	if (Weapon != None && !Weapon.WeaponCanSwitch())
		return false;

	return true;
}

//-----------------------------------------------------------------------------
// CanBusySwitchWeapon - The weapon can be switched even though the player
// or the weapon is busy (Needed for certain cases like nades - don't want to
// prevent someone from finishing throwing thier nade and cause them to
// explode :)
//-----------------------------------------------------------------------------
simulated function bool CanBusySwitchWeapon()
{
    // if the weapon is busy, don't allow a switch
	if (Weapon != None && !Weapon.WeaponCanBusySwitch())
		return false;

	return true;
}

// toss out a weapon
function TossWeapon(Vector TossVel)
{
	local Vector X,Y,Z;

	if( Weapon == none )
		return;

	// Undeploy the weapon if they are deployed
 	if( bBipodDeployed )
	 	SetBipodDeployed(false);

	Weapon.Velocity = TossVel;
	GetAxes(Rotation,X,Y,Z);
	Weapon.DropFrom(Location + 0.8 * CollisionRadius * X - 0.5 * CollisionRadius * Y);
}

//-----------------------------------------------------------------------------
// TossMGAmmo(RO) - toss out MG ammo all players carry
//-----------------------------------------------------------------------------
function TossMGAmmo( Pawn Gunner)
{
	local bool bResupplySuccessful;

	if( bUsedCarriedMGAmmo )
		return;

	if( ROWeapon(Gunner.Weapon) != none && ROWeapon(Gunner.Weapon).ResupplyAmmo())
	{
		bResupplySuccessful=true;
	}

	bUsedCarriedMGAmmo = bResupplySuccessful;
	if( bResupplySuccessful )
	{
		if( (ROTeamGame(Level.Game) != none) && (Controller != none)
			&& (Gunner.Controller != none) )
		{
		    // Send notification message to gunner & remove resupply request
		    if (ROPlayer(Gunner.Controller) != none)
		    {
		        ROPlayer(Gunner.Controller).ReceiveLocalizedMessage(
                    class'ROResupplyMessage', 1, Controller.PlayerReplicationInfo);
                if (ROGameReplicationInfo(ROTeamGame(Level.Game).GameReplicationInfo) != none)
                    ROGameReplicationInfo(ROTeamGame(Level.Game).GameReplicationInfo)
                        .RemoveMGResupplyRequestFor(Gunner.Controller.PlayerReplicationInfo);
            }

            // Send notification message to supplier
            if (PlayerController(Controller) != none)
            {
                PlayerController(Controller).ReceiveLocalizedMessage(
                    class'ROResupplyMessage', 0, Gunner.Controller.PlayerReplicationInfo);
		    }

		    // Score point
			ROTeamGame(Level.Game).ScoreMGResupply(Controller, Gunner.Controller);
		}

    	//PlayOwnedSound(sound'Inf_Weapons_Foley.ammogive', SLOT_Interact, 1.75,, 10);
	}
}

/* PrevWeapon()
- switch to previous inventory group weapon
*/
simulated function PrevWeapon()
{
    if ( Level.Pauser != None )
        return;

 	if( !bRecievedInitialLoadout )
 	{
 		return;
 	}

    if ( Weapon == None && Controller != None )
    {
        Controller.SwitchToBestWeapon();
        return;
    }
    if ( PendingWeapon != None )
    {
        if ( PendingWeapon.bForceSwitch )
            return;
        PendingWeapon = Inventory.PrevWeapon(None, PendingWeapon);
    }
    else
        PendingWeapon = Inventory.PrevWeapon(None, Weapon);

    if ( (PendingWeapon != none) && (PendingWeapon != Weapon) )
        Weapon.PutDown();
}

/* NextWeapon()
- switch to next inventory group weapon
*/
simulated function NextWeapon()
{
    if ( Level.Pauser != None )
        return;

 	if( !bRecievedInitialLoadout )
 	{
 		return;
 	}

    if ( Weapon == None && Controller != None )
    {
        Controller.SwitchToBestWeapon();
        return;
    }
    if ( PendingWeapon != None )
    {
		if ( PendingWeapon.bForceSwitch )
            return;
        PendingWeapon = Inventory.NextWeapon(None, PendingWeapon);
    }
    else
    {
	    PendingWeapon = Inventory.NextWeapon(None, Weapon);
    }

    if ( (PendingWeapon != none) && (PendingWeapon != Weapon) )
        Weapon.PutDown();
}

// The player wants to switch to weapon group number F. Overriden to fix "no weapon" issues when switching weapons right after spawning
simulated function SwitchWeapon(byte F)
{
    local weapon newWeapon;

 	if( !bRecievedInitialLoadout )
 	{
 		return;
 	}

    if ( (Level.Pauser!=None) || (Inventory == None) )
        return;
    if ( (Weapon != None) && (Weapon.Inventory != None) )
        newWeapon = Weapon.Inventory.WeaponChange(F, false);
    else
        newWeapon = None;
    if ( newWeapon == None )
        newWeapon = Inventory.WeaponChange(F, true);

    if ( newWeapon == None )
	{
		if ( F == 10 )
			ServerNoTranslocator();

		return;
	}

    if ( PendingWeapon != None && PendingWeapon.bForceSwitch )
        return;

    if ( Weapon == None )
    {
        PendingWeapon = newWeapon;
        ChangedWeapon();
    }
    else if ( Weapon != newWeapon || PendingWeapon != None )
    {
        PendingWeapon = newWeapon;
        Weapon.PutDown();
    }
    else if ( Weapon == newWeapon )
        Weapon.Reselect(); // sjs
}

//-----------------------------------------------------------------------------
// GetWeaponBoneFor - Determines proper bone for inventory
//-----------------------------------------------------------------------------
// MergeTODO: These are going to change. Also, rather than hard coding it maybe a variable would be better
function name GetWeaponBoneFor(Inventory I)
{
    if (I.IsA('ROGrenadeWeapon') || I.IsA('ROPistolWeapon') || I.IsA('ROSatchelChargeWeapon'))
		return 'weapon_rhand';//'righthand';
	else if (I.IsA('Weapon'))
		return 'weapon_rhand';//'FlagHand';
}

// Same as GetWeaponBoneFor, but statically and works on a class<Inventory> instead of instance
// Used by ROGUISelection to get weapon attachment bone
static function name StaticGetWeaponBoneFor(class<Inventory> I)
{
    // Not sure how to implement this, but seems righthand is what's always being used :)
    return 'weapon_rhand';
}

//-----------------------------------------------------------------------------
// StartFiring
//-----------------------------------------------------------------------------

simulated function StartFiring(bool bAltFire, bool bRapid)
{
	local name FireAnim;
	local bool bIsMoving;

	if (Physics == PHYS_Swimming || WeaponAttachment == None)
		return;

	bIsMoving = VSizeSquared(Velocity) > 25;

	if (bAltFire)
	{
		if (WeaponAttachment.bBayonetAttached)
		{
			if (bIsCrawling)
				FireAnim = WeaponAttachment.PA_ProneBayonetAltFire;
			else if (bIsCrouched)
				FireAnim = WeaponAttachment.PA_CrouchBayonetAltFire;
			else
				FireAnim = WeaponAttachment.PA_BayonetAltFire;
		}
		else
		{
			if (bIsCrawling)
				FireAnim = WeaponAttachment.PA_ProneAltFire;
			else if (bIsCrouched)
				FireAnim = WeaponAttachment.PA_CrouchAltFire;
			else if( bBipodDeployed )
				FireAnim = WeaponAttachment.PA_DeployedAltFire;
			else
				FireAnim = WeaponAttachment.PA_AltFire;
		}
	}
	// regular fire
	else
	{
		if( bBipodDeployed )
		{
			if (bIsCrouched)
			{
				FireAnim = WeaponAttachment.PA_CrouchDeployedFire;
			}
			else if ( bIsCrawling )
			{
			    FireAnim = WeaponAttachment.PA_ProneDeployedFire;
			}
			else
			{
				FireAnim = WeaponAttachment.PA_DeployedFire;
			}
		}
		else if (bIsCrawling)
			FireAnim = WeaponAttachment.PA_ProneFire;
		else if (bIsCrouched)
		{
			if( bIsMoving )
			{
				FireAnim = WeaponAttachment.PA_MoveCrouchFire[Get8WayDirection()];
			}
			else
			{
			 	if (bIronSights)
			 	{
				 	FireAnim = WeaponAttachment.PA_CrouchIronFire;
				}
				else
				{
				 	FireAnim = WeaponAttachment.PA_CrouchFire;
				}
			}
		}
		else if (bIronSights)
		{
			if( bIsMoving )
			{
				FireAnim = WeaponAttachment.PA_MoveStandIronFire[Get8WayDirection()];
			}
			else
			{
			 	FireAnim = WeaponAttachment.PA_IronFire;
			}
		}
		else
		{
			if( bIsMoving )
			{
				if(bIsWalking)
				{
					FireAnim = WeaponAttachment.PA_MoveWalkFire[Get8WayDirection()];
				}
				else
				{
				 	FireAnim = WeaponAttachment.PA_MoveStandFire[Get8WayDirection()];
				}
			}
			else
			{
			 	FireAnim = WeaponAttachment.PA_Fire;
			}
		}
	}

	// blend the fire animation a bit so the standard player movement animations still play
	AnimBlendParams(1, 0.25, 0.0, 0.2, FireRootBone);

	if (bRapid)
	{
		if (WeaponState != GS_FireLooped)
		{
			LoopAnim(FireAnim,, 0.0, 1);
			WeaponState = GS_FireLooped;

			if (!bAltFire)
			{
				if (WeaponAttachment.bBayonetAttached)
					WeaponAttachment.LoopAnim(WeaponAttachment.WA_BayonetFire);
				else
					WeaponAttachment.LoopAnim(WeaponAttachment.WA_Fire);
			}
		}
	}
	else
	{
		PlayAnim(FireAnim,, 0.0, 1);
		WeaponState = GS_FireSingle;

		if (!bAltFire)
		{
			if (WeaponAttachment.bBayonetAttached)
				WeaponAttachment.PlayAnim(WeaponAttachment.WA_BayonetFire);
			else
				WeaponAttachment.PlayAnim(WeaponAttachment.WA_Fire);
		}
	}

	IdleTime = Level.TimeSeconds;
}

//-----------------------------------------------------------------------------
// StopFiring
//-----------------------------------------------------------------------------

simulated function StopFiring()
{
	if (WeaponState == GS_FireLooped)
	{
		WeaponState = GS_FireSingle;
	}

	IdleTime = Level.TimeSeconds;
}

// Called on the server. Sends a message to the client to let them know to play a the reload
function HandleStandardReload()
{
	local name PlayerAnim;
	local bool bEmpty;

	// Set the anim blend time so the server will make this player relevant for third person reload sounds to be heard
	if( Level.NetMode != NM_StandAlone )
	{
		if (WeaponAttachment != None)
		{
	     	bEmpty = WeaponAttachment.bOutOfAmmo;

			if (bEmpty)
			{
				if (bIsCrawling)
					PlayerAnim = WeaponAttachment.PA_ProneReloadEmptyAnim;
				else
					PlayerAnim = WeaponAttachment.PA_ReloadEmptyAnim;
			}
			else
			{
				if (bIsCrawling)
					PlayerAnim = WeaponAttachment.PA_ProneReloadAnim;
				else
					PlayerAnim = WeaponAttachment.PA_ReloadAnim;
			}

			AnimBlendTime = GetAnimDuration(PlayerAnim, 1.0)+0.1;
		}
	}

	SetAnimAction('DoStandardReload');
}

// Called on the server. Sends a message to the client to let them know to start a looping reload
function StartReload()
{
	SetAnimAction('DoLoopingReload');
}

// Called on the server. Sends a message to the client to let them know to play a the reload
function StopReload()
{
	SetAnimAction('DoReloadEnd');
}

// Play a standard reload on the client
simulated function PlayStandardReload()
{
	local name PlayerAnim;
	local name WeaponAnim;
	local bool bEmpty;

	if (WeaponAttachment != None)
	{
     	bEmpty = WeaponAttachment.bOutOfAmmo;

		if (bEmpty)
		{
			if (bIsCrawling)
				PlayerAnim = WeaponAttachment.PA_ProneReloadEmptyAnim;
			else
				PlayerAnim = WeaponAttachment.PA_ReloadEmptyAnim;
		}
		else
		{
			if (bIsCrawling)
				PlayerAnim = WeaponAttachment.PA_ProneReloadAnim;
			else
				PlayerAnim = WeaponAttachment.PA_ReloadAnim;
		}



		if (WeaponAttachment.bBayonetAttached)
		{
			if( bIsCrawling )
			{
				if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_BayonetProneReloadEmpty != '')
					WeaponAnim = WeaponAttachment.WA_BayonetProneReloadEmpty;
				else if (WeaponAttachment.WA_BayonetProneReload != '')
					WeaponAnim = WeaponAttachment.WA_BayonetProneReload;
			}
			else
			{
				if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_BayonetReloadEmpty != '')
					WeaponAnim = WeaponAttachment.WA_BayonetReloadEmpty;
				else if (WeaponAttachment.WA_BayonetReload != '')
					WeaponAnim = WeaponAttachment.WA_BayonetReload;
			}
		}
		else
		{
			if( bIsCrawling )
			{
				if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_ProneReloadEmpty != '')
					WeaponAnim = WeaponAttachment.WA_ProneReloadEmpty;
				else if (WeaponAttachment.WA_ProneReload != '')
					WeaponAnim = WeaponAttachment.WA_ProneReload;
			}
			else
			{
				if (WeaponAttachment.bOutOfAmmo && WeaponAttachment.WA_ReloadEmpty != '')
					WeaponAnim = WeaponAttachment.WA_ReloadEmpty;
				else
					WeaponAnim = WeaponAttachment.WA_Reload;
			}
		}

        if( bIsCrawling )
		{
	        AnimBlendParams(1,1.0 , 0.0, 0.2, FireRootBone);
        }
        else
        {
			AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
	        AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);
        }
		PlayAnim(PlayerAnim,, 0.1, 1);
		WeaponAttachment.PlayAnim(WeaponAnim,, 0.1);

		AnimBlendTime = GetAnimDuration(PlayerAnim, 1.0)+0.1;

		WeaponState = GS_ReloadSingle;
	}
}


//-----------------------------------------------------------------------------
// StartReloading - Play reloading anims
//-----------------------------------------------------------------------------

simulated function PlayStartReloading()
{
	if (WeaponAttachment != None)
	{
		// Play the pre-reload anim and then return if looping
        AnimBlendParams(1,1.0 , 0.0, 0.2, SpineBone1);
        AnimBlendParams(1,1.0, 0.0, 0.2, SpineBone2);

		if (bIsCrawling)
			PlayAnim(WeaponAttachment.PA_PronePreReloadAnim,, 0.1, 1);
		else
			PlayAnim(WeaponAttachment.PA_PreReloadAnim,, 0.1, 1);

		if (WeaponAttachment.bBayonetAttached && WeaponAttachment.WA_BayonetPreReload != '')
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_BayonetPreReload,, 0.1);
		else if (WeaponAttachment.WA_PreReload != '')
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_PreReload,, 0.1);

		WeaponState = GS_PreReload;
	}
}

//-----------------------------------------------------------------------------
// StopReloading - Stop reloading anims if looping
//-----------------------------------------------------------------------------

simulated function PlayStopReloading()
{
	if ((WeaponState == GS_ReloadLooped || WeaponState == GS_PreReload) && WeaponAttachment != None)
	{
		AnimBlendParams(1, 1.0, 0.0, 0.2, FireRootBone);

		if (bIsCrawling)
			PlayAnim(WeaponAttachment.PA_PronePostReloadAnim,, 0.1, 1);
		else
			PlayAnim(WeaponAttachment.PA_PostReloadAnim,, 0.1, 1);

		if (WeaponAttachment.bBayonetAttached && WeaponAttachment.WA_BayonetPostReload != '')
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_BayonetPostReload,, 0.1);
		else if (WeaponAttachment.WA_PostReload != '')
			WeaponAttachment.PlayAnim(WeaponAttachment.WA_PostReload,, 0.1);

		WeaponState = GS_ReloadSingle;
	}

	IdleTime = Level.TimeSeconds;
}

//=============================================================
// Movement
//=============================================================

//-----------------------------------------------------------------------------
// StartSprint
//-----------------------------------------------------------------------------

function StartSprint()
{
	if (ROWeapon(Weapon) != None)
		ROWeapon(Weapon).SetSprinting(true);
}

//-----------------------------------------------------------------------------
// EndSprint
//-----------------------------------------------------------------------------

function EndSprint()
{
	if (ROWeapon(Weapon) != None)
		ROWeapon(Weapon).SetSprinting(false);
}

//-----------------------------------------------------------------------------
// BaseChange - Took out pawn damage, and added momentum from vehicle
//-----------------------------------------------------------------------------
singular event BaseChange()
{
	local float decorMass;

	if ( bInterpolating )
		return;

	// If someone jumps off a moving vehicle, give them the vehicles momentum
	if ( base == none && Vehicle(SavedBase) != none && (VSize(Vehicle(SavedBase).Velocity) > 25))
	{
		Velocity += Vehicle(SavedBase).Velocity;
		Velocity.Z += 5;
	}
	SavedBase = base;

	if ( (base == None) && (Physics == PHYS_None) )
		SetPhysics(PHYS_Falling);
	// Pawns can only set base to non-pawns, or pawns which specifically allow it.
	// Otherwise jump off.
     else if ( Pawn(Base) != None )
	{
		if ( !Pawn(Base).bCanBeBaseForPawns && ROPawn(Base) == none || ROPawn(Base) != none && VSize(Base.Velocity) > 1)
		{
			JumpOffPawn();
		}
	}
	else if ( (Decoration(Base) != None) && (Velocity.Z < -400) )
	{
		decorMass = FMax(Decoration(Base).Mass, 1);
		Base.TakeDamage((-2* Mass/decorMass * Velocity.Z/400), Self, Location, 0.5 * Velocity, class'Crushed');
	}
}

// Don't telefrag players when they are near someone going to/from prone or crouch
event EncroachedBy(Actor Other)
{
	// Allow encroachment by Vehicles so they can push the pawn out of the way
	if ( ROPawn(Other) == None && Pawn(Other) != None && Vehicle(Other) == None)
		gibbedBy(Other);
}

// LimitYaw - limits player's yaw or turning amount
function LimitYaw(out int yaw)
{
	local	int MaxBipodYaw;
	local	int MinBipodYaw;

	if( bBipodDeployed )
	{
    	MaxBipodYaw = InitialDeployedRotation.Yaw + DeployedPositiveYawLimit;
    	MinBipodYaw = InitialDeployedRotation.Yaw + DeployedNegativeYawLimit;

    	if( yaw > MaxBipodYaw )
    	{
    		yaw = MaxBipodYaw;
    		return;
    	}
    	else if( yaw < MinBipodYaw )
    	{
    		yaw = MinBipodYaw;
    		return;
    	}
	}
}

 /*
 	 PitchUpLimit=18000
	 PitchDownLimit=49153
 */
function int LimitPitch(int pitch, optional float DeltaTime)
{
	local	int MaxBipodPitch;
	local	int MinBipodPitch;

    pitch = pitch & 65535;

	if( bBipodDeployed )
	{

    	MaxBipodPitch = InitialDeployedRotation.Pitch + DeployedPitchUpLimit;
		MinBipodPitch = InitialDeployedRotation.Pitch + DeployedPitchDownLimit;

		if( MaxBipodPitch > 65535 )
			MaxBipodPitch -= 65535;

		if( MinBipodPitch < 0 )
			MinBipodPitch += 65535;

		if( (MaxBipodPitch > PitchUpLimit) && (MaxBipodPitch < PitchDownLimit) )
			MaxBipodPitch = PitchUpLimit;

		if( (MinBipodPitch < PitchDownLimit) && (MinBipodPitch > PitchUpLimit) )
			MinBipodPitch = PitchDownLimit;

		// handles areas where newPitchUpLimit is less than newPitchDownLimit
    	if( (pitch > MaxBipodPitch) && (pitch < MinBipodPitch) )
    	{
        	if( (pitch - MaxBipodPitch) < (MinBipodPitch - pitch) )
            	pitch = MaxBipodPitch;
        	else
            	pitch = MinBipodPitch;
    	}
    	// following 2 if's handle when newPitchUpLimit is greater than newPitchDownLimit
    	else if( (pitch > MaxBipodPitch) && (MaxBipodPitch > MinBipodPitch) )
    	{
			pitch = MaxBipodPitch;
    	}
    	else if( (pitch < MinBipodPitch) && (MaxBipodPitch > MinBipodPitch) )
    	{
    		pitch = MinBipodPitch;
    	}
	}
	else
	{
		if( bIsCrawling )
		{
			// Smoothly rotate the player to the pitch limit when you start crawling.
			// This prevents the jarring "pop" when the pitch limit kicks in to
			// prevent you from looking through your arms
			if( Weapon != none && Weapon.IsCrawling() )
			{
				if (pitch > CrawlingPitchUpLimit && pitch < CrawlingPitchDownLimit)
		    	{
		        	if (pitch - CrawlingPitchUpLimit < CrawlingPitchDownLimit - pitch)
		        	{
						if( Level.TimeSeconds - Weapon.LastStartCrawlingTime < 0.15 )
						{
							pitch -= CrawlPitchTweenRate * deltatime;
						}
						else
						{
							pitch = CrawlingPitchUpLimit;
						}
		            }
		        	else
		        	{
						if( Level.TimeSeconds - Weapon.LastStartCrawlingTime < 0.15 )
						{
							pitch += CrawlPitchTweenRate * deltatime;
						}
						else
						{
							pitch = CrawlingPitchDownLimit;
						}
		            }
		    	}
			}
			else
			{
				if (pitch > PronePitchUpLimit && pitch < PronePitchDownLimit)
		    	{
		        	if (pitch - PronePitchUpLimit < PronePitchDownLimit - pitch)
		            	pitch = PronePitchUpLimit;
		        	else
		            	pitch = PronePitchDownLimit;
		    	}
	    	}
		}
        else if (pitch > PitchUpLimit && pitch < PitchDownLimit)
    	{
        	if (pitch - PitchUpLimit < PitchDownLimit - pitch)
            	pitch = PitchUpLimit;
        	else
            	pitch = PitchDownLimit;
    	}
    }

    return pitch;
}

simulated function vector EyePosition()
{
	local vector res, x, y, z;
	local float Lean;
	local actor HitActor;
	local vector HitLocation, HitNormal, TraceStart, TraceEnd;

	GetAxes(Rotation, x, y, z);

	if (IsInState('StartProning') || IsInState('EndProning'))
	{
		TraceStart = Location + ((GetBoneCoords(CameraBone).Origin - Location) * vect(0,0,1));
		TraceEnd = GetBoneCoords(CameraBone).Origin;
		HitActor = Trace( HitLocation, HitNormal, TraceEnd, TraceStart, true, vect(10,10,10));

		if( HitActor != none )
		{
			res = (HitLocation - Location) + WalkBob;
		}
		else
		{
        	res = (GetBoneCoords(CameraBone).Origin - Location) + WalkBob;
        }
	}
	else if ( bIsCrawling && !IsInState('DivingToProne'))
		res = EyeHeight * vect(0,0,1) + WalkBob + ((( Location + ProneEyeDist * Normal(x) ) - Location) * vect(1,1,0)) ;
    else
		res = EyeHeight * vect(0,0,1) + WalkBob;

   	if( LeanAmount != 0 )
   	{
   	 	Lean = Abs(LeanAmount / LeanMax);

   		if( bIsCrawling )
   		{
   			if( LeanAmount < 0 )
   				res += Lean * (X * LeanLProneViewOffset.X + Y * LeanLProneViewOffset.Y +  Z * LeanLProneViewOffset.Z);
   			else
   				res += Lean * (X * LeanRProneViewOffset.X + Y * LeanRProneViewOffset.Y +  Z * LeanRProneViewOffset.Z);
   		}
   		else if( bIsCrouched )
   		{
   			if( LeanAmount < 0 )
   				res += Lean * (X * LeanLCrouchViewOffset.X + Y * LeanLCrouchViewOffset.Y +  Z * LeanLCrouchViewOffset.Z);
   			else
   				res += Lean * (X * LeanRCrouchViewOffset.X + Y * LeanRCrouchViewOffset.Y +  Z * LeanRCrouchViewOffset.Z);
   		}
   		else
   		{
   			if( LeanAmount < 0 )
   				res += Lean * (X * LeanLViewOffset.X + Y * LeanLViewOffset.Y +  Z * LeanLViewOffset.Z);
   			else
   				res += Lean * (X * LeanRViewOffset.X + Y * LeanRViewOffset.Y +  Z * LeanRViewOffset.Z);
   		}
   	}

	return res;
}

//-----------------------------------------------------------------------------
// Landed - Added land sound and prevented anim for prone landing
//-----------------------------------------------------------------------------
event Landed(vector HitNormal)
{
	ImpactVelocity = vect(0,0,0);
	TakeFallingDamage();
	if ( Health > 0 && !bIsCrawling)
		PlayLanded(Velocity.Z);
	if ( (Velocity.Z < -200) && (PlayerController(Controller) != None) )
		bJustLanded = PlayerController(Controller).bLandingShake;
	LastHitBy = None;

	if (Health > 0)
	{
		if( bIsCrawling )
		    PlayOwnedSound(GetSound(EST_DiveLand), SLOT_Interact, FMin(2,Abs(Velocity.Z)/MaxFallSpeed),, 10);
        else
            PlayOwnedSound(GetSound(EST_Land), SLOT_Interact, FMin(1,-0.3 * Velocity.Z/JumpZ),, 10);
	}
}

//-----------------------------------------------------------------------------
// TakeFallingDamage - Increased damage once over safe fall threshold
//-----------------------------------------------------------------------------
// MergeTODO: Players complain that the fall distance is too short before getting hurt. Investigate
function TakeFallingDamage()
{
	local float Shake, EffectiveSpeed;

	if (Velocity.Z < -0.5 * MaxFallSpeed)
	{
		if ( Role == ROLE_Authority )
		{
		    MakeNoise(1.0);
		    if (Velocity.Z < -1 * MaxFallSpeed)
		    {
				EffectiveSpeed = Velocity.Z;
				if ( TouchingWaterVolume() )
					EffectiveSpeed = FMin(0, EffectiveSpeed + 100);
				if ( EffectiveSpeed < -1 * MaxFallSpeed )
				{
					TakeDamage(-100 * (1.5 * EffectiveSpeed + MaxFallSpeed)/MaxFallSpeed, None, Location, vect(0,0,0), class'Fell');
					// Damaged the legs
					UpdateDamageList(254);

				}
		    }
		}
		if ( Controller != None )
		{
			Shake = FMin(1, -1 * Velocity.Z/MaxFallSpeed);
            Controller.DamageShake(Shake);
		}
	}
	else if (Velocity.Z < -1.4 * JumpZ)
		MakeNoise(0.5);
}

//-----------------------------------------------------------------------------
// FootStepping - overriden to support custom footstep volumes
//-----------------------------------------------------------------------------
simulated function FootStepping(int Side)
{
    local int SurfaceTypeID, i;
	local actor A;
	local material FloorMat;
	local vector HL,HN,Start,End,HitLocation,HitNormal;
	local float FootVolumeMod;

    SurfaceTypeID = 0;
    FootVolumeMod = 1.0;

    for ( i=0; i<Touching.Length; i++ )
		if ( ((PhysicsVolume(Touching[i]) != None) && PhysicsVolume(Touching[i]).bWaterVolume)
			|| (FluidSurfaceInfo(Touching[i]) != None) )
		{
			//PlaySound(sound'Inf_Player.FootStepWaterDeep', SLOT_Interact, FootstepVolume * 2,, FootStepSoundRadius);

			// Play a water ring effect as you walk through the water
 			if ( !Level.bDropDetail && (Level.DetailMode != DM_Low) && (Level.NetMode != NM_DedicatedServer)
				&& !Touching[i].TraceThisActor(HitLocation, HitNormal,Location - CollisionHeight*vect(0,0,1.1), Location) )
			{
					Spawn(class'WaterRingEmitter',,,HitLocation,rot(16384,0,0));
			}

			return;
		}

	// Lets still play the sounds when walking slow, just play them quieter
	if ( bIsCrawling )
	{
		return;
	}
	else if ( bIsCrouched || bIsWalking )
	{
        FootVolumeMod = QuietFootStepVolume;
	}

	if ( (Base!=None) && (!Base.IsA('LevelInfo')) && (Base.SurfaceType!=0) )
	{
		SurfaceTypeID = Base.SurfaceType;
	}
	else
	{
		Start = Location - Vect(0,0,1)*CollisionHeight;
		End = Start - Vect(0,0,16);
		A = Trace(hl,hn,End,Start,false,,FloorMat);
		if (FloorMat !=None)
			SurfaceTypeID = FloorMat.SurfaceType;
	}
	//PlaySound(SoundFootsteps[SurfaceTypeID], SLOT_Interact, (FootstepVolume * FootVolumeMod),,(FootStepSoundRadius * FootVolumeMod));
}

// Returns true if you can jump in this movement state
simulated function bool CanJump()
{
	if( Weapon != none && Weapon.IsMounted() )
		return false;

	if ( bIsLimping || bIsCrouched || bWantsToCrouch || bIsCrawling || bWantsToProne )
		return false;

	return true;
}

//-----------------------------------------------------------------------------
// DoJump - overriden to support a wait time between jumps
//-----------------------------------------------------------------------------
function bool DoJump( bool bUpdating )
{
	// No jumping if stamina is too low
	if ((Stamina < JumpStaminaDrain) || (Level.TimeSeconds < NextJumpTime) )
	{
		if(CanJump() && !bUpdating)
		{
			PlayOwnedSound(GetSound(EST_TiredJump), SLOT_Pain, GruntVolume,,80);
		}
		return false;
	}

	if ( CanJump() && ((Physics == PHYS_Walking) || (Physics == PHYS_Ladder) || (Physics == PHYS_Spider)))
	{
		// Take stamina away with each jump
		Stamina = FMax(Stamina - JumpStaminaDrain, 0.0);

		if ( Role == ROLE_Authority )
		{
			if ( (Level.Game != None) && (Level.Game.GameDifficulty > 2) )
				MakeNoise(0.1 * Level.Game.GameDifficulty);
			if ( bCountJumps && (Inventory != None) )
				Inventory.OwnerEvent('Jumped');
		}

		// For playing jumping anims, etc
		if( Weapon != none )
		{
			Weapon.NotifyOwnerJumped();
		}

		if (!bUpdating)
			PlayOwnedSound(GetSound(EST_Jump), SLOT_Pain, GruntVolume,,80);

		NextJumpTime = Level.TimeSeconds + 2.0;

		if ( Physics == PHYS_Spider )
			Velocity = JumpZ * Floor;
		else if ( Physics == PHYS_Ladder )
			Velocity.Z = 0;
		else if ( bIsWalking )
			Velocity.Z = Default.JumpZ;
		else
			Velocity.Z = JumpZ;
		if ( (Base != None) && !Base.bWorldGeometry )
			Velocity.Z += Base.Velocity.Z;
		SetPhysics(PHYS_Falling);

		return true;
	}

	return false;
}

//-----------------------------------------------------------------------------
// Proning functions
//-----------------------------------------------------------------------------

// Returns true if the player can switch the prone state. Only valid on the client
simulated function bool CanProneTransition()
{
	if( Physics == PHYS_Walking && (Weapon == none || Weapon.WeaponAllowProneChange()) )
	{
		return true;
	}

	return false;
}

// Returns true if the player can switch the crouch state.
simulated function bool CanCrouchTransition()
{
	if( IsTransitioningToProne() )
	{
		return false;
	}

	if( Weapon == none || Weapon.WeaponAllowCrouchChange() )
	{
		return true;
	}

	return false;
}

// Stub events called when physics actually allows prone to begin or end
// use these for changing the animation (if script controlled)
event EndProne(float HeightAdjust)
{
	// Take the weapon out of iron sights
	// TODO: Give this its own notify, instead of piggybacking the notify owner jumped one
	if( Weapon != none )
	{
		Weapon.NotifyOwnerJumped();
	}

  	SetAnimAction('EndCrawling');

	if( bBipodDeployed && ROBipodWeapon(Weapon) != none )
	{
		ROBipodWeapon(Weapon).ForceUndeploy();
	}

	EyeHeight -= HeightAdjust;
	OldZ += HeightAdjust;
	BaseEyeHeight = Default.BaseEyeHeight;
}

event StartProne(float HeightAdjust)
{
	SetWalking(false);
	ShouldCrouch(false);

	if( bBipodDeployed && ROBipodWeapon(Weapon) != none )
	{
		ROBipodWeapon(Weapon).ForceUndeploy();
	}

	if ( ROPlayer(Controller) != none)
	{
		ROPlayer(Controller).ResetSwayValues();
	}

	// Take the weapon out of iron sights
	// TODO: Give this its own notify, instead of piggybacking the notify owner jumped one
	if( Weapon != none )
	{
		Weapon.NotifyOwnerJumped();
	}

  	SetAnimAction('StartCrawling');

	EyeHeight += HeightAdjust;
	OldZ -= HeightAdjust;
	BaseEyeHeight = ProneEyeHeight;
}

event CrouchToProne(float HeightAdjust)
{
	SetWalking(false);
	ShouldCrouch(false);

	if( bBipodDeployed && ROBipodWeapon(Weapon) != none )
	{
		ROBipodWeapon(Weapon).ForceUndeploy();
	}

	if ( ROPlayer(Controller) != none)
	{
		ROPlayer(Controller).ResetSwayValues();
	}

	// Take the weapon out of iron sights
	// TODO: Give this its own notify, instead of piggybacking the notify owner jumped one
	if( Weapon != none )
	{
		Weapon.NotifyOwnerJumped();
	}

	// Send the weapon to the crawling state if we are moving
	if( Weapon!= none && VSizeSquared(Velocity) > 1.0 )
	{
		Weapon.NotifyCrawlMoving();
	}

    SetAnimAction('CrouchToProne');

	EyeHeight += HeightAdjust;
	OldZ -= HeightAdjust;
	BaseEyeHeight = ProneEyeHeight;
}

event ProneToCrouch(float HeightAdjust)
{
	EyeHeight += HeightAdjust;
	OldZ -= HeightAdjust;

	ShouldProne(false);

	if( bBipodDeployed && ROBipodWeapon(Weapon) != none )
	{
		ROBipodWeapon(Weapon).ForceUndeploy();
	}

	// Take the weapon out of iron sights
	// TODO: Give this its own notify, instead of piggybacking the notify owner jumped one
	if( Weapon != none )
	{
		Weapon.NotifyOwnerJumped();
	}

    SetAnimAction('ProneToCrouch');

    if( VSizeSquared(Velocity) > 25 )
    {
    	BaseEyeHeight = CrouchMoveEyeHeightMod * CrouchHeight;
    }
    else
    {
    	BaseEyeHeight = CrouchEyeHeightMod * CrouchHeight;
    }
}

event StartProneDive(float HeightAdjust)
{
	SetWalking(false);
	ShouldCrouch(false);

  	SetAnimAction('DiveToProne');

	EyeHeight += HeightAdjust;
	OldZ -= HeightAdjust;
	BaseEyeHeight = ProneEyeHeight;
}

// Player is prone
simulated state Crawling
{
	simulated function BeginState()
	{
		if( !bBipodDeployed && ROBipodWeapon(Weapon) != none && Weapon.bUsingSights )
		{
			Weapon.NotifyOwnerJumped();
		}

		SetSprinting(false);
	}

	simulated function EndState()
	{
		if ( Weapon != none )
			Weapon.NotifyStopCrawlMoving();
	}
}

simulated state ProningFromCrouch
{
	simulated function bool CanProneTransition(){return false;}
    simulated event bool IsTransitioningToProne(){return true;}
	simulated event bool IsProneTransitioning(){return true;}

    simulated function Timer()
	{
		GotoState('Crawling');
	}

	simulated function BeginState()
	{
		AnimBlendTimer();

		// Cancel any anims playing on the weapon since we do the same for the player
		if( WeaponAttachment != none )
			WeaponAttachment.PlayIdle();

		PlayProningFromCrouch();

		if( Weapon!= none && VSizeSquared(Velocity) > 1.0 )
		{
			Weapon.NotifyCrawlMoving();
		}

	}
}

simulated state CrouchingFromProne
{
	simulated event bool IsProneTransitioning(){return true;}

    simulated function Timer()
	{
		GotoState('');
	}

	simulated function BeginState()
	{
		AnimBlendTimer();

		// Cancel any anims playing on the weapon since we do the same for the player
		if( WeaponAttachment != none )
			WeaponAttachment.PlayIdle();

		PlayCrouchingFromProne();
	}
}

simulated state StartProning
{
	simulated function bool CanProneTransition(){return false;}
    simulated event bool IsTransitioningToProne(){return true;}
	simulated event bool IsProneTransitioning(){return true;}

    simulated function Timer()
	{
		GotoState('Crawling');
	}

	simulated function BeginState()
	{
		if( Weapon!= none && VSizeSquared(Velocity) > 1.0 )
			Weapon.NotifyCrawlMoving();

		AnimBlendTimer();

		// Cancel any anims playing on the weapon since we do the same for the player
		if( WeaponAttachment != none )
			WeaponAttachment.PlayIdle();

		PlayStartCrawling();
	}
}

simulated state EndProning
{
	simulated function bool CanProneTransition(){return false;}
	simulated event bool IsProneTransitioning(){return true;}

    simulated function Timer()
	{
		GotoState('');
	}

	simulated function BeginState()
	{
		AnimBlendTimer();

		// Cancel any anims playing on the weapon since we do the same for the player
		if( WeaponAttachment != none )
			WeaponAttachment.PlayIdle();

		PlayEndCrawling();
	}
}

// This is a little tricky. Animend isn't reliable enough to count on
// serverside to change the pre-pivot value so we use a timer. But
// The timer causes the anim to pop client side so we have to
// use animend client side to switch the pre-pivot value.
simulated state DivingToProne
{
	simulated function bool CanProneTransition(){return false;}
	simulated event bool IsTransitioningToProne(){return true;}

    simulated function Timer()
	{
		GotoState('Crawling');
	}

	simulated event AnimEnd(int Channel)
	{
		Global.AnimEnd(Channel);

		if( Level.NetMode != NM_DedicatedServer )
			GotoState('Crawling');
	}

	simulated function BeginState()
	{
		local name Anim;

		// Merge TODO, replace this with the animation length when we get an animation - Ramm
		if( Level.NetMode == NM_DedicatedServer )
			SetTimer(0.26,false);

		if (WeaponAttachment != None)
			Anim = WeaponAttachment.PA_DiveToProneStartAnim;
		else
			Anim = DiveToProneStartAnim;

        AnimBlendTimer();

 		// Cancel any anims playing on the weapon since we do the same for the player
		if( WeaponAttachment != none )
			WeaponAttachment.PlayIdle();

		PlayAnim(Anim, 1.0, 0.25, 0);

		if( Weapon!= none )
			Weapon.NotifyCrawlMoving();
	}

	simulated function EndState()
	{
		local float NewHeight;
		local name Anim;

        NewHeight = default.CollisionHeight - ProneHeight;

		if (WeaponAttachment != None)
			Anim = WeaponAttachment.PA_DiveToProneEndAnim;
		else
			Anim = DiveToProneEndAnim;

		PlayAnim(DiveToProneEndAnim, 0.0, 0.0, 0);
        PrePivot = default.PrePivot + (NewHeight * vect(0,0,1));
	}
}

//-----------------------------------------------------------------------------
// EndCrouch
//-----------------------------------------------------------------------------
event EndCrouch(float HeightAdjust)
{
	EyeHeight -= HeightAdjust;
	OldZ += HeightAdjust;
	BaseEyeHeight = Default.BaseEyeHeight;

	if( bBipodDeployed && ROBipodWeapon(Weapon) != none )
	{
		ROBipodWeapon(Weapon).ForceUndeploy();
	}

	PlayOwnedSound(CrouchToStandSound, SLOT_Interact, 1.0,, 10);
}

//-----------------------------------------------------------------------------
// StartCrouch - Changed crouch eye height
//-----------------------------------------------------------------------------
event StartCrouch(float HeightAdjust)
{
	EyeHeight += HeightAdjust;
	OldZ -= HeightAdjust;

	if( bBipodDeployed && ROBipodWeapon(Weapon) != none )
	{
		ROBipodWeapon(Weapon).ForceUndeploy();
	}

	if ( ROPlayer(Controller) != none)
	{
		ROPlayer(Controller).ResetSwayValues();
	}

	ShouldProne(false);

    PlayOwnedSound(StandToCrouchSound, SLOT_Interact, 1.0,, 10);

    if( VSizeSquared(Velocity) > 25 )
    {
    	BaseEyeHeight = CrouchMoveEyeHeightMod * CrouchHeight;
    }
    else
    {
    	BaseEyeHeight = CrouchEyeHeightMod * CrouchHeight;
    }
}

// Crouch when trying to deploy
event DeployedStartCrouch()
{
	if ( ROPlayer(Controller) != none)
	{
		ROPlayer(Controller).ResetSwayValues();
	}

	ShouldProne(false);

    PlayOwnedSound(StandToCrouchSound, SLOT_Interact, 1.0,, 10);
}

//=============================================================
// Death/Damage
//=============================================================

// Sometimes we need to damage only the highest damage hitpoint, this will return that hitpoint index
function int GetHighestDamageHitIndex( array<int> PointsHit )
{
	local int i, besthit, bestdamage;

	if( PointsHit.Length == 1 )
	{
		return 0;
	}

	for(i=0; i<PointsHit.Length; i++)
	{
		if( Hitpoints[PointsHit[i]].DamageMultiplier > bestdamage )
		{
			besthit = i;
			bestdamage = Hitpoints[PointsHit[i]].DamageMultiplier;
		}
	}

	return besthit;
}

// Process a precision hit
function ProcessLocationalDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType, array<int> PointsHit)
{
	local int actualDamage, originalDamage, cumulativeDamage, totalDamage, i;
	local int HighestDamagePoint, HighestDamageAmount;
	// Hit detection debugging
    /*local coords CO;
	local vector HeadLoc;
	local bool bFirstHit;*/

    originalDamage = damage;

	// If someone else has killed this player , return
	if( bDeleteMe || PointsHit.Length < 1 || Health <= 0 )
		return;

	for(i=0; i<PointsHit.Length; i++)
	{
		// If someone else has killed this player , return
		if( bDeleteMe || Health <= 0 )
			return;

		actualDamage = originalDamage;

		actualDamage *= Hitpoints[PointsHit[i]].DamageMultiplier;
		totalDamage += actualDamage;
		actualDamage = Level.Game.ReduceDamage(Damage, self, instigatedBy, HitLocation, Momentum, DamageType);
		cumulativeDamage += actualDamage;

		if( actualDamage > HighestDamageAmount )
		{
			HighestDamageAmount = actualDamage;
			HighestDamagePoint = PointsHit[i];
		}

		//log("We hit "$GetEnum(enum'EPawnHitPointType',Hitpoints[PointsHit[i]].HitPointType));

        // Hit detection debugging
		/*if( PointsHit[i] != 0 && !bFirstHit )
		{
	        CO = GetBoneCoords(Hitpoints[PointsHit[i]].PointBone);
			HeadLoc = CO.Origin;
			HeadLoc = HeadLoc + (Hitpoints[PointsHit[i]].PointOffset >> GetBoneRotation(Hitpoints[PointsHit[i]].PointBone));

			DrawLocation = HeadLoc;
			DrawRotation = GetBoneRotation(Hitpoints[PointsHit[i]].PointBone);
			DrawIndex = PointsHit[i];
			HitPointDebugByte++;
			bFirstHit = true;
		}*/

		if (Hitpoints[PointsHit[i]].HitPointType == PHP_Leg || Hitpoints[PointsHit[i]].HitPointType ==PHP_Foot)
		{
	        if (ActualDamage > 0 )
				SetLimping(FMin(ActualDamage / 5.0, 10.0));
		}
		else if (Hitpoints[PointsHit[i]].HitPointType == PHP_Hand)
		{
            if( (ROPlayer(Controller) != none) && (ROTeamGame(Level.Game).FriendlyFireScale > 0.0) && !InGodMode())
            {
	            ROPlayer(Controller).ThrowWeapon();
	            ROPlayer(Controller).ReceiveLocalizedMessage(class'ROWeaponLostMessage');
            }
		}

		// Update the locational damage list
		//UpdateDamageList(Hitpoints[PointsHit[i]].HitPointType);
		UpdateDamageList(PointsHit[i] - 1);

		// Lets exit out if one of the shots killed the player
		if ( cumulativeDamage >=  Health )
		{
			TakeDamage(totalDamage, instigatedBy, hitlocation, momentum, damageType, HighestDamagePoint);
		}
	}

	if( totalDamage > 0 )
	{
		// If someone else has killed this player , return
		if( bDeleteMe || Health <= 0 )
			return;

		TakeDamage(totalDamage, instigatedBy, hitlocation, momentum, damageType, HighestDamagePoint);
	}
}

// Update the list of damaged areas for the pawn
// 255 = All areas, 254 = Just the legs
function UpdateDamageList(byte NewDamagePoint)
{
	if( Role == ROLE_Authority )
	{
		if( NewDamagePoint == 254 )
		{
			DamageList[3] = 1;
			DamageList[4] = 1;
			DamageList[7] = 1;
			DamageList[8] = 1;
			DamageList[13] = 1;
			DamageList[14] = 1;

			ClientUpdateDamageList(NewDamagePoint);
		}
		else if( DamageList[NewDamagePoint] == 0 )
		{
			DamageList[NewDamagePoint] = 1;

			ClientUpdateDamageList(NewDamagePoint);
		}
	}
}

// Replicated from server to client to set the clients
// Damage areas
simulated function ClientUpdateDamageList(byte NewDamagePoint)
{
	local PlayerController PC;

	PC = Level.GetLocalPlayerController();

	if( NewDamagePoint == 254 )
	{
		DamageList[3] = 1;
		DamageList[4] = 1;
		DamageList[7] = 1;
		DamageList[8] = 1;
		DamageList[13] = 1;
		DamageList[14] = 1;
	}
	else
	{
		DamageList[NewDamagePoint] = 1;
	}
}

// Hit detection debugging - Only use when debugging
/*
simulated function DrawBoneLocation()
{
    local vector X, Y, Z;

    GetAxes(DrawRotation, X,Y,Z);
    ClearStayingDebugLines();

	DrawStayingDebugLine(HitStart, HitEnd, 0,255,0);
	Spawn(class 'ROEngine.RODebugTracer',self,,HitStart,Rotator(Normal(HitEnd-HitStart)));

	DrawDebugCylinder(DrawLocation,Z,Y,X,Hitpoints[DrawIndex].PointRadius * Hitpoints[DrawIndex].PointScale,Hitpoints[DrawIndex].PointHeight * Hitpoints[DrawIndex].PointScale,10,0, 255, 0);
}

simulated function DrawDebugCylinder(vector Base,vector X, vector Y,vector Z, FLOAT Radius,float HalfHeight,int NumSides, byte R, byte G, byte B)
{
	local float AngleDelta;
	local vector LastVertex, Vertex;
	local int SideIndex;

	AngleDelta = 2.0f * PI / NumSides;
	LastVertex = Base + X * Radius;

	for(SideIndex = 0;SideIndex < NumSides;SideIndex++)
	{
		Vertex = Base + (X * Cos(AngleDelta * (SideIndex + 1)) + Y * Sin(AngleDelta * (SideIndex + 1))) * Radius;

        DrawStayingDebugLine( LastVertex - Z * HalfHeight,Vertex - Z * HalfHeight,R,G,B);
        DrawStayingDebugLine( LastVertex + Z * HalfHeight,Vertex + Z * HalfHeight,R,G,B);
        DrawStayingDebugLine( LastVertex - Z * HalfHeight,LastVertex + Z * HalfHeight,R,G,B);

		LastVertex = Vertex;
	}
}*/

//returns how exposed this player is to another actor
function float GetExposureTo(vector TestLocation)
{
	local int i;
	local float PercentExposed;

	for(i=0; i<Hitpoints.Length; i++)
	{
		if( i == 0 )
		{
			if( FastTrace(GetBoneCoords(Hitpoints[i].PointBone).Origin,TestLocation))
			{
				PercentExposed += 0.4;
			}
		}
		else if ( i == 1)
		{
			if( FastTrace(GetBoneCoords(Hitpoints[i].PointBone).Origin,TestLocation))
			{
				PercentExposed += 0.3;
			}
		}
		else if ( i == 13)
		{
			if( FastTrace(GetBoneCoords(Hitpoints[i].PointBone).Origin,TestLocation))
			{
				PercentExposed += 0.15;
			}
		}
		else if ( i == 14)
		{
			if( FastTrace(GetBoneCoords(Hitpoints[i].PointBone).Origin,TestLocation))
			{
				PercentExposed += 0.15;
			}
		}
	}

	return PercentExposed;
}


// Overriden so pawns don't go to the falling state every time they are shot
function AddVelocity( vector NewVelocity)
{
	if ( bIgnoreForces || (NewVelocity == vect(0,0,0)) )
		return;
	if ( (Physics == PHYS_Falling) && (AIController(Controller) != None) )
		ImpactVelocity += NewVelocity;
	if ( (Physics == PHYS_Walking && (NewVelocity.Z > (Default.JumpZ/2)))
		|| (((Physics == PHYS_Ladder) || (Physics == PHYS_Spider)) && (NewVelocity.Z > Default.JumpZ)) )
		SetPhysics(PHYS_Falling);
	if ( (Velocity.Z > 380) && (NewVelocity.Z > 0) )
		NewVelocity.Z *= 0.5;
	Velocity += NewVelocity;
}

//-----------------------------------------------------------------------------
// TakeDamage - Handle locational damage
//-----------------------------------------------------------------------------
// MergeTODO: This function needs some work
function TakeDamage(int Damage, Pawn InstigatedBy, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional int HitIndex)
{
	local int actualDamage;
	local Controller Killer;

	if ( damagetype == None )
	{
		if ( InstigatedBy != None )
			warn("No damagetype for damage by "$instigatedby$" with weapon "$InstigatedBy.Weapon);
		DamageType = class'DamageType';
	}

	if ( Role < ROLE_Authority )
	{
		//log(self$" client damage type "$damageType$" by "$instigatedBy);
		return;
	}

	if ( Health <= 0 )
		return;

	if ((instigatedBy == None || instigatedBy.Controller == None) && DamageType.default.bDelayedDamage && DelayedDamageInstigatorController != None)
		instigatedBy = DelayedDamageInstigatorController.Pawn;

	if ( (Physics == PHYS_None) && (DrivenVehicle == None) )
		SetMovementPhysics();
	if (Physics == PHYS_Walking && damageType.default.bExtraMomentumZ)
		momentum.Z = FMax(momentum.Z, 0.4 * VSize(momentum));
	if ( instigatedBy == self )
		momentum *= 0.6;
	momentum = momentum/Mass;

	if (Weapon != None)
		Weapon.AdjustPlayerDamage( Damage, InstigatedBy, HitLocation, Momentum, DamageType );

	if (DrivenVehicle != None)
        	DrivenVehicle.AdjustDriverDamage( Damage, InstigatedBy, HitLocation, Momentum, DamageType );

	ActualDamage = Level.Game.ReduceDamage(Damage, self, instigatedBy, HitLocation, Momentum, DamageType);

	if (ActualDamage > 0 && (DamageType.Name == 'Fell'))
		SetLimping(FMin(ActualDamage / 5.0, 10.0));

	//ClientMessage("Hit area:" @ HitBone @ "Damage:" @ ActualDamage);

	Health -= actualDamage;
	if ( HitLocation == vect(0,0,0) )
		HitLocation = Location;

	LastHitIndex = HitIndex;

	PlayHit(actualDamage,InstigatedBy, hitLocation, damageType, Momentum, HitIndex);
	if ( Health <= 0 )
	{
		// pawn died
		if ( DamageType.default.bCausedByWorld && (instigatedBy == None || instigatedBy == self) && LastHitBy != None )
			Killer = LastHitBy;
		else if ( instigatedBy != None )
			Killer = instigatedBy.GetKillerController();
		if ( Killer == None && DamageType.Default.bDelayedDamage )
			Killer = DelayedDamageInstigatorController;
		if ( bPhysicsAnimUpdate )
			SetTearOffMomemtum(momentum);
		Died(Killer, damageType, HitLocation);
	}
	else
	{
		AddVelocity( momentum );
		if ( Controller != None )
			Controller.NotifyTakeHit(instigatedBy, HitLocation, actualDamage, DamageType, Momentum);

		if ( instigatedBy != None && instigatedBy != self )
			LastHitBy = instigatedBy.Controller;
	}
	MakeNoise(1.0);
}

/**
  * When player dies this method is called to find and drop
  * all other weapons in their inventory
  */
// MergeTODO: This function was probably crashing due to the bDeleteMe flag problem. Search unprog for the fix
function DropWeaponInventory(Vector TossVel)
{
	local Inventory Inv;
	local Weapon invWeapon;
	local Vector X,Y,Z;
	local int count, i;
	local array<class> DroppedClasses;
	local bool bAlreadyUsedClass;

	GetAxes(Rotation,X,Y,Z);

	count=0;
	Inv=Inventory;

	// consider doing a check on count to make sure it doesn't get too high
	// and force Unreal to crash with a run away loop
    while((Inv != none) && (count < 15))// 500
    {
        count++;
        if(Inv.IsA('Weapon'))
        {
            invWeapon = Weapon(Inv);

            if(invWeapon != none && invWeapon.bCanThrow)
            {
                for ( i=0;i<DroppedClasses.Length;i++ )
                {
                    //log("Dropped classes "$i$" = "$DroppedClasses[i]);
                    if( invWeapon.Class == DroppedClasses[i] )
                    {
                        bAlreadyUsedClass = true;
                        break;
                    }
                }

                if( !bAlreadyUsedClass )
                {
                    // because the weapon is destroyed from inventory need to start over again
                    // and search through the inventory from the beginning.
                    DroppedClasses[DroppedClasses.Length] = invWeapon.Class;
                    invWeapon.DropFrom(Location + 0.8 * CollisionRadius * X - 0.5 * CollisionRadius * Y);
                    Inv = Inventory;
                }
                else
                {
                    //log("Trying to drop the same weapon: "$invWeapon.Class$" twice - possible lag bug cause");
                    Inv=Inv.Inventory;
                }
            }
            else
            {
                Inv=Inv.Inventory;
            }
        }
        else
        {
            Inv=Inv.Inventory;
        }

        bAlreadyUsedClass=false;
    }
}

// Clean up weapon inventory before level change since certain weapons
// (sniper scopes with 3d scopes) won't get properly garbage collected
// otherwise. This lead to the webadmin and memory leak issues - Ramm
simulated function PreTravelCleanUp()
{
	local Inventory Inv;
	local ROWeapon invWeapon;
	local int count;

	count=0;

	// consider doing a check on count to make sure it doesn't get too high
	// and force Unreal to crash with a run away loop
	for ( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
	{
		invWeapon = ROWeapon(Inv);
		if ( invWeapon != None )
		{
			invWeapon.PreTravelCleanUp();
		}

		count++;

		if( count > 500 )
			break;
	}
}

//-----------------------------------------------------------------------------
// Died - A few minor additions
//-----------------------------------------------------------------------------

function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
    local Vector			TossVel;
	local Trigger			T;
	local NavigationPoint	N;
	local float	DamageBeyondZero;
	local vector HitDirection;

	if ( bDeleteMe || Level.bLevelChange || Level.Game == None )
		return; // already destroyed, or level is being cleaned up

	if ( DamageType.default.bCausedByWorld && (Killer == None || Killer == Controller) && LastHitBy != None )
		Killer = LastHitBy;

	// mutator hook to prevent deaths
	// WARNING - don't prevent bot suicides - they suicide when really needed
	if ( Level.Game.PreventDeath(self, Killer, damageType, HitLocation) )
	{
		Health = max(Health, 1); //mutator should set this higher
		return;
	}

	// Turn off the auxilary collision when the player dies
	if (  AuxCollisionCylinder != none )
	{
	    AuxCollisionCylinder.SetCollision(false,false,false);
	}

    DamageBeyondZero = Health;

	Health = Min(0, Health);

	// Fix for suicide death messages
    if (DamageType == class'Suicided')
	    DamageType = class'ROSuicided';

    if ( Weapon != None && (DrivenVehicle == None || DrivenVehicle.bAllowWeaponToss) )
    {
		if ( Controller != None )
			Controller.LastPawnWeapon = Weapon.Class;
        Weapon.HolderDied();
        TossVel = Vector(GetViewRotation());
        TossVel = TossVel * ((Velocity Dot TossVel) + 50) + Vect(0,0,200);
        TossWeapon(TossVel);
    }

	DropWeaponInventory(TossVel);		// drops all weapons in inventory

	if ( DrivenVehicle != None )
	{
		Velocity = DrivenVehicle.Velocity;
		DrivenVehicle.DriverDied();
	}

	if ( Controller != None )
	{
		Controller.WasKilledBy(Killer);
		Level.Game.Killed(Killer, Controller, self, damageType);
	}
	else
		Level.Game.Killed(Killer, Controller(Owner), self, damageType);

	DrivenVehicle = None;

	if ( Killer != None )
		TriggerEvent(Event, self, Killer.Pawn);
	else
		TriggerEvent(Event, self, None);

	// make sure to untrigger any triggers requiring player touch
	if ( IsPlayerPawn() || WasPlayerPawn() )
	{
		PhysicsVolume.PlayerPawnDiedInVolume(self);
		ForEach TouchingActors(class'Trigger',T)
			T.PlayerToucherDied(self);

		// event for HoldObjectives
		foreach TouchingActors(class'NavigationPoint', N)
			if ( N.bReceivePlayerToucherDiedNotify )
				N.PlayerToucherDied( Self );
	}

	// remove powerup effects, etc.
	RemovePowerups();

	Velocity.Z *= 1.3;
	if ( IsHumanControlled() )
		PlayerController(Controller).ForceDeathUpdate();
	if ( ROPlayer(Controller) != none
         && class<ROWeaponDamageType>(DamageType) != none
         && class<ROWeaponDamageType>(DamageType).default.bCauseViewJarring == true )
	{
        HitDirection = Location - HitLocation;
        HitDirection.Z = 0.0f;
        HitDirection = normal(HitDirection);

	    ROPlayer(Controller).PlayerJarred(HitDirection,3.0f);
	}
    if ( (DamageType != None) && DamageType.default.bAlwaysGibs && !class'GameInfo'.static.UseLowGore())
    {
        if ( Level.NetMode == NM_DedicatedServer )
           DoDamageFX('obliterate',1010,class'RODiedInTankDamType', Rotation);
        ChunkUp( Rotation, DamageType.default.GibPerterbation );
	}
	else if (DamageType != none && (Abs(DamageBeyondZero) + default.Health) > DamageType.default.HumanObliterationThreshhold &&
		!class'GameInfo'.static.UseLowGore())
	{
	    if ( Level.NetMode == NM_DedicatedServer )
	       DoDamageFX('obliterate',1010,class'RODiedInTankDamType', Rotation);
        ChunkUp( rotator(GetTearOffMomemtum()), DamageType.default.GibPerterbation );
	}
	else
	{
		NetUpdateFrequency = Default.NetUpdateFrequency;
		PlayDying(DamageType, HitLocation);
		if ( Level.Game.bGameEnded )
			return;
		if ( !bPhysicsAnimUpdate && !IsLocallyControlled() )
			ClientDying(DamageType, HitLocation);
	}
}

// Overridden to support some Xpawn functionality we wanted
simulated function PlayDying(class<DamageType> DamageType, vector HitLoc)
{
	WeaponState = GS_None;
	if( PlayerController(Controller) != none )
		PlayerController(Controller).bFreeCamera = false;

	AmbientSound = None;
    bCanTeleport = false; // sjs - fix karma going crazy when corpses land on teleporters
    bReplicateMovement = false;
    bTearOff = true;
    bPlayedDeath = true;

	HitDamageType = DamageType; // these are replicated to other clients
    TakeHitLocation = HitLoc;

    if ( DamageType != None )
    {
		if ( DamageType.Default.DeathOverlayMaterial != None && !class'GameInfo'.static.UseLowGore() )
			SetOverlayMaterial(DamageType.Default.DeathOverlayMaterial, DamageType.default.DeathOverlayTime, true);
		else if ( (DamageType.Default.DamageOverlayMaterial != None) && (Level.DetailMode != DM_Low) && !Level.bDropDetail )
			SetOverlayMaterial(DamageType.Default.DamageOverlayMaterial, 2*DamageType.default.DamageOverlayTime, true);
	}

    // stop shooting
    AnimBlendParams(1, 0.0);
	LifeSpan = RagdollLifeSpan;

    GotoState('Dying');

	PlayDyingAnimation(DamageType, HitLoc);
}

//-----------------------------------------------------------------------------
// KilledBy - Changed damage type - butto 9/14/03
//-----------------------------------------------------------------------------
function KilledBy( pawn EventInstigator )
{
	local Controller Killer;

	Health = 0;
	if ( EventInstigator != None )
		Killer = EventInstigator.Controller;
	Died( Killer, class'ROSuicided', Location );
}

// Killed yourself (like with a grenade that you let go off in your hand)
function KilledSelf( class<DamageType> damageType )
{
	local Controller Killer;

	Health = 0;

	Killer = Controller;
	Died( Killer, damageType, Location );
}

//-----------------------------------------------------------------------------
// DoDamageFX
//-----------------------------------------------------------------------------
// TODO: This is where are gib stuff will go
function DoDamageFX( Name boneName, int Damage, class<DamageType> DamageType, Rotator r )
{
	local float DismemberProbability;
    local int RandBone;
    local bool bDidSever;

    if (  FRand() > 0.3f || Damage > 30 || Health <= 0 )
    {
        HitFX[HitFxTicker].damtype = DamageType;

        if( Health <= 0 )
        {
            switch( boneName )
            {
                case 'lfoot':
                case 'lthigh':
                case 'lupperthigh':
                    boneName = 'lthigh';
                    break;

                case 'rfoot':
                case 'rthigh':
                case 'rupperthigh':
                    boneName = 'rthigh';
                    break;

                case 'lhand':
                case 'lfarm':
                case 'lupperarm':
                case 'lshoulder':
                    boneName = 'lfarm';
                    break;

                case 'rhand':
                case 'rfarm':
                case 'rupperarm':
                case 'rshoulder':
                    boneName = 'rfarm';
                    break;

                case 'None':
                    boneName = 'Spine';
                    break;
            }

//	        if( !DamageType.default.bLocationalHit && (boneName == 'None' || boneName == 'Upperspine' ||
//				boneName == 'Spine' ))
//	        {
//	        	RandBone = Rand(4);
//
//				switch( RandBone )
//	            {
//	                case 0:
//						boneName = 'lthigh';
//						break;
//	                case 1:
//						boneName = 'rthigh';
//						break;
//	                case 2:
//						boneName = 'lfarm';
//	                    break;
//	                case 3:
//						boneName = 'rfarm';
//	                    break;
//	                case 4:
//						boneName = 'head';
//	                    break;
//	                default:
//	                	boneName = 'lthigh';
//	            }
//	        }

			if( DamageType.default.bAlwaysSevers || (Damage == 1000) )
			{
                HitFX[HitFxTicker].bSever = true;
                bDidSever = true;
                if ( boneName == 'None' )
                {
					boneName = 'spine';
				}
			}
            else if( DamageType.Default.GibModifier > 0.0 )
            {
	            DismemberProbability = Abs( (Health - Damage*DamageType.Default.GibModifier) / 130.0f );
/*				switch( boneName )
                {
                    case 'lfoot':
                    case 'rfoot':
	                case 'lthigh':
                    case 'rthigh':
                    case 'lhand':
                    case 'rhand':
                    case 'rfarm':
                    case 'lfarm':
                    case 'head':
                        if( FRand() < DismemberProbability )
                            HitFX[HitFxTicker].bSever = true;
                        break;

                    case 'None':
 						boneName = 'spine';
                     case 'spine':
                        if( FRand() < DismemberProbability * 0.3 )
                        {
                            HitFX[HitFxTicker].bSever = true;
                            if ( FRand() < 0.65 )
								bExtraGib = true;
						}
                        break;
                }*/

                if( FRand() < DismemberProbability )
                {
                	HitFX[HitFxTicker].bSever = true;
                	bDidSever = true;
                }
            }
        }

        if ( class'GameInfo'.static.UseLowGore() )
        {
			HitFX[HitFxTicker].bSever = false;
			bDidSever = false;
		}


        if ( HitFX[HitFxTicker].bSever )
        {
	        if( !DamageType.default.bLocationalHit && (boneName == 'None' || boneName == 'Upperspine' ||
				boneName == 'Spine' ))
	        {
	        	RandBone = Rand(4);

				switch( RandBone )
	            {
	                case 0:
						boneName = 'lthigh';
						break;
	                case 1:
						boneName = 'rthigh';
						break;
	                case 2:
						boneName = 'lfarm';
	                    break;
	                case 3:
						boneName = 'rfarm';
	                    break;
	                case 4:
						boneName = 'head';
	                    break;
	                default:
	                	boneName = 'lthigh';
	            }
	        }
        }

		if( Health < 0 && Damage > DamageType.default.HumanObliterationThreshhold && Damage != 1000 )
		{
			boneName = 'obliterate';
		}

       	HitFX[HitFxTicker].bone = boneName;
        HitFX[HitFxTicker].rotDir = r;
        HitFxTicker = HitFxTicker + 1;
        if( HitFxTicker > ArrayCount(HitFX)-1 )
            HitFxTicker = 0;

        // If this was a really hardcore damage from an explosion, randomly spawn some arms and legs
        if ( bDidSever && !DamageType.default.bLocationalHit && Damage > 200 && Damage != 1000 )
        {
			if ((Damage > 400 && FRand() < 0.3) || FRand() < 0.1 )
			{
				DoDamageFX('head',1000,DamageType,r);
				DoDamageFX('lthigh',1000,DamageType,r);
				DoDamageFX('rthigh',1000,DamageType,r);
				DoDamageFX('lfarm',1000,DamageType,r);
				DoDamageFX('rfarm',1000,DamageType,r);
			}
			if ( FRand() < 0.25 )
			{
				DoDamageFX('lthigh',1000,DamageType,r);
				DoDamageFX('rthigh',1000,DamageType,r);
				if ( FRand() < 0.5 )
				{
					DoDamageFX('lfarm',1000,DamageType,r);
				}
				else
				{
					DoDamageFX('rfarm',1000,DamageType,r);
				}
			}
			else if ( FRand() < 0.35 )
				DoDamageFX('lthigh',1000,DamageType,r);
			else if ( FRand() < 0.5 )
				DoDamageFX('rthigh',1000,DamageType,r);
			else if ( FRand() < 0.75 )
			{
				if ( FRand() < 0.5 )
				{
					DoDamageFX('lfarm',1000,DamageType,r);
				}
				else
				{
					DoDamageFX('rfarm',1000,DamageType,r);
				}
			}
		}
    }
}

//-----------------------------------------------------------------------------
// ProcessHitFX
//-----------------------------------------------------------------------------
 // MergeTODO: Replace this with realistic gibbing
simulated function ProcessHitFX()
{
    local Coords boneCoords;
    //local class<xEmitter> HitEffects[4];
    local int j;//i,j;
    local float GibPerterbation;

    if( (Level.NetMode == NM_DedicatedServer) )
    {
		SimHitFxTicker = HitFxTicker;
        return;
    }

    for ( SimHitFxTicker = SimHitFxTicker; SimHitFxTicker != HitFxTicker; SimHitFxTicker = (SimHitFxTicker + 1) % ArrayCount(HitFX) )
    {
		j++;
		if ( j > 30 )
		{
			SimHitFxTicker = HitFxTicker;
			return;
		}

        if( (HitFX[SimHitFxTicker].damtype == None) || (Level.bDropDetail && (Level.TimeSeconds - LastRenderTime > 3) && !IsHumanControlled()) )
            continue;

		//log("Processing effects for damtype "$HitFX[SimHitFxTicker].damtype);

		if( HitFX[SimHitFxTicker].bone == 'obliterate' && !class'GameInfo'.static.UseLowGore())
		{
			SpawnGibs( HitFX[SimHitFxTicker].rotDir, 0);
			bGibbed = true;
			Destroy();
			return;
		}

        boneCoords = GetBoneCoords( HitFX[SimHitFxTicker].bone );

        if ( !Level.bDropDetail && !class'GameInfo'.static.NoBlood())
        {
			AttachEffect( BleedingEmitterClass, HitFX[SimHitFxTicker].bone, boneCoords.Origin, HitFX[SimHitFxTicker].rotDir );

//			HitFX[SimHitFxTicker].damtype.static.GetHitEffects( HitEffects, Health );
//
//			if( !PhysicsVolume.bWaterVolume ) // don't attach effects under water
//			{
//				for( i = 0; i < ArrayCount(HitEffects); i++ )
//				{
//					if( HitEffects[i] == none )
//						continue;
//
//					AttachEffect( HitEffects[i], HitFX[SimHitFxTicker].bone, boneCoords.Origin, HitFX[SimHitFxTicker].rotDir );
//				}
//			}
		}
        if ( class'GameInfo'.static.UseLowGore() )
			HitFX[SimHitFxTicker].bSever = false;

        if( HitFX[SimHitFxTicker].bSever )
        {
            GibPerterbation = HitFX[SimHitFxTicker].damtype.default.GibPerterbation;

            switch( HitFX[SimHitFxTicker].bone )
            {
                case 'obliterate':
                    break;

				case 'lthigh':
                case 'lupperthigh':
                	if( !bLeftLegGibbed )
					{
	                    SpawnGiblet( DetachedLegClass, boneCoords.Origin, HitFX[SimHitFxTicker].rotDir, GibPerterbation );
	                    bLeftLegGibbed=true;
                    }
                    break;

                case 'rthigh':
                case 'rupperthigh':
                	if( !bRightLegGibbed )
					{
	                    SpawnGiblet( DetachedLegClass, boneCoords.Origin, HitFX[SimHitFxTicker].rotDir, GibPerterbation );
	                    bRightLegGibbed=true;
                    }
                    break;

                case 'lfarm':
                case 'lupperarm':
                	if( !bLeftArmGibbed )
					{
	                    SpawnGiblet( DetachedArmClass, boneCoords.Origin, HitFX[SimHitFxTicker].rotDir, GibPerterbation );
	                    bLeftArmGibbed=true;
                    }
                    break;

                case 'rfarm':
                case 'rupperarm':
                	if( !bRightArmGibbed )
					{
	                    SpawnGiblet( DetachedArmClass, boneCoords.Origin, HitFX[SimHitFxTicker].rotDir, GibPerterbation );
	                    bRightArmGibbed=true;
                    }
                    break;

                case 'head':
                  	HelmetShotOff(HitFX[SimHitFxTicker].rotDir);
                    break;

//                case 'spine':
//                case 'Upperspine':
//                case 'None':
//					  bGibbed = true;
//                    break;
            }
            //never hide the head
//            if(HitFX[SimHitFXTicker].bone == 'head')
//            {
//            	if( Headgear != none )
//            	{
//            		Headgear.Destroy();
//            	}
//            }

			if( HitFX[SimHitFXTicker].bone != 'Spine' && HitFX[SimHitFXTicker].bone != 'UpperSpine' )
            	HideBone(HitFX[SimHitFxTicker].bone);
        }

        if(HitFX[SimHitFXTicker].bone == 'head' && Health < 0)
        {
        	if( Headgear != none )
        	{
        		HelmetShotOff(HitFX[SimHitFxTicker].rotDir);
        	}
        }
    }
}

//-----------------------------------------------------------------------------
// HelmetShotOff
//-----------------------------------------------------------------------------
simulated function HelmetShotOff(Rotator Rotation)
{
/*    local DroppedHeadGear Hat;

    if( HeadGear == none )
    {
    	return;
    }

    Hat = Spawn( class'DroppedHeadGear',,, HeadGear.Location, HeadGear.Rotation );
    if( Hat == none )
        return;

    Hat.LinkMesh(HeadGear.Mesh);

    HeadGear.Destroy();

    Hat.Velocity = Velocity + vector(Rotation) * (Hat.MaxSpeed + (Hat.MaxSpeed/2) * FRand());
    Hat.LifeSpan = Hat.LifeSpan + 2 * FRand() - 1;*/
}



//-----------------------------------------------------------------------------
// StartDeRes
//-----------------------------------------------------------------------------
// MergeTODO: This Deres stuff is crap. Replace with something better
simulated function StartDeRes()
{
    if( Level.NetMode == NM_DedicatedServer )
        return;

	MaxLights=0;

	// Turn off collision when we de-res (avoids rockets etc. hitting corpse!)
	SetCollision(true, false, false);

	// Remove/disallow projectors
	Projectors.Remove(0, Projectors.Length);
	bAcceptsProjectors = false;

	// Remove shadow
	if(PlayerShadow != None)
		PlayerShadow.bShadowActive = false;

	// Turn off any overlays
	SetOverlayMaterial(None, 0.0f, true);

}

//-----------------------------------------------------------------------------
// Destroyed - Destroy any dummy attachments
//-----------------------------------------------------------------------------

simulated event Destroyed()
{
	local int i;

	if( Headgear != none )
	{
		Headgear.Destroy();
	}

	for (i = AmmoPouches.Length - 1; i >= 0; i--)
	{
		if( AmmoPouches[i] != none )
			AmmoPouches[i].Destroy();

		AmmoPouches.Length = AmmoPouches.Length - 1;
	}

	if (  AuxCollisionCylinder != none )
	{
	    AuxCollisionCylinder.Destroy();
	}

	// Delete any attached emitters
    for( i = 0; i < Attached.length; i++ )
    {
        if( Attached[i].IsA('Emitter') && Attached[i].bDeleteMe )
        {
        	Attached[i].Destroy();
        }
    }

	// TODO: lets throw out the weapon that was on the player's back
	if( AttachedBackItem != none )
	{
		AttachedBackItem.Destroy();
	}

	if( SeveredLeftArm != none )
	{
		SeveredLeftArm.Destroy();
	}

	if( SeveredRightArm != none )
	{
		SeveredRightArm.Destroy();
	}

	if( SeveredRightLeg != none )
	{
		SeveredRightLeg.Destroy();
	}

	if( SeveredLeftLeg != none )
	{
		SeveredLeftLeg.Destroy();
	}

	if( SeveredHead != none )
	{
		SeveredHead.Destroy();
	}

    if( PlayerShadow != none )
        PlayerShadow.Destroy();


	Super.Destroyed();
}

//-----------------------------------------------------------------------------
// TickFX
//-----------------------------------------------------------------------------

simulated function TickFX(float DeltaTime)
{
    if ( SimHitFxTicker != HitFxTicker )
    {
		ProcessHitFX();
    }
}

//-----------------------------------------------------------------------------
// Dying - Improvements to corpse handling
//-----------------------------------------------------------------------------

state Dying
{
	// from UnrealPawn
	function Landed(vector HitNormal)
	{
		//do nothing
/*		if ( Level.NetMode == NM_DedicatedServer )
			return;
		if ( Shadow != None )
			Shadow.Destroy();*/
	}

	// From Xpawn
	simulated function AnimEnd( int Channel )
	{
	    ReduceCylinder();
	}

    function LandThump()
    {
        // animation notify - play sound if actually landed, and animation also shows it
        if ( Physics == PHYS_None)
        {
            bThumped = true;
            //PlaySound(GetSound(EST_CorpseLanded));
        }
    }
    // end from Xpawn

	simulated function TakeDamage(int Damage, Pawn InstigatedBy, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional int HitIndex)
	{
		local Vector SelfToHit, SelfToInstigator, CrossPlaneNormal;
		local float W;
		local float YawDir;

		local Vector HitNormal, shotDir;
		local Vector PushLinVel, PushAngVel;
		local Name HitBone;
		local float HitBoneDist;
		local int MaxCorpseYawRate;

		if (DamageType == None)
			return;

		if(Physics == PHYS_KarmaRagdoll)
		{
			// Can't shoot corpses during de-res
			if(bDeRes)
				return;

			//log("HIT RAGDOLL. M:"$Momentum);
			// Throw the body if its a rocket explosion or shock combo
			if(damageType.Name == 'ROSMineDamType' || damageType.Name == 'ROStielGranateDamType' || damageType.Name == 'ROMineDamType' || damageType.Name == 'ROF1GrenadeDamType')
			{
				shotDir = Normal(Momentum);
				PushLinVel = (RagDeathVel * shotDir) +  vect(0, 0, 250);
				PushAngVel = Normal(shotDir Cross vect(0, 0, 1)) * -18000;
				KSetSkelVel( PushLinVel, PushAngVel );
			}
			else if( damageType.Default.bRagdollBullet )
			{
				if ( Momentum == vect(0,0,0) )
					Momentum = HitLocation - InstigatedBy.Location;
				if ( FRand() < 0.65 )
				{
					if ( Velocity.Z <= 0 )
						PushLinVel = vect(0,0,40);
					PushAngVel = Normal(Normal(Momentum) Cross vect(0, 0, 1)) * -8000 ;
					PushAngVel.X *= 0.5;
					PushAngVel.Y *= 0.5;
					PushAngVel.Z *= 4;
					KSetSkelVel( PushLinVel, PushAngVel );
				}
                PushLinVel = RagShootStrength*Normal(Momentum);
				KAddImpulse(PushLinVel, HitLocation);
				if ( (LifeSpan > 0) && (LifeSpan < DeResTime + 2) )
					LifeSpan += 0.2;
			}
			else
			{
				PushLinVel = RagShootStrength*Normal(Momentum);
				KAddImpulse(PushLinVel, HitLocation);
			}
			if ( (DamageType.Default.DamageOverlayMaterial != None) && (Level.DetailMode != DM_Low) && !Level.bDropDetail )
				SetOverlayMaterial(DamageType.Default.DamageOverlayMaterial, DamageType.default.DamageOverlayTime, true);
			return;
		}

		if (Damage > 0)
		{
			if ( InstigatedBy != None )
			{

				// Figure out which direction to spin:

				if( InstigatedBy.Location != Location )
				{
					SelfToInstigator = InstigatedBy.Location - Location;
					SelfToHit = HitLocation - Location;

					CrossPlaneNormal = Normal( SelfToInstigator cross Vect(0,0,1) );
					W = CrossPlaneNormal dot Location;

					if( HitLocation dot CrossPlaneNormal < W )
						YawDir = -1.0;
					else
						YawDir = 1.0;
				}
			}
			if( VSize(Momentum) < 10 )
			{
				Momentum = - Normal(SelfToInstigator) * Damage * 1000.0;
				Momentum.Z = Abs( Momentum.Z );
			}

			SetPhysics(PHYS_Falling);
			Momentum = Momentum / Mass;
			AddVelocity( Momentum );
			bBounce = true;

			RotationRate.Pitch = 0;
			RotationRate.Yaw += VSize(Momentum) * YawDir;

			MaxCorpseYawRate = 150000;
			RotationRate.Yaw = Clamp( RotationRate.Yaw, -MaxCorpseYawRate, MaxCorpseYawRate );
			RotationRate.Roll = 0;

			bFixedRotationDir = true;
			bRotateToDesired = false;

			Health -= Damage;
			CalcHitLoc( HitLocation, vect(0,0,0), HitBone, HitBoneDist );

			if( InstigatedBy != None )
				HitNormal = Normal( Normal(InstigatedBy.Location-HitLocation) + VRand() * 0.2 + vect(0,0,2.8) );
			else
				HitNormal = Normal( Vect(0,0,1) + VRand() * 0.2 + vect(0,0,2.8) );

			DoDamageFX( HitBone, Damage, DamageType, Rotator(HitNormal) );
		}
	}

	function BeginState()
	{
		local int i;

		SetCollision(true,false,false);
        if ( bTearOff && (Level.NetMode == NM_DedicatedServer) )
			LifeSpan = 1.0;
		else
			SetTimer(2.0, false);

        SetPhysics(PHYS_Falling);
		bInvulnerableBody = true;
		if ( Controller != None )
		{
			if ( Controller.bIsPlayer )
				Controller.PawnDied(self);
			else
				Controller.Destroy();
		}

		for (i = 0; i < Attached.length; i++)
			if (Attached[i] != None)
				Attached[i].PawnBaseDied();

		AmbientSound = None;
 	}

	simulated function Timer()
	{
		local KarmaParamsSkel skelParams;

		//log("ROPawn dead viewtarget = "$PlayerController(OldController).ViewTarget);

		// Regular PlayerCanSeeMe() check is not good enough, since we don't render the body, but use the karma for first person death
		if ( !PlayerCanSeeMe() && (PlayerController(OldController) == None) || ((PlayerController(OldController) != None) && (PlayerController(OldController).ViewTarget != self)))
		{
			StartDeRes();
			Destroy();
		}
		// If we are running out of life, but we still haven't come to rest, force the de-res.
		// unless pawn is the viewtarget of a player who used to own it
		else if ( LifeSpan <= DeResTime && bDeRes == false )
		{
			skelParams = KarmaParamsSkel(KParams);

			// check not viewtarget
			if ( (PlayerController(OldController) != None) && (PlayerController(OldController).ViewTarget == self) )
			{
				skelParams.bKImportantRagdoll = true;
				LifeSpan = FMax(LifeSpan,DeResTime + 2.0);
				SetTimer(1.0, false);
				return;
			}
			else
			{
				skelParams.bKImportantRagdoll = false;
			}

			// spawn derez
			bDeRes=true;
		}
		else
		{
			SetTimer(1.0, false);
		}
	}
}

// Overriden to send the weapon to the idle state when entering a vehicle.
// Apparantly calling the super here isn't good enough. Get accessed nones if this
// isn't in ROPawn
simulated event StartDriving(Vehicle V)
{
	local int i;

	DrivenVehicle = V;
	NetUpdateTime = Level.TimeSeconds - 1;
	AmbientSound = None;
	StopWeaponFiring();
	DeactivateSpawnProtection();

	// Move the driver into position, and attach to car.
	ShouldCrouch(false);
	ShouldProne(false);
	bIgnoreForces = true;
	Velocity = vect(0,0,0);
	Acceleration = vect(0,0,0);
	bCanTeleport = false;

	if ( !V.bRemoteControlled || V.bHideRemoteDriver )
    	{
		SetCollision( False, False, False);
		bCollideWorld = false;
		V.AttachDriver( Self );
		if ( V.bDrawDriverinTP )
			CullDistance = 5000;
		else
		   	bHidden = true;
    	}

	// set animation
	bPhysicsAnimUpdate = false;
	bWaitForAnim = false;
	if ( !V.bHideRemoteDriver && V.bDrawDriverinTP )
	{
		if ( HasAnim(DrivenVehicle.DriveAnim) )
			LoopAnim(DrivenVehicle.DriveAnim);
		else
			LoopAnim('Vehicle_Driving');
		SetAnimFrame(0.5);
		SmoothViewYaw = Rotation.Yaw;
		SetTwistLook(0,0);
	}

	if( PlayerShadow != none )
		PlayerShadow.bShadowActive = false;

	if ( WeaponAttachment != None )
		WeaponAttachment.Hide(true);

	//hack for sticky grenades
	for (i = 0; i < Attached.Length; i++)
		if (Projectile(Attached[i]) != None)
			Attached[i].SetBase(None);

    if( V.bKeepDriverAuxCollision )
    {
	   ToggleAuxCollision(true);
	}
	else
	{
       ToggleAuxCollision(false);
    }

	if( ROWeapon(Weapon)!=none)
	{
	   ROWeapon(Weapon).GotoState('Idle');
	}

    if( Weapon != none )
		Weapon.NotifyOwnerJumped();
}

// Overriden to turn the aux collision back on when you leave the vehicle
simulated function StopDriving(Vehicle V)
{
	Super.StopDriving(V);

	if( PlayerShadow != None )
		PlayerShadow.bShadowActive = true;

	if ( WeaponAttachment != None )
		WeaponAttachment.Hide(false);

	ToggleAuxCollision(true);

	// Clear any upper body animations. for when leaving a vehicle
	SetAnimAction('ClearAnims');
}

// Helper function for PostNetRecieve. Returns true if it finds a matching
// Primary weapon for this player and their role,and the weapon's instigator
// has finished replicating
simulated function bool VerifyPrimary(Inventory Inv)
{
	local int i;
	local bool bFoundMatch;
	local RORoleInfo RI;
	local int EmptyCount;

	if ( PlayerReplicationInfo != none && ROPlayerReplicationInfo(PlayerReplicationInfo) != none &&
				ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo != none )
	{
		RI = ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo;

		for (i = 0; i < ArrayCount(RI.PrimaryWeapons); i++)
		{
			if (RI.PrimaryWeapons[i].Item == None)
			{
				EmptyCount++;
				continue;
			}
	        else
	        {
	        	if( RI.PrimaryWeapons[i].Item == Inv.Class )
	        	{
	        		bFoundMatch = true;
					break;
	        	}
	        }
		}

		// There were no possible primary weapons
		if( EmptyCount == ArrayCount(RI.PrimaryWeapons) )
		{
			return true;
		}
	}

	return (bFoundMatch && (Inv.Instigator != none));
}

// Helper function for PostNetRecieve. Returns true if it finds a matching
// Secondary weapon for this player and their role,and the weapon's instigator
// has finished replicating
simulated function bool VerifySecondary(Inventory Inv)
{
	local int i;
	local bool bFoundMatch;
	local RORoleInfo RI;
	local int EmptyCount;

	if ( PlayerReplicationInfo != none && ROPlayerReplicationInfo(PlayerReplicationInfo) != none &&
				ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo != none )
	{
		RI = ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo;

			for (i = 0; i < ArrayCount(RI.SecondaryWeapons); i++)
			{
				if (RI.SecondaryWeapons[i].Item == None)
				{
					EmptyCount++;
					continue;
				}
		        else
		        {
		        	if( RI.SecondaryWeapons[i].Item == Inv.Class )
		        	{
		        		bFoundMatch = true;
						break;
		        	}
		        }
			}


		if( EmptyCount == ArrayCount(RI.SecondaryWeapons) )
		{
			return true;
		}
	}

	return (bFoundMatch && (Inv.Instigator != none));
}

// Helper function for PostNetRecieve. Returns true if it finds a matching
// Nade weapon for this player and their role,and the weapon's instigator
// has finished replicating
simulated function bool VerifyNades(Inventory Inv)
{
	local int i;
	local bool bFoundMatch;
	local RORoleInfo RI;
	local int EmptyCount;

	if ( PlayerReplicationInfo != none && ROPlayerReplicationInfo(PlayerReplicationInfo) != none &&
				ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo != none )
	{
		RI = ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo;

			for (i = 0; i < ArrayCount(RI.Grenades); i++)
			{
				if (RI.Grenades[i].Item == None)
				{
					EmptyCount++;
					continue;
				}
		        else
		        {
		        	if( RI.Grenades[i].Item == Inv.Class )
		        	{
		        		bFoundMatch = true;
						break;
		        	}
		        }
			}


		if( EmptyCount == ArrayCount(RI.Grenades) )
		{
			return true;
		}
	}

	return (bFoundMatch && (Inv.Instigator != none));
}

// Helper function for PostNetRecieve. Returns true if it finds a matching
// Given items for this player and their role,and the weapon's instigator
// has finished replicating
simulated function bool VerifyGivenItems()
{
	local inventory Inv;
	local int i, j, ItemCount;
	local RORoleInfo RI;
	local class<Inventory> InventoryClass;

 	if ( PlayerReplicationInfo != none && ROPlayerReplicationInfo(PlayerReplicationInfo) != none &&
				ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo != none )
	{
		RI = ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo;

		for ( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
		{
			if ( (Weapon(Inv) != None) )
			{
				for (j = 0; j < RI.GivenItems.Length; j++)
				{
                		InventoryClass = class<Inventory>(DynamicLoadObject(RI.GivenItems[j], class'Class'));

			        	if( InventoryClass == Inv.Class && Inv.Instigator != none)
			        	{
			        		ItemCount++;
							break;
			        	}

				}
			}
			i++;
			if ( i > 500 )
				break;
		}

		if( ItemCount == RI.GivenItems.Length )
		{
			return true;
		}
	}

	return false;
}

//-----------------------------------------------------------------------------
// PostNetReceive - Change player animations appropriately
//-----------------------------------------------------------------------------
// MergeTODO: look into setting bNetNotify to false here like Xpawn does
simulated function PostNetReceive()
{
	local int i;
	local inventory Inv;
	local int j;
	local bool bVerifiedPrimary, bVerifiedSecondary, bVerifiedNades, bVerifiedGivenItems;

    if( !bRecievedInitialLoadout )
    {
		for ( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
		{
			if ( (Weapon(Inv) != None) )
			{
				if( VerifyPrimary(Inv) )
				{
					bVerifiedPrimary = true;
				}

				if( VerifySecondary(Inv) )
				{
					bVerifiedSecondary = true;
				}

				if( VerifyNades(Inv) )
				{
					bVerifiedNades = true;
				}
			}
			j++;
			if ( j > 500 )
				break;
		}

		if( VerifyGivenItems() )
		{
			bVerifiedGivenItems = true;
		}

		if( bVerifiedPrimary && bVerifiedSecondary && bVerifiedNades && bVerifiedGivenItems )
		{
			bRecievedInitialLoadout = true;
			Controller.SwitchToBestWeapon();
			//log("*********** Got Initial Loadout!!!****************");
		}
	}

	// Hit detection debugging
/*	if(	HitPointDebugByte != OldHitPointDebugByte)
	{
  		DrawBoneLocation();
  		OldHitPointDebugByte = HitPointDebugByte;
	}*/

    if (!bInitializedPlayer)
	{
		if ( ForceDefaultCharacter() )
		{
			Setup(class'xUtil'.static.FindPlayerRecord(GetDefaultCharacter()));
			bInitializedPlayer = true;
		}
		else if ( PlayerReplicationInfo != none && ROPlayerReplicationInfo(PlayerReplicationInfo) != none &&
			ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo != none &&
			ROPlayerReplicationInfo(PlayerReplicationInfo).RoleInfo.static.GetModel() == PlayerReplicationInfo.CharacterName)
		{
			Setup(class'xUtil'.static.FindPlayerRecord(PlayerReplicationInfo.CharacterName));
			bInitializedPlayer = true;
		}
		else if ( (DrivenVehicle != None) && (DrivenVehicle.PlayerReplicationInfo != None) )
		{
			Setup(class'xUtil'.static.FindPlayerRecord(DrivenVehicle.PlayerReplicationInfo.CharacterName));
			bInitializedPlayer = true;
		}
	}

	if( !bInitializedWeaponAttachment && WeaponAttachment == none)
	{
		// Try and find weapon attachement
	    for( i = 0; i < Attached.length; i++ )
	    {
	        if( Attached[i].IsA('ROWeaponAttachment') )
	        {
	        	SetWeaponAttachment(ROWeaponAttachment(Attached[i]));
	        	bInitializedWeaponAttachment = true;
	        	break;
	        }
	    }
	}

	if( bInitializedPlayer && bInitializedWeaponAttachment && bRecievedInitialLoadout)
		bNetNotify = false;
}

// MergeTODO: commented out turning off the bNetNotify stuff. However, it should probably be turned
// back on when we refactor PostNetRecieve.
simulated function NotifyTeamChanged()
{
	// my PRI now has a new team
	if ( ForceDefaultCharacter() )
	{
		Setup(class'xUtil'.static.FindPlayerRecord(GetDefaultCharacter()));
        bNetNotify = false;
	}
	else if ( PlayerReplicationInfo != None )
    {
		Setup(class'xUtil'.static.FindPlayerRecord(PlayerReplicationInfo.CharacterName));
        bNetNotify = false;
    }
    else if ( (DrivenVehicle != None) && (DrivenVehicle.PlayerReplicationInfo != None) )
    {
		Setup(class'xUtil'.static.FindPlayerRecord(DrivenVehicle.PlayerReplicationInfo.CharacterName));
        bNetNotify = false;
    }
}

// Can we sprint in this state?
simulated function bool AllowSprint()
{
	if (!bIsCrawling &&((Weapon == None || Weapon.WeaponAllowSprint()) && Acceleration != vect(0,0,0)))
	{
		return true;
	}

	return false;
}

// Force a stamina update on the client
simulated function ClientForceStaminaUpdate(float NewStamina)
{
	Stamina = NewStamina;
}

// Handles the stamina calculations and sprinting functionality
function HandleStamina(float DeltaTime)
{
	local byte NewBreathSound;

	// Prone
	if( bIsCrawling )
	{
		if (Stamina < default.Stamina && Acceleration == vect(0,0,0))
		{
			Stamina = FMin(default.Stamina, Stamina + (DeltaTime * ProneStaminaRecoveryRate));
		}
		else
		{
		    Stamina = FMin(default.Stamina, Stamina + (DeltaTime * SlowStaminaRecoveryRate));
		}
	}
	else
	{
		// Walking
		if (bIsSprinting)
		{
			// Use more stamina when crouch sprinting
			if ( bIsCrouched )
			{
				Stamina = FMax(0.0, Stamina - (DeltaTime * 1.25));
			}
			else
			{
			   	Stamina = FMax(0.0, Stamina - DeltaTime);
			}
		}
		else
		{
			if (Stamina < default.Stamina && !bIsWalking && !bIsCrouched && VSizeSquared(Velocity) > 0.0 )
			{
				Stamina = FMin(default.Stamina, Stamina + (DeltaTime * SlowStaminaRecoveryRate));
			}
			else
			{
				if ( bIsCrouched )
				{
					Stamina = FMin(default.Stamina, Stamina + (DeltaTime * CrouchStaminaRecoveryRate));
				}
				else
				{
                 	Stamina = FMin(default.Stamina, Stamina + (DeltaTime * StaminaRecoveryRate));
				}
			}
		}
	}

	// Only set this flag on the server
	if ( Level.NetMode != NM_Client )
	{
		bCanStartSprint = Stamina > 2.0;
	}

	if( Stamina == 0.0 || Acceleration == vect(0,0,0) )
	{
		SetSprinting(false);
	}

    // Stamina sound handling. Sets the ambient breathing sound based on stamina level
	if ( Level.NetMode != NM_Client )
	{
		if (Health > 0 && Stamina < 10.0)
		{
		    if ( Stamina <= 2.0 )
			{
		    	NewBreathSound = 1;
			}
			else if (Stamina < 5.0 )
			{
				NewBreathSound = 2;
			}
			else if ( Stamina < 7.5 )
			{
		        NewBreathSound = 3;
			}
			else
			{
		        NewBreathSound = 4;
			}

		}
		else
		{
		    NewBreathSound = 5;
		}

		if( SavedBreathSound != NewBreathSound )
			SetBreathingSound(NewBreathSound);
	}
}

//-----------------------------------------------------------------------------
// Turned this tick back on to do stamina based breathing calculations -Ramm
// 08/15/04
//-----------------------------------------------------------------------------
simulated function Tick(float DeltaTime)
{
	if( Role > ROLE_SimulatedProxy )
		HandleStamina(DeltaTime);
	// Handle limping

	if( Role == ROLE_Authority )
	{
	    if( bIsLimping )
	    {
	    	if ( LimpTime <= 0 )
	    	{
	    		bIsLimping =  false;
				GroundSpeed=Default.GroundSpeed;
	    	}
	    	else
	    	{
	    	   	LimpTime -= DeltaTime;

				if (LimpTime>0)
				{
					GroundSpeed=Default.GroundSpeed - LimpTime * 20;
					if (GroundSpeed < 0)
						GroundSpeed = 0;
				}
	    	}
	    }
    }

	if( Level.Netmode != NM_DedicatedServer )
	{
		if ( Controller != None )
			OldController = Controller;

		// do footsteps for nonlocal pawns and bots
		if( !IsLocallyControlled() || (Level.Netmode == NM_Standalone && !IsHumanControlled()))
		{
			CheckFootSteps(DeltaTime);
		}

	    TickFX(DeltaTime);
	}
	TickLean(DeltaTime);
}

/*==========================================
* UnrealPawn functions
*=========================================*/

function gibbedBy(actor Other)
{
	if ( Role < ROLE_Authority )
		return;
	if ( Pawn(Other) != None )
	{
		if ( (Pawn(Other).Weapon != None) && Pawn(Other).Weapon.IsA('Translauncher') )
			Died(Pawn(Other).Controller, Pawn(Other).Weapon.GetDamageType(), Location);
		else
			Died(Pawn(Other).Controller, class'DamTypeTelefragged', Location);
	}
	else
		Died(None, class'Gibbed', Location);
}

function HoldFlag(Actor FlagActor)
{
	if ( GameObject(FlagActor) != None )
		HoldGameObject(GameObject(FlagActor),GameObject(FlagActor).GameObjBone);
}

function HoldGameObject(GameObject gameObj, name GameObjBone)
{
	if ( GameObjBone == 'None' )
	{
		GameObj.SetPhysics(PHYS_Rotating);
		GameObj.SetLocation(Location);
		GameObj.SetBase(self);
		GameObj.SetRelativeLocation(vect(0,0,0));
	}
	else
	{
		AttachToBone(gameObj,GameObjBone);
		gameObj.SetRelativeRotation(GameObjRot + gameObj.GameObjRot);
		gameObj.SetRelativeLocation(GameObjOffset + gameObj.GameObjOffset );
	}
}

function EndJump();	// Called when stop jumping

simulated function ShouldUnCrouch();

function String GetDebugName()
{
	if ( (Bot(Controller) != None) && Bot(Controller).bSoaking && (Level.Pauser != None) )
		return GetHumanReadableName()@Bot(Controller).SoakString;
	if ( PlayerReplicationInfo != None )
		return PlayerReplicationInfo.PlayerName;
	return GetItemName(string(self));
}

/* IsInLoadout()
return true if InventoryClass is part of required or optional equipment
*/
function bool IsInLoadout(class<Inventory> InventoryClass)
{
	//MergeTODO: Write proper RO specific functionality for this
	return true;
/*	local int i;
	local string invstring;

	if ( bAcceptAllInventory )
		return true;

	invstring = string(InventoryClass);

	for ( i=0; i<16; i++ )
	{
		if ( RequiredEquipment[i] ~= invstring )
			return true;
		else if ( RequiredEquipment[i] == "" )
			break;
	}

	for ( i=0; i<16; i++ )
	{
		if ( OptionalEquipment[i] ~= invstring )
			return true;
		else if ( OptionalEquipment[i] == "" )
			break;
	}
	return false; */
}

function CreateInventory(string InventoryClassName)
{
	local Inventory Inv;
	local class<Inventory> InventoryClass;

	InventoryClass = Level.Game.BaseMutator.GetInventoryClass(InventoryClassName);
	if( (InventoryClass!=None) && (FindInventoryType(InventoryClass)==None) )
	{
		Inv = Spawn(InventoryClass);
		if( Inv != None )
		{
			Inv.GiveTo(self);
			if ( Inv != None )
				Inv.PickupFunction(self);
		}
	}
}

function SetMovementPhysics()
{
	if (Physics == PHYS_Falling)
		return;
	if ( PhysicsVolume.bWaterVolume )
		SetPhysics(PHYS_Swimming);
	else
		SetPhysics(PHYS_Walking);
}

function TakeDrowningDamage()
{
	TakeDamage(5, None, Location + CollisionHeight * vect(0,0,0.5)+ 0.7 * CollisionRadius * vector(Controller.Rotation), vect(0,0,0), class'Drowned');
}

function int GetSpree()
{
	return spree;
}

function IncrementSpree()
{
	spree++;
}

simulated function PlayFootStep(int Side)
{
	if ( (Role==ROLE_SimulatedProxy) || (PlayerController(Controller) == None) || PlayerController(Controller).bBehindView )
	{
		FootStepping(Side);
		return;
	}
}

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

/*
Pawn was killed - detach any controller, and die
*/
simulated function ChunkUp( Rotator HitRotation, float ChunkPerterbation )
{
	if ( (Level.NetMode != NM_Client) && (Controller != None) )
	{
		if ( Controller.bIsPlayer )
			Controller.PawnDied(self);
		else
			Controller.Destroy();
	}

	bTearOff = true;
	HitDamageType = class'Gibbed'; // make sure clients gib also
	if ( (Level.NetMode == NM_DedicatedServer) || (Level.NetMode == NM_ListenServer) )
		GotoState('TimingOut');
	if ( Level.NetMode == NM_DedicatedServer )
		return;
	if ( class'GameInfo'.static.UseLowGore() )
	{
		Destroy();
		return;
	}
	SpawnGibs(HitRotation,ChunkPerterbation);

	if ( Level.NetMode != NM_ListenServer )
		Destroy();
}

/* TimingOut - where gibbed pawns go to die (delay so they can get replicated)
*/
state TimingOut
{
ignores BaseChange, Landed, AnimEnd, Trigger, Bump, HitWall, HeadVolumeChange, PhysicsVolumeChange, Falling, BreathTimer;

	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
							Vector momentum, class<DamageType> damageType, optional int HitIndex)
	{
	}

	function BeginState()
	{
		SetPhysics(PHYS_None);
		SetCollision(false,false,false);
		LifeSpan = 1.0;
		if ( Controller != None )
		{
			if ( Controller.bIsPlayer )
				Controller.PawnDied(self);
			else
				Controller.Destroy();
		}
	}
}


/*==========================================
* Xpawn functions
*=========================================*/
simulated function PlayWaiting() {}

function RosterEntry GetPlacedRoster()
{
	PlayerReplicationInfo.CharacterName = PlacedCharacterName;
	return class'RORosterEntry'.static.CreateRosterEntryCharacter(PlacedCharacterName);
}

// return true if was controlled by a Player (AI or human)
simulated function bool WasPlayerPawn()
{
	return ( (OldController != None) && OldController.bIsPlayer );
}

// Set up default blending parameters and pose. Ensures the mesh doesn't have only a T-pose whenever it first springs into view.
simulated function AssignInitialPose()
{
    if ( DrivenVehicle != None )
    {
		if ( HasAnim(DrivenVehicle.DriveAnim) )
			LoopAnim(DrivenVehicle.DriveAnim,, 0.1);
		else
			LoopAnim('Vehicle_Driving',, 0.1);
	}
	else
		TweenAnim(MovementAnims[0],0.0);
	AnimBlendParams(1, 1.0, 0.2, 0.2, 'Bip01_Spine1');
    BoneRefresh();
}

function DeactivateSpawnProtection()
{
	if ( bSpawnDone )
		return;
	bSpawnDone = true;
	if ( Level.TimeSeconds - SpawnTime < DeathMatch(Level.Game).SpawnProtectionTime )
	{
		SpawnTime = Level.TimeSeconds - DeathMatch(Level.Game).SpawnProtectionTime - 1;
	}
}

function PlayMoverHitSound()
{
	//PlaySound(SoundGroupClass.static.GetHitSound(), SLOT_Interact);
}

function Gasp()
{
    if ( Role != ROLE_Authority )
        return;
    //if ( BreathTime < 2 )
        //PlaySound(GetSound(EST_Gasp), SLOT_Interact);
    //else
        //PlaySound(GetSound(EST_BreatheAgain), SLOT_Interact);
}

function Controller GetKillerController()
{
	if ( Controller != None )
		return Controller;
	if ( OldController != None )
		return OldController;
	return None;
}

simulated function int GetTeamNum()
{
	if ( Controller != None )
		return Controller.GetTeamNum();
	if ( (DrivenVehicle != None) && (DrivenVehicle.Controller != None) )
		return DrivenVehicle.Controller.GetTeamNum();
	if ( OldController != None )
		return OldController.GetTeamNum();
	if ( (PlayerReplicationInfo == None) || (PlayerReplicationInfo.Team == None) )
		return 255;
	return PlayerReplicationInfo.Team.TeamIndex;
}

function TeamInfo GetTeam()
{
	if ( PlayerReplicationInfo != None )
		return PlayerReplicationInfo.Team;
	if ( (DrivenVehicle != None) && (DrivenVehicle.PlayerReplicationInfo != None) )
		return DrivenVehicle.PlayerReplicationInfo.Team;
	if ( (OldController != None) && (OldController.PlayerReplicationInfo != None) )
		return OldController.PlayerReplicationInfo.Team;
	return None;
}

simulated function AttachEffect( class<Emitter> EmitterClass, Name BoneName, Vector Location, Rotator Rotation )
{
    local Actor a;
    local int i;

    if( BoneName == 'None' )
        return;

    for( i = 0; i < Attached.Length; i++ )
    {
        if( Attached[i] == None )
            continue;

        if( Attached[i].AttachmentBone != BoneName )
            continue;

        if( ClassIsChildOf( EmitterClass, Attached[i].Class ) )
            return;
    }

    a = Spawn( EmitterClass,,, Location, Rotation );

    if( !AttachToBone( a, BoneName ) )
    {
        log( "Couldn't attach "$EmitterClass$" to "$BoneName, 'Error' );
        a.Destroy();
        return;
    }

    for( i = 0; i < Attached.length; i++ )
    {
        if( Attached[i] == a )
            break;
    }

    a.SetRelativeRotation( Rotation );
}

simulated event SetHeadScale(float NewScale)
{
	HeadScale = NewScale;
	SetBoneScale(4,HeadScale,'head');
}

simulated function SpawnGiblet( class<SeveredAppendage> GibClass, Vector Location, Rotator Rotation, float GibPerterbation )
{
    local SeveredAppendage Giblet;
    local Vector Direction, Dummy;

    if( (GibClass == None) || class'GameInfo'.static.UseLowGore() )
        return;

	Instigator = self;
    Giblet = Spawn( GibClass,,, Location, Rotation );
    if( Giblet == None )
        return;
	Giblet.SpawnTrail();

    GibPerterbation *= 32768.0;
    Rotation.Pitch += ( FRand() * 2.0 * GibPerterbation ) - GibPerterbation;
    Rotation.Yaw += ( FRand() * 2.0 * GibPerterbation ) - GibPerterbation;
    Rotation.Roll += ( FRand() * 2.0 * GibPerterbation ) - GibPerterbation;

    GetAxes( Rotation, Dummy, Dummy, Direction );

    Giblet.Velocity = Velocity + Normal(Direction) * (Giblet.MaxSpeed + (Giblet.MaxSpeed/2) * FRand());
    Giblet.LifeSpan = self.RagdollLifeSpan;
}

simulated function HideBone(name boneName)
{
	local int BoneScaleSlot;

    if( boneName == 'lthigh' )
    {
		boneScaleSlot = 0;
		if( SeveredLeftLeg == none )
		{
			SeveredLeftLeg = Spawn(SeveredLegAttachClass,self);
			AttachToBone(SeveredLeftLeg, 'lupperthigh');
		}
	}
	else if ( boneName == 'rthigh' )
	{
		boneScaleSlot = 1;
		if( SeveredRightLeg == none )
		{
			SeveredRightLeg = Spawn(SeveredLegAttachClass,self);
			AttachToBone(SeveredRightLeg, 'rupperthigh');
		}
	}
	else if( boneName == 'rfarm' )
	{
		boneScaleSlot = 2;
		if( SeveredRightArm == none )
		{
			SeveredRightArm = Spawn(SeveredArmAttachClass,self);
			AttachToBone(SeveredRightArm, 'rupperarm');
		}
	}
	else if ( boneName == 'lfarm' )
	{
		boneScaleSlot = 3;
		if( SeveredLeftArm == none )
		{
			SeveredLeftArm = Spawn(SeveredArmAttachClass,self);
			AttachToBone(SeveredLeftArm, 'lupperarm');
		}
	}
	else if ( boneName == 'head' )
	{
		boneScaleSlot = 4;
		if( SeveredHead == none )
		{
			SeveredHead = Spawn(SeveredHeadAttachClass,self);
			AttachToBone(SeveredHead, 'Bip01_Neck');
		}
	}
	else if ( boneName == 'spine' )
		boneScaleSlot = 5;

    SetBoneScale(BoneScaleSlot, 0.0, BoneName);
}

// MergeTODO: This needs to be replaced with our more precise system
function CalcHitLoc( Vector hitLoc, Vector hitRay, out Name boneName, out float dist )
{
    boneName = GetClosestBone( hitLoc, hitRay, dist );
}

simulated function SetOverlayMaterial( Material mat, float time, bool bOverride )
{
	if ( Level.bDropDetail || Level.DetailMode == DM_Low )
		time *= 0.75;
	Super.SetOverlayMaterial(mat,time,bOverride);
}

function bool CheckReflect( Vector HitLocation, out Vector RefNormal, int Damage )
{
    if (Weapon != None)
        return Weapon.CheckReflect( HitLocation, RefNormal, Damage );
    else
        return false;
}

function name GetOffhandBoneFor(Inventory I)
{
     return 'bip01 l hand';
}

// ----- animation ----- //

simulated function name GetAnimSequence()
{
    local name anim;
    local float frame, rate;

    GetAnimParams(0, anim, frame, rate);
    return anim;
}

function PlayWeaponSwitch(Weapon NewWeapon)
{
    SetAnimAction('stand_draw_kar');
}

// Need to override to support weapons on the back
function ServerChangedWeapon(Weapon OldWeapon, Weapon NewWeapon)
{
	local PlayerController PC;

    PC = PlayerController(Controller);

 	// New weapon switching code

	// For offline or when your running a listen server and your not watching yourself in third person
	// Just switch the attachment, don't worry about playing all the third person player stuff.
	// That was borking up the first person weapon switches
	if( PC != none && !PC.bBehindView && IsLocallyControlled() && Level.Netmode != NM_DedicatedServer )
	{
	    Weapon = NewWeapon;

	    if ( Controller != None )
			Controller.ChangedWeapon();

	    PendingWeapon = None;

		if ( OldWeapon != None )
		{
			if( OldWeapon.bCanAttachOnBack )
			{
				if( AttachedBackItem != none )
				{
					AttachedBackItem.Destroy();
					AttachedBackItem = None;
				}

		        AttachedBackItem = Spawn(class 'BackAttachment',self);
		        AttachedBackItem.InitFor(OldWeapon);
		        AttachToBone(AttachedBackItem,AttachedBackItem.AttachmentBone);
	        }

			OldWeapon.SetDefaultDisplayProperties();
			OldWeapon.DetachFromPawn(self);
	        OldWeapon.GotoState('Hidden');
	        OldWeapon.NetUpdateFrequency = 2;
		}

		if ( Weapon != None )
		{
			if( AttachedBackItem != none && AttachedBackItem.InventoryClass == Weapon.Class)
			{
				AttachedBackItem.Destroy();
				AttachedBackItem = None;
			}

		    Weapon.NetUpdateFrequency = 100;
			Weapon.AttachToPawn(self);
			Weapon.BringUp(OldWeapon);
	        PlayWeaponSwitch(NewWeapon);
		}

		if ( Inventory != None )
			Inventory.OwnerEvent('ChangedWeapon'); // tell inventory that weapon changed (in case any effect was being applied)
	}
	else
	{
		if( OldWeapon != none )
		{
			// If we are already in state PutWeaponAway, exit that state and then switch
			// to this new weapon
			if( IsInState('PutWeaponAway') )
			{
				GotoState('');

				PendingWeapon = NewWeapon;

				GotoState('PutWeaponAway');
			}
			else
			{
				PendingWeapon = NewWeapon;
			    GotoState('PutWeaponAway');
		    }
	    }
	// end new stuff
	    else
	    {
		    Weapon = NewWeapon;

		    if ( Controller != None )
				Controller.ChangedWeapon();

		    PendingWeapon = None;

			if ( OldWeapon != None )
			{
				OldWeapon.SetDefaultDisplayProperties();
				OldWeapon.DetachFromPawn(self);
		        OldWeapon.GotoState('Hidden');
		        OldWeapon.NetUpdateFrequency = 2;
			}

			if ( Weapon != None )
			{
				if( AttachedBackItem != none && AttachedBackItem.InventoryClass == Weapon.Class)
				{
					AttachedBackItem.Destroy();
					AttachedBackItem = None;
				}

			    Weapon.NetUpdateFrequency = 100;
				Weapon.AttachToPawn(self);
				Weapon.BringUp(OldWeapon);
		        PlayWeaponSwitch(NewWeapon);
			}

			if ( Inventory != None )
				Inventory.OwnerEvent('ChangedWeapon'); // tell inventory that weapon changed (in case any effect was being applied)
		}
	}
}

// Not sure if we need this, its the same as the super, but keep here until the weapon switching code is final
// Just changed to pendingWeapon
simulated function ChangedWeapon()
{
    local Weapon OldWeapon;

    ServerChangedWeapon(Weapon, PendingWeapon);
    if (Role < ROLE_Authority)
	{
       	// When switching weapons, don't let the client attempt to fire until the switch is complete
        if( Weapon != none )
		{
			bPreventWeaponFire = true;
        }

        OldWeapon = Weapon;
        Weapon = PendingWeapon;
		PendingWeapon = None;
		if ( Controller != None )
			Controller.ChangedWeapon();

        if (Weapon != None)
		    Weapon.BringUp(OldWeapon);
    }
}

// Handles creating the back attachment if the weapon should go on the back
// as well as playing the proper draw/put away anims for the weapons that are being switched
state PutWeaponAway
{
    simulated function Timer()
	{
		GotoState('');
	}

	simulated function BeginState()
	{
		local name Anim;

		bPreventWeaponFire = true;

		// Put the weapon down on the server as well as the client
		if( Level.NetMode == NM_DedicatedServer && Weapon != none)
		{
			Weapon.PutDown();
		}

		// select the proper animation to play based on what the player is holding
		// Weapon could be none because it might have been destroyed before getting here (nades, faust, etc)
    	if( Weapon != none )
    	{
	 		if( Weapon.IsA('ROExplosiveWeapon') || Weapon.IsA('BinocularsItem') )
			{
	    		if( bIsCrawling )
	    		{
	    			Anim = 'prone_putaway_nade';
	    		}
	    		else
	    		{
	    			Anim = 'stand_putaway_nade';
	    		}
			}
			else if( (Weapon.IsA('ROBoltActionWeapon') || Weapon.IsA('ROAutoWeapon') ||
				Weapon.IsA('ROSemiAutoWeapon')))
			{
	    		if( bIsCrawling )
	    		{
	    			Anim = 'prone_putaway_kar';
	    		}
	    		else
	    		{
	    			Anim = 'stand_putaway_kar';
	    		}
			}
			else if( Weapon.IsA('ROPistolWeapon'))
			{
	    		if( bIsCrawling )
	    		{
	    			Anim = 'prone_putaway_pistol';
	    		}
	    		else
	    		{
	    			Anim = 'stand_putaway_pistol';
	    		}
			}
			else
			{
				// Default in case there is no anim
	    		if( bIsCrawling )
	    		{
	    			Anim = 'prone_putaway_kar';
	    		}
	    		else
	    		{
	    			Anim = 'stand_putaway_kar';
	    		}
			}
    	}
    	else
    	{
			// TODO: Need a put away empty anim
    		if( bIsCrawling )
    		{
    			Anim = 'prone_putaway_kar';
    		}
    		else
    		{
    			Anim = 'stand_putaway_kar';
    		}
    	}

        // Handle the inventory side of swapping the weapon, not the visual side
		SwapWeapon = Weapon;

    	if ( Weapon != None )
    	{
            Weapon.GotoState('Hidden');
            Weapon.NetUpdateFrequency = 2;
    	}

		Weapon = PendingWeapon;

	    if ( Controller != None )
			Controller.ChangedWeapon();

		PendingWeapon = None;

		if ( Weapon != None )
		{
		    Weapon.NetUpdateFrequency = 100;
		    Weapon.AttachToPawnHidden(self);
			Weapon.BringUp(SwapWeapon);
		}

        if( !Weapon.IsA('ROExplosiveWeapon') )
        {
			bPreventWeaponFire = false;
		}

		if ( Inventory != none )
			Inventory.OwnerEvent('ChangedWeapon'); // tell inventory that weapon changed (in case any effect was being applied)

		SetTimer(GetAnimDuration(Anim, 1.0) + 0.1,false);

        SetAnimAction(Anim);
	}

	simulated function EndState()
	{
		local name Anim;

    	if ( SwapWeapon != None )
    	{

    		if( SwapWeapon.bCanAttachOnBack )
    		{
    			if( AttachedBackItem != none )
    			{
    				AttachedBackItem.Destroy();
    				AttachedBackItem = None;
    			}

    	        AttachedBackItem = Spawn(class 'BackAttachment',self);
    	        AttachedBackItem.InitFor(SwapWeapon);
    	        AttachToBone(AttachedBackItem,AttachedBackItem.AttachmentBone);
            }

			SwapWeapon.SetDefaultDisplayProperties();
    		SwapWeapon.DetachFromPawn(self);
    	}

        // select the proper animation to play based on what the player is holding and
        // what weapon they are switching to

    	// From grenade or binocs to rifle
    	if( SwapWeapon == none )
    	{
    		// TODO: Need a put away empty anim
    		if( bIsCrawling )
    		{
    			Anim = 'prone_draw_kar';
    		}
    		else
    		{
    			Anim = 'stand_draw_kar';
    		}
    	}
    	else if( Weapon == none )
    	{
    		if( bIsCrawling )
    		{
    			Anim = 'prone_nadeFromRifle';
    		}
    		else
    		{
    			Anim = 'stand_nadefromrifle';
    		}
    	}
    	else if( ( SwapWeapon.IsA('ROExplosiveWeapon') || SwapWeapon.IsA('BinocularsItem') )&&
    		(Weapon.IsA('ROBoltActionWeapon') || Weapon.IsA('ROAutoWeapon') ||
    		 Weapon.IsA('ROSemiAutoWeapon')) )
    	{
    		if( bIsCrawling )
    		{
    			Anim = 'prone_rifleFromNade';
    		}
    		else
    		{
    			Anim = 'stand_riflefromnade';
    		}
    	}
    	// from rifle to grenade or binocs
    	else if( (SwapWeapon.IsA('ROBoltActionWeapon') || SwapWeapon.IsA('ROAutoWeapon') ||
    		SwapWeapon.IsA('ROSemiAutoWeapon')) && (Weapon.IsA('ROExplosiveWeapon') ||
    		Weapon.IsA('BinocularsItem')))
    	{
    		if( bIsCrawling )
    		{
    			Anim = 'prone_nadeFromRifle';
    		}
    		else
    		{
    			Anim = 'stand_nadefromrifle';
    		}
    	}
    	// from pistol to rifle
    	else if( SwapWeapon.IsA('ROPistolWeapon') && (Weapon.IsA('ROBoltActionWeapon') ||
    		Weapon.IsA('ROAutoWeapon') || Weapon.IsA('ROSemiAutoWeapon')))
    	{
    		if( bIsCrawling )
    		{
    			Anim = 'prone_riflefrompistol';
    		}
    		else
    		{
    			Anim = 'stand_riflefrompistol';
    		}
    	}
    	// from rifle to pistol
    	else if( (SwapWeapon.IsA('ROBoltActionWeapon') || SwapWeapon.IsA('ROAutoWeapon') ||
    		SwapWeapon.IsA('ROSemiAutoWeapon')) && Weapon.IsA('ROPistolWeapon'))
    	{
    		if( bIsCrawling )
    		{
    			Anim = 'prone_pistolfromrifle';
    		}
    		else
    		{
    			Anim = 'stand_pistolfromrifle';
    		}
    	}
    	// from pistol to grenade or binocs
    	else if( SwapWeapon.IsA('ROPistolWeapon') && (Weapon.IsA('ROExplosiveWeapon') ||
    		Weapon.IsA('BinocularsItem')))
    	{
    		if( bIsCrawling )
    		{
    			Anim = 'prone_nadefrompistol';
    		}
    		else
    		{
    			Anim = 'stand_nadefrompistol';
    		}
    	}
    	// from grenade or binocs to pistol
    	else if( ( SwapWeapon.IsA('ROExplosiveWeapon') || SwapWeapon.IsA('BinocularsItem')) &&
    		Weapon.IsA('ROPistolWeapon') )
    	{
    		if( bIsCrawling )
    		{
    			Anim = 'prone_pistolfromnade';
    		}
    		else
    		{
    			Anim = 'stand_pistolfromnade';
    		}
    	}
    	// from grenade or binocs, to grenade or binocs
    	else if( ( SwapWeapon.IsA('ROExplosiveWeapon') || SwapWeapon.IsA('BinocularsItem')) &&
    		(Weapon.IsA('ROExplosiveWeapon') || Weapon.IsA('BinocularsItem') ) )
    	{
    		// TODO: Need a real anim here
    		if( bIsCrawling )
    		{
    			Anim = 'prone_draw_nade';
    		}
    		else
    		{
    			Anim = 'stand_draw_nade';
    		}
    	}
    	else
    	{
    		// Default in case there is no anim
    		if( bIsCrawling )
    		{
    			Anim = 'prone_draw_kar';
    		}
    		else
    		{
    			Anim = 'stand_draw_kar';
    		}
    	}

    	SetAnimAction(Anim);

		if ( Weapon != None )
		{
			if( AttachedBackItem != none && AttachedBackItem.InventoryClass == Weapon.Class)
			{
				AttachedBackItem.Destroy();
				AttachedBackItem = None;
			}

			//Weapon.AttachToPawn(self);
			// unhide the weapon now
			if( Weapon.ThirdPersonActor != none )
				Weapon.ThirdPersonActor.bHidden = false;
			else
				Weapon.AttachToPawn(self);
		}

        SwapWeapon = none;

        bPreventWeaponFire = false;
	}
}

simulated final function RandSpin(float spinRate)
{
    DesiredRotation = RotRand(true);
    RotationRate.Yaw = spinRate * 2 *FRand() - spinRate;
    RotationRate.Pitch = spinRate * 2 *FRand() - spinRate;
    RotationRate.Roll = spinRate * 2 *FRand() - spinRate;

    bFixedRotationDir = true;
    bRotateToDesired = false;
}

function PlayDyingAnimation(class<DamageType> DamageType, vector HitLoc)
{
	local vector shotDir, hitLocRel, deathAngVel, shotStrength;
	local float maxDim;
	local string RagSkelName;
	local KarmaParamsSkel skelParams;
	local bool PlayersRagdoll;
	local PlayerController pc;

	if ( Level.NetMode != NM_DedicatedServer )
	{
		// Is this the local player's ragdoll?
		if(OldController != None)
			pc = PlayerController(OldController);
		if( pc != None && pc.ViewTarget == self )
			PlayersRagdoll = true;

		if( FRand() < 0.3 )
		{
			HelmetShotOff(Rotator(Normal(GetTearOffMomemtum())));
		}

		// In low physics detail, if we were not just controlling this pawn,
		// and it has not been rendered in 3 seconds, just destroy it.
		if( (Level.PhysicsDetailLevel != PDL_High) && !PlayersRagdoll && (Level.TimeSeconds - LastRenderTime > 3) )
		{
			Destroy();
			return;
		}

		// Try and obtain a rag-doll setup. Use optional 'override' one out of player record first, then use the species one.
		if( RagdollOverride != "")
			RagSkelName = RagdollOverride;
		else if(Species != None)
			RagSkelName = Species.static.GetRagSkelName( GetMeshName() );
		else
			Log("xPawn.PlayDying: No Species");

		// If we managed to find a name, try and make a rag-doll slot availbale.
		if( RagSkelName != "" )
		{
			KMakeRagdollAvailable();
		}

		if( KIsRagdollAvailable() && RagSkelName != "" )
		{
			skelParams = KarmaParamsSkel(KParams);
			skelParams.KSkeleton = RagSkelName;

			// Stop animation playing.
			StopAnimating(true);

			if( DamageType != None )
			{
				if ( DamageType.default.bLeaveBodyEffect )
					TearOffMomentum = vect(0,0,0);

				if( DamageType.default.bKUseOwnDeathVel )
				{
					RagDeathVel = DamageType.default.KDeathVel;
					RagDeathUpKick = DamageType.default.KDeathUpKick;
					RagShootStrength = DamageType.default.KDamageImpulse;
				}
			}

			// Set the dude moving in direction he was shot in general
			shotDir = Normal(GetTearOffMomemtum());
			shotStrength = RagDeathVel * shotDir;

			// Calculate angular velocity to impart, based on shot location.
			hitLocRel = TakeHitLocation - Location;



			if( DamageType.default.bLocationalHit )
			{
				hitLocRel.X *= RagSpinScale;
				hitLocRel.Y *= RagSpinScale;

				if( Abs(hitLocRel.X)  > RagMaxSpinAmount )
				{
					if( hitLocRel.X < 0 )
					{
						hitLocRel.X = FMax((hitLocRel.X * RagSpinScale), (RagMaxSpinAmount * -1));
					}
					else
					{
						hitLocRel.X = FMin((hitLocRel.X * RagSpinScale), RagMaxSpinAmount);
					}
				}

				if( Abs(hitLocRel.Y)  > RagMaxSpinAmount )
				{
					if( hitLocRel.Y < 0 )
					{
						hitLocRel.Y = FMax((hitLocRel.Y * RagSpinScale), (RagMaxSpinAmount * -1));
					}
					else
					{
						hitLocRel.Y = FMin((hitLocRel.Y * RagSpinScale), RagMaxSpinAmount);
					}
				}

			}
			else
			{
				// We scale the hit location out sideways a bit, to get more spin around Z.
				hitLocRel.X *= RagSpinScale;
				hitLocRel.Y *= RagSpinScale;
			}

			//log("hitLocRel.X = "$hitLocRel.X$" hitLocRel.Y = "$hitLocRel.Y);
			//log("TearOffMomentum = "$VSize(GetTearOffMomemtum()));

			// If the tear off momentum was very small for some reason, make up some angular velocity for the pawn
			if( VSize(GetTearOffMomemtum()) < 0.01 )
			{
				//Log("TearOffMomentum magnitude of Zero");
				deathAngVel = VRand() * 18000.0;
			}
			else
			{
				deathAngVel = RagInvInertia * (hitLocRel cross shotStrength);
			}

    		// Set initial angular and linear velocity for ragdoll.
			// Scale horizontal velocity for characters - they run really fast!
			if ( DamageType.Default.bRubbery )
				skelParams.KStartLinVel = vect(0,0,0);
			if ( Damagetype.default.bKUseTearOffMomentum )
				skelParams.KStartLinVel = GetTearOffMomemtum() + Velocity;
			else
			{
				skelParams.KStartLinVel.X = 0.6 * Velocity.X;
				skelParams.KStartLinVel.Y = 0.6 * Velocity.Y;
				skelParams.KStartLinVel.Z = 1.0 * Velocity.Z;
    				skelParams.KStartLinVel += shotStrength;
			}
			// if not moving downwards - give extra upward kick
			if( !DamageType.default.bLeaveBodyEffect && !DamageType.Default.bRubbery && (Velocity.Z > -10) )
				skelParams.KStartLinVel.Z += RagDeathUpKick;

			if ( DamageType.Default.bRubbery )
			{
				Velocity = vect(0,0,0);
    			skelParams.KStartAngVel = vect(0,0,0);
    		}
			else
			{
    			skelParams.KStartAngVel = deathAngVel;

    			// Set up deferred shot-bone impulse
				maxDim = Max(CollisionRadius, CollisionHeight);

    			skelParams.KShotStart = TakeHitLocation - (1 * shotDir);
    			skelParams.KShotEnd = TakeHitLocation + (2*maxDim*shotDir);
    			skelParams.KShotStrength = RagShootStrength;
			}

			//log("RagDeathVel = "$RagDeathVel$" KShotStrength = "$skelParams.KShotStrength$" RagDeathUpKick = "$RagDeathUpKick);

    		// If this damage type causes convulsions, turn them on here.
    		if(DamageType != none && DamageType.default.bCauseConvulsions)
    		{
    			RagConvulseMaterial=DamageType.default.DamageOverlayMaterial;
    			skelParams.bKDoConvulsions = true;
		    }

    		// Turn on Karma collision for ragdoll.
			KSetBlockKarma(true);

			// Set physics mode to ragdoll.
			// This doesn't actaully start it straight away, it's deferred to the first tick.
			SetPhysics(PHYS_KarmaRagdoll);

			// If viewing this ragdoll, set the flag to indicate that it is 'important'
			if( PlayersRagdoll )
				skelParams.bKImportantRagdoll = true;

			skelParams.KActorGravScale = RagGravScale;

			return;
		}
		// jag
	}

	// non-ragdoll death fallback
	Velocity += GetTearOffMomemtum();
    BaseEyeHeight = Default.BaseEyeHeight;
    SetTwistLook(0, 0);
    // We don't do this - Ramm
    //PlayDirectionalDeath(HitLoc);
    SetPhysics(PHYS_Falling);
}

// Apply karma from client side explosions to a ragdoll for a dead pawn
simulated function DeadExplosionKarma(class<DamageType> DamageType, vector Momentum, float Strength)
{
    local Vector shotDir;
    local Vector PushLinVel, PushAngVel;

	if( (RagdollLifeSpan - LifeSpan) < 1.0 )
	{
		return;
	}

	if ( Level.NetMode != NM_DedicatedServer )
	{
		if ( class'GameInfo'.static.UseLowGore() )
			return;

		if( DamageType != none )
		{
			if( DamageType.default.bKUseOwnDeathVel )
			{
				RagDeathVel = DamageType.default.KDeathVel;
				RagDeathUpKick = DamageType.default.KDeathUpKick;
				RagShootStrength = DamageType.default.KDamageImpulse;
			}
		}


		shotDir = Normal(Momentum);
	    PushLinVel = (RagDeathVel * shotDir);
	    PushLinVel.Z += RagDeathUpKick*(RagShootStrength*DamageType.default.KDeadLinZVelScale);

		PushAngVel = Normal(shotDir cross vect(0, 0, 1)) * -18000;
		PushAngVel *= RagShootStrength*DamageType.default.KDeadAngVelScale;

		PushLinVel *= Strength;
		PushAngVel *= Strength;

		KSetSkelVel( PushLinVel, PushAngVel );

		if ( DamageType.Default.DeathOverlayMaterial != None )
			SetOverlayMaterial(DamageType.Default.DeathOverlayMaterial, DamageType.default.DeathOverlayTime, true);
	}
}

// Maybe spawn some chunks when the player gets obliterated
simulated function SpawnGibs(Rotator HitRotation, float ChunkPerterbation)
{
	bGibbed = true;
	PlayDyingSound();

    if ( class'GameInfo'.static.UseLowGore() )
		return;

	if( ObliteratedEffectClass != none )
		Spawn( ObliteratedEffectClass,,, Location, HitRotation );

    if ( FRand() < 0.1 )
	{
		SpawnGiblet( DetachedLegClass, Location, HitRotation, ChunkPerterbation );
		SpawnGiblet( DetachedLegClass, Location, HitRotation, ChunkPerterbation );
		SpawnGiblet( DetachedArmClass, Location, HitRotation, ChunkPerterbation );
		SpawnGiblet( DetachedArmClass, Location, HitRotation, ChunkPerterbation );
	}
	else if ( FRand() < 0.25 )
	{
		SpawnGiblet( DetachedLegClass, Location, HitRotation, ChunkPerterbation );
		SpawnGiblet( DetachedLegClass, Location, HitRotation, ChunkPerterbation );
		if ( FRand() < 0.5 )
		{
			SpawnGiblet( DetachedArmClass, Location, HitRotation, ChunkPerterbation );
		}
	}
	else if ( FRand() < 0.35 )
		SpawnGiblet( DetachedLegClass, Location, HitRotation, ChunkPerterbation );
	else if ( FRand() < 0.5 )
	{
		SpawnGiblet( DetachedArmClass, Location, HitRotation, ChunkPerterbation );
	}
}

function ClientDying(class<DamageType> DamageType, vector HitLocation){}

function PlayTakeHit(vector HitLocation, int Damage, class<DamageType> DamageType)
{
    local vector direction;
    local rotator InvRotation;
    local float jarscale;
    // This doesn't really fit our system - Ramm
	//PlayDirectionalHit(HitLocation);

    if( Level.TimeSeconds - LastPainSound < MinTimeBetweenPainSounds )
        return;

    LastPainSound = Level.TimeSeconds;

    if( HeadVolume.bWaterVolume )
    {
        //if( DamageType.IsA('Drowned') )
            //PlaySound( GetSound(EST_Drown), SLOT_Pain,1.5*TransientSoundVolume );
        //else
            //PlaySound( GetSound(EST_HitUnderwater), SLOT_Pain,1.5*TransientSoundVolume );
        return;
    }

    // for standalone and client
    // Cooney
    if ( Level.NetMode != NM_DedicatedServer )
    {
       if ( class<ROWeaponDamageType>(DamageType) != none )
       {
           if (class<ROWeaponDamageType>(DamageType).default.bCauseViewJarring == true
              && ROPlayer(Controller) != none)
           {
               // Get the approximate direction
               // that the hit went into the body
               direction = self.Location - HitLocation;
               // No up-down jarring effects since
               // I dont have the barrel valocity
               direction.Z = 0.0f;
               direction = normal(direction);

               // We need to rotate the jarring direction
               // in screen space so basically the
               // exact opposite of the player's pawn's
               // rotation.
               InvRotation.Yaw = -Rotation.Yaw;
               InvRotation.Roll = -Rotation.Roll;
               InvRotation.Pitch = -Rotation.Pitch;
               direction = direction >> InvRotation;

               jarscale = 0.1f + (Damage/50.0f);
               if ( jarscale > 1.0f ) jarscale = 1.0f;

               ROPlayer(Controller).PlayerJarred(direction,jarscale);
           }
       }
    }

    PlayOwnedSound(SoundGroupClass.static.GetHitSound(DamageType), SLOT_Pain,3*TransientSoundVolume,,200);
}

// jag
// Called when in Ragdoll when we hit something over a certain threshold velocity
// Used to play impact sounds.
event KImpact(actor other, vector pos, vector impactVel, vector impactNorm)
{
	local float VelocitySquared;
	local float RagHitVolume;

	if(Level.TimeSeconds > RagLastSoundTime + RagImpactSoundInterval)
	{
    	VelocitySquared = VSizeSquared(impactVel);

		//log("Ragimpact velocity: "$VSize(impactVel)$" VelocitySquared: "$VelocitySquared);

		RagHitVolume = FMin(2.0,(VelocitySquared/40000));

		//log("RagHitVolume = "$RagHitVolume);

		//PlaySound(RagImpactSound, SLOT_None, RagHitVolume);
		RagLastSoundTime = Level.TimeSeconds;
	}
}
//jag

simulated function PlayFootStepLeft()
{
    PlayFootStep(-1);
}

simulated function PlayFootStepRight()
{
    PlayFootStep(1);
}

simulated function ClientRestart()
{
	Super.ClientRestart();
	if ( Controller != None )
		OldController = Controller;
}

// MergeTODO: Write some real code for this
simulated function bool ForceDefaultCharacter()
{

	//log("MergeTODO: Write some real code for ForceDefaultCharacter!!!");

	return false;
/*	local PlayerController P;

	if ( !class'DeathMatch'.default.bForceDefaultCharacter )
		return false;

	// validate and use player's model for enemies of same sex
	P = Level.GetLocalPlayerController();
	if ( (P != None) && (P.PlayerReplicationInfo != None) )
	{
		if ( P.PlayerReplicationInfo.bIsFemale )
		{
			PlacedFemaleCharacterName = P.PlayerReplicationInfo.CharacterName;
			if ( !CheckValidFemaleDefault() )
			{
				PlacedFemaleCharacterName = "Tamika";
				return false;
			}
		}
		else
		{
			PlacedCharacterName = P.PlayerReplicationInfo.CharacterName;
			if ( !CheckValidMaleDefault() )
			{
				PlacedCharacterName = "Jakob";
				return false;
			}
		}
	}
	return true;  */
}

// MergeTODO: Write some real code for this
simulated function string GetDefaultCharacter()
{
	//log("MergeTODO: Write some real code for GetDefaultCharacter!!!");

    return "FixmePlease";

/*	if ( Level.IsDemoBuild() )
	{
		PlacedFemaleCharacterName = "Tamika";
		PlacedCharacterName = "Jakob";
	}
	else
	{
		// make sure picking from valid default characters
		if ( !CheckValidFemaleDefault() )
			PlacedFemaleCharacterName = "Tamika";

		if ( !CheckValidMaleDefault() )
			PlacedCharacterName = "Jakob";
	}
	// return appropriate character based on this pawn's sex
	if ( (PlayerReplicationInfo != None) && PlayerReplicationInfo.bIsFemale )
		return PlacedFemaleCharacterName;
	else
		return PlacedCharacterName; */
}

// MergeTODO: Replace xUtil with ROUtil
simulated function Setup(xUtil.PlayerRecord rec, optional bool bLoadNow)
{
	if ( (rec.Species == None) || ForceDefaultCharacter() )
		rec = class'xUtil'.static.FindPlayerRecord(GetDefaultCharacter());

    Species = rec.Species;
	RagdollOverride = rec.Ragdoll;

	if ( !Species.static.Setup(self,rec) )
	{
		rec = class'xUtil'.static.FindPlayerRecord(GetDefaultCharacter());
		if ( !Species.static.Setup(self,rec) )
			return;
	}
	ResetPhysicsBasedAnim();
}

simulated function ResetPhysicsBasedAnim()
{
    bIsIdle = false;
    bWaitForAnim = false;
}

function Sound GetSound(ROPawnSoundGroup.ESoundType soundType)
{
	local int SurfaceTypeID;
	local actor A;
	local vector HL,HN,Start,End;
	local material FloorMat;

    if( soundType == EST_Land || soundType == EST_Jump )
	{
		if ( (Base!=None) && (!Base.IsA('LevelInfo')) && (Base.SurfaceType!=0) )
		{
			SurfaceTypeID = Base.SurfaceType;
		}
		else
		{
			Start = Location - Vect(0,0,1)*CollisionHeight;
			End = Start - Vect(0,0,16);
			A = Trace(hl,hn,End,Start,false,,FloorMat);
			if (FloorMat !=None)
				SurfaceTypeID = FloorMat.SurfaceType;
		}
	}

    return SoundGroupClass.static.GetSound(soundType, SurfaceTypeID);
}

// End Xpawn functions

//Lean functions
simulated function bool TraceWall(int Direction, float CheckDist)
{
	local actor HitActor;
	local vector HitLocation, HitNormal, TraceStart, TraceEnd;
	local rotator Angle;

	Angle.Yaw=Direction;

	TraceStart=Location;
	TraceStart.Z+=BaseEyeHeight;
	TraceEnd=TraceStart+vector(Rotation+Angle)*CheckDist;

	HitActor=Trace(HitLocation, HitNormal, TraceEnd, TraceStart, true);

	if ( HitActor != None )
		return true;

	return false;
}

simulated function TickLean(float DeltaTime)
{
    if( Role > ROLE_SimulatedProxy )
    {
		//If theres a wall to the side of the lean can't be leaning
		if (bLeanLeft && TraceWall(-16384, 64))
			bLeanLeft = false;

		if (bLeanRight && TraceWall(16384, 64))
			bLeanRight = false;

		if ( bIsSprinting )
		{
			bLeanLeft = false;
			bLeanRight = false;
		}
	}

	//Return from leaning right to center
	if ( bLeaningRight && !bLeanRight )
	{
		LeanAmount -= LeanFactor * deltatime;
		if ( LeanAmount < 0 )
		{
			LeanAmount = 0;
			bLeaningRight=false;
		}
	}
	//Leaning right
	else if ( bLeanRight )
	{
		if ( abs(LeanAmount) < LeanMax )
			LeanAmount += LeanFactor * deltatime;
		else if ( abs(LeanAmount) >= LeanMax )
			LeanAmount = LeanMax;
		bLeaningRight=true;
	}
	//Returning from lean left to center
	if (bLeaningLeft && !bLeanLeft)
	{
		LeanAmount += LeanFactor * deltatime;
		if ( LeanAmount > 0 )
		{
			LeanAmount = 0;
			bLeaningLeft=false;
		}
	}
	//Leaning left
	else if (bLeanLeft)
	{
		if ( abs(LeanAmount) < LeanMax )
			LeanAmount -= LeanFactor * deltatime;
		else if ( abs(LeanAmount) >= LeanMax )
			LeanAmount = -LeanMax;
		bLeaningLeft=true;
	}
}

simulated function LeanRight()
{
	if ( TraceWall(16384, 64) || bLeaningLeft || bIsSprinting )
	{
		bLeanRight=false;
		return;
	}

	if ( !bLeanLeft )
		bLeanRight=true;
}

simulated function LeanRightReleased()
{
	bLeanRight=false;
}

simulated function LeanLeft()
{
	if ( TraceWall(-16384, 64) || bLeaningRight || bIsSprinting )
	{
		bLeanLeft=false;
		return;
	}

	if ( !bLeanRight )
		bLeanLeft=true;
}

simulated function LeanLeftReleased()
{
	bLeanLeft=false;
}

function float ModifyThreat(float current, Pawn Threat)
{
	if (Vehicle(Threat) != None)
		current -= 2.0;
	else
		current += 0.5;
	return current;
}

defaultproperties
{
     bNoDefaultInventory=True
     bAcceptAllInventory=True
     bPlayOwnFootsteps=True
     AttackSuitability=0.500000
     SquadName="Squad"
     VoiceType="ROGame.ROGerman1Voice"
     bPlayerShadows=True
     Species=Class'ROEngine.ROSPECIES_Human'
     DeResTime=6.000000
     GruntVolume=0.180000
     FootstepVolume=0.500000
     MinTimeBetweenPainSounds=0.350000
     SoundGroupClass=Class'ROEngine.ROPawnSoundGroup'
     RagdollLifeSpan=30.000000
     RagInvInertia=4.000000
     RagDeathVel=100.000000
     RagShootStrength=200.000000
     RagSpinScale=7.500000
     RagMaxSpinAmount=100.000000
     RagGravScale=1.000000
     RagImpactSoundInterval=0.250000
     PlacedCharacterName="Soldier"
     FireRootBone="Bip01_Spine"
     SeveredArmAttachClass=Class'ROEffects.SeveredArmAttachment'
     SeveredLegAttachClass=Class'ROEffects.SeveredLegAttachment'
     SeveredHeadAttachClass=Class'ROEffects.SeveredHeadAttachment'
     BleedingEmitterClass=Class'ROEffects.ROBloodSpurt'
     ProjectileBloodSplatClass=Class'ROEffects.ProjectileBloodSplat'
     DetachedArmClass=Class'ROEffects.SeveredArm'
     DetachedLegClass=Class'ROEffects.SeveredLeg'
     ObliteratedEffectClass=Class'ROEffects.PlayerObliteratedEmitter'
     Stamina=20.000000
     JumpStaminaDrain=4.000000
     StaminaRecoveryRate=0.650000
     CrouchStaminaRecoveryRate=0.800000
     ProneStaminaRecoveryRate=1.000000
     SlowStaminaRecoveryRate=0.200000
     MomentumCurve=(Points=((InVal=400.000000),(InVal=625.000000,OutVal=1.250000),(InVal=2500.000000,OutVal=3.125000),(InVal=5625.000000,OutVal=6.250000),(InVal=1000000000.000000,OutVal=6.250000)))
     FrictionScale=0.543750
     PronePitchUpLimit=14000
     PronePitchDownLimit=51000
     CrawlingPitchUpLimit=14000
     CrawlingPitchDownLimit=60000
     CrawlPitchTweenRate=60000
     ProneIdleRestAnim="prone_idle_nade"
     CrouchIdleRestAnim="crouch_idle_nade"
     ProneAnims(0)="prone_crawlF_nade"
     ProneAnims(1)="prone_crawlB_nade"
     ProneAnims(2)="prone_crawlL_nade"
     ProneAnims(3)="prone_crawlR_nade"
     ProneAnims(4)="prone_crawlFL_nade"
     ProneAnims(5)="prone_crawlFR_nade"
     ProneAnims(6)="prone_crawlBL_nade"
     ProneAnims(7)="prone_crawlBR_nade"
     IdleProneAnim="prone_idle_nade"
     ProneTurnRightAnim="prone_turnR_binoc"
     ProneTurnLeftAnim="prone_turnL_binoc"
     StandToProneAnim="StandtoProne_nade"
     ProneToStandAnim="PronetoStand_nade"
     CrouchToProneAnim="CrouchtoProne_nade"
     ProneToCrouchAnim="PronetoCrouch_nade"
     DiveToProneStartAnim="prone_divef_nade"
     DiveToProneEndAnim="prone_diveend_nade"
     SprintAnims(0)="stand_sprintF_nade"
     SprintAnims(1)="stand_sprintB_nade"
     SprintAnims(2)="stand_sprintL_nade"
     SprintAnims(3)="stand_sprintR_nade"
     SprintAnims(4)="stand_sprintFL_nade"
     SprintAnims(5)="stand_sprintFR_nade"
     SprintAnims(6)="stand_sprintBL_nade"
     SprintAnims(7)="stand_sprintBR_nade"
     SprintCrouchAnims(0)="crouch_sprintF_nade"
     SprintCrouchAnims(1)="crouch_sprintB_nade"
     SprintCrouchAnims(2)="crouch_sprintL_nade"
     SprintCrouchAnims(3)="crouch_sprintR_nade"
     SprintCrouchAnims(4)="crouch_sprintFL_nade"
     SprintCrouchAnims(5)="crouch_sprintFR_nade"
     SprintCrouchAnims(6)="crouch_sprintBL_nade"
     SprintCrouchAnims(7)="crouch_sprintBR_nade"
     WalkIronAnims(0)="stand_walkFiron_binoc"
     WalkIronAnims(1)="stand_walkBiron_binoc"
     WalkIronAnims(2)="stand_walkLiron_binoc"
     WalkIronAnims(3)="stand_walkRiron_binoc"
     WalkIronAnims(4)="stand_walkFLiron_binoc"
     WalkIronAnims(5)="stand_walkFRiron_binoc"
     WalkIronAnims(6)="stand_walkBLiron_binoc"
     WalkIronAnims(7)="stand_walkBRiron_binoc"
     IdleIronRestAnim="stand_idleiron_binoc"
     IdleIronWeaponAnim="stand_idleiron_binoc"
     IdleCrouchIronWeaponAnim="crouch_idle_nade"
     TurnIronRightAnim="stand_turnRiron_binoc"
     TurnIronLeftAnim="stand_turnLiron_binoc"
     CrouchTurnIronRightAnim="crouch_turnRiron_binoc"
     CrouchTurnIronLeftAnim="crouch_turnLiron_binoc"
     LimpAnims(0)="stand_limpFhip_binoc"
     LimpAnims(1)="stand_limpBhip_binoc"
     LimpAnims(2)="stand_limpLhip_binoc"
     LimpAnims(3)="stand_limpRhip_binoc"
     LimpAnims(4)="stand_limpFLhip_binoc"
     LimpAnims(5)="stand_limpFRhip_binoc"
     LimpAnims(6)="stand_limpBLhip_binoc"
     LimpAnims(7)="stand_limpBRhip_binoc"
     LandRecoveryTime=1.500000
     CurrentCapArea=255
     SprintAccelRate=350.000000
     FootStepSoundRadius=125.000000
     QuietFootStepVolume=0.450000
     CrouchEyeHeightMod=0.300000
     CrouchMoveEyeHeightMod=0.770000
     ProneEyeHeight=5.000000
     ProneEyeDist=10.000000
     CameraBone="Camera_Bone"
     LeanMax=3000.000000
     LeanFactor=10000.000000
     LeanLViewOffset=(Y=-18.000000,Z=-8.000000)
     LeanRViewOffset=(Y=21.000000,Z=-14.000000)
     LeanLCrouchViewOffset=(Y=-14.000000,Z=-1.000000)
     LeanRCrouchViewOffset=(Y=17.000000,Z=-8.000000)
     LeanLProneViewOffset=(Y=-14.000000,Z=2.000000)
     LeanRProneViewOffset=(Y=17.000000,Z=1.000000)
     AnimPitchUpLimit=9000
     AnimPitchDownLimit=-14000
     ProneAnimPitchUpLimit=4500
     ProneAnimPitchDownLimit=-2000
     LeanBones(0)="Bip01_Spine"
     LeanBones(1)="Bip01_Spine1"
     LeanBones(2)="Bip01_Spine2"
     LeanBones(3)="Bip01_Spine3"
     LeanBones(4)="Bip01_Neck"
     LeanBones(5)="Bip01_Head"
     LeanBones(6)="ShovelCase01"
     LeanLeftStanding(0)=(Pitch=4850)
     LeanLeftStanding(1)=(Pitch=4850)
     LeanLeftStanding(6)=(Pitch=-3800)
     LeanRightStanding(0)=(Pitch=-6500)
     LeanRightStanding(1)=(Pitch=350)
     LeanRightStanding(6)=(Pitch=3000)
     LeanLeftCrouch(0)=(Pitch=6000)
     LeanLeftCrouch(1)=(Pitch=4000,Yaw=1000)
     LeanLeftCrouch(5)=(Pitch=-4000)
     LeanLeftCrouch(6)=(Pitch=-7000)
     LeanRightCrouch(0)=(Pitch=-3000)
     LeanRightCrouch(1)=(Pitch=-2800)
     LeanRightCrouch(5)=(Roll=-1000)
     LeanRightCrouch(6)=(Pitch=1300)
     LeanLeftProne(0)=(Pitch=2500,Yaw=6000,Roll=2500)
     LeanLeftProne(1)=(Pitch=4000,Yaw=-3000,Roll=-300)
     LeanLeftProne(5)=(Pitch=-2000)
     LeanLeftProne(6)=(Pitch=-1000,Yaw=-5000)
     LeanRightProne(0)=(Pitch=2000,Yaw=-4500,Roll=2000)
     LeanRightProne(1)=(Pitch=-7000,Yaw=3000,Roll=500)
     LeanRightProne(6)=(Pitch=-1500,Yaw=2000)
     DeployedPitchUpLimit=12000
     DeployedPitchDownLimit=-10000
     DeployedPositiveYawLimit=7300
     DeployedNegativeYawLimit=-7300
     NetSoundRadiusSquared=820000.000000
     bCanCrouch=True
     bCanSwim=True
     bCanClimbLadders=True
     bCanStrafe=True
     bCanDoubleJump=False
     bCanWalkOffLedges=True
     bNoCoronas=False
     bCanPickupInventory=True
     bMuffledHearing=True
     SightRadius=6000.000000
     MeleeRange=20.000000
     GroundSpeed=200.000000
     WaterSpeed=100.000000
     AirSpeed=70.000000
     LadderSpeed=75.000000
     AccelRate=300.000000
     JumpZ=315.000000
     AirControl=0.020000
     WalkingPct=0.350000
     CrouchedPct=0.300000
     MaxFallSpeed=650.000000
     BaseEyeHeight=42.000000
     EyeHeight=42.000000
     CrouchHeight=38.000000
     CrouchRadius=22.000000
     UnderWaterTime=20.000000
     Bob=0.010000
     ControllerClass=Class'ROEngine.ROBot'
     bPhysicsAnimUpdate=True
     bDoTorsoTwist=True
     MovementAnims(0)="stand_jogF_nade"
     MovementAnims(1)="stand_jogB_nade"
     MovementAnims(2)="stand_jogL_nade"
     MovementAnims(3)="stand_jogR_nade"
     MovementAnims(4)="stand_jogFL_nade"
     MovementAnims(5)="stand_jogFR_nade"
     MovementAnims(6)="stand_jogBL_nade"
     MovementAnims(7)="stand_jogBR_nade"
     TurnLeftAnim="stand_turnLhip_binoc"
     TurnRightAnim="stand_turnRhip_binoc"
     SwimAnims(0)="stand_jogF_nade"
     SwimAnims(1)="stand_jogB_nade"
     SwimAnims(2)="stand_jogL_nade"
     SwimAnims(3)="stand_jogR_nade"
     CrouchAnims(0)="crouch_walkF_nade"
     CrouchAnims(1)="crouch_walkB_nade"
     CrouchAnims(2)="crouch_walkL_nade"
     CrouchAnims(3)="crouch_walkR_nade"
     CrouchAnims(4)="crouch_walkFL_nade"
     CrouchAnims(5)="crouch_walkFR_nade"
     CrouchAnims(6)="crouch_walkBL_nade"
     CrouchAnims(7)="crouch_walkBR_nade"
     WalkAnims(0)="stand_walkFhip_binoc"
     WalkAnims(1)="stand_walkBhip_binoc"
     WalkAnims(2)="stand_walkLhip_binoc"
     WalkAnims(3)="stand_walkRhip_binoc"
     WalkAnims(4)="stand_walkFLhip_binoc"
     WalkAnims(5)="stand_walkFRhip_binoc"
     WalkAnims(6)="stand_walkBLhip_binoc"
     WalkAnims(7)="stand_walkBRhip_binoc"
     AirAnims(0)="jumpF_mid_binoc"
     AirAnims(1)="jumpB_mid_binoc"
     AirAnims(2)="jumpL_mid_binoc"
     AirAnims(3)="jumpR_mid_binoc"
     TakeoffAnims(0)="jumpF_takeoff_binoc"
     TakeoffAnims(1)="jumpB_takeoff_binoc"
     TakeoffAnims(2)="jumpL_takeoff_binoc"
     TakeoffAnims(3)="jumpR_takeoff_binoc"
     LandAnims(0)="jumpF_land_binoc"
     LandAnims(1)="jumpB_land_binoc"
     LandAnims(2)="jumpL_land_binoc"
     LandAnims(3)="jumpR_land_binoc"
     DodgeAnims(0)="jumpF_mid_binoc"
     DodgeAnims(1)="jumpB_mid_binoc"
     DodgeAnims(2)="jumpL_mid_binoc"
     DodgeAnims(3)="jumpR_mid_binoc"
     AirStillAnim="jump_mid_binoc"
     TakeoffStillAnim="jump_takeoff_binoc"
     CrouchTurnRightAnim="crouch_turnR_nade"
     CrouchTurnLeftAnim="crouch_turnL_nade"
     IdleCrouchAnim="crouch_idle_nade"
     IdleWeaponAnim="stand_idlehip_binoc"
     IdleRestAnim="stand_idlehip_binoc"
     IdleChatAnim="Idle_Chat"
     RootBone="HIP"
     HeadBone="Bip01_Head"
     SpineBone1="Bip01_Spine"
     SpineBone2="Bip01_Spine1"
     bCanProne=True
     ProneHeight=10.000000
     HitPoints(0)=(PointRadius=60.000000,PointHeight=75.000000,PointScale=1.000000,PointBone="HIP")
     HitPoints(1)=(PointRadius=6.500000,PointHeight=8.000000,PointScale=1.000000,PointBone="head",PointOffset=(X=4.000000,Y=-2.500000),DamageMultiplier=2.000000,HitPointType=PHP_Head)
     HitPoints(2)=(PointRadius=11.000000,PointHeight=13.000000,PointScale=1.000000,PointBone="UpperSpine",PointOffset=(X=5.000000),DamageMultiplier=1.000000,HitPointType=PHP_Torso)
     HitPoints(3)=(PointRadius=10.500000,PointHeight=10.000000,PointScale=1.000000,PointBone="spine",PointOffset=(X=-5.000000),DamageMultiplier=1.000000,HitPointType=PHP_Torso)
     HitPoints(4)=(PointRadius=6.000000,PointHeight=12.000000,PointScale=1.000000,PointBone="lupperthigh",PointOffset=(X=16.000000,Z=1.000000),DamageMultiplier=0.500000,HitPointType=PHP_Leg)
     HitPoints(5)=(PointRadius=6.000000,PointHeight=12.000000,PointScale=1.000000,PointBone="rupperthigh",PointOffset=(X=16.000000,Z=-1.000000),DamageMultiplier=0.500000,HitPointType=PHP_Leg)
     HitPoints(6)=(PointRadius=5.000000,PointHeight=9.000000,PointScale=1.000000,PointBone="lupperarm",PointOffset=(X=7.000000),DamageMultiplier=0.300000,HitPointType=PHP_Arm)
     HitPoints(7)=(PointRadius=5.000000,PointHeight=9.000000,PointScale=1.000000,PointBone="rupperarm",PointOffset=(X=7.000000),DamageMultiplier=0.300000,HitPointType=PHP_Arm)
     HitPoints(8)=(PointRadius=5.000000,PointHeight=15.000000,PointScale=1.000000,PointBone="lthigh",PointOffset=(X=15.000000),DamageMultiplier=0.400000,HitPointType=PHP_Leg)
     HitPoints(9)=(PointRadius=5.000000,PointHeight=15.000000,PointScale=1.000000,PointBone="rthigh",PointOffset=(X=15.000000),DamageMultiplier=0.400000,HitPointType=PHP_Leg)
     HitPoints(10)=(PointRadius=4.000000,PointHeight=10.000000,PointScale=1.000000,PointBone="lfarm",PointOffset=(X=7.000000),DamageMultiplier=0.200000,HitPointType=PHP_Arm)
     HitPoints(11)=(PointRadius=4.000000,PointHeight=10.000000,PointScale=1.000000,PointBone="rfarm",PointOffset=(X=7.000000),DamageMultiplier=0.200000,HitPointType=PHP_Arm)
     HitPoints(12)=(PointRadius=4.000000,PointHeight=5.000000,PointScale=1.000000,PointBone="lhand",PointOffset=(X=5.000000,Y=-1.000000,Z=-1.000000),DamageMultiplier=0.100000,HitPointType=PHP_Hand)
     HitPoints(13)=(PointRadius=4.000000,PointHeight=5.000000,PointScale=1.000000,PointBone="rhand",PointOffset=(X=5.000000,Y=-2.000000),DamageMultiplier=0.100000,HitPointType=PHP_Hand)
     HitPoints(14)=(PointRadius=4.000000,PointHeight=7.000000,PointScale=1.000000,PointBone="lfoot",PointOffset=(Y=-2.000000),DamageMultiplier=0.100000,HitPointType=PHP_Foot)
     HitPoints(15)=(PointRadius=4.000000,PointHeight=7.000000,PointScale=1.000000,PointBone="rfoot",PointOffset=(Y=-2.000000),DamageMultiplier=0.100000,HitPointType=PHP_Foot)
     LightHue=204
     LightBrightness=255.000000
     LightRadius=3.000000
     bActorShadows=True
     bDramaticLighting=True
     bStasis=False
     LODBias=1.800000
     Texture=None
     PrePivot=(Z=-42.000000)
     AmbientGlow=5
     MaxLights=8
     bForceSkelUpdate=True
     SoundVolume=150
     SoundRadius=75.000000
     CollisionRadius=23.000000
     CollisionHeight=52.000000
     bUseCylinderCollision=True
     bNetNotify=True
     bBlockHitPointTraces=False
     Buoyancy=99.000000
     RotationRate=(Pitch=3072,Roll=2048)
     Begin Object Class=KarmaParamsSkel Name=PawnKParams
         KConvulseSpacing=(Max=2.200000)
         KLinearDamping=0.150000
         KAngularDamping=0.050000
         KBuoyancy=1.000000
         KStartEnabled=True
         KVelDropBelowThreshold=50.000000
         bHighDetailOnly=False
         KFriction=1.300000
         KRestitution=0.200000
         KImpactThreshold=85.000000
     End Object
     KParams=KarmaParamsSkel'ROEngine.ROPawn.PawnKParams'

     ForceType=FT_DragAlong
     ForceRadius=100.000000
     ForceScale=2.500000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:28.000 - Creation time: Fri 13-10-2023 03:19:07.260 - Created with UnCodeX