Freelancer Community Network
Reminder: Internet Explorer 6 or below are NOT supported.
HomeHome
ForumForum
WikiWiki
DownloadsDownloads
ForgeForge
Multiplayer Connection Tutorial
Collapse/Expand Random Image
Collapse/Expand Login
Username:

Password:

Remember me



Lost Password?

Register now!
Collapse/Expand Chat
Collapse/Expand Who's Online
65 user(s) are online (48 user(s) are browsing Forum)

Members: 1
Guests: 64

starworld, more...
Collapse/Expand Donations
Monthly costs: -30€
Income (ads): +5€
Donations (last month): +0€

Current balance: 60€
(last updated 03/2020)

Please make a donation if you want to help keeping The-Starport online:

Bitcoin address:
Thanks!
Collapse/Expand Links
Collapse/Expand Advertisement
There are currently 116 users playing Freelancer on 41 servers.
May. 31, 2020

Browsing this Thread:   1 Anonymous Users



 Bottom   Previous Topic   Next Topic  Register To Post



[SOLVED] Fixing broken behaviour with NPC gunfire
Just popping in
Joined:
2009/8/19 4:03
Group:
Registered Users
Posts: 5
Offline
EDIT: On second thought I'm not sure which category this should've gone in, this is basically my first post here so my apologies for this potentially being in the wrong section.



I'm trying to develop NPCs into a much bigger threat in the mod I'm working on, and I've been putting a few days into how they fly. I finally have them e-killing and turning in a way that makes them turn as good as a player, and if I pass them in a joust, our noses are typically lining up around the same time as we turn on each other afterwards.

However, I *always* outdamage the NPCs on a pass, even with their accuracy set to absurd levels, and I didn't understand why until I did some testing to confirm that the AI aren't firing all their guns.

Players get given special benefits such as MUZZLE_CONE_ANGLE in Data/Constants.ini to allow them to fire their weapons in directions that would either be outside the field of view of the weapon mount, or would be blocked by their own fuselage. This is good, as otherwise half your guns wouldn't shoot at any targe you pick; gun mounts aren't on the tip of your nose so they'll always be blocked from one side or another.

The problem is that the AI doesn't seem to benefit from anything like this. By swapping which guns the AI had in their loadouts and on what hardpoints, I was able to confirm that unlike the player, they don't seem to be able to shoot guns through their own fuselage; if you only give the AI guns on the right or left side, and then you evade to the opposite side when they're attacking you, they won't be able to shoot you anymore as their ship blocks their guns.


This is a huge problem for me. I'm trying to make AI into legitimate threats, and their 1v1 flight is starting to look good, but if they can't fire all their guns, they'll never be competitive with players.

Does anyone know of a way to fix this behaviour and have AI firing all their guns all the time, just like players do?

Posted on: 3/12 4:28
Top
Re: Fixing broken behaviour with NPC gunfire
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1951
Offline
NPCs do use MUZZLE_CONE_ANGLE. It looks like each gun has a timing delay. I'll try and track down where it comes from tomorrow, but for now here's how to disable it, so NPCs continuously fire all available guns: common.dll, 08ADD7, 07->00.

Posted on: 3/12 14:04
Top
Re: Fixing broken behaviour with NPC gunfire
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1951
Offline
The timing delay is governed by the GunBlock interval settings in DATA\MISSIONS\pilots_population.ini - 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 (CEGun::CanSeeTargetObject), 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.

Posted on: 3/13 6:34
Top
Re: Fixing broken behaviour with NPC gunfire
Just popping in
Joined:
2009/8/19 4:03
Group:
Registered Users
Posts: 5
Offline
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.

Posted on: 3/13 7:17
Top
Re: [SOLVED] Fixing broken behaviour with NPC gunfire

Joined:
2016/3/29 21:54
From Cambridge, England
Group:
Registered Users
Trusted Speciality Developers
Posts: 35
Offline
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.

Posted on: 3/13 16:43
Way too ambitious for his own good.
Top
Re: [SOLVED] Fixing broken behaviour with NPC gunfire
Quite a regular
Joined:
2017/3/20 14:31
From South Yorkshire, UK
Group:
Registered Users
Posts: 103
Offline
Don't make this AI too OP man, nobody will want to fight it when you stick it in a mod

But yeah this would be good for those practising on low pop servers, keep their jousting skills on par

Posted on: 3/14 12:43
Top
Re: Fixing broken behaviour with NPC gunfire
Just popping in
Joined:
2009/8/19 4:03
Group:
Registered Users
Posts: 5
Offline
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:

Quote:

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?

Posted on: 4/2 1:38
Top
Re: [SOLVED] Fixing broken behaviour with NPC gunfire
Not too shy to talk
Joined:
2017/3/1 17:22
From Bavaria
Group:
Registered Users
$$$ Supporters $$$
Posts: 51
Offline
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.

Posted on: 4/2 20:53
FL Leuchtfeuer
Top
Re: [SOLVED] Fixing broken behaviour with NPC gunfire
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1951
Offline
Turns out CanSeeTargetObject 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

Posted on: 4/3 2:47
Top
Re: [SOLVED] Fixing broken behaviour with NPC gunfire
Just popping in
Joined:
2009/8/19 4:03
Group:
Registered Users
Posts: 5
Offline
Implemented this and it's been a huge help, thanks again Adoxa. It seems to be doing what's expected and the AI's much less annoying now.

Posted on: 4/6 13:10
Top
Re: [SOLVED] Fixing broken behaviour with NPC gunfire
Just can't stay away
Joined:
2010/2/17 20:45
From Germany
Group:
Registered Users
Senior Members
Posts: 474
Offline
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).


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.

Posted on: 4/6 13:32
How to create .SUR files - Tutorial
Top
Re: [SOLVED] Fixing broken behaviour with NPC gunfire
Not too shy to talk
Joined:
2017/3/1 17:22
From Bavaria
Group:
Registered Users
$$$ Supporters $$$
Posts: 51
Offline
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

Posted on: 4/6 19:06
FL Leuchtfeuer
Top