Fixys Fixes

Discussion in 'Modifications' started by Fixious, Apr 19, 2015.

  1. Fixious

    Fixious Test Lead

    Can't even remember if this was ever posted. Just know that it isn't part of the current build, though used to be a long time ago I think. This script allows you to take mega screenshots or save each frame as an image. Mega screenshots are a whopping 12,800 by 7,200 resolution, and are around 265MB in size. Pretty sure you can set it to whatever resolution you want but I haven't been able to figure it out yet. There's a normal screenshot function but I couldn't get it to work. Saving frames as a movie is a very laggy process; to stop it just enter stopMovie() into the console. There are variables for this function as well, but haven't figured it all out yet.

    Code:
    //---------------------------------------------------------------------------------------------
    // Torque Game Builder
    // Copyright (C) GarageGames.com, Inc.
    //---------------------------------------------------------------------------------------------
    
    GlobalActionMap.bind(keyboard, "ctrl p", doScreenShot);
    GlobalActionMap.bindCmd(keyboard, "ctrl [", "", "doMegaShot();");
    
    function doMegaShot()
    {
       $MegaShot::do = 1;
    }
    
    function setMegaShotSize(%val)
    {
       $Pref::MegaShot::numSamples = %val;
    }
    
    function setMegaShotLODBias(%val)
    {
       $Pref::MegaShot::lodBias = %val;
    }
    
    function setAntialiasLevel(%val)
    {
       %mode = $Pref::Video::Mode;
       Canvas.setVideoMode(getWord(%mode, 0), getWord(%mode, 1), getWord(%mode, 2), getWord(%mode, 3), getWord(%mode, 4), %val);
    }
    
    //---------------------------------------------------------------------------------------------
    // formatImageNumber
    // Preceeds a number with zeros to make it 6 digits long.
    //---------------------------------------------------------------------------------------------
    function formatImageNumber(%number)
    {
       if(%number < 10)
          %number = "0" @ %number;
       if(%number < 100)
          %number = "0" @ %number;
       if(%number < 1000)
          %number = "0" @ %number;
       if(%number < 10000)
          %number = "0" @ %number;
       return %number;
    }
    
    //---------------------------------------------------------------------------------------------
    // formatSessionNumber
    // Preceeds a number with zeros to make it 4 digits long.
    //---------------------------------------------------------------------------------------------
    function formatSessionNumber(%number)
    {
       if(%number < 10)
          %number = "0" @ %number;
       if(%number < 100)
          %number = "0" @ %number;
       return %number;
    }
    
    //---------------------------------------------------------------------------------------------
    // recordMovie
    // Captures screenshots at a rate of %fps frames per second until stopMovie is called.
    //---------------------------------------------------------------------------------------------
    function recordMovie(%movieName, %fps)
    {
       $timeAdvance = 1000 / %fps;
       $screenGrabThread = schedule($timeAdvance, 0, movieGrabScreen, %filename, 0); 
    }
    
    function movieGrabScreen(%movieName, %frameNumber)
    {
       screenshot(%movieName @ formatImageNumber(%frameNumber) @ ".png", "PNG");
       $screenGrabThread = schedule($timeAdvance, 0, movieGrabScreen, %movieName, %frameNumber + 1); 
    }
    
    function stopMovie()
    {
       $timeAdvance = 0;
       cancel($screenGrabThread);
    }
    
    //---------------------------------------------------------------------------------------------
    // doScreenShot
    // Capture a screenshot.
    //---------------------------------------------------------------------------------------------
    $screenshotNumber = 0;
    function doScreenShot(%val)
    {
       // Because this can be bound to a hotkey, we make sure that %val is 1 or not specified. That
       // way, the screenshot will be taken only on keydown, or when this function is called with
       // no parameters.
       if ((%val) || (%val $= ""))
       {
          if ($pref::Video::screenShotSession $= "")
             $pref::Video::screenShotSession = 0;
           
          if ($screenshotNumber == 0)
             $pref::Video::screenShotSession++;
           
          if ($pref::Video::screenShotSession > 999)
             $pref::Video::screenShotSession = 1;
           
          %name = expandFileName( "^game/data/screenshots/" @ formatSessionNumber($pref::Video::screenShotSession) @ "-" @
                   formatImageNumber($screenshotNumber) );
        
          $screenshotNumber++;
        
          if (($pref::Video::screenShotFormat $= "JPEG") ||
              ($pref::video::screenShotFormat $= "JPG"))
             screenShot(%name @ ".jpg", "JPEG");
           
          else if($pref::Video::screenShotFormat $= "PNG")
             screenShot(%name @ ".png", "PNG");
           
          else
             screenShot(%name @ ".png", "PNG");
       }
    }
    
    function toggleHud()
    {
       HudOverlay.visible = 1 - HudOverlay.visible;
    }
    
    Copy this to Notepad, save it as "screenshot.cs", and place it in mods/autoexec. If the autoexec folder doesn't exist simply create one. This script is pretty cool as it allows you to take screenshots at a resolution higher than the one you play at, though it doesn't look like the HUD scales nicely. For example, I play on a laptop at 1366x768, though using the megaShot function I can take a huge screenshot then scale it down in Photoshop to 4000x2250. Examples:

    http://www.fps-z.com/wp-content/uploads/2015/2.png
    http://www.fps-z.com/wp-content/uploads/2015/02.png
    http://www.fps-z.com/wp-content/uploads/2015/7.png
     
    Last edited: Apr 19, 2015
    a20z07 likes this.
  2. The_Horny_Rat

    The_Horny_Rat New Member

    I want mega screens in JPG....
    Even after setting the pref to jpg, and editing the functions, so only jpg is created it still creates a .png
    Anyone else only getting .png?

    Code:
    $Pref::Video::ScreenShotFormat = "JPG";
    
    GlobalActionMap.bind(keyboard, "ctrl p", doScreenShot);
    GlobalActionMap.bindCmd(keyboard, "ctrl [", "", "doMegaShot();");
    
    function doMegaShot()
    {
       $MegaShot::do = 1;
    }
    
    function setMegaShotSize(%val)
    {
       $Pref::MegaShot::numSamples = %val;
    }
    
    function setMegaShotLODBias(%val)
    {
       $Pref::MegaShot::lodBias = %val;
    }
    
    function setAntialiasLevel(%val)
    {
       %mode = $Pref::Video::Mode;
       Canvas.setVideoMode(getWord(%mode, 0), getWord(%mode, 1), getWord(%mode, 2), getWord(%mode, 3), getWord(%mode, 4), %val);
    }
    
    //---------------------------------------------------------------------------------------------
    // formatImageNumber
    // Preceeds a number with zeros to make it 6 digits long.
    //---------------------------------------------------------------------------------------------
    function formatImageNumber(%number)
    {
       if(%number < 10)
          %number = "0" @ %number;
       if(%number < 100)
          %number = "0" @ %number;
       if(%number < 1000)
          %number = "0" @ %number;
       if(%number < 10000)
          %number = "0" @ %number;
       return %number;
    }
    
    //---------------------------------------------------------------------------------------------
    // formatSessionNumber
    // Preceeds a number with zeros to make it 4 digits long.
    //---------------------------------------------------------------------------------------------
    function formatSessionNumber(%number)
    {
       if(%number < 10)
          %number = "0" @ %number;
       if(%number < 100)
          %number = "0" @ %number;
       return %number;
    }
    
    //---------------------------------------------------------------------------------------------
    // recordMovie
    // Captures screenshots at a rate of %fps frames per second until stopMovie is called.
    //---------------------------------------------------------------------------------------------
    function recordMovie(%movieName, %fps)
    {
       $timeAdvance = 1000 / %fps;
       $screenGrabThread = schedule($timeAdvance, 0, movieGrabScreen, %filename, 0);
    }
    
    function movieGrabScreen(%movieName, %frameNumber)
    {
       screenshot(%movieName @ formatImageNumber(%frameNumber) @ ".jpg", "JPG");
       $screenGrabThread = schedule($timeAdvance, 0, movieGrabScreen, %movieName, %frameNumber + 1);
    }
    
    function stopMovie()
    {
       $timeAdvance = 0;
       cancel($screenGrabThread);
    }
    
    //---------------------------------------------------------------------------------------------
    // doScreenShot
    // Capture a screenshot.
    //---------------------------------------------------------------------------------------------
    $screenshotNumber = 0;
    function doScreenShot(%val)
    {
       // Because this can be bound to a hotkey, we make sure that %val is 1 or not specified. That
       // way, the screenshot will be taken only on keydown, or when this function is called with
       // no parameters.
       if ((%val) || (%val $= ""))
       {
          if ($pref::Video::screenShotSession $= "")
             $pref::Video::screenShotSession = 0;
          
          if ($screenshotNumber == 0)
             $pref::Video::screenShotSession++;
          
          if ($pref::Video::screenShotSession > 999)
             $pref::Video::screenShotSession = 1;
          
          %name = expandFileName( "^game/data/screenshots/" @ formatSessionNumber($pref::Video::screenShotSession) @ "-" @
                   formatImageNumber($screenshotNumber) );
       
          $screenshotNumber++;
       
          if (($pref::Video::screenShotFormat $= "JPEG") ||
              ($pref::video::screenShotFormat $= "JPG"))
             screenShot(%name @ ".jpg", "JPEG");
           else
             screenShot(%name @ ".jpg", "JPEG");
       }
    }
    
    function toggleHud()
    {
       HudOverlay.visible = 1 - HudOverlay.visible;
    }
     
  3. Fixious

    Fixious Test Lead

    The jpeg/png options only affect the normal Screenshot function, which I actually got working. Change this:

    Code:
    %name = expandFileName( "^game/data/screenshots/" @ formatSessionNumber($pref::Video::screenShotSession) @ "-" @
      formatImageNumber($screenshotNumber) );
    
    To this:
    Code:
     %name = expandFileName( "legions/data/screenshots/" @ formatSessionNumber ($pref::Video::screenShotSession) @ "-" @ 
    formatImageNumber($screenshotNumber) );
    You'll have to create a screenshots folder within data, or just have them save to data if you want I guess. If you want these to be JPEG, go to your prefs.cs file and change $Pref::Video::ScreenShotFormat = "PNG"; to $Pref::Video::ScreenShotFormat = "JPEG";.

    edit: Okay, I've figured out how function setMegaShotSize(%val) works. setMegaShotSize(1) takes a megaScreenshot at your current in-game resolution. setMegaShotSize(2) takes a megaScreenshot at double your in-game resolution, and so on.
     
    Last edited: Apr 19, 2015
  4. The_Horny_Rat

    The_Horny_Rat New Member

  5. Fixious

    Fixious Test Lead

    A while ago I noticed a slightly odd error in the console. 'Connection failed' would appear about 7 seconds after entering a game. I also noticed that demo names no longer had the date they were recorded appended to them. Then I remembered how Pop implemented this, and figured the server the script pointed to was down. If this bugs anyone it's a fairly simple fix.

    Open time.cs in Legions\game\client\scripts\time.cs.
    Scroll down to lines 34-48, or to 'function TimeCheck().
    Change this:
    Code:
    function TimeCheck()
    {
       if($delayOver == 0)
       {
          echo("I was on timeout");
          return;
       }
      
       %obj = new TCPObject(netTime);
       %obj.connect("nist1-ny2.ustiming.org:13");
       $delayOver = 0;
       schedule(7000,0,"timeTimeout");
       return true;
          //%obj.send("TIME\r");
    }
    
    To this:
    Code:
    function TimeCheck()
    {
       if($delayOver == 0)
       {
          echo("I was on timeout");
          return;
       }
      
       %obj = new TCPObject(netTime);
       %obj.connect("nist.netservicesgroup.com:13");
       $delayOver = 0;
       schedule(7000,0,"timeTimeout");
       return true;
          //%obj.send("TIME\r");
    }
    Save the file, and delete time.cs.dso while you're at it. Start Leejunz, record a demo and it should be back to normal. Nothing major, but something I noticed and was able to 'fix' easily.

    [​IMG]
     
    Last edited: Apr 24, 2015
    k e v i n likes this.
  6. Fixious

    Fixious Test Lead

    Huh. Was wondering why I couldn't remove my HUD. This script was overriding the main HUD toggle. Remove this from screenshot.cs and all should be good:

    Code:
    function toggleHud()
    {
      HudOverlay.visible = 1 - HudOverlay.visible;
    }
     
  7. Fixious

    Fixious Test Lead

    I figured out how to get rid of the Core cooldown when turning off the HUD. It's always bothered me a little but I never really got around to figuring out how to fix it. Open up Legions\game\client\scripts\keybindings.cs, scroll down to the toggleHud() function and change this:

    Code:
    function toggleHud(%val)
    {
        if(!%val)
        {
            if(HudOverlay.Visible == 1)
            {
                HudOverlay.Visible = 0;
                gameUI.visible = 0;
                ObjectiveHudGui.visible = 0;
            }
            else
            {
                HudOverlay.Visible = 1;
                gameUI.visible = 1;
                ObjectiveHudGui.visible = 1;
            }
        }
    }
    To this:

    Code:
    function toggleHud(%val)
    {
        if(!%val)
        {
            if(HudOverlay.Visible == 1)
            {
                HudOverlay.Visible = 0;
                gameUI.visible = 0;
                ObjectiveHudGui.visible = 0;
                newCoreHud.setVisible(false);
            }
            else
            {
                HudOverlay.Visible = 1;
                gameUI.visible = 1;
                ObjectiveHudGui.visible = 1;
                newCoreHud.setVisible(true);
            }
        }
    }
    Now when you toggle the HUD, everything will actually disappear now.
     
  8. WildFire

    WildFire Warrior of Linux

    Not quite, the midhud elements still show up if you have them enabled. Not sure of the variable name the bar and the percentage has though. As they're a custom element and I have them always enabled I suspect they'll have to be set to 1/true in the first if block and then set to 0/false in the second to get it working correctly.
     
  9. Fixious

    Fixious Test Lead

    Did a quick test and it appears to work.

    Code:
    function toggleHud(%val)
    {
        if(!%val)
        {
            if(HudOverlay.Visible == 1)
            {
                HudOverlay.Visible = 0;
                gameUI.visible = 0;
                ObjectiveHudGui.visible = 0;
                newCoreHud.setVisible(false);
                MidHudGUI.setVisible(false);
            }
            else
            {
                HudOverlay.Visible = 1;
                gameUI.visible = 1;
                ObjectiveHudGui.visible = 1;
                newCoreHud.setVisible(true);
                MidHudGUI.setVisible(true);
            }
        }
    }
     
  10. 57thEnryu

    57thEnryu Member

    and this works in demo mode? Cool...if this game were still alive...
     
  11. WildFire

    WildFire Warrior of Linux

    Thanks fixi
     
  12. Fixious

    Fixious Test Lead

    I changed the code a bit for the sake of consistency. It doesn't change how it works at all so you don't have to replace it if you don't want to.

    Code:
    function toggleHud(%val)
    {
        if(!%val)
        {
            if(HudOverlay.Visible == 1)
            {
                HudOverlay.Visible = 0;
                gameUI.visible = 0;
                ObjectiveHudGui.visible = 0;
                newCoreHud.visible = 0;
                MidHudGUI.visible = 0;
            }
            else
            {
                HudOverlay.Visible = 1;
                gameUI.visible = 1;
                ObjectiveHudGui.visible = 1;
                newCoreHud.visible = 1;
                MidHudGUI.visible = 1;
            }
        }
    }
     
  13. Fixious

    Fixious Test Lead

    Tired of seeing the Item HUD at the top left? Legions\game\client\gui\scripts\gameUI.cs:

    Code:
            if($Pref::listOpen == 1)
               limitContainer.setVisible(true);  // CHANGE THIS TO FALSE
            EngyLimGui.setText(
                            "Turrets:" SPC $currentTurret @ "/" @ $maxTurret NL
                            "Utilities:" SPC $currentUtility @ "/" @ $maxUtilities NL
                            "Reactors:" SPC $currentReactor @ "/" @ $maxReactors NL
                            "Guardians:" SPC $currentGuardian @ "/" @ $maxGuardians NL
                            "Defensive:" SPC $currentDefensive @ "/" @ $maxDefensive NL
                            "Sensors:" SPC $currentSensors @ "/" @ $maxSensors);
        }
    I also figured out how to get Energy and Health to display during demos in this file, however as the comment already states this will cause a lot of console spam when not in a game or watching a demo. Needs some tweaks before posting.
     
  14. Fixious

    Fixious Test Lead

    Never really figured out how to get rid of the console spam, but if you're interested in seeing your health/energy/speed while watching a demo, open Legions/game/client/gui/scripts/gameUI.cs, and change the first function so it reads:

    Code:
    if($Client::IsConnected == 1 || ServerConnection.isDemoPlaying())
     
    Last edited: May 8, 2015
  15. Fixious

    Fixious Test Lead

    [​IMG]

    Figured out how to get rid of console spam and have health/energy during demo playback. Change the function above so it reads like this:

    Code:
    if($Client::IsConnected == 1 || $IsADemoPlayback == true)
     
    Piggeh and k e v i n like this.
  16. Fixious

    Fixious Test Lead

    Considering Overdrive is the only core that cares about your speed, it's sorta pointless to display 'Velocity Warning' for players using any other core. This fixes that.

    Code:
            if(%speed >= 88 && $CoreEquipped $= "OD")
               clientCmdCenterPrint("Velocity Warning", 2000, 1);
    Legions\game\client\gui\scripts\gameUI.cs, line 99.

    \o/

    Also, 'Velocity Warning' has never sounded good in my opinion. It should be something less threatening, like "Overdrive Online" or "Overdrive Available". Velocity Warning makes you think something bad is about to happen.
     
    k e v i n and loc like this.
  17. Fixious

    Fixious Test Lead

    Not sure how many people use demo bookmarks, but this will create one as soon as a game starts. No more fast-forwarding through a PUG demo and trying to guess when it starts / going past it. Legions\game\client\scripts\message.cs, line 78.

    Code:
    function handleMsgGameStart( %msgType )
    {
       sfxPlayOnce(CtfGameStartEnd);
       insertBookmark();
       clientCmdBottomPrint("Demo Bookmark Saved.", 2500, 1);  //optional.  Simply pops up a message stating a bookmark was made.
    }
     
    Poponfu and WildFire like this.
  18. Fixious

    Fixious Test Lead

    For whatever reason it isn't possible to throw boost grenades in regular Rabbit unless it's in Overtime. Turns out the canThrow function was simply empty (perhaps for a reason?). Anyways, this fixes that. Line 436 of server/game/gametypes/rabbit.cs:

    Code:
    function RabbitGame::canThrow( %this, %player, %data )
    {
      if (%player.inventory["Flag"] == 1)
      {
      return false;
      }
      else
      {
      return true;
      }
    }
    
    };
    
     
    Last edited: Jul 1, 2015
  19. Fixious

    Fixious Test Lead

    Koffee asked for a script that automatically switches to first person if you're using the Laser Rifle. If not, it'll go back to third person. Save this as TPS.cs and place it in your mods/autoexec folder. If you don't have an autoexec folder, simply make one.

    Code:
    // 3rd Person Sniper by Fixious, inspired by 3rd Person OverDrive by RockeyRex
    
    
    package TPS
    {
        function clientCmdSetActiveWeapon(%this)
        {
            // We don't wish to interrupt the original function so we just let it go.
            parent::clientCmdSetActiveWeapon(%this);
         
            //Checks if the current weapon you have selected is the Laser Rifle.  Legions simply calls it Rifle.  If it is, we switch to first person.
            if($ActiveWeapon $= "Rifle" )
            {
    
                ServerConnection.setFirstPerson(1);
            }
            //If it's any weapon other than the Rifle, we go back to third person view.
            else if ($ActiveWeapon !$= "Rifle"){
                ServerConnection.setFirstPerson(0);
            }
        }
     
    };
    activatepackage(TPS);
    Alternatively, you could modify this code a bit and have your sensitivity lowered/raised depending on which weapon you have selected.
     
    Last edited: Jul 18, 2015
    Doomsify likes this.
  20. Doomsify

    Doomsify Member

    Works!
     
    Fixious likes this.