[SOLVED] Fixing broken behaviour with NPC gunfire
-
-
The timing delay is governed by the GunBlock interval settings in [c]DATA\MISSIONS\pilots_population.ini[/c] - make 'em 0 and hey presto continuous fire. I’d say you probably already knew that.
Your concern looks to be a targeting issue - the gun can’t see the target ([c]CEGun::CanSeeTargetObject[/c]), so it doesn’t fire; players don’t really have that problem, since they shoot at the cursor. I think it’d take a plugin to make configurable, but if you want to experiment with seeing everything: common.dll, 038590, 83EC345356->B001C20400.
-
Amazing, thank you - your latest offset fixed the issue. With the gun being able to see everything, the AI is firing their weapons as a player would.
I can see what you mean about the worth of a plugin to configure the degree to which the AI can do this (shooting above the ship in particular seems to be a little more generous than what a player would usually do using a crosshair and their monitor) but it doesn’t immediately seem like a big problem.
This is a huge positive step forward for me in general with the AI, thanks so much.
I can’t seem to get YouTube embedding working but here’s a preview of the fix in action - the AI has a single gun in their loadout on the side of their fuselage, and you can see as it fires it in all directions.
-
I wonder if it would work the other way too. Either removing the player version of muzzle cone constraint, or preventing players from shooting through their ship. The latter one I’d really like to see if it is possible; seeing players shoot guns through their ship was always so immersion breaking for me.
-
Yeah, the idea is to make them as human-like and competitive as possible first, and then scale back things like their accuracy and evasive abilities as needed to make easier versions for each area or mission difficulty.
Speaking of which:
adoxa wrote:
I think it’d take a plugin to make configurable, but if you want to experiment with seeing everything: common.dll, 038590, 83EC345356->B001C20400.I’ve been testing for a while with this and it’s a huge upgrade but it’s definitely also true that them seeing everything is not ideal. It allows the AI to shoot at crazy angles players never would be able to while also flying their ships. For example, the Falcon’s weapons can fire 90 degrees straight up - a player would have to use turret mode to accomplish this, but the AI just does it all the time now.
Ideally we want to restrict the AI to a halfway between vanilla behaviour and seeing everything - give them a ‘cone of fire’ similar to how a player can only click on things within the constraints of their monitor. Probably even make it a little less than the player’s absoloute field of fire to simulate the fact that a player can’t really evade in one direction and shoot in another as both use the mouse cursor.
In other words, most of the time we want the AI to be firing in a modest field of fire centered on the direction of their nose, and be pointing their noise at their target. That seems the best way to keep fighting the AI feeling fun and not too overwhelming.
My question then is, how would I be able to go about this plugin that would make things configurable? This behaviour is a huge upgrade to vanilla, but I’d love to be able to configure to what degree the AI can see rather than the flat ‘see everything’ so that I can abstract this field of fire behaviour. However I know absoloutely nothing about plugins or programming them. Could someone help me create it?
-
Well, as a workaround you could try limiting the weapons firing angles to realistic values or lower their tracking speed.
This way I was able to create weapons that fire at where they are pointing in my mod.Things you can try to tweak are:
DATA\Constants.ini MUZZLE_CONE_ANGLE
DATA\weapon_equip.ini turn_rate,force_gun_ori
DATA\Equipment\models\weapons*.cmp Rev Data Axis Max
(very time consuming)I don’t recommend to use force_gun_ori, as your guns will fire even if they are not able to shoot at the target point.
-
Turns out [c]CanSeeTargetObject[/c] has a parameter, which is the muzzle cone angle. It seems to be fixed to 3° for guns and 22.5° for missiles. Here’s the patch for the guns:
common.dll, 08A185, 0.0523599f = NPC muzzle cone angle (radians) PART 1
common.dll, 08AE95, 0.0523599f = NPC muzzle cone angle (radians) PART 2 -
[d]To summarize I understand the problem and solution correctly:
Each Hardpoint (on ship models and weapon models each) have a range of movement. Players can use those freely (+ the muzzle cone tolerance degree given in constants.ini to “shoot around the corner”).
NPCs do not use these ranges for guns and missiles. Only for turrets (else no station and cruiser would work).
Instead NPCs take the default direction vector of gun hardpoints + fixed 3° for guns or 22,5° for missiles.
Meaning that even if a gun could be rotated 360° they would only fire almost straight forward.Is that correct?
And then the fix means now that NPCs, given a higher degree by Adoxa’s hack, could also use the HP movement range freely (if using a big range set in the offset).[/d]
Ok, I just noticed myself that I misunderstood the problem. The NPCs do not use the player muzzle cone entry from constants.ini, but instead the fixed ones given by Adoxa. Allowing them to also shoot “around the corner”, so to say.
-
I performed a short test and it looks like NPCs move their weapons around during combat.(not just the turrets)
If this angle is used during the calculations is hard to tell, but it looks like it is.
I think the only difference is that NPCs do not use the Muzzle_Cone_Angle from constants.ini, but a hardcoded value from common.dll