-
Notifications
You must be signed in to change notification settings - Fork 12
/
Ped.ts
929 lines (738 loc) · 22.9 KB
/
Ped.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
import { Player, Vector3 } from '../';
import {
DrivingStyle,
FiringPattern,
Gender,
HelmetType,
RagdollType,
SpeechModifier,
VehicleSeat,
} from '../enums';
import { WeaponHash } from '../hashes';
import { Tasks } from '../Tasks';
import { Entity, PedBoneCollection, Vehicle } from './';
import { WeaponCollection } from '../weapon/WeaponCollection';
export class Ped extends Entity {
public static exists(ped: Ped): boolean {
return typeof ped !== 'undefined' && ped.exists();
}
private pedBones: PedBoneCollection | undefined;
private weapons: WeaponCollection | undefined;
private readonly speechModifierNames: string[] = [
'SPEECH_PARAMS_STANDARD',
'SPEECH_PARAMS_ALLOW_REPEAT',
'SPEECH_PARAMS_BEAT',
'SPEECH_PARAMS_FORCE',
'SPEECH_PARAMS_FORCE_FRONTEND',
'SPEECH_PARAMS_FORCE_NO_REPEAT_FRONTEND',
'SPEECH_PARAMS_FORCE_NORMAL',
'SPEECH_PARAMS_FORCE_NORMAL_CLEAR',
'SPEECH_PARAMS_FORCE_NORMAL_CRITICAL',
'SPEECH_PARAMS_FORCE_SHOUTED',
'SPEECH_PARAMS_FORCE_SHOUTED_CLEAR',
'SPEECH_PARAMS_FORCE_SHOUTED_CRITICAL',
'SPEECH_PARAMS_FORCE_PRELOAD_ONLY',
'SPEECH_PARAMS_MEGAPHONE',
'SPEECH_PARAMS_HELI',
'SPEECH_PARAMS_FORCE_MEGAPHONE',
'SPEECH_PARAMS_FORCE_HELI',
'SPEECH_PARAMS_INTERRUPT',
'SPEECH_PARAMS_INTERRUPT_SHOUTED',
'SPEECH_PARAMS_INTERRUPT_SHOUTED_CLEAR',
'SPEECH_PARAMS_INTERRUPT_SHOUTED_CRITICAL',
'SPEECH_PARAMS_INTERRUPT_NO_FORCE',
'SPEECH_PARAMS_INTERRUPT_FRONTEND',
'SPEECH_PARAMS_INTERRUPT_NO_FORCE_FRONTEND',
'SPEECH_PARAMS_ADD_BLIP',
'SPEECH_PARAMS_ADD_BLIP_ALLOW_REPEAT',
'SPEECH_PARAMS_ADD_BLIP_FORCE',
'SPEECH_PARAMS_ADD_BLIP_SHOUTED',
'SPEECH_PARAMS_ADD_BLIP_SHOUTED_FORCE',
'SPEECH_PARAMS_ADD_BLIP_INTERRUPT',
'SPEECH_PARAMS_ADD_BLIP_INTERRUPT_FORCE',
'SPEECH_PARAMS_FORCE_PRELOAD_ONLY_SHOUTED',
'SPEECH_PARAMS_FORCE_PRELOAD_ONLY_SHOUTED_CLEAR',
'SPEECH_PARAMS_FORCE_PRELOAD_ONLY_SHOUTED_CRITICAL',
'SPEECH_PARAMS_SHOUTED',
'SPEECH_PARAMS_SHOUTED_CLEAR',
'SPEECH_PARAMS_SHOUTED_CRITICAL',
];
private tasks: Tasks | undefined;
constructor(handle: number) {
super(handle);
}
public get Player(): Player {
return new Player(NetworkGetPlayerIndexFromPed(this.handle));
}
public get Money(): number {
return GetPedMoney(this.handle);
}
public set Money(amount: number) {
SetPedMoney(this.handle, amount);
}
public get Gender(): Gender {
return IsPedMale(this.handle) ? Gender.Male : Gender.Female;
}
public get Armor(): number {
return GetPedArmour(this.handle);
}
public set Armor(amount: number) {
if (amount > 100) amount = 100;
SetPedArmour(this.handle, amount);
}
public get Accuracy(): number {
return GetPedAccuracy(this.handle);
}
public set Accuracy(accuracy: number) {
if (accuracy > 100) accuracy = 100;
SetPedAccuracy(this.handle, accuracy);
}
public get Health(): number {
return super.Health - 100;
}
public set Health(amount: number) {
super.Health = amount + 100;
}
public get MaxHealth(): number {
return super.MaxHealth - 100;
}
public set MaxHealth(amount: number) {
super.MaxHealth = amount + 100;
}
public set Sweat(value: number) {
SetPedSweat(this.handle, value);
}
public set WetnessHeight(value: number) {
if (value === 0) {
ClearPedWetness(this.Handle);
} else {
SetPedWetnessHeight(this.handle, value);
}
}
public set Voice(value: string) {
SetAmbientVoiceName(this.handle, value);
}
public set ShootRate(value: number) {
if (value > 1000) value = 1000;
SetPedShootRate(this.handle, value);
}
public get WasKilledByStealth(): boolean {
return WasPedKilledByStealth(this.handle);
}
public get WasKilledByTakedown(): boolean {
return WasPedKilledByTakedown(this.handle);
}
public get SeatIndex(): VehicleSeat {
if (!this.CurrentVehicle) return VehicleSeat.None;
const numberOfSeats = GetVehicleModelNumberOfSeats(this.CurrentVehicle.Model.Hash);
for (let seat = -1; seat < numberOfSeats; seat++) {
if (this.CurrentVehicle.getPedOnSeat(seat).Handle == this.handle) {
return seat;
}
}
return VehicleSeat.None;
}
public get CurrentVehicle(): Vehicle | null {
const veh = new Vehicle(GetVehiclePedIsIn(this.handle, false));
return veh.exists() ? veh : null;
}
public get LastVehicle(): Vehicle | null {
const veh = new Vehicle(GetVehiclePedIsIn(this.handle, true));
return veh.exists() ? veh : null;
}
public get VehicleTryingToEnter(): Vehicle | null {
const veh = new Vehicle(GetVehiclePedIsTryingToEnter(this.handle));
return veh.exists() ? veh : null;
}
public get IsJumpingOutOfVehicle(): boolean {
return IsPedJumpingOutOfVehicle(this.handle);
}
public set StaysInVehicleWhenJacked(value: boolean) {
SetPedStayInVehicleWhenJacked(this.handle, value);
}
public set MaxDrivingSpeed(value: number) {
SetDriveTaskMaxCruiseSpeed(this.handle, value);
}
public get IsHuman(): boolean {
return IsPedHuman(this.handle);
}
public set IsEnemy(value: boolean) {
SetPedAsEnemy(this.handle, value);
}
public set IsPriorityTargetForEnemies(value: boolean) {
SetEntityIsTargetPriority(this.handle, value, 0);
}
public get IsPlayer(): boolean {
return IsPedAPlayer(this.handle);
}
public get IsCuffed(): boolean {
return IsPedCuffed(this.handle);
}
public get IsWearingHelmet(): boolean {
return IsPedWearingHelmet(this.handle);
}
public get IsRagdoll(): boolean {
return IsPedRagdoll(this.handle);
}
public get IsIdle(): boolean {
return (
!this.IsInjured &&
!this.IsRagdoll &&
!this.IsInAir &&
!this.IsOnFire &&
!this.IsDucking &&
!this.IsGettingIntoAVehicle &&
!this.IsInCombat &&
!this.IsInMeleeCombat &&
(!this.isInAnyVehicle() || this.isSittingInAnyVehicle())
);
}
public get IsProne(): boolean {
return IsPedProne(this.handle);
}
public set IsDucking(value: boolean) {
SetPedDucking(this.handle, value);
}
public get IsDucking(): boolean {
return IsPedDucking(this.handle);
}
public get IsGettingUp(): boolean {
return IsPedGettingUp(this.handle);
}
public get IsClimbing(): boolean {
return IsPedClimbing(this.handle);
}
public get IsJumping(): boolean {
return IsPedJumping(this.handle);
}
public get IsFalling(): boolean {
return IsPedFalling(this.handle);
}
public get IsStopped(): boolean {
return IsPedStopped(this.handle);
}
public get IsWalking(): boolean {
return IsPedWalking(this.handle);
}
public get IsRunning(): boolean {
return IsPedRunning(this.handle);
}
public get IsSprinting(): boolean {
return IsPedSprinting(this.handle);
}
public get IsDiving(): boolean {
return IsPedDiving(this.handle);
}
public get IsInParachuteFreeFall(): boolean {
return IsPedInParachuteFreeFall(this.handle);
}
public get IsSwimming(): boolean {
return IsPedSwimming(this.handle);
}
public get IsSwimmingUnderWater(): boolean {
return IsPedSwimmingUnderWater(this.handle);
}
public get IsVaulting(): boolean {
return IsPedVaulting(this.handle);
}
public get IsOnBike(): boolean {
return IsPedOnAnyBike(this.handle);
}
public get IsOnFoot(): boolean {
return IsPedOnFoot(this.handle);
}
public get IsInSub(): boolean {
return IsPedInAnySub(this.handle);
}
public get IsInTaxi(): boolean {
return IsPedInAnyTaxi(this.handle);
}
public get IsInTrain(): boolean {
return IsPedInAnyTrain(this.handle);
}
public get IsInHeli(): boolean {
return IsPedInAnyHeli(this.handle);
}
public get IsInPlane(): boolean {
return IsPedInAnyPlane(this.handle);
}
public get IsInFlyingVehicle(): boolean {
return IsPedInFlyingVehicle(this.handle);
}
public get IsInBoat(): boolean {
return IsPedInAnyBoat(this.handle);
}
public get IsInPoliceVehicle(): boolean {
return IsPedInAnyPoliceVehicle(this.handle);
}
public get IsJacking(): boolean {
return IsPedJacking(this.handle);
}
public get IsBeingJacked(): boolean {
return IsPedBeingJacked(this.handle);
}
public get IsGettingIntoAVehicle(): boolean {
return IsPedGettingIntoAVehicle(this.handle);
}
public get IsTryingToEnterALockedVehicle(): boolean {
return IsPedTryingToEnterALockedVehicle(this.handle);
}
public get IsInjured(): boolean {
return IsPedInjured(this.handle);
}
public get IsFleeing(): boolean {
return IsPedFleeing(this.handle);
}
public get IsInCombat(): boolean {
return IsPedInCombat(this.handle, PlayerPedId());
}
public get IsInMeleeCombat(): boolean {
return IsPedInMeleeCombat(this.handle);
}
public get IsInStealthMode(): boolean {
return GetPedStealthMovement(this.handle);
}
public get IsAmbientSpeechPlaying(): boolean {
return IsAmbientSpeechPlaying(this.handle);
}
public get IsScriptedSpeechPlaying(): boolean {
return IsScriptedSpeechPlaying(this.handle);
}
public get IsAnySpeechPlaying(): boolean {
return IsAnySpeechPlaying(this.handle);
}
public get IsAmbientSpeechEnabled(): boolean {
return !IsAmbientSpeechDisabled(this.handle);
}
public set IsPainAudioEnabled(value: boolean) {
DisablePedPainAudio(this.handle, !value);
}
public get IsPlantingBomb(): boolean {
return IsPedPlantingBomb(this.handle);
}
public get IsShooting(): boolean {
return IsPedShooting(this.handle);
}
public get IsAiming(): boolean {
return this.getConfigFlag(78);
}
public get IsReloading(): boolean {
return IsPedReloading(this.handle);
}
public get IsDoingDriveby(): boolean {
return IsPedDoingDriveby(this.handle);
}
public get IsGoingIntoCover(): boolean {
return IsPedGoingIntoCover(this.handle);
}
public get IsBeingStunned(): boolean {
return IsPedBeingStunned(this.handle, 0);
}
public get IsBeingStealthKilled(): boolean {
return IsPedBeingStealthKilled(this.handle);
}
public get IsPerformingStealthKill(): boolean {
return IsPedPerformingStealthKill(this.handle);
}
public get IsAimingFromCover(): boolean {
return IsPedAimingFromCover(this.handle);
}
public isInCover(expectUseWeapon = false): boolean {
return IsPedInCover(this.handle, expectUseWeapon);
}
public get IsInCoverFacingLeft(): boolean {
return IsPedInCoverFacingLeft(this.handle);
}
public set FiringPattern(value: FiringPattern) {
SetPedFiringPattern(this.handle, value);
}
public set DropsWeaponsOnDeath(value: boolean) {
SetPedDropsWeaponsWhenDead(this.handle, value);
}
public set DrivingSpeed(value: number) {
SetDriveTaskCruiseSpeed(this.handle, value);
}
public set DrivingStyle(style: DrivingStyle) {
SetDriveTaskDrivingStyle(this.handle, Number(style));
}
public set IsDrunk(isDrunk: boolean) {
SetPedIsDrunk(this.handle, isDrunk);
}
public set MotionBlur(value: boolean) {
SetPedMotionBlur(this.handle, value);
}
public get Task(): Tasks | undefined {
if (!this.tasks) {
this.tasks = new Tasks(this);
}
return this.tasks;
}
public get TaskSequenceProgress(): number {
return GetSequenceProgress(this.handle);
}
public set BlockPermanentEvents(block: boolean) {
SetBlockingOfNonTemporaryEvents(this.handle, block);
}
public isInAnyVehicle(): boolean {
return IsPedInAnyVehicle(this.handle, false);
}
public isInVehicle(vehicle: Vehicle): boolean {
return IsPedInVehicle(this.handle, vehicle.Handle, false);
}
public isSittingInAnyVehicle(): boolean {
return IsPedSittingInAnyVehicle(this.handle);
}
public isSittingInVehicle(vehicle: Vehicle): boolean {
return IsPedSittingInVehicle(this.handle, vehicle.Handle);
}
public setIntoVehicle(vehicle: Vehicle, seat: VehicleSeat): void {
SetPedIntoVehicle(this.handle, vehicle.Handle, Number(seat));
}
public isHeadtracking(entity: Entity): boolean {
return IsPedHeadtrackingEntity(this.handle, entity.Handle);
}
public isInCombatAgainst(target: Ped): boolean {
return IsPedInCombat(this.handle, target.Handle);
}
public getJacker(): Ped {
return new Ped(GetPedsJacker(this.handle));
}
public getJackTarget(): Ped {
return new Ped(GetJackTarget(this.handle));
}
public getMeleeTarget(): Ped {
return new Ped(GetMeleeTargetForPed(this.handle));
}
public getKiller(): Entity | null {
return Ped.fromHandle(GetPedSourceOfDeath(this.handle));
}
public kill(): void {
this.Health = -1;
}
public resurrect(): void {
const maxHealth: number = this.Health;
const isCollisionEnabled: boolean = super.IsCollisionEnabled;
ResurrectPed(this.handle);
this.MaxHealth = maxHealth;
this.Health = maxHealth;
super.IsCollisionEnabled = isCollisionEnabled;
ClearPedTasksImmediately(this.handle);
}
public resetVisibleDamage(): void {
ResetPedVisibleDamage(this.handle);
}
public clearBloodDamage(): void {
ClearPedBloodDamage(this.handle);
}
// TODO: Add RelationshipGroup
public get IsInGroup(): boolean {
return IsPedInGroup(this.handle);
}
public set NeverLeavesGroup(value: boolean) {
SetPedNeverLeavesGroup(this.handle, value);
}
public leaveGroup(): void {
RemovePedFromGroup(this.handle);
}
public playAmbientSpeed(
speechName: string,
voiceName = '',
modifier: SpeechModifier = SpeechModifier.Standard,
): void {
if (Number(modifier) >= 0 && Number(modifier) < this.speechModifierNames.length) {
if (voiceName === '') {
PlayAmbientSpeech1(this.handle, speechName, this.speechModifierNames[Number(modifier)]);
} else {
PlayAmbientSpeechWithVoice(
this.handle,
speechName,
voiceName,
this.speechModifierNames[Number(modifier)],
false,
);
}
} else {
throw new RangeError('modifier');
}
}
public applyDamage(damageAmount: number, armorFirst = true): void {
ApplyDamageToPed(this.handle, damageAmount, armorFirst);
}
public hasBeenDamagedByWeapon(weapon: WeaponHash): boolean {
return HasPedBeenDamagedByWeapon(this.handle, Number(weapon), 0);
}
public hasBeenDamagedByAnyWeapon(): boolean {
return HasPedBeenDamagedByWeapon(this.handle, 0, 2);
}
public hasBeenDamagedByAnyMeleeWeapon(): boolean {
return HasPedBeenDamagedByWeapon(this.handle, 0, 1);
}
public clearLastWeaponDamage(): void {
ClearPedLastWeaponDamage(this.handle);
}
public get Bones(): PedBoneCollection {
if (!this.pedBones) {
this.pedBones = new PedBoneCollection(this);
}
return this.pedBones;
}
/**
* Ped Weapons
*
* @constructor
*/
public get Weapons(): WeaponCollection {
if (!this.weapons) {
this.weapons = new WeaponCollection(this);
}
return this.weapons;
}
public giveWeapon(weapon: WeaponHash, ammoCount = 999, isHidden = false, equipNow = true): void {
GiveWeaponToPed(this.handle, weapon, ammoCount, isHidden, equipNow);
}
public removeWeapon(weapon: WeaponHash): void {
RemoveWeaponFromPed(this.handle, weapon);
}
public removeAllWeapons(): void {
RemoveAllPedWeapons(this.handle, true);
}
public getLastWeaponImpactPosition(): Vector3 {
const position = GetPedLastWeaponImpactCoord(this.handle)[1];
return new Vector3(position[0], position[1], position[2]); // Does this work?
}
public get CanRagdoll(): boolean {
return CanPedRagdoll(this.handle);
}
public set CanRagdoll(value: boolean) {
SetPedCanRagdoll(this.handle, value);
}
public ragdoll(duration = -1, ragdollType: RagdollType = RagdollType.Normal): void {
this.CanRagdoll = true;
SetPedToRagdoll(this.handle, duration, duration, Number(ragdollType), false, false, false);
}
public cancelRagdoll(): void {
SetPedToRagdoll(this.handle, 1, 1, 1, false, false, false);
}
public giveHelmet(
canBeRemovedByPed: boolean,
helmetType: HelmetType,
textureIndex: number,
): void {
GivePedHelmet(this.handle, !canBeRemovedByPed, Number(helmetType), textureIndex);
}
public removeHelmet(instantly: boolean): void {
RemovePedHelmet(this.handle, instantly);
}
public openParachute(): void {
ForcePedToOpenParachute(this.handle);
}
public getConfigFlag(flagId: number): boolean {
return GetPedConfigFlag(this.handle, flagId, true);
}
public setConfigFlag(flagId: number, value: boolean): void {
SetPedConfigFlag(this.handle, flagId, value);
}
public resetConfigFlag(flagId: number): void {
SetPedResetFlag(this.handle, flagId, true);
}
// TODO: Proper extension for this
public clone(): Ped {
return new Ped(ClonePed(this.handle, false, false, false));
}
public exists(ped?: Ped): boolean {
if (!ped) {
return super.exists() && GetEntityType(this.handle) === 1;
}
return ped?.exists() ?? false;
}
public setComponentVariation(
componentId: number,
drawableId: number,
textureId: number,
paletteId = 0,
): void {
SetPedComponentVariation(this.handle, componentId, drawableId, textureId, paletteId);
}
public setRandomComponentVariation(): void {
SetPedRandomComponentVariation(this.handle, 0);
}
public setDefaultComponentVariation(): void {
SetPedDefaultComponentVariation(this.handle);
}
public getDrawableVariation(componentId: number): number {
return GetPedDrawableVariation(this.handle, componentId);
}
public getNumberOfDrawableVariations(componentId: number): number {
return GetNumberOfPedDrawableVariations(this.handle, componentId);
}
public getTextureVariation(componentId: number): number {
return GetPedTextureVariation(this.handle, componentId);
}
public getNumberTextureVariations(
componentId: number,
drawableId = this.getDrawableVariation(componentId),
): number {
return GetNumberOfPedTextureVariations(this.handle, componentId, drawableId);
}
public setRandomProps(): void {
SetPedRandomProps(this.handle);
}
public setPropIndex(propId: number, drawableId: number, textureId: number, attach = true): void {
SetPedPropIndex(this.handle, propId, drawableId, textureId, attach);
}
public clearProp(propId: number): void {
ClearPedProp(this.handle, propId);
}
public clearAllProps(): void {
ClearAllPedProps(this.handle);
}
public knockPropOff(p1: boolean, p2: boolean, p3: boolean, p4: boolean): void {
KnockOffPedProp(this.handle, p1, p2, p3, p4);
}
public isPropValid(propId: number, drawableId: number, textureId: number): boolean {
return SetPedPreloadPropData(this.handle, propId, drawableId, textureId);
}
public getPropIndex(propId: number): number {
return GetPedPropIndex(this.handle, propId);
}
public getNumberOfPropDrawableVariations(propId: number): number {
return GetNumberOfPedPropDrawableVariations(this.handle, propId);
}
public getNumberOfPropTextureVariations(
propId: number,
drawableId = this.getPropIndex(propId),
): number {
return GetNumberOfPedPropTextureVariations(this.handle, propId, drawableId);
}
public getPropTextureIndex(propId: number): number {
return GetPedPropTextureIndex(this.handle, propId);
}
public setHelmetPropIndex(propIndex: number): void {
SetPedHelmetPropIndex(this.handle, propIndex);
}
public setEyeColor(color: number): void {
SetPedEyeColor(this.handle, color);
}
public getEyeColor(): number {
return GetPedEyeColor(this.handle);
}
public setHairColors(primary: number, highlight: number): void {
SetPedHairColor(this.handle, primary, highlight);
}
public setHairColor(color: number): void {
this.setHairColors(color, this.getHairHighlightColor());
}
public getHairColor(): number {
return GetPedHairColor(this.handle);
}
public setHairHighlightColor(color: number): void {
this.setHairColors(this.getHairColor(), color);
}
public getHairHighlightColor(): number {
return GetPedHairHighlightColor(this.handle);
}
public getHeadOverlayNum(overlayId: number): number {
return GetPedHeadOverlayNum(overlayId);
}
public getHeadOverlayValue(overlayId: number): number {
return GetPedHeadOverlayValue(this.handle, overlayId);
}
public setHeadOverlayValue(overlayId: number, value: number): void {
const opacity = GetPedHeadOverlayData(this.handle, overlayId)[5];
this.setHeadOverlay(overlayId, value, opacity);
}
public getHeadOverlay(overlayId: number): [number, number, number, number, number] | void {
const [ret, overlayValue, colourType, firstColour, secondColour, overlayOpacity] =
GetPedHeadOverlayData(this.handle, overlayId);
if (!ret) {
return undefined;
}
return [overlayValue, colourType, firstColour, secondColour, overlayOpacity];
}
public setHeadOverlay(overlayId: number, index: number, opacity: number): void {
SetPedHeadOverlay(this.handle, overlayId, index, opacity);
}
public getHeadOverlayOpacity(overlayId: number): number {
return GetPedHeadOverlayData(this.handle, overlayId)[5];
}
public setHeadOverlayOpacity(overlayId: number, opacity: number): void {
this.setHeadOverlay(overlayId, this.getHeadOverlayValue(overlayId), opacity);
}
public setHeadOverlayColor(overlayId: number, color: number): void {
let colorId = 0;
if (overlayId === 1 || overlayId === 2 || overlayId === 10) {
colorId = 1;
} else if (overlayId === 5 || overlayId === 8) {
colorId = 2;
}
SetPedHeadOverlayColor(this.handle, overlayId, colorId, color, color);
}
public setHeadBlend(
shapeFirstID: number,
shapeSecondID: number,
shapeThirdID: number,
skinFirstID: number,
skinSecondID: number,
skinThirdID: number,
shapeMix: number,
skinMix: number,
thirdMix: number,
isParent = false,
): void {
SetPedHeadBlendData(
this.handle,
shapeFirstID,
shapeSecondID,
shapeThirdID,
skinFirstID,
skinSecondID,
skinThirdID,
shapeMix,
skinMix,
thirdMix,
isParent,
);
}
public getHeadBlend():
| [number, number, number, number, number, number, number, number, number, boolean]
| void {
const buffer = new ArrayBuffer(80);
if (
!(Citizen.invokeNative(
'0x2746BD9D88C5C5D0',
this.handle,
new Float32Array(buffer),
) as unknown)
) {
return undefined;
}
const {
0: shapeFirstId,
2: shapeSecondId,
4: shapeThirdId,
6: skinFirstId,
8: skinSecondId,
10: skinThirdId,
18: isParent,
} = new Uint32Array(buffer);
const { 0: shapeMix, 2: skinMix, 4: thirdMix } = new Float32Array(buffer, 48);
return [
shapeFirstId,
shapeSecondId,
shapeThirdId,
skinFirstId,
skinSecondId,
skinThirdId,
shapeMix,
skinMix,
thirdMix,
!!isParent,
];
}
public finalizeHeadBlend(): void {
FinalizeHeadBlend(this.handle);
}
public hasHeadBlendFinished(): boolean {
return HasPedHeadBlendFinished(this.handle);
}
}