diff --git a/locale/en/mtn_fortress_v3.cfg b/locale/en/mtn_fortress_v3.cfg index a02ee2e6..662e2985 100644 --- a/locale/en/mtn_fortress_v3.cfg +++ b/locale/en/mtn_fortress_v3.cfg @@ -1,7 +1,7 @@ [mountain_fortress_v3] map_info_main_caption=M O U N T A I N F O R T R E S S V3 map_info_sub_caption= ~~ diggy diggy choo choo ~~ -map_info_text=[color=red]READ THIS!\nIf there are any code bugs or desyncs. Please report asap to @Gerkiz!\nIf there are any game breaking bugs then this map might be shutdown to hot-fix the issue.[/color]\n\nThe biters have caught the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research will overhaul your mining equipment, increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nArtillery will try to shoot you down! Dig fast, dig north!\n\nSome explosives may cause rocks to fall down the mountain, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nEnter the cargo wagon to reveal the wagon surface!\n\nRandom buildings that generate resources can be found throughout the world.\n\nPlacing steel-chests near cargo-wagons enables you to quickly move content.\n\nStaying inside the locomotive aura prevents biters from spawning when mining entities.\n\nRPG GUI is disabled inside the locomotive.\nDisconnecting wagons is disabled.\nYou can't cancel crafting when standing inside the locomotive aura.\n\nDon't try to run north with your Spidertron if the train is not near you.\nYou have been warned.\nThe mystical chest in the locomotive offers some rewards.\nOne must feed the chest to receive such rewards.\n\nGood luck on your journey! +map_info_text=[color=red]READ THIS!\nIf there are any code bugs or desyncs. Please report asap to @Gerkiz!\nIf there are any game breaking bugs then this map might be shutdown to hot-fix the issue.[/color]\n\nThe biters have caught the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research will overhaul your mining equipment, increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nArtillery will try to shoot you down! Dig fast, dig north!\n\nSome explosives may cause rocks to fall down the mountain, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nEnter the cargo wagon to reveal the wagon surface!\n\nRandom buildings that generate resources can be found throughout the world.\n\nPlacing steel-chests near cargo-wagons enables you to quickly move content.\n\nStaying inside the locomotive aura prevents biters from spawning when mining entities.\n\nRPG GUI is disabled inside the locomotive.\nDisconnecting wagons is disabled.\nYou can't cancel crafting when standing inside the locomotive aura.\n\nDon't try to run north with your Spidertron if the train is not near you.\nYou have been warned.\n\nMining drills have great mining-bonus which also is increased after each research, use them when you can!\n\nThe mystical chest in the locomotive offers some rewards.\nOne must feed the chest to receive such rewards.\n\nGood luck on your journey! [breached_wall] collapse_start=[color=blue]Mapkeeper:[/color]\nWarning, Collapse has begun! diff --git a/maps/mountain_fortress_v3/entities.lua b/maps/mountain_fortress_v3/entities.lua index e46ac1ac..ff8b93f7 100644 --- a/maps/mountain_fortress_v3/entities.lua +++ b/maps/mountain_fortress_v3/entities.lua @@ -691,12 +691,10 @@ local mining_events = { { function(entity) local chest = 'crash-site-chest-' .. random(1, 2) - if entity.surface.can_place_entity({name = chest, position = entity.position, force = 'neutral'}) then - local container = entity.surface.create_entity({name = chest, position = entity.position, force = 'neutral'}) - if container and container.health then - container.insert({name = 'vehicle-machine-gun', count = 1}) - container.health = random(1, container.health) - end + local container = entity.surface.create_entity({name = chest, position = entity.position, force = 'neutral'}) + if container and container.health then + container.insert({name = 'vehicle-machine-gun', count = 1}) + container.health = random(1, container.health) end end, 64, @@ -1337,6 +1335,11 @@ local function on_built_entity(event) return end + if entity.type == 'mining-drill' then + entity.force = 'bonus_drill' + return + end + local upgrades = WPT.get('upgrades') local upg = upgrades @@ -1405,6 +1408,11 @@ local function on_robot_built_entity(event) return end + if entity.type == 'mining-drill' then + entity.force = 'bonus_drill' + return + end + local upgrades = WPT.get('upgrades') local upg = upgrades diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 8494b9fd..49af43b2 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -1465,8 +1465,14 @@ function Public.on_research_finished(event) disable_tech() local research = event.research + local bonus_drill = game.forces.bonus_drill + local player = game.forces.player - research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots / + research.force.character_inventory_slots_bonus = player.mining_drill_productivity_bonus * 50 -- +5 Slots / + bonus_drill.mining_drill_productivity_bonus = bonus_drill.mining_drill_productivity_bonus + 0.1 + if bonus_drill.mining_drill_productivity_bonus >= 3 then + bonus_drill.mining_drill_productivity_bonus = 3 + end if research.name == 'steel-axe' then local msg = 'Steel-axe technology has been researched, 100% has been applied.\nBuy Pickaxe-upgrades in the market to boost it even more!' diff --git a/maps/mountain_fortress_v3/icw/functions.lua b/maps/mountain_fortress_v3/icw/functions.lua index a029d02f..89cbc3b1 100644 --- a/maps/mountain_fortress_v3/icw/functions.lua +++ b/maps/mountain_fortress_v3/icw/functions.lua @@ -70,7 +70,10 @@ local function kick_players_from_surface(wagon) if validate_entity(main_surface) then for _, e in pairs(wagon.surface.find_entities_filtered({area = wagon.area})) do if validate_entity(e) and e.name == 'character' and e.player then - e.player.teleport(main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5), main_surface) + e.player.teleport( + main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5), + main_surface + ) end end end @@ -299,7 +302,15 @@ function Public.hazardous_debris() local p = {x = position[1], y = position[2]} local get_tile = surface.get_tile(p) if get_tile.valid and get_tile.name == 'out-of-map' then - create({name = 'uranium-cannon-projectile', position = position, force = 'neutral', target = {position[1], position[2] + fallout_width * 2}, speed = speed}) + create( + { + name = 'uranium-cannon-projectile', + position = position, + force = 'neutral', + target = {position[1], position[2] + fallout_width * 2}, + speed = speed + } + ) end end end @@ -948,7 +959,10 @@ local function move_room_to_train(icw, train, wagon) train.top_y = destination_area.right_bottom.y - if destination_area.left_top.x == wagon.area.left_top.x and destination_area.left_top.y == wagon.area.left_top.y and wagon.surface.name == train.surface.name then + if + destination_area.left_top.x == wagon.area.left_top.x and destination_area.left_top.y == wagon.area.left_top.y and + wagon.surface.name == train.surface.name + then return end kick_players_from_surface(wagon) @@ -1034,7 +1048,9 @@ local function get_connected_rolling_stock(entity, direction, carriages) return nil end - angle = math.atan2(-(connected_stock.position.x - entity.position.x), connected_stock.position.y - entity.position.y) / (2 * math.pi) - connected_stock.orientation + angle = + math.atan2(-(connected_stock.position.x - entity.position.x), connected_stock.position.y - entity.position.y) / (2 * math.pi) - + connected_stock.orientation while angle < -0.5 do angle = angle + 1 end @@ -1148,7 +1164,9 @@ function Public.draw_minimap(icw, player, surface, position) end local element = frame['icw_sub_frame'] if not frame.icw_auto_switch then - frame.add({type = 'switch', name = 'icw_auto_switch', allow_none_state = false, left_label_caption = {'gui.map_on'}, right_label_caption = {'gui.map_off'}}) + frame.add( + {type = 'switch', name = 'icw_auto_switch', allow_none_state = false, left_label_caption = {'gui.map_on'}, right_label_caption = {'gui.map_off'}} + ) end if not element then element = diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 16792cae..c87b2259 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -94,16 +94,27 @@ local collapse_kill = { enabled = true } -local init_new_force = function() - local new_force = game.forces.protectors +local init_protectors_force = function() + local protectors = game.forces.protectors local enemy = game.forces.enemy - if not new_force then - new_force = game.create_force('protectors') + if not protectors then + protectors = game.create_force('protectors') end - new_force.set_friend('enemy', true) + protectors.set_friend('enemy', true) enemy.set_friend('protectors', true) end +local init_bonus_drill_force = function() + local bonus_drill = game.forces.bonus_drill + local player = game.forces.player + if not bonus_drill then + bonus_drill = game.create_force('bonus_drill') + end + bonus_drill.set_friend('player', true) + player.set_friend('bonus_drill', true) + bonus_drill.mining_drill_productivity_bonus = 1 +end + local is_position_near_tbl = function(position, tbl) local status = false local function inside(pos) @@ -180,7 +191,8 @@ function Public.reset_map() Group.alphanumeric_only(false) Functions.disable_tech() - init_new_force() + init_protectors_force() + init_bonus_drill_force() local surface = game.surfaces[this.active_surface_index] diff --git a/maps/mountain_fortress_v3/mining.lua b/maps/mountain_fortress_v3/mining.lua index 897c515a..e2ed4485 100644 --- a/maps/mountain_fortress_v3/mining.lua +++ b/maps/mountain_fortress_v3/mining.lua @@ -330,6 +330,10 @@ local function randomness(data) } ) + if data.debug_mode then -- we're debugging - don't insert items + return + end + if harvest_amount > max_spill then if spill_items_to_surface then player.surface.spill_item_stack(position, {name = harvest, count = max_spill}, true) @@ -379,6 +383,10 @@ local function randomness_scrap(data) } ) + if data.debug_mode then -- we're debugging - don't insert items + return + end + if harvest_amount > max_spill then if spill_items_to_surface then player.surface.spill_item_stack(position, {name = harvest, count = max_spill}, true) @@ -434,6 +442,8 @@ function Public.on_player_mined_entity(event) local index = player.index local scrap_zone = RPG.get_value_from_player(index, 'scrap_zone') + local debug_mode = RPG.get_value_from_player(index, 'debug_mode') + data.debug_mode = debug_mode or false if scrap_zone or is_scrap then randomness_scrap(data) else diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index bd08d415..ccfbf4e3 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -15,6 +15,11 @@ Public.level_depth = WPT.level_depth Public.level_width = WPT.level_width local worm_level_modifier = 0.19 +local start_ground_tiles = { + 'black-refined-concrete', + 'nuclear-ground' +} + local wagon_raffle = { 'cargo-wagon', 'cargo-wagon', @@ -2400,22 +2405,9 @@ local function border_chunk(p, data) entities[#entities + 1] = {name = trees[random(1, #trees)], position = pos} end - local seed = data.seed - local small_caves = get_perlin('dungeons', p, seed + 34883) - local noise_cave_ponds = get_perlin('cave_ponds', p, seed + 28939) - local cave_rivers = get_perlin('cave_rivers', p, seed) - - if small_caves > 0.64 then - tiles[#tiles + 1] = {name = 'nuclear-ground', position = pos} - end - if noise_cave_ponds > 0.33 then - tiles[#tiles + 1] = {name = 'red-desert-' .. random(1, 3), position = pos} - end - if cave_rivers > 0.54 then - tiles[#tiles + 1] = {name = 'grass-' .. random(1, 4), position = pos} - end - - -- tiles[#tiles + 1] = {name = 'dirt-' .. random(1, 6), position = pos} + local noise = get_perlin('dungeons', pos, 14882) + local index = floor(noise * 32) % 2 + 1 + tiles[#tiles + 1] = {name = start_ground_tiles[index], position = pos} local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities() @@ -2549,7 +2541,15 @@ Event.add( local winter_mode = WPT.get('winter_mode') if winter_mode then rendering.draw_sprite( - {sprite = 'tile/lab-white', x_scale = 32, y_scale = 32, target = left_top, surface = surface, tint = {r = 0.6, g = 0.6, b = 0.6, a = 0.6}, render_layer = 'ground'} + { + sprite = 'tile/lab-white', + x_scale = 32, + y_scale = 32, + target = left_top, + surface = surface, + tint = {r = 0.6, g = 0.6, b = 0.6, a = 0.6}, + render_layer = 'ground' + } ) end @@ -2557,7 +2557,9 @@ Event.add( local locomotive = WPT.get('locomotive') if locomotive and locomotive.valid then local position = locomotive.position - for _, entity in pairs(surface.find_entities_filtered({area = {{position.x - 5, position.y - 6}, {position.x + 5, position.y + 10}}, type = 'simple-entity'})) do + for _, entity in pairs( + surface.find_entities_filtered({area = {{position.x - 5, position.y - 6}, {position.x + 5, position.y + 10}}, type = 'simple-entity'}) + ) do entity.destroy() end end diff --git a/maps/mountain_fortress_v3/traps.lua b/maps/mountain_fortress_v3/traps.lua index 74e79dca..ceb5baf1 100644 --- a/maps/mountain_fortress_v3/traps.lua +++ b/maps/mountain_fortress_v3/traps.lua @@ -51,12 +51,10 @@ local function create_kaboom(surface, position, name) local rng = random(1, 512) local chest = 'crash-site-chest-' .. random(1, 2) - if surface.can_place_entity({name = chest, position = position, force = 'neutral'}) then - local container = surface.create_entity({name = chest, position = position, force = 'neutral'}) - if container and container.health then - container.insert({name = 'coin', count = rng}) - container.health = random(1, container.health) - end + local container = surface.create_entity({name = chest, position = position, force = 'neutral'}) + if container and container.health then + container.insert({name = 'coin', count = rng}) + container.health = random(1, container.health) end return end diff --git a/modules/rpg/commands.lua b/modules/rpg/commands.lua index fba98624..ba54fecd 100644 --- a/modules/rpg/commands.lua +++ b/modules/rpg/commands.lua @@ -183,14 +183,15 @@ if _DEBUG then data[k].dexterity = 999 data[k].enable_entity_spawn = true data[k].explosive_bullets = true - data[k].level = 500 + data[k].level = 1000 data[k].magicka = 999 data[k].mana = 50000 data[k].mana_max = 50000 + data[k].debug_mode = true data[k].one_punch = true data[k].stone_path = true - data[k].strength = 999 - data[k].vitality = 999 + data[k].strength = 3000 + data[k].vitality = 3000 data[k].xp = 456456 local p = game.get_player(k) if p and p.valid then diff --git a/modules/rpg/functions.lua b/modules/rpg/functions.lua index 30ce9d60..fd96c511 100644 --- a/modules/rpg/functions.lua +++ b/modules/rpg/functions.lua @@ -272,6 +272,56 @@ function Public.validate_player(player) return true end +function Public.remove_mana(player, mana_to_remove) + local rpg_extra = Public.get('rpg_extra') + local rpg_t = Public.get_value_from_player(player.index) + if not rpg_extra.enable_mana then + return + end + + if not mana_to_remove then + return + end + + mana_to_remove = floor(mana_to_remove) + + if not rpg_t then + return + end + + if rpg_t.debug_mode then + rpg_t.mana = 9999 + return + end + + if player.gui.screen[main_frame_name] then + local f = player.gui.screen[main_frame_name] + local data = Gui.get_data(f) + if data.mana and data.mana.valid then + data.mana.caption = rpg_t.mana + end + end + + rpg_t.mana = rpg_t.mana - mana_to_remove + + if rpg_t.mana < 0 then + rpg_t.mana = 0 + return + end + + if player.gui.screen[spell_gui_frame_name] then + local f = player.gui.screen[spell_gui_frame_name] + if f['spell_table'] then + if f['spell_table']['mana'] then + f['spell_table']['mana'].caption = math.floor(rpg_t.mana) + end + if f['spell_table']['maxmana'] then + f['spell_table']['maxmana'].caption = math.floor(rpg_t.mana_max) + end + end + end +end + function Public.update_mana(player) local rpg_extra = Public.get('rpg_extra') local rpg_t = Public.get_value_from_player(player.index) diff --git a/modules/rpg/main.lua b/modules/rpg/main.lua index 0979f63b..000f6ff8 100644 --- a/modules/rpg/main.lua +++ b/modules/rpg/main.lua @@ -1203,17 +1203,22 @@ local function on_player_used_capsule(event) else force = 'player' end + if obj_name == 'suicidal_comfylatron' then Public.suicidal_comfylatron(position, surface) p(({'rpg_main.suicidal_comfylatron', 'Suicidal Comfylatron'}), Color.success) - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) elseif obj_name == 'repair_aoe' then local ents = Public.repair_aoe(player, position) p(({'rpg_main.repair_aoe', ents}), Color.success) - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) elseif obj_name == 'pointy_explosives' then local entities = - player.surface.find_entities_filtered {force = player.force, type = 'container', area = {{position.x - 1, position.y - 1}, {position.x + 1, position.y + 1}}} + player.surface.find_entities_filtered { + force = player.force, + type = 'container', + area = {{position.x - 1, position.y - 1}, {position.x + 1, position.y + 1}} + } local detonate_chest for i = 1, #entities do @@ -1224,7 +1229,7 @@ local function on_player_used_capsule(event) local success = Explosives.detonate_chest(detonate_chest) if success then player.print(({'rpg_main.detonate_chest'}), Color.success) - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) else player.print(({'rpg_main.detonate_chest_failed'}), Color.fail) end @@ -1237,15 +1242,14 @@ local function on_player_used_capsule(event) pos = game.forces.player.get_spawn_position(surface) player.teleport(pos, surface) end - rpg_t.mana = 0 + Public.remove_mana(player, 999999) Public.damage_player_over_time(player, random(8, 16)) player.play_sound {path = 'utility/armor_insert', volume_modifier = 1} p(({'rpg_main.warped_ok'}), Color.info) - rpg_t.mana = rpg_t.mana - object.mana_cost elseif obj_name == 'fish' then -- spawn in some fish player.insert({name = 'raw-fish', count = object.amount}) p(({'rpg_main.object_spawned', 'raw-fish'}), Color.success) - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) elseif projectile_types[obj_name] then -- projectiles for i = 1, object.amount do local damage_area = { @@ -1260,17 +1264,17 @@ local function on_player_used_capsule(event) end end p(({'rpg_main.object_spawned', obj_name}), Color.success) - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) else if object.target then -- rockets and such surface.create_entity({name = obj_name, position = position, force = force, target = target_pos, speed = 1}) p(({'rpg_main.object_spawned', obj_name}), Color.success) - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) elseif surface.can_place_entity {name = obj_name, position = position} then if object.biter then local e = surface.create_entity({name = obj_name, position = position, force = force}) tame_unit_effects(player, e) - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) elseif object.aoe then for x = 1, -1, -1 do for y = 1, -1, -1 do @@ -1281,14 +1285,14 @@ local function on_player_used_capsule(event) end local e = surface.create_entity({name = obj_name, position = pos, force = force}) e.direction = player.character.direction - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) end end end else local e = surface.create_entity({name = obj_name, position = position, force = force}) e.direction = player.character.direction - rpg_t.mana = rpg_t.mana - object.mana_cost + Public.remove_mana(player, object.mana_cost) end p(({'rpg_main.object_spawned', obj_name}), Color.success) else diff --git a/modules/rpg/spells.lua b/modules/rpg/spells.lua index fc3ffaf9..929cff03 100644 --- a/modules/rpg/spells.lua +++ b/modules/rpg/spells.lua @@ -113,6 +113,28 @@ function Public.conjure_items() enabled = true, sprite = 'recipe/express-underground-belt' } + spells[#spells + 1] = { + name = {'entity-name.pipe'}, + obj_to_create = 'pipe', + level = 1, + type = 'item', + mana_cost = 50, + tick = 100, + aoe = false, + enabled = true, + sprite = 'recipe/pipe' + } + spells[#spells + 1] = { + name = {'entity-name.pipe-to-ground'}, + obj_to_create = 'pipe-to-ground', + level = 1, + type = 'item', + mana_cost = 100, + tick = 100, + aoe = false, + enabled = true, + sprite = 'recipe/pipe-to-ground' + } spells[#spells + 1] = { name = {'entity-name.tree'}, obj_to_create = 'tree-05',