-
Notifications
You must be signed in to change notification settings - Fork 0
/
RideablePokemon_Script.uc
940 lines (890 loc) · 30.3 KB
/
RideablePokemon_Script.uc
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
930
931
932
933
934
935
936
937
938
939
940
class RideablePokemon_Script extends GameMod
config(Mods);
enum LoadoutItem_State
{
State_Remove,
State_Add,
State_Equip
};
struct LoadoutItem
{
var class<Object> ItemClass;
var LoadoutItem_State ItemState;
};
enum NotifyType
{
Type_None,
Type_Select
};
var transient private Array<Hat_GhostPartyPlayerStateBase> RideablePokemonGppStates;
var transient private Hat_MusicNodeBlend_Dynamic FurretMusicTrack;
var transient private Array<Hat_Player> CurrentPlayers;
var config int FurretMusic, OnlineFurretMusic, AllowPokemonScaring, DebugMessages, PokemonSelect, EnableCollision, AllowTimedEventSkins;
static function bool UpdatePokemonSelectNotifyLevelBit() //Returns true if level bit was less than 1 and subtitle message should be displayed.
{
local int i;
local Hat_SaveGame_Base sg;
sg = class'Hat_SaveBitHelper'.static.GetSaveGame();
if (sg == None)
return false;
i = class'Hat_SaveBitHelper_Base'.static.GetLevelBits("pokemonselectnotify", "rideablepokemon", sg);
if (i < 1)
{
class'Hat_SaveBitHelper_Base'.static.SetLevelBits("pokemonselectnotify", 1, "rideablepokemon", sg);
return true;
}
if (i != 1)
class'Hat_SaveBitHelper_Base'.static.SetLevelBits("pokemonselectnotify", 1, "rideablepokemon", sg);
return false;
}
static function RemoveModLevelBits()
{
RemovePokemonSelectNotifyLevelBit();
}
static function bool RemovePokemonSelectNotifyLevelBit() //Returns true if level bit was not equal to 0.
{
local Hat_SaveGame_Base sg;
sg = class'Hat_SaveBitHelper'.static.GetSaveGame();
if (sg == None)
return false;
if (class'Hat_SaveBitHelper_Base'.static.GetLevelBits("pokemonselectnotify", "rideablepokemon", sg) != 0)
{
class'Hat_SaveBitHelper_Base'.static.SetLevelBits("pokemonselectnotify", 0, "rideablepokemon", sg);
return true;
}
return false;
}
static function bool IsCollisionEnabled()
{
return (GetConfigValue(default.Class, NameOf(default.EnableCollision)) < 1);
}
static function bool IsPokemonScaringAllowed()
{
return (GetConfigValue(default.Class, NameOf(default.AllowPokemonScaring)) < 1);
}
static function bool AreTimedEventSkinsAllowed()
{
return (GetConfigValue(default.Class, NameOf(default.AllowTimedEventSkins)) < 1);
}
static function string GetClassPathName(class<Object> c)
{
if (c == None)
return "None";
if (IsBaseGameClass(c))
return string(c.Name);
return PathName(c);
}
static function bool IsBaseGameClass(class<Object> c)
{
if (c == None)
return true;
return IsBaseGameClassPackage(c.GetPackageName());
}
static function bool IsBaseGameClassPackage(Name PackageName)
{
switch(locs(PackageName))
{
case "core":
case "engine":
case "gameframework":
case "hatintimeeditor":
case "hatintimegame":
case "hatintimegamecontent":
case "ipdrv":
case "onlinesubsystemsteamworks":
case "unrealed":
case "windrv":
default:
return false;
}
}
static function string GetPlayerString(Object o, optional bool FirstCapital)
{
local Hat_Player ply;
local Hat_GhostPartyPlayer gpp;
local Hat_GhostPartyPlayerStateBase s;
local PlayerController pc;
local string SteamID;
local int PlayerIndex;
if (o == None)
return "None";
pc = class'Shara_SteamID_Tools_RPS'.static.GetPlayerController(o);
if (pc != None)
{
PlayerIndex = class'Shara_SteamID_Tools_RPS'.static.GetPlayerIndex(pc);
if (PlayerIndex < 0)
{
if (FirstCapital)
return "Indexless Local Player"@(pc.Pawn == None ? "None" : GetClassPathName(pc.Pawn.Class));
return "indexless Local Player"@(pc.Pawn == None ? "None" : GetClassPathName(pc.Pawn.Class));
}
return "Local Player"@PlayerIndex+1@(pc.Pawn == None ? "None" : GetClassPathName(pc.Pawn.Class));
}
ply = class'Shara_SteamID_Tools_RPS'.static.GetPlayerPawn(o);
if (ply != None)
{
if (FirstCapital)
return "Fake Local Player"@GetClassPathName(ply.Class);
return "fake Local Player"@GetClassPathName(ply.Class);
}
gpp = Hat_GhostPartyPlayer(o);
if (gpp != None)
{
s = gpp.PlayerState;
if (s == None)
return "Online Player"@GetClassPathName(gpp.PlayerVisualClass == None ? class'Hat_Player_HatKid' : gpp.PlayerVisualClass)@"without Player State";
SteamID = s.GetNetworkingIDString();
if (SteamID == "")
return "Online Player"@s.SubID+1@GetClassPathName(gpp.PlayerVisualClass == None ? class'Hat_Player_HatKid' : gpp.PlayerVisualClass)@"with destroyed Player State";
return "Online Player"@s.SubID+1@GetClassPathName(gpp.PlayerVisualClass == None ? class'Hat_Player_HatKid' : gpp.PlayerVisualClass)@"with Steam ID"@SteamID@"("$s.GetDisplayName()$")";
}
s = Hat_GhostPartyPlayerStateBase(o);
if (s == None)
{
if (FirstCapital)
return "Unknown"@GetClassPathName(o.Class);
return "unknown"@GetClassPathName(o.Class);
}
if (SteamID == "")
{
if (s.IsLocalPlayer())
{
if (FirstCapital)
return "Destroyed Player State of Local Player"@s.SubID+1;
return "destroyed Player State of Local Player"@s.SubID+1;
}
if (FirstCapital)
return "Destroyed Player State of Online Player"@s.SubID+1;
return "destroyed Player State of Online Player"@s.SubID+1;
}
if (s.IsLocalPlayer())
{
if (FirstCapital)
return "Player State of Local Player"@s.SubID+1;
return "Player State of Local Player"@s.SubID+1;
}
return "Player State of Online Player"@s.SubID+1@"with Steam ID"@SteamID@"("$s.GetDisplayName()$")";
}
static function SendWarningMessage(string Message, optional Object Sender)
{
local WorldInfo wi;
local PlayerController pc;
if (Message == "")
return;
if (GetConfigValue(default.Class, 'DebugMessages') == 0)
return;
if (!IsDev())
return;
LogMod(Message);
pc = class'Shara_SteamID_Tools_RPS'.static.GetPlayerController(Sender);
if (pc != None)
pc.ClientMessage(Message);
else
{
wi = class'WorldInfo'.static.GetWorldInfo();
if (wi != None && wi.Game != None)
wi.Game.Broadcast(wi, Message);
}
}
static function SendMessageArray(Array<string> StringArray, optional Object Sender)
{
local int i;
local string s;
for (i = 0; i < StringArray.Length; i++)
{
s $= StringArray[i];
if (i != StringArray.Length-1)
s $= "\n";
}
SendWarningMessage(s, Sender);
}
static function RideablePokemon_Script GetModInstance()
{
local RideablePokemon_Script inst;
local WorldInfo wi;
wi = class'WorldInfo'.static.GetWorldInfo();
if (wi == None)
return None;
foreach wi.AllActors(class'RideablePokemon_Script', inst)
{
if (inst != None)
return inst;
}
return None;
}
static function bool IsDev()
{
local string SteamID;
SteamID = class'Shara_SteamID_Tools_RPS'.static.GetMySteamID();
if (SteamID == "76561198063502902") //Shararamosh.
return true;
return false;
}
static function class<Hat_StatusEffect_RideablePokemon> GetPokemonFromConfig(optional out NotifyType nt)
{
local int n;
local Array<class<Hat_StatusEffect_RideablePokemon>> PokemonEffects;
PokemonEffects = class'RideablePokemon_OnlinePartyHandler'.static.GetStandardPokemonStatusEffects();
n = Clamp(GetConfigValue(default.Class, 'PokemonSelect'), 0, PokemonEffects.Length); //Gotta make sure we won't end up outside Pokemon list.
if (UpdatePokemonSelectNotifyLevelBit())
nt = Type_Select;
else
nt = Type_None;
if (n == 0)
return None; //Otherwise use Pokemon tied to flair.
return PokemonEffects[n-1]; //Use Pokedex-sorted list of available Pokemon.
}
function OnPreStatusEffectAdded(Pawn PawnCombat, out class<Object> StatusEffect, optional out float OverrideDuration)
{
local class<Hat_StatusEffect_RideablePokemon> PokemonStatus, NewPokemonStatus;
local Hat_PawnCombat p;
local Hat_Player ply;
local NotifyType nt;
local bool IsPredefined;
PokemonStatus = class<Hat_StatusEffect_RideablePokemon>(StatusEffect);
if (PokemonStatus == None)
return;
p = Hat_PawnCombat(PawnCombat);
if (p != None)
{
p.RemoveStatusEffect(class'Hat_StatusEffect_BadgeScooter', true);
ply = Hat_Player(p);
}
if (ply == None)
{
StatusEffect = None;
return;
}
if (!PokemonStatus.static.IsTiedToFlair() && !PokemonStatus.static.IsDebugOnly())
{
NewPokemonStatus = GetPokemonFromConfig(nt);
if (nt == Type_Select)
ShowSubtitleForPlayer(class'Shara_SteamID_Tools_RPS'.static.GetPawnPlayerController(ply), "RideablePokemon|ConfigNotify|system");
if (NewPokemonStatus != None && NewPokemonStatus.static.CanRidePokemon(ply, true, false))
{
PokemonStatus = NewPokemonStatus;
IsPredefined = true;
}
}
NewPokemonStatus = PokemonStatus.static.GetRandomAppearance(true, !IsPredefined);
if (NewPokemonStatus.static.CanRidePokemon(ply, true, false))
StatusEffect = NewPokemonStatus;
else
{
if (IsPredefined || PokemonStatus.static.CanRidePokemon(ply, true, true))
StatusEffect = PokemonStatus;
else
{
if (HasNonVanillaScooterBadge(ply))
StatusEffect = class'Hat_StatusEffect_BadgeScooter';
else
{
StatusEffect = class<Hat_StatusEffect_BadgeScooter>(class'Hat_ClassHelper'.static.GetScriptClass("DyeableScooter.Hat_StatusEffect_DyeableScooter"));
if (StatusEffect == None)
StatusEffect = class'Hat_StatusEffect_BadgeScooter';
}
}
}
}
static function bool HasNonVanillaScooterBadge(Hat_Player ply)
{
local int i;
local Hat_InventoryManager im;
local Hat_Badge_Scooter ScooterBadge;
if (ply == None)
return false;
im = Hat_InventoryManager(ply.InvManager);
if (im == None)
return false;
for (i = 0; i < im.Badges.Length; i++)
{
ScooterBadge = Hat_Badge_Scooter(im.Badges[i]);
if (ScooterBadge == None)
continue;
if (ScooterBadge.Class == class'Hat_Badge_Scooter' || ScooterBadge.Class == class'Hat_Badge_Scooter_Subcon')
continue;
return true;
}
return false;
}
static function RemoveModStatusEffects()
{
local WorldInfo wi;
local Hat_Player ply;
wi = class'WorldInfo'.static.GetWorldInfo();
if (wi == None)
return;
foreach wi.AllPawns(class'Hat_Player', ply)
{
if (ply != None)
ply.RemoveStatusEffect(class'Hat_StatusEffect_RideablePokemon', true);
}
}
static function RemoveModActors()
{
local int i;
local WorldInfo wi;
local Hat_RideablePokemon_Collision CollisionActor;
local Array<Hat_RideablePokemon_Collision> RemoveList;
wi = class'WorldInfo'.static.GetWorldInfo();
if (wi == None)
return;
foreach wi.AllActors(class'Hat_RideablePokemon_Collision', CollisionActor)
{
if (CollisionActor != None)
RemoveList.AddItem(CollisionActor);
}
for (i = 0; i < RemoveList.Length; i++)
{
if (RemoveList[i] == None)
continue;
if (!RemoveList[i].Destroy())
RemoveList[i].ShutDown();
}
RemoveList.Length = 0;
}
static function RemoveModItems()
{
local Array<LoadoutItem> ModItems;
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_SafariHat', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_Substitute', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_TrapperHat', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_DawnHat', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_WoolKnit', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_GlaceonCap', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_OverallsCap', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_SummerHat', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_LeafeonCap', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_RibbonBoater', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_SpringHat', State_Remove));
ModItems.AddItem(MakeLoadoutItem(class'Hat_CosmeticItemQualityInfo_Sprint_SylveonCap', State_Remove));
HandleAllLoadoutItems(ModItems);
}
static function LoadoutItem MakeLoadoutItem(class<Object> ObjectClass, LoadoutItem_State lis)
{
local LoadoutItem li;
li.ItemClass = ObjectClass;
li.ItemState = lis;
return li;
}
static function HandleAllLoadoutItems(Array<LoadoutItem> LoadoutItems)
{
local WorldInfo wi;
local Hat_PlayerController hpc;
if (LoadoutItems.Length < 1)
return;
wi = class'WorldInfo'.static.GetWorldInfo();
if (wi == None)
return;
foreach wi.AllControllers(class'Hat_PlayerController', hpc)
{
if (hpc == None)
continue;
HandleLoadoutItems(hpc.GetLoadout(), LoadoutItems);
}
}
static function HandleLoadoutItems(Hat_Loadout l, Array<LoadoutItem> LoadoutItems)
{
local int i;
local class<Actor> MainItem;
local class<Hat_CosmeticItemQualityInfo> FlairClass;
if (LoadoutItems.Length < 1)
return;
if (l == None)
return;
for (i = 0; i < LoadoutItems.Length; i++)
{
if (LoadoutItems[i].ItemClass == None)
continue;
FlairClass = class<Hat_CosmeticItemQualityInfo>(LoadoutItems[i].ItemClass);
if (FlairClass != None)
MainItem = FlairClass.static.GetBaseCosmeticItemWeApplyTo();
else
MainItem = class<Actor>(LoadoutItems[i].ItemClass);
HandleLoadoutActorItem(l, MainItem, FlairClass, LoadoutItems[i].ItemState);
}
}
static function bool HandleLoadoutActorItem(Hat_Loadout l, class<Actor> ActorClass, class<Hat_CosmeticItemQualityInfo> FlairClass, LoadoutItem_State lis)
{
local Hat_LoadoutBackpackItem lbi;
if (l == None)
return false;
if (ActorClass == None || ClassIsDeprecated(ActorClass)) //No item?
return false;
if (FlairClass != None && ClassIsDeprecated(FlairClass)) //Abstract or deprecated Flair? Uh, that's definitely an error.
return false;
lbi = l.MakeLoadoutItem(ActorClass, FlairClass, l.SaveGame);
if (lbi == None)
return false;
if (lis < State_Add)
return l.RemoveBackpack(lbi);
if (lbi.ItemQualityInfo == None) //Item has no Flair at all, so we just give it to Player.
return l.AddBackpack(lbi, lis > State_Add);
if (l.BackpackHasInventory(class<Actor>(lbi.BackpackClass), false, lbi.ItemQualityInfo != None ? class<Hat_CosmeticItemQualityInfo>(lbi.ItemQualityInfo.default.CosmeticItemWeApplyTo) : None)) //Player has a base Class for an Item (e.g. Hat_Ability_Help with no Flair, Hat_Ability_StatueFall with no Flair, etc.) or CosmeticItemWeApplyTo Flair.
return l.AddBackpack(lbi, lis > State_Add);
return l.RemoveBackpack(lbi);
}
event OnModLoaded()
{
HookActorSpawn(class'Hat_GhostPartyPlayerStateBase', 'Hat_GhostPartyPlayerStateBase');
HookActorSpawn(class'Hat_Player', 'Hat_Player');
}
event OnModUnloaded()
{
RemoveModStatusEffects();
RemoveFurretMusic();
RemoveModItems();
RemoveModActors();
RemoveModLevelBits();
ClearGppStates();
}
event OnHookedActorSpawn(Object NewActor, Name Identifier)
{
local Hat_Player ply;
switch(Identifier)
{
case 'Hat_GhostPartyPlayerStateBase':
class'RideablePokemon_OnlinePartyHandler'.static.HandleHookedOnlinePlayerState(Hat_GhostPartyPlayerStateBase(NewActor), self);
break;
case 'Hat_Player':
ply = Hat_Player(NewActor);
if (ply != None && CurrentPlayers.Find(ply) < 0)
CurrentPlayers.AddItem(ply);
break;
default:
break;
}
}
event OnOnlinePartyCommand(string Command, Name CommandChannel, Hat_GhostPartyPlayerStateBase Sender)
{
class'RideablePokemon_OnlinePartyHandler'.static.HandleOnlinePartyCommand(Command, CommandChannel, Sender, self);
}
simulated function float GetFurretMusicListeningRadius()
{
switch(OnlineFurretMusic)
{
case 0:
return 400.0;
case 1:
return 600.0;
case 2:
return 800.0;
default:
return 0.0;
}
}
simulated event Tick(float DeltaTime)
{
local bool ShouldLocalMusicBeDisabled, ShouldOnlineMusicBeDisabled;
if (WorldInfo != None && WorldInfo.Pauser != None) //Game is paused.
{
CleanUpLocalPlayers(true);
CleanUpOnlinePlayers(true);
return;
}
ShouldLocalMusicBeDisabled = CleanUpLocalPlayers(false);
ShouldOnlineMusicBeDisabled = CleanUpOnlinePlayers(false);
if (ShouldLocalMusicBeDisabled && ShouldOnlineMusicBeDisabled)
StopFurretMusic();
else
StartFurretMusic();
}
simulated function bool CleanUpLocalPlayers(bool IsGamePaused) //Returns true if Furret Music should be disabled.
{
local int i;
local bool ShouldLocalMusicBeDisabled;
ShouldLocalMusicBeDisabled = true;
for (i = CurrentPlayers.Length-1; i > -1; i--)
{
if (CurrentPlayers[i] == None)
{
CurrentPlayers.Remove(i, 1);
continue;
}
if (IsGamePaused)
continue;
if (!ShouldLocalMusicBeDisabled)
continue;
if (class'Shara_SteamID_Tools_RPS'.static.GetPawnPlayerController(CurrentPlayers[i]) == None)
continue;
if (!CurrentPlayers[i].HasStatusEffect(class'Hat_StatusEffect_RideableFurret', false))
continue;
if (class'Hat_StatusEffect_RideablePokemon'.static.AllowSpeedDustParticle(CurrentPlayers[i].Velocity, CurrentPlayers[i].GroundSpeed, true, CurrentPlayers[i].VehicleProperties.Throttle))
ShouldLocalMusicBeDisabled = false;
}
if (FurretMusic > 0)
return true;
return ShouldLocalMusicBeDisabled;
}
simulated function bool CleanUpOnlinePlayers(bool IsGamePaused) //Returns true if Furret Music should be disabled.
{
local float f;
local int i, j;
local Hat_GhostPartyPlayer gpp;
local bool ShouldOnlineMusicBeDisabled;
local class<Hat_StatusEffect_RideablePokemon> PokemonEffect;
ShouldOnlineMusicBeDisabled = true;
f = GetFurretMusicListeningRadius();
for (i = RideablePokemonGppStates.Length-1; i > -1; i--)
{
if (RideablePokemonGppStates[i] == None)
{
RideablePokemonGppStates.Remove(i, 1);
continue;
}
gpp = Hat_GhostPartyPlayer(RideablePokemonGppStates[i].GhostActor);
if (gpp == None)
continue;
PokemonEffect = class'RideablePokemon_OnlinePartyHandler'.static.GetPokemonStatusEffectByMesh(gpp.ScooterMesh);
if (PokemonEffect == None)
continue;
ApplyOnlinePlayerScooterParticles(gpp, PokemonEffect);
ApplyOnlinePlayerScooterSounds(gpp, PokemonEffect);
if (IsGamePaused)
continue;
if (!ShouldOnlineMusicBeDisabled || f <= 0.0)
continue;
if (PokemonEffect != class'Hat_StatusEffect_RideableFurret')
continue;
if (!class'Hat_StatusEffect_RideablePokemon'.static.AllowSpeedDustParticle(gpp.Velocity, gpp.PlayerVisualClass != None ? gpp.PlayerVisualClass.default.GroundSpeed : class'Hat_Player_HatKid'.default.GroundSpeed))
continue;
for (j = 0; j < CurrentPlayers.Length; j++)
{
if (CurrentPlayers[j] == None)
continue;
if (VSizeSq(CurrentPlayers[j].Location-gpp.Location) > Square(f))
continue;
if (class'Shara_SteamID_Tools_RPS'.static.GetPawnPlayerController(CurrentPlayers[j]) == None)
continue;
ShouldOnlineMusicBeDisabled = false;
}
}
if (f <= 0.0)
return true;
return ShouldOnlineMusicBeDisabled;
}
static function Hat_MusicNodeBlend_Dynamic CreateAndPushDynamicMusicNode(SoundCue c, int BPM, int Priority, float BlendInTime, float BlendOutTime)
{
local Hat_MusicNodeBlend_Dynamic DynamicMusicNode;
if (c == None)
return None;
DynamicMusicNode = new class'Hat_MusicNodeBlend_Dynamic';
if (DynamicMusicNode == None)
return None;
DynamicMusicNode.BlendTimes[0] = Abs(BlendInTime);
DynamicMusicNode.BlendTimes[1] = Abs(BlendOutTime);
DynamicMusicNode.Music = c;
DynamicMusicNode.BPM = Abs(BPM);
DynamicMusicNode.Priority = Priority;
`PushMusicNode(DynamicMusicNode);
return DynamicMusicNode;
}
simulated function StartFurretMusic()
{
if (FurretMusicTrack == None)
FurretMusicTrack = CreateAndPushDynamicMusicNode(SoundCue'RideableFurret_Package.Music.Accumula_Town', 123, 800, RandRange(0.5, 1.2), RandRange(0.5, 2.4));
else if (FurretMusicTrack.GetActiveChildIndex() != 1)
FurretMusicTrack.SetActiveChildIndex(1);
}
simulated function StopFurretMusic()
{
if (FurretMusicTrack != None && FurretMusicTrack.GetActiveChildIndex() != 0)
FurretMusicTrack.SetActiveChildIndex(0);
}
simulated function RemoveFurretMusic()
{
if (FurretMusicTrack != None)
{
FurretMusicTrack.Stop();
FurretMusicTrack = None;
}
}
simulated function AddGppState(Hat_GhostPartyPlayerStateBase PlayerState)
{
if (PlayerState == None)
return;
if (RideablePokemonGppStates.Find(PlayerState) < 0)
RideablePokemonGppStates.AddItem(PlayerState);
}
simulated function RemoveGppState(Hat_GhostPartyPlayerStateBase PlayerState)
{
local Hat_GhostPartyPlayer gpp;
local class<Hat_StatusEffect_RideablePokemon> PokemonEffect;
if (PlayerState == None)
return;
RideablePokemonGppStates.RemoveItem(PlayerState);
gpp = Hat_GhostPartyPlayer(PlayerState.GhostActor);
if (gpp == None)
return;
PokemonEffect = class'RideablePokemon_OnlinePartyHandler'.static.GetPokemonStatusEffectByMesh(gpp.ScooterMesh);
RestoreScooterMesh(gpp.ScooterMesh, PlayerState.UnreliableState.ScooterIsSubcon);
RestoreOnlinePlayerScooterParticles(gpp, PokemonEffect, PlayerState.UnreliableState.IsOnScooter, PlayerState.UnreliableState.ScooterIsSubcon);
RestoreOnlinePlayerScooterSounds(gpp, PokemonEffect, PlayerState.UnreliableState.IsOnScooter, PlayerState.UnreliableState.ScooterIsSubcon);
}
simulated function ClearGppStates()
{
local int i;
local Hat_GhostPartyPlayer gpp;
local class<Hat_StatusEffect_RideablePokemon> PokemonEffect;
for (i = 0; i < RideablePokemonGppStates.Length; i++)
{
if (RideablePokemonGppStates[i] == None)
continue;
gpp = Hat_GhostPartyPlayer(RideablePokemonGppStates[i].GhostActor);
if (gpp == None)
continue;
PokemonEffect = class'RideablePokemon_OnlinePartyHandler'.static.GetPokemonStatusEffectByMesh(gpp.ScooterMesh);
RestoreScooterMesh(gpp.ScooterMesh, RideablePokemonGppStates[i].UnreliableState.ScooterIsSubcon);
RestoreOnlinePlayerScooterParticles(gpp, PokemonEffect, RideablePokemonGppStates[i].UnreliableState.IsOnScooter, RideablePokemonGppStates[i].UnreliableState.ScooterIsSubcon);
RestoreOnlinePlayerScooterSounds(gpp, PokemonEffect, RideablePokemonGppStates[i].UnreliableState.IsOnScooter, RideablePokemonGppStates[i].UnreliableState.ScooterIsSubcon);
}
RideablePokemonGppStates.Length = 0;
}
static function RestoreScooterMesh(SkeletalMeshComponent comp, bool ScooterIsSubcon)
{
local class<Hat_StatusEffect_BadgeScooter> ScooterClass;
if (!class'RideablePokemon_OnlinePartyHandler'.static.IsPokemonMesh(comp))
return;
ScooterClass = (ScooterIsSubcon ? class'Hat_StatusEffect_BadgeScooter_Subcon' : class'Hat_StatusEffect_BadgeScooter');
comp.SetSkeletalMesh(ScooterClass.default.ScooterMesh);
comp.SetSectionGroup('');
comp.SetPhysicsAsset(ScooterClass.default.ScooterPhysics);
comp.SetHasPhysicsAssetInstance(ScooterClass.default.ScooterPhysicsAssetInstance);
if (comp.AnimSets.Length != 0)
{
comp.AnimSets.Length = 0;
comp.UpdateAnimations();
}
if (comp.MorphSets.Length != 0)
{
comp.MorphSets.Length = 0;
comp.InitMorphTargets();
}
if (comp.AnimTreeTemplate != ScooterClass.default.ScooterAnimTree)
comp.SetAnimTreeTemplate(ScooterClass.default.ScooterAnimTree);
class'Shara_SkinColors_Tools_Short_RPS'.static.ResetMaterials(comp, true);
}
static function ApplyOnlinePlayerScooterSounds(Hat_GhostPartyPlayer gpp, class<Hat_StatusEffect_BadgeScooter> ScooterClass)
{
if (gpp == None)
return;
if (ScooterClass == None || ScooterClass.default.EngineSound == None)
{
if (gpp.ScooterEngineSound != None)
{
gpp.ScooterEngineSound.Stop();
gpp.ScooterEngineSound.DetachFromAny();
gpp.ScooterEngineSound = None;
}
}
else
{
if (gpp.ScooterEngineSound.ObjectArchetype != ScooterClass.default.EngineSound)
{
gpp.ScooterEngineSound.Stop();
gpp.ScooterEngineSound.DetachFromAny();
gpp.ScooterEngineSound = None;
}
if (gpp.ScooterEngineSound == None)
{
gpp.ScooterEngineSound = new(gpp) ScooterClass.default.EngineSound.Class(ScooterClass.default.EngineSound);
if (gpp.ScooterEngineSound != None)
gpp.AttachComponent(gpp.ScooterEngineSound);
}
}
if (ScooterClass == None || ScooterClass.default.EngineDrivingSound == None)
{
if (gpp.ScooterDrivingSound != None)
{
gpp.ScooterDrivingSound.Stop();
gpp.ScooterDrivingSound.DetachFromAny();
gpp.ScooterDrivingSound = None;
}
}
else
{
if (gpp.ScooterDrivingSound.ObjectArchetype != ScooterClass.default.EngineDrivingSound)
{
gpp.ScooterDrivingSound.Stop();
gpp.ScooterDrivingSound.DetachFromAny();
gpp.ScooterDrivingSound = None;
}
if (gpp.ScooterDrivingSound == None)
{
gpp.ScooterDrivingSound = new(gpp) ScooterClass.default.EngineDrivingSound.Class(ScooterClass.default.EngineDrivingSound);
if (gpp.ScooterDrivingSound != None)
gpp.AttachComponent(gpp.ScooterDrivingSound);
}
}
}
static function ApplyOnlinePlayerScooterParticles(Hat_GhostPartyPlayer gpp, class<Hat_StatusEffect_BadgeScooter> ScooterClass)
{
local class<Hat_Player> PlayerClass;
if (gpp == None)
return;
PlayerClass = gpp.PlayerVisualClass;
if (PlayerClass == None)
PlayerClass = class'Hat_Player_HatKid';
if (PlayerClass.default.SprintParticle == None)
{
if (gpp.SprintParticle != None)
gpp.SprintParticle.SetActive(false);
return;
}
if (gpp.SprintParticle == None || gpp.SprintParticle.ObjectArchetype != PlayerClass.default.SprintParticle)
{
if (gpp.SprintParticle != None)
{
gpp.SprintParticle.SetActive(false);
gpp.SprintParticle.DetachFromAny();
}
gpp.SprintParticle = new(gpp) class'ParticleSystemComponent'(PlayerClass.default.SprintParticle);
if (gpp.SprintParticle != None)
gpp.AttachComponent(gpp.SprintParticle);
}
if (gpp.SprintParticle == None)
return;
if (ScooterClass == None)
{
if (gpp.SprintParticle.Template != PlayerClass.default.SprintParticle.Template)
gpp.SprintParticle.SetTemplate(PlayerClass.default.SprintParticle.Template);
}
else if (gpp.SprintParticle.Template != ScooterClass.default.SpeedDustParticle)
gpp.SprintParticle.SetTemplate(ScooterClass.default.SpeedDustParticle);
}
static function RestoreOnlinePlayerScooterSounds(Hat_GhostPartyPlayer gpp, class<Hat_StatusEffect_BadgeScooter> CurrentScooterClass, bool IsOnScooter, bool ScooterIsSubcon)
{
local class<Hat_StatusEffect_BadgeScooter> ScooterClass;
if (gpp == None || CurrentScooterClass == None)
return;
ScooterClass = (ScooterIsSubcon ? class'Hat_StatusEffect_BadgeScooter_Subcon' : class'Hat_StatusEffect_BadgeScooter');
if (CurrentScooterClass.default.EngineSound != None)
{
if (gpp.ScooterEngineSound != None && gpp.ScooterEngineSound.ObjectArchetype == CurrentScooterClass.default.EngineSound)
{
if (!IsOnScooter || ScooterClass.default.EngineSound == None)
{
gpp.ScooterEngineSound.Stop();
gpp.ScooterEngineSound.DetachFromAny();
gpp.ScooterEngineSound = None;
}
else if (CurrentScooterClass.default.EngineSound != ScooterClass.default.EngineSound)
{
gpp.ScooterEngineSound.Stop();
gpp.ScooterEngineSound.DetachFromAny();
gpp.ScooterEngineSound = new(gpp) ScooterClass.default.EngineSound.Class(ScooterClass.default.EngineSound);
if (gpp.ScooterEngineSound != None)
gpp.AttachComponent(gpp.ScooterEngineSound);
}
}
}
else if (gpp.ScooterEngineSound == None || gpp.ScooterEngineSound.ObjectArchetype == None)
{
if (gpp.ScooterEngineSound != None)
{
gpp.ScooterEngineSound.Stop();
gpp.ScooterEngineSound.DetachFromAny();
}
if (!IsOnScooter || ScooterClass.default.EngineSound == None)
gpp.ScooterEngineSound = None;
else
{
gpp.ScooterEngineSound = new(gpp) ScooterClass.default.EngineSound.Class(ScooterClass.default.EngineSound);
if (gpp.ScooterEngineSound != None)
gpp.AttachComponent(gpp.ScooterEngineSound);
}
}
if (CurrentScooterClass.default.EngineDrivingSound != None)
{
if (gpp.ScooterDrivingSound != None && gpp.ScooterDrivingSound.ObjectArchetype == CurrentScooterClass.default.EngineDrivingSound)
{
if (!IsOnScooter || ScooterClass.default.EngineDrivingSound == None)
{
gpp.ScooterDrivingSound.Stop();
gpp.ScooterDrivingSound.DetachFromAny();
gpp.ScooterDrivingSound = None;
}
else if (CurrentScooterClass.default.EngineDrivingSound != ScooterClass.default.EngineDrivingSound)
{
gpp.ScooterDrivingSound.Stop();
gpp.ScooterDrivingSound.DetachFromAny();
gpp.ScooterDrivingSound = new(gpp) ScooterClass.default.EngineDrivingSound.Class(ScooterClass.default.EngineDrivingSound);
if (gpp.ScooterDrivingSound != None)
gpp.AttachComponent(gpp.ScooterDrivingSound);
}
}
}
else if (gpp.ScooterDrivingSound == None || gpp.ScooterDrivingSound.ObjectArchetype == None)
{
if (gpp.ScooterDrivingSound != None)
{
gpp.ScooterDrivingSound.Stop();
gpp.ScooterDrivingSound.DetachFromAny();
}
if (!IsOnScooter || ScooterClass.default.EngineDrivingSound == None)
gpp.ScooterDrivingSound = None;
else
{
gpp.ScooterDrivingSound = new(gpp) ScooterClass.default.EngineDrivingSound.Class(ScooterClass.default.EngineDrivingSound);
if (gpp.ScooterDrivingSound != None)
gpp.AttachComponent(gpp.ScooterDrivingSound);
}
}
}
static function RestoreOnlinePlayerScooterParticles(Hat_GhostPartyPlayer gpp, class<Hat_StatusEffect_BadgeScooter> CurrentScooterClass, bool IsOnScooter, bool ScooterIsSubcon)
{
local class<Hat_Player> PlayerClass;
local class<Hat_StatusEffect_BadgeScooter> ScooterClass;
if (gpp == None || CurrentScooterClass == None)
return;
PlayerClass = gpp.PlayerVisualClass;
if (PlayerClass == None)
PlayerClass = class'Hat_Player_HatKid';
if (PlayerClass.default.SprintParticle == None)
{
if (gpp.SprintParticle != None)
gpp.SprintParticle.SetActive(false);
return;
}
if (gpp.SprintParticle == None || gpp.SprintParticle.ObjectArchetype != PlayerClass.default.SprintParticle)
{
if (gpp.SprintParticle != None)
{
gpp.SprintParticle.SetActive(false);
gpp.SprintParticle.DetachFromAny();
}
gpp.SprintParticle = new(gpp) class'ParticleSystemComponent'(PlayerClass.default.SprintParticle);
if (gpp.SprintParticle != None)
gpp.AttachComponent(gpp.SprintParticle);
}
if (gpp.SprintParticle == None || gpp.SprintParticle.Template != CurrentScooterClass.default.SpeedDustParticle)
return;
if (IsOnScooter)
{
ScooterClass = (ScooterIsSubcon ? class'Hat_StatusEffect_BadgeScooter_Subcon' : class'Hat_StatusEffect_BadgeScooter');
if (gpp.SprintParticle.Template != ScooterClass.default.SpeedDustParticle)
gpp.SprintParticle.SetTemplate(ScooterClass.default.SpeedDustParticle);
}
else if (gpp.SprintParticle.Template != PlayerClass.default.SprintParticle.Template)
gpp.SprintParticle.SetTemplate(PlayerClass.default.SprintParticle.Template);
}
static function bool ShowSubtitleForPlayer(PlayerController pc, optional string msg, optional byte r = 255, optional byte g = 255, optional byte b = 255, optional float closeAfter = 5.0, optional Array<KeywordLocalizationInfo> Keywords)
{
local Hat_HUD H;
local Hat_HUDElementSubtitles_Advanced_RPS SubtitlesHUD;
if (pc == None)
return false;
H = Hat_HUD(pc.myHUD);
if (H == None)
return false;
SubtitlesHUD = Hat_HUDElementSubtitles_Advanced_RPS(H.OpenHUD(class'Hat_HUDElementSubtitles_Advanced_RPS', ""$r$"|"$g$"|"$b$"|"$msg));
if (SubtitlesHUD == None)
return false;
SubtitlesHUD.SetKeywordReplacements(Keywords);
SubtitlesHUD.SetTimeUntilClose(closeAfter);
return true;
}
defaultproperties
{
bAlwaysTick = true
}