Advertisement
Guest User

Untitled

a guest
Jun 26th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // CD_ZedNameUtils
  3. //=============================================================================
  4. // Static helper methods for manipulating zed name strings and their
  5. // equivalent EAIType enum values
  6. //=============================================================================
  7.  
  8. class CD_ZedNameUtils extends Object
  9.     Abstract;
  10.  
  11. `include(CD_Log.uci)
  12.  
  13. /**
  14.     Get a zed EAIType from the name.
  15.  
  16.     This is based on the LoadMonsterByName from KFCheatManager, but I have a separate copy here
  17.     for several reasons:
  18.     0. I need EAIType instead of a class, and there does not seem to be an easy way to convert those
  19.     1. To allow for a few more abbreviations than KFCheatManager knows (e.g. for clots: CC, CA, CS)
  20.     2. To accept a slightly smaller universe of legal input strings, so that the effective API
  21.        created by this function is as small as possible.
  22.     3. So that a hypothetical future KF2 update that might change KFCheatManager's zed abbreviations
  23.        will not change the behavior of this method, which is used to parse wave squad schedules and
  24.        generally represents a public API that must not change.
  25.     5. I have no need for the "friendly-to-player" zed AI names here, and I want to accept the absolute
  26.        minimum universe of correct inputs, so that this is easy to maintain.  Same for "TestHusk".
  27. */
  28.  
  29. enum ECDZedNameResolv
  30. {
  31.     ZNR_OK,
  32.     ZNR_INVALID_NAME,
  33.     ZNR_INVALID_SPECIAL,
  34.     ZNR_INVALID_RAGE
  35. };
  36.  
  37. static function ECDZedNameResolv GetZedType(
  38.     /* Input parameters */
  39.     const out string ZedName, const bool IsSpecial, const bool IsRagedOnSpawn,
  40.     /* Output parameters */
  41.     out EAIType ZedType, out class<KFPawn_Monster> ZedClass )
  42. {
  43.     local int ZedLen;
  44.     local bool ZedTypeCanBeSpecial, ZedTypeCanBeRaged;
  45.  
  46.     ZedLen = Len( ZedName );
  47.     ZedClass = None;
  48.     ZedTypeCanBeSpecial = false;
  49.     ZedTypeCanBeRaged = false;
  50.    
  51.     if ( ZedName ~= "CLOTA" || ZedName ~= "CA" || (2 <= ZedLen && ZedLen <= 5 && ZedName ~= Left("ALPHA", ZedLen)) )
  52.     {
  53.         ZedType = AT_AlphaClot;
  54.         ZedClass = IsSpecial ?
  55.             class'CD_Pawn_ZedClot_Alpha_Special' :
  56.             class'CD_Pawn_ZedClot_Alpha_Regular' ;
  57.         ZedTypeCanBeSpecial = true;
  58.     }
  59.     else if ( ZedName ~= "CLOTS" || ZedName ~= "CS" || (2 <= ZedLen && ZedLen <= 7 && ZedName ~= Left("SLASHER", ZedLen)) )
  60.     {
  61.         ZedType = AT_SlasherClot;
  62.     }
  63.     else if ( ZedName ~= "CLOTC" || ZedName ~= "CC" || (2 <= ZedLen && ZedLen <= 4 && ZedName ~= Left("CYST", ZedLen)) )
  64.     {
  65.         ZedType = AT_Clot;
  66.     }
  67.     else if ( ZedName ~= "FP" || (1 <= ZedLen && ZedLen <= 10 && ZedName ~= Left("FLESHPOUND", ZedLen)) )
  68.     {
  69.         ZedType = AT_FleshPound;
  70.         ZedClass = IsRagedOnSpawn ?
  71.             class'CD_Pawn_ZedFleshpound_RS' :
  72.             class'CD_Pawn_ZedFleshpound_NRS' ;
  73.         ZedTypeCanBeRaged = true;
  74.     }
  75.     else if ( ZedName ~= "MF" || ZedName ~= "MFP" || (2 <= ZedLen && ZedLen <= 14 && ZedName ~= Left("MINIFLESHPOUND", ZedLen)) )
  76.     {
  77.         ZedType = AT_FleshpoundMini;
  78.         ZedClass = IsRagedOnSpawn ?
  79.             class'CD_Pawn_ZedFleshpoundMini_RS' :
  80.             class'CD_Pawn_ZedFleshpoundMini_NRS' ;
  81.         ZedTypeCanBeRaged = true;
  82.     }
  83.     else if ( ZedName ~= "G" || ZedName ~= "GF" || (1 <= ZedLen && ZedLen <= 8 && ZedName ~= Left("GOREFAST", ZedLen)) )
  84.     {
  85.         ZedType = AT_GoreFast;
  86.         ZedClass = IsSpecial ?
  87.             class'CD_Pawn_ZedGorefast_Special' :
  88.             class'CD_Pawn_ZedGorefast_Regular' ;
  89.         ZedTypeCanBeSpecial = true;
  90.     }
  91.     else if ( 2 <= ZedLen && ZedLen <= 7 && ZedName ~= Left("STALKER", ZedLen) )
  92.     {
  93.         ZedType = AT_Stalker;
  94.     }
  95.     else if ( 1 <= ZedLen && ZedLen <= 5 && ZedName ~= Left("BLOAT", ZedLen) )
  96.     {
  97.         ZedType = AT_Bloat;
  98.     }
  99.     else if ( 2 <= ZedLen && ZedLen <= 6 && ZedName ~= Left("SCRAKE", ZedLen) )
  100.     {
  101.         ZedType = AT_Scrake;
  102.     }
  103.     else if ( 2 <= ZedLen && ZedLen <= 7 && ZedName ~= Left("CRAWLER", ZedLen) )
  104.     {
  105.         ZedType = AT_Crawler;
  106.         ZedClass = IsSpecial ?
  107.             class'CD_Pawn_ZedCrawler_Special' :
  108.             class'CD_Pawn_ZedCrawler_Regular' ;
  109.         ZedTypeCanBeSpecial = true;
  110.     }
  111.     else if ( 1 <= ZedLen && ZedLen <= 4 && ZedName ~= Left("HUSK", ZedLen) )
  112.     {
  113.         ZedType = AT_Husk;
  114.     }
  115.     else if ( 2 <= ZedLen && ZedLen <= 5 && ZedName ~= Left("SIREN", ZedLen) )
  116.     {
  117.         ZedType = AT_Siren;
  118.     }
  119.     else if ( ZedName ~= "TP" || 2 <= ZedLen && ZedLen <= 7 && ZedName ~= Left("TRAPPER", ZedLen) )
  120.     {
  121.         ZedClass = class'KFPawn_ZedDAR_EMP';
  122.     }
  123.     else if ( ZedName ~= "RK" || 2 <= ZedLen && ZedLen <= 6 && ZedName ~= Left("BOOMER", ZedLen) )
  124.     {
  125.         ZedClass = class'KFPawn_ZedDAR_Rocket';
  126.     }
  127.     else if ( ZedName ~= "LS" || 2 <= ZedLen && ZedLen <= 7 && ZedName ~= Left("BLASTER", ZedLen) )
  128.     {
  129.         ZedClass = class'KFPawn_ZedDAR_Laser';
  130.     }
  131.     else
  132.     {
  133.         return ZNR_INVALID_NAME;
  134.     }
  135.  
  136.     // Return OK only if this zed type is allowed to be raged/albino
  137.  
  138.     if ( IsSpecial && !ZedTypeCanBeSpecial )
  139.     {
  140.         return ZNR_INVALID_SPECIAL;
  141.     }
  142.  
  143.     if ( IsRagedOnSpawn && !ZedTypeCanBeRaged )
  144.     {
  145.         return ZNR_INVALID_RAGE;
  146.     }
  147.  
  148.     return ZNR_OK;
  149. }
  150.  
  151. static function GetZedFullName( const AISquadElement SquadElement, out string ZedName )
  152. {
  153.     ZedName = "";
  154.  
  155.     if ( SquadElement.Type == AT_AlphaClot )
  156.     {
  157.         ZedName = "Alpha";
  158.     }
  159.     else if ( SquadElement.Type == AT_SlasherClot )
  160.     {
  161.         ZedName = "Slasher";
  162.     }
  163.     else if ( SquadElement.Type == AT_Clot )
  164.     {
  165.         ZedName = "Cyst";
  166.     }
  167.     else if ( SquadElement.Type == AT_FleshPound )
  168.     {
  169.         ZedName = "Fleshpound";
  170.     }
  171.     else if ( SquadElement.Type == AT_FleshpoundMini )
  172.     {
  173.         ZedName = "MiniFleshpound";
  174.     }
  175.     else if ( SquadElement.Type == AT_Gorefast )
  176.     {
  177.         ZedName = "Gorefast";
  178.     }
  179.     else if ( SquadElement.Type == AT_Stalker )
  180.     {
  181.         ZedName = "Stalker";
  182.     }
  183.     else if ( SquadElement.Type == AT_Bloat )
  184.     {
  185.         ZedName = "Bloat";
  186.     }
  187.     else if ( SquadElement.Type == AT_Scrake )
  188.     {
  189.         ZedName = "Scrake";
  190.     }
  191.     else if ( SquadElement.Type == AT_Crawler )
  192.     {
  193.         ZedName = "Crawler";
  194.     }
  195.     else if ( SquadElement.Type == AT_Husk )
  196.     {
  197.         ZedName = "Husk";
  198.     }
  199.     else if ( SquadElement.Type == AT_Siren )
  200.     {
  201.         ZedName = "Siren";
  202.     }
  203.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_EMP' )
  204.     {
  205.         ZedName = "Trapper";
  206.     }
  207.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_Rocket' )
  208.     {
  209.         ZedName = "Boomer";
  210.     }
  211.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_Laser' )
  212.     {
  213.         ZedName = "Blaster";
  214.     }
  215.  
  216.     AppendModifierChars( SquadElement.CustomClass, ZedName );
  217. }
  218.  
  219. static function GetZedTinyName( const AISquadElement SquadElement, out string ZedName )
  220. {
  221.     ZedName = "";
  222.  
  223.     if ( SquadElement.Type == AT_AlphaClot )
  224.     {
  225.         ZedName = "AL";
  226.     }
  227.     else if ( SquadElement.Type == AT_SlasherClot )
  228.     {
  229.         ZedName = "SL";
  230.     }
  231.     else if ( SquadElement.Type == AT_Clot )
  232.     {
  233.         ZedName = "CY";
  234.     }
  235.     else if ( SquadElement.Type == AT_FleshPound )
  236.     {
  237.         ZedName = "F";
  238.     }
  239.     else if ( SquadElement.Type == AT_FleshpoundMini )
  240.     {
  241.         ZedName = "MF";
  242.     }
  243.     else if ( SquadElement.Type == AT_Gorefast )
  244.     {
  245.         ZedName = "G";
  246.     }
  247.     else if ( SquadElement.Type == AT_Stalker )
  248.     {
  249.         ZedName = "ST";
  250.     }
  251.     else if ( SquadElement.Type == AT_Bloat )
  252.     {
  253.         ZedName = "B";
  254.     }
  255.     else if ( SquadElement.Type == AT_Scrake )
  256.     {
  257.         ZedName = "SC";
  258.     }
  259.     else if ( SquadElement.Type == AT_Crawler )
  260.     {
  261.         ZedName = "CR";
  262.     }
  263.     else if ( SquadElement.Type == AT_Husk )
  264.     {
  265.         ZedName = "H";
  266.     }
  267.     else if ( SquadElement.Type == AT_Siren )
  268.     {
  269.         ZedName = "SI";
  270.     }
  271.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_EMP' )
  272.     {
  273.         ZedName = "TP";
  274.     }
  275.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_Rocket' )
  276.     {
  277.         ZedName = "RK";
  278.     }
  279.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_Laser' )
  280.     {
  281.         ZedName = "LS";
  282.     }
  283.  
  284.     AppendModifierChars( SquadElement.CustomClass, ZedName );
  285. }
  286.  
  287. static function GetZedShortName( const AISquadElement SquadElement, out string ZedName )
  288. {
  289.     ZedName = "";
  290.  
  291.     if ( SquadElement.Type == AT_AlphaClot )
  292.     {
  293.         ZedName = "AL";
  294.     }
  295.     else if ( SquadElement.Type == AT_SlasherClot )
  296.     {
  297.         ZedName = "SL";
  298.     }
  299.     else if ( SquadElement.Type == AT_Clot )
  300.     {
  301.         ZedName = "CY";
  302.     }
  303.     else if ( SquadElement.Type == AT_FleshPound )
  304.     {
  305.         ZedName = "FP";
  306.     }
  307.     else if ( SquadElement.Type == AT_FleshpoundMini )
  308.     {
  309.         ZedName = "MF";
  310.     }
  311.     else if ( SquadElement.Type == AT_Gorefast )
  312.     {
  313.         ZedName = "GF";
  314.     }
  315.     else if ( SquadElement.Type == AT_Stalker )
  316.     {
  317.         ZedName = "ST";
  318.     }
  319.     else if ( SquadElement.Type == AT_Bloat )
  320.     {
  321.         ZedName = "BL";
  322.     }
  323.     else if ( SquadElement.Type == AT_Scrake )
  324.     {
  325.         ZedName = "SC";
  326.     }
  327.     else if ( SquadElement.Type == AT_Crawler )
  328.     {
  329.         ZedName = "CR";
  330.     }
  331.     else if ( SquadElement.Type == AT_Husk )
  332.     {
  333.         ZedName = "HU";
  334.     }
  335.     else if ( SquadElement.Type == AT_Siren )
  336.     {
  337.         ZedName = "SI";
  338.     }
  339.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_EMP' )
  340.     {
  341.         ZedName = "TP";
  342.     }
  343.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_Rocket' )
  344.     {
  345.         ZedName = "RK";
  346.     }
  347.     else if ( SquadElement.CustomClass == class'KFPawn_ZedDAR_Laser' )
  348.     {
  349.         ZedName = "LS";
  350.     }
  351.  
  352.     AppendModifierChars( SquadElement.CustomClass, ZedName );
  353. }
  354.  
  355. static function AppendModifierChars( const class CustomClass, out string ZedName )
  356. {
  357.     local string s;
  358.  
  359.     if ( CustomClass != None )
  360.     {
  361.         s = Locs( string( CustomClass.name ) );
  362.  
  363.         if ( Left(s, 7) != "cd_pawn")
  364.         {
  365.             return;
  366.         }
  367.  
  368.         if ( 0 < InStr( s, "_spec" ) )
  369.         {
  370.             ZedName = ZedName $ "*";
  371.         }
  372.  
  373.         if ( 0 < InStr( s, "_rs" ) )
  374.         {
  375.             ZedName = ZedName $ "!";
  376.         }
  377.     }
  378. }
  379.  
  380. static function class CheckClassRemap( const class OrigClass, const string InstigatorName, const bool EnableLogging )
  381. {
  382.     local class<KFPawn_Monster> Monster${1}< ${3} >
  383.  
  384.     if ( ClassIsChildOf( OrigClass, class'KFPawn_Monster' ) )
  385.     {
  386.         MonsterClass = class<KFPawn_Monster>( OrigClass );
  387.         return CheckMonsterClassRemap( MonsterClass, InstigatorName, EnableLogging );
  388.     }
  389.  
  390.     `cdlog("Letting non-monster class "$OrigClass$" stand via "$InstigatorName, EnableLogging );
  391.     return Orig${1}< ${3} >
  392. }
  393.  
  394. static function class<Pawn> CheckPawnClassRemap( const class<Pawn> OrigClass, const string InstigatorName, const bool EnableLogging )
  395. {
  396.     local class<KFPawn_Monster> Monster${1}< ${3} >
  397.  
  398.     if ( ClassIsChildOf( OrigClass, class'KFPawn_Monster' ) )
  399.     {
  400.         MonsterClass = class<KFPawn_Monster>( OrigClass );
  401.         return CheckMonsterClassRemap( MonsterClass, InstigatorName, EnableLogging );
  402.     }
  403.  
  404.     `cdlog("Letting non-monster class "$OrigClass$" stand via "$InstigatorName, EnableLogging );
  405.     return Orig${1}< ${3} >
  406. }
  407.  
  408. static function class<KFPawn_Monster> CheckMonsterClassRemap( const class<KFPawn_Monster> OrigClass, const string InstigatorName, const bool EnableLogging )
  409. {
  410.     local class<KFPawn_Monster> New${1}< ${3} >
  411.  
  412.     NewClass = Orig${1}< ${3} >
  413.  
  414.     if ( OrigClass == class'CD_Pawn_ZedCrawler_Special' ||
  415.          OrigClass == class'CD_Pawn_ZedCrawler_Regular' )
  416.     {
  417.         NewClass = class'KFPawn_ZedCrawler';
  418.     }
  419.     else if ( OrigClass == class'CD_Pawn_ZedClot_Alpha_Special' ||
  420.               OrigClass == class'CD_Pawn_ZedClot_Alpha_Regular' )
  421.     {
  422.         NewClass = class'KFPawn_ZedClot_Alpha';
  423.     }
  424.     else if ( OrigClass == class'CD_Pawn_ZedGorefast_Special' ||
  425.               OrigClass == class'CD_Pawn_ZedGorefast_Regular' )
  426.     {
  427.         NewClass = class'KFPawn_ZedGorefast';
  428.     }
  429.     else if ( OrigClass == class'CD_Pawn_ZedFleshpound_NRS' ||
  430.               OrigClass == class'CD_Pawn_ZedFleshpound_RS' )
  431.     {
  432.         NewClass = class'KFPawn_ZedFleshpound';
  433.     }
  434.     else if ( OrigClass == class'CD_Pawn_ZedFleshpoundMini_NRS' ||
  435.               OrigClass == class'CD_Pawn_ZedFleshpoundMini_RS' )
  436.     {
  437.         NewClass = class'KFPawn_ZedFleshpoundMini';
  438.     }
  439.  
  440.     // Log what we just did
  441.     if ( OrigClass != NewClass )
  442.     {
  443.         `cdlog("Masked monster class "$OrigClass$" with substitute class "$NewClass$" via "$InstigatorName, EnableLogging );
  444.     }
  445.     else
  446.     {
  447.         `cdlog("Letting monster class "$OrigClass$" stand via "$InstigatorName, EnableLogging );
  448.     }
  449.  
  450.     return New${1}< ${3} >
  451. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement