TheBiky88

message.lua

Feb 25th, 2026 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.00 KB | None | 0 0
  1. require("prototypes.scripts.camera")
  2.  
  3. -- Spidertron spawning configuration
  4. local SPIDERTRON_SPAWN_CONFIG = {
  5.   technology = "lurker-tech",  
  6.   spidertron_name = "unit-07",  
  7.   surface_name = "eneas",
  8.   search_radius = 100,  
  9.   max_attempts = 100  
  10. }
  11.  
  12. -- Technology configurations with messages, sounds, and animations
  13. local tech_data = {
  14.   ["steam-power"] = {
  15.     sound = "utility/new_objective",
  16.     animation = "eye-2",
  17.     messages = {
  18.       {"dialogue.tech.steam-power.line-01"},
  19.       {"dialogue.tech.steam-power.line-02"},
  20.       {"dialogue.tech.steam-power.line-03"}
  21.     }
  22.   },
  23.   ["automation-science-pack"] = {
  24.     sound = "utility/new_objective",
  25.     messages = {
  26.       {"dialogue.tech.automation-science-pack.line-01"},
  27.       {"dialogue.tech.automation-science-pack.line-02"},
  28.       {"dialogue.tech.automation-science-pack.line-03"}
  29.     }
  30.   },
  31.   ["logistic-science-pack"] = {
  32.     sound = "utility/new_objective",
  33.     messages = {
  34.       {"dialogue.tech.logistic-science-pack.line-01"},
  35.       {"dialogue.tech.logistic-science-pack.line-02"},
  36.       {"dialogue.tech.logistic-science-pack.line-03"},
  37.       {"dialogue.tech.logistic-science-pack.line-04"}
  38.     }
  39.   },
  40.   ["chemical-science-pack"] = {
  41.     sound = "utility/new_objective",
  42.     messages = {
  43.       {"dialogue.tech.chemical-science-pack.line-01"},
  44.       {"dialogue.tech.chemical-science-pack.line-02"},
  45.       {"dialogue.tech.chemical-science-pack.line-03"},
  46.       {"dialogue.tech.chemical-science-pack.line-04"},
  47.       {"dialogue.tech.chemical-science-pack.line-05"},
  48.       {"dialogue.tech.chemical-science-pack.line-06"}
  49.     }
  50.   },
  51.   ["automation"] = {
  52.     sound = "utility/new_objective",
  53.     messages = {
  54.       {"dialogue.tech.automation.line-01"},
  55.       {"dialogue.tech.automation.line-02"},
  56.       {"dialogue.tech.automation.line-03"}
  57.     }
  58.   },
  59.   ["automation-2"] = {
  60.     sound = "utility/new_objective",
  61.     messages = {
  62.       {"dialogue.tech.automation-2.line-01"},
  63.       {"dialogue.tech.automation-2.line-02"},
  64.       {"dialogue.tech.automation-2.line-03"}
  65.     }
  66.   },
  67.   ["automation-3"] = {
  68.     sound = "utility/new_objective",
  69.     messages = {
  70.       {"dialogue.tech.automation-3.line-01"},
  71.       {"dialogue.tech.automation-3.line-02"},
  72.       {"dialogue.tech.automation-3.line-03"}
  73.     }
  74.   },
  75.   ["processing-unit"] = {
  76.     sound = "utility/new_objective",
  77.     messages = {
  78.       {"dialogue.tech.processing-unit.line-01"},
  79.       {"dialogue.tech.processing-unit.line-02"},
  80.       {"dialogue.tech.processing-unit.line-03"}
  81.     }
  82.   },
  83.   ["railway"] = {
  84.     sound = "utility/new_objective",
  85.     messages = {
  86.       {"dialogue.tech.railway.line-01"},
  87.       {"dialogue.tech.railway.line-02"},
  88.       {"dialogue.tech.railway.line-03"}
  89.     }
  90.   },
  91.   ["automated-rail-transportation"] = {
  92.     sound = "utility/new_objective",
  93.     messages = {
  94.       {"dialogue.tech.automated-rail-transportation.line-01"},
  95.       {"dialogue.tech.automated-rail-transportation.line-02"}
  96.     }
  97.   },
  98.   ["steel-axe"] = {
  99.     sound = "utility/new_objective",
  100.     messages = {
  101.       {"dialogue.tech.steel-axe.line-01"},
  102.       {"dialogue.tech.steel-axe.line-02"},
  103.       {"dialogue.tech.steel-axe.line-03"},
  104.       {"dialogue.tech.steel-axe.line-04"}
  105.     }
  106.   },
  107.   ["artifact-analysis-basic"] = {
  108.     sound = "utility/new_objective",
  109.     messages = {
  110.       {"dialogue.tech.artifact-analysis-basic.line-01"},
  111.       {"dialogue.tech.artifact-analysis-basic.line-02"},
  112.       {"dialogue.tech.artifact-analysis-basic.line-03"},
  113.       {"dialogue.tech.artifact-analysis-basic.line-04"},
  114.       {"dialogue.tech.artifact-analysis-basic.line-05"}
  115.     }
  116.   },
  117.   ["tinker-tech-basic"] = {
  118.     sound = "utility/new_objective",
  119.     messages = {
  120.       {"dialogue.tech.tinker-tech-basic.line-01"},
  121.       {"dialogue.tech.tinker-tech-basic.line-02"}
  122.     }
  123.   },
  124.   ["tinker-tech-advanced"] = {
  125.     sound = "utility/new_objective",
  126.     messages = {
  127.       {"dialogue.tech.tinker-tech-advanced.line-01"},
  128.       {"dialogue.tech.tinker-tech-advanced.line-02"}
  129.     }
  130.   },
  131.   ["artifact-analysis-advanced"] = {
  132.     sound = "utility/new_objective",
  133.     messages = {
  134.       {"dialogue.tech.artifact-analysis-advanced.line-01"},
  135.       {"dialogue.tech.artifact-analysis-advanced.line-02"}
  136.     }
  137.   },
  138.   ["basic-data-management"] = {
  139.     sound = "utility/new_objective",
  140.     messages = {
  141.       {"dialogue.tech.basic-data-management.line-01"},
  142.       {"dialogue.tech.basic-data-management.line-02"},
  143.       {"dialogue.tech.basic-data-management.line-03"}
  144.     }
  145.   },
  146.   ["oil-gathering"] = {
  147.     sound = "utility/new_objective",
  148.     animation = "eye-3",
  149.     messages = {
  150.       {"dialogue.tech.oil-gathering.line-01"},
  151.       {"dialogue.tech.oil-gathering.line-02"}
  152.     }
  153.   },
  154.   ["oil-processing"] = {
  155.     sound = "utility/new_objective",
  156.     animation = "eye-3",
  157.     messages = {
  158.       {"dialogue.tech.oil-processing.line-01"},
  159.       {"dialogue.tech.oil-processing.line-02"},
  160.       {"dialogue.tech.oil-processing.line-03"}
  161.     }
  162.   },
  163.   ["military"] = {
  164.     sound = "utility/new_objective",
  165.     animation = "confused",
  166.     messages = {
  167.       {"dialogue.tech.military.line-01"},
  168.       {"dialogue.tech.military.line-02"},
  169.       {"dialogue.tech.military.line-03"},
  170.       {"dialogue.tech.military.line-04"},
  171.       {"dialogue.tech.military.line-05"}
  172.     }
  173.   },
  174.   ["military-2"] = {
  175.     sound = "utility/new_objective",
  176.     messages = {
  177.       {"dialogue.tech.military-2.line-01"},
  178.       {"dialogue.tech.military-2.line-02"},
  179.       {"dialogue.tech.military-2.line-03"},
  180.       {"dialogue.tech.military-2.line-04"},
  181.       {"dialogue.tech.military-2.line-05"}
  182.     }
  183.   },
  184.   ["military-3"] = {
  185.     sound = "utility/new_objective",
  186.     messages = {
  187.       {"dialogue.tech.military-3.line-01"},
  188.       {"dialogue.tech.military-3.line-02"},
  189.       {"dialogue.tech.military-3.line-03"}
  190.     }
  191.   },
  192.   ["modular-armor"] = {
  193.     sound = "utility/new_objective",
  194.     messages = {
  195.       {"dialogue.tech.modular-armor.line-01"},
  196.       {"dialogue.tech.modular-armor.line-02"},
  197.       {"dialogue.tech.modular-armor.line-03"},
  198.       {"dialogue.tech.modular-armor.line-04"},
  199.       {"dialogue.tech.modular-armor.line-05"}
  200.     }
  201.   },
  202.   ["advanced-radar"] = {
  203.     sound = "utility/new_objective",
  204.     messages = {
  205.       {"dialogue.tech.advanced-radar.line-01"},
  206.       {"dialogue.tech.advanced-radar.line-02"},
  207.       {"dialogue.tech.advanced-radar.line-03"},
  208.       {"dialogue.tech.advanced-radar.line-04"}
  209.     }
  210.   },
  211.   ["planet-discovery-eneas"] = {
  212.     sound = "utility/new_objective",
  213.     messages = {
  214.       {"dialogue.tech.planet-discovery-eneas.line-01"},
  215.       {"dialogue.tech.planet-discovery-eneas.line-02"},
  216.       {"dialogue.tech.planet-discovery-eneas.line-03"},
  217.       {"dialogue.tech.planet-discovery-eneas.line-04"},
  218.       {"dialogue.tech.planet-discovery-eneas.line-05"},
  219.       {"dialogue.tech.planet-discovery-eneas.line-06"}
  220.     }
  221.   },
  222.   ["ambition-science-pack"] = {
  223.     sound = "utility/new_objective",
  224.     messages = {
  225.       {"dialogue.tech.ambition-science-pack.line-01"},
  226.       {"dialogue.tech.ambition-science-pack.line-02"},
  227.       {"dialogue.tech.ambition-science-pack.line-03"},
  228.       {"dialogue.tech.ambition-science-pack.line-04"}
  229.     }
  230.   },
  231.   ["codex-tech"] = {
  232.     sound = "utility/new_objective",
  233.     messages = {
  234.       {"dialogue.tech.codex-tech.line-01"},
  235.       {"dialogue.tech.codex-tech.line-02"},
  236.       {"dialogue.tech.codex-tech.line-03"},
  237.       {"dialogue.tech.codex-tech.line-04"},
  238.       {"dialogue.tech.codex-tech.line-05"},
  239.     }
  240.   },
  241.   ["artifact-drilling"] = {
  242.     sound = "utility/new_objective",
  243.     messages = {
  244.       {"dialogue.tech.artifact-drilling.line-01"},
  245.       {"dialogue.tech.artifact-drilling.line-02"},
  246.       {"dialogue.tech.artifact-drilling.line-03"},
  247.     }
  248.   },
  249.   ["pyrolysis-tech-basic"] = {
  250.     sound = "utility/new_objective",
  251.     messages = {
  252.       {"dialogue.tech.pyrolysis-tech-basic.line-01"},
  253.       {"dialogue.tech.pyrolysis-tech-basic.line-02"},
  254.       {"dialogue.tech.pyrolysis-tech-basic.line-03"}
  255.     }
  256.   },
  257.   ["lurker-tech"] = {
  258.     sound = "utility/new_objective",
  259.     messages = {
  260.       {"dialogue.tech.lurker-tech.line-01"},
  261.       {"dialogue.tech.lurker-tech.line-02"},
  262.       {"dialogue.tech.lurker-tech.line-03"},
  263.       {"dialogue.tech.lurker-tech.line-04"}
  264.     }
  265.   },
  266.   ["oil-tech"] = {
  267.     sound = "utility/new_objective",
  268.     messages = {
  269.       {"dialogue.tech.oil-tech.line-01"},
  270.       {"dialogue.tech.oil-tech.line-02"}
  271.     }
  272.   },
  273.   ["chromium"] = {
  274.     sound = "utility/new_objective",
  275.     messages = {
  276.       {"dialogue.tech.chromium.line-01"},
  277.       {"dialogue.tech.chromium.line-02"},
  278.       {"dialogue.tech.chromium.line-03"},
  279.       {"dialogue.tech.chromium.line-04"},
  280.       {"dialogue.tech.chromium.line-05"},
  281.     }
  282.   },
  283.   ["anger-science-pack"] = {
  284.     sound = "utility/new_objective",
  285.     messages = {
  286.       {"dialogue.tech.anger-science-pack.line-01"},
  287.       {"dialogue.tech.anger-science-pack.line-02"},
  288.       {"dialogue.tech.anger-science-pack.line-03"},
  289.       {"dialogue.tech.anger-science-pack.line-04"},
  290.       {"dialogue.tech.anger-science-pack.line-05"},
  291.     }
  292.   },
  293.   ["advanced-repair-pack"] = {
  294.     sound = "utility/new_objective",
  295.     messages = {
  296.       {"dialogue.tech.advanced-repair-pack.line-01"},
  297.       {"dialogue.tech.advanced-repair-pack.line-02"},
  298.       {"dialogue.tech.advanced-repair-pack.line-03"},
  299.       {"dialogue.tech.advanced-repair-pack.line-04"},
  300.     }
  301.   },
  302.   ["stonebrick-advanced"] = {
  303.     sound = "utility/new_objective",
  304.     messages = {
  305.       {"dialogue.tech.stonebrick-advanced.line-01"},
  306.       {"dialogue.tech.stonebrick-advanced.line-02"},
  307.       {"dialogue.tech.stonebrick-advanced.line-03"},
  308.       {"dialogue.tech.stonebrick-advanced.line-04"},
  309.     }
  310.   },
  311.   ["overclock-unit"] = {
  312.     sound = "utility/new_objective",
  313.     messages = {
  314.       {"dialogue.tech.overclock-unit.line-01"},
  315.       {"dialogue.tech.overclock-unit.line-02"},
  316.       {"dialogue.tech.overclock-unit.line-03"},
  317.       {"dialogue.tech.overclock-unit.line-04"},
  318.       {"dialogue.tech.overclock-unit.line-05"},
  319.       {"dialogue.tech.overclock-unit.line-06"},
  320.     }
  321.   },
  322.   ["grief-science-pack"] = {
  323.     sound = "utility/new_objective",
  324.     messages = {
  325.       {"dialogue.tech.grief-science-pack.line-01"},
  326.       {"dialogue.tech.grief-science-pack.line-02"},
  327.       {"dialogue.tech.grief-science-pack.line-03"},
  328.       {"dialogue.tech.grief-science-pack.line-04"},
  329.       {"dialogue.tech.grief-science-pack.line-05"},
  330.     }
  331.   },
  332.   ["eneas-nutrients"] = {
  333.     sound = "utility/new_objective",
  334.     messages = {
  335.       {"dialogue.tech.eneas-nutrients.line-01"},
  336.       {"dialogue.tech.eneas-nutrients.line-02"},
  337.       {"dialogue.tech.eneas-nutrients.line-03"},
  338.       {"dialogue.tech.eneas-nutrients.line-04"},
  339.       {"dialogue.tech.eneas-nutrients.line-05"},
  340.     }
  341.   },
  342.   ["fear-science-pack"] = {
  343.     sound = "utility/new_objective",
  344.     messages = {
  345.       {"dialogue.tech.fear-science-pack.line-01"},
  346.       {"dialogue.tech.fear-science-pack.line-02"},
  347.       {"dialogue.tech.fear-science-pack.line-03"},
  348.       {"dialogue.tech.fear-science-pack.line-04"},
  349.       {"dialogue.tech.fear-science-pack.line-05"},
  350.       {"dialogue.tech.fear-science-pack.line-06"},
  351.     }
  352.   },
  353.   ["biocomputer"] = {
  354.     sound = "utility/new_objective",
  355.     messages = {
  356.       {"dialogue.tech.biocomputer.line-01"},
  357.       {"dialogue.tech.biocomputer.line-02"},
  358.       {"dialogue.tech.biocomputer.line-03"},
  359.       {"dialogue.tech.biocomputer.line-04"},
  360.     }
  361.   }
  362. }
  363.  
  364. -- Supply drops configuration
  365. local supply_drops = {
  366.   ["basic-data-management"] = {quality = "uncommon", items = {["engineer-assembler"] = 2}},
  367.   ["railway"] = {quality = "legendary", items = {["locomotive"] = 1}},
  368.   ["oil-processing"] = {quality = "rare", items = {["solar-panel"] = 10}},
  369.   ["oil-tech"] = {quality = "normal", items = {["heavy-oil-barrel"] = 30}},
  370.   ["modular-armor"] = {quality = "uncommon", items = {["recycler"] = 1}},
  371.   ["steel-axe"] = {quality = "normal", items = {["cliff-explosives"] = 10}},
  372.   ["advanced-radar"] = {quality = "normal", items = {
  373.     ["storage-chest"] = 1,
  374.     ["engineer-roboport"] = 1,
  375.     ["construction-robot"] = 10
  376.   }},
  377.   ["ambition-science-pack"] = {quality = "normal", items = {["clarifier"] = 3}},
  378.   ["pyrolysis-tech-basic"] = {quality = "normal", items = {["agricultural-tower"] = 2}},
  379. }
  380.  
  381. local has_construction_drones = script.active_mods["Construction_Drones_Forked"]
  382. local has_spiderbots = script.active_mods["spiderbots"]
  383.  
  384. if has_construction_drones then
  385.  
  386.   supply_drops["automation"] = {quality = "normal", items = {["Construction_Drone"] = 1}}
  387.   supply_drops["automation-2"] = {quality = "normal", items = {["Construction_Drone"] = 3}}
  388.   supply_drops["automation-3"] = {quality = "normal", items = {["Construction_Drone"] = 5}}
  389. end
  390.  
  391. if has_spiderbots then
  392.  
  393.   supply_drops["automation"] = {quality = "normal", items = {["spiderbot"] = 1}}
  394.   supply_drops["automation-2"] = {quality = "normal", items = {["spiderbot"] = 3}}
  395.   supply_drops["automation-3"] = {quality = "normal", items = {["spiderbot"] = 5}}
  396. end
  397.  
  398.  
  399. if not has_construction_drones and not has_spiderbots then
  400.   table.insert(tech_data["automation"].messages, {"dialogue.tech.automation.line-04"})
  401.   table.insert(tech_data["automation-2"].messages, {"dialogue.tech.automation.line-04"})
  402.   table.insert(tech_data["automation-3"].messages, {"dialogue.tech.automation.line-04"})
  403. end
  404.  
  405. local function find_water_spawn_position(surface, origin, radius, max_attempts)
  406.   for attempt = 1, max_attempts do
  407.     local angle = storage.rng.spawn() * 2 * math.pi
  408.     local distance = storage.rng.spawn() * radius
  409.     local test_position = {
  410.       x = origin.x + math.cos(angle) * distance,
  411.       y = origin.y + math.sin(angle) * distance
  412.     }
  413.    
  414.     -- Check if this tile is water
  415.     local tile = surface.get_tile(test_position.x, test_position.y)
  416.     if tile and tile.valid then
  417.       local tile_name = tile.name
  418.       -- Check for various water tile types
  419.       if string.find(tile_name, "water") or
  420.          string.find(tile_name, "deepwater") or
  421.          tile_name == "water-green-eneas" or
  422.          tile_name == "deepwater-green-eneas" then
  423.        
  424.         -- Found water, now check if spidertron can spawn here
  425.         local spawn_position = surface.find_non_colliding_position(
  426.           SPIDERTRON_SPAWN_CONFIG.spidertron_name,
  427.           test_position,
  428.           5,
  429.           0.5
  430.         )
  431.        
  432.         if spawn_position then
  433.           return spawn_position
  434.         end
  435.       end
  436.     end
  437.   end
  438.  
  439.   return nil
  440. end
  441.  
  442. local function spawn_spidertron_for_force(force)
  443.   local surface = game.surfaces[SPIDERTRON_SPAWN_CONFIG.surface_name]
  444.  
  445.   if not surface then
  446.     game.print("[color=red][Unit-05][/color] Error: Eneas surface not found for spidertron deployment.")
  447.     return false
  448.   end
  449.  
  450.   local origin = {x = 0, y = 0}
  451.   local spawn_position = find_water_spawn_position(
  452.     surface,
  453.     origin,
  454.     SPIDERTRON_SPAWN_CONFIG.search_radius,
  455.     SPIDERTRON_SPAWN_CONFIG.max_attempts
  456.   )
  457.  
  458.   if not spawn_position then
  459.     game.print("[color=orange][Unit-05][/color] Warning: Could not find suitable water location for spidertron deployment near origin.")
  460.     -- Fallback: try to spawn on any valid position near origin
  461.     spawn_position = surface.find_non_colliding_position(
  462.       SPIDERTRON_SPAWN_CONFIG.spidertron_name,
  463.       origin,
  464.       SPIDERTRON_SPAWN_CONFIG.search_radius,
  465.       1
  466.     )
  467.   end
  468.  
  469.   if spawn_position then
  470.     local spidertron = surface.create_entity{
  471.       name = SPIDERTRON_SPAWN_CONFIG.spidertron_name,
  472.       position = spawn_position,
  473.       force = force
  474.     }
  475.    
  476.     if spidertron and spidertron.valid then
  477.       -- Visual effects
  478.       surface.create_trivial_smoke{name = "smoke-fast", position = spawn_position}
  479.       surface.play_sound{path = "utility/build_large", position = spawn_position}
  480.      
  481.       -- Notify all players in the force
  482.       game.print(
  483.         "[color=cyan][Unit-05][/color] Something emerged at " ..
  484.         "[gps=" .. math.floor(spawn_position.x) .. "," ..
  485.         math.floor(spawn_position.y) .. "," .. SPIDERTRON_SPAWN_CONFIG.surface_name .. "]"
  486.       )
  487.      
  488.       -- Alert all players with a custom alert
  489.       for _, player in pairs(force.connected_players) do
  490.         player.add_custom_alert(
  491.           spidertron,
  492.           {type = "item", name = SPIDERTRON_SPAWN_CONFIG.spidertron_name},
  493.           "Spidertron Deployed",
  494.           true
  495.         )
  496.         player.play_sound{path = "utility/achievement_unlocked"}
  497.       end
  498.      
  499.       -- Add chart tag
  500.       force.add_chart_tag(surface, {
  501.         position = spawn_position,
  502.         text = "Spidertron [entity=" .. SPIDERTRON_SPAWN_CONFIG.spidertron_name .. "]"
  503.       })
  504.      
  505.       return true
  506.     end
  507.   else
  508.     game.print("[color=red][Unit-05][/color] Failed to deploy spidertron - no valid location found.")
  509.     return false
  510.   end
  511.  
  512.   return false
  513. end
  514.  
  515. function on_research_finished(event)
  516.   local research = event.research
  517.   local tech_name = research.name
  518.   local force = research.force
  519.   local tech = tech_data[tech_name]
  520.  
  521.   -- === Message Handling ===
  522.   if tech and tech.messages then
  523.     -- Only loop through players in the force that researched the tech
  524.     for _, player in pairs(force.connected_players) do
  525.       for _, message in ipairs(tech.messages) do
  526.         player.print(message)
  527.       end
  528.      
  529.       if tech.sound then
  530.         player.play_sound{path = tech.sound, volume_modifier = 1.0}
  531.       end
  532.     end
  533.    
  534.     -- Show transmission animation with last message
  535.     local transmission_message = tech.messages[#tech.messages]
  536.     local animation = tech.animation or "eye-1"
  537.     ShowStaticTransmission(transmission_message, 8, animation)
  538.   end
  539.  
  540.   -- === Spidertron Spawning ===
  541.   if tech_name == SPIDERTRON_SPAWN_CONFIG.technology then
  542.     spawn_spidertron_for_force(force)
  543.   end
  544.  
  545.   -- === Supply Drop Handling (PER PLAYER) ===
  546.   local drop_contents = supply_drops[tech_name]
  547.   if drop_contents then
  548.     -- Create a supply drop for EACH connected player in the force
  549.     for _, player in pairs(force.connected_players) do
  550.       if player.valid and player.character then  -- Make sure player has a character
  551.         local surface = player.surface
  552.         local drop_position = surface.find_non_colliding_position(
  553.           "steel-chest",
  554.           player.position,
  555.           50,
  556.           1
  557.         )
  558.  
  559.         if drop_position then
  560.           local chest = surface.create_entity{
  561.             name = "steel-chest",
  562.             position = drop_position,
  563.             force = force
  564.           }
  565.  
  566.           if chest and chest.valid then
  567.             -- Personalized label with player name
  568.             chest.backer_name = string.format("Supply Crate for %s", player.name)
  569.            
  570.             for item, count in pairs(drop_contents.items) do
  571.               chest.insert{name = item, count = count, quality = drop_contents.quality}
  572.             end
  573.  
  574.             -- Visual and sound feedback (per player's location)
  575.             surface.create_trivial_smoke{name = "smoke-fast", position = drop_position}
  576.             surface.play_sound{path = "entity-open/steel-chest", position = drop_position}
  577.  
  578.             -- Alert only this specific player
  579.             player.print("[color=gray]Unit-05 has delivered a supply crate nearby![/color]")
  580.             player.add_custom_alert(chest, {type = "item", name = "steel-chest"}, "Your Supply Drop", true)
  581.             player.play_sound{path = "utility/achievement_unlocked"}
  582.            
  583.             -- Optional: Add chart tag (visible to whole force)
  584.             force.add_chart_tag(surface, {
  585.               position = drop_position,
  586.               text = string.format("%s's Supply", player.name)
  587.             })
  588.           end
  589.         else
  590.           -- Fallback if no valid position found
  591.           player.print("[color=red]Warning: Could not find safe location for supply drop![/color]")
  592.         end
  593.       end
  594.     end
  595.   end
  596. end
  597.  
  598. -------------------------------------------------------------------
  599. --- fish
  600. ----------------------------------------------------------------------------------------------
  601. local voicelines = {}
  602.  
  603. voicelines.servofish = {
  604.   "My friend these are not edible.",
  605.   "Atleast now you know better, right? right..?",
  606.   "I admire your curiosity. Truly",
  607.   "These poor things have been through enough already, stop it!",
  608.   "How is this counterintuitive? It's clearly made out of METAL.",
  609.   "Oh my.. really?",
  610.   "I believe this is a learning experience. For both of us.",
  611.   "We have a long way to go if this seems like a logical choice to you.",
  612.   "DO. NOT. EAT. THE. ROBOT. FISH. THANK YOU.",
  613.   "Does this really look appetizing to you?"
  614. }
  615.  
  616. script.on_event(defines.events.on_player_used_capsule, function(event)
  617.   if event.item.name == "servofish" then
  618.     local player = game.get_player(event.player_index)
  619.     if player then
  620.       local message = voicelines.servofish[storage.rng.talk(#voicelines.servofish)]
  621.       player.print("[color=yellow][img=entity/unit-05]:" .. message .. "[/color]")
  622.     end
  623.   end
  624. end)
Advertisement
Add Comment
Please, Sign In to add comment