Announcement

Collapse
No announcement yet.

Need help with simple mutator!

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

    Need help with simple mutator!

    Hey so I posted a thread a while back asking if someone could make me the mutator. No one did, and I ended up making it myself. However, I cannot find it ANYWHERE on my computer, only the code that I used to compile the version that worked - or so I thought. When I compiled it, it 'worked', but it simply doesn't work ingame. What this mutator does is very simple. It hides your reticule (crosshair). I really don't have much of a clue what I'm doing, even less than I did when I got it to work. There's probably something really basic I'm missing here, and I think it could be in the ini so I'm including that too.

    The .uc:
    Code:
    class UTMutator_NoReticule extends UTMutator;
    
    function InitMutator(string Options, out string ErrorMessage)
    {
    	if ( UTPlayerController(Instigator.Controller) != None )
    	{
    		UTPlayerController(Instigator.Controller).bNoCrosshair = true;
    	}
    	Super.InitMutator(Options, ErrorMessage);
    }
    
    defaultproperties
    {
    	GroupNames[0]="NoReticule"
    	bExportMenuData=false
    }
    The .ini:
    Code:
    [UTMutator_NoReticule UTUIDataProvider_Mutator]
    ClassName=NoReticule.UTMutator_NoReticule
    FriendlyName=No Crosshair
    Description=Fight without the crosshair.
    GroupNames=NoReticule
    UIConfigScene=
    bStandaloneOnly=False
    BitValue=0
    bRemoveOn360=False
    bRemoveOnPC=False
    bRemoveOnPS3=False
    I don't get it, what's wrong?

    #2
    I think initmutator is called when the server init's the mutator. Some or all or your playercontrollers may not exist at this point. You may want to try overriding NotifyLogin as well. If this is not reliant, you may have to iterate through all your player controllers on a timer or simply base on additional event(s). As you are just setting a boolean, you may also need to determine if the code which relies on the boolean will trigger, is it on a tick, on weapon change, etc.
    function NotifyLogin(Controller NewPlayer)
    {
    local PlayerController PC;

    super.NotifyLogin(NewPlayer);

    PC = PlayerController(NewPlayer);

    if(PC != none)
    {
    p.s. if notify login works out for you then you also should probably override GetSeamlessTravelActorList and perhaps even notifylogout. IIRC, you are setting up a melee server. You could also try just replacing hud instead, but you would have to maintain the replacement when setting up new/other gametypes on your server.

    Comment


      #3
      As usual, I leave something out. I thought I didn't need to include it because I thought this was how all single boolean mutators were made. Considering what you said, apparently not. Not only did I make a mutator that did this a while back, I also made another one (and I had that source code too, but it actually worked, unlike the NoReticule mutator) of a mod that enabled the hoverboard in any gamemode. Now, I know this already exists, I just wanted to try to make a mod, and it worked. The funny thing though, is that the only difference between this mod and the hoverboard one is the location (I believe it was something to the effect of: WorldInfo(UTGame.Info)), the command (to enable the hoverboard rather than disable the reticule) and, in the case of the ini, what it references (hoverboard, not noreticule)

      ...In other words, this mod is literally a copy of the hoverboard mod I made, which in fact works, using these exact commands (except location and actual action). It's unfortunate I'm unable to access the hoverboard mutator at this moment, but it will be done within the next 24 hours (or should be, I'm known to forget). There probably are multiple ways to do this, and thanks for your help so far. However, it will probably be incredibly simple for you to pinpoint what went wrong when I changed the hoverboard mod to the noreticule one. I remember it being a small change, but I don't remember what. I think it could've been the location (it wasn't in playercontroller instigator whatever thing it was in) I think it had to do with that but I dont know, and I've looked there already (not to mention that the mod compiles, it just doesnt do what I want it to) As I think I said, I'm really not that knowledgable about this but as far as I know, if it compiles then it finds the bNoReticule in the location I gave it. Whether that's possibly some sort of test dummy that wasn't used in the game and there's really another one five lines down, I don't know. I seem to remember it being something like that though... Well, in reality, I seem to remember this being the one that works. You sure there's nothing wrong with my ini?

      Anyways, I'll upload the hoverboard mod files soon, hopefully the problem will be able to be fixed (and I'll actually SAVE the working one this time, never figured out what happened to the last one...

      Edit: Yes, this is for a melee server. However, players not only need to see their health but also their current level, so I would have to override it with something else. But would I have to recreate the current HUD? As far as I know, the HUD isn't all one image, it's several (one of them being the crosshair I think) Is there a way to just override the crosshair component? Or am I thinking about this in the complete wrong way? (wouldn't be the first time :P)

      Comment


        #4
        WOW, I actually DID forget. Sorry about that, here's the hoverboard .uc:

        Code:
        class UTMutator_Hoverboard extends UTMutator;
        
        function InitMutator(string Options, out string ErrorMessage)
        {
        	if ( UTGame(WorldInfo.Game) != None )
        	{
        		UTGame(WorldInfo.Game).bAllowHoverboard = true;
        	}
        	Super.InitMutator(Options, ErrorMessage);
        }
        
        defaultproperties
        {
        	GroupNames[0]="HOVERBOARD"
        	bExportMenuData=false
        }
        And it's .ini:

        Code:
        [UTMutator_Hoverboard UTUIDataProvider_Mutator]
        ClassName=HoverBoard.UTMutator_HoverBoard
        FriendlyName=Hoverboard
        Description=Gives you a Hover Board no matter what the gametype!
        GroupNames=HoverBoard
        UIConfigScene=
        bStandaloneOnly=False
        BitValue=0
        bRemoveOn360=False
        bRemoveOnPC=False
        bRemoveOnPS3=False
        I'm sure there's some incredibly obvious (to you anyways) problem here, could anyone shed some light?

        PS: This hoverboard mod works perfectly, it gives you access to the hoverboard in any gamemode, and it works exactly like it does in warfare or vctf. What I'm confused about is how my NoReticule mod, which works the exact same way, DOESN'T work (it compiles but does absolutely nothing whatsoever ingame)

        Comment


          #5
          bNoCrosshair is a configurable property. That means it will not be replicated. While bAllowHoverboard isn't replicated either, its effect is applied on the server (it's assigned to Pawn.bHasHoverboard, which in turn is replicated). bNoCrosshair is configurable, so if you set it to some fixed value you risk making it a permanent change for unsuspecting players. Find a different way to do it, unless you want to anger your players.

          Comment


            #6
            Well thats good to know. Do you know of a way to hide the crosshair just when you are on the server? There's probably some easy way to do it but I don't know. I remember finding another way to get it to work though. I don't know much about code in UT3 at all but I should be able to pinpoint the command itself if I know the general type of file it comes from. Do you have any suggestions? I think I've already checked the entire UTPlayerController .uc file, and perhaps I should do the same with UTGame.uc. Besides those, do you have any suggestions as to where to find such a command that would temporarily hide it? (instead of sending the command to change your profile's settings to have it hidden, im looking for what that command TRIGGERS, what's the ACTUAL core command that literally just hides the crosshair) Thanks for your help thusfar. At least I have some direction now, I know that I can't just edit little things to get it to work, I need to find another command (instead of bNoCrosshair). If I am not mistaken, I remember it being in UTGame.uc or UTPlayerController, even though I haven't found it yet... Perhaps I should take the alternate path and just try to locate it on my computer (I did end up making a working one a while back after all, I just can't find it anywhere. Then again, I never checked my recycle bin...)

            The most important thing besides that is the ini. Considering that nothing was said about it I would assume it's all correct? (For some wierd reason, it won't make the ini when I compile)

            Comment


              #7
              I made you something. http://www.gamefront.com/files/21199269/Aimless.7z
              This uses the config bool bNoCrossHair, so you probably shouldn't run it with any mod/mutator which has a class which uses "Config(Game);" and does a "SaveConfig()".
              There is another bool which is set in the UTPlayerControllers exec function ToggleScreenShotMode. I tried scripting this another way which acessed and set this bool, but that did not hide the crosshair in my tests. Not sure what else would be required to perform the hide/remove in that manner..

              Comment


                #8
                Sorry, haven't been doing much in the way of UT3 lately, but I'm back at it (somewhat :P) The link's dead but I already got the mutator, testing it soon.

                Comment


                  #9
                  EDIT: Oh. I posted 20 minutes after you replied. **** long post


                  Old post
                  ---------------------------
                  Ehm. Is this "problem" solved? idnewton asked me to look at this thread some days ago.
                  Otherwise, i got something for you.

                  Fully working mutator:
                  RSNoCrosshair_v0.1b.zip
                  http://www.mediafire.com/file/lb8rwd...hair_v0.1b.zip


                  Explanation:
                  Basically to get the wanted function working, you need to look for a code which calls the function to draw the crosshair. In this case, its the function ''DrawWeaponCrosshair(...)"

                  Code:
                  /*********************************************************************************************
                   * Hud/Crosshairs
                   *********************************************************************************************/
                  
                  /**
                   * Access to HUD and Canvas.
                   * Event always called when the InventoryManager considers this Inventory Item currently "Active"
                   * (for example active weapon)
                   *
                   * @param    HUD            - HUD with canvas to draw on
                   */
                  simulated function ActiveRenderOverlays( HUD H )
                  {
                      local UTPlayerController PC;
                  
                      PC = UTPlayerController(Instigator.Controller);
                      if ( (PC != None) && !PC.bNoCrosshair )
                      {
                          CrossHairCoordinates = PC.bSimpleCrosshair ? SimpleCrosshairCoordinates : default.CrosshairCoordinates;
                          DrawWeaponCrosshair( H );
                      }
                  }
                  
                  /**
                   * Draw the Crosshairs
                   */
                  simulated function DrawWeaponCrosshair( Hud HUD )
                  {
                      local vector2d CrosshairSize;
                      local float x,y,PickupScale, ScreenX, ScreenY;
                      local UTHUD    H;
                      local UTPlayerController PC;
                  
                      H = UTHUD(HUD);
                      if ( H == None )
                          return;
                  
                      // Apply pickup scaling
                      if ( H.LastPickupTime > WorldInfo.TimeSeconds - 0.3 )
                      {
                          if ( H.LastPickupTime > WorldInfo.TimeSeconds - 0.15 )
                          {
                              PickupScale = (1 + 5 * (WorldInfo.TimeSeconds - H.LastPickupTime));
                          }
                          else
                          {
                              PickupScale = (1 + 5 * (H.LastPickupTime + 0.3 - WorldInfo.TimeSeconds));
                          }
                      }
                      else
                      {
                          PickupScale = 1.0;
                      }
                  
                      PC = UTPlayerController(Instigator.Controller);
                      if ( PC.bSimpleCrosshair )
                      {
                           CrosshairSize.Y = H.ConfiguredCrosshairScaling * CrosshairScaling * CrossHairCoordinates.VL * PickupScale * H.Canvas.ClipY/768;
                            CrosshairSize.X = CrosshairSize.Y * ( CrossHairCoordinates.UL / CrossHairCoordinates.VL ) * H.Canvas.ClipX/1024;
                      }
                      else
                      {
                           CrosshairSize.Y = H.ConfiguredCrosshairScaling * CrosshairScaling * CrossHairCoordinates.VL * PickupScale * H.Canvas.ClipY/768;
                            CrosshairSize.X = CrosshairSize.Y * ( CrossHairCoordinates.UL / CrossHairCoordinates.VL );
                      }
                  
                      X = H.Canvas.ClipX * 0.5;
                      Y = H.Canvas.ClipY * 0.5;
                      ScreenX = X - (CrosshairSize.X * 0.5);
                      ScreenY = Y - (CrosshairSize.Y * 0.5);
                      if ( CrosshairImage != none )
                      {
                          // crosshair drop shadow
                          H.Canvas.DrawColor = H.BlackColor;
                          H.Canvas.SetPos( ScreenX+1, ScreenY+1 );
                          H.Canvas.DrawTile(CrosshairImage,CrosshairSize.X, CrosshairSize.Y, CrossHairCoordinates.U, CrossHairCoordinates.V, CrossHairCoordinates.UL,CrossHairCoordinates.VL);
                  
                          CrosshairColor = H.bGreenCrosshair ? H.Default.LightGreenColor : Default.CrosshairColor;
                          H.Canvas.DrawColor = (WorldInfo.TimeSeconds - LastHitEnemyTime < 0.3) ? H.RedColor : CrosshairColor;
                          H.Canvas.SetPos(ScreenX, ScreenY);
                          H.Canvas.DrawTile(CrosshairImage,CrosshairSize.X, CrosshairSize.Y, CrossHairCoordinates.U, CrossHairCoordinates.V, CrossHairCoordinates.UL,CrossHairCoordinates.VL);
                      }
                  }
                  As you can see, if bNoCrosshair is not set the DrawWeaponCrosshair function is not called. The next step is to investigate if bNoCrosshair is replicated, serversided or clientsided (or something else). Wormbo already mentioned the important part, so you have to get a solution to set this variable clientsided.

                  The most easiest way is to create a Hud, override the function DrawWeaponCrosshair with a null function. But in this case, every mutator/gametype with its own Hud will be in conflict.

                  Code:
                  simulated function DrawWeaponCrosshair( Hud HUD )
                  {
                  }
                  Classes which caues conflicts (-> less compatibility)
                  • UTPawn: Most game play modifying mutator uses an own Pawn class
                  • UTPlayerController: Most mutator use this to hook the inpup
                  • UTHud
                  • ...

                  Classes to be used which won't cause a conflict (if so it's very rare):
                  • Interaction
                  • Inventory
                  • -ReplicationInfo

                  I used the ReplicationInfo. By setting bNoCrosshair clientsided the crosshair won't show up on clients or any local players. If bNoCrosshair will interfere with something else, you could use a solution with CrosshairImage. As you can see in the code above, the variables is used for drawing an image to the Canvas of the Hud. But if it's not set, it won't trigger that block of code - and it won't draw the crosshair.
                  Another important part: You have to know a bit of replication and what the keywords simulated, client and server in a signature of a function will do. You can start by reading Wormo's link in his signature.
                  http://wiki.beyondunreal.com/Everything_you_ever_wanted_to_know_about_replicati on_(but_were_afraid_to_ask)


                  For both solutions bNoCrosshair and CrosshairImage you need verify if no mutator/gametype will call a SaveConfig (SaveStaticConfig) function. Otherwise, the variables will be overwritten and the players need to restore the old value manually.

                  Hope, my explanation was not to difficult to understand.

                  Here's the full sourcecode.

                  Mutator class
                  Code:
                  class RSMutator_NoCrosshair extends UTMutator;
                  
                  var NoCrosshairReplicationInfo _nocross_rep;
                  
                  event PostBeginPlay()
                  {
                      Super.PostBeginPlay();
                  
                      // spawn a replication info to set bNoCrosshair
                      // this replication will be replicated natively to clients
                      _nocross_rep = Spawn(class'NoCrosshairReplicationInfo');
                  }
                  
                  DefaultProperties
                  {
                  }
                  Replication class
                  Code:
                  class NoCrosshairReplicationInfo extends ReplicationInfo;
                  
                  simulated function PostBeginPlay()
                  {
                      super.PostBeginPlay();
                      
                      // Set timer on client/listen server only
                      if (Worldinfo.NetMode != NM_DedicatedServer) {
                          SetTimer(0.1, True);
                      }
                  }
                  
                  simulated function Timer()
                  {
                      SetNoCrosshair();
                  }
                  
                  simulated function SetNoCrosshair()
                  {
                      local UTPlayerController UTPC;
                  
                      // set the var on each local PlayerController.
                      // If there are more than 1 player, they will be on the same server.
                      // No need to check that
                      foreach LocalPlayerControllers(class'UTPlayerController', UTPC) {
                          UTPC.bNoCrosshair = true;
                      }
                  }
                  
                  DefaultProperties
                  {
                  }

                  Comment


                    #10
                    No, oddly it's not. The mod doesn't work for me. If it worked for you, NickG, perhaps I need to reinstall. I'll try this one and see how it goes.

                    Comment


                      #11
                      Mine worked for me as a Dedicated server mutator. Which mutator is not working for you, did you miss Rattlesnake's link posted above? I have not tried it. If you want mine again, I should improve it, first. I purposefully avoided loops in mine, but a Timer like in RattleSnake's should prove more reliable if another class or function sets bNoCrosshair true during play.

                      Comment

                      Working...
                      X