Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

2 years ago

Advertisement
October 16, 2019, 01:32:20 am

Author Topic: [Beta] Autopilot  (Read 9254 times)

DaAlpha

  • Donator
  • Jr. Member
  • *****
  • Posts: 53
    • View Profile
Re: [Beta] Autopilot
« Reply #15 on: July 08, 2015, 07:44:44 pm »
Very snazzy. This script takes the cake on my server when it comes to the fewest modifications done to it by myself ... and that is saying something :D

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #16 on: July 08, 2015, 10:22:39 pm »
Very snazzy. This script takes the cake on my server when it comes to the fewest modifications done to it by myself ... and that is saying something :D
Good to hear that others are using this. Let me know if you have any suggestions or find any bugs. It still needs improving before I move it into a full release.

DaAlpha

  • Donator
  • Jr. Member
  • *****
  • Posts: 53
    • View Profile
Re: [Beta] Autopilot
« Reply #17 on: July 12, 2015, 05:06:44 am »
Something I would like to see is if stuff like the config, the plane data and the airport data get moved into separate files (cConfig, cPlanes, cAirports, ...). The main autopilot script is a bit too full with this, leads to a lot of scrolling. Also, the settings like two_keys, panel_toggle_button etc. should rather be in the initiator, so that one does not have to dig into the code to toggle this stuff. Maybe you could even move the settings into an own file as well so that settings for all classes (Autopilot, HUD, ApproachPath) would be in one place.

Asides from that, the separator button is not really the most elegant way to separate this stuff. You should probably find a good replacement for that, a group box for example might do (not used them yet though).

What I would also appreciate would be a visual indicator (like a diamond) on the targeted player when auto-chase is active. I could provide you with the code for that, I already have a temporary version on the dev server which does not scale yet.

Oh yeah, bug-wise I also have something for you. cHUD, line 104, attempt to index field 'screen_size' (a nil value). The issue here is just that in line 103, self.screen_size is set to 'args.Size', which does not exist. However, 'args.size' exists, it's just the capital s.

In the line below that, line 105, it gets even fancier with two typos: 'self.screen__size' and 'self.screen_ize', of course both technically nil values, thus leading to the same error as above.

That's what I found so far. Ofc, I will keep you updated if I find something else.

Edit: I just found another thing to be improved. Currently, the AP is also available for passengers. I think there should be an additional check if one is actually the driver.

Edit edit: It would also be good to have a button to toggle the approach paths with a default that can be set in the settings. I prefer it to be offline by default because those lines are more confusing than anything to most people, because they do not know what it is.
« Last Edit: July 12, 2015, 04:17:44 pm by DaAlpha »

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #18 on: July 12, 2015, 04:32:46 pm »
Something I would like to see is if stuff like the config, the plane data and the airport data get moved into separate files
Done.

Quote
Asides from that, the separator button is not really the most elegant way to separate this stuff. You should probably find a good replacement for that, a group box for example might do (not used them yet though).
I didn't like how the GroupBox looked. I changed it to a Rectangle, though, so it no longer flickers.

Quote
What I would also appreciate would be a visual indicator (like a diamond) on the targeted player when auto-chase is active. I could provide you with the code for that, I already have a temporary version on the dev server which does not scale yet.
Added to to-do list.

Quote
Oh yeah, bug-wise I also have something for you. cHUD, line 104, attempt to index field 'screen_size' (a nil value). The issue here is just that in line 103, self.screen_size is set to 'args.Size', which does not exist. However, 'args.size' exists, it's just the capital s.

In the line below that, line 105, it gets even fancier with two typos: 'self.screen__size' and 'self.screen_ize', of course both technically nil values, thus leading to the same error as above.
I got rid of those variables anyway, so fixed.

Quote
Edit: I just found another thing to be improved. Currently, the AP is also available for passengers. I think there should be an additional check if one is actually the driver.
Done.

Quote
Edit edit: It would also be good to have a button to toggle the approach paths with a default that can be set in the settings. I prefer it to be offline by default because those lines are more confusing than anything to most people, because they do not know what it is.
The ApproachPath script is not required, so you don't have to install it. I'm not sure how the lines can be misinterpreted for anything other than a runway indicator, though.

DaAlpha

  • Donator
  • Jr. Member
  • *****
  • Posts: 53
    • View Profile
Re: [Beta] Autopilot
« Reply #19 on: July 12, 2015, 04:42:58 pm »
The approach path is fancy, I would not want to remove it. But I would like it not to be enabled by default. Well, I guess I can just add my own button for that :D

Asides from that, very fancy. Looking forward to the next update.

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #20 on: July 12, 2015, 05:14:09 pm »
A feature that I considered adding was one where, instead of having to spam the approach hold button in search of a runway, the autopilot could automatically scan for runways every few seconds while the approach button is toggled on. If one were found, the approach hold would activate and the path would render. I think I'll add that on the next update.
« Last Edit: July 13, 2015, 02:19:45 am by SinisterRectus »

DaAlpha

  • Donator
  • Jr. Member
  • *****
  • Posts: 53
    • View Profile
Re: [Beta] Autopilot
« Reply #21 on: July 12, 2015, 05:17:40 pm »
A good idea imo. This would solve my complaint as well.

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #22 on: July 12, 2015, 10:25:59 pm »
I implemented the mentioned features for Approach-Hold as well as an indicator for Target-Hold and a few other tweaks.



Full list of today's changes:

  • Moved config, planes, and airports tables into separate _init.lua file
  • Moved keystroke settings to from Autopilot:InitGUI() to Autopilot:__init()
  • Added driver check to availability check
  • Changed window break line from Button to Rectangle
  • Debug HUD now utilizes Render.Size when necessary instead of storing it
  • Debug HUD now uses tostringint() function instead of tostring(int())
  • Moved tostringint() function to _init.lua
  • Made color scheme configurable with self.color in Autopilot:__init()
  • Added GUI indicator for Target-Hold. Can be toggled with self.draw_target
  • Added GUI indicator for Approach-Hold. Can be toggled with self.draw_approach
  • Removed ApproachPath script (made redundant by GUI indicator)
  • Changed ApproachHold() and TargetHold() subscriptions from InputPoll to Render
  • Approach-Hold now actively scans for runways until one is found
  • Basic autopilot functions are unavailable while scanning for runways
  • Altitude-Hold can no longer be activated while Target-Hold is active
  • Speed-Hold can no longer be deactivated while Target-Hold is active
  • Target-Hold now properly deactivates functions that it was using
« Last Edit: July 13, 2015, 02:43:21 am by SinisterRectus »

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #23 on: August 07, 2015, 08:53:47 pm »
Update!

  • Target-Hold now scans for planes in the same way that Approach-Hold scans for runways
  • Removed degrees functions from the Autopilot class and moved them to _init.lua
  • Changed the autopilot vehicle get functions to the Vehicle class and moved them to _init.lua
  • Fixed bug where Approach-Hold would not turn on the Autopilot main switch
  • Simplified plane-despawn check
  • Removed some debug code that I accidentally committed

The next thing that I'd like to do is improve the autopilot's automated landings. Self-flying planes might also happen in the future. :)

[email protected]

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: [Beta] Autopilot
« Reply #24 on: August 08, 2015, 02:13:44 am »
awesome!!
really looking forward to autopilot in heli's :)
keep on rocking!

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #25 on: August 08, 2015, 03:20:15 am »
awesome!!
really looking forward to autopilot in heli's :)
keep on rocking!
I haven't quite figured out how I want it to work in helicopters, since their physics is very different from airplane physics. It's definitely on my to-do list, but not a high priority at the moment. I'll probably have to write a script for helicopters that is independent from the current script, so I might save that for my "final" release, whenever that may be.

misterff1

  • Donator
  • Hero Member
  • *****
  • Posts: 582
    • View Profile
Re: [Beta] Autopilot
« Reply #26 on: September 11, 2015, 04:18:50 pm »
It's amazing to see all this progress in such a short time! One thing I am still missing is the option for km/h or mph though. We added that on our version, but it's a pain in the ass to keep doing that every time if we update the script with the latest changes and I think it would be a nice addition anyway :)

Other than that, I am really impressed by what this script can do :D

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #27 on: September 12, 2015, 05:50:03 pm »
Update!

Your wish is my command. I've added units settings that only affect the displayed values. All internal calculations are still done in meters, km/h, and degrees. You can set the defaults at the very top of _init.lua, but players can also change them in game. Changes will affect both the Autopilot panel and the debug HUD.

I also added the ability to change the maximum input values and gain levels. Most people won't need to change these, but it's nice to have.

Changed settings do not save anywhere, they will revert on log-out.

Please let me know if you find any bugs!



Other changes:

  • Replaced tostringint() with string.format("%i")
  • Switched config table keys to consecutive indices, which allows for better procedural generation of GUI elements
  • Refactored GUI code to accommodate changes
« Last Edit: September 12, 2015, 09:27:28 pm by SinisterRectus »

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Beta] Autopilot
« Reply #28 on: October 04, 2015, 07:04:26 pm »
I just realized that recent changes to these scripts require a 0.2 client. My apologies to anyone who has tried to run the newest version of Autopilot on 0.1.4.

The latest commit compatible with 0.1.4 can be found here.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [Beta] Autopilot
« Reply #29 on: October 11, 2015, 04:00:39 pm »
This is pure awesomeness. However, maybe the approach angle can be a little steeper. On a lot of runways i end up hitting hills or trees for the most part. Cheers.