determine who fired a projectile

Post » Thu Aug 11, 2011 6:42 pm

I was thinking of developing an anti-missile system a la Deus Ex and Battletech. I know it's possible to iterate over all projectiles in the air, and I know it's possible to destroy them. What's crucial for this mod, though, is that the AMS only destroys missiles that are within some set distance of the player and that were fired by enemies. There are two methods I can think of to accomplish this.

1. Determine who fired the projectile, then once it's within some set distance of the player, destroy it.
Problem with this method is, I have no idea how to determine who fired a projectile. There must be some way to do this, because projectiles that impact neutrals will make them hostile to whomever fired the projectile. I just haven't found anything in standard functions that will tell me this. Is there anything in NVSE for it?

2. Determine velocity vector, figure out if it's going towards or away from the player, then if it's going towards the player and falls within a certain set distance, destroy it.
This avoids the "who fired" problem, because anything going away from the player is most likely fired by the player or an ally, or since it's going away from the player, we don't care about it. The problem with this method is determining that a velocity vector is pointing *vaguely* towards the player, not necessarily directly at a player. Near-misses can impact walls, ceiling, or flooring around the player, still allowing the missile to damage the player, so I need to be able to account for this. I'm thinking that if I can determine that the vector is within a cone of set radius (not angle, mind you, as that will be determined by distance) whose center points towards the player and the projectile is within some distance, that should be fine, but really, what is the best way to do this?
User avatar
Jennifer Munroe
 
Posts: 3411
Joined: Sun Aug 26, 2007 12:57 am

Post » Thu Aug 11, 2011 11:59 am

1 isn't possible, so 2 is your only option. If you're constantly scanning nearby cells for projectiles you could potentially match up new references to origin NPCs by looking for the closest NPC to them when they appeared, but that'd be crazy costly. You may be better off just destroying /all/ missiles, as very few companions use missile launchers and they're not a hugely oft-used weapon. Certainly not used regularly enough that temporarily disabling your AMS when using one would be a heavy burden.
User avatar
BlackaneseB
 
Posts: 3431
Joined: Sat Sep 23, 2006 1:21 am

Post » Thu Aug 11, 2011 1:30 pm

Yeah, that's what I figured. In that case, is there a way to turn the projectile into a dud rather than explosively detonating it? Or suppose I just remove it from existence somehow, would it be possible to place some other explosion image in its place, like a puff of smoke with electricity or something to simulate EMP?
User avatar
Christie Mitchell
 
Posts: 3389
Joined: Mon Nov 27, 2006 10:44 pm

Post » Thu Aug 11, 2011 8:56 pm

Well you have the reference, so you can call any function that will run on a reference on it (like PlaceAtMe to add junk or drop an explosion).
User avatar
Benjamin Holz
 
Posts: 3408
Joined: Fri Oct 19, 2007 9:34 pm

Post » Thu Aug 11, 2011 6:42 am

Hm, my first idea would be something like this:

(Formlist A)if number of projectiles in nearby cells == 0    if clearFlag == 1        clearFlag = 0        clear A    endif    returnendiffor each projectile P:    d = distance(player, P)    ; Inner radius    if d < 3000        if P is in A            remove P from A            disable P        endif    ; Outer radius    elseif d < 6000        if P is not in A            clearFlag = 1            add P to A        endif    ; Keep list clean of anything that left the region of interest.    else        remove P from A    endif


So you have an inner and and outer radius around player. Projectiles moving towards the player move from outer to inner, so you can detect that and ignore those that move from inner to outer.
User avatar
jennie xhx
 
Posts: 3429
Joined: Wed Jun 21, 2006 10:28 am


Return to Fallout: New Vegas