Specific resistance for energy shields

Things that we aren't going to implement
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Specific resistance for energy shields

Post by darkfrei »

Hi! Is it possible to make specific resistances for energy shields like it specified by armor?

Power armor (part):

Code: Select all

data.raw.armor["power-armor-mk2"].resistances[1].type = "physical" 
data.raw.armor["power-armor-mk2"].resistances[1].decrease = 10 
data.raw.armor["power-armor-mk2"].resistances[1].percent = 40 
data.raw.armor["power-armor-mk2"].resistances[2].type = "acid" 
data.raw.armor["power-armor-mk2"].resistances[2].decrease = 10 
data.raw.armor["power-armor-mk2"].resistances[2].percent = 40 
data.raw.armor["power-armor-mk2"].resistances[3].type = "explosion" 
data.raw.armor["power-armor-mk2"].resistances[3].decrease = 60 
data.raw.armor["power-armor-mk2"].resistances[3].percent = 50 
data.raw.armor["power-armor-mk2"].resistances[4].type = "fire" 
data.raw.armor["power-armor-mk2"].resistances[4].decrease = 0
data.raw.armor["power-armor-mk2"].resistances[4].percent = 70 
Energy shield:

Code: Select all

data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].type = "energy-shield-equipment" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].name = "energy-shield-mk2-equipment" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].sprite.filename = "__base__/graphics/equipment/energy-shield-mk2-equipment.png" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].sprite.width = 64 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].sprite.height = 64 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].sprite.priority = "medium" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].shape.width = 2 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].shape.height = 2 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].shape.type = "full" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].max_shield_value = 150 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].energy_source.type = "electric" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].energy_source.buffer_capacity = "180kJ" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].energy_source.input_flow_limit = "360kW" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].energy_source.usage_priority = "primary-input" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].energy_per_shield = "30kJ" 
data.raw["energy-shield-equipment"]["energy-shield-mk2-equipment"].categories[1] = "armor"
Suggested prototype (parts):

Code: Select all

data.raw["energy-shield-equipment"]["physical-energy-shield-mk2-equipment"].resistances[1].type = "physical" 
data.raw["energy-shield-equipment"]["physical-energy-shield-mk2-equipment"].resistances[1].decrease = 10 
data.raw["energy-shield-equipment"]["physical-energy-shield-mk2-equipment"].resistances[1].percent = 40 

Code: Select all

data.raw["energy-shield-equipment"]["acid-energy-shield-mk2-equipment"].resistances[1].type = "acid" 
data.raw["energy-shield-equipment"]["acid-energy-shield-mk2-equipment"].resistances[1].decrease = 10 
data.raw["energy-shield-equipment"]["acid-energy-shield-mk2-equipment"].resistances[1].percent = 40 

Code: Select all

data.raw["energy-shield-equipment"]["explosion-energy-shield-mk2-equipment"].resistances[1].type = "explosion" 
data.raw["energy-shield-equipment"]["explosion-energy-shield-mk2-equipment"].resistances[1].decrease = 60
data.raw["energy-shield-equipment"]["explosion-energy-shield-mk2-equipment"].resistances[1].percent = 50

Code: Select all

data.raw["energy-shield-equipment"]["fire-energy-shield-mk2-equipment"].resistances[1].type = "fire" 
data.raw["energy-shield-equipment"]["fire-energy-shield-mk2-equipment"].resistances[1].decrease = 0
data.raw["energy-shield-equipment"]["fire-energy-shield-mk2-equipment"].resistances[1].percent = 70
So you can stack specific resistances together for specific situations. Now we have only max_shield_value = 150, but it doesn't defined the type of damage resistance.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Specific resistance for energy shields

Post by eradicator »

How would you want that to work if the player has several different types of shield equipment? I.e. 6*Mk1, 4*Mk2?
Intuition can say either "average" or "maximum of each resitance" depending on what kind of game you played before.
(Or does factorio actually calculate shields one after another?)
Rseding91
Factorio Staff
Factorio Staff
Posts: 14601
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Specific resistance for energy shields

Post by Rseding91 »

How would you imagine having different shields with different resistances working when the game goes to apply damage to shields?
If you want to get ahold of me I'm almost always on Discord.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Specific resistance for energy shields

Post by darkfrei »

Rseding91 wrote:How would you imagine having different shields with different resistances working when the game goes to apply damage to shields?
The same way like now applied damage to health. But to shields. It can be also normal armor elements, like bomber suit or like by firefighters.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Specific resistance for energy shields

Post by darkfrei »

eradicator wrote:How would you want that to work if the player has several different types of shield equipment? I.e. 6*Mk1, 4*Mk2?
Multiplicative or not additive stacking: r = 1- (1-r_1)*(1-r_2)*(1-r_3)
If mk1 has 0.2 and mk2 has 0.4 resistance, than
2xMk1 = 0.36
1xMk1 + 1xMk2 = 0.52
2xMk2 = 0.64

6xMk1 = 0.74
4xMk2 = 0.87
6xMk1 + 4xMk2 = 0.97
Rseding91
Factorio Staff
Factorio Staff
Posts: 14601
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Specific resistance for energy shields

Post by Rseding91 »

darkfrei wrote:
eradicator wrote:How would you want that to work if the player has several different types of shield equipment? I.e. 6*Mk1, 4*Mk2?
Multiplicative or not additive stacking: r = 1- (1-r_1)*(1-r_2)*(1-r_3)
If mk1 has 0.2 and mk2 has 0.4 resistance, than
2xMk1 = 0.36
1xMk1 + 1xMk2 = 0.52
2xMk2 = 0.64

6xMk1 = 0.74
4xMk2 = 0.87
6xMk1 + 4xMk2 = 0.97
That's not how the game does resistances. Resistances are a per-entity thing - not a merged set of all resistances. In the character example the character has resistances, the armor has resistances and they're both calculated separately. first the armor then the character. If shields had resistances it would calculate them one at a time meaning having different resistances across different shields just wouldn't work.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Specific resistance for energy shields

Post by Arch666Angel »

Rseding91 wrote:
darkfrei wrote:
eradicator wrote:How would you want that to work if the player has several different types of shield equipment? I.e. 6*Mk1, 4*Mk2?
Multiplicative or not additive stacking: r = 1- (1-r_1)*(1-r_2)*(1-r_3)
If mk1 has 0.2 and mk2 has 0.4 resistance, than
2xMk1 = 0.36
1xMk1 + 1xMk2 = 0.52
2xMk2 = 0.64

6xMk1 = 0.74
4xMk2 = 0.87
6xMk1 + 4xMk2 = 0.97
That's not how the game does resistances. Resistances are a per-entity thing - not a merged set of all resistances. In the character example the character has resistances, the armor has resistances and they're both calculated separately. first the armor then the character. If shields had resistances it would calculate them one at a time meaning having different resistances across different shields just wouldn't work.
Then maybe just get the highest value of all shield entities and ignore the rest?
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Specific resistance for energy shields

Post by darkfrei »

Rseding91 wrote:That's not how the game does resistances. Resistances are a per-entity thing - not a merged set of all resistances. In the character example the character has resistances, the armor has resistances and they're both calculated separately. first the armor then the character. If shields had resistances it would calculate them one at a time meaning having different resistances across different shields just wouldn't work.
So if I have two resistances: 20% by armor and 20% by character, what damage I get from 100 damage?
What if character 20%, armor 40%?
What if character 40%, armor 40%?
answer
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Specific resistance for energy shields

Post by eradicator »

darkfrei wrote:If mk1 has 0.2 and mk2 has 0.4 resistance, than
2xMk1 = 0.36 (damage = 64%)
1xMk1 + 1xMk2 = 0.52 (damage = 48%)
2xMk2 = 0.64 (damage = 36%)
That sort of multiplicatoin is ridiculous. It would mean that if you stack 10 shields with 10% reduction "each" you end up with 65% total reduction. Far too strong. Also as Rsed says (and as the game GUI and general player experience suggest) all shield "emitters" merge into one big shield bubble, they're not seperate.

So for the shield bubble to have resistances we need to take the average of all emitters (==shield equipment):

Average resistance = 1 - ( ( (emitter1_count * emitter1_shield_capacity * emitter1_resistance) + (emitter2_count * emitter2_shield_capacity * emitter2_resistance) + (etc...) ) / total_emitter_capacity ).


Example 1:
10 Emitters with 0.6 resistance and 100 hp each:
→ 1 - ((10 * (1-0.6) * 100) / (10 * 100)) = 0.6
As expected using multiple identical emitters does not change resistance.

Example 2:
5 Emitters with 0.2 resistance and 500 hp each and 5 Emitters with 0.9 resistance and 100 hp each:
→ 1 - ( ( (5*(1-0.2)*500) + (5*(1-0.9)*100) ) / (5*500 + 5*100) ) = 0.31666
The less resistant emitters have much more capacity and thus strongly reduce the effect of the high resistance emitters.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Specific resistance for energy shields

Post by darkfrei »

eradicator wrote:That sort of multiplicatoin is ridiculous. It would mean that if you stack 10 shields with 10% reduction "each" you end up with 65% total reduction.
Rseding91 wrote:In the character example the character has resistances, the armor has resistances and they're both calculated separately. first the armor then the character.
1. The biter bites you with 100 hp damage.
2. The armor has 40% resist and you must get (100 hp * 60%) = 60 hp damage.
3. The character has 20% resist and you must get (60 hp * 80%) = 48 hp damage.

The same you get when you calculate it in opposite direction. The main formula is also: resist = 1-(1-resist_armor)*(1-resist_character) = 1-(1-0.4)*(1-0.2) = 1-0.48 = 0.52
So, 20% resist + 40% resist = 52 % resist.
Post Reply

Return to “Won't implement”