Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("prototypes.scripts.camera")
- -- Spidertron spawning configuration
- local SPIDERTRON_SPAWN_CONFIG = {
- technology = "lurker-tech",
- spidertron_name = "unit-07",
- surface_name = "eneas",
- search_radius = 100,
- max_attempts = 100
- }
- -- Technology configurations with messages, sounds, and animations
- local tech_data = {
- ["steam-power"] = {
- sound = "utility/new_objective",
- animation = "eye-2",
- messages = {
- {"dialogue.tech.steam-power.line-01"},
- {"dialogue.tech.steam-power.line-02"},
- {"dialogue.tech.steam-power.line-03"}
- }
- },
- ["automation-science-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.automation-science-pack.line-01"},
- {"dialogue.tech.automation-science-pack.line-02"},
- {"dialogue.tech.automation-science-pack.line-03"}
- }
- },
- ["logistic-science-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.logistic-science-pack.line-01"},
- {"dialogue.tech.logistic-science-pack.line-02"},
- {"dialogue.tech.logistic-science-pack.line-03"},
- {"dialogue.tech.logistic-science-pack.line-04"}
- }
- },
- ["chemical-science-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.chemical-science-pack.line-01"},
- {"dialogue.tech.chemical-science-pack.line-02"},
- {"dialogue.tech.chemical-science-pack.line-03"},
- {"dialogue.tech.chemical-science-pack.line-04"},
- {"dialogue.tech.chemical-science-pack.line-05"},
- {"dialogue.tech.chemical-science-pack.line-06"}
- }
- },
- ["automation"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.automation.line-01"},
- {"dialogue.tech.automation.line-02"},
- {"dialogue.tech.automation.line-03"}
- }
- },
- ["automation-2"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.automation-2.line-01"},
- {"dialogue.tech.automation-2.line-02"},
- {"dialogue.tech.automation-2.line-03"}
- }
- },
- ["automation-3"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.automation-3.line-01"},
- {"dialogue.tech.automation-3.line-02"},
- {"dialogue.tech.automation-3.line-03"}
- }
- },
- ["processing-unit"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.processing-unit.line-01"},
- {"dialogue.tech.processing-unit.line-02"},
- {"dialogue.tech.processing-unit.line-03"}
- }
- },
- ["railway"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.railway.line-01"},
- {"dialogue.tech.railway.line-02"},
- {"dialogue.tech.railway.line-03"}
- }
- },
- ["automated-rail-transportation"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.automated-rail-transportation.line-01"},
- {"dialogue.tech.automated-rail-transportation.line-02"}
- }
- },
- ["steel-axe"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.steel-axe.line-01"},
- {"dialogue.tech.steel-axe.line-02"},
- {"dialogue.tech.steel-axe.line-03"},
- {"dialogue.tech.steel-axe.line-04"}
- }
- },
- ["artifact-analysis-basic"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.artifact-analysis-basic.line-01"},
- {"dialogue.tech.artifact-analysis-basic.line-02"},
- {"dialogue.tech.artifact-analysis-basic.line-03"},
- {"dialogue.tech.artifact-analysis-basic.line-04"},
- {"dialogue.tech.artifact-analysis-basic.line-05"}
- }
- },
- ["tinker-tech-basic"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.tinker-tech-basic.line-01"},
- {"dialogue.tech.tinker-tech-basic.line-02"}
- }
- },
- ["tinker-tech-advanced"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.tinker-tech-advanced.line-01"},
- {"dialogue.tech.tinker-tech-advanced.line-02"}
- }
- },
- ["artifact-analysis-advanced"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.artifact-analysis-advanced.line-01"},
- {"dialogue.tech.artifact-analysis-advanced.line-02"}
- }
- },
- ["basic-data-management"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.basic-data-management.line-01"},
- {"dialogue.tech.basic-data-management.line-02"},
- {"dialogue.tech.basic-data-management.line-03"}
- }
- },
- ["oil-gathering"] = {
- sound = "utility/new_objective",
- animation = "eye-3",
- messages = {
- {"dialogue.tech.oil-gathering.line-01"},
- {"dialogue.tech.oil-gathering.line-02"}
- }
- },
- ["oil-processing"] = {
- sound = "utility/new_objective",
- animation = "eye-3",
- messages = {
- {"dialogue.tech.oil-processing.line-01"},
- {"dialogue.tech.oil-processing.line-02"},
- {"dialogue.tech.oil-processing.line-03"}
- }
- },
- ["military"] = {
- sound = "utility/new_objective",
- animation = "confused",
- messages = {
- {"dialogue.tech.military.line-01"},
- {"dialogue.tech.military.line-02"},
- {"dialogue.tech.military.line-03"},
- {"dialogue.tech.military.line-04"},
- {"dialogue.tech.military.line-05"}
- }
- },
- ["military-2"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.military-2.line-01"},
- {"dialogue.tech.military-2.line-02"},
- {"dialogue.tech.military-2.line-03"},
- {"dialogue.tech.military-2.line-04"},
- {"dialogue.tech.military-2.line-05"}
- }
- },
- ["military-3"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.military-3.line-01"},
- {"dialogue.tech.military-3.line-02"},
- {"dialogue.tech.military-3.line-03"}
- }
- },
- ["modular-armor"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.modular-armor.line-01"},
- {"dialogue.tech.modular-armor.line-02"},
- {"dialogue.tech.modular-armor.line-03"},
- {"dialogue.tech.modular-armor.line-04"},
- {"dialogue.tech.modular-armor.line-05"}
- }
- },
- ["advanced-radar"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.advanced-radar.line-01"},
- {"dialogue.tech.advanced-radar.line-02"},
- {"dialogue.tech.advanced-radar.line-03"},
- {"dialogue.tech.advanced-radar.line-04"}
- }
- },
- ["planet-discovery-eneas"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.planet-discovery-eneas.line-01"},
- {"dialogue.tech.planet-discovery-eneas.line-02"},
- {"dialogue.tech.planet-discovery-eneas.line-03"},
- {"dialogue.tech.planet-discovery-eneas.line-04"},
- {"dialogue.tech.planet-discovery-eneas.line-05"},
- {"dialogue.tech.planet-discovery-eneas.line-06"}
- }
- },
- ["ambition-science-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.ambition-science-pack.line-01"},
- {"dialogue.tech.ambition-science-pack.line-02"},
- {"dialogue.tech.ambition-science-pack.line-03"},
- {"dialogue.tech.ambition-science-pack.line-04"}
- }
- },
- ["codex-tech"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.codex-tech.line-01"},
- {"dialogue.tech.codex-tech.line-02"},
- {"dialogue.tech.codex-tech.line-03"},
- {"dialogue.tech.codex-tech.line-04"},
- {"dialogue.tech.codex-tech.line-05"},
- }
- },
- ["artifact-drilling"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.artifact-drilling.line-01"},
- {"dialogue.tech.artifact-drilling.line-02"},
- {"dialogue.tech.artifact-drilling.line-03"},
- }
- },
- ["pyrolysis-tech-basic"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.pyrolysis-tech-basic.line-01"},
- {"dialogue.tech.pyrolysis-tech-basic.line-02"},
- {"dialogue.tech.pyrolysis-tech-basic.line-03"}
- }
- },
- ["lurker-tech"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.lurker-tech.line-01"},
- {"dialogue.tech.lurker-tech.line-02"},
- {"dialogue.tech.lurker-tech.line-03"},
- {"dialogue.tech.lurker-tech.line-04"}
- }
- },
- ["oil-tech"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.oil-tech.line-01"},
- {"dialogue.tech.oil-tech.line-02"}
- }
- },
- ["chromium"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.chromium.line-01"},
- {"dialogue.tech.chromium.line-02"},
- {"dialogue.tech.chromium.line-03"},
- {"dialogue.tech.chromium.line-04"},
- {"dialogue.tech.chromium.line-05"},
- }
- },
- ["anger-science-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.anger-science-pack.line-01"},
- {"dialogue.tech.anger-science-pack.line-02"},
- {"dialogue.tech.anger-science-pack.line-03"},
- {"dialogue.tech.anger-science-pack.line-04"},
- {"dialogue.tech.anger-science-pack.line-05"},
- }
- },
- ["advanced-repair-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.advanced-repair-pack.line-01"},
- {"dialogue.tech.advanced-repair-pack.line-02"},
- {"dialogue.tech.advanced-repair-pack.line-03"},
- {"dialogue.tech.advanced-repair-pack.line-04"},
- }
- },
- ["stonebrick-advanced"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.stonebrick-advanced.line-01"},
- {"dialogue.tech.stonebrick-advanced.line-02"},
- {"dialogue.tech.stonebrick-advanced.line-03"},
- {"dialogue.tech.stonebrick-advanced.line-04"},
- }
- },
- ["overclock-unit"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.overclock-unit.line-01"},
- {"dialogue.tech.overclock-unit.line-02"},
- {"dialogue.tech.overclock-unit.line-03"},
- {"dialogue.tech.overclock-unit.line-04"},
- {"dialogue.tech.overclock-unit.line-05"},
- {"dialogue.tech.overclock-unit.line-06"},
- }
- },
- ["grief-science-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.grief-science-pack.line-01"},
- {"dialogue.tech.grief-science-pack.line-02"},
- {"dialogue.tech.grief-science-pack.line-03"},
- {"dialogue.tech.grief-science-pack.line-04"},
- {"dialogue.tech.grief-science-pack.line-05"},
- }
- },
- ["eneas-nutrients"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.eneas-nutrients.line-01"},
- {"dialogue.tech.eneas-nutrients.line-02"},
- {"dialogue.tech.eneas-nutrients.line-03"},
- {"dialogue.tech.eneas-nutrients.line-04"},
- {"dialogue.tech.eneas-nutrients.line-05"},
- }
- },
- ["fear-science-pack"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.fear-science-pack.line-01"},
- {"dialogue.tech.fear-science-pack.line-02"},
- {"dialogue.tech.fear-science-pack.line-03"},
- {"dialogue.tech.fear-science-pack.line-04"},
- {"dialogue.tech.fear-science-pack.line-05"},
- {"dialogue.tech.fear-science-pack.line-06"},
- }
- },
- ["biocomputer"] = {
- sound = "utility/new_objective",
- messages = {
- {"dialogue.tech.biocomputer.line-01"},
- {"dialogue.tech.biocomputer.line-02"},
- {"dialogue.tech.biocomputer.line-03"},
- {"dialogue.tech.biocomputer.line-04"},
- }
- }
- }
- -- Supply drops configuration
- local supply_drops = {
- ["basic-data-management"] = {quality = "uncommon", items = {["engineer-assembler"] = 2}},
- ["railway"] = {quality = "legendary", items = {["locomotive"] = 1}},
- ["oil-processing"] = {quality = "rare", items = {["solar-panel"] = 10}},
- ["oil-tech"] = {quality = "normal", items = {["heavy-oil-barrel"] = 30}},
- ["modular-armor"] = {quality = "uncommon", items = {["recycler"] = 1}},
- ["steel-axe"] = {quality = "normal", items = {["cliff-explosives"] = 10}},
- ["advanced-radar"] = {quality = "normal", items = {
- ["storage-chest"] = 1,
- ["engineer-roboport"] = 1,
- ["construction-robot"] = 10
- }},
- ["ambition-science-pack"] = {quality = "normal", items = {["clarifier"] = 3}},
- ["pyrolysis-tech-basic"] = {quality = "normal", items = {["agricultural-tower"] = 2}},
- }
- local has_construction_drones = script.active_mods["Construction_Drones_Forked"]
- local has_spiderbots = script.active_mods["spiderbots"]
- if has_construction_drones then
- supply_drops["automation"] = {quality = "normal", items = {["Construction_Drone"] = 1}}
- supply_drops["automation-2"] = {quality = "normal", items = {["Construction_Drone"] = 3}}
- supply_drops["automation-3"] = {quality = "normal", items = {["Construction_Drone"] = 5}}
- end
- if has_spiderbots then
- supply_drops["automation"] = {quality = "normal", items = {["spiderbot"] = 1}}
- supply_drops["automation-2"] = {quality = "normal", items = {["spiderbot"] = 3}}
- supply_drops["automation-3"] = {quality = "normal", items = {["spiderbot"] = 5}}
- end
- if not has_construction_drones and not has_spiderbots then
- table.insert(tech_data["automation"].messages, {"dialogue.tech.automation.line-04"})
- table.insert(tech_data["automation-2"].messages, {"dialogue.tech.automation.line-04"})
- table.insert(tech_data["automation-3"].messages, {"dialogue.tech.automation.line-04"})
- end
- local function find_water_spawn_position(surface, origin, radius, max_attempts)
- for attempt = 1, max_attempts do
- local angle = storage.rng.spawn() * 2 * math.pi
- local distance = storage.rng.spawn() * radius
- local test_position = {
- x = origin.x + math.cos(angle) * distance,
- y = origin.y + math.sin(angle) * distance
- }
- -- Check if this tile is water
- local tile = surface.get_tile(test_position.x, test_position.y)
- if tile and tile.valid then
- local tile_name = tile.name
- -- Check for various water tile types
- if string.find(tile_name, "water") or
- string.find(tile_name, "deepwater") or
- tile_name == "water-green-eneas" or
- tile_name == "deepwater-green-eneas" then
- -- Found water, now check if spidertron can spawn here
- local spawn_position = surface.find_non_colliding_position(
- SPIDERTRON_SPAWN_CONFIG.spidertron_name,
- test_position,
- 5,
- 0.5
- )
- if spawn_position then
- return spawn_position
- end
- end
- end
- end
- return nil
- end
- local function spawn_spidertron_for_force(force)
- local surface = game.surfaces[SPIDERTRON_SPAWN_CONFIG.surface_name]
- if not surface then
- game.print("[color=red][Unit-05][/color] Error: Eneas surface not found for spidertron deployment.")
- return false
- end
- local origin = {x = 0, y = 0}
- local spawn_position = find_water_spawn_position(
- surface,
- origin,
- SPIDERTRON_SPAWN_CONFIG.search_radius,
- SPIDERTRON_SPAWN_CONFIG.max_attempts
- )
- if not spawn_position then
- game.print("[color=orange][Unit-05][/color] Warning: Could not find suitable water location for spidertron deployment near origin.")
- -- Fallback: try to spawn on any valid position near origin
- spawn_position = surface.find_non_colliding_position(
- SPIDERTRON_SPAWN_CONFIG.spidertron_name,
- origin,
- SPIDERTRON_SPAWN_CONFIG.search_radius,
- 1
- )
- end
- if spawn_position then
- local spidertron = surface.create_entity{
- name = SPIDERTRON_SPAWN_CONFIG.spidertron_name,
- position = spawn_position,
- force = force
- }
- if spidertron and spidertron.valid then
- -- Visual effects
- surface.create_trivial_smoke{name = "smoke-fast", position = spawn_position}
- surface.play_sound{path = "utility/build_large", position = spawn_position}
- -- Notify all players in the force
- game.print(
- "[color=cyan][Unit-05][/color] Something emerged at " ..
- "[gps=" .. math.floor(spawn_position.x) .. "," ..
- math.floor(spawn_position.y) .. "," .. SPIDERTRON_SPAWN_CONFIG.surface_name .. "]"
- )
- -- Alert all players with a custom alert
- for _, player in pairs(force.connected_players) do
- player.add_custom_alert(
- spidertron,
- {type = "item", name = SPIDERTRON_SPAWN_CONFIG.spidertron_name},
- "Spidertron Deployed",
- true
- )
- player.play_sound{path = "utility/achievement_unlocked"}
- end
- -- Add chart tag
- force.add_chart_tag(surface, {
- position = spawn_position,
- text = "Spidertron [entity=" .. SPIDERTRON_SPAWN_CONFIG.spidertron_name .. "]"
- })
- return true
- end
- else
- game.print("[color=red][Unit-05][/color] Failed to deploy spidertron - no valid location found.")
- return false
- end
- return false
- end
- function on_research_finished(event)
- local research = event.research
- local tech_name = research.name
- local force = research.force
- local tech = tech_data[tech_name]
- -- === Message Handling ===
- if tech and tech.messages then
- -- Only loop through players in the force that researched the tech
- for _, player in pairs(force.connected_players) do
- for _, message in ipairs(tech.messages) do
- player.print(message)
- end
- if tech.sound then
- player.play_sound{path = tech.sound, volume_modifier = 1.0}
- end
- end
- -- Show transmission animation with last message
- local transmission_message = tech.messages[#tech.messages]
- local animation = tech.animation or "eye-1"
- ShowStaticTransmission(transmission_message, 8, animation)
- end
- -- === Spidertron Spawning ===
- if tech_name == SPIDERTRON_SPAWN_CONFIG.technology then
- spawn_spidertron_for_force(force)
- end
- -- === Supply Drop Handling (PER PLAYER) ===
- local drop_contents = supply_drops[tech_name]
- if drop_contents then
- -- Create a supply drop for EACH connected player in the force
- for _, player in pairs(force.connected_players) do
- if player.valid and player.character then -- Make sure player has a character
- local surface = player.surface
- local drop_position = surface.find_non_colliding_position(
- "steel-chest",
- player.position,
- 50,
- 1
- )
- if drop_position then
- local chest = surface.create_entity{
- name = "steel-chest",
- position = drop_position,
- force = force
- }
- if chest and chest.valid then
- -- Personalized label with player name
- chest.backer_name = string.format("Supply Crate for %s", player.name)
- for item, count in pairs(drop_contents.items) do
- chest.insert{name = item, count = count, quality = drop_contents.quality}
- end
- -- Visual and sound feedback (per player's location)
- surface.create_trivial_smoke{name = "smoke-fast", position = drop_position}
- surface.play_sound{path = "entity-open/steel-chest", position = drop_position}
- -- Alert only this specific player
- player.print("[color=gray]Unit-05 has delivered a supply crate nearby![/color]")
- player.add_custom_alert(chest, {type = "item", name = "steel-chest"}, "Your Supply Drop", true)
- player.play_sound{path = "utility/achievement_unlocked"}
- -- Optional: Add chart tag (visible to whole force)
- force.add_chart_tag(surface, {
- position = drop_position,
- text = string.format("%s's Supply", player.name)
- })
- end
- else
- -- Fallback if no valid position found
- player.print("[color=red]Warning: Could not find safe location for supply drop![/color]")
- end
- end
- end
- end
- end
- -------------------------------------------------------------------
- --- fish
- ----------------------------------------------------------------------------------------------
- local voicelines = {}
- voicelines.servofish = {
- "My friend these are not edible.",
- "Atleast now you know better, right? right..?",
- "I admire your curiosity. Truly",
- "These poor things have been through enough already, stop it!",
- "How is this counterintuitive? It's clearly made out of METAL.",
- "Oh my.. really?",
- "I believe this is a learning experience. For both of us.",
- "We have a long way to go if this seems like a logical choice to you.",
- "DO. NOT. EAT. THE. ROBOT. FISH. THANK YOU.",
- "Does this really look appetizing to you?"
- }
- script.on_event(defines.events.on_player_used_capsule, function(event)
- if event.item.name == "servofish" then
- local player = game.get_player(event.player_index)
- if player then
- local message = voicelines.servofish[storage.rng.talk(#voicelines.servofish)]
- player.print("[color=yellow][img=entity/unit-05]:" .. message .. "[/color]")
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment