LynxOfTheSky Posted February 4, 2022 Posted February 4, 2022 (edited) Hi, i am trying to do a dynamic in-mission limiter, of what can you use, for players to unlock certain features (like targeting pods) later, by completing tasks. Besides from just locking, some of them should also be limited, but in general, not linked to a certain airfield (for ex. you capture the base, you gain 3 targeting pods, but you can equip them on amy base for sake of slightly more arcade gameplay). I've tried solving the task, but failed: - getAmmo function returns only ammo, so you can't check things like targeting pods and fuel tanks - weapon_add event is invoked only on spawn (both in air on on ground), so if you spawn empty plane, and then player rearms and takes off, nothing is invoked - get_payload function from MIST returns loadout from mission file, it can't check "live" loadout, as stated in manual So, my question is: is there any way to do it? Addition: There is a possible workaround, based on unit weight, but I can't find a function, that can tell me current unit's weight. Anyone know such a function? Edited February 4, 2022 by LynxOfTheSky
PravusJSB Posted February 7, 2022 Posted February 7, 2022 (edited) The getAmmo method called on the unit should return an array of tables (for each pylon and guns), does it not work on players? Here's and example of how i use it.. local function has_air2air(group_name,detail) local GRP = Grp.get(group_name) local UNITS = GRP:units() local details = {} for i = 1,#UNITS do local ammo = UNITS[i]:getAmmo() for pylon = 1,#ammo do if ammo[pylon].count > 0 and ammo[pylon].desc.category == 1 and ammo[pylon].missileCategory == 1 then if not detail then return true elseif detail then if ammo[pylon].desc.displayName then if not details[ammo[pylon].desc.displayName] then details[ammo[pylon].desc.displayName] = ammo[pylon].count else details[ammo[pylon].desc.displayName] = details[ammo[pylon].desc.displayName] + ammo[pylon].count end end end end end end if detail then return details else return false end end Edited February 7, 2022 by PravusJSB Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
Grimes Posted February 7, 2022 Posted February 7, 2022 Unfortunately there is no function that returns live pylon information. A feature request for such a function has been around for a while now. . getAmmo() returns a list of weapons indexed numerically. It has nothing to do with what pylon has it. Not actually sure if there is any logic to the order. 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
LynxOfTheSky Posted February 8, 2022 Author Posted February 8, 2022 Yeah, it only return weapons, not containers, fuel tanks, racks. As ai mentioned in redacted head, i had an idea to get that information based on weight of the unit, but I failed to find any kind of getCurrentWeight function. Which is actually strange, cause ED provided us with emptyWeight, maxWeight and maxFuel.
Recommended Posts