• Reliable way of getting hitgroup from hitbox
    3 replies, posted
Is there any reliable way of getting the hitbox/bone hitgroup? My current trace-based hitgroup detection has a huge flaw of not working on some models, namely fast zombie and poison zombie. https://i.imgur.com/T5aObxw.jpg hook.Remove("CreateMove", "test") hook.Add("CreateMove", "test", function(cmd)     for k, v in pairs( ents.GetAll() ) do         local numHitBoxGroups = v:GetHitBoxGroupCount()         if (numHitBoxGroups) then             for group=0, numHitBoxGroups - 1 do                 local numHitBoxes = v:GetHitBoxCount( group )                 for hitbox=0, numHitBoxes - 1 do                     local bone = v:GetHitBoxBone( hitbox, group )                     local bonepos, boneang = v:GetBonePosition(bone)                     local tr = util.TraceLine({                         start = bonepos + Vector(0,0,0.1),                         endpos = bonepos - Vector(0,0,0.1),                         mask = MASK_SHOT                     })                     if (tr.Hit) then                         debugoverlay.Text( bonepos, tostring(tr.HitGroup), 0, false )                     end                 end             end         end     end end) One more intresting thing, is that print(LocalPlayer():GetEyeTrace().HitGroup) outputs the correct hitgroup: https://i.imgur.com/bGaqW19.png
Bump, anybody know a clean way for this?
Did it the major autism way: parsing .mdl local cache = {} local function Parse(filename)     if (cache[filename]) then         return cache[filename]     end     cache[filename] = {Hitboxes = {}}     local fl = file.Open(filename, "rb", "GAME")     if not fl then print("[LuaMDL] Unable to open: "..filename) return end     print("[LuaMDL] Parsing: "..filename)     local ident = fl:Read(4)     if ident ~= "IDST" then print("[LuaMDL] Invalid file header: "..ident) return end     local rtn = {}     rtn.version = fl:ReadLong()     rtn.checksum = fl:ReadLong()     fl:Read(64) //name     rtn.dataLength = fl:ReadLong()     fl:Read(12) //eyeposition     fl:Read(12) //illumposition     fl:Read(12) //hull_min     fl:Read(12) //hull_max     fl:Read(12) //view_bbmin     fl:Read(12) //view_bbmax     rtn.flags = fl:ReadLong()     //mstudiobone_t     rtn.bone_count = fl:ReadLong()     rtn.bone_offset = fl:ReadLong()     //mstudiobonecontroller_t     rtn.bonecontroller_count = fl:ReadLong()     rtn.bonecontroller_offset = fl:ReadLong()     //mstudiobonecontroller_t     rtn.hitbox_count = fl:ReadLong()     rtn.hitbox_offset = fl:ReadLong()     fl:Seek(rtn.hitbox_offset)         rtn.sznameindex = fl:ReadLong()         rtn.numhitboxes = fl:ReadLong()         rtn.hitboxindex = fl:ReadLong()     fl:Seek(rtn.hitbox_offset + rtn.hitboxindex)         rtn.Hitboxes = {}         for z = 1, rtn.numhitboxes do             local tmp = {}             tmp.bone = fl:ReadLong()             tmp.group = fl:ReadLong()             tmp.bbmin = Vector(fl:ReadFloat(),fl:ReadFloat(),fl:ReadFloat())             tmp.bbmax = Vector(fl:ReadFloat(),fl:ReadFloat(),fl:ReadFloat())             tmp.szhitboxnameindex = fl:ReadLong()             fl:Read(32) // unused             rtn.Hitboxes[tmp.bone] = tmp         end     fl:Close()     cache[filename] = rtn;     return rtn end
Check util.GetModelInfo's return.
Sorry, you need to Log In to post a reply to this thread.