mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-09 13:37:02 +02:00
Merge pull request #289 from ComfyFactory/fish_defender_v2
Fish v2 - fix that modded turrets are also included in the turret limit
This commit is contained in:
commit
38e2a36116
@ -1042,8 +1042,8 @@ local function on_entity_died(event)
|
||||
|
||||
local entity_limits = Public.get('entity_limits')
|
||||
|
||||
if entity_limits[event.entity.name] then
|
||||
entity_limits[event.entity.name].placed = entity_limits[event.entity.name].placed - 1
|
||||
if entity_limits[event.entity.type] then
|
||||
entity_limits[event.entity.type].placed = entity_limits[event.entity.type].placed - 1
|
||||
update_fd_stats()
|
||||
end
|
||||
end
|
||||
@ -1121,16 +1121,16 @@ local function on_built_entity(event)
|
||||
return
|
||||
end
|
||||
local entity_limits = Public.get('entity_limits')
|
||||
if entity_limits[entity.name] then
|
||||
if entity_limits[entity.type] then
|
||||
local surface = entity.surface
|
||||
|
||||
if entity_limits[entity.name].placed < entity_limits[entity.name].limit then
|
||||
entity_limits[entity.name].placed = entity_limits[entity.name].placed + 1
|
||||
if entity_limits[entity.type].placed < entity_limits[entity.type].limit then
|
||||
entity_limits[entity.type].placed = entity_limits[entity.type].placed + 1
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
text = entity_limits[entity.name].placed .. ' / ' .. entity_limits[entity.name].limit .. ' ' .. entity_limits[entity.name].str .. 's',
|
||||
text = entity_limits[entity.type].placed .. ' / ' .. entity_limits[entity.type].limit .. ' ' .. entity_limits[entity.type].str .. 's',
|
||||
color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
}
|
||||
)
|
||||
@ -1140,7 +1140,7 @@ local function on_built_entity(event)
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
text = entity_limits[entity.name].str .. ' limit reached.',
|
||||
text = entity_limits[entity.type].str .. ' limit reached.',
|
||||
color = {r = 0.82, g = 0.11, b = 0.11}
|
||||
}
|
||||
)
|
||||
@ -1166,15 +1166,15 @@ local function on_robot_built_entity(event)
|
||||
|
||||
local entity_limits = Public.get('entity_limits')
|
||||
|
||||
if entity_limits[entity.name] then
|
||||
if entity_limits[entity.type] then
|
||||
local surface = entity.surface
|
||||
if entity_limits[entity.name].placed < entity_limits[entity.name].limit then
|
||||
entity_limits[entity.name].placed = entity_limits[entity.name].placed + 1
|
||||
if entity_limits[entity.type].placed < entity_limits[entity.type].limit then
|
||||
entity_limits[entity.type].placed = entity_limits[entity.type].placed + 1
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
text = entity_limits[entity.name].placed .. ' / ' .. entity_limits[entity.name].limit .. ' ' .. entity_limits[entity.name].str .. 's',
|
||||
text = entity_limits[entity.type].placed .. ' / ' .. entity_limits[entity.type].limit .. ' ' .. entity_limits[entity.type].str .. 's',
|
||||
color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
}
|
||||
)
|
||||
@ -1184,7 +1184,7 @@ local function on_robot_built_entity(event)
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
text = entity_limits[entity.name].str .. ' limit reached.',
|
||||
text = entity_limits[entity.type].str .. ' limit reached.',
|
||||
color = {r = 0.82, g = 0.11, b = 0.11}
|
||||
}
|
||||
)
|
||||
@ -1219,8 +1219,8 @@ end
|
||||
local function on_player_mined_entity(event)
|
||||
local entity_limits = Public.get('entity_limits')
|
||||
|
||||
if entity_limits[event.entity.name] then
|
||||
entity_limits[event.entity.name].placed = entity_limits[event.entity.name].placed - 1
|
||||
if entity_limits[event.entity.type] then
|
||||
entity_limits[event.entity.type].placed = entity_limits[event.entity.type].placed - 1
|
||||
update_fd_stats()
|
||||
end
|
||||
end
|
||||
@ -1228,8 +1228,8 @@ end
|
||||
local function on_robot_mined_entity(event)
|
||||
local entity_limits = Public.get('entity_limits')
|
||||
|
||||
if entity_limits[event.entity.name] then
|
||||
entity_limits[event.entity.name].placed = entity_limits[event.entity.name].placed - 1
|
||||
if entity_limits[event.entity.type] then
|
||||
entity_limits[event.entity.type].placed = entity_limits[event.entity.type].placed - 1
|
||||
update_fd_stats()
|
||||
end
|
||||
end
|
||||
|
@ -2,10 +2,10 @@ local Event = require 'utils.event'
|
||||
local Public = require 'maps.fish_defender_v2.table'
|
||||
|
||||
local slot_upgrade_offers = {
|
||||
[1] = {'gun-turret', 'gun turret'},
|
||||
[2] = {'laser-turret', 'laser turret'},
|
||||
[1] = {'ammo-turret', 'gun turret'},
|
||||
[2] = {'electric-turret', 'laser turret'},
|
||||
[3] = {'artillery-turret', 'artillery turret'},
|
||||
[4] = {'flamethrower-turret', 'flamethrower turret'},
|
||||
[4] = {'fluid-turret', 'flamethrower turret'},
|
||||
[5] = {'land-mine', 'land mine'}
|
||||
}
|
||||
|
||||
@ -33,20 +33,20 @@ local function refresh_market_offers()
|
||||
|
||||
local entity_limits = Public.get('entity_limits')
|
||||
|
||||
local str1 = 'Gun Turret Slot for ' .. tostring(entity_limits['gun-turret'].limit * entity_limits['gun-turret'].slot_price)
|
||||
local str1 = 'Gun Turret Slot for ' .. tostring(entity_limits['ammo-turret'].limit * entity_limits['ammo-turret'].slot_price)
|
||||
str1 = str1 .. ' Coins.'
|
||||
|
||||
local str2 = 'Laser Turret Slot for ' .. tostring(entity_limits['laser-turret'].limit * entity_limits['laser-turret'].slot_price)
|
||||
local str2 = 'Laser Turret Slot for ' .. tostring(entity_limits['electric-turret'].limit * entity_limits['electric-turret'].slot_price)
|
||||
str2 = str2 .. ' Coins.'
|
||||
|
||||
local str3 = 'Artillery Slot for ' .. tostring(entity_limits['artillery-turret'].limit * entity_limits['artillery-turret'].slot_price)
|
||||
str3 = str3 .. ' Coins.'
|
||||
|
||||
local current_limit = 1
|
||||
if entity_limits['flamethrower-turret'].limit ~= 0 then
|
||||
current_limit = current_limit + entity_limits['flamethrower-turret'].limit
|
||||
if entity_limits['fluid-turret'].limit ~= 0 then
|
||||
current_limit = current_limit + entity_limits['fluid-turret'].limit
|
||||
end
|
||||
local str4 = 'Flamethrower Turret Slot for ' .. tostring(current_limit * entity_limits['flamethrower-turret'].slot_price)
|
||||
local str4 = 'Flamethrower Turret Slot for ' .. tostring(current_limit * entity_limits['fluid-turret'].slot_price)
|
||||
str4 = str4 .. ' Coins.'
|
||||
|
||||
local str5 = 'Landmine Slot for ' .. tostring(math.ceil((entity_limits['land-mine'].limit / 3) * entity_limits['land-mine'].slot_price))
|
||||
@ -160,16 +160,17 @@ end
|
||||
|
||||
local function slot_upgrade(player, offer_index)
|
||||
local entity_limits = Public.get('entity_limits')
|
||||
local price = entity_limits[slot_upgrade_offers[offer_index][1]].limit * entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
local entry = entity_limits[slot_upgrade_offers[offer_index][1]]
|
||||
local price = entry.limit * entry.slot_price
|
||||
|
||||
local gain = 1
|
||||
if offer_index == 5 then
|
||||
price = math.ceil((entity_limits[slot_upgrade_offers[offer_index][1]].limit / 3) * entity_limits[slot_upgrade_offers[offer_index][1]].slot_price)
|
||||
price = math.ceil((entry.limit / 3) * entry.slot_price)
|
||||
gain = 3
|
||||
end
|
||||
|
||||
if slot_upgrade_offers[offer_index][1] == 'flamethrower-turret' then
|
||||
price = (entity_limits[slot_upgrade_offers[offer_index][1]].limit + 1) * entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
if slot_upgrade_offers[offer_index][1] == 'fluid-turret' then
|
||||
price = (entry.limit + 1) * entry.slot_price
|
||||
end
|
||||
|
||||
local coins_removed = player.remove_item({name = 'coin', count = price})
|
||||
|
@ -49,10 +49,10 @@ function Public.reset_table()
|
||||
this.boss_biters = {}
|
||||
this.acid_lines_delay = {}
|
||||
this.entity_limits = {
|
||||
['gun-turret'] = {placed = 1, limit = 6, str = 'gun turret', slot_price = 70},
|
||||
['laser-turret'] = {placed = 0, limit = 1, str = 'laser turret', slot_price = 300},
|
||||
['ammo-turret'] = {placed = 1, limit = 6, str = 'gun turret', slot_price = 70},
|
||||
['electric-turret'] = {placed = 0, limit = 1, str = 'laser turret', slot_price = 300},
|
||||
['artillery-turret'] = {placed = 0, limit = 1, str = 'artillery turret', slot_price = 500},
|
||||
['flamethrower-turret'] = {placed = 0, limit = 0, str = 'flamethrower turret', slot_price = 50000},
|
||||
['fluid-turret'] = {placed = 0, limit = 0, str = 'flamethrower turret', slot_price = 50000},
|
||||
['land-mine'] = {placed = 0, limit = 1, str = 'mine', slot_price = 20}
|
||||
}
|
||||
this.difficulties_votes = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user