Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

# Gameplay.Vehicle

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

    // Vehicle

    // Base Tribes vehicle class. Effectively a copy past of KVehicle. This was done due
    // to the fact that KVehicle derives from Pawn and is located in Engine.
    class Vehicle extends Rook implements IFiringMotor
    	native
    	abstract
    	notplaceable;

    const MAXIMUM_NUMBER_POSITIONS = 10;

    const NUMBER_MINOR_ENTRY_SIGNALS = 4;

    cpptext
    {
    	virtual void PostNetReceive();
    	virtual void PostEditChange();
    	virtual void setPhysics(BYTE NewPhysics, AActor *NewFloor, FVector NewFloorV);
    	virtual void CleanupDestroyed();
    	virtual void tickAI( FLOAT DeltaSeconds );
    	virtual UBOOL shouldLookForPawns();
    	virtual void TickSimulated( FLOAT DeltaSeconds );
    	virtual void TickAuthoritative( FLOAT DeltaSeconds );
    	virtual FVector predictedLocation( float t );

    	virtual void HavokPreStepCallback(FLOAT deltaTime);
    	virtual void RemakeRigidBodyVehicle();
    	virtual void initialiseHavokDataObject();
    	virtual bool HavokInitActor();
    	virtual void HavokQuitActor();

    	virtual void PostNetReceiveLocation();

    	virtual void physicsRotation(FLOAT deltaTime, FVector OldVelocity);

    	virtual UBOOL IsNetRelevantFor(APlayerController* RealViewer, AActor* Viewer, FVector SrcLocation);

    	bool isOccupant(ACharacter* character);

    	virtual UBOOL Tick(float deltaSeconds, ELevelTick tickType);

    	void updateInertiaTensor();

    	virtual bool groundContact();

    	virtual void updateHavokCollisionFilter();

    	virtual bool isHavokInitialised();

    	UBOOL CheckOwnerUpdated();

    	void clearVehicleAnimation(USkeletalMeshInstance *mesh, int index);
    	void loopVehicleAnimation(AVehicle* vehicle, USkeletalMeshInstance *mesh, int index, const FName& sequence);

    	class HkSoftCeiling* softCeiling;
    	class HkCollisionDamageSignaller* collisionDamageSignaller;
    	class HkStayUprightAction* xStayUpright;
    	class HkStayUprightAction* yStayUpright;
    	class HkDampingAction* dampingAction;
    	class HkStayUprightAction* flipAction;
    	class HkInfiniteMassCollisionController* infiniteMassCollisionController;
    	class HkClientInterpolationControl* clientInterpolationControl;
    }

    // not all vehicle positions are valid for each vehicle
    enum VehiclePositionType
    {
    	VP_DRIVER,
    	VP_GUNNER,
    	VP_LEFT_GUNNER,
    	VP_RIGHT_GUNNER,
    	VP_INVENTORY_STATION_ONE,
    	VP_INVENTORY_STATION_TWO,
    	VP_INVENTORY_STATION_THREE,
    	VP_INVENTORY_STATION_FOUR,
    	VP_NULL
    };

    // Each vehicle position is represented by the following struct. The set of positions are stored in the 'positions' array. The
    // 'toBePossessed' member specifies what is to be possessed when the position is occupied. This member is initialised by the vehicle in the
    // begin play functions. If this member is None on the server it implies that the position is a Minor position rather than a Major
    // position. Clients can use the isMajorPositon function. A Major
    // position is one that actually involves control of the vehicle, a Minor one simply involves placement in a vehicle. Sub classes would
    // be expected to provide extra fuctionality for Minor positions.
    struct native VehiclePosition
    {
    	var VehiclePositionType type;
    	var Character occupant;
    	var bool wantsToGetOut;
    	var bool hideOccupant;
    	var bool thirdPersonCamera;
    	var bool lookAtInheritPitch;
    	var Rook toBePossessed;
    	var name occupantControllerState;

    	// only valid for turret positions
    	var vector firstPersonCameraLocation;
    	var vector firstPersonWeaponLocation;

    	var name enterAnimation;
    	var name exitAnimation;
    	var name occupiedAnimation;
    	var name unoccupiedAnimation;
    	var weapon oldOccupantWeapon;
    	var vector occupantRelativeLocation;
    	var rotator occupantRelativeRotation;

    	// designer editable position coords for manifest
    	var() int ManifestXPosition			"X location of position on manifest diagram";
    	var() int ManifestYPosition			"Y location of position on manifest diagram";
    	var() bool bNotLabelledInManifest	"Whether this position should be labelled in the manifest";

    	// only valid if not hideOccupant
    	var name occupantConnection;
    	var() name occupantAnimation;
    };

    var float lastStateReceiveTime;

    // occupant is replicated using the clientDriverEnter function
    var() array<VehiclePosition> positions;

    var int driverIndex;

    var (Vehicle) float inverseCosUprightAngle;

    struct native VehicleEntryData
    {
    	var () float radius;
    	var () float height;
    	var () vector offset;
    	var () VehiclePositionType primaryPosition;
    	var () array<VehiclePositionType> secondaryPositions;
    	var () class<VehicleEntry> entryClass;
    };

    var (Vehicle) array<VehicleEntryData> entries;
    var array<VehicleEntry> vehicleEntries;

    struct native VehicleFlipTriggerData
    {
    	var () float radius;
    	var () float height;
    	var () vector offset;
    };
    var (Vehicle) array<VehicleFlipTriggerData> flipTriggers;
    var array<VehicleFlipTrigger> vehicleFlipTriggers;

    var class<VehicleMotor> motorClass;

    var (Vehicle) class<Explosion> destroyedExplosionClass;

    // generic controls (set by controller, used by concrete derived classes)
    var float StrafeInput; // between -1 and 1
    var float ThrottleInput; // between -1 and 1
    var rotator RotationInput;
    var float ThrustInput; // between 0 and 1
    var bool DiveInput;

    var (Vehicle) bool customInertiaTensor;
    var (Vehicle) vector customInertiaTensorDiagonal;

    var (Vehicle) float minimumCollisionDamageMagnitude;
    var (Vehicle) float collisionDamageMagnitudeScale;

    var (Vehicle) bool bCollisionDamageEnabled;

    var (Vehicle) float settledUpsideDownCosAngle;
    var (Vehicle) float settledUpsideDownSpeed;

    var (Vehicle) bool bVehicleCameraTrace;
    var (Vehicle) vector vehicleCameraTraceExtents;

    var bool bSettledUpsideDown;

    var (Vehicle) float healthModifier;

    var (Vehicle) array<VehiclePositionType> doNotEjectOnFlip;

    var (Vehicle) bool clientInterpolationHard;

    // indicates if vehicle is in the process of being spawned from a spawn point
    var bool spawning;

    // 'true' if vehicle is in the process of flipping
    var bool bFlipping;

    // current class that has been switched in, will be None if no switch has taken place
    var class<Vehicle> currentSwitchClass;

    // exits
    struct native ExitData
    {
    	var () vector offset;
    	var () VehiclePositionType position;
    };
    var (Vehicle) array<ExitData> exits;

    var (ClientSidePhysics) float clientInterpolationSnapDistance;
    var (ClientSidePhysics) float clientInterpolationPeriod;

    // The following is used to manage animations. The indices into animationFinishThenLoop correspond to animation channels. If a value is set
    // for a particular channel then that animation should loop after the one that is currently playing on the channel finishes.
    var array<Name> animationFinishThenLoop;

    var (Vehicle) float	maximumNetUpdateInterval;

    // latest time we should force an update of vehicles state
    var float maximumNextNetUpdateTime;

    var (Vehicle) float flipRotationStrength;
    var (Vehicle) float flipRotationDamping;
    var (Vehicle) float flipPushUpImpulse;
    var (Vehicle) float flipPushUpDuration;
    var (Vehicle) float flipMaximumRotationDuration;
    var float flipRotateTime;
    var float flipRotationTimeOut;

    var bool bShowPhysicsDebug;

    var bool bGodMode;

    var (Vehicle) bool bDisablePositionSwitching;

    var bool abandonmentDestruction;
    var private float abandonmentDestructionPeriod;
    var private float currentAbandonmentDuration;

    var TeamInfo lastOccupantTeam;

    // speed at which engine shall cease to apply force to vehicle
    var (Vehicle) float	TopSpeed;

    var (Vehicle) bool stayUprightEnabled;
    var (Vehicle) float stayUprightDamping;
    var (Vehicle) float stayUprightStrength;

    var (Vehicle) int driverMinimumPitch;
    var (Vehicle) int driverMaximumPitch;

    ////////// NAVIGATION //////////

    var float minimumObstacleLookAhead;
    var float obstacleLookAheadVeloocityScale;
    var float distanceToMaximumDurationScale;

    var float driveYawCoefficient;
    var float drivePitchCoefficient;

    // only relevant to vehicles that slow down at corners
    var float cornerSlowDownDistance;
    var float cornerSlowDownMinimumCosAngle;
    var float cornerSlowDownSpeedCoefficient;

    var bool stopForEnemies;

    ////////// CAMERA //////////

    var (Vehicle) float cameraDistance;

    var (Vehicle) vector TPCameraLookAt;
    var (Vehicle) float TPCameraDistance;

    var	(Vehicle) bool bDrawDriverInTP; // whether to draw the driver when in 3rd person mode

    var Vector cachedCameraLocation;

    // corresponds to vehicle centre
    var (Vehicle) name rootBone;

    // driver weapon
    var (Vehicle) class<Weapon> driverWeaponClass;
    var Weapon driverWeapon;

    var (Vehicle) float waterDamagePerSecond;

    var vector localMoveDestination;

    // enahanced damping
    var bool dampingPlusEnabled;
    var float dampingPlusXY;
    var float dampingPlusPositiveZ;
    var float dampingPlusNegativeZ;

    var bool retriggerEffectEvents;

    struct native VehicleEffect
    {
    	var name effectName;
    	var bool flag;
    	var VehicleEffectObserver observer;
    };

    struct native ClientOccupantEnterData
    {
    	var Controller controller;
    	var Character occupant;
    	var byte positionIndex;
    	var bool newData;
    	var bool flipFlop;
    };

    var ClientOccupantEnterData minorPositionEntrySignals[NUMBER_MINOR_ENTRY_SIGNALS];

    struct native ClientPositionData
    {
    	var Character occupant;
    };

    var ClientPositionData clientPositions[MAXIMUM_NUMBER_POSITIONS];
    var ClientPositionData localClientPositions[MAXIMUM_NUMBER_POSITIONS];

    var int throttleForwardEffectIndex;
    var int throttleBackEffectIndex;
    var int strafeLeftEffectIndex;
    var int strafeRightEffectIndex;
    var int engineIdlingEffectIndex;
    var int thrustingEffectIndex;
    var int throttleForwardOrThrustEffectIndex;
    var int strafeLeftOrThrustEffectIndex;
    var int strafeRightOrThrustEffectIndex;

    var array<VehicleEffect> effects;

    var VehicleMotor motor;

    var TeamInfo localTeam;

    var() class<DynamicObject>	destructionObjectClass;

    // indicates whether or not a vehicle has been occupied at all
    var bool bHasBeenOccupied;

    // indicates whether or not this vehicle can be driven by an enemy before being driven by an ally
    var bool bCanBeStolen;

    // background material for hud data
    var() Material		ManifestLayoutMaterial;

    // prompts
    const DRIVER_PROMPT_INDEX = 0;
    var (VehiclePrompts) localized string driverPrompt;
    const GUNNER_PROMPT_INDEX = 1;
    var (VehiclePrompts) localized string gunnerPrompt;
    const LEFT_GUNNER_PROMPT_INDEX = 2;
    var (VehiclePrompts) localized string leftGunnerPrompt;
    const RIGHT_GUNNER_PROMPT_INDEX = 3;
    var (VehiclePrompts) localized string rightGunnerPrompt;
    const INVENTORY_STATION_PROMPT_INDEX = 4;
    var (VehiclePrompts) localized string inventoryStationPrompt;
    const FULL_VEHICLE_PROMPT_INDEX = 5;
    var (VehiclePrompts) localized string fullVehiclePrompt;
    const VEHICLE_PROHIBITED_OBJECT_PROMPT_INDEX = 6;
    var (VehiclePrompts) localized string vehicleProhibitedObjectPrompt;
    const FLIP_PROMPT_INDEX = 7;
    var (VehiclePrompts) localized string flipPrompt;
    const CANNOT_STEAL_VEHICLE_PROMPT_INDEX = 8;
    var (VehiclePrompts) localized string cannotStealPrompt;
    const ENEMY_OCCUPIED_VEHICLE_PROMPT_INDEX = 9;
    var (VehiclePrompts) localized string enemyOccupiedPrompt;
    const ENEMY_INVENTORY_STATION_PROMPT_INDEX = 10;
    var (VehiclePrompts) localized string enemyInventoryStationPrompt;
    const HEAVY_ATTEMPT_TO_PILOT = 11;
    var (VehiclePrompts) localized string heavyAttemptedToPilot;
    var (VehiclePrompts) float heavyAttemptedToPilotSwitchPromptDuration;

    var (Vehicle) localized string localizedName;

    var bool bInvincible;
    var float loseInitialInvincibilityTime;
    var (Vehicle) float initialInvincibilityDuration;
    var (Vehicle) Material invicibilityMaterial;

    var (Vehicle) float velocityInheritOnExitScale "scales how much of the vehicle's velocity the player inherits when exiting";

    var (Vehicle) class<MovementCrushingDamageType>	CrushingDamageTypeClass;

    // used by clients to snap to server position
    struct native DesiredHavokState
    {
    	var vector velocity;
    	var vector angularVelocity;
    	var vector position;
    	var quat rotation;

    	var bool ignoreRotation;

    	var bool newState;
    };
    var DesiredHavokState currentDesiredHavokState;

    // padding
    var transient noexport private const int padding[8];

    // useful function for plotting data to real-time graph on screen
    native final function GraphData(string DataName, float DataValue);

    native function forceNetDirty();

    native function performFlip();

    native function Actor cameraTrace(out vector HitLocation, out vector HitNormal, vector TraceEnd, optional vector TraceStart,
    		optional bool bTraceActors, optional vector Extent);

    native function bool vehicleTrace(out vector HitLocation, out vector HitNormal, vector TraceEnd, optional vector TraceStart,
    		optional vector Extent);

    native function Actor vehicleTransitionTrace(out vector HitLocation, out vector HitNormal, vector TraceEnd, optional vector TraceStart);

    native function bool isHavokCompletelyInitialised();

    replication
    {
    	reliable if (Role == ROLE_Authority)
    		clientOccupantEnter, clientDriverLeave, minorPositionEntrySignals, driverWeapon, clientPositions, bInvincible, bHasBeenOccupied;

    	reliable if (Role == ROLE_Authority && bNetInitial)
    		spawning;
    }

    static simulated function PrecacheVehicleMeshes(LevelInfo Level, class<Vehicle> VehicleClass)
    {
    	// precache damage components
    	PrecacheDamageComponents(Level, VehicleClass);

    	// precache destruciton mesh
    	class'DynamicObject'.Static.PrecacheDynamicObjectRenderData(Level, VehicleClass.default.destructionObjectClass);

    	// precache main mesh
    	Level.AddPrecacheMesh(VehicleClass.default.Mesh);
    }

    simulated function UpdatePrecacheRenderData()
    {
    	Super.UpdatePrecacheRenderData();
    	PrecacheVehicleMeshes(Level, Class);
    }

    simulated native function byte getLowByte(int angle);

    simulated native function byte getHighByte(int angle);

    simulated native function int getAngle(byte lowByte, byte highByte);

    // Spawns a character within this vehicle. Should be called immediately after usual respawn processing.
    function spawnCharacter(Character character)
    {
    	character.bSpawningAtVehicle = true;
    }

    simulated function IFiringMotor firingMotor()
    {
    	return self;
    }

    // a way to access getViewRotation from native code (it would be quite tricky to do this through the firingMotor)
    simulated event Rotator getViewRotationFromMotor()
    {
    	return getViewRotation();
    }

    // Returns the character (if it exists) that is controlling this rook (i.e. turret or vehicle)
    simulated function Character getControllingCharacter()
    {
    	if ( positions.length > 0 )
    		return positions[driverIndex].occupant;
    	else
    		return None;
    }

    function processInput();

    function float getTeamDamagePercentage()
    {
    	// vehicles ignore the team damage concept
    	return 0;
    }

    function enableAbandonmentDestruction(float periodSeconds)
    {
    	abandonmentDestruction = true;
    	abandonmentDestructionPeriod = periodSeconds;
    }

    simulated function setSkin(Material skin)
    {
    	skins[0] = skin;
    }

    function bool needToPushStateToClient()
    {
    	return true;
    }

    function pushStateToClient();

    simulated function applyOutput();

    function getOut(VehiclePositionType type)
    {
    	local int index;

    	// indicate in positions array that occupant wants to get out
    	index = getPositionIndex(type);
    	positions[index].wantsToGetOut = true;
    }

    simulated function FaceRotation( rotator NewRotation, float DeltaTime )
    {
    	// vehicles ignore 'face rotation'
    }

    function initVehicleAI()
    {
    	local Tyrion_ResourceBase r;
    	local int i;

    	r = new class<Tyrion_ResourceBase>( DynamicLoadObject( "Tyrion.AI_VehicleResource", class'Class'));
    	vehicleAI = r;
    	r.setResourceOwner( self );

    	for ( i = 0; i < goals.length; i++ )
    	{
    		r.assignGoal( goals[i] );
    	}

    	for ( i = 0; i < abilities.length; i++ )
    	{
    		r.assignAbility( abilities[i] );
    	}
    }

    function initDriverAI( int index )
    {
    	local Tyrion_ResourceBase r;
    	local int i;

    	r = new class<Tyrion_ResourceBase>( DynamicLoadObject( "Tyrion.AI_DriverResource", class'Class'));
    	positions[index].toBePossessed.mountAI = r;
    	r.setResourceOwner( self );
    	r.setIndex( index );

    	for ( i = 0; i < goals.length; i++ )
    	{
    		r.assignGoal( goals[i] );
    	}

    	for ( i = 0; i < abilities.length; i++ )
    	{
    		r.assignAbility( abilities[i] );
    	}
    }

    function initGunnerAI( int index )
    {
    	local Tyrion_ResourceBase r;
    	local int i;

    	// vision systems for the gunner
    	positions[index].toBePossessed.CreateVisionNotifier();

    	r = new class<Tyrion_ResourceBase>( DynamicLoadObject( "Tyrion.AI_GunnerResource", class'Class'));
    	positions[index].toBePossessed.mountAI = r;
    	r.setResourceOwner( self );
    	r.setIndex( index );

    	for ( i = 0; i < goals.length; i++ )
    	{
    		r.assignGoal( goals[i] );
    	}

    	for ( i = 0; i < abilities.length; i++ )
    	{
    		r.assignAbility( abilities[i] );
    	}

    	copyVehicleAIValuesToTurret( positions[index].toBePossessed );
    }

    // cleanup AI when vehicle dead
    event bool cleanupAI()
    {
    	local int i;

    	if ( super.cleanupAI() )
    		return true;

    	if ( vehicleAI != None )	// (can be None if vehicle is deleted before PostNetBeginPlay is called)
    		vehicleAI.cleanup();
    	for ( i = 0; i < positions.length; ++i )
    		if ( positions[i].toBePossessed != None && positions[i].toBePossessed.mountAI != None )
    			positions[i].toBePossessed.mountAI.cleanup();

    	if ( vehicleAI != None )
    		vehicleAI.deleteSensors();
    	for ( i = 0; i < positions.length; ++i )
    		if ( positions[i].toBePossessed != None && positions[i].toBePossessed.mountAI != None )
    			positions[i].toBePossessed.mountAI.deleteSensors();

    	if ( vehicleAI != None )
    		vehicleAI.deleteRemovedActions();
    	for ( i = 0; i < positions.length; ++i )
    		if ( positions[i].toBePossessed != None && positions[i].toBePossessed.mountAI != None )
    			positions[i].toBePossessed.mountAI.deleteRemovedActions();

    	return false;
    }

    // Cause all resources attached to this pawn to re-check their goals
    function rematchGoals()
    {
    	local int i;

    	if ( vehicleAI != None )	// (can be None if vehicle is deleted before PostNetBeginPlay is called)
    		vehicleAI.bMatchGoals = true;
    	for ( i = 0; i < positions.length; ++i )
    		if ( positions[i].toBePossessed != None )
    			positions[i].toBePossessed.mountAI.bMatchGoals = true;
    }

    // set pertinent AI values on the vehicleMountedTurret
    function copyVehicleAIValuesToTurret( Rook turret )
    {
    	turret.AI_LOD_ActivationDistance = AI_LOD_ActivationDistance;
    	turret.AI_LOD_DeactivationDistance = AI_LOD_DeactivationDistance;
    	turret.SightRadius = SightRadius;
    	turret.shotAngularDeviation = shotAngularDeviation;
    	turret.shotLeadAbility = shotLeadAbility;
    	turret.reactionDelay = reactionDelay;
    }

    // generate "AllyKilled" speech events for vehicle occupants
    function generateAIDeathSpeechEvents( int deadIndex )
    {
    	local int index;
    	local String extraTag;
    	local BaseAICharacter ai;

    	if ( deadIndex == driverIndex )
    		extraTag = "Pilot";
    	else
    		extraTag = "Gunner";

    	for (index = 0; index < positions.length; ++index)
    	{
    		ai = BaseAICharacter( positions[index].occupant );
    		if ( class'Pawn'.static.checkAlive( ai ) )	// (also checks for non-None)
    		{
    			level.speechmanager.PlayDynamicSpeech( ai, 'AllyKilled', None, self, extraTag );
    			break;
    		}
    	}
    }

    simulated function updateTeamSkin()
    {
    	local Material teamSkin;

    	// only change skin if we have none set... is this correct logic?
    	if (skins.Length == 0 || skins[0] == None)
    	{
    		teamSkin = getTeamSkin(); // getTeamSkin overriden by derived classes
    		if (teamSkin != None)
    			setSkin(teamSkin);
    	}
    }

    // vehicles ovveride this to return their particular team skin
    simulated function Material getTeamSkin()
    {
    	return None;
    }

    simulated function setTeam(TeamInfo newTeam)
    {
    	local int i;

    	super.setTeam(newTeam);

    	for ( i = 0; i < positions.length; ++i )
    		if ( positions[i].toBePossessed != None && positions[i].toBePossessed != self )
    			positions[i].toBePossessed.setTeam(newTeam);

    	updateTeamSkin();
    }

    event bool EncroachingOn(Actor other)
    {
    	// do not encroach vehicle spawn points
    	if (VehicleSpawnPoint(other) != None)
    		return false;

    	return Super.EncroachingOn(other);
    }

    simulated function PostBeginPlay()
    {
    	local int index;
    	local coords connection;

    	super.PostBeginPlay();

    	assert(positions.length <= MAXIMUM_NUMBER_POSITIONS);

    	// steering is straight ahead initially
    	RotationInput = Rotation;

    	// apply initial invincibility
    	if (Role == ROLE_Authority)
    	{
    		bInvincible = true;
    		loseInitialInvincibilityTime = Level.TimeSeconds + initialInvincibilityDuration;
    	}

    	// Update occupant relative location and position (perhaps would be more robust to do in native as it is easier to get relative
    	// location and relative rotation of socket.
    	for (index = 0; index < positions.length; ++index)
    	{
    		connection = GetBoneCoords(positions[index].occupantConnection, true);
    		positions[index].occupantRelativeLocation = connection.origin - Location;
    		positions[index].occupantRelativeLocation = positions[index].occupantRelativeLocation << Rotation;
    		positions[index].occupantRelativeRotation = OrthoRotation(connection.xAxis, connection.yAxis, connection.zAxis) - Rotation;
    	}
    }

    function PostLoadGame()
    {
    	local int i;

    	super.PostLoadGame();

    	for (i = 0; i < positions.Length; ++i)
    	{
    		if (positions[i].occupant != None)
    			occupantEnterAnimationProcessing(i);
    	}
    }

    simulated function initialiseEffects()
    {
    	addEffect('throttleForward', false, throttleForwardEffectIndex);
    	addEffect('throttleBack', false, throttleBackEffectIndex);
    	addEffect('strafeLeft', false, strafeLeftEffectIndex);
    	addEffect('strafeRight', false, strafeRightEffectIndex);
    	addEffect('EngineIdling', false, engineIdlingEffectIndex);
    	addEffect('Thrusting', false, thrustingEffectIndex);
    	addEffect('ThrottleForwardOrThrust', false, throttleForwardOrThrustEffectIndex);
    	addEffect('StrafeLeftOrThrust', false, strafeLeftOrThrustEffectIndex);
    	addEffect('StrafeRightOrThrust', false, strafeRightOrThrustEffectIndex);
    }

    simulated function addEffect(name effectName, bool dynamicUpdate, out int effectIndex)
    {
    	effectIndex = effects.length;
    	effects.length = effects.length + 1;
    	effects[effectIndex].effectName = effectName;
    	effects[effectIndex].flag = false;
    	if (dynamicUpdate)
    		effects[effectIndex].observer = new class'VehicleEffectObserver'();
    }

    simulated function vector getVehicleUseablePoint(int pointI)
    {
    	return vehicleEntries[pointI].GetUseablePoint();
    }

    simulated event PostNetBeginPlay()
    {
    	local int entryI;
    	local int flipTriggerI;
    	local vector xAxis;
    	local vector yAxis;
    	local vector zAxis;
    	local int index;

    	if (spawning)
    	{
    		assert(physics == PHYS_None);
    		SetPhysics(PHYS_Havok);
    		SetPhysics(PHYS_None);
    	}

    	// vision for the driver
    	CreateVisionNotifier();

    	// initialise driver position index
    	driverIndex = getPositionIndex(VP_DRIVER);

    	// initialise driver position
    	positions[driverIndex].toBePossessed = self;

    	Super.PostNetBeginPlay();

    	// apply health modifier
    	healthMaximum *= healthModifier;
    	health = healthMaximum;

    	// initialise vehicle effects
    	effects.length = 0;
    	if (Level.NetMode != NM_DedicatedServer)
    		initialiseEffects();

    	motor = new motorClass(self);

    	GetAxes(rotation, xAxis, yAxis, zAxis);

    	// spawn driver weapon
    	if (Level.NetMode != NM_Client)
    	{
    		if (driverWeaponClass != None)
    		{
    			driverWeapon = Spawn(driverWeaponClass, self, , location);
    			driverWeapon.setOwner(self);

    			// initialise weapon
    			driverWeapon.equip();
    			driverWeapon.gotostate('Idle');
    		}
    	}

    	// spawn vehicle entries client and server side, only reason they are on the client is for HUD prompts
    	vehicleEntries.length = entries.length;
    	for (entryI = 0; entryI < entries.length; ++entryI)
    	{
    		if(entries[entryI].entryClass == None)
    			entries[entryI].entryClass = class'VehicleEntry';
    		vehicleEntries[entryI] = spawn(entries[entryI].entryClass, self, , location +
    				entries[entryI].offset.X * xAxis + entries[entryI].offset.Y * yAxis + entries[entryI].offset.Z * zAxis);
    		vehicleEntries[entryI].setBase(self);
    		vehicleEntries[entryI].setCollision(true, false, false);
    		vehicleEntries[entryI].setCollisionSize(entries[entryI].radius, entries[entryI].height);
    		vehicleEntries[entryI].secondaryPositions = entries[entryI].secondaryPositions;
    		vehicleEntries[entryI].initialiseVehicleEntry(entries[entryI].primaryPosition, self);

    		// Update useable points array
    		UseablePoints[entryI] = vehicleEntries[entryI].GetUseablePoint();
    		UseablePointsValid[entryI] = UP_Valid;
    	}

    	// create flip triggers
    	if (Level.NetMode != NM_Client)
    	{
    		vehicleFlipTriggers.length = flipTriggers.length;
    		for (flipTriggerI = 0; flipTriggerI < flipTriggers.length; ++flipTriggerI)
    		{
    			vehicleFlipTriggers[flipTriggerI] = spawn(class'VehicleFlipTrigger', self, , location + flipTriggers[flipTriggerI].offset.X *
    					xAxis + flipTriggers[flipTriggerI].offset.Y * yAxis + flipTriggers[flipTriggerI].offset.Z * zAxis);
    			vehicleFlipTriggers[flipTriggerI].promptIndex = FLIP_PROMPT_INDEX;
    			vehicleFlipTriggers[flipTriggerI].ownerVehicle = self;
    			vehicleFlipTriggers[flipTriggerI].setBase(self);
    			vehicleFlipTriggers[flipTriggerI].setCollision(true, false, false);
    			vehicleFlipTriggers[flipTriggerI].setCollisionSize(flipTriggers[flipTriggerI].radius, flipTriggers[flipTriggerI].height);

    			// Update useable points array
    			UseablePoints[entries.Length + flipTriggerI] = vehicleFlipTriggers[flipTriggerI].GetUseablePoint();
    			UseablePointsValid[entries.Length + flipTriggerI] = UP_Unused;
    		}
    	}

    	// do other client processing for unoccupied positions
    	for (index = 0; index < positions.length; ++index)
    	{
    		if (clientPositions[index].occupant == None)
    		{
    			// play unoccupied animation
    			if (positions[index].exitAnimation != 'None')
    			{
    				PlayAnim(positions[index].exitAnimation);
    				animationFinishThenLoop[index] = positions[index].unoccupiedAnimation;
    			}
    		}
    		else
    		{
    			// play occupied animation
    			if (positions[index].enterAnimation != 'None')
    			{
    				PlayAnim(positions[index].enterAnimation);
    				animationFinishThenLoop[index] = positions[index].occupiedAnimation;
    			}
    		}
    	}

    	// init AI
    	initVehicleAI();
    	initDriverAI( driverIndex );

    	// make sure client skin is updated
    	updateTeamSkin();
    }

    simulated function postNetReceive()
    {
    	local int index;
    	local Character oldOccupant;

    	super.postNetReceive();

    	// check for minor position entry
    	for (index = 0; index < NUMBER_MINOR_ENTRY_SIGNALS; ++index)
    	{
    		if (minorPositionEntrySignals[index].newData)
    		{
    			// ideally should not be recieved at all if not character net owner
    			if (minorPositionEntrySignals[index].occupant.bNetOwner)
    				clientOccupantEnter(minorPositionEntrySignals[index]);
    			minorPositionEntrySignals[index].newData = false;
    		}
    	}

    	// check for team change
    	if (localTeam != m_team)
    	{
    		localTeam = m_team;
    		updateTeamSkin();
    	}

    	// check for occupant changes

    	// ... leaving
    	for (index = 0; index < positions.length; ++index)
    	{
    		if (clientPositions[index] != localClientPositions[index] && clientPositions[index].occupant == None)
    		{
    			oldOccupant = localClientPositions[index].occupant;
    			localClientPositions[index] = clientPositions[index];
    			otherClientOccupantLeave(index, oldOccupant);
    		}
    	}

    	// ... entering
    	for (index = 0; index < positions.length; ++index)
    	{
    		if (clientPositions[index] != localClientPositions[index] && clientPositions[index].occupant != None)
    		{
    			localClientPositions[index] = clientPositions[index];
    			otherClientOccupantEnter(index);
    		}
    	}
    }

    function bool InGodMode()
    {
    	return bGodMode || Super.InGodMode();
    }

    function PostTakeDamage(float Damage, Pawn instigatedBy, Vector hitlocation,  Vector momentum, class<DamageType> damageType, optional float projectileFactor)
    {
    	local class<ProjectileDamageType> pdt;
    	local int positionI;
    	local Controller killer;
    	local Rook killerRook;
    	local ModeInfo mode;
    	local Rook instigatedRook;

    	instigatedRook = Rook(instigatedBy);

    	// catch case we have been torn off and this is called
    	if (Level.NetMode == NM_Client)
    		return;

    	// disable invincibility if attacked by our own team
    	if (instigatedRook != None && instigatedRook.team() == team())
    		bInvincible = false;

    	// do nothing if in god mode or invincible
    	if (InGodMode() || bInvincible)
    		return;

    	pdt = class<ProjectileDamageType>(damageType);

    	if (pdt != None)
    		Damage *= pdt.default.vehicleDamageModifier;

    	// avoid damage healing the car
    	if (Damage < 0)
    		return;

    	// vehicle is dead
    	if ((Health - Damage) <= 0)
    	{
    		aboutToDie();

    		// have all occupants leave
    		for (positionI = 0; positionI < positions.length; ++positionI)
    		{
    			if (positions[positionI].occupant != None)
    				driverLeave(true, positionI);
    		}

    		// Notify mode for stat-tracking purposes
    		mode = ModeInfo(Level.Game);
    		if (mode != None)
    		{
    			mode.OnVehicleDestroyed(instigatedBy, self, damageType);
    		}

    		// Remove dead vehicle's from other AI's VisionNotifier's
    		// (maybe to be consistent with Pawn's postTakeDamage function we should call Died() here)
    		Level.Game.NotifyKilled(instigatedBy.Controller, Controller, self);

    		// emit death message
    		if (instigatedBy != None)
    			killer = instigatedBy.GetKillerController();
    		if (killer!= None && Killer.Pawn != None)
    		{
    			killerRook = Rook(Killer.Pawn);
    			if (killerRook != None)
    				dispatchMessage(new class'MessageDeath'(killerRook.getKillerLabel(), label, killer.Pawn.PlayerReplicationInfo, None));
    			else
    				dispatchMessage(new class'MessageDeath'(killer.Pawn.label, label, killer.Pawn.PlayerReplicationInfo, None));
    		}
    		else
    			dispatchMessage(new class'MessageDeath'(self.label, label, None, None));

    		TriggerEffectEvent('VehicleDestroyed');
    	}

    	Super.PostTakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType, projectileFactor);
    }

    function aboutToDie()
    {

    }

    // Vehicles do not get telefragged.
    event EncroachedBy( actor Other )
    {
    	Log("Vehicle("$self$") Encroached By: "$Other$".");
    }

    // You got some new info from the server (VehicleState has some new info).
    simulated event VehicleStateReceived()
    {
    	// make sure we are in PHYS_Havok
    	if (physics != PHYS_Havok)
    		setPhysics(PHYS_Havok);

    	HavokActivate();

    	lastStateReceiveTime = Level.TimeSeconds;
    }

    // Called when a parameter of the overall articulated actor has changed (like PostEditChange).
    simulated event VehicleUpdateParams()
    {

    }

    simulated function vehicleFire()
    {
    	if (driverWeapon == None)
    		return;

    	fire(false);
    }

    simulated function fire(optional bool fireOnce)
    {
    	driverWeapon.fire(fireOnce);
    }

    function altFire(optional bool fireOnce)
    {

    }

    function releaseFire()
    {

    }

    function releaseAltFire()
    {

    }

    function bool shouldFire(Equippable e)
    {
    	return false;
    }

    function setFirePressed(Equippable e, bool pressed)
    {
    }

    simulated function vehicleCeaseFire()
    {
    	if (driverWeapon == None)
    		return;

    	driverWeapon.releaseFire();
    }

    function int getOccupantPositionIndex(Character occupant)
    {
    	local int positionI;
    	for (positionI = 0; positionI < positions.length; ++positionI)
    		if (positions[positionI].occupant == occupant)
    			return positionI;
    	return -1;
    }

    // Convenience function that simply forwards an attempt to occupy the driver position.
    function bool tryToDrive(Character character)
    {
    	local array<VehiclePositionType> secondaryPositions;
    	return tryToOccupy(character, VP_DRIVER, secondaryPositions) >= 0;
    }

    simulated function bool canArmourBeDriver(class<Armor> armour)
    {
    	local int index;
    	if (armour == None)
    		return false;
    	for (index = 0; index < armour.default.allowedDriver.length; ++index)
    		if (armour.default.allowedDriver[index] == class)
    			return true;
    	return false;
    }

    simulated function bool canArmourBePassenger(class<Armor> armour)
    {
    	local int index;
    	for (index = 0; index < armour.default.allowedPassenger.length; ++index)
    		if (armour.default.allowedPassenger[index] == class)
    			return true;
    	return false;
    }

    // If this function cannot find an available position it shall simply return -1.
    simulated function int getAvailablePositionIndex(int positionIndex, array<VehiclePositionType> secondaryPositions, Character character)
    {
    	local int index;
    	local int temporary;
    	if (clientPositions[positionIndex].occupant != None || !canArmorOccupy(positions[positionIndex].type, character))
    	{
    		for (index = 0; index < secondaryPositions.length; ++index)
    		{
    			temporary = getPositionIndex(secondaryPositions[index]);
    			if (clientPositions[temporary].occupant == None && (character == None || canArmorOccupy(secondaryPositions[index], character)))
    			{
    				return temporary;
    			}
    		}
    		return -1;
    	}
    	return positionIndex;
    }

    simulated function bool isOccupant(Character character)
    {
    	local int index;
    	for (index = 0; index < positions.length; ++index)
    	{
    		if (clientPositions[index].occupant == character)
    			return true;
    	}
    	return false;
    }

    // Returns true if the armour of the specified character can occupy the specified position.
    simulated function bool canArmorOccupy(VehiclePositionType position, Character character)
    {
    	if (character.armorClass == None)
    	{
    		warn(character.name $ "'s armor class is none");
    		return true;
    	}
    	else if (position == VP_DRIVER)
    		return canArmourBeDriver(character.armorClass);
    	else
    		return canArmourBePassenger(character.armorClass);
    }

    function int canOccupy(Character character, VehiclePositionType position, array<VehiclePositionType> secondaryPositions,
    		out byte promptIndex)
    {
    	local int positionIndex;
    	local TeamInfo workTeam;
    	local int targetPositionIndex;

    	promptIndex = 255;

    	if (spawning)
    		return -1;

    	if (character.Controller == None)
    		return -1;

    	// cannot enter flipped vehicle
    	if (bSettledUpsideDown)
    		return -1;

    	positionIndex = getPositionIndex(position);

    	// ignore if the occupant team of this vehicle is not the same as the character
    	workTeam = getOccupantTeam();
    	if (workTeam != None && workTeam != character.team())
    	{
    		promptIndex = ENEMY_OCCUPIED_VEHICLE_PROMPT_INDEX;
    		return -1;
    	}

    	// handle case vehicle is attempted to be stolen
    	if (!bCanBeStolen && !bHasBeenOccupied && character.team() != team())
    	{
    		promptIndex = CANNOT_STEAL_VEHICLE_PROMPT_INDEX;
    		return -1;
    	}

    	if (isOccupant(character))
    		return -1;

    	// handle case character is carrying an object that prevents vehicle entry
    	if (character.numDroppableCarryables() > 0 && !character.carryableReference.bCanBringIntoVehicle)
    	{
    		promptIndex = VEHICLE_PROHIBITED_OBJECT_PROMPT_INDEX;
    		return -1;
    	}

    	// attempt to access a secondary position if primary is occupied
    	targetPositionIndex = getAvailablePositionIndex(positionIndex, secondaryPositions, character);

    	if (targetPositionIndex == -1)
    	{
    		promptIndex = FULL_VEHICLE_PROMPT_INDEX;

    		// assume if attempting to access pilot position and armour cannot occupy we are a heavy
    		if (positionIndex == driverIndex && positions[positionIndex].occupant == None &&
    				!canArmorOccupy(positions[positionIndex].type, character))
    			promptIndex = HEAVY_ATTEMPT_TO_PILOT;

    		return -1;
    	}

    	// ignore if attempting to enter an inventory station position and not on vehicles team
    	if (isInventoryPosition(positions[targetPositionIndex].type) && (character.team() != team()))
    	{
    		promptIndex = ENEMY_INVENTORY_STATION_PROMPT_INDEX;
    		return -1;
    	}

    	// confirm possession target is initialised
    	if (isMajorPosition(positions[targetPositionIndex].type) && (positions[targetPositionIndex].toBePossessed == None))
    	{
    		warn("possession target is none");
    		return -1;
    	}

    	promptIndex = getPositionPromptIndex(positions[targetPositionIndex].type);

    	// assume if attempting to access pilot position and armour cannot occupy we are a heavy
    	if (positionIndex == driverIndex && !canArmorOccupy(positions[positionIndex].type, character))
    		promptIndex = HEAVY_ATTEMPT_TO_PILOT;

    	return targetPositionIndex;
    }

    simulated function bool isInventoryPosition(VehiclePositionType positionType)
    {
    	return positionType == VP_INVENTORY_STATION_ONE || positionType == VP_INVENTORY_STATION_TWO ||
    			positionType == VP_INVENTORY_STATION_THREE || positionType == VP_INVENTORY_STATION_FOUR;
    }

    // A Character has tried to occupy this vehicle.
    // Returns the positionIndex if the character successfully occupied this vehicle or -1 if not.
    function int tryToOccupy(Character character, VehiclePositionType position, array<VehiclePositionType> secondaryPositions)
    {
    	local int targetPositionIndex;
    	local byte dummy;

    	targetPositionIndex = canOccupy(character, position, secondaryPositions, dummy);

    	if (targetPositionIndex == -1)
    		return -1;

        if (
    			// player case
    			(character.Controller.bIsPlayer && !character.Controller.IsInState('PlayerDriving') && character.IsHumanControlled())
    			||
    			// ai case
    			(!character.IsHumanControlled())
    			)
    	{
    		occupantEnter(character, targetPositionIndex);
    		return targetPositionIndex;
    	}
    	else
    	{
    		return -1;
    	}
    }

    // returns true if the vehicle can target the location given its view constraints;
    // this function should return true if it's possible to target this point, not if it can currently be targetted
    // (individual vehicles should override this function based on their weapon)
    function bool canTargetPoint(Vector targetLoc)
    {
    	return true;
    }

    // wrapper funtion to call aimClass.static.aimlocation from native code
    event Vector getAimLocation( Pawn target )
    {
    	return driverWeapon.aimClass.static.getAimLocation( driverWeapon, target );
    }

    // Returns the team of this vehicle's occupant(s). If there are no occupants it returns None.
    simulated function TeamInfo getOccupantTeam()
    {
    	local int positionI;
    	for (positionI = 0; positionI < positions.length; ++positionI)
    	{
    		if (clientPositions[positionI].occupant != None)
    			return clientPositions[positionI].occupant.team();
    	}
    	return None;
    }

    simulated function Character getDriver()
    {
    	return positions[driverIndex].occupant;
    }

    // Returns index into positions array corresponding to a particular position type.
    simulated function int getPositionIndex(VehiclePositionType position)
    {
    	local int index;

    	for (index = 0; index < positions.length; ++index)
    	{
    		if (positions[index].type == position)
    			return index;
    	}

    	log("WARNING: vehicle position not found");

    	return 0;
    }

    // Events called on driver entering/leaving vehicle.

    // Places an occupant within this vehicle.
    simulated function clientOccupantEnter(ClientOccupantEnterData data)
    {
    	local PlayerController pc;

    	// store the driver
    	positions[data.positionIndex].occupant = data.occupant;

    	// ... update client position data immediately
    	clientPositions[data.positionIndex].occupant = data.occupant;
    	if (localClientPositions[data.positionIndex].occupant != data.occupant)
    	{
    		localClientPositions[data.positionIndex].occupant = data.occupant;
    		otherClientOccupantEnter(data.positionIndex);
    	}

    	if (Role < ROLE_Authority)
    		attachToVehicle(data.positionIndex);

    	// prevent weapons from firing after we leave
    	if (clientPositions[data.positionIndex].occupant.motor != None)
    		clientPositions[data.positionIndex].occupant.motor.bFirePressed = false;

    	// do player major position specific processing
    	pc = PlayerController(data.controller);
    	if (pc != None && isMajorPosition(positions[data.positionIndex].type))
    	{
    		pc.GotoState(positions[data.positionIndex].occupantControllerState);

    		if (positions[data.positionIndex].thirdPersonCamera)
    			pc.bBehindView = true;
    		else
    			pc.bBehindView = false;

    		pc.bFixedCamera = false;
    		pc.bFreeCamera = true;

    		pc.SetRotation(Rotation);
    	}
    }

    simulated function bool isMajorPosition(VehiclePositionType type)
    {
    	return (type == VP_DRIVER) || (type == VP_GUNNER) || (type == VP_LEFT_GUNNER) || (type == VP_RIGHT_GUNNER);
    }

    simulated function bool canBeRepairedBy(Rook otherGuy)
    {
    	local TeamInfo tiThisGuy;
    	local TeamInfo tiOtherGuy;

    	if (otherGuy == None)
    		return true;

    	// use last occupant team if available
    	if (lastOccupantTeam != None)
    		tiThisGuy = lastOccupantTeam;
    	else
    		tiThisGuy = team();

    	tiOtherGuy = otherGuy.getControllingCharacterTeam();

    	if (tiThisGuy == None || tiOtherGuy == None)
    		return true;

    	return tiThisGuy.isFriendly( tiOtherGuy );
    }

    function occupantEnter(Character p, int positionIndex)
    {
    	local PlayerController pc;
    	local Controller c;
    	local ClientOccupantEnterData data;
    	local int minorPositionEntryIndex;

    	if (isOccupant(p))
    	{
    		warn(p @ "cannot enter" @ self @ "because they are already an occupant");
    		return;
    	}

    	bHasBeenOccupied = true;

    	// store occupant
    	positions[positionIndex].occupant = p;
    	clientPositions[positionIndex].occupant = p;

    	if (positions[positionIndex].hideOccupant)
    		positions[positionIndex].occupant.setDrawType(DT_None);

    	attachToVehicle(positionIndex);

    	c = p.Controller;

    	pc = PlayerController(c);

    	// do major position specific processing
    	if (positions[positionIndex].toBePossessed != None)
    	{
    		// disconnect PlayerController from occupant and connect to
    		c.Unpossess();
    		positions[positionIndex].occupant.SetOwner(c); // keeps the driver relevant
    		c.Possess(positions[positionIndex].toBePossessed);

    		// save the occupant's current weapon, and holster it
    		if (positions[positionIndex].occupant.weapon != None)
    		{
    			positions[positionIndex].oldOccupantWeapon = positions[positionIndex].occupant.weapon;
    			positions[positionIndex].oldOccupantWeapon.bHidden = true;
    		}
    		positions[positionIndex].occupant.motor.setWeapon(None);

    		// player specific processing
    		if (pc != None)
    		{
    			// set playercontroller to view the vehicle
    			pc.ClientSetViewTarget(positions[positionIndex].toBePossessed);

    			// change controller state to driver
    			pc.GotoState(positions[positionIndex].occupantControllerState);

    			// get rid of AI inaccuracy
    			if ( positions[positionIndex].toBePossessed.firingMotor() != None )
    				positions[positionIndex].toBePossessed.firingMotor().getWeapon().AISpread = Rot(0.0, 0.0, 0.0);
    		}
    	}

    	// update character flag
    	if (positions[positionIndex].hideOccupant)
    		positions[positionIndex].occupant.bHiddenVehicleOccupant = true;

    	// scripting message
    	if (positionIndex == driverIndex)
    		dispatchMessage(new class'MessageDriverEnter'(label, p.label));
    	else
    		dispatchMessage(new class'MessageGunnerEnter'(label, p.label));

    	// signal to client that driver has entered
    	data.controller = c;
    	data.occupant = positions[positionIndex].occupant;
    	data.positionIndex = positionIndex;
    	if (positions[positionIndex].toBePossessed == self)
    	{
    		clientOccupantEnter(data);
    	}
    	else if (VehicleMountedTurret(positions[positionIndex].toBePossessed) != None)
    	{
    		// go through VehicleMountedTurret because otherwise the function is not replicated, call will
    		// simply be forwarded to the vehicle on the client side
    		VehicleMountedTurret(positions[positionIndex].toBePossessed).clientOccupantEnter(pc,
    				positions[positionIndex].occupant, positionIndex);
    	}
    	else
    	{
    		// use variable replication to signal a client has entered a minor position
    		minorPositionEntryIndex = getMinorPositionEntryIndex(data.positionIndex);
    		if (minorPositionEntryIndex != -1)
    		{
    			minorPositionEntrySignals[minorPositionEntryIndex].controller = data.controller;
    			minorPositionEntrySignals[minorPositionEntryIndex].occupant = data.occupant;
    			minorPositionEntrySignals[minorPositionEntryIndex].positionIndex = data.positionIndex;
    			minorPositionEntrySignals[minorPositionEntryIndex].newData = true;
    			minorPositionEntrySignals[minorPositionEntryIndex].flipFlop = !minorPositionEntrySignals[minorPositionEntryIndex].flipFlop;
    		}
    	}

    	occupantEnterAnimationProcessing(positionIndex);

    	otherClientOccupantEnter(positionIndex);
    }

    // Does any necessary animation processing for a client in a particular position.
    function occupantEnterAnimationProcessing(int positionIndex)
    {
    	if (!positions[positionIndex].hideOccupant)
    	{
    		positions[positionIndex].occupant.enterManualAnimationState();
    		positions[positionIndex].occupant.LoopAnim(positions[positionIndex].occupantAnimation);
    	}
    }

    // Called on all machines when an occupant enters this vehicle.
    simulated function otherClientOccupantEnter(int positionI)
    {
    	bHasBeenOccupied = true;

    	// kill all movement effects
    	clientPositions[positionI].occupant.stopMovementEffects();

    	// update last occupant team
    	lastOccupantTeam = clientPositions[positionI].occupant.team();

    	// animation
    	if (positions[positionI].enterAnimation != 'None')
    	{
    		PlayAnim(positions[positionI].enterAnimation);
    		animationFinishThenLoop[positionI] = positions[positionI].occupiedAnimation;
    	}

    	// driver enter effect
    	if (positionI == driverIndex)
    		TriggerEffectEvent('DriverEntered');

    	clientPositions[positionI].occupant.hideJetpack();

    	// turn off shadow
    	if (clientPositions[positionI].occupant.Shadow != None)
    		clientPositions[positionI].occupant.Shadow.bShadowActive = false;
    }

    function occupantLeaveAnimationProcessing(int positionIndex)
    {
    	positions[positionIndex].occupant.exitManualAnimationState();
    }

    // Move the occupant into position, and attach to car. Occurs client and server side.
    simulated function attachToVehicle(int positionIndex)
    {
    	// when moving out of fusion collision state is set back to what it was so must set physics to PHYS_None before updating collision
    	positions[positionIndex].occupant.SetPhysics(PHYS_None);

    	// collide actors needs to be so as the player will set off triggers and can be shot at
    	positions[positionIndex].occupant.SetCollision(true, false, false);

    	positions[positionIndex].occupant.bCollideWorld = false;
    	positions[positionIndex].occupant.Velocity = vect(0,0,0);

    	// When putting player in vehicle SetRelativeRotation at the end to get the hard attach matrix updated correctly.

    	if (!positions[positionIndex].hideOccupant)
    	{
    		// put occupant in correct position
    		positions[positionIndex].occupant.SetLocation(Location + (positions[positionIndex].occupantRelativeLocation >> Rotation));
    		positions[positionIndex].occupant.SetRotation(rot(0, 0, 0));
    	}
    	else
    		positions[positionIndex].occupant.SetLocation(Location);

    	positions[positionIndex].occupant.SetPhysics(PHYS_None);

    	positions[positionIndex].occupant.bHardAttach = true;
    	positions[positionIndex].occupant.SetBase(None);

    	// needs to be called here because Driver.SetBase(None) may call SetPhysics(PHYS_Falling)
    	positions[positionIndex].occupant.SetPhysics(PHYS_None);

    	positions[positionIndex].occupant.SetBase(self);
    	positions[positionIndex].occupant.SetPhysics(PHYS_None);

    	if (!positions[positionIndex].hideOccupant)
    	{
    		positions[positionIndex].occupant.SetRelativeRotation(positions[positionIndex].occupantRelativeRotation);
    		positions[positionIndex].occupant.SetRelativeLocation(positions[positionIndex].occupantRelativeLocation);
    	}
    }

    simulated function clientDriverLeave(Controller c, Character oldDriver)
    {
    	local int workIndex;
    	local PlayerController pc;

    	pc = PlayerController(c);

    	if (pc != None)
    	{
    		pc.bBehindView = false;
    		pc.bFixedCamera = true;
    		pc.bFreeCamera = false;
    	}

    	oldDriver.bOwnerNoSee = true;

    	// turn off all effects
    	for (workIndex = 0; workIndex < effects.length; ++workIndex)
    	{
    		if (effects[workIndex].flag)
    		{
    			//log("UnTriggerEffectEvent(" $ effects[workIndex].effectName $ ")");
    			UnTriggerEffectEvent(effects[workIndex].effectName);
    			effects[workIndex].flag = false;
    		}
    	}
    }

    // Called from when an occupant wants to get out.
    function bool driverLeave(bool bForceLeave, int positionIndex)
    {
    	local Controller c;
    	local PlayerController pc;
    	local int exitI;
    	local bool havePlaced;
    	local vector HitLocation, HitNormal;
    	local vector rootLocation;
    	local Character oldOccupant;
    	local int minorPositionEntryIndex;
    	local vector exitLocation;

    	// do nothing if we're not being driven
    	if (positions[positionIndex].occupant == None)
    		return false;

    	positions[positionIndex].occupant.bSpawningAtVehicle = false;

    	oldOccupant = positions[positionIndex].occupant;

    	// Before we can exit, we need to find a place to put the driver.
    	// Iterate over array of possible exit locations.

    	positions[positionIndex].occupant.bHardAttach = false;
    	positions[positionIndex].occupant.bCollideWorld = true;
    	positions[positionIndex].occupant.SetCollision(true, true, true);

    	havePlaced = false;
    	rootLocation = GetBoneCoords(rootBone).origin;
    	if (vehicleEntries.length == 0)
    		warn("no entries thus no way to exit");

    	// use exit points

    	// ... firstly try to place at exit corresponding to position we are in
    	for (exitI = 0; exitI < exits.length && !havePlaced; exitI++)
    	{
    		if (exits[exitI].position != positions[positionIndex].type)
    			continue;

    		exitLocation = Location + (exits[exitI].offset >> Rotation);

    		// first, do a line check (stops us passing through things on exit)
    		if (vehicleTransitionTrace(HitLocation, HitNormal, exitLocation, rootLocation) != None)
    			continue;

    		// then see if we can place the player there
    		if (!positions[positionIndex].occupant.SetLocation(exitLocation))
    			continue;

    		havePlaced = true;
    	}

    	// ... secondly try to place at exit not corresponding to position we are in
    	for (exitI = 0; exitI < exits.length && !havePlaced; exitI++)
    	{
    		if (exits[exitI].position == positions[positionIndex].type)
    			continue;

    		exitLocation = Location + (exits[exitI].offset >> Rotation);

    		// first, do a line check (stops us passing through things on exit)
    		if (vehicleTransitionTrace(HitLocation, HitNormal, exitLocation, rootLocation) != None)
    			continue;

    		// then see if we can place the player there
    		if (!positions[positionIndex].occupant.SetLocation(exitLocation))
    			continue;

    		havePlaced = true;
    	}

    	// if we could not find a place to put the driver, leave driver inside as before
    	if(!havePlaced && !bForceLeave)
    	{
    		Log("Could not place driver.");

    		positions[positionIndex].occupant.bHardAttach = true;
    		positions[positionIndex].occupant.bCollideWorld = false;
    		positions[positionIndex].occupant.SetCollision(true, false, false);

    		return false;
    	}

    	// scripting message
    	if (positionIndex == driverIndex)
    		dispatchMessage(new class'MessageDriverLeave'(label, positions[positionIndex].occupant.label));
    	else
    		dispatchMessage(new class'MessageGunnerLeave'(label, positions[positionIndex].occupant.label));

    	// get controller
    	if (positions[positionIndex].toBePossessed != None)
    		c = positions[positionIndex].toBePossessed.Controller;
    	else
    		c = positions[positionIndex].occupant.controller;

    	pc = PlayerController(c);

    	// signal to client that occupant has left
    	if (positions[positionIndex].toBePossessed == self)
    	{
    		clientDriverLeave(c, positions[positionIndex].occupant);
    	}
    	else if (VehicleMountedTurret(positions[positionIndex].toBePossessed) != None)
    	{
    		clientDriverLeave(c, positions[positionIndex].occupant);
    	}
    	else
    	{
    		clientDriverLeave(c, positions[positionIndex].occupant);

    		// clear minor entry signal
    		minorPositionEntryIndex = getMinorPositionEntryIndex(positionIndex);
    		if (minorPositionEntryIndex != -1)
    		{
    			minorPositionEntrySignals[minorPositionEntryIndex].controller = None;
    			minorPositionEntrySignals[minorPositionEntryIndex].occupant = None;
    			minorPositionEntrySignals[minorPositionEntryIndex].newData = false;
    			minorPositionEntrySignals[minorPositionEntryIndex].flipFlop = !minorPositionEntrySignals[minorPositionEntryIndex].flipFlop;
    		}
    	}

    	// update character flag
    	positions[positionIndex].occupant.bHiddenVehicleOccupant = false;

    	// do major position specific processing
    	if (positions[positionIndex].toBePossessed != None)
    	{
    		// reconnect PlayerController to Driver
    		c.Unpossess();
    		c.Possess(positions[positionIndex].occupant);

    		// set playercontroller to view the person that got out
    		if (pc != None)
    			pc.ClientSetViewTarget(positions[positionIndex].occupant);

    		positions[positionIndex].toBePossessed.controller = None;
    	}

    	positions[positionIndex].occupant.PlayWaiting();

        positions[positionIndex].occupant.Acceleration = vect(0, 0, 24000);

    	// do not do this stuff if character is in ragdoll
    	if (positions[positionIndex].occupant.isAlive())
    	{
    		positions[positionIndex].occupant.SetPhysics(PHYS_Movement);
    		positions[positionIndex].occupant.SetBase(None);
    		occupantLeaveAnimationProcessing(positionIndex);

    		// restore the driver's weapon
    		if (positions[positionIndex].oldOccupantWeapon != None)
    		{
    			positions[positionIndex].oldOccupantWeapon.bHidden = false;
    			positions[positionIndex].occupant.motor.setWeapon(positions[positionIndex].oldOccupantWeapon);
    			positions[positionIndex].oldOccupantWeapon = None;
    		}
    	}

    	// inherit vehicle velocity on exit
    	positions[positionIndex].occupant.unifiedSetVelocity(unifiedGetVelocity()*velocityInheritOnExitScale);

    	// return to default draw type
    	if (positions[positionIndex].occupant.DrawType != DT_Mesh)
    		positions[positionIndex].occupant.setDrawType(DT_Mesh);

    	// mark as unoccupied
    	positions[positionIndex].occupant = None;
    	clientPositions[positionIndex].occupant = None;

    	// put brakes on before you get out
        ThrottleInput = 0;
        StrafeInput = 0;
    	RotationInput = rot(0,0,0);
    	ThrustInput = 0;
    	DiveInput = false;

    	otherClientOccupantLeave(positionIndex, oldOccupant);

        return true;
    }

    // Called on all machines when an occupant leaves this vehicle.
    simulated function otherClientOccupantLeave(int positionI, Character oldOccupant)
    {
    	// animation
    	if (positions[positionI].exitAnimation != 'None')
    	{
    		PlayAnim(positions[positionI].exitAnimation);
    		animationFinishThenLoop[positionI] = positions[positionI].unoccupiedAnimation;
    	}

    	if (oldOccupant != None)
    		oldOccupant.showJetpack();

    	// driver exit effect
    	if (positionI == driverIndex)
    		TriggerEffectEvent('DriverExited');

    	// turn on shadow
    	if (oldOccupant.Shadow != None)
    		oldOccupant.Shadow.bShadowActive = true;
    }

    simulated function vector getCameraLookAt(rotator cameraRotation, int positionIndex)
    {
    	local rotator cameraWorkRotation;
    	cameraWorkRotation = cameraRotation;
    	cameraWorkRotation.Roll = 0;
    	if (!positions[positionIndex].lookAtInheritPitch)
    		cameraWorkRotation.Pitch = 0;
    	return positions[positionIndex].toBePossessed.Location + (TPCameraLookat >> cameraWorkRotation);
    }

    simulated function bool specialCalcViewProcessing(out actor viewActor, out vector cameraLocation,
    		out rotator cameraRotation, int positionIndex)
    {
    	local vector lookAt;
    	local vector HitLocation, HitNormal, OffsetVector;
    	local PlayerController pc;

    	pc = PlayerController(positions[positionIndex].toBePossessed.Controller);

    	// only do this mode we have a playercontroller viewing this vehicle
    	if (pc == None || positions[positionIndex].toBePossessed == None || pc.ViewTarget != positions[positionIndex].toBePossessed)
    		return false;

    	// always third person

    	ViewActor = positions[positionIndex].toBePossessed;

    	lookAt = getCameraLookAt(cameraRotation, positionIndex);

    	// calculate camera location
    	OffsetVector = vect(0, 0, 0);
    	OffsetVector.X = -1.0 * TPCameraDistance;
    	CameraLocation = lookAt + (OffsetVector >> cameraRotation);

    	// ... handle case of obstruction between vehicle and camera location
    	if (cameraTrace(HitLocation, HitNormal, CameraLocation, Location, false, vect(10, 10, 10)) != None)
    		CameraLocation = HitLocation;

    	// ... handle case vehicle obstructs trace between camera look at and camera location
    	if (bVehicleCameraTrace && !vehicleTrace(HitLocation, HitNormal, CameraLocation, lookAt, vehicleCameraTraceExtents))
    		CameraLocation = HitLocation;

    	if (bDrawDriverInTP)
    		positions[positionIndex].occupant.bOwnerNoSee = false;
    	else
    		positions[positionIndex].occupant.bOwnerNoSee = true;

    	return true;
    }

    // Special calc-view for vehicles.
    simulated function bool specialCalcView(out actor viewActor, out vector cameraLocation, out rotator cameraRotation)
    {
    	local bool retVal;

    	retVal = specialCalcViewProcessing(viewActor, cameraLocation, cameraRotation, driverIndex);
    	cachedCameraLocation = cameraLocation;

    	return retVal;
    }

    simulated function vector EyePosition()
    {
    	return cachedCameraLocation - Location;
    }

    simulated function Destroyed()
    {
        local int workIndex;

    	// turn off all effects and destroy observers
    	for (workIndex = 0; workIndex < effects.length; ++workIndex)
    	{
    		// switch off
    		if (effects[workIndex].flag)
    		{
    			UnTriggerEffectEvent(effects[workIndex].effectName);
    			effects[workIndex].flag = false;
    		}

    		// destroy
    		if (effects[workIndex].observer != None)
    		{
    			effects[workIndex].observer.cleanup();
    			effects[workIndex].observer.delete();
    			effects[workIndex].observer = None;
    		}
    	}

    	// destroy entries
    	for (workIndex = 0; workIndex < vehicleEntries.length; ++workIndex)
    		vehicleEntries[workIndex].destroy();

    	// destroy flip triggers
    	for (workIndex = 0; workIndex < vehicleFlipTriggers.length; ++workIndex)
    		vehicleFlipTriggers[workIndex].destroy();

    	// destroy driver weapon
    	if (driverWeapon != None)
    		driverWeapon.destroy();

    	if (motor != None)
    		motor.destroy();

    	Super.Destroyed();
    }

    simulated function bool isOccupied()
    {
    	local int index;
    	for (index = 0; index < positions.length; ++index)
    		if (clientPositions[index].occupant != None)
    			return true;
    	return false;
    }

    simulated event tick(float deltaSeconds)
    {
    	local bool gotOut;
    	local int index;
    	local int doNotEjectI;
    	local bool doNotEject;
    	local bool oldSettledUpsideDown;
    	local bool vehicleIsOccupied;
    	local name animationSequence;
    	local float animationFrame;
    	local float animationRate;

    	vehicleIsOccupied = isOccupied();

    	// kill ourselves if we are outside the boundary volume
    	if ((Level.NetMode == NM_ListenServer || Level.NetMode == NM_DedicatedServer) && Level.game.boundaryVolume != None &&
    			!Level.game.boundaryVolume.encompasses(self))
    		TakeDamage(health + 1, None, vect(0.0, 0.0, 0.0), vect(0.0, 0.0, 0.0), class'DamageType');

    	// stop firing driver weapon if no occupant
    	if (driverWeapon != None && driverWeapon.IsInState('FirePressed') && Controller == None)
    		driverWeapon.releaseFire();

    	// initial invincibility processing
    	if (Role == ROLE_Authority && bInvincible && Level.TimeSeconds > loseInitialInvincibilityTime)
    		bInvincible = false;

    	// handle case an occupant wants to get out
    	if (vehicleIsOccupied && Level.NetMode != NM_Client)
    	{
    		for (index = 0; index < positions.length; ++index)
    		{
    			if (positions[index].wantsToGetOut)
    			{
    				gotOut = driverLeave(false, index);
    				if (!gotOut )
    				{
    					Log("Couldn't Leave - staying in!");
    				}
    			}
    			positions[index].wantsToGetOut = false;
    		}
    	}

    	// boot occupants if settled upside down
    	if (vehicleIsOccupied && Level.NetMode != NM_Client && bSettledUpsideDown)
    	{
    		for (index = 0; index < positions.length; ++index)
    		{
    			if (positions[index].occupant != None)
    			{
    				// check if this functionality has been overridden
    				doNotEject = false;
    				for (doNotEjectI = 0; doNotEjectI < doNotEjectOnFlip.length; ++doNotEjectI)
    				{
    					if (doNotEjectOnFlip[doNotEjectI] == positions[index].type)
    					{
    						doNotEject = true;
    						break;
    					}
    				}
    				if (doNotEject)
    					continue;

    				aboutToSettleUpsideDown();

    				driverLeave(true, index);
    			}
    		}
    	}

    	// kick dead occupants (controller will possess dead character which appears to be OK)
    	if (vehicleIsOccupied && Level.NetMode != NM_Client)
    	{
    		for (index = 0; index < positions.length; ++index)
    		{
    			if (positions[index].occupant != None && !positions[index].occupant.isAlive())
    			{
    				driverLeave(true, index);
    				generateAIDeathSpeechEvents( index );
    			}
    		}
    	}

    	// vehicle effects processing
    	if (Level.NetMode != NM_DedicatedServer)
    	{
    		updateEffectsStates();
    		updateDynamicEffectStates();
    	}

    	// if server and not spawning process input and pack output for replication
    	if (Level.NetMode != NM_Client && !spawning)
    	{
    		processInput();
    		if ((Level.NetMode != NM_Standalone) && ((Level.TimeSeconds > maximumNextNetUpdateTime) || (HavokIsActive() &&
    				needToPushStateToClient())))
    		{
    			maximumNextNetUpdateTime = Level.TimeSeconds + maximumNetUpdateInterval;
    			pushStateToClient();
    		}
    	}

    	applyOutput();

    	// abandonment destruction functionality
    	if (Level.NetMode != NM_Client && abandonmentDestruction)
    	{
    		if (!vehicleIsOccupied)
    		{
    			currentAbandonmentDuration += deltaSeconds;
    			if (currentAbandonmentDuration > abandonmentDestructionPeriod)
    				destroy();
    		}
    		else
    			currentAbandonmentDuration = 0;
    	}

    	// always active if we have a driver
    	if (clientPositions[driverIndex].occupant != None)
    		HavokActivate(true);

    	// do animation processing
    	for (index = 0; index < animationFinishThenLoop.length; ++index)
    	{
    		if (animationFinishThenLoop[index] != 'None')
    		{
    			if (!IsAnimating(index))
    			{
    				LoopAnim(animationFinishThenLoop[index], 1, 0, index);
    				animationFinishThenLoop[index] = 'None';
    			}
    		}
    	}

    	// settled upside down processing
    	oldSettledUpsideDown = bSettledUpsideDown;
    	bSettledUpsideDown = isSettledUpsideDown();
    	if (oldSettledUpsideDown != bSettledUpsideDown && Level.NetMode != NM_Client)
    		settledUpsideDownChanged();

    	// check for client side tearoff
        if (bTearOff)
        {
            if ( !bPlayedDeath )
                PlayDying(HitDamageType, TakeHitLocation);
        }

    	// AI debug display
    	if ( bShowTyrionCharacterDebug || bShowSensingDebug )
    		displayTyrionDebugHeader();
    	if ( bShowSensingDebug )
    		displayEnemiesList();
    	if ( bShowTyrionCharacterDebug && vehicleAI != None )
    	{
    		vehicleAI.displayTyrionDebug();
    		for ( index = 0; index < positions.length; ++index )
    			if ( positions[index].toBePossessed != None)
    				positions[index].toBePossessed.mountAI.displayTyrionDebug();
    	}

    	// verify all occupants are in correct position and playing correct animation
    	if (vehicleIsOccupied)
    	{
    		for (index = 0; index < positions.length; ++index)
    		{
    			if (clientPositions[index].occupant != None)
    			{
    				// position
    				if (clientPositions[index].occupant.relativeLocation != positions[index].occupantRelativeLocation)
    					clientPositions[index].occupant.setRelativeLocation(positions[index].occupantRelativeLocation);
    				if (clientPositions[index].occupant.relativeRotation != positions[index].occupantRelativeRotation)
    					clientPositions[index].occupant.setRelativeRotation(positions[index].occupantRelativeRotation);

    				// animation
    				if (!positions[index].hideOccupant)
    				{
    					clientPositions[index].occupant.GetAnimParams(0, animationSequence, animationFrame, animationRate);
    					if (animationSequence != positions[index].occupantAnimation)
    						clientPositions[index].occupant.LoopAnim(positions[index].occupantAnimation);
    				}
    			}
    		}
    	}

    	// water damage
    	if (Level.NetMode != NM_Client && PhysicsVolume.bWaterVolume)
    		takeDamage(waterDamagePerSecond * deltaSeconds, self, Location, vect(0,0,0), class'DamageType');

    }

    function aboutToSettleUpsideDown();

    simulated function bool isSettledUpsideDown()
    {
    	local vector vehicleUp;
    	vehicleUp = vect(0,0,1) >> rotation;
    	return ((vehicleUp dot vect(0,0,1)) < settledUpsideDownCosAngle) && (VSizeSquared(velocity) < (settledUpsideDownSpeed *
    			settledUpsideDownSpeed));
    }

    simulated event bool isUpright()
    {
    	local vector vehicleUp;
    	vehicleUp = vect(0,0,1) >> rotation;
    	return ((vehicleUp dot vect(0,0,1)) > inverseCosUprightAngle);
    }

    function useEnergy(float amount)
    {

    }

    simulated function updateEffectsStates()
    {
    	local int workIndex;
    	local bool effectUntriggered;

    	for (workIndex = 0; workIndex < effects.length; ++workIndex)
    	{
    		if (effects[workIndex].flag && !isEffectCauserActive(workIndex))
    		{
    			//log("UnTrigger Effect: " $ effects[workIndex].effectName);
    			UnTriggerEffectEvent(effects[workIndex].effectName);
    			effects[workIndex].flag = false;
    			effectUntriggered = true;
    		}
    	}
    	for (workIndex = 0; workIndex < effects.length; ++workIndex)
    	{
    		if ((!effects[workIndex].flag || (effectUntriggered && retriggerEffectEvents)) && isEffectCauserActive(workIndex))
    		{
    			//log("Trigger Effect: " $ effects[workIndex].effectName);
    			TriggerEffectEvent(effects[workIndex].effectName, , , , , , , effects[workIndex].observer);
    			effects[workIndex].flag = true;
    		}
    	}
    }

    simulated function updateDynamicEffectStates();

    // Reurns true if a particular effect within the 'effects' array should be active. Classes that overload this function should call
    // super.isEffectCauserActive after doinf their own processing becuase Vehicle.isEffectCauserActive assumes nothing will be called after.
    simulated function bool isEffectCauserActive(int effectCauserIndex)
    {
    	switch (effectCauserIndex)
    	{
    	case throttleForwardEffectIndex:
    		return ThrottleInput > 0;
    	case throttleBackEffectIndex:
    		return ThrottleInput < 0;
    	case strafeLeftEffectIndex:
    		return StrafeInput > 0;
    	case strafeRightEffectIndex:
    		return StrafeInput < 0;
    	case engineIdlingEffectIndex:
    		return clientPositions[driverIndex].occupant != None;
    	case throttleForwardOrThrustEffectIndex:
    		return ThrottleInput > 0 || ThrustInput > 0;
    	case strafeLeftOrThrustEffectIndex:
    		return StrafeInput > 0 || ThrustInput > 0;
    	case strafeRightOrThrustEffectIndex:
    		return StrafeInput < 0 || ThrustInput > 0;
    	case thrustingEffectIndex:
    		return ThrustInput > 0;
    	}

    	// if we are here effect was not handled
    	warn("unknown effect causer index");
    }

    function toggleShowPhysicsDebug()
    {
    	bShowPhysicsDebug = !bShowPhysicsDebug;
    	showPhysicsDebug(bShowPhysicsDebug);
    }

    function displayWorldSpaceDebug(HUD displayHUD)
    {
    	local int vehicleEntryI;
    	local color workColor;
    	local vector workVector;
    	local int exitI;

    	super.displayWorldSpaceDebug(displayHUD);

    	// draw entry points
    	workColor.R = 0;
    	workColor.G = 255;
    	workColor.B = 255;
    	for (vehicleEntryI = 0; vehicleEntryI < vehicleEntries.length; ++vehicleEntryI)
    	{
    		displayHud.draw3DLine(vehicleEntries[vehicleEntryI].location, location, workColor);
    		drawActorCollision(vehicleEntries[vehicleEntryI], displayHUD, workColor);
    	}

    	// draw exit points
    	workColor.R = 255;
    	workColor.G = 0;
    	workColor.B = 0;
    	for (exitI = 0; exitI < exits.length; ++exitI)
    	{
    		workVector = Location + (exits[exitI].offset >> Rotation);
    		displayHud.draw3DLine(workVector, location, workColor);
    		displayHud.draw3DLine(workVector - vect(0, 0, 30), workVector + vect(0, 0, 30), workColor);
    	}

    	motor.displayWorldSpaceDebug(displayHUD);

    	workColor.R = 0;
    	workColor.G = 0;
    	workColor.B = 255;

    	// destination
    	if (!isHumanControlled())
    	{
    		displayHud.draw3DLine(location, localMoveDestination, workColor);
    	}

    	workColor.R = 100;
    	workColor.G = 100;
    	workColor.B = 100;

    	// rotation input
    	workVector = vect(1,0,0) >> rotationInput;
    	displayHud.draw3DLine(location, location + workVector * 500, workColor);
    }

    // Draws approximation of an actors collision cylinder.
    function drawActorCollision(Actor actor, HUD displayHUD, Color color)
    {
    	local vector workVector;

    	workVector.X = 0;
    	workVector.Y = 0;
    	workVector.Z = actor.collisionHeight;
    	displayHud.draw3DLine(actor.location + workVector, actor.location - workVector, color);
    	workVector.X = 0;
    	workVector.Y = actor.collisionRadius;
    	workVector.Z = 0;
    	displayHud.draw3DLine(actor.location + workVector, actor.location - workVector, color);
    	workVector.X = actor.collisionRadius;
    	workVector.Y = 0;
    	workVector.Z = 0;
    	displayHud.draw3DLine(actor.location + workVector, actor.location - workVector, color);
    }

    function showPhysicsDebug(bool show);

    function vector getProjectileSpawnLocation()
    {
    	// temporary
    	return location;
    }

    function onShotFiredNotification()
    {
    	// ignore
    }

    function float getEnergy()
    {
    	return 1000;
    }

    function bool aimAdjustViewRotation()
    {
    	return false;
    }

    simulated function vector getFirstPersonEquippableLocation(Equippable subject)
    {
    	warn("not implemented");
    	return location;
    }

    simulated function getAlternateAimAdjustStart(rotator cameraRotation, out vector newAimAdjustStart);

    simulated function rotator getFirstPersonEquippableRotation(Equippable subject)
    {
    	warn("not implemented");
    	return rotation;
    }

    simulated function getThirdPersonEquippableAttachment(Equippable subject, out Rook attachTo, out name boneName)
    {
    	warn("not implemented");
    }

    function Rook getPhysicalAttachment()
    {
    	return self;
    }

    function Weapon getWeapon()
    {
    	return driverWeapon;
    }

    simulated function Actor getEffectsBaseActor()
    {
    	return None;
    }

    simulated event PlayDying(class<DamageType> DamageType, vector HitLoc)
    {
    	local DynamicObject destructionObject;

    	if (bPlayedDeath)
    		return;

        bCanTeleport = false;
        bReplicateMovement = false;
        bTearOff = true;
        bPlayedDeath = true;

    	// note: these are replicated if need be, but we dont use em (for the moment)
    	//HitDamageType = DamageType;
        //TakeHitLocation = HitLoc;

    	if (Level.NetMode != NM_DedicatedServer)
    	{
    		// destruciton clientside rigid body
    		if (destructionObjectClass != None)
    		{
    			destructionObject = spawn(destructionObjectClass, , , Location, Rotation);
    			if (destructionObject != None)
    				destructionObject.NextVersion();
    		}

    		// effect event
    		TriggerEffectEvent('Destroyed');
    	}

    	// destruction explosion client and server
    	spawn(destroyedExplosionClass, , , Location, Rotation).Trigger(self, None);

    	GotoState('Dying');
    }

    State Dying
    {
    	simulated function BeginState()
    	{
    		// added this function because the default calls setPhysics(PHYS_Falling)

    		if (Controller != None)
    			Controller.PawnDied(self);

    		// NOTE: this 'technique' for deferred client fx copied straight from ut2k4
    		// If server, wait a second for replication of bTearOff so that client will do playdying (c
    		if ( Level.NetMode == NM_DedicatedServer || Level.NetMode == NM_ListenServer )
    			SetTimer(1.f, false);
    		// otherwise destroy straight away
    		else
    			Destroy();
    	}

    	simulated function Timer()
    	{
    		if ( !bDeleteMe )
    			Destroy();
    	}
    }

    singular event BaseChange()
    {
    	// nothing
    }

    simulated event collisionDamage(float magnitude)
    {
    	if (bCollisionDamageEnabled && magnitude >= minimumCollisionDamageMagnitude)
    	{
    		// apply damage on the server
    		if (ROLE == ROLE_Authority)
    			TakeDamage(collisionDamageMagnitudeScale * magnitude, self, Location, vect(0,0,0), class'DamageType');
    	}
    }

    simulated function playerMoveProcessing(float deltaTime)
    {
    	// nothing
    }

    function bool flip()
    {
    	if (bSettledUpsideDown && !bFlipping)
    	{
    		performFlip();
    		return true;
    	}
    	else
    	{
    		return false;
    	}
    }

    // If switch class is None the default class will be used.
    simulated function switchClass(class<Vehicle> switchClass)
    {
    	currentSwitchClass = switchClass;
    }

    simulated function startedSpawnFromVehicleSpawnPoint()
    {
    	// disable collision damage
    	if (ROLE == ROLE_Authority)
    		bCollisionDamageEnabled = false;
    }

    simulated function finishedSpawnFromVehicleSpawnPoint()
    {
    	setPhysics(PHYS_Havok);

    	if (ROLE == ROLE_Authority)
    		bCollisionDamageEnabled = class.default.bCollisionDamageEnabled;

    	TriggerEffectEvent('SpawnedFromSpawnPoint');
    }

    simulated function int getTargetPositionIndex(byte selectedPosition)
    {
    	return selectedPosition - 1;
    }

    function switchPosition(int currentPositionIndex, byte selectedPosition)
    {
    	local int targetPositionIndex;
    	local Controller c;
    	local PlayerController pc;
    	local Character character;
    	local ClientOccupantEnterData data;

    	if (!canSwitchPosition(currentPositionIndex, selectedPosition))
    		return;

    	targetPositionIndex = getTargetPositionIndex(selectedPosition);

    	// !!!!!!!!!! do not allow switching to minor positions
    	if (positions[targetPositionIndex].toBePossessed == None)
    		return;

    	character = positions[currentPositionIndex].occupant;

    	// get controller
    	if (positions[currentPositionIndex].toBePossessed != None)
    		c = positions[currentPositionIndex].toBePossessed.Controller;
    	else
    		c = positions[currentPositionIndex].occupant.controller;

    	pc = PlayerController(c);

    	// leave old position

    	c.Unpossess();

    	// ... do major position specific processing
    	if (positions[currentPositionIndex].toBePossessed != None)
    	{
    		positions[currentPositionIndex].toBePossessed.controller = None;
    	}

    	otherClientOccupantLeave(currentPositionIndex, positions[currentPositionIndex].occupant);

    	// ... mark as unoccupied
    	positions[currentPositionIndex].occupant = None;
    	clientPositions[currentPositionIndex].occupant = None;

    	// enter new position

    	// ... store occupant
    	positions[targetPositionIndex].occupant = character;
    	clientPositions[targetPositionIndex].occupant = character;

    	if (positions[targetPositionIndex].hideOccupant)
    	{
    		if (positions[targetPositionIndex].occupant.drawType != DT_None)
    			positions[targetPositionIndex].occupant.setDrawType(DT_None);
    	}
    	else
    	{
    		if (positions[targetPositionIndex].occupant.drawType != DT_Mesh)
    			positions[targetPositionIndex].occupant.setDrawType(DT_Mesh);
    	}

    	attachToVehicle(targetPositionIndex);

    	// ... do major position specific processing
    	if (positions[targetPositionIndex].toBePossessed != None)
    	{
    		positions[targetPositionIndex].occupant.SetOwner(c); // keeps the driver relevant
    		c.Possess(positions[targetPositionIndex].toBePossessed);

    		// ... player specific processing
    		if (pc != None)
    		{
    			// ... set playercontroller to view the vehicle
    			pc.ClientSetViewTarget(positions[targetPositionIndex].toBePossessed);

    			// ... change controller state to driver
    			pc.GotoState(positions[targetPositionIndex].occupantControllerState);
    		}
    	}

    	// ... handle case we are going from a major position to a minor position
    	if (positions[targetPositionIndex].toBePossessed == None && positions[targetPositionIndex].occupant.controller == None)
    		c.Possess(positions[targetPositionIndex].occupant);

    	// ... signal to client that driver has entered
    	data.controller = c;
    	data.occupant = positions[targetPositionIndex].occupant;
    	data.positionIndex = targetPositionIndex;
    	if (positions[targetPositionIndex].toBePossessed == self)
    	{
    		clientOccupantEnter(data);
    	}
    	else if (VehicleMountedTurret(positions[targetPositionIndex].toBePossessed) != None)
    	{
    		// ... go through VehicleMountedTurret because otherwise the function is not replicated, call will
    		// ... simply be forwarded to the vehicle on the client side
    		VehicleMountedTurret(positions[targetPositionIndex].toBePossessed).clientOccupantEnter(pc, positions[targetPositionIndex].occupant,
    				targetPositionIndex);
    	}

    	// ... update character flag
    	positions[targetPositionIndex].occupant.bHiddenVehicleOccupant = positions[targetPositionIndex].hideOccupant;

    	occupantEnterAnimationProcessing(targetPositionIndex);

    	otherClientOccupantEnter(targetPositionIndex);

    	occupantSwitchPosition(positions[targetPositionIndex].occupant, targetPositionIndex);
    }

    function int getMinorPositionEntryIndex(int positionIndex)
    {
    	return -1;
    }

    function occupantSwitchPosition(Character occupant, int targetPositionIndex)
    {

    }

    function UnPossessed()
    {
    	NetPriority = Default.NetPriority;

    	Super.UnPossessed();
    }

    function bool canSwitchPosition(int currentPositionIndex, byte selectedPosition)
    {
    	local int targetPositionIndex;

    	if (bDisablePositionSwitching)
    		return false;

    	// check someone in current position
    	if (positions[currentPositionIndex].occupant == None)
    		return false;

    	targetPositionIndex = getTargetPositionIndex(selectedPosition);

    	// check target position exists
    	if (targetPositionIndex >= positions.length)
    		return false;

    	// check no one in target position
    	if (positions[targetPositionIndex].occupant != None)
    		return false;

    	// check armour
    	if (!canArmorOccupy(positions[targetPositionIndex].type, positions[currentPositionIndex].occupant))
    		return false;

    	return true;
    }

    function InventoryStationAccess getCorrespondingInventoryStation()
    {
    	return None;
    }

    simulated function byte getPositionPromptIndex(VehiclePositionType positionType)
    {
    	switch (positionType)
    	{
    	case VehiclePositionType.VP_DRIVER:
    		return DRIVER_PROMPT_INDEX;
    	case VehiclePositionType.VP_GUNNER:
    		return GUNNER_PROMPT_INDEX;
    	case VehiclePositionType.VP_LEFT_GUNNER:
    		return LEFT_GUNNER_PROMPT_INDEX;
    	case VehiclePositionType.VP_RIGHT_GUNNER:
    		return RIGHT_GUNNER_PROMPT_INDEX;
    	case VehiclePositionType.VP_INVENTORY_STATION_ONE:
    	case VehiclePositionType.VP_INVENTORY_STATION_TWO:
    	case VehiclePositionType.VP_INVENTORY_STATION_THREE:
    	case VehiclePositionType.VP_INVENTORY_STATION_FOUR:
    		return INVENTORY_STATION_PROMPT_INDEX;
    	default:
    		warn("unknown vehicle position prompt");
    	}

    	return 255;
    }

    static function string getPrompt(byte promptIndex)
    {
    	switch (promptIndex)
    	{
    	case DRIVER_PROMPT_INDEX:
    		return default.driverPrompt;
    	case GUNNER_PROMPT_INDEX:
    		return default.gunnerPrompt;
    	case LEFT_GUNNER_PROMPT_INDEX:
    		return default.leftGunnerPrompt;
    	case RIGHT_GUNNER_PROMPT_INDEX:
    		return default.rightGunnerPrompt;
    	case INVENTORY_STATION_PROMPT_INDEX:
    		return default.inventoryStationPrompt;
    	case FULL_VEHICLE_PROMPT_INDEX:
    		return default.fullVehiclePrompt;
    	case VEHICLE_PROHIBITED_OBJECT_PROMPT_INDEX:
    		return default.vehicleProhibitedObjectPrompt;
    	case FLIP_PROMPT_INDEX:
    		return default.flipPrompt;
    	case CANNOT_STEAL_VEHICLE_PROMPT_INDEX:
    		return default.cannotStealPrompt;
    	case ENEMY_OCCUPIED_VEHICLE_PROMPT_INDEX:
    		return default.enemyOccupiedPrompt;
    	case ENEMY_INVENTORY_STATION_PROMPT_INDEX:
    		return default.enemyInventoryStationPrompt;
    	case HEAVY_ATTEMPT_TO_PILOT:
    		return default.heavyAttemptedToPilot;
    	default:
    		warn("unknown vehicle position prompt");
    	}

    	return "unknown";
    }

    simulated function Material GetOverlayMaterial(int Index)
    {
    	if (bInvincible)
    		return invicibilityMaterial;

    	return super.GetOverlayMaterial(Index);
    }

    simulated event bool ShouldProjectileHit(Actor projInstigator)
    {
    	// do not collide if it originated from us
    	if (self == projInstigator)
    		return false;

    	return super.ShouldProjectileHit(projInstigator);
    }

    simulated function bool customFiredEffectProcessing()
    {
    	return false;
    }

    simulated function doCustomFiredEffectProcessing()
    {
    	assert(false);
    }

    static function rotator interpolateRotation(rotator current, rotator target, float rate, float deltaSeconds)
    {
    	local rotator result;
    	local float pitchDelta;
    	local float yawDelta;

    	pitchDelta = target.Pitch - current.Pitch;
    	yawDelta = target.Yaw - current.Yaw;

    	if (pitchDelta > 32768)
    		pitchDelta = pitchDelta - 65536;
    	if (pitchDelta < -32768)
    		pitchDelta = 65536 + pitchDelta;

    	if (yawDelta > 32768)
    		yawDelta = yawDelta - 65536;
    	if (yawDelta < -32768)
    		yawDelta = 65536 + yawDelta;

    	if (abs(pitchDelta) > deltaSeconds * rate)
    		if (pitchDelta < 0)
    			pitchDelta = -deltaSeconds * rate;
    		else
    			pitchDelta = deltaSeconds * rate;

    	if (abs(yawDelta) > deltaSeconds * rate)
    		if (yawDelta < 0)
    			yawDelta = -deltaSeconds * rate;
    		else
    			yawDelta = deltaSeconds * rate;

    	result = current;
    	result.Pitch += pitchDelta;
    	result.Yaw += yawDelta;

    	result = Normalize(result);

    	return result;
    }

    function InventoryStationAccess getUnusedInventoryStation()
    {
    	return None;
    }

    simulated function bool canCharacterRespawnAt()
    {
    	return false;
    }

    simulated function String GetHumanReadableName()
    {
    	return localizedName;
    }

    function settledUpsideDownChanged();

    simulated function DisplayDebug(Canvas Canvas, out float YL, out float YPos)
    {
    	Super.DisplayDebug(Canvas, YL, YPos);

    	Canvas.SetDrawColor(0,255,0);

    	Canvas.SetPos(4,YPos);

    	// spawning flag
    	Canvas.DrawText("Spawning:" @ spawning);
    	YPos += YL;
    	Canvas.SetPos(4,YPos);

    	// last state received time
    	if (Level.NetMode == NM_Client)
    	{
    		Canvas.DrawText("Last Server State Receive Time:" @ lastStateReceiveTime);
    		YPos += YL;
    		Canvas.SetPos(4,YPos);
    	}

    	// havok state
    	if (Physics == PHYS_Havok)
    	{
    		Canvas.DrawText("Havok Is Active:" @ HavokIsActive() $ ", Havok Is Completely Initialised:" @ isHavokCompletelyInitialised());
    		YPos += YL;
    		Canvas.SetPos(4,YPos);
    	}

    	// make sure we are being ticked
    	Canvas.DrawText("Tick:" @ LastTick);
    	YPos += YL;
    	Canvas.SetPos(4,YPos);
    }

    static function int packPitchAndYaw(rotator pitchAndYaw)
    {
    	local int workAngle;
    	local int result;
    	pitchAndYaw = Normalize(pitchAndYaw);
    	workAngle = pitchAndYaw.Yaw;
    	if (workAngle < 0)
    		workAngle += 65536;
    	result = workAngle << 16;
    	workAngle = pitchAndYaw.Pitch;
    	if (workAngle < 0)
    		workAngle += 65536;
    	result = result | workAngle;
    	return result;
    }

    static function rotator unpackPitchAndYaw(int pitchAndYaw)
    {
    	local rotator result;
    	result.pitch = pitchAndYaw & (65535);
    	if (result.pitch > 32768)
    		result.pitch -= 65536;
    	result.yaw = pitchAndYaw >> 16;
    	if (result.yaw > 32768)
    		result.yaw -= 65536;
    	return result;
    }

    defaultproperties
    {
    	bEdShouldSnap=True
    	bStatic=False
    	bShadowCast=False
    	bCollideActors=True
    	bCollideWorld=False
    	bProjTarget=True
    	bBlockActors=True
    	bBlockNonZeroExtentTraces=True
    	bBlockZeroExtentTraces=True
    	bBlockPlayers=True
    	bWorldGeometry=False
    	bBlockKarma=True
    	CollisionHeight=+000001.000000
    	CollisionRadius=+000001.000000
    	bAcceptsProjectors=False
    	bCanBeBaseForPawns=True
    	bAlwaysRelevant=false
    	RemoteRole=ROLE_SimulatedProxy
    	bNetInitialRotation=true
    	bUseCompressedPosition=false
    	bSpecialCalcView=true
    	//bSpecialHUD=true

    	playerControllerState = "TribesPlayerDriving"

    	cameraDistance=1000

    	TPCameraLookat=(X=100,Y=0,Z=100)
    	TPCameraDistance=600

    	exits(0)=(offset=(X=0,Y=300,Z=100))
    	exits(1)=(offset=(X=0,Y=-300,Z=100))

    	bShowPhysicsDebug=false

    	entries(0)=(radius=200,height=200,offset=(X=0,Y=250,Z=150))
    	entries(1)=(radius=200,height=200,offset=(X=0,Y=-250,Z=150))

    	bActorShadows=true
    	ShadowLightDistance = 2000
    	MaxShadowTraceDistance = 800

    	bNetNotify=true

    	maximumNetUpdateInterval=0.5

    	bRotateToDesired = false

    	bUpdateSimulatedPosition = false

    	// required to replicate physics
    	bReplicateMovement = true

    	AI_LOD_Level = AILOD_MINIMAL

    	motorClass = class'VehicleMotor'

    	minimumObstacleLookAhead = 600
    	obstacleLookAheadVeloocityScale = 1
    	distanceToMaximumDurationScale = 0.005
    	cornerSlowDownDistance = 2000
    	cornerSlowDownMinimumCosAngle = -0.5
    	cornerSlowDownSpeedCoefficient = 10

    	abandonmentDestruction = false
    	currentAbandonmentDuration = 0

    	Physics = PHYS_Havok

    	TopSpeed = 2000

    	minimumCollisionDamageMagnitude = 100
    	collisionDamageMagnitudeScale = 0.0025

    	flipRotationStrength = 4
    	flipRotationDamping = 0.9
    	flipPushUpImpulse = 170000
    	flipPushUpDuration = 0.5

    	bCollisionDamageEnabled = true

    	healthModifier = 1

    	bCanBeStolen = true

    	driverPrompt = "**enter driver position"
    	gunnerPrompt = "**enter gunner position"
    	leftGunnerPrompt = "**enter left gunner position"
    	rightGunnerPrompt = "**enter right gunner position"
    	inventoryStationPrompt = "**enter inventory station position"
    	fullVehiclePrompt = "**vehicle is full"
    	vehicleProhibitedObjectPrompt = "you cannot enter a vehicle carrying fuel, flags or balls"
    	flipPrompt = "press <USE> to flip the vehicle"
    	cannotStealPrompt = "you cannot steal an enemy vehicle before it has been driven off the vehicle spawn"
    	enemyOccupiedPrompt = "you cannot enter a vehicle that is occupied by the enemy"
    	enemyInventoryStationPrompt = "you cannot use enemy base objects"
    	heavyAttemptedToPilot = "you can't pilot a vehicle when in heavy armour"

    	teamSpecificHavokCollisionFiltering = true

    	initialInvincibilityDuration = 6

    	invicibilityMaterial = Shader'FX.ScreenShader'

    	settledUpsideDownCosAngle = -0.1
    	settledUpsideDownSpeed = 50

    	velocityInheritOnExitScale = 1

    	waterDamagePerSecond = 10

    	stopForEnemies = true

    	bOwnerNoSee = false

    	bNeedPostRenderCallback = true	// required for DoIdentify to work

    	driveYawCoefficient = 0.05
    	drivePitchCoefficient = 0.05

    	clientInterpolationSnapDistance = 150
    	clientInterpolationPeriod = 0.2

    	flipMaximumRotationDuration = 3

    	heavyAttemptedToPilotSwitchPromptDuration = 3

    	driverMinimumPitch = -16202
    	driverMaximumPitch = 16202

    	bIsVehicle = true

    	vehicleCameraTraceExtents = (X=60,Y=60,Z=60)

    	inverseCosUprightAngle = 0.6
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

Class file time: ne 5.9.2004 15:53:28.000 - Creation time: st 23.5.2018 00:10:50.400 - Created with UnCodeX