NPC detection

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

NPC detection

Postby trojanuch » 02 Oct 2015, 15:07

I will re-post my comment from ModDB here as it got buries fast.

trojanuch:
Guys, what's wrong with the NPC detection times?

No matter what vision setting I apply to them (especially default CoC ones) I cannot force them to start shooting at me properly fast. It's always like 2-3 secs of visibility before they open fire.

Sometimes they are unable to see me at all - like when I am standing in the window or only stick out partially out of cover. This get's especially prominent in low light conditions.

Generaly it seems like it takes them much longer / harder to reach the regular visibility_treshold - on vision settings on which in regular CoP they react almost instaneusly, here they are like sitting ducks. Also they almost never shoot while moving (but that might be connected with this delayed shooting altogheter).

Was there anything in the scripts which has changed the rate at which they are able to react? If so, where can it be edited to less forgiving values?


kcs:
Scripting/config wise, I think it is handled trough xr_danger.script and config file "..\ai_tweaks\xr_danger.ltx"

I don't seee anything unusual there, might be also that something is wrong how game calculate conditions "is_dark_night" and similar, some bug might sliped in unnoticed.

You should try to change values for danger_inertion in xr_danger.ltx to see if there is improvment on AI detection.

And take everything that I said with grain of salt, someone from TeamEpic should confirm or deny my observations trough scripts.

Based on question asked, I think that Trojanuch have already done more than just unpacking db files :)


trojanuch:
I think it might actually be an engine change. In m_stalker.ltx there's an info regarding the formula used to calculate vision - I don't know if it's CoP vanilla formula or the new one - created especially for CoC.

Aside from actual calculation though - info says that value has to get equal or above the visibility_treshold (this part actually has not changed) - however, even if I've lowered the visibility_treshold to sth 5.0 (40x lower than our setting and 4x lower than CoC default setting) the improvement in NPC reaction is slight or negligible.

Same goes for other params - I've pushed time_quant, transparency and luminocity tresholds to extreme values and still no proper effect - detection is delayed, NPCs fire short bursts like if the detection got broken and had to be reestablished after each shot (normally they queue bursts ahead and even fire last of them after you hide, producing sort of 'pin fire' effect).

There's definately something funny going on here and it doesn't seem to be scripts.

Hope we'll get the reply from authors soon.


So - I would very grateful for any explanation regarding above.

Gratz again for the work awesomely done with the release and all :)

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1371
Joined: 26 May 2012, 22:26

Re: NPC detection

Postby Alundaio » 02 Oct 2015, 15:52

No. I didn't change any engine code for detection. This problem seems to be new as it wasn't noticed in leak and I'm unsure what is causing it.

Also, it depends on what NPCs you are testing on. There is a scheme, xr_camper, which is entirely scripted and it makes AI retarded. It is used in many places in CoC but this scheme is mainly used to force NPCs to stay on waypoints during combat, so it's good for NPCs who stand on tops of buildings or snipers. I see most complaints about bad AI directed at Deadcity, when a majority of the NPCs there use the camper scheme, which is mostly a vanilla scheme so it is no wonder why someone would think this.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

Re: NPC detection

Postby trojanuch » 02 Oct 2015, 16:04

I'll try to record a comparison movie or sth. - I've just today tested Misery and CoC with more or less the same weather conditions and with same vision, dispersion and fire_queue setting - experiences are completely different. The map on which I was testing it was Military Warehouses.

I first noticed this when I got a task to go to camp in the village to 'defend a point' - it turned out there was a single Dutier there. It was dusk. I noticed that on purely Misery settings he is unable to notice me at all before I come to like 2-3 meters away. Then I tried CoC settings - it was slightly better but again reaction was very slow and I had to sprint before his eyes (to speed up reaction due to velocity_factor) before he opened fire. Then I tried Misery setting again but with luminocity_factor set to very low value - this is so far the best but still far from proper.

I then teleported to Duty outpost where few squads of Loners hand-out. Each time I start combat I can take them out with Makarov without a hassle - they do shoot but very slowly.

I then started experimenting with values further but nothing seems to work - even lowering the visibility_treshold to sth like 5 and multiplying time_quant 10x.

Same experience has been confirmed by other ppl on the team trying it out. So - I am clueless at this point.

I will now try 100% purely, pure CoC and report here - maybe it's actually something with the merge but I've disabled the camo features (which is the only thing which slightly might affect this but in thruth it works differently) and cannot think of anything else which could interfere with detection (all AI script are 100% CoC ones).

btw - has Bangalore shared with you the little package I've sent him lately? :)

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1371
Joined: 26 May 2012, 22:26

Re: NPC detection

Postby Alundaio » 02 Oct 2015, 18:31

Do you have "AI Die In Anomaly" enabled? If so, try detection with this feature off and tell me if you notice quicker reaction.

I think making Space Restrictors visible for AI is causing a detection problem.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

Re: NPC detection

Postby trojanuch » 02 Oct 2015, 19:30

Hmmm - that could actually be the case. I will test it in a sec - I am at this moment compressing the video footage I have captured on 100% pure CoC. The issues were still there - NPC vision erratically jumped from full visibility to 0 + they were completely unable to notice me across certain areas - like if there was an 'invisible wall' between us or sth (example is bridge in military base - when I was on the bridge then noone standing north of it was able to detect me no matter what I did). I will upload asap. Then I'll test with 'AI die in anomaly off' and report again.

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

Re: NPC detection

Postby trojanuch » 02 Oct 2015, 20:05

Yeah - that was it :)

I've just wasted an hour capturing footage lol

Anyway - this combat planner info showing up on the right is pretty cool. I understand that thos 'Mgr Act' lists commands directly from the previously hardcoded goap combat planner?

It's cool what has been achieved with this project (and X-Ray open), so many stuff bein vague guesses on how stuff works now being accessible.

btw what do the files in the \ai folder do and how do you edit them?

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1371
Joined: 26 May 2012, 22:26

Re: NPC detection

Postby Alundaio » 02 Oct 2015, 20:26

Yeah, I just figured it out that this was the cause. Sadly this feature was added a day before we released CoC which I shouldn't have done with no testing. I guess GSC disabled npc dying in anomaly for a good reason.

Yeah, the debug stuff I spent a lot of time on but it saves a lot of time and helped me understand a lot about the engine. Yes, it lists actions from hardcoded combat and danger planners. If NPC is doing something wrong this is the first place to look to see what action he is performing and what it is conflicting with.

The .efd files? These are complex formula packed into a database, I have not figured out how to alter them as it seems to be created with an old tool. Those ef_* fields you see everywhere are used by these equations to determine AI behavior. Most of them aren't used anymore since they are used by the now disabled offline alife. But weapon selection still uses ef_weapon_type which really sucks! So there is no way to change how npcs decide which weapons to use without re-writing this code in engine.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

Re: NPC detection

Postby trojanuch » 03 Oct 2015, 16:47

Well - regarding the weapon selection I think it's not that bad at it's core (NPCs in fact acknowledge their surroundings and position of enemy and do change the gun depending on it) - however it fails at execution. I think that it basically lacks two things:
1. NPCs should always prioritize weapon with best condition and use it first and foremost. Only the weapon which is maximally like 15% in worse condition than the one they have equiped should be considered as switchable to
2. Once weapon is switched there should be sth like a cooldown timer before another switch can be made
This second point is more important as it would fix the issue of NPCs constantly switching between weapons (especially if they have a shotgun on them) as mutatns circle around which in most cases prohibits them from taking a single shot. So a 'simple' prohibition of those rapid switches would fix like 90% of problems which this hardcoded system introduces.

Alternatively - I don't know if you remember - but part of original Rulix package for CoP contains an alternative weapons manager. I still have those files on my rig should you like to see them.
I remember that on one point long time ago we've been discussing it's implementation and I think it has even been in for a while. However later on it has been dropped for some reason - don't exacly remember why (maybe it crashed or sth and you deemed it unsalvagable at that time).
However - when it was actually working - it prohibited those rapid switches and NPCs could be armed with rifle and shotgun without rendering themselves useless against mutants.
Maybe now, with expanded options / knowledge those old scripts could prove usefull?

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

Re: NPC detection

Postby trojanuch » 03 Oct 2015, 18:00

Also Bangalore has written me that there is a saved objects limitation of 65,535.

He also said that the save got corrupt for him after 3 in-game days when playing the package from me (the number got from 31818 to 42.700).

Any ideas how to optimize the usage of this space (as I understand that it cannot be expanded?) other than perhaps clearing the items sold to traders and despawning all non-crucial a-life on distant maps?

User avatar
Bangalore
Explorer
Posts: 640
Joined: 09 Jun 2012, 19:02
Contact:

Re: NPC detection

Postby Bangalore » 03 Oct 2015, 18:17

trojanuch wrote:Also Bangalore has written me that there is a saved objects limitation of 65,535.

He also said that the save got corrupt for him after 3 in-game days when playing the package from me (the number got from 31818 to 42.700).


No, i could play further with my last save before blowout, and i still play. But when I saved during the blowout, this save became corrupted, i couldn't reload it.
Now i have 44.700 spawn objects, and still growing with each save, as i progress from map to map.
"Some sort of pressure must exist; the artist exists because the world is not perfect. Art would be useless if the world were perfect, as man wouldn’t look for harmony but would simply live in it. Art is born out of an ill-designed world."

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

Re: NPC detection

Postby trojanuch » 03 Oct 2015, 19:06

Oh - ok, sorry for misunderstanding you. I've just played for like 3 in-game hours moving around Military Warehouses. The cound is so far stable at ~38k jumping forwads and backwards.

btw were it is defined which levels will use which loading screen textures from textures\intro folder? I cannot find a config for that anywhere in the data be it configs\ui or level folders.

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1371
Joined: 26 May 2012, 22:26

Re: NPC detection

Postby Alundaio » 03 Oct 2015, 19:19

trojanuch wrote:Also Bangalore has written me that there is a saved objects limitation of 65,535.

He also said that the save got corrupt for him after 3 in-game days when playing the package from me (the number got from 31818 to 42.700).

Any ideas how to optimize the usage of this space (as I understand that it cannot be expanded?) other than perhaps clearing the items sold to traders and despawning all non-crucial a-life on distant maps?


It's true you can only have 65534 game object ids with 65535 being invalid and 0 always being actor. You would probably have to despawn stuff and change the way stashes work (only spawn items when the player opens box). Code could be added to flag dropped items to be removed after leaving a map and stuff like that.

There are also limitations on Net Packet size but you need to start using alife_storage_manager.script instead which can encode and save any lua data type to disk practically making this limitless.

loadscreen I think is hardcoded except for tips.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

kcs123
Scavenger
Posts: 10
Joined: 11 Oct 2015, 12:41

Re: NPC detection

Postby kcs123 » 11 Oct 2015, 14:07

Let me join a party here.

Few thoughts regarding stability/performance. Without knowlage how to disable Smart terain from being processed on distant map, I have made something similar for next Misery release. I have created function that checks all in game objects, and if it is on any other map than actor stands on, NPC squad is despawned from map.

Furthermore, function have some safety checks. It check if NPC is also story object and alows despawn only if NPC is not important. Trader squad, faction comanders, mechanics, all important NPC in game have set story_id flag, so they were protected from delete. Trough testing we were found that this might not be enough, so another ltx file is also checked and if there is spawn section name listed there, that NPC is also protected from despawn.

At the same time, to prevent further spawns, all S_T have condition flag similar like this:

Code: Select all

spawn_num = {=actor_on_level(zaton)} 1, 0


With combination of S_T configuration and new despawn function it is possible to have more crowded map where actor stand without performance loss and stability issues. There is some unwanted effect with S_T configuration that have actor_on_level set on. S_T is not completely disabled, it's timer is still calculated, but when it reach zero, squad is not spawned, timer continue to decrease and goes negative.

Here comes interesting effect form this: when actor comes to map with S_T that have negative counter, that S_T is populated imediately with defined squad. Result from this is that we have rich alife at map where actor stand on and on previous map squads were despawned at the same time.
After few minutes spending on map, overcrowded alife is normalized by itself - trough regular alife simulation, squads of oposite factions kill each other and S_T spawns continue as usual.

I tested this new function in CoC and it works quite well, but some further modification is needed. That is why I'm writing all this.
New function is required, similar to "actor_on_level" function in xr_conditions.script, but it should return value if actor is on linked level.
Let's call it "actor_on_linked_level" for now. That one should be used trough S_T configs for squads that were spawned on linked map but they travel to other map, where actor stands on, for example. Some S_T should have condition "actor_on_level" while only few should have no condition at all.

In my despawn function, I have used "simulation_objects.is_on_the_same_level(obj, alife():actor())" to check if some NPC can be despawned or not.
There is also need to have similar function, to delete NPC only on distant map, not on all outher maps that includes linked levels.

Furthermore, I only see problem with despawn function when deals quest NPCs - when you need to kill some NPC or rescue hostage or something like that. Those quest NPCs need to be chosen from section names that have STORY_ID flag set properly or need to be of known spawn section names that can be enlisted in ltx file.

I will try to make my own function for all this, but I can't tell when it will be available for public usage. You might want to include something like that in next patch, it is not too hard to create and might improve CoC performance even further.
I can share you despawn function if you are interested, to save you some time, but I need some time to revise all S_T and check all quest NPC squads. so I'm telling all this because I think you will be able to release CoC patch much sooner.

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1371
Joined: 26 May 2012, 22:26

Re: NPC detection

Postby Alundaio » 11 Oct 2015, 17:48

In CoC, I used to remove squads after a cap was reached but this was removed, it wasn't needed anymore. There is code in place to prevent squad and smart terrain updates on other levels which substantially improves performance. Other levels are frozen until player is on a linked level. If you look in _g.script you will see a variable you can change to disable this new feature and see how performance is without it. Despawning squads would screw up a few tasks, like bounty hunting and some quests are only available if simulation squads are entered to a smart, but I suppose those can be altered. There are features that people want to add to CoC like Dynamic News which depend on offline alife.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

trojanuch
Scavenger
Posts: 10
Joined: 27 May 2012, 17:31

Re: NPC detection

Postby trojanuch » 12 Oct 2015, 03:50

Some good insights above - thx!

Just few fast questions from me this time around:

1. I get a lot of no-log crashes on Dead City - i gather that it has been reported and fix is comming in next rls?

2. How do I disable the helicopter from spawning altogheter? I find it very difficult to balance with it's current AI (primarly immediate auto-detection from the other side of map). It would be best for me to get rid of it totally from all maps, but if that's not possible can it be made at least to despawn from time to time and not re-appear for a good while?
Alternatively - it would be cool to fiddle with it's detection but I understand it follows a completely new AI scheme so it woudn't be that easy would it?

3. How do I increase the overall odds for stuff appearing in random stashes (so that the loot[x] tiers are still there, just that all of them have +xx% higher chance of spawning an item)? There are some params for it in coc_treasure_manager.script but I find them somewhat unclear.

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1371
Joined: 26 May 2012, 22:26

Re: NPC detection

Postby Alundaio » 12 Oct 2015, 20:44

2. Helicopter only attacks when flagged as an enemy. For the player to get flagged he either has to attack a squad, most likely military, and they have to radio in the chopper or the player has entered an unrestricted area, usually a military camp that the helicopter has a job at. To lose the flag the player can simply sleep or leave the level. Aggro is completely gone until he repeats the above.

Helicopters are now spawned like squads. You should find spawn_heli sections in respawn params on their maps. I don't know the names off hand but when I look for them I just open all marsh smart ltxes in NP++ then look for it.

Helicopter uses smart terrain and can select jobs, just like squads now (only within the level because of notorious physic object bug). If you set up waypoints in LE for a heli at a smart, following the gulag_general directions, then you can add heli = 1 in simulation object props and they will go to that smart. The smart they are currently taking jobs because a defending area, they will attack anything within the radius of this smart.

Helicopters only attack within 250m radius and I will re-add their visibility threshold stuff in next patch.

3. It's not a simple chance algorithm. It's basically weights things in tiers. A roll is made for which tier, then a lucky roll is made to add to this. The script cycles down rewarding from lower tiers until there are no points left. Seems complex but it just makes sure that the player is rewarded fairly and that rolls are consistent. By consistent I mean every time you roll and get tier 4 it will always yield similar results. But a scripter shouldn't have difficult just changing this to use xr_box or death dropped system.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest