cfrag Posted May 26, 2023 Posted May 26, 2023 Version 1.0.0 - 20230526 The stopGap script allows us to fill an empty airfield with static representations for your player planes. That way your airfields look so much better when you design a mission with many player slots. For multiplayer missions, this allows for new interesting strategic options: what if a player slot stand-in is destroyed, and that slot then becomes blocked? This would allow players to selectively attack planes on the ground on the other faction's airfield Hate the enemy's Blacksharks? Take them out before they can take off! Love your air superiority? Defend your airspace against similar enemy activity. See that bomb truck coming in? Intercept now or lose your Eagles! sittingDucks is the script that answers that question. It's tiny, requires SSB on the server, and works as an add-on to stopGap. And it's multiplayer only. HOW TO USE - copy the script below into a DOSCRIP action at MISSION START. Make sure to do that after the stopGap script REQUIREMENTS multiplayer only (i.e. for single-player you must run your mission as multiplayer) requires SSB be installed on the server (and only server) requires that SSB is configured as follows: SSB.kickReset = false Script: please see below Spoiler sittingDucks = {} sittingDucks.verbose = false sittingDucks.version = "1.0.0" sittingDucks.ssbDisabled = 100 -- must match the setting of SSB, usually 100 sittingDucks.resupplyTime = -1 -- seconds until "reinforcements" reopen the slot, set to -1 to turn off, 3600 is one hour -- -- Destroying a client stand-in on an airfield will block that -- Slot for players. Multiplayer only -- WARNING: ENTIRE GROUP will be blocked when one aircraft is destroyed -- -- MULTIPLAYER-ONLY. REQUIRES (on the server): -- 1) SSB running on the server AND -- 2) set SSB.kickReset = false -- function sittingDucks:onEvent(event) if not event then return end if not event.id then return end if not event.initiator then return end -- home in on the kill event if event.id == 8 then -- dead event local theUnit = event.initiator local deadName = theUnit:getName() if not deadName then return end -- look at stopGap's collection of stand-ins for gName, staticGroup in pairs (stopGap.standInGroups) do for uName, aStatic in pairs(staticGroup) do if uName == deadName then -- yup, a stand-in. block entire group local blockState = sittingDucks.ssbDisabled trigger.action.setUserFlag(gName, blockState) -- tell cfxSSBClient as well - if it's loaded if cfxSSBClient and cfxSSBClient.slotState then cfxSSBClient.slotState[gName] = blockState end if sittingDucks.verbose then trigger.action.outText("SittingDuck: in group <" .. gName .. "> unit <" .. uName .. "> was destroyed on the ground, group blocked.", 30) end if sittingDucks.resupplyTime > 0 then timer.scheduleFunction(sittingDucks.resupply, gName, timer.getTime() + sittingDucks.resupplyTime) end return end end end end end -- re-supply: enable slots after some time function sittingDucks.resupply(args) local gName = args trigger.action.setUserFlag(gName, 0) if cfxSSBClient and cfxSSBClient.slotState then cfxSSBClient.slotState[gName] = 0 end if stopGap.standInGroups[gName] then -- should not happen, just in case stopGap.removeStaticGapGroupNamed(gName) end if sittingDucks.verbose then trigger.action.outText("SittingDuck: group <" .. gName .. "> re-supplied, slots reopened.", 30) end end -- make sure stopGap is available if stopGap and stopGap.start then trigger.action.setUserFlag("SSB",100) world.addEventHandler(sittingDucks) trigger.action.outText("Sitting Ducks v" .. sittingDucks.version .. " running, SSB enabled", 30) else trigger.action.outText("Sitting Ducks requires stopGap to run", 30) end Demo Please see below Acknowledgements My thanks to @Panthir for submitting this request Note A slightly more capable version of sittingDucks is part of DML Cheers, -ch sitting ducks in a barrel.miz 2
Recommended Posts