Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Missile intercept code

An area for discussing new ideas and additions to Oolite.

Moderators: another_commander, winston

User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Post by Cmdr James »

Also, ShipEntity.m trackPrimaryTarget at about line 4577 returns if scanClass is missile (it executes the new supercool code we are talking about :) )

So I think the code at about 4655 if not reachable.

Code: Select all

// treat missiles specially
	if ((scanClass == CLASS_MISSILE) && (d_forward > cos(delta_t * max_flight_pitch)))
	{
		OOLog(@"missile.track", @"missile %@ in tracking mode", self);
		[self trackOntoTarget: delta_t withDForward: d_forward];
		return d_forward;
	}
[code]

If I understand correctly (and objective C is not my forte) we can remove this code completely, as it should never be reachable, (unless an item can become a missile due to some kind of race condition while this method is executing, which seems kind of unlikely).  Maybe the OOLog should be moved up to the first block around 4577 so that we get the expected output?
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1878
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

how about pilot-rating/bounty/ship-price etc determine some fraction of the missile random accuracy?

In effect making it an inherited value from the launcher's skills.

edit:
or equipment check for missile guidance and tracking systems, giving a boost to the semi-random value if found. This would favour well equiped, rich, thus presumably also experienced pilots.
Riding the Rocket!
User avatar
Hoopy
---- E L I T E ----
---- E L I T E ----
Posts: 438
Joined: Wed Oct 03, 2007 8:54 pm
Location: Durham, England

Post by Hoopy »

except that a good pilot with a good ship etc is less likely to have need of a good missile as they're likely to be good with lasers already. And the novice pilot with a Mk III and pulse lasers is likely to rely on missiles early on so needs them to be good.

I like the idea of variable ability for missiles but I can't think of way to use it which makes actually the game better.

Maybe missiles bought at lower tech worlds could be worse?

or maybe have several types of missle of varying cost/ability/tech level required?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6557
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Have a look at the missile options OXP by Cmdr Maegil. Details in the Expansion Pack section. This is a good way of using the new functionality for missiles.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1878
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

I was thinking of the NPCs use of and skill with missiles actually, not really the player.
(who can buy and use missiles as his own skill and money allow, I wouldn't want to script the player ...not like this anyhow. ;) )
Riding the Rocket!
User avatar
Captain Hesperus
Grand High Clock-Tower Poobah
Grand High Clock-Tower Poobah
Posts: 2312
Joined: Tue Sep 19, 2006 1:10 pm
Location: Anywhere I can sell Trumbles.....

Post by Captain Hesperus »

Arexack_Heretic wrote:
( I wouldn't want to script the player ...not like this anyhow. ;) )
More like:

Code: Select all

playership.BuyTrumble.SetToAccept
playership.AllowTrumbleMultiplication.SetToAccept
playership.DeliverTrumblesToTrumbleCollector.SetToAccept
:wink:

Captain Hesperus
....

Code: Select all

Encourageplayer.BuyTrumble.True
The truth, revealed!!
Image
User avatar
Cmdr. Maegil
Sword-toting nut-job
Sword-toting nut-job
Posts: 1294
Joined: Tue Feb 27, 2007 10:28 pm
Location: On the mend in Western Africa

Post by Cmdr. Maegil »

newspeak.oxp?
You know those who, having been mugged and stabbed, fired, dog run over, house burned down, wife eloped with best friend, daughters becoming prostitutes and their countries invaded - still say that "all is well"?
I'm obviously not one of them.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Missile intercept code

Post by Eric Walch »

Cmdr James wrote:
Guys, I have made a small modification to the code used for the missile interception logic. It is now, normally much more likely to strike a target, as it will predict the target location based upon its current velocity. I guess it might be better to add some damping due to the imperfect ability to read a target velocity?
There is one bug in the prediction code. For a long time I use missiles to shoot away incoming hardheads. I have a special set with an accuracy of 8 and very often they start flying the wrong way. Today I looked a bit deeper in it. For 90% of the time of the incoming missile, my fired missile even stayed behind me and did not fly towards the incoming one. Setting accuracy to zero fixed the problem.

Looking at your code, I see that it assumes the missile is in pursuit of the target and heads not for the missile itself but for a position in front of the target, based on the travel time. But with a head-on approach towards a fast flying ship, it can happen that it calculates an interception point that even lies further away than the current distance. I have not tested this, but it should also mean that when you inject towards an incoming missile, that missile might get confused. :P
(EDIT: I just tested it with a missile with accuracy=8 that was fired at me: player.ship.heading.dot(player.ship.target.heading)= 0.9703339338302612 The value near 1 means the missile was fleeing from me when I injected toward it :lol: )

I suggest adding a line that calculates the dot product between own and target forward_vector. And only use your accuracy code when in persuit.

Code: Select all

inPursuit   =   (dot_product([target forwardVector], v_forward) > 0.0f);
With this addition, my missiles now hit the incoming ones from the air when a high accuracy was defined. Before it only worked correct when defining a low accuracy what seemed a bit strange.

Browsing through some missile containing oxps I could only find one using the accuracy setting and that was the abs missile from nukes.oxp. For any other missiles without an accuracy setting, this effect will be not present.
User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Re: Missile intercept code

Post by Cmdr James »

Good work. I think you are right.

Unfortunately I never got around to sorting out my git access properly, maybe someone else can commit your change?
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Missile intercept code

Post by Eric Walch »

Committed it now.

Those strange missile launches made me wonder for over a year, but I always thought it was part of the normal randomness. Only today when looking at the code the pieces fell together that the defined accuracy of my missile had to do with it. And normally ships flee for missiles and is a missile always in pursuit.
Post Reply