STEAM GROUP
SW Addons SW Addons
STEAM GROUP
SW Addons SW Addons
13
IN-GAME
66
ONLINE
Founded
6 August, 2024
Language
English
Showing 1-7 of 7 entries
2
1
Integration of SW VR friendly weapons (Melee) with VRMod x64 - Extended
As some might be aware I am working on the fork of VRMod , in order to optimize it for Gmod x64 and in general make it playable at least to the level of Half-Life 2 VR.

One of the existing problems is lack of unified melee system. I saw some efforts in ArcVR, but it was only within the addon. I saw efforts from the author of semi-official branch, even helped by adding velocity based damage. However I did not like the implementation. It was conflicting with hand physics (for prop interaction) as both addons were spamming props, which were essentially hitting each other. Plus holding a swep did not have any effect, same cube inside arm that does a bullet damage on collision.

I saw that you disabled melee weapons in your Lambda SWEPs, but perhaps you want to try the melee system [github.com] that I am currently working at?

It's a trace based system that works with hands and any sort of weapon, melee or non melee.
If for the first time equipped by anyone on the server, it will calculate radius by using the longest side of the currently held weapon and cache it to avoid this relatively expensive operation in the future. It might not be the most accurate method, however you don't need to worry about position and angle offsets for each and every model. One of the advantages is that we can have a custom filter. Since my hand physics uses serverside ents.Create("base_anim") instead of prop, they won't collide.

At this point you don't need do much, just test them our sweps and see if it's acceptable behavior.
If you will be satisfied by the results, we might think about further integration, such as including TryMelee() in the API.

For example the hit sound is currently based on the type(for now just "fist" or "blunt") that has a set of random sounds specifically for each one and a damage multiplier in case we use a weapon. Hypothetically I can add ability to customize these sounds, damage multiplier and maybe visual effects.

Cheers
9
[DEV] VRMod won't work without Initial release of SW Addons combined with older version of hl2weaponreplacements on Gmod x64 Native Linux
Originally posted by Grocel:
SW_Addons.AutoLoadAddon() is used for the base to detect the lua file and loads it to give it a SW_ADDON instance. It has to be at the top or the stript will break. The code we have done is accually quite untypical for gmod standards.

I think your way of debugging it is quite the right path on getting down to the issue. I think something with EF_BONEMERGE or the "models/sligwolf/unique_props/nodraw" material is causing the side effect.

Alright, I managed to shrink the code even further and convert most of the functions to locals so they would not require SW_ADDONS. All apart from Think()

if !SW_ADDON then SW_Addons.AutoLoadAddon(function() end) return end local Author = "SligWolf" local NiceName = "VRMod Linux Dirty Fix" SW_ADDON.Author = Author SW_ADDON.NiceName = NiceName SW_ADDON.Version = "2024-09-07" SW_ADDON.hooks = { PostCleanupMap = "PostCleanupMap", } local Classes = { weapon_physcannon = true, weapon_physgun = true, } local function HideAllOriginalWorldmodels(ply, hide) --print("HideAllOriginalWorldmodels") if !IsValid(ply) then return end hide = tobool(hide) or false for class, bool in pairs(Classes) do if !bool then continue end local Wep = ply:GetWeapon(class) if !IsValid(Wep) then continue end if hide then Wep:SetMaterial("models/sligwolf/unique_props/nodraw") end end end local function UpdateWeapon(ply) --print("UpdateWeapon") if !IsValid(ply) then return end local VR_State = vrmod.IsPlayerInVR(ply) if SERVER then HideAllOriginalWorldmodels(ply, VR_State) end end local function PollWeaponChange(ply) --print("PollWeaponChange") if !IsValid(ply) then return end local Wep = ply:GetActiveWeapon() UpdateWeapon(ply) end function SW_ADDON:Think() --print("think") for k, ply in ipairs(player.GetHumans()) do if !IsValid(ply) then continue end PollWeaponChange(ply) end end

If I relocate the code to VRMod as a separate file and call it from vrmod.lua with include function the Think() will not start. I've tried converting it to local and just calling it, but I need to find a way to terminate it on demand as it prevents vrmod from exiting.
I don't know where to post it, but this is driving me nuts for a several months already and I still haven't figured it out...

I am working on a VRmod version for Linux user(s) GitHub [github.com]

For some mysterious reason it simply won't work without older version of SW Addons combined with HL2 Weapons pack on any other map apart from gm_flatgrass. Hl2 pack Link

Without SW addons In HMD the image would look like somebody punched the screen and the steamvr performance graph will be purple. With sw addons combined with older hl2 weapons pack the VR would work very well, but you won't be able to exit vr mod and start again without reloading the game. Unless you reload to gm_construct. The same pixelated mess.
YouTube

It looks like texture buffer was not cleared properly, so I attempted to work withthe vrmod c++ backend. I updated openvr, implemented texture verification and filtering with a proper flush of textures for openGL. GitHub [github.com] However it did not fix the problem.

I am C++ kind of guy and know very little about gmod lua and all the tricks and workarounds, so I might be missing something.

I've consulted with Grocel and have been pointed at possible functions that might have been related to non-intentional fix , however it seems that it's not that simple. I had no other choice but to use deduction to came up with bare minimum code to fix the problem.

So far I have initial version of SW Addons from github and stripped older version of hl2weaponreplacements. It only has autorun file and init. No textures or materials.
However I also needed
if !SW_ADDON then SW_Addons.AutoLoadAddon(function() end) return end

from sound.lua to avoid importing the whole file.

Here is what's left in init.lua, if I remove anything else it would no longer work.

local Author = "SligWolf" local NiceName = "VRMod Linux Dirty Fix" SW_ADDON.Author = Author SW_ADDON.NiceName = NiceName SW_ADDON.Version = "2024-09-07" SW_ADDON.hooks = { PostCleanupMap = "PostCleanupMap", } local Classes = { weapon_physcannon = true, weapon_physgun = true, } local function HideAllOriginalWorldmodels(ply, hide) if !IsValid(ply) then return end hide = tobool(hide) or false for class, bool in pairs(Classes) do if !bool then continue end local Wep = ply:GetWeapon(class) if !IsValid(Wep) then continue end if hide then local oldMat = Wep:GetMaterial() or "" if oldMat == "models/sligwolf/unique_props/nodraw" then oldMat = "" end Wep:SetMaterial("models/sligwolf/unique_props/nodraw") Wep.__sw_oldMateria = oldMat else local oldMat = Wep.__sw_oldMaterial or "" if oldMat == "models/sligwolf/unique_props/nodraw" then oldMat = "" end Wep:SetMaterial(oldMat) Wep.__sw_oldMateria = nil end end end function SW_ADDON:GetVRWorldmodel(ply, createIfNotExists) if !IsValid(ply) then return end if IsValid(ply.__SW_VRWorldmodel) then return ply.__SW_VRWorldmodel end if !createIfNotExists then return end local Ent = self:MakeEnt("prop_physics", ply, ply) Ent:SetModel("models/weapons/c_pistol.mdl") Ent:SetSolid(SOLID_NONE) self:SetupChildEntity(Ent, ply, COLLISION_GROUP_IN_VEHICLE) Ent:SetParent(ply, ply:LookupAttachment("anim_attachment_RH")) Ent:SetNoDraw(true) Ent:DrawShadow(false) Ent:AddEffects(EF_BONEMERGE) Ent.__SW_Blockedprop = true ply.__SW_VRWorldmodel = Ent return Ent end function SW_ADDON:UpdateWeapon(ply, wep) if !IsValid(ply) then return end if !IsValid(wep) then return end local VR_State = self:VRIsPlayerInVR(ply) if SERVER then self:GetVRWorldmodel(ply, VR_State) HideAllOriginalWorldmodels(ply, VR_State) end if CLIENT then SetWorldModelBoneOffsetForWeapon(wep, !VR_State) end if VR_State then SetViewModelBodyGroupForWeapon(ply, wep) if SERVER then UpdateVRWorldmodel(ply, wep) end if CLIENT then SetViewModelOffsetForWeapon(wep) end end end function SW_ADDON:Think() for k, ply in ipairs(player.GetHumans()) do if !IsValid(ply) then continue end self:PollWeaponChange(ply) end end function SW_ADDON:SwitchWeapon(ply, oldwep, newwep) if !IsValid(newwep) then return end self:UpdateWeapon(ply, newwep) end function SW_ADDON:PollWeaponChange(ply) if !IsValid(ply) then return end local Wep = ply:GetActiveWeapon() local LastWep = ply.__SW_LastWep if Wep != LastWep then -- Ensure the weapon switch is detected on EVERY client without additional networking self:SwitchWeapon(ply, LastWep, Wep) ply.__SW_LastWep = Wep end end function SW_ADDON:OnVRStateChange(ply, state) if !IsValid(ply) then return end self:UpdatePlayerVRState(ply, state) end function SW_ADDON:PostCleanupMap() if CLIENT then return end for k, ply in ipairs(player.GetHumans()) do if !IsValid(ply) then continue end self:UpdateWeapon(ply, ply:GetActiveWeapon()) end end if !SW_ADDON then SW_Addons.AutoLoadAddon(function() end) return end

I really want to get to the bottom of this, since it's not ok to just copy paste your code while using sw-base as a dependency and call it a fix. I apologize for posting this on bug report section , however I and maybe 2.5 Linux users would appreciate any help.
Showing 1-7 of 7 entries