cfrag Posted September 26, 2022 Posted September 26, 2022 This one has left me scratching my head, and I would appreciate any insight. I'm trying to discern a weapon's capabilities when it's being fired (i.e. inside :OnEvent with an ID == S_EVENT_SHOT) I have the weapon, and now would like to mask the various flag bits to find out if the weapon that was fired is a "Marker Weapon" as outlined here. But silly me can't find a way to access that flag information. Can some kind soul tell me what I am overlooking, i.e. given an arbitrary weapon, how can I find out if that weapon is a "Marker Weapon" (or failing that, get at the flag value that uses bits to encode that information)? Thank you so much, -ch
dark_wood Posted September 26, 2022 Posted September 26, 2022 Not sure I have understood your request, but I found this: https://www.digitalcombatsimulator.com/en/support/faq/1261/ At the bottom of the page you will find: Weapon.Desc "weapon descriptor. This is common part of descriptor for any weapon. Some fields are actual only for HE and AP+HE warheads, some fields are actual only for shaped explosive warheads. Descriptor format depended on weapon category." And some basic example at the end.. Hope it helps - ignore if useless
Grimes Posted September 26, 2022 Posted September 26, 2022 (edited) Or give em the actually useful page https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag Its a weird combo of the enum values are doubled and the combo values are effectively the original values added together. Outside that is just the categories that describe a given weapon. They aren't always the most complete definition. Quite a few show up as "other" under missile category. Most of the time it is good enough to get an idea, but you should probably have to make bespoke definitions for certain weapons that dont normally fit that criteria. Edited September 26, 2022 by Grimes The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
cfrag Posted September 26, 2022 Author Posted September 26, 2022 Thank you, @dark_wood and @Grimes - The problem I can't wrap my head around is how to get the flag value in the first place. Weapon.flag and Weapon.Desc are class enums. Given that I get a weapon instance from the onEvent callback in event.weapon, how do I access that information? It seems I'm overlooking something glaringly obvious. I initially thought that the flags are encoded in a weapon's type. But there is no such field when I query event.weapon:getDesc(). I'm trying to get at the weapon instance's flags. All I've come up with is nothing.
cfrag Posted September 26, 2022 Author Posted September 26, 2022 (edited) apologies, @Grimes and @dark_wood, let me try to be more precise: function williePete:onEvent(event) local theUnit = event.initiator if event.id == 1 then -- S_EVENT_SHOT -- initiator is who fired. maybe want to test if player trigger.action.outText(theUnit:getName() .. " " .. pType .. " fired " .. event.weapon:getTypeName() .. ".", 30) -- find out if this is a marker weapon -- need to access weapon's flags -- getDesc() does not reveal that information -- event.weapon.flags does not exist I want to find out if the weapon is a "marker weapon" end end Edited September 26, 2022 by cfrag
toutenglisse Posted September 26, 2022 Posted September 26, 2022 As it returns a unic number relative to weapon type I think it is (for example - I think it is gbu12) : ...and event.weapon:getName() == 16793344 then... But I find more convenient to compare event with table like : smokeWeapons = {"HYDRA_70_M274","HYDRA_70_MK61","HYDRA_70_MK1","HYDRA_70_WTU1B","BDU_45B","BDU_33","BDU_45","BDU_45LGB","BDU_50HD","BDU_50LD","BDU_50LGB","C_8CM"} if event.weapon:getTypeName() == smokeWeapons[i] then...
cfrag Posted September 26, 2022 Author Posted September 26, 2022 1 hour ago, toutenglisse said: I find more convenient to compare event with table like : Thank you @toutenglisse, that was my first thought, but I thought it a bit error prone (how would I get all smokeWeapons, and I'd have to maintain it whenever a new one arrives). It will probably be my method as well. 1 hour ago, toutenglisse said: it returns a unic number relative to weapon type I think it is Ha! Do I understand you correctly that the *Name* of the weapon has it's type encoded in the lower bits? I'll bust out my calculater to look at that, thank you so much for the hint! -ch
toutenglisse Posted September 26, 2022 Posted September 26, 2022 17 minutes ago, cfrag said: ...Ha! Do I understand you correctly that the *Name* of the weapon has it's type encoded in the lower bits? I'll bust out my calculater to look at that, thank you so much for the hint!... I didn't go farther than testing for some weapons to get the number (flag ?) and check weapon type on hit by comparing with this number. Weapons seem much less accessible than any other datas, I used this reference store list (not up to date), choosed smoke and training (and not white phosphore) to make weapon table of TypeNames. Laborious but less obscure to me than the flags... DCS Reference: Stores List - Airgoons
dark_wood Posted September 26, 2022 Posted September 26, 2022 5 hours ago, Grimes said: Or give em the actually useful page https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag Well, that link was already in the OP
cfrag Posted September 26, 2022 Author Posted September 26, 2022 (edited) 3 hours ago, toutenglisse said: I didn't go farther than testing for some weapons to get the number (flag ?) and check weapon type on hit by comparing with this number. So I did some testing, and could not make head nor tails out of that. It looks as if some version of the weapon type (flags) is encoded in the 16 most significant bits, and a counter in the 16 least significant bits of the weapon name (to arrive at a unique number) but there is some bit shifting going on that I can't fathom. Simply bitANDing the weapon's name with, e.g. 13312 (MarkerWeapon) yields 0, as does doing that with only the 16 MSBits. So, I'll go to your kindly suggested fallback solution that looks through an array of weapon names. Thank you again, -ch Edited September 26, 2022 by cfrag
dark_wood Posted September 26, 2022 Posted September 26, 2022 @cfrag MOOSE library have something similar, just search for "WeaponFlag" inside Moose.lua ENUMS.WeaponFlag={ -- Bombs LGB = 2, TvGB = 4, SNSGB = 8, HEBomb = 16, Penetrator = 32, NapalmBomb = 64, ...... AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb) ...... -- Even More Genral Auto = 3221225470, -- Any Weapon (AnyBomb + AnyRocket + AnyMissile + Cannons) AutoDCS = 1073741822, -- Something if often see AnyAG = 2956984318, -- Any Air-To-Ground Weapon AnyAA = 264241152, -- Any Air-To-Air Weapon AnyUnguided = 2952822768, -- Any Unguided Weapon AnyGuided = 268402702, -- Any Guided Weapon } then is called weaponType = WeaponType or ENUMS.WeaponFlag.AnyBomb,
Recommended Posts