Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: General Battuta on June 26, 2015, 08:27:29 am

Title: How do missiles decide to chase CMs?
Post by: General Battuta on June 26, 2015, 08:27:29 am
Specifically, I'm interested in the randomness used.

Let's say I have ten missiles chasing a single ship. The ship fires a countermeasure.

The CM has strength 1, and the missiles have seeker strength 2. So there's a 50% chance the missiles will chase the CM.

What I want to know is: if all ten missiles see the countermeasure in the same frame, will they each roll a separate 50%, or do they all use the same roll?
Title: Re: How do missiles decide to chase CMs?
Post by: The E on June 26, 2015, 08:39:16 am
Every missile gets its own dice roll.
Title: Re: How do missiles decide to chase CMs?
Post by: General Battuta on June 26, 2015, 08:51:47 am
That's not the behavior I'm observing, but I suspect it has something else to do with the way CMs and missiles interact. I'll poke at it further.
Title: Re: How do missiles decide to chase CMs?
Post by: The E on June 26, 2015, 10:13:06 am
In pseudocode, what happens is this:

For all homing weapons
    For all countermeasures
              if countermeasure team != weapon team OR weapon owner is traitor
                    if weapon is within countermeasure effect radius
                            compute intercept chance
                            if frand() >= chance
                                  ignore this countermeasure
                            if countermeasure not ignored and within weapon's FOV
                                  change weapon target to countermeasure
Title: Re: How do missiles decide to chase CMs?
Post by: General Battuta on June 26, 2015, 10:16:51 am
frand() gets rerolled for each missile, I assume, it's not some kind of seed that gets updated once a frame or something?

Let's talk about this last bit, this seems funny and possibly explanatory to me:

Quote
if countermeasure not ignored and within weapon's FOV
                 change weapon target to countermeasure

So it performs the FOV check after the decoy roll? If a weapon gets pulled, but then isn't looking at the CM, it won't chase the CM?

Maybe more importantly, a missile checks for decoy not when it's [in range and looking], but when it's [in range], right? If it later 'sees' the CM for the first time, it's already decided (not) to chase it?

What happens if a CM dies while the missile is attacking it? Can it retarget back to the original?
Title: Re: How do missiles decide to chase CMs?
Post by: The E on June 26, 2015, 12:36:11 pm
So it performs the FOV check after the decoy roll? If a weapon gets pulled, but then isn't looking at the CM, it won't chase the CM?

Correct.

Quote
Maybe more importantly, a missile checks for decoy not when it's [in range and looking], but when it's [in range], right? If it later 'sees' the CM for the first time, it's already decided (not) to chase it?

This is trickier. First, missiles have limited memory of countermeasures they ignore; if a missile ignores a cm, it stores the cm's object id until it ignores a different one. As a result, a countermeasure has a number of chances to pull a given missile (1 chance for every frame in which the missile sees the cm and is inside the cm's effect range). Incidentally, this means that cms become more effective the higher the framerate.

Quote
What happens if a CM dies while the missile is attacking it? Can it retarget back to the original?

No. Once a weapon is locked onto a cm, the original targeting information is lost and cannot be retrieved any longer; if the weapon is tabled as an untargeted heat seeker, it may find a new victim.
Title: Re: How do missiles decide to chase CMs?
Post by: General Battuta on June 26, 2015, 12:50:23 pm
Ugh this **** is a nightmare!

So Angel Flare spreads have more effectiveness than we thought, because each flare in the spread is a chance to reset the missile's memory, right? If you're looking at two flares, you go into an infinite loop of 'I ignore flare A, now I need to roll B, and if I ignore it, return to A...'

I think I've seen Apocs re targeting to a warship after the flare spread dies. But maybe I'm nuts.
Title: Re: How do missiles decide to chase CMs?
Post by: General Battuta on June 26, 2015, 12:51:08 pm
Does range provide any kind of coefficient to CM effectiveness?
Title: Re: How do missiles decide to chase CMs?
Post by: The E on June 26, 2015, 01:00:26 pm
To be fair, I am not entirely certain about how target reacquisition may or may not work. It's certainly possible that there's some code somewhere that would allow missiles to reacquire their original targets.

Quote
So Angel Flare spreads have more effectiveness than we thought, because each flare in the spread is a chance to reset the missile's memory, right? If you're looking at two flares, you go into an infinite loop of 'I ignore flare A, now I need to roll B, and if I ignore it, return to A...'

Well, not an infinite loop precisely as the missile will eventually leave the cm's sphere of influence. But yeah, pretty much exactly that is what is happening.

Does range provide any kind of coefficient to CM effectiveness?

Nope.
Title: Re: How do missiles decide to chase CMs?
Post by: General Battuta on June 26, 2015, 01:05:55 pm
Ugh. Maybe we should move spreads to a 'one real decoy, cosmetic companions' model...
Title: Re: How do missiles decide to chase CMs?
Post by: The E on June 26, 2015, 01:07:40 pm
Maybe. Or we could think about how we can refactor this system a bit.
Title: Re: How do missiles decide to chase CMs?
Post by: Dragon on June 26, 2015, 03:17:13 pm
How are the swarm/corkscrew missiles treated in this context? From what I've seen, the entire salvo will always either be spoofed or not. It's impossible to, say, lose half of the salvo with a single CM, it's always all or nothing. It might be useful to be able to change this behavior (on a per-mod basis, of course).
Ugh. Maybe we should move spreads to a 'one real decoy, cosmetic companions' model...
That would make them decoy decoys, wouldn't it? :)

...I know, I know.
Title: Re: How do missiles decide to chase CMs?
Post by: General Battuta on June 26, 2015, 03:21:02 pm
That's a really good question. I hadn't thought of that. E, are the Narayana's Apocs currently using swarm or burst?
Title: Re: How do missiles decide to chase CMs?
Post by: DahBlount on June 26, 2015, 05:38:29 pm
If I remember the tables correctly, Apocs use Swarm with 4 missiles per swarm.
Title: Re: How do missiles decide to chase CMs?
Post by: Cyborg17 on June 26, 2015, 07:41:52 pm
I think I've seen individual missiles be spoofed by countermeasures.  It's worth testing to make sure.
Title: Re: How do missiles decide to chase CMs?
Post by: X3N0-Life-Form on June 27, 2015, 12:54:11 am
If I remember the tables correctly, Apocs use Swarm with 4 missiles per swarm.
Looks like it from the release table I have on hand.
Code: [Select]
$Name: Apocalypse#Narayana
$Model File: MissileXL.pof
$POF target LOD: 0
$Mass: 60.0
$Velocity: 200.0
$Fire Wait: 20.0
$Damage: 1000
$Damage Type: HugeWeapon
$Arm radius: 250
$Shockwave Damage Type: Shockwave
$Blast Force: 1000.0
$Inner Radius: 150.0
$Outer Radius: 300.0
$Shockwave Speed: 100
$Shockwave name:                shockwave01
$Dinky shockwave:
+Blast Force: 100
+Inner Radius: 10
+Outer Radius: 20
+Shockwave Speed: 0.0
$Armor Factor: 1.0
$Shield Factor: 0.1
$Subsystem Factor:  0.5
$Lifetime: 72.0
$Energy Consumed: 0.0
$Cargo Size: 2.5
$Homing:  YES
+Type: ASPECT
+Turn Time:  2.0
+View Cone: 360.0
+Min Lock Time: 4.0
+Lock Pixels/Sec: 25
+Catch-up Pixels/Sec: 10
+Catch-up Penalty: 15
$Swarm: 4
+SwarmWait: 2.0
$Free Flight Time: 1.0
$LaunchSnd: 325
$ImpactSnd: 101
$FlyBySnd: -1
$Rearm Rate: 0.02
+Weapon Range: 12000
$Flags: ( "supercap" "Huge" "Big Ship" "No Dumbfire" "particle spew" "bomb" "same turret cooldown" "no lifeleft penalty" "cycle" )
$Trail:
+Start Width: 3.0
+End Width: 0
+Start Alpha: 1.0
+End Alpha: 0.0
+Max Life: 4.0
+Bitmap: missiletrail02
$Impact Explosion: ExpMissileHit1
$Impact Explosion Radius: 104.76
$Dinky impact explosion: ExpMissileHit1
$Dinky impact explosion radius: 104.76
$Piercing Impact Explosion: exp04
$Piercing Impact Radius: 52.38
$Piercing Impact Velocity: 25
$Piercing Impact Splash Velocity: -25
$Piercing Impact Variance: 20000
$Piercing Impact Particles: 10
$Pspew:
+Count: 1
+Time: 1
+Vel: 0.0
+Radius: 1.5
+Life: 0.1
+Scale: 0.0
+Bitmap: missilespew02
$Thruster Flame Effect: missilethruster02
$Thruster Glow Effect: missileglow02
Title: Re: How do missiles decide to chase CMs?
Post by: AdmiralRalwood on June 28, 2015, 08:58:25 pm
Another possible solution is to make the probability of the missile ignoring the CM drastically higher so that checking each frame has roughly the same probability as a single check with the current strength (of course, a lower framerate will make flares less effective, and a lower framerate is probably more likely in a massive missile swarm).
Title: Re: How do missiles decide to chase CMs?
Post by: jr2 on June 28, 2015, 10:51:37 pm
Mph.  Why do I get the feeling that having gameplay features rely on variables that can change from system to system is a bad idea?  I'm getting that early 90s vibe where if you tried to play an old DOS game on a Pentium you got insta-stomped as everything was playing at ludicrous speed. 

Was retail FPS capped?  If so, can't the missile be changed to check 30x every second or whatever the cap was?
Title: Re: How do missiles decide to chase CMs?
Post by: AdmiralRalwood on June 28, 2015, 11:24:24 pm
Why do you need to base the behavior on retail when we're dealing with modded weapons and countermeasures in the first place?

A better solution would be to somehow change countermeasures to not use a single cmeasure_ignore_objnum value, but inserting a vector into a countermeasure object sounds like a bad idea... maybe a pointer to a vector/dynamic array? You're adding indirection (and virtually guaranteeing CPU cache misses) for a central type of object which will need to be processed multiple times per frame, though...
Title: Re: How do missiles decide to chase CMs?
Post by: Bobboau on June 29, 2015, 02:29:03 am
an optional flag for multiplying distraction chance by frame time? another optional flag for what not remembering anything at all and re-evaluating all countermeasures all the time?
Title: Re: How do missiles decide to chase CMs?
Post by: General Battuta on June 29, 2015, 08:14:04 am
I think the most useful option might be a simple 'one roll per countermeasure' setup. That would require missiles to keep memory of which countermeasures they'd ignored, though.
Title: Re: How do missiles decide to chase CMs?
Post by: The E on June 29, 2015, 08:45:40 am
I'd go with that solution as well (properly guarded by flags, of course). It's probably closer to what :V: intended to happen than what is happening now.
Title: Re: How do missiles decide to chase CMs?
Post by: Spoon on June 29, 2015, 07:37:51 pm
I think the most useful option might be a simple 'one roll per countermeasure' setup. That would require missiles to keep memory of which countermeasures they'd ignored, though.
I always sort of assumed this is what happened, this thread showed me how wrong I was.

Title: Re: How do missiles decide to chase CMs?
Post by: AdmiralRalwood on June 29, 2015, 08:19:44 pm
I think the most useful option might be a simple 'one roll per countermeasure' setup. That would require missiles to keep memory of which countermeasures they'd ignored, though.
I'd go with that solution as well (properly guarded by flags, of course). It's probably closer to what :V: intended to happen than what is happening now.
That is the solution I was talking about here (http://www.hard-light.net/forums/index.php?topic=90008.msg1789151#msg1789151). The question is entirely how to best implement it.
Title: Re: How do missiles decide to chase CMs?
Post by: z64555 on June 30, 2015, 07:38:29 am
Eh, in theory countermeasures would apply to all warheads in its effective range, meaning that friendly missiles have just as equal a chance to be spoofed as do enemy missiles do. (Feature idea?) Naturally this isn't the behavior seen in FS.

having a vector per countermeasure seems... bad. Maybe it'd be better to set up a round-robin system like with the collision detection that schedules a check against missile/CM pairs depending on things like effective range of the CM, distance between CM and friendlies, etc?
Title: Re: How do missiles decide to chase CMs?
Post by: Spoon on June 30, 2015, 10:23:45 pm
This is the fuuutuuuuure, surely our hyper advance missile guidance systems can distinguish between friendly and hostile counter meassures!
Title: Re: How do missiles decide to chase CMs?
Post by: AdmiralRalwood on July 02, 2015, 12:29:05 am
That being said, an option for certain countermeasures/missiles to spoof/be spoofed by friendly missiles/countermeasures would be an interesting potential feature (especially for pre-FS1 or non-Freespace campaigns where missile guidance systems being able to ignore friendly countermeasures may not make sense).