Page 1 of 1
how to stop something that has speed 0?
Posted: Wed Dec 17, 2008 7:54 am
by Commander McLane
For my q-bomb OXP I would like defunct q-bombs to just sit there. But I can't make it.
When I eject a q-bomb it gets a certain velocity, inherited from my own ship. If I stand still, its backwards velocity is biggest. I I fly forward, the bomb's velocity is smaller.
However, while moving away from me, it officially has a speed of 0.
> player.ship.target.speed
0
is what the console says, despite of the bomb's high velocity.
Now I've got a problem. How do I stop something which for scripting purposes has a speed of 0, while in reality it moves fast?
setSpeedTo: 0 doesn't work (speed
is already 0), same for
setSpeedFactorTo: 0. Also
performHold brought me no luck.
Oh, and I already changed its thrust from 0 to positive values. First I tried 10, then 50, then 1000. To no avail.
What else can I do to make it stop? How does it work for escape pods? Doesn't their inherited injection speed drop to 0 after a while and is replaced by their engines' speed?
Posted: Wed Dec 17, 2008 9:37 am
by JensAyton
Unfortunately, there’s a distinction between engine-controlled speed and physics-controlled velocity. Ships generally compensate for non-zero velocity by thrusting in the opposite direction, which is what you’re seeing with the escape pods. Q-bombs have zero thrust, though, so they just drift. There’s currently no way to give just some q-bombs non-zero thrust unless you can use separate shipdata entries.
Posted: Wed Dec 17, 2008 9:41 am
by Eric Walch
As far as I remember from the code, a ship can have two kinds of "speeds". The speed that is defined in shipdata and scripting. That is always in flying direction. Than there is a "velocity". This is actually a vector that contains a ships actual speed and direction. e.g. when missiles are launched they have a forward speed but also a velocity downwards. This velocity is the actual movement. Speed is internally transferred into velocity (Is makes sense as speed is not just a number but a vector with direction)
From the code of ejecting a bomb:
Code: Select all
double eject_speed = -800.0;
vel = vector_multiply_scalar(v_forward, [self flightSpeed] + eject_speed);
eject_speed *= 0.5 * (randf() - 0.5); // -0.25x .. +0.25x
vel = vector_add(vel, vector_multiply_scalar(v_up, eject_speed));
eject_speed *= 0.5 * (randf() - 0.5); // -0.0625x .. +0.0625x
vel = vector_add(vel, vector_multiply_scalar(v_right, eject_speed));
Its a little bit cryptic, but the names probably already give a rough idea of what happens.
But to your speed reduction: A ship needs trust to reduce its speed. With a trust of zero it still will remain its speed even when max speed is zero. In my experience a trust around the 15 gives a nice slowdown until max speed is reached. AI commands are not needed as the system always will try to slow down the stuff to max speed.
Your method should work. I don't see anything in the code that is overruling a previous trust setting.
Posted: Wed Dec 17, 2008 10:24 am
by Commander McLane
@ Ahruman: Currently I opted for giving all q-bombs thrust via shipdata-overrides.plist.
But it doesn't work even with a thrust of 1000, inferred upon the q-bomb this way.
Question: In timebombAI I just set the speed to 0 if the bomb is defused. Then I inserted a pauseAI:, because I thought there is perhaps some time needed to let it come into effect. So it looks like this:
Code: Select all
"CHECK_FOR_MASS" = {
DEFUSE = ("setSpeedTo: 0.0", "pauseAI: 5.0");
DETONATE = (becomeEnergyBlast);
ENTER = ("sendScriptMessage: checkForPlanetProximity");
UPDATE = (becomeUncontrolledThargon);
};
Now to my question: Do I perhaps need some perform... method as well, to make the setSpeedTo: effective?
Posted: Wed Dec 17, 2008 3:34 pm
by LittleBear
performStop maybe in AI? becomeUncontrolledThargon should also work. My minesweepers tell any nasty ordinance they find to becomeUncontrolledThargon by way of a scipt action and in playtesting Cascade Missiles just stop and spin when they are turned into uncontrolled Thargons.
Posted: Thu Dec 18, 2008 6:38 am
by Commander McLane
Sorry to Ahruman and Eric! Everything's working perfect, the only buggy factor was, ahem..., me.
For some reason that I don't recall the shipdata-overrides or shipdata I wrote into was not from the OXP version in my AddOns, but from a development version stored elsewhere. So all my changes of cargo_type and thrust simply weren't incorporated in the game. Oops!
When I finally realized this and opened the correct file(s), everything worked like a charm.
After some tests qnd playing with different values I did not go for substituting the defused qbomb with a clone, but gave it a thrust of 15. This will bring it to a halt in a sufficient amount of time (and no setSpeedTo: or the like are even needed). Warning: This means that the qbomb will slowly decelerate
from the moment it is dumped, so it will explode a little closer to the dumper. However, with a thrust of 15 the difference is not very big.