Announcement

Collapse
No announcement yet.

UScript noob needs help on first mutator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    UScript noob needs help on first mutator

    OK, I wanted a mutator that would give you every weapon and infinite ammo. I decided that this would be a good time to start learning UScript (on advice), so this is what I have:

    Code:
    (old code removed)
    Here's the problems thus far:
    1.
    Analyzing...
    Parsing MutLoadout
    Compiling MutLoadout
    D:\Games\Unreal Tournament 2004\Loadout\Classes\MutLoadout.uc(100) : Error, Can't access protected variable 'Ammo' in 'Weapon'
    Compile aborted due to errors.
    Failure - 1 error(s), 0 warning(s)
    I'm guessing this means the UT2K3 tutorial I was using is outdated :cry:... so how can I actually set ammunition? (RESOLVED)
    2. Will my mutator work correctly chained? (IE if I use WoRM: Weapon Replacer along with this, will all players start with the weapons WoRM has specified?) (CHAINING NOT WORKING)
    3. How do I create a configuration dialog for configuration within UT2K4? (RESOLVED)

    Thanks!

    #2
    Score one for the nubs!

    I resolved the error myself. Code now stands as follows:
    Code:
    (old code removed)
    Going to test chainability now! However, I still need help on the config dialog.

    Comment


      #3
      After changing GroupName, mutator chaining works properly. So now a very simple question: how do I build configuration dialogs?

      Comment


        #4
        The following will give you an config screen with a check box that passes a true or false back to bWhatDoIDo
        Code:
        class somemute extends mutator;
        
        var config bool bWhatDoIDo;
        var string OptionName, OptionDescription;
        
        function PostBeginPlay()
        {
             log(bWhatDoIDo);
        }
        
        static function FillPlayInfo(PlayInfo PlayInfo)
        {
             PlayInfo.AddSetting(default.RulesGroup, "bWhatDoIDo", default.OptionName, 0, 1, "Check");
        }
        
        static event string GetDescriptionText(string PropName)
        {
             if (PropName == "bWhatDoIDo")
                  return default.OptionDescription;
        }
        
        defaultproperties
        {
             bWhatDoIDo=False;
             OptionName="Log True"
             OptionDescription="Logs true if checked, false if not"
        }

        Comment


          #5
          you can build dialogs with a open button too, but that is mutch more work

          Comment


            #6
            OK, between HSoolien's code and the Unreal Wiki, this is what I have for the GUI:
            Code:
            (more old code removed)
            But my configuration GUI doesn't show up Help!
            Edit: I've now tried commenting out Super.FillPlayInfo(PlayInfo), still doesn't work.
            Edit: Resolved

            Comment


              #7
              Found out how to decompile packages, decompiled Angel Item Physics, looked at code, realized my variables are supposed to be var _config_ etc., changed, recompiled, it works.

              Comment


                #8
                i have seen your tread on the idea's forums
                good you did it yourself
                is it already downloadable ?

                Comment


                  #9
                  Downloadable? Probably not a good idea, since I just found out it doesn't work properly with chaining :cry:

                  I turned on CUT2, but the mutator gave me regular weapons

                  Any more help? Here's a link to a zip with the source code and the compiled .u/.ucl/.int files if anyone wants to try them. (So yes, it's downloadable )

                  The code:
                  Code:
                  // MutLoadout - Player Loadout Mutator
                  // Gives players alternate starting health and shield, all weapons, and infinite ammo.
                  // By Neoflame, 11 June 2004
                  
                  class MutLoadout extends Mutator;
                  
                  var() config float StartingHealth; // player starting health
                  var() config float StartingArmor; // player starting armor
                  var config bool bInfiniteAmmo; // whether the player has infinite ammo, or just starts with maximum
                  var config bool bGiveONSWeapons; // whether the player gets ONS-specific weapons
                  var config bool bGiveSuperWeapons; // whether the player gets superweapons
                  
                  var localized string GUINameText[5];
                  var localized string GUIDescText[5];
                  
                  event PreBeginPlay()
                  {
                      if (bInfiniteAmmo)
                      {
                          SetTimer(0.25, true);
                      }
                  }
                  
                  function GiveAmmo(Pawn Obj)
                  {
                      // Check if infinite ammo is on
                      if (bInfiniteAmmo)
                      {
                          // Give 999 ammo
                          // Give basic weapon ammo
                          Weapon(Obj.FindInventoryType(class'AssaultRifle')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'BioRifle')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'ClassicSniperRifle')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'FlakCannon')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'LinkGun')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'Minigun')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'RocketLauncher')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'ShockRifle')).SuperMaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'SniperRifle')).SuperMaxOutAmmo();
                          // Give ONS weapon ammo (if applicable)
                          if (bGiveONSWeapons)
                          {
                              Weapon(Obj.FindInventoryType(class'ONSAVRiL')).SuperMaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'ONSGrenadeLauncher')).SuperMaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'ONSMineLayer')).SuperMaxOutAmmo();
                          }
                          // Give superweapon ammo (if applicable)
                          if (bGiveSuperWeapons)
                          {
                              Weapon(Obj.FindInventoryType(class'Redeemer')).SuperMaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'Painter')).SuperMaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'ONSPainter')).SuperMaxOutAmmo();
                          }
                      }
                      else
                      {
                             // Give maximum ammo
                          // Give basic weapon ammo
                          Weapon(Obj.FindInventoryType(class'AssaultRifle')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'BioRifle')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'ClassicSniperRifle')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'FlakCannon')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'LinkGun')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'Minigun')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'RocketLauncher')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'ShockRifle')).MaxOutAmmo();
                          Weapon(Obj.FindInventoryType(class'SniperRifle')).MaxOutAmmo();
                          // Give ONS weapon ammo (if applicable)
                          if (bGiveONSWeapons)
                          {
                              Weapon(Obj.FindInventoryType(class'ONSAVRiL')).MaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'ONSGrenadeLauncher')).MaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'ONSMineLayer')).MaxOutAmmo();
                          }
                          // Give superweapon ammo (if applicable)
                          if (bGiveSuperWeapons)
                          {
                              Weapon(Obj.FindInventoryType(class'Redeemer')).MaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'Painter')).MaxOutAmmo();
                              Weapon(Obj.FindInventoryType(class'ONSPainter')).MaxOutAmmo();
                          }
                      }
                  }
                  
                  function Timer()
                  {
                      local Controller Obj;
                      for (Obj = Level.ControllerList; Obj != None; Obj = Obj.NextController)
                      {
                          if (Obj.Pawn != None)
                          {
                              GiveAmmo(Obj.Pawn);
                          }
                      }
                  }
                  
                  function ModifyPlayer(Pawn Obj)
                  {
                      Obj.Health = StartingHealth;
                      Obj.ShieldStrength = StartingArmor;
                  
                      Obj.GiveWeapon("XWeapons.BioRifle");
                      Obj.GiveWeapon("XWeapons.FlakCannon");
                      Obj.GiveWeapon("XWeapons.LinkGun");
                      Obj.GiveWeapon("XWeapons.Minigun");
                      Obj.GiveWeapon("XWeapons.RocketLauncher");
                      Obj.GiveWeapon("XWeapons.ShockRifle");
                      Obj.GiveWeapon("XWeapons.SniperRifle");
                      Obj.GiveWeapon("UTClassic.ClassicSniperRifle");
                      // Give ONS weapons if applicable
                      if (bGiveONSWeapons)
                      {
                          Obj.GiveWeapon("Onslaught.ONSAVRiL");
                          Obj.GiveWeapon("Onslaught.ONSGrenadeLauncher");
                          Obj.GiveWeapon("Onslaught.ONSMineLayer");
                      }
                      // Give superweapons if applicable
                      if (bGiveSuperWeapons)
                      {
                          Obj.GiveWeapon("XWeapons.Redeemer");
                          Obj.GiveWeapon("XWeapons.Painter");
                          Obj.GiveWeapon("OnslaughtFull.ONSPainter");
                      }
                  
                      GiveAmmo(Obj);
                  
                      Super.ModifyPlayer(Obj);
                  }
                  
                  static function FillPlayInfo(PlayInfo PlayInfo)
                  {
                      Super.FillPlayInfo(PlayInfo);
                      PlayInfo.AddSetting(default.RulesGroup, "StartingHealth", default.GUINameText[0], 0, 0, "Text", "3;1:199");
                      PlayInfo.AddSetting(default.RulesGroup, "StartingArmor", default.GUINameText[1], 0, 0, "Text", "3;0:150");
                      PlayInfo.AddSetting(default.RulesGroup, "bInfiniteAmmo", default.GUINameText[2], 0, 0, "Check");
                      PlayInfo.AddSetting(default.RulesGroup, "bGiveONSWeapons", default.GUINameText[3], 0, 0, "Check");
                      PlayInfo.AddSetting(default.RulesGroup, "bGiveSuperWeapons", default.GUINameText[4], 0, 0, "Check");
                  }
                  
                  static event string GetDisplayText(string PropName)
                  {
                      switch (PropName)
                      {
                          case "StartingHealth": return default.GUINameText[0];
                          case "StartingArmor": return default.GUINameText[1];
                          case "bInfiniteAmmo": return default.GUINameText[2];
                          case "bGiveONSWeapons": return default.GUINameText[3];
                          case "bGiveSuperWeapons": return default.GUINameText[4];
                      }
                  }
                  
                  static event string GetDescriptionText(string PropName)
                  {
                      switch (PropName)
                      {
                          case "StartingHealth": return default.GUIDescText[0];
                          case "StartingArmor": return default.GUIDescText[1];
                          case "bInfiniteAmmo": return default.GUIDescText[2];
                          case "bGiveONSWeapons": return default.GUIDescText[3];
                          case "bGiveSuperWeapons": return default.GUIDescText[4];
                          default: return Super.GetDescriptionText(PropName);
                      }
                  }
                  
                  defaultproperties
                  {
                  StartingHealth=100
                  StartingArmor=100
                  bInfiniteAmmo=true
                  bGiveONSWeapons=true
                  bGiveSuperWeapons=false
                  GUINameText[0]="Starting Health"
                  GUINameText[1]="Starting Shield"
                  GUINameText[2]="Infinite Ammo"
                  GUINameText[3]="Onslaught Weapons"
                  GUINameText[4]="Superweapons"
                  GUIDescText[0]="Amount of health players start with."
                  GUIDescText[1]="Amount of shield players start with."
                  GUIDescText[2]="If this box is checked, all weapons will have infinite ammo. If not, all players will start off with the maximum amount of ammo for their weapons, but ammo will be finite."
                  GUIDescText[3]="If this box is checked, Onslaught weapons will be included in the loadout."
                  GUIDescText[4]="If this box is checked, superweapons will be included in the loadout."
                  GroupName="Loadout"
                  FriendlyName="Player Loadout"
                  Description="Starts players off with a configurable amount of health and shield, as well as every weapon and full ammo."
                  }

                  Comment


                    #10
                    A few questions, with the code above, what exactly DOES work? |(Do you get the weapons?, do you get max ammo on the default weapons?, do you see anything in the mutator config?)

                    Comment


                      #11
                      why dont use the checkreplacement
                      (dont know if it will work, only once used for ies1.04v2, and copyed from the smp, with permission)

                      Comment


                        #12
                        With the code above, I get:
                        1. the configuration dialog
                        2. all UT2004 weapons
                        3. infinite ammo for the UT2004 weapons

                        However, I do not get:
                        1. weapons replaced by other mutators
                        2. infinite ammo for non-UT2004 weapons

                        Bartje321, what's checkreplacement?

                        Comment


                          #13
                          part of ies1.04V2:
                          Code:
                          function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
                          {
                          	local int i,arraynum;
                          	if(bUseConfig && Other.IsA('Monster'))
                          	{
                          		for(i=0;i<24;i++)
                          		{
                          			if(Other.class==LoadMonsterClass[i])
                          			{
                                          Other.Acceleration*=MonsterConfigs[i].AccelScale;
                          				Monster(Other).groundspeed*=MonsterConfigs[i].SpeedScale;
                          				Monster(Other).airspeed*=MonsterConfigs[i].SpeedScale;
                          				Monster(Other).waterspeed*=MonsterConfigs[i].SpeedScale;
                          				Monster(Other).health*=MonsterConfigs[i].HealthScale;
                          				Monster(Other).ScoringValue=MonsterConfigs[i].ScoreValue;
                          				Other.SetDrawScale(Other.drawscale*MonsterConfigs[i].SizeScale);
                          				Other.SetCollisionSize(Other.CollisionRadius*MonsterConfigs[i].SizeScale,Other.CollisionHeight*MonsterConfigs[i].SizeScale);
                          				Pawn(Other).SkillModifier=MonsterConfigs[i].SkillModifier;
                                       	break;
                          
                          			}
                          
                          		}
                          
                          	}
                          
                          	return true;
                          }
                          anyway, it checks of some thinges have to change before placing them. i guess it works for the player pawn, or controller (who gets the weapons?) so you can change his stuff too

                          Comment


                            #14
                            OK, I've "fixed" infinite ammo by throwing together an ugly, "decieve the user into thinking they're starting off with infinite ammo" hack:
                            Code:
                            function Timer()
                            {
                                local Controller Obj;
                                for (Obj = Level.ControllerList; Obj != None; Obj = Obj.NextController)
                                {
                                    if (Obj.Pawn != None)
                                    {
                                        Obj.Pawn.Weapon.MaxOutAmmo();
                                    }
                                }
                            }
                            ...when in reality they only start getting infinite ammo when they pull out their gun!

                            But I'm still getting regular UT2004 weapons :cry:
                            Edit: I'll take a look at CheckReplacement.

                            Comment


                              #15
                              Right now, it seems to me that I can't directly check what weapons other mutators have replaced. So if I really want the functionality, I might have to reimplement WoRM/SwitchArsenal in my mutator :cry:

                              CheckReplacement probably won't work for me, because it looks like it only functions when spawning an Actor. I need an event or something to trap when other mutators change weaponry...

                              Comment

                              Working...
                              X