1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00

Merge pull request #266 from ComfyFactory/mtn_v3

mtn v3 - fix cheesing
This commit is contained in:
Gerkiz 2022-05-15 01:31:49 +02:00 committed by GitHub
commit be6476c740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,12 @@ local clear_items_upon_surface_entry = {
['substation'] = true
}
local valid_armors = {
['modular-armor'] = true,
['power-armor'] = true,
['power-armor-mk2'] = true
}
local function add_random_loot_to_main_market(rarity)
local main_market_items = WPT.get('main_market_items')
local items = Market.get_random_item(rarity, true, false)
@ -247,6 +253,45 @@ local function set_carriages()
WPT.set('carriages', locomotive.train.carriages)
end
local function get_driver_action(entity)
if not entity or not entity.valid then
return
end
local driver = entity.get_driver()
if not driver or not driver.valid then
return
end
local player = driver.player
if not player or not player.valid then
return
end
if player.cursor_stack and player.cursor_stack.valid_for_read and player.cursor_stack.name == 'raw-fish' then
player.print('[color=blue][Locomotive][/color] Unequip your fishy if you want to drive.')
driver.driving = false
return
end
local weapon = driver.get_inventory(defines.inventory.character_guns)
if weapon then
for i = 1, 3 do
if weapon[i] and weapon[i].valid_for_read then
player.print('[color=blue][Locomotive][/color] Unequip your weapon if you want to drive.')
driver.driving = false
return
end
end
end
local armor = driver.get_inventory(defines.inventory.character_armor)
if armor and armor[1] and armor[1].valid_for_read and valid_armors[armor[1].name] then
player.print('[color=blue][Locomotive][/color] Unequip your armor if you want to drive.')
driver.driving = false
end
end
local function set_locomotive_health()
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
@ -265,6 +310,7 @@ local function set_locomotive_health()
if not (entity and entity.valid) then
return
end
get_driver_action(entity)
local cargo_health = 600
if entity.type == 'locomotive' then
entity.health = 1000 * m