Advertisement
mGm_Lizard

Mutator.uc

Oct 24th, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Mutator.
  3. //
  4. // Mutators allow modifications to gameplay while keeping the game rules intact.
  5. // Mutators are given the opportunity to modify player login parameters with
  6. // ModifyLogin(), to modify player pawn properties with ModifyPlayer(), to change
  7. // the default weapon for players with GetDefaultWeapon(), or to modify, remove,
  8. // or replace all other actors when they are spawned with CheckRelevance(), which
  9. // is called from the PreBeginPlay() function of all actors except those (Decals,
  10. // Effects and Projectiles for performance reasons) which have bGameRelevant==true.
  11. //=============================================================================
  12. class Mutator extends Info
  13.     DependsOn(GameInfo)
  14.     CacheExempt // rjp -- for Caching
  15.     native;
  16.  
  17. var Mutator NextMutator;
  18. var class<Weapon> DefaultWeapon;
  19. var string DefaultWeaponName;
  20. var bool bUserAdded;        // mc - mutator was added by user (cmdline or mutator list)
  21. var bool bAddToServerPackages;      // if true, the package this mutator is in will be added to serverpackages at load time
  22.  
  23. var() cache string            IconMaterialName;
  24. var() cache string            ConfigMenuClassName;
  25. var() cache string            GroupName; // Will only allow one mutator with this tag to be selected.
  26.  
  27. /* rjp ---
  28.     A note about mutators & the caching system:
  29.     In order for your mutator to appear in the game's mutator lists, you must create a cache file which
  30.     contains your mutator's important information.
  31.  
  32.     This can be done automatically using a commandlet.  If you wish to ensure support for multiple
  33.     languages in your mutator, you should always export localized strings to .int before exporting the mutator's cache
  34.     information.  This ensures that the caching system will recognize that your mutator has localized properties and
  35.     will adjust your mutator's cache entry accordingly.
  36.  
  37.     To export localized properties, use the 'dumpint' commandlet:
  38.     'ucc dumpint <PackageFileName.ext>' - generates .int file containing all localized properties.
  39.  
  40.     To export cache entries, use the 'exportcache' commandlet:
  41.     'ucc exportcache <PackageName.ext>' - generates a .ucl file containing all required caching information.
  42.  
  43.     Ex: (ACoolMutator.u)
  44.  
  45.     ucc dumpint ACoolMutator.u
  46.       - generates ACoolMutator.int
  47.     ucc exportcache ACoolMutator.u
  48.       - generates ACoolMutator.ucl file containing an entry for each mutator, gameinfo, weapon, and crosshair in
  49.         the ACoolMutator package.
  50.  
  51.  
  52.     Adding "Object=()" lines to your mutator's .int file is no longer necessary.  If the caching system finds any
  53.     Object=() entries in an .int file for your mutator, it will automatically create the necessary .ucl file the first
  54.     time the game is started.
  55.  
  56.     -- rjp
  57. */
  58. var() localized cache string  FriendlyName;
  59. var() localized cache string  Description;
  60.  
  61. /* Don't call Actor PreBeginPlay() for Mutator
  62. */
  63. event PreBeginPlay()
  64. {
  65.     if ( !MutatorIsAllowed() )
  66.         Destroy();
  67.     else if (bAddToServerPackages)
  68.         AddToPackageMap();
  69. }
  70.  
  71. function bool MutatorIsAllowed()
  72. {
  73.     return !Level.IsDemoBuild() || Class==class'Mutator';
  74. }
  75.  
  76. function Destroyed()
  77. {
  78.     local Mutator M;
  79.  
  80.     // remove from mutator list
  81.     if ( Level.Game.BaseMutator == self )
  82.         Level.Game.BaseMutator = NextMutator;
  83.     else
  84.     {
  85.         for ( M=Level.Game.BaseMutator; M!=None; M=M.NextMutator )
  86.             if ( M.NextMutator == self )
  87.             {
  88.                 M.NextMutator = NextMutator;
  89.                 break;
  90.             }
  91.     }
  92.     Super.Destroyed();
  93. }
  94.  
  95. function Mutate(string MutateString, PlayerController Sender)
  96. {
  97.     if ( NextMutator != None )
  98.         NextMutator.Mutate(MutateString, Sender);
  99. }
  100.  
  101. function ModifyLogin(out string Portal, out string Options)
  102. {
  103.     if ( NextMutator != None )
  104.         NextMutator.ModifyLogin(Portal, Options);
  105. }
  106.  
  107. //Notification that a player is exiting
  108. function NotifyLogout(Controller Exiting)
  109. {
  110.     if (NextMutator != None)
  111.         NextMutator.NotifyLogout(Exiting);
  112. }
  113.  
  114. /* called by GameInfo.RestartPlayer()
  115.     change the players jumpz, etc. here
  116. */
  117. function ModifyPlayer(Pawn Other)
  118. {
  119.     if ( NextMutator != None )
  120.         NextMutator.ModifyPlayer(Other);
  121. }
  122.  
  123. /* return what should replace the default weapon
  124.    mutators further down the list override earlier mutators
  125. */
  126. function Class<Weapon> GetDefaultWeapon()
  127. {
  128.     local Class<Weapon> W;
  129.  
  130.     if ( NextMutator != None )
  131.     {
  132.         W = NextMutator.GetDefaultWeapon();
  133.         if ( W == None )
  134.             W = MyDefaultWeapon();
  135.     }
  136.     else
  137.         W = MyDefaultWeapon();
  138.     return W;
  139. }
  140.  
  141. /* GetInventoryClass()
  142. return an inventory class - either the class specified by InventoryClassName, or a
  143. replacement.  Called when spawning initial inventory for player
  144. */
  145. function Class<Inventory> GetInventoryClass(string InventoryClassName)
  146. {
  147.     InventoryClassName = GetInventoryClassOverride(InventoryClassName);
  148.     return class<Inventory>(DynamicLoadObject(InventoryClassName, class'Class'));
  149. }
  150.  
  151. /* GetInventoryClassOverride()
  152. return the string passed in, or a replacement class name string.
  153. */
  154. function string GetInventoryClassOverride(string InventoryClassName)
  155. {
  156.     // here, in mutator subclass, change InventoryClassName if desired.  For example:
  157.     // if ( InventoryClassName == "Weapons.DorkyDefaultWeapon"
  158.     //      InventoryClassName = "ModWeapons.SuperDisintegrator"
  159.  
  160.     if ( NextMutator != None )
  161.         return NextMutator.GetInventoryClassOverride(InventoryClassName);
  162.     return InventoryClassName;
  163. }
  164.  
  165. function class<Weapon> MyDefaultWeapon()
  166. {
  167.     if ( (DefaultWeapon == None) && (DefaultWeaponName != "") )
  168.         DefaultWeapon = class<Weapon>(DynamicLoadObject(DefaultWeaponName, class'Class'));
  169.  
  170.     return DefaultWeapon;
  171. }
  172.  
  173. function AddMutator(Mutator M)
  174. {
  175.     if ( NextMutator == None )
  176.         NextMutator = M;
  177.     else
  178.         NextMutator.AddMutator(M);
  179. }
  180.  
  181. function string RecommendCombo(string ComboName)
  182. {
  183.     return ComboName;
  184. }
  185.  
  186. function string NewRecommendCombo(string ComboName, AIController C)
  187. {
  188.     local string NewComboName;
  189.  
  190.     NewComboName = RecommendCombo(ComboName);
  191.     if (NewComboName != ComboName)
  192.         return NewComboName;
  193.  
  194.     if (NextMutator != None)
  195.         return NextMutator.NewRecommendCombo(ComboName, C);
  196.     return ComboName;
  197. }
  198.  
  199. /* ReplaceWith()
  200. Call this function to replace an actor Other with an actor of aClass.
  201. */
  202. function bool ReplaceWith(actor Other, string aClassName)
  203. {
  204.     local Actor A;
  205.     local class<Actor> a${1}< ${3} >
  206.  
  207.     if ( aClassName == "" )
  208.         return true;
  209.  
  210.     aClass = class<Actor>(DynamicLoadObject(aClassName, class'Class'));
  211.     if ( aClass != None )
  212.         A = Spawn(aClass,Other.Owner,Other.tag,Other.Location, Other.Rotation);
  213.     if ( Other.IsA('Pickup') )
  214.     {
  215.         if ( Pickup(Other).MyMarker != None )
  216.         {
  217.             Pickup(Other).MyMarker.markedItem = Pickup(A);
  218.             if ( Pickup(A) != None )
  219.             {
  220.                 Pickup(A).MyMarker = Pickup(Other).MyMarker;
  221.                 A.SetLocation(A.Location
  222.                     + (A.CollisionHeight - Other.CollisionHeight) * vect(0,0,1));
  223.             }
  224.             Pickup(Other).MyMarker = None;
  225.         }
  226.         else if ( A.IsA('Pickup') )
  227.             Pickup(A).Respawntime = 0.0;
  228.     }
  229.     if ( A != None )
  230.     {
  231.         A.event = Other.event;
  232.         A.tag = Other.tag;
  233.         return true;
  234.     }
  235.     return false;
  236. }
  237.  
  238. /* Force game to always keep this actor, even if other mutators want to get rid of it
  239. */
  240. function bool AlwaysKeep(Actor Other)
  241. {
  242.     if ( NextMutator != None )
  243.         return ( NextMutator.AlwaysKeep(Other) );
  244.     return false;
  245. }
  246.  
  247. function bool IsRelevant(Actor Other, out byte bSuperRelevant)
  248. {
  249.     local bool bResult;
  250.  
  251.     bResult = CheckReplacement(Other, bSuperRelevant);
  252.     if ( bResult && (NextMutator != None) )
  253.         bResult = NextMutator.IsRelevant(Other, bSuperRelevant);
  254.  
  255.     return bResult;
  256. }
  257.  
  258. function bool CheckRelevance(Actor Other)
  259. {
  260.     local bool bResult;
  261.     local byte bSuperRelevant;
  262.  
  263.     if ( AlwaysKeep(Other) )
  264.         return true;
  265.  
  266.     // allow mutators to remove actors
  267.  
  268.     bResult = IsRelevant(Other, bSuperRelevant);
  269.  
  270.     return bResult;
  271. }
  272.  
  273. function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
  274. {
  275.     return true;
  276. }
  277.  
  278. //
  279. // Called when a player sucessfully changes to a new class
  280. //
  281. function PlayerChangedClass(Controller aPlayer)
  282. {
  283.     if ( NextMutator != None )
  284.         NextMutator.PlayerChangedClass(aPlayer);
  285. }
  286.  
  287. //
  288. // server querying
  289. //
  290. function GetServerDetails( out GameInfo.ServerResponseLine ServerState )
  291. {
  292.     // append the mutator name.
  293.     local int i;
  294.     i = ServerState.ServerInfo.Length;
  295.     ServerState.ServerInfo.Length = i+1;
  296.     ServerState.ServerInfo[i].Key = "Mutator";
  297.     ServerState.ServerInfo[i].Value = GetHumanReadableName();
  298. }
  299.  
  300. function GetServerPlayers( out GameInfo.ServerResponseLine ServerState )
  301. {
  302. }
  303.  
  304. // jmw - Allow mod authors to hook in to the %X var parsing
  305.  
  306. function string ParseChatPercVar(Controller Who, string Cmd)
  307. {
  308.     if (NextMutator !=None)
  309.         Cmd = NextMutator.ParseChatPercVar(Who,Cmd);
  310.  
  311.     return Cmd;
  312. }
  313.  
  314. function MutatorFillPlayInfo(PlayInfo PlayInfo)
  315. {
  316.     FillPlayInfo(PlayInfo);
  317.  
  318.     if (NextMutator != None)
  319.         NextMutator.MutatorFillPlayInfo(PlayInfo);
  320. }
  321.  
  322. event bool OverrideDownload( string PlayerIP, string PlayerID, string PlayerURL, out string RedirectURL )
  323. {
  324.     if( NextMutator != None )
  325.         return NextMutator.OverrideDownload( PlayerIP, PlayerID, PlayerURL, RedirectURL );
  326.  
  327.     return true;
  328. }
  329.  
  330. function ServerTraveling(string URL, bool bItems)
  331. {
  332.     if (NextMutator != None)
  333.         NextMutator.ServerTraveling(URL,bItems);
  334. }
  335.  
  336.  
  337. function bool CanEnterVehicle(Vehicle V, Pawn P)
  338. {
  339.     if( NextMutator != None )
  340.         return NextMutator.CanEnterVehicle(V, P);
  341.  
  342.     return true;
  343. }
  344.  
  345. function DriverEnteredVehicle(Vehicle V, Pawn P)
  346. {
  347.     if( NextMutator != None )
  348.         NextMutator.DriverEnteredVehicle(V, P);
  349. }
  350.  
  351. function bool CanLeaveVehicle(Vehicle V, Pawn P)
  352. {
  353.     if( NextMutator != None )
  354.         return NextMutator.CanLeaveVehicle(V, P);
  355.  
  356.     return true;
  357. }
  358.  
  359. function DriverLeftVehicle(Vehicle V, Pawn P)
  360. {
  361.     if( NextMutator != None )
  362.         NextMutator.DriverLeftVehicle(V, P);
  363. }
  364.  
  365. defaultproperties
  366. {
  367.      IconMaterialName="MutatorArt.nosym"
  368. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement