Weapon and weapon ammo GUI display rendering issue

KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
Hi,

I have successfully created new weapons for my mod, however I am stuck with an issue for a great amount of hours and can't figure out what this could be (as there isn't any errors at all, seem silently ignored).

In short, on the picture attached, the first one shows the ammo GUI not displayed, the second one how the weapon looks like (wrong) and the third one how it should really be.

I have been doing research on MyWeapon.kModelName, check twice TechData.lua, check MyWeapon:OnUpdateRender() (client side), read every NS2 weapons files, Check GetUIDisplaySettings(), etc. Now I am just running out of ideas.

So if someone has already solved this issue before feel free :)

Thank you

Comments

  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited April 2015
    You have to create a GUI script for your weapon ammo display, I suggest that you make one that matches an existing one because they suck to make. If you post your source files here I can take a look at it
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    The main .lua file I am using is in attachment, in fact I do not need to do a new GUI script (as the one used with the shotgun is exactly what I need, but can't figure out how to make it working).
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    * Edit: with the file its better (.lua looks like a wrong extension for the forum)
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited April 2015
    That is not the file I am talking about. Look at GUIShotgunDisplay.lua. You need to make sure you have that mesh set to a texture in the max file, to the file that the shotgun uses in the ui folder.
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    Hum, I am not really used to work with those. I see ui/ShotgunDisplay.dds, some fonts and call to "SetPosition(Vector(0,0,0))" but I am a bit lost around here. Can you tell me where to find those or if I need to make some test on a NS2 files ?
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    You need to set the ammo counter mesh in 3ds max to ui/Shotgundisplay.dds
    You then need to create a GUIHeavyShotgunDisplay.lua based on GUIShotgundisplay.lua
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    I feel confident for the second part as it is mostly lua code, but for the first one did you mean editing ui/Shotgundisplay.dds with 3dsmax and update values ?
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited April 2015
    Oh my fault, I thought you had made a new model, that simplifies things a bit.
    Press ` to open the console and tell me what errors there are.
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    edited April 2015
    I do not have any errors in my console, that the problem :). I am using the FadedHeavyShotgun.lua and its almost the only extra file (whitout TechData.lua, TechTreeConstant.lua and Shared.lua). If it can help I have the same issue with the other weapons I have done (flame mine without the clip displayed)
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    edited April 2015
    Below a screenshot of the game with the gun in hand and the console so far. The "GUI Created Loaded" is only debug placed on the HeavyShotgun.lua (the code concerning the GUI is mostly copy & past in order to place debug)
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited April 2015
    I would make your lua file not reference Shotgun.lua at all, but instead just copy the entire Shotgun.lua and change it to how you want, but name it FadedHeavyShotgun.lua
    It's definitely a lua problem. It should be a copy of Shotgun.lua except for the changes that you made and the classname

    You also don't need any of this
    function FadedWeaponOnUpdateRender(self)
    
          local parent = self:GetParent()
          local settings = self:GetUIDisplaySettings()
          if parent and parent:GetIsLocalPlayer() and settings then
    
    	 local ammoDisplayUI = self.ammoDisplayUI
    	 if not ammoDisplayUI then
    
    	    ammoDisplayUI = Client.CreateGUIView(settings.xSize, settings.ySize)
    	    ammoDisplayUI:Load(settings.script)
    	    ammoDisplayUI:SetTargetTexture("*ammo_display" .. (settings.textureNameOverride or self:GetMapName()))
                self.ammoDisplayUI = ammoDisplayUI
    	    Print("GUI Created loaded")
    	 end
    
    	 ammoDisplayUI:SetGlobal("weaponClip", parent:GetWeaponClip())
    	 ammoDisplayUI:SetGlobal("weaponAmmo", parent:GetWeaponAmmo())
    	 ammoDisplayUI:SetGlobal("weaponAuxClip", parent:GetAuxWeaponClip())
    	 if settings.variant then
    	    ammoDisplayUI:SetGlobal("weaponVariant", settings.variant)
    	 end
    	 self.ammoDisplayUI:SetGlobal("globalTime", Shared.GetTime())
    	 -- For some reason I couldn't pass a bool here so... this is for modding anyways!
    	 -- If you pass anything that's not "true" it will disable the low ammo warning
    	 self.ammoDisplayUI:SetGlobal("lowAmmoWarning", "true")
    
          elseif self.ammoDisplayUI then
    
          	 Client.DestroyGUIView(self.ammoDisplayUI)
          	 self.ammoDisplayUI = nil
    
          end
    
       end
    
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    edited April 2015
    Thank you :). I will give it a try tomorrow and edit this post as soon as it is changed.

    Edit: bad news, this do not seem to solve the problem (ammo display & third person view). The FadedHeavyShotgun.lua do not reference any "Shotgun" function (only a few globals) and I made a whole copy of GUIShotgunDisplay.lua. I can past you those files if needed but there are not much than the previous one except renaming and copy-pasting of missing function. I think the issue might be somewhere else.
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    Posting those here would be helpful
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    edited April 2015
    Here:

    Edit: I copy & past the NS2 Shotgun.lua and only replace Shotgun by HeavyShotgun and it works somehow... I will make test further until I reach the old weapon I tell you.
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    False victory, forgot to change the kMapName of the HeavyShotgun. I give you 2 files. The FadedHeavyShotgun.lua and the diff with the real one. I have tested both GUIShotgunDisplay.lua and GUIHeavyShotgunDisplay.lua (for the render) but both are doing the same in the FadedHeavyShotgun.lua. Still got those display errors.

    Except the clip size changed from 6 to 2 (in order to be sure we have the new weapon in hand) it has now the least amount of change possible after a full copy in order to make it works.
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    Actually you don't need to make a new gui script, just have it use the shotgun one.
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    Hi,

    Little news: I managed to fix the ammo display on the weapon but the third person view is still wrong.
    If anyone is stuck with this, the solution is pretty simple. (using "class 'HeavyShotgun' (Shotgun)" seems ok so far)
    function    HeavyShotgun:GetUIDisplaySettings()
        return {xSize = ..., ySize = ..., script = ..., textureNameOverride = "shotgun"} // <-- Set textureNameOverride 
    end
    

    On the lua/Weapons/Weapon.lua there is a function "Weapon:OnUpdateRender" on
    which there is a line:
    ammoDisplayUi:SetTargetTexture("*ammo_display" .. (settings.textureNameOverride or self:GetMapName()))
    
    The ammo_display for my custom does not exist as I do not create any, but there was one for the shotgun. The HeavyRifle.lua from NS2 does the same in order to keep the ammo display GUI.

    Searching now for the third view issue.
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited April 2015
    Here you go, https://dropbox.com/s/77tto6p566t7asw/shotgundisplay.zip?dl=0
    Just place those in the models/marine/shotgun folder of your mod
    EyL4eqM.png

    The world model never had an ammo display, I'll add it in vanilla sometime when I can, with a proper ammo display as well with numbers
  • KatzenfleischKatzenfleisch Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
    edited April 2015
    Thanks for those, but there are hardcoded path on shotgun.model and I can not use them directly. (D:/NS2Perforce/...)(no third view display if I try)

    I tried to change them but the result was not was I was expecting (seems not enough or I might changed it the wrong). If I correctly understand this will provide a better way to fix the ammo display than using the "textureNameOverride" ?
    fpx8x4qm40la.png
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    No, that's there for that reason. I only added the texture of a fake ammo display for the third person model. I'll fix that path issue, I forgot to change the path after exporting
Sign In or Register to comment.