AI Speed commands
Moderators: winston, another_commander
AI Speed commands
Small request, aside from the current setSpeedTo: and setSpeedFactorTo: , would it be possible to have commands to just increase and decrease speed by a given amount (either absolute, factor percentage or perhaps both by seperate command)?
I'm thinking here to semi-realistically allow controlled acceleration and deceleration of ships and such by using such a command in conjunction with the update event (and without having to go through a lot of steps with specifically set speeds or speed factors).
At the moment a lot of ships seem to come to a halt as if they've hit a brick wall and then zoom off in a fashion that would have their pilots laminated onto the back wall of the cockpit, depending on their shipdata settings. Having controllable acceleration/deceleration might allow a simple-ish work-around for that?
I'm thinking here to semi-realistically allow controlled acceleration and deceleration of ships and such by using such a command in conjunction with the update event (and without having to go through a lot of steps with specifically set speeds or speed factors).
At the moment a lot of ships seem to come to a halt as if they've hit a brick wall and then zoom off in a fashion that would have their pilots laminated onto the back wall of the cockpit, depending on their shipdata settings. Having controllable acceleration/deceleration might allow a simple-ish work-around for that?
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: AI Speed commands
To my knowledge that is already build in since the early oolite days, but a lot of ship designers want super fast ships that stop like they hit a brick wall.Thargoid wrote:At the moment a lot of ships seem to come to a halt as if they've hit a brick wall and then zoom off in a fashion that would have their pilots laminated onto the back wall of the cockpit, depending on their shipdata settings. Having controllable acceleration/deceleration might allow a simple-ish work-around for that?
Look at a ship like the Behemoth. That was designed by Aegidean. He knew how to make things realistic and gives heavy ships like a Behemoth a realistic decelerate value.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
It's the Thrust value in shipdata.plist - with lower values more time is needed to reach the set speed.
...and keep it under lightspeed!
Friendliest Meteor Police that side of Riedquat
Far Arm ships
Z-ships
Baakili Far Trader
Tin of SPAM
Friendliest Meteor Police that side of Riedquat
Far Arm ships
Z-ships
Baakili Far Trader
Tin of SPAM
The example I want it for is a de-activated missile (minesweeper operation). Once de-activated, I want it to slow down gradually as if suddenly unpowered but from its original speed (ie natural slow deceleration, rather than a forced stop). But currently without a lot of messing around and multiple AI states it's not actually possible to do, which surprised me.
Basically I'm looking to increase/decrease speed by a given value or percentage of maxSpeed, not to a given value or percentage (if you see the distinction).
I'm just trying to be a little more realistic here and have a ship that doesn't have binary accelerator and brake pedals (plus it would be nice for ships to slow down rather than dead-stop before performing tumble etc when looking for targets and such, as some AIs at the moment make ship behaviour in this situation look very odd).
Basically I'm looking to increase/decrease speed by a given value or percentage of maxSpeed, not to a given value or percentage (if you see the distinction).
Yes I know that, but it's an all or nothing setting, and can't be changed iirc for a given situation (so won't be any use at all in the above scenario).Zieman wrote:It's the Thrust value in shipdata.plist - with lower values more time is needed to reach the set speed.
I'm just trying to be a little more realistic here and have a ship that doesn't have binary accelerator and brake pedals (plus it would be nice for ships to slow down rather than dead-stop before performing tumble etc when looking for targets and such, as some AIs at the moment make ship behaviour in this situation look very odd).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
There is no command in Oolite that can set a ship at "dead-stop", even not the performTumble or performStop. No command can set speed directly, only desired-speed can be defined. And everything slows down to desired speed using the thrust value.Thargoid wrote:(plus it would be nice for ships to slow down rather than dead-stop before performing tumble etc when looking for targets and such, as some AIs at the moment make ship behaviour in this situation look very odd).
What you are looking for is more a different thrust for acceleration and deceleration. Or even thrust as a read/write value?
Last edited by Eric Walch on Wed Oct 21, 2009 9:26 am, edited 1 time in total.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
performStop or setSpeedFactorTo: 0.0 combined with the thrust values of most ships (and missiles in this case) will effectively cause a dead-stop. It's only the bigger ships like the Behemoth where the thrust setting is low that a gradual stop can be achieved.
But you are correct though in approximating what I want to a variable thrust, but it would be more convenient to have commands to increaseSpeedBy / increaseSpeedFactorBy plus the decrease mirrors rather than having to mess around with thrust level and then to set the speed (factor) to a fixed value.
But you are correct though in approximating what I want to a variable thrust, but it would be more convenient to have commands to increaseSpeedBy / increaseSpeedFactorBy plus the decrease mirrors rather than having to mess around with thrust level and then to set the speed (factor) to a fixed value.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
It is not a dead stop. When you look in shipdata for a missile it has a maxSpeed of 750 and a thrust value of 250. Thrust is the speed change per second. So even a missile should take 3 seconds to come to a full stop. Anything fasted would be a bug.Thargoid wrote:performStop or setSpeedFactorTo: 0.0 combined with the thrust values of most ships (and missiles in this case) will effectively cause a dead-stop.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Let me double-check tonight again with a test missile.
But I recall seeing something similar with the hired guns ships. They have max speed of 1000 and thrust of 100 (for the viper-interceptor model) and I can recall seeing them in the past dead-stop, tumble and then shoot off in a different direction. Maybe something I'm doing wrong there in the AI/js, but it's an oddity.
But I recall seeing something similar with the hired guns ships. They have max speed of 1000 and thrust of 100 (for the viper-interceptor model) and I can recall seeing them in the past dead-stop, tumble and then shoot off in a different direction. Maybe something I'm doing wrong there in the AI/js, but it's an oddity.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
For me this sound very counter productive because this is exactly that the code already is doing constantly. I think something like "setThrustFactorTo:" would be better. Only accepting values between 0 and 1. And effectively setting the used trust to this percentage of the thrust defined in shipdata. This way the AI does dot need to constantly change speeds and oolites own speed regulation can do its job.Thargoid wrote:Basically I'm looking to increase/decrease speed by a given value or percentage of maxSpeed, not to a given value or percentage (if you see the distinction).
For a slow halt you than can use: ("setThrustFactorTo: 0.01", performStop)
EDIT: or would the name "setEnginePowerTo:" be better? Also within the range 0 to 1 (0 to 100%)
UPS-Courier & DeepSpacePirates & others at the box and some older versions
That would work yes. I was originally thinking of something like ("decreaseSpeedFactorBy: 0.1") as an update or repeatedly called event, thus reducing speed by 10% of max every time. If it was capped at 0 speed (with message "MIN_SPEED" or somesuch) and maxSpeed (with message "MAX_SPEED" or similar) then that too would work.
And I wouldn't think it would be too difficult to code, as all your doing is adding or subtracting maxSpeed * the argument to the current speed set point.
And I wouldn't think it would be too difficult to code, as all your doing is adding or subtracting maxSpeed * the argument to the current speed set point.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Anyway, back to the original question. I've tested a missile that when launched gets minesweepered by the following code snippets:
where the AI is:
When tried on a photon torpedo from RMB via OSE (max speed 3000, thrust 360) it carries on its merry way at a speed of a little under 3000, circles the target station and then smacks into it but doesn't trigger the cascade explosion. So in the correct sense it is disarmed, but either the deactivation AI isn't working (although when checked with the console it is in the right AI, in state "WAITFORIT") or there's some hang-over from its original AI into the new one?
Editted to add - and if I replace the setSpeedFactor in the AI with performStop, the missiles travel a grand total of about 130m (js position to ship position, with me in a SuperCobra) before coming to a complete stop (ie they dead-stop on launch). They're in the AI correctly, as they sit for a minute or two and then explode as they should.
So one way or t'other, something here's bust methinks.
Code: Select all
function localMines(entity) {
var isWeapon = entity.isWeapon,
isActive = entity.AI !== "TCAT_deactivatedAI.plist",
mines = [
"EQ_QC_MINE", "EQ_RMB_CASCADE_MISSILE", "EQ_RMB_LAW_MISSILE", "EQ_RMB_OVERRIDE_MISSILE",
"energy-bomb", "EQ_NUKE2_MISSILE", "EQ_HARPOON_NUKE2_MISSILE", "EQ_PHOTON_MISSILE", "RANDOM_HITS_MINE"],
isLocalMine = mines.some(function (mine, i, array) {return entity.hasRole(mine);});
return isWeapon && isActive && isLocalMine;
}
this.mineScan = function()
{
this.mineArray = system.filteredEntities(this, localMines, this.ship, 25600);
if(this.mineArray.length > 0)
{
player.consoleMessage("Quirium suppression field detected", 6);
this.mineArray.forEach(function (mine) {mine.setAI("TCAT_deactivatedAI.plist"); mine.displayName = "Disarmed " + mine.displayName;})
}
}
Code: Select all
{
GLOBAL =
{
ENTER = (switchLightsOff, throwSparks, "setSpeedFactorTo: 0.0");
UPDATE = ("setStateTo: WAITFORIT");
};
"WAITFORIT" =
{
ENTER = ("randomPauseAI: 20.0 60.0");
UPDATE = (becomeExplosion);
};
}
Editted to add - and if I replace the setSpeedFactor in the AI with performStop, the missiles travel a grand total of about 130m (js position to ship position, with me in a SuperCobra) before coming to a complete stop (ie they dead-stop on launch). They're in the AI correctly, as they sit for a minute or two and then explode as they should.
So one way or t'other, something here's bust methinks.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
It is still flying in performIntercept. You must give it a new behaviour. e.g. performIdle.Thargoid wrote:or there's some hang-over from its original AI into the new one?
And on the variable thrust: it now works for me in my compile. Using "setEnginePowerTo: 0.01" and than doing a "performStop" will make it takes ages before the missile comes to a complete stop. (Should be 100 times longer but I did not check the distance).
Last edited by Eric Walch on Wed Oct 21, 2009 5:14 pm, edited 1 time in total.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
performStop makes it dead-stop though, certainly not in the 8 or so seconds it should via the simple thrust/speed calculation. I'll try adding a performIdle or performTumble with the setSpeedFactor and see what we get.
I've PM'd you a link to the WIP if you want to try it yourself.
Editted to add - if I do "performIdle" in addition to the setSpeedFactorTo in the code above, it works same as performStop - ie the missiles just deadstop immediately on launch when their AI's get swapped, no slowdown at thrust rates...
I've PM'd you a link to the WIP if you want to try it yourself.
Editted to add - if I do "performIdle" in addition to the setSpeedFactorTo in the code above, it works same as performStop - ie the missiles just deadstop immediately on launch when their AI's get swapped, no slowdown at thrust rates...
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link