Jump to content

Anti Taxiway Take off code


Shahdoh

Recommended Posts

On the Virtual Aerobatics server, we have sometimes been plagued by people too impatient to use the runways. They startup, turn and lunge down the ramp to take off, sometimes hitting other people on the way. I finally sat down and modified some race lua code by Bas 'Joe Kurr' Weijers (thanks!) and have it check the zones for:

#1 - They are on the ground.

#2 - Their velocity computed to knots.

 

If their velocity is between 40-60 knots, they get a warning. If the velocity is over 60 knots, they are removed from aircraft with Unit.getByName(unit:getName()):destroy()

No explosion, they just disappear!

 

I set the timing to check every 2 seconds, and with 40 trigger zones on a busy VA server, it appears to have no impact on the mission. I suspect there are other mission designers/server operators out there who would like the same thing so I am sharing it here. Most missions will only need a fraction of the trigger areas, making the load to the mission even less. So, I hope others will find it as useful as we have on the VA.

 

/Salute

Shahdoh

 

Updated Taxi code to avoid those warping.

TaxiCheck2.rar


Edited by Shahdoh
  • Like 1
Link to comment
Share on other sites

Awesome! Does it have to load with mission start or is a do script sufficient?

ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 

"This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL

Link to comment
Share on other sites

Great! I'll start incorporating this in DoW missions

ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 

"This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL

Link to comment
Share on other sites

I don't run a server but I still think this is very cool. :thumbup:

 

Even better if you could respawn the offending individual into a target drone for a 5 minute penalty time! ;)

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to comment
Share on other sites

1 consequence we are having with the code, is it does sometimes pick up when a person warps while in the taxi zone, thus, indicating they were going way faster then they were and removing them from the aircraft. In one thought, the reason for the code is to reduce collisions on the ramps/taxiways and as thus, continue to remove them. The other thought is to not punishing someone for warping. So, if anyone has any coding ideas in how to allow for warping, it would be greatly appreciated.

Link to comment
Share on other sites

I don't know that works.

 

local warned --bind it with the ID or UNIT

for unitIndex, unit in ipairs(unitsInZone) do

grp = unit:getGroup()

 

if unit:getLife() > 1 and unit:inAir() == false and mist.vec.mag(unit:getVelocity())*1.95 > 40 and mist.vec.mag(unit:getVelocity())*1.95 <=60 then

warned = true

trigger.action.outTextForGroup(grp:getID(), unit:getPlayerName() .. ' - You are exceeding safe taxi speeds, slow down or you will be removed from your aircraft!', 3)

elseif unit:getLife() > 1 and unit:inAir() == false and mist.vec.mag(unit:getVelocity())*1.95 > 60 and warned then

trigger.action.outText(unit:getPlayerName() .. ' has been removed from their aircraft. Speed on taxiway reported at: '.. math.floor(mist.vec.mag(unit:getVelocity())*1.95+.05) .. ' knots.', 5)

Unit.getByName(unit:getName()):destroy()

end

end

 

if it's not working, then try a timestamp using GetMissionTime()

 

 

or

for unitIndex, unit in ipairs(unitsInZone) do

grp = unit:getGroup()

 

if unit:getLife() > 1 and unit:inAir() == false and mist.vec.mag(unit:getVelocity())*1.95 > 40 and mist.vec.mag(unit:getVelocity())*1.95 <= 60 then

trigger.action.outTextForGroup(grp:getID(), unit:getPlayerName() .. ' - You are exceeding safe taxi speeds, slow down or you will be removed from your aircraft!', 3)

elseif unit:getLife() > 1 and unit:inAir() == false and mist.vec.mag(unit:getVelocity())*1.95 > 60 and mist.vec.mag(unit:getVelocity())*1.95 <= 300 then

trigger.action.outText(unit:getPlayerName() .. ' has been removed from their aircraft. Speed on taxiway reported at: '.. math.floor(mist.vec.mag(unit:getVelocity())*1.95+.05) .. ' knots.', 5)

Unit.getByName(unit:getName()):destroy()

end

end


Edited by Interceptor
Link to comment
Share on other sites

Thanks Interceptor, we are currently trying the 2nd one, though our settings are between 60-250. Is definitely better, but there have been sometimes where a warp occurred at those speeds. It has minimized it considerably though, so maybe thats enough.

 

I was thinking of making it some type of time base, like exceeding 60 by more then like 3 seconds or something like that, but not sure how to do it.


Edited by Shahdoh
typo
Link to comment
Share on other sites

When I was on this evening it was working well but someone had a speed of 25000 knots which made me smile. I guess this was a warping issue. If these are the speeds recorded when a player warps then a speed greater than 60 but less than 1000 may be a solution:)

i5 8600k@5.2Ghz, Asus Prime A Z370, 32Gb DDR4 3000, GTX1080 SC, Oculus Rift CV1, Modded TM Warthog Modded X52 Collective, Jetseat, W10 Pro 64

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

I have been watching it pretty closely, and have seen/heard reported that warps have triggered almost any speed, from being just enough to trigger the warning(pilot reported that had just barely started moving, but had lagged), to well over 7000 knots. Our current settings of between 60-250 knots seems to be working pretty well for now.

Link to comment
Share on other sites

This is amazing :)

 

Now ... if it would be possible to do something similar for taking off from the non-active runway (say, within such-and-such a distance of the wrong end of the runway, at ground level, moving in the wrong direction between these speeds ... might need to pre-define runway end coordinates for all known runways) :)

Link to comment
Share on other sites

The active changes with the weather :)

 

Yeah, I'm not sure that it is possible.

 

With regular weather, where the wind direction doesn't change, it might be possible, but with dynamic weather the active can change during a mission it would be even harder, unless there's some API call that allows you to extract the active.

 

I can dream, however ;)

Link to comment
Share on other sites

The other issue, is that this code works universally across the whole map, no matter the airport. To identify proper runway checks, you would now need a lot more variables and checks for each runway.

 

Other then trying to eliminate the warp triggering the code, this is about as far as I intend to take the code. Obviously open for others to take the helm though.

Link to comment
Share on other sites

The question/danger in my mind is where's "the line" between systemically enforcing reasonable policies and enforcing petty preferences of the server operator?

 

But I think enforcing the taxiway takeoff policy is perfectly reasonable (other people get damaged/killed)

Link to comment
Share on other sites

  • 1 month later...

Not sure if many have tried the code, but we have updated the code so that it does a much better job of not punishing people for warping across the ramp. See original post for updated files.

 

I have added a secondary check that takes place 2 seconds after the violation. If they are still in violation they are removed. This appears to have remedied over 90% of warping triggering the taxi code.

Link to comment
Share on other sites

Hey Shahdoh,

 

I think this is a very important script, but making numerous trigger zones for each base is a bit problematic and annoying :)

 

Instead, I suggest using mist.flagFunc.units_in_polygon

This function can raise a flag when a certain plane is in the polygon zone, you can use that to trigger the destroy function only when the flag is on.

Link to comment
Share on other sites

Xcom, thanks for the input. I would love to do that, but my knowledge of Lua is pretty limited and have struggled to get it this far. Right now the code goes through the list of zones by cycling through the names of the trigger areas. Can this be done with polygon zones as well? I was unaware you could name them. If not, how would you cycle through multiple polygon zones?

 

Again, thanks for the suggestion, always looking to improve things.

Link to comment
Share on other sites

Example -

 

--Polygon zones
local polyzone = 
{
}

--Populate polyzones from mission
for GName, Data in pairs(mist.DBs.groupsByName) do
if Data.category == "vehicle" then
	if string.sub(GName,1,string.len("POLYZONE"))=="POLYZONE" then
		table.insert(polyzone,GName)
	end
end
end

--Run polygon continues test for units
for i,name in pairs(polyzone) do
for k,v in pairs(mist.DBs.humansById) do
		mist.flagFunc.units_in_polygon
		{
		units = v.groupName,
		zone = mist.getGroupPoints(name),
		flag = v.groupName,
		req_num = 1,
		interval = 5,
		toggle = true
		}
end
end





 

The above code puts up a flag of the human group name whenever it is inside the polygon zone, which I suggest putting on the airbases runways, the way to do it is create a late activation unit and place it's waypoints on the runway edges, starting name of the units group needs to be - polyzone.

 

And then just run through all the human units to check something similar to your taxi check function but for if their flag name is on...

 

function takeoffbuster()
for k,v in pairs(mist.DBs.humansById) do
		if Group.getByName(groupName) then
			if trigger.misc.getUserFlag(v.groupName) then

 

Hope this is clear, it would be nice to have a mission template ready with this script inside and the relevant polygon zones on all the runways.

Link to comment
Share on other sites

Enabling only the runways for use is not a solution I am aiming for. People like to use the grass areas and roads and such on the VA. The whole reason for the script is to maintain order on the busy areas of the airports(ramps/taxiways). I will look more at the code and see how it will work out.

 

Thanks for the example.

Link to comment
Share on other sites

  • 3 years later...

Moin..

 

Thanks for that.. nice one.

It works, but..

 

If someone is too fast, there are a message player xy is too fast and removed from aircraft

but he didn't was removed..

 

He can fly

why? I want to remove or kill the player for beeing too fast

 

 

MrZweig

MrZweig - Germany - = vJAG = - -= Online Aerobatics Germany =- FreeFlight - 45 Slots - dedicated

Caucasus - 82.220.20.214:10308

Nevada - 82.220.20.212:10308

http://online-aerobatics-germany.de - www.forum.online-aerobatics-germany.de - TS adress: Online Aerobatics Germany - IP: 82.220.20.214

Link to comment
Share on other sites

  • Recently Browsing   0 members

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