XpecV52

DancePlayerMut

Nov 21st, 2021 (edited)
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class DancePlayerMut extends Mutator;
  2.  
  3. const NUM_EMOJI_ANIMS = 53;
  4.  
  5. var PlayerController PC;
  6. var transient Interaction ClientInteraction;
  7. var const name EMAnims[53];
  8. var const string EMAbbrevs[53];
  9.  
  10. var string interaction${1}< ${3} >
  11.  
  12. function PostBeginPlay()
  13. {
  14.     local KFGameType KFGT;
  15.  
  16.     KFGT = KFGameType(Level.Game);
  17.     if(KFGT == none)
  18.         return;
  19.        
  20.     KFGT.PlayerControllerClass = class'DancePlayerController';
  21.     KFGT.PlayerControllerClassName = string(class'DancePlayerController');
  22. }
  23.  
  24. simulated function Tick(float DeltaTime)
  25. {
  26.     // local PlayerController PC;
  27.  
  28.     PC = Level.GetLocalPlayerController();
  29.  
  30.     if(Role == ROLE_Authority)
  31.         Disable('Tick');
  32.  
  33.     // else if(Role == ROLE_SimulatedProxy && KFPlayerReplicationInfo(PC.PlayerReplicationInfo) != none)
  34.     // {
  35.         if(/* Role == ROLE_SimulatedProxy && */ PC != none)
  36.         {
  37.             PC.Player.InteractionMaster.AddInteraction(interactionClass, PC.Player);
  38.             DancePlayerInteraction(ClientInteraction).mut = self;
  39.         }
  40.     Disable('Tick');
  41.     // }
  42. }
  43.  
  44. /* simulated function PostNetBeginPlay()
  45. // simulated function PostBeginPlay()
  46. {
  47.     PC = Level.GetLocalPlayerController();
  48.     if(PC != none)
  49.     {
  50.         ClientInteraction = PC.Player.InteractionMaster.AddInteraction(interactionClass, PC.Player);
  51.         DancePlayerInteraction(ClientInteraction).mut = self;
  52.     }
  53.     super.PostBeginPlay();
  54. } */
  55.  
  56. function PlayerController FindPlayer(int id)
  57. {
  58.     local PlayerController Player;
  59.     local Controller C;
  60.  
  61.     for(C = Level.ControllerList;C != none;C = C.nextController)
  62.     {
  63.         Player = PlayerController(C);
  64.         if(Player != none && Player.PlayerReplicationInfo.PlayerID == id)
  65.             return Player;
  66.     }
  67.     return none;
  68. }
  69.  
  70. function string MergeStrings(array<string> Input, int StartPosition)
  71. {
  72.     local int i;
  73.     local string Result;
  74.  
  75.     if(StartPosition >= Input.Length)
  76.         return "";
  77.  
  78.     Result = Input[StartPosition];
  79.  
  80.     if(StartPosition < Input.Length - 1)
  81.     {
  82.         for(i = StartPosition + 1;i < Input.Length;i++)
  83.             Result @= Input[i];
  84.     }
  85.     return Result;
  86. }
  87.  
  88. function Mutate(string MutateString, PlayerController Sender)
  89. {
  90.     local Controller C;
  91.     local PlayerController Target;
  92.     local array<string> Commands;
  93.     local string TempString;
  94.     local int i;
  95.  
  96.     if(Sender.PlayerReplicationInfo.bAdmin || Sender.PlayerReplicationInfo.bSilentAdmin || Level.NetMode == NM_Standalone || Level.NetMode == NM_ListenServer)
  97.     {
  98.         Split(MutateString, " ", Commands);
  99.         if(Commands[0] ~= "x")
  100.         {
  101.             if(Commands.Length == 1)
  102.                 SendMessage(Sender, "Use %gmutate x inf %wto get the list of %rconsole commands%w.");
  103.  
  104.             else if(Commands[1] ~= "INF")
  105.             {
  106.                 SendMessage(Sender, "=%g=%r=%w=%g=%r= %gList of commands %r=%g=%w=%r=%g=%w=");
  107.                 SendMessage(Sender, " ");
  108.                 SendMessage(Sender, "%gClientCommand%w, %gCC %r<target> <string>%w: force %r<target> %wto use command %r<string>%w.");
  109.                 SendMessage(Sender, "%gClientEmoji%w, %gCE, %gD %r<target> <string>%w: force %r<target> %wto emote.");
  110.                 SendMessage(Sender, "Use %gmutate x inf list %wto get the list of %rdances%w.");
  111.  
  112.                 if(Commands[2] ~= "List")
  113.                 {
  114.                     SendMessage(Sender, " ");
  115.                     SendMessage(Sender, "List of dances: ");
  116.                     for(i=0;i < 53;i++)
  117.                     {
  118.                         SendMessage(Sender, "%w" $ string(i) $ " %r- %g" $ string(EMAnims[i]));
  119.                     }
  120.                 }
  121.             }
  122.  
  123.             else if(Commands[1] ~= "ClientCommand" || Commands[1] ~= "CC")
  124.             {
  125.                 if(Commands.Length == 2)
  126.                     Commands[Commands.Length] = "0";
  127.  
  128.                 if(Commands.Length == 3)
  129.                     Commands[Commands.Length] = "Say :yoba:";
  130.  
  131.                 Target = FindPlayer(Max(int(Commands[2]), 0));
  132.  
  133.                 if(DancePlayerController(Target) != none)
  134.                 {
  135.                     TempString = MergeStrings(Commands, 3);
  136.                     DancePlayerController(Target).PerformCommand(TempString);
  137.                     SendMessage(Sender, "%g" $ Target.PlayerReplicationInfo.PlayerName $ " %wused %r" $ TempString);
  138.                 }
  139.  
  140.                 else
  141.                     SendMessage(Sender, "%gThe player %wdoesn't %rexist%w!");
  142.             }
  143.  
  144.             else if(Commands[1] ~= "ClientEmoji" || Commands[1] ~= "CE" || Commands[1] ~= "D")
  145.             {
  146.                 if(Commands.Length == 2)
  147.                     Commands[Commands.Length] = "Me";
  148.  
  149.                 if(Commands.Length == 3)
  150.                     Commands[Commands.Length] = "0";
  151.  
  152.                 if(Commands[2] ~= "All" || Commands[2] ~= "A")
  153.                 {
  154.                     if(AlivePlayers() > 0)
  155.                     {
  156.                         for(C = Level.ControllerList;C != none;C = C.nextController)
  157.                         {
  158.                             if((PlayerController(C) != none) && DanceHumanPawn(C.Pawn) != none)
  159.                                 DanceHumanPawn(C.Pawn).EmojiTrigger(EMAnims[Clamp(int(Commands[3]), 0, 52)]);
  160.                         }
  161.  
  162.                         if(!Sender.PlayerReplicationInfo.bSilentAdmin)
  163.                             BroadcastText(("%g" $ Sender.PlayerReplicationInfo.PlayerName) $ " %wforced %rall the players %wto emote.");
  164.  
  165.                         else
  166.                             SendMessage(Sender, "%gYou %whave forced %rall the players %wto emote.");
  167.                     }
  168.  
  169.                     else
  170.                         SendMessage(Sender, "%gNo players %ralive%w!");
  171.                 }
  172.  
  173.                 else if(Commands[2] ~= "Me" || Commands[2] ~= "M")
  174.                 {
  175.                     if(DanceHumanPawn(Sender.Pawn) != none)
  176.                         DanceHumanPawn(Sender.Pawn).EmojiTrigger(EMAnims[Clamp(int(Commands[3]), 0, 52)]);
  177.  
  178.                     else
  179.                         SendMessage(Sender, "%gYou %ware %rdead %wor %ra spectator%w!");
  180.                 }
  181.  
  182.                 else
  183.                 {
  184.                     Target = FindPlayer(Max(int(Commands[2]), 2));
  185.                     if(Target != none && DanceHumanPawn(Target.Pawn) != none)
  186.                     {
  187.                         DanceHumanPawn(Target.Pawn).EmojiTrigger(EMAnims[Clamp(int(Commands[3]), 0, 52)]);
  188.                         if(!Sender.PlayerReplicationInfo.bSilentAdmin)
  189.                             BroadcastText("%g" $ Sender.PlayerReplicationInfo.PlayerName $ " %wforced %r" $ Target.PlayerReplicationInfo.PlayerName $ " %wto emote.");
  190.  
  191.                         else
  192.                             SendMessage(Sender, "%gYou %whave forced %r" $ Target.PlayerReplicationInfo.PlayerName $ " %wto emote.");
  193.                     }
  194.  
  195.                     else
  196.                         SendMessage(Sender, "%gThe player %wdoesn't %rexist%w, %whe is %ra spectator %wor %rdead%w!");
  197.                 }
  198.             }
  199.         }
  200.     }
  201.  
  202.     else
  203.     {
  204.         Split(MutateString, " ", Commands);
  205.         if(Commands[0] ~= "x")
  206.         {
  207.             if(Commands.Length == 1)
  208.                 SendMessage(Sender, "Use %gmutate x inf %wto get the list of %rconsole commands%w.");
  209.  
  210.             else if(Commands[1] ~= "INF")
  211.             {
  212.                 SendMessage(Sender, "=%g=%r=%w=%g=%r= %gList of commands %r=%g=%w=%r=%g=%w=");
  213.                 SendMessage(Sender, " ");
  214.                 SendMessage(Sender, "%gClientEmoji%w, %gCE, %D %r<target> <string>%w: force %r<target> %wto emote.");
  215.                 SendMessage(Sender, "Use %gmutate x inf list %wto get the list of %rdances%w.");
  216.                 if(Commands[2] ~= "List")
  217.                 {
  218.                     SendMessage(Sender, " ");
  219.                     SendMessage(Sender, "List of dances: ");
  220.                     for(i=0;i < 53;i++)
  221.                     {
  222.                         SendMessage(Sender, "%w" $ string(i) $ " %r- %g" $ string(EMAnims[i]));
  223.                     }
  224.                 }
  225.             }
  226.  
  227.             else if(Commands[1] ~= "ClientEmoji" || Commands[1] ~= "CE"  || Commands[1] ~= "D")
  228.             {
  229.                 if(Commands.Length == 2)
  230.                     Commands[Commands.Length] = "Me";
  231.  
  232.                 if(Commands.Length == 3)
  233.                     Commands[Commands.Length] = "0";
  234.  
  235.                 if(DanceHumanPawn(Sender.Pawn) != none)
  236.                     DanceHumanPawn(Sender.Pawn).EmojiTrigger(EMAnims[Clamp(int(Commands[3]), 0, 52)]);
  237.  
  238.                 else
  239.                     SendMessage(Sender, "%gYou %ware %rdead %wor %ra spectator%w!");
  240.             }
  241.         }
  242.     }
  243.     super.Mutate(MutateString, Sender);
  244. }
  245.  
  246. function int AlivePlayers()
  247. {
  248.     local Controller C;
  249.     local int Counter;
  250.  
  251.     for(C = Level.ControllerList;C != none;C = C.nextController)
  252.     {
  253.         if(PlayerController(C) != none && C.Pawn != none && C.Pawn.Health > 0)
  254.             Counter ++;
  255.     }
  256.     return Counter;
  257. }
  258.  
  259. function SendMessage(PlayerController Player, coerce string Message)
  260. {
  261.     if(Player == none || Message == "")
  262.         return;
  263.        
  264.     if(Player.PlayerReplicationInfo.PlayerName ~= "WebAdmin" && Player.PlayerReplicationInfo.PlayerID == 0)
  265.         Message = StripFormattedString(Message);
  266.  
  267.     else
  268.         Message = ParseFormattedLine(Message);
  269.  
  270.     Player.TeamMessage(none, Message, 'DancePlayer');
  271. }
  272.  
  273. function BroadcastText(string Message, optional bool bSaveToLog)
  274. {
  275.     local Controller C;
  276.  
  277.     for(C = Level.ControllerList;C != none;C = C.nextController)
  278.     {
  279.         if(PlayerController(C) != none)
  280.             SendMessage(PlayerController(C), Message);
  281.     }
  282.     if(bSaveToLog)
  283.         Message = StripFormattedString(Message);
  284.         // Log("DancePlayer: " $ Message);
  285. }
  286.  
  287. function string ParseFormattedLine(string Input)
  288. {
  289.     ReplaceText(Input, "%r", ((Chr(27) $ Chr(200)) $ Chr(1)) $ Chr(1));
  290.     ReplaceText(Input, "%g", ((Chr(27) $ Chr(1)) $ Chr(200)) $ Chr(1));
  291.     ReplaceText(Input, "%b", ((Chr(27) $ Chr(1)) $ Chr(100)) $ Chr(200));
  292.     ReplaceText(Input, "%w", ((Chr(27) $ Chr(200)) $ Chr(200)) $ Chr(200));
  293.     ReplaceText(Input, "%y", ((Chr(27) $ Chr(200)) $ Chr(200)) $ Chr(1));
  294.     ReplaceText(Input, "%p", ((Chr(27) $ Chr(200)) $ Chr(1)) $ Chr(200));
  295.     return Input;
  296. }
  297.  
  298. function string StripFormattedString(string Input)
  299. {
  300.     ReplaceText(Input, "%r", "");
  301.     ReplaceText(Input, "%g", "");
  302.     ReplaceText(Input, "%b", "");
  303.     ReplaceText(Input, "%w", "");
  304.     ReplaceText(Input, "%y", "");
  305.     ReplaceText(Input, "%p", "");
  306.     return Input;
  307. }
  308.  
  309. defaultproperties
  310. {
  311.     EMAnims(0)="Dance_CanCan"
  312.     EMAnims(1)="Dance_Chicken"
  313.     EMAnims(2)="Dance_MaraschinoStep"
  314.     EMAnims(3)="Dance_RunningMan"
  315.     EMAnims(4)="Dance_Twerk"
  316.     EMAnims(5)="Dance_Noodle"
  317.     EMAnims(6)="Dance_Rainbow"
  318.     EMAnims(7)="Dance_Silly"
  319.     EMAnims(8)="Dance_Snake"
  320.     EMAnims(9)="Dance_Tut"
  321.     EMAnims(10)="Dance_Twist"
  322.     EMAnims(11)="Dance_RaiseTheRoof"
  323.     EMAnims(12)="Dance_Quake"
  324.     EMAnims(13)="Dance_RibPops"
  325.     EMAnims(14)="Dance_Macarena"
  326.     EMAnims(15)="Dance_Salsa"
  327.     EMAnims(16)="Dance_Shuffling"
  328.     EMAnims(17)="Dance_YMCA"
  329.     EMAnims(18)="Gesture_Summersault"
  330.     EMAnims(19)="Gesture_Dab"
  331.     EMAnims(20)="Gesture_Agony"
  332.     EMAnims(21)="Gesture_Booty"
  333.     EMAnims(22)="Gesture_Salute"
  334.     EMAnims(23)="Gesture_LookingAround"
  335.     EMAnims(24)="Gesture_Petting"
  336.     EMAnims(25)="Gesture_Patting"
  337.     EMAnims(26)="Gesture_ThroatSlash"
  338.     EMAnims(27)="Gesture_Elbow"
  339.     EMAnims(28)="Gesture_Power"
  340.     EMAnims(29)="Gesture_Victory"
  341.     EMAnims(30)="Gesture_Star"
  342.     EMAnims(31)="Gesture_JoyfulJump"
  343.     EMAnims(32)="Gesture_Waving"
  344.     EMAnims(33)="Gesture_Hello"
  345.     EMAnims(34)="Gesture_Cheering"
  346.     EMAnims(35)="Gesture_Clapping"
  347.     EMAnims(36)="Gesture_Crazy"
  348.     EMAnims(37)="Gesture_Defeated"
  349.     EMAnims(38)="Gesture_HokeyPokey"
  350.     EMAnims(39)="Gesture_No"
  351.     EMAnims(40)="Gesture_Pain"
  352.     EMAnims(41)="Gesture_Pointing"
  353.     EMAnims(42)="Gesture_Shaking"
  354.     EMAnims(43)="Gesture_Strong"
  355.     EMAnims(44)="Gesture_Whatever"
  356.     EMAnims(45)="Fight_ElbowUppercut"
  357.     EMAnims(46)="Fight_HeadButt"
  358.     EMAnims(47)="Fight_Fireball"
  359.     EMAnims(48)="Fight_IllegalElbowPunch"
  360.     EMAnims(49)="Fight_JabToElbowPunch"
  361.     EMAnims(50)="Fight_HighKick"
  362.     EMAnims(51)="Fight_PunchingBag"
  363.     EMAnims(52)="Fight_UppercutJab"
  364.  
  365.     EMAbbrevs(0)="Can Can"
  366.     EMAbbrevs(1)="Chicken"
  367.     EMAbbrevs(2)="Maraschino Step"
  368.     EMAbbrevs(3)="Running Man"
  369.     EMAbbrevs(4)="Twerk"
  370.     EMAbbrevs(5)="Noodle"
  371.     EMAbbrevs(6)="Rainbow"
  372.     EMAbbrevs(7)="Silly"
  373.     EMAbbrevs(8)="Snake"
  374.     EMAbbrevs(9)="Tut"
  375.     EMAbbrevs(10)="Twist"
  376.     EMAbbrevs(11)="Raise The Roof"
  377.     EMAbbrevs(12)="Quake"
  378.     EMAbbrevs(13)="Rib Pops"
  379.     EMAbbrevs(14)="Macarena"
  380.     EMAbbrevs(15)="Salsa"
  381.     EMAbbrevs(16)="Shuffling"
  382.     EMAbbrevs(17)="YMCA"
  383.     EMAbbrevs(18)="Summersault"
  384.     EMAbbrevs(19)="Dab"
  385.     EMAbbrevs(20)="Agony"
  386.     EMAbbrevs(21)="Booty"
  387.     EMAbbrevs(22)="Salute"
  388.     EMAbbrevs(23)="Looking Around"
  389.     EMAbbrevs(24)="Petting"
  390.     EMAbbrevs(25)="Patting"
  391.     EMAbbrevs(26)="Throat Slash"
  392.     EMAbbrevs(27)="Elbow"
  393.     EMAbbrevs(28)="Power"
  394.     EMAbbrevs(29)="Victory"
  395.     EMAbbrevs(30)="Star"
  396.     EMAbbrevs(31)="Joyful Jump"
  397.     EMAbbrevs(32)="Waving"
  398.     EMAbbrevs(33)="Hello"
  399.     EMAbbrevs(34)="Cheering"
  400.     EMAbbrevs(35)="Clapping"
  401.     EMAbbrevs(36)="Crazy"
  402.     EMAbbrevs(37)="Defeated"
  403.     EMAbbrevs(38)="Hokey Pokey"
  404.     EMAbbrevs(39)="No"
  405.     EMAbbrevs(40)="Pain"
  406.     EMAbbrevs(41)="Pointing"
  407.     EMAbbrevs(42)="Shaking"
  408.     EMAbbrevs(43)="Strong"
  409.     EMAbbrevs(44)="Whatever"
  410.     EMAbbrevs(45)="Elbow Uppercut"
  411.     EMAbbrevs(46)="Head Butt"
  412.     EMAbbrevs(47)="Fireball"
  413.     EMAbbrevs(48)="Illegal Elbow Punch"
  414.     EMAbbrevs(49)="Jab To Elbow Punch"
  415.     EMAbbrevs(50)="High Kick"
  416.     EMAbbrevs(51)="Punching Bag"
  417.     EMAbbrevs(52)="Uppercut Jab"
  418.     bAddToServerPackages=true
  419.     interactionClass="DancePlayer.DancePlayerInteraction"
  420.     GroupName="KFDancePlayer"
  421.     FriendlyName="KFDancePlayer"
  422.     Description="KFDancePlayer"
  423.     bAlwaysRelevant=true
  424.     RemoteRole=ROLE_SimulatedProxy
  425. }
Add Comment
Please, Sign In to add comment