Jump to content

Is it possible to use scripting to set up something that would replicate a "rounds in zone" trigger condition?


Recommended Posts

Posted

What I want to do is give the player the ability to use their cannon to suppress a sniper who is "hiding" inside of a building without having to place an actual infantry guy there on the ground and have him die to trigger the condition. 

So player flies in, shoots up the selected building (map object, whatever) and that triggers a radio message saying "good job" or whatever you want it to trigger. 

Is this possible? 

Posted
On 7/20/2023 at 1:31 AM, Tree_Beard said:

What I want to do is give the player the ability to use their cannon to suppress a sniper who is "hiding" inside of a building without having to place an actual infantry guy there on the ground and have him die to trigger the condition. 

So player flies in, shoots up the selected building (map object, whatever) and that triggers a radio message saying "good job" or whatever you want it to trigger. 

I have tried this with mixed results. 'Rounds in zone' is currently not easily done without heavy scripting, and will not for most airframes (the script needs access to your aircraft's targeting system's LOS, something that I know I can get from the Gazelle, but not many others).

I've tried a more roundabout way: you place a structure on the ground, and when the health of that structure is below 50% or it is destroyed, you get the message. The problem is this: many structures appear to be impervious to most smaller weapons, they do not receive damage. The attached demo shows the idea. I've use the red 'café' as object to detect the damage, but neither my Shark's cannon, Vikhr, nor rockets could damage the café, so you may want to look for a more brittle object/structure that can be destroyed or that register damage.

Suppress Sniper Test.miz

Posted

Tracking shells is doable, but somewhat annoying. Here is a very quick I threw together. Its not at all optimized and has some flaws with logic. For instance it only starts the check once an aircraft stops shooting and it can schedule it to check if there are multiple stop shooting events. Also it isn't checking the existing table for if it is already tracking a given weapon. Again just something super basic that was cobbled together from a few other scripts sitting around. To see it in action check that imgur link. 

https://i.imgur.com/JMctEkt.mp4

 

local mId = 0
local volS = {
	id = world.VolumeType.SPHERE,
	params = {
		radius = 5000
	},
}
local weps = {}
local ifFound = function(foundItem, val)
	table.insert(weps, {obj = foundItem})
    return true
end
local function trackWeapons()
	if #weps > 0 then
		timer.scheduleFunction(trackWeapons, {}, timer.getTime() + .25)
	end
	for id, wpn in pairs(weps) do
		
		if wpn.obj:isExist() == true then 
			wpn.pos = wpn.obj:getPosition().p
			wpn.dir = wpn.obj:getPosition().x
			wpn.ip = land.getIP(wpn.pos, wpn.dir, 200)
		else
			local ip = wpn.ip
			if wpn.pos and not ip then
				ip = wpn.pos
			end
			mId = mId + 1
			trigger.action.markToAll(mId, "Impact", ip)
			table.remove(weps, id)

		end
	end
end

local e = {}

function e:onEvent(event)
	if event.id == 24 then
		volS.params.point = event.initiator:getPoint()
		world.searchObjects(2, volS, ifFound)
		trackWeapons()

	end
end
world.addEventHandler(e)

JMctEkt.mp4

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted
21 hours ago, Grimes said:

Tracking shells is doable, but somewhat annoying. Here is a very quick I threw together. Its not at all optimized and has some flaws with logic. For instance it only starts the check once an aircraft stops shooting and it can schedule it to check if there are multiple stop shooting events. Also it isn't checking the existing table for if it is already tracking a given weapon. Again just something super basic that was cobbled together from a few other scripts sitting around. To see it in action check that imgur link. 

https://i.imgur.com/JMctEkt.mp4

 

local mId = 0
local volS = {
	id = world.VolumeType.SPHERE,
	params = {
		radius = 5000
	},
}
local weps = {}
local ifFound = function(foundItem, val)
	table.insert(weps, {obj = foundItem})
    return true
end
local function trackWeapons()
	if #weps > 0 then
		timer.scheduleFunction(trackWeapons, {}, timer.getTime() + .25)
	end
	for id, wpn in pairs(weps) do
		
		if wpn.obj:isExist() == true then 
			wpn.pos = wpn.obj:getPosition().p
			wpn.dir = wpn.obj:getPosition().x
			wpn.ip = land.getIP(wpn.pos, wpn.dir, 200)
		else
			local ip = wpn.ip
			if wpn.pos and not ip then
				ip = wpn.pos
			end
			mId = mId + 1
			trigger.action.markToAll(mId, "Impact", ip)
			table.remove(weps, id)

		end
	end
end

local e = {}

function e:onEvent(event)
	if event.id == 24 then
		volS.params.point = event.initiator:getPoint()
		world.searchObjects(2, volS, ifFound)
		trackWeapons()

	end
end
world.addEventHandler(e)

JMctEkt.mp4

Thanks. I'm certainly not expecting you to drop everything and work on this, but if you could figure out a way to create a version this script that sets a flag active if those rounds land within a trigger zone, that would be awesome. Seems like that should be possible, given each impact location is marked and recorded?

 

On 7/21/2023 at 1:51 AM, cfrag said:

I have tried this with mixed results. 'Rounds in zone' is currently not easily done without heavy scripting, and will not for most airframes (the script needs access to your aircraft's targeting system's LOS, something that I know I can get from the Gazelle, but not many others).

I've tried a more roundabout way: you place a structure on the ground, and when the health of that structure is below 50% or it is destroyed, you get the message. The problem is this: many structures appear to be impervious to most smaller weapons, they do not receive damage. The attached demo shows the idea. I've use the red 'café' as object to detect the damage, but neither my Shark's cannon, Vikhr, nor rockets could damage the café, so you may want to look for a more brittle object/structure that can be destroyed or that register damage.

Suppress Sniper Test.miz 9.87 kB · 0 downloads

Thanks. Ideally I'd like to be able to not have this tied to a building's health, like for example what if I want to do a gun and suppress a tree line? But, this is better than nothing.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...