From 8d5c00512e32c5f2cae34c225043757f7434f9a6 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sun, 15 May 2022 01:24:16 +0200 Subject: [PATCH] mtn v3 - fix cheesing --- maps/mountain_fortress_v3/locomotive.lua | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/maps/mountain_fortress_v3/locomotive.lua b/maps/mountain_fortress_v3/locomotive.lua index a147d7aa..ec10df46 100644 --- a/maps/mountain_fortress_v3/locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive.lua @@ -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