MeridiusIX / Modular-Encounters-Systems

Modular Encounters Systems is a Massive NPC Management Framework for the game Space Engineers
54 stars 22 forks source link

NPCShieldProvider gives out broken shields to station grids and cant tell the difference between stations or ships #301

Open stubkan opened 2 months ago

stubkan commented 2 months ago

If you want to use NPC Shield providers with your MES encounters - you can use them, but they are going to be nonfunctional on all the station grids. They have been this way for a few years now, unfortunately. This gives the player free expensive shield blocks if they find a station grid, as they can approach it safely shielded, while the station is undefended. Many exploration themed mods also have ruined structures or wrecks and they will all come with free expensive shields that dont turn on.

You can test this, by creating a world with MES, Weaponcore and Defense Shields. Then turning on NPC shield providers. All mobile grids will get shields, which work. All station grids will get shields, which don't work. Here is an example station grid encounter;

image

They are helpfully provided with shield blocks that don't work;

image

image

Furthermore, you have many options when it comes to weapon replacers - blacklist groups, whitelists, size restrictions, etc. But when it comes to shields, there seems to be nothing. Its On or Off for everything, ships, stations, big and small.

This means if you want to play an exploration game with weaponcore weapons, and have small ruins or wrecks to encounter as well as dangerous ships to encounter - you are going to get balanced dangerous ships and unbalanced free loot on ruins -or- unbalanced unshielded ships and balanced ruins with balanced loot to discover.

Unfortunately there appears no way to have one without the other - as there is no grid or group blacklist/whitelist or configuration option available for the NPC shield provider. The only functions there are, are "AddDefenseShieldBlocks" and "IgnoreShieldProviderMod" which have to be applied to specific grids directly. You'd have to manually edit all the exploration mods and add or remove shields by hand - which defeats the purpose of the NPC shield provider meant to work without mod rewriting.

This is a longstanding bug that has been around for years, and the original NPC shield provider page was aware of this, as shown on the original page;

image

I get that it is some kind of issue with station grids, but why not add a simple check of 'is this a station grid? and then if it is a station grid, then dont give it a shield. The original mod already did this, and that seems to have been lost at some point, thus breaking this function. Re-adding this check would go a long way.

stubkan commented 2 months ago

I changed line 541 of PrefabManipulation.cs from;

if (!data.Attributes.ShieldActivation && NPCShieldManager.AddDefenseShieldsToGrid(grid, true)) {

to;

if (!grid.IsStatic && !data.Attributes.ShieldActivation && NPCShieldManager.AddDefenseShieldsToGrid(grid, true)) {

And tested on my local game. Spawned a dozen grids, all station grids that spawned did not recieve any shield emitters, whereas all ship grids did. This seems like an easy fix to me. I will continue to test.

The issue of NPCShieldProviders not working on station grids is a different issue, but I think this small fix will go a long way in making shield providers usable for now.

(the var IsStatic is set in the start of ///Manipulation Order around line 340 in PrefabManipulation.cs, however I do not see any contingency in where IsStatic isn't set, and ends up being null. I am unsure if this will occur at some point. It reads the values ForceStaticGrid and DoNotForceStaticGrid from each grid, so if the grid does not have these defined... However this was tested on pure vanilla npcs, which presumably do not have any MES values at all added, so this seems to be working fine.)