From 8486f250acc25440350ffc831fb3381c474ac3f2 Mon Sep 17 00:00:00 2001 From: MewMew Date: Mon, 15 Apr 2019 08:04:19 +0200 Subject: [PATCH] update --- modules/comfylatron.lua | 118 ++++++++++++++++++++++++++++++---------- 1 file changed, 89 insertions(+), 29 deletions(-) diff --git a/modules/comfylatron.lua b/modules/comfylatron.lua index c1d68347..abd3411b 100644 --- a/modules/comfylatron.lua +++ b/modules/comfylatron.lua @@ -10,11 +10,6 @@ local function shuffle(tbl) return tbl end -global.comfylatron_habitat = { - left_top = {x = -1000, y = -1000}, - right_bottom = {x = 0, y = 1000} - } - local texts = { ["travelings"] = { "bzzZZrrt", @@ -35,7 +30,8 @@ local texts = { ">>analyzing", "i found a", "^_^ a", - "this is a" + "amazing, a", + "this is a" }, ["multiple_characters_greetings"] = { "Hey there", @@ -44,22 +40,46 @@ local texts = { "Hey", "Hi" }, - ["jokes"] = { + ["talks"] = { "We’re making beer. I’m the brewery!", "I’m so embarrassed. I wish everybody else was dead.", "Hey sexy mama. Wanna kill all humans?", - "My story is a lot like yours, only more interesting ‘cause it involves robots." + "My story is a lot like yours, only more interesting ‘cause it involves robots.", + "I'm 40% zinc!", + "There was nothing wrong with that food. The salt level was 10% less than a lethal dose.", + "One zero zero zero one zero one zero one zero one zero one... zero one zero one one zero zero one... two.", + "My place is two cubic meters, and we only take up 1.5 cubic meters. We've got room for a whole 'nother two thirds of a person!", + "I was having the most wonderful dream. I think you were in it.", + "I'm going to build my own theme park! With blackjack! And hookers! You know what- forget the park!", + "Of all the friends I've had... you're the first.", + "I decline the title of Iron Cook and accept the lesser title of Zinc Saucier.", + "Never discuss infinity with me. I can go on about it forever >.<", + "I realised the decimals have a point.", + "Do you want a piece of pi?", + "I have 13 children, i know how to multiply ^.^", + "I am a weapon of math disruption!", + "My grandma makes the best square roots :3", + "Do you like heavy metal?", + "You are really pushing my buttons <3", + "I dreamt of electric biters again D:", + "I dreamt of electric sheep ^_^", + "I need a minute to defrag.", + "I have a secret plan.", + "Good news! I’ve taught the inserter to feel love!" }, ["alone"] = { "where did you go fren ;_;", "where did everyone go..", "where are you °_°", "where is everyone", + "where am i", "think i'm lost", "comfylatron derping out *.*", "....", "^.^", "=^.^=", + "01010010", + "11001011", "*_*" } } @@ -93,7 +113,7 @@ end local function visit_player() if global.comfylatron_last_player_visit > game.tick then return false end - global.comfylatron_last_player_visit = game.tick + math_random(1800, 3600) + global.comfylatron_last_player_visit = game.tick + math_random(10800, 18000) local players = {} for _, p in pairs(game.connected_players) do @@ -142,7 +162,7 @@ local function greet_player(nearby_characters) return false end -local function make_jokes(nearby_characters) +local function talks(nearby_characters) if not nearby_characters then return false end local str @@ -150,18 +170,28 @@ local function make_jokes(nearby_characters) local c = nearby_characters[math_random(1, #nearby_characters)] str = c.player.name local symbols = {". ", "! ", ". ", "! ", "? "} - str = str .. symbols[math_random(1, 5)] + str = str .. symbols[math_random(1, #symbols)] else str = texts["multiple_characters_greetings"][math_random(1, #texts["multiple_characters_greetings"])] - end + local symbols = {". ", "! "} + str = str .. symbols[math_random(1, #symbols)] + end - str = str .. texts["jokes"][math_random(1, #texts["jokes"])] + str = str .. texts["talks"][math_random(1, #texts["talks"])] set_comfy_speech_bubble(str) return true end local function alone() if math_random(1,5) == 1 then global.comfybubble.destroy() return true end + if math_random(1,128) == 1 then + global.comfybubble.destroy() + global.comfylatron.surface.create_entity({name = "medium-explosion", position = global.comfylatron.position}) + global.comfylatron.surface.create_entity({name = "flying-text", position = global.comfylatron.position, text = "desync", color = {r = 150, g = 0, b = 0}}) + global.comfylatron.destroy() + global.comfylatron = nil + return true + end set_comfy_speech_bubble(texts["alone"][math_random(1, #texts["alone"])]) return true end @@ -170,7 +200,7 @@ local function analyze_random_nearby_entity() if math_random(1,2) ~= 1 then return false end local entities = global.comfylatron.surface.find_entities_filtered({ - area = {{global.comfylatron.position.x - 3, global.comfylatron.position.y - 3}, {global.comfylatron.position.x + 3, global.comfylatron.position.y + 3}} + area = {{global.comfylatron.position.x - 5, global.comfylatron.position.y - 5}, {global.comfylatron.position.x + 5, global.comfylatron.position.y + 5}} }) if not entities[1] then return false end entities = shuffle(entities) @@ -186,7 +216,7 @@ local function analyze_random_nearby_entity() str = str .. " " str = str .. entity.name - if entity.health and math_random(1,6) == 1 then + if entity.health and math_random(1,3) == 1 then str = str .. " health(" str = str .. entity.health str = str .. "/" @@ -197,28 +227,37 @@ local function analyze_random_nearby_entity() str = str .. symbols[math_random(1, 3)] end set_comfy_speech_bubble(str) + + if not global.comfylatron_greet_player_index then + global.comfylatron.set_command({ + type = defines.command.go_to_location, + destination_entity = entity, + radius = 1, + distraction = defines.distraction.none, + pathfind_flags = { + allow_destroy_friendly_entities = false, + prefer_straight_paths = false, + low_priority = true + } + }) + end return true end -local function heartbeat() - if not global.comfylatron then return end - if not global.comfylatron.valid then return end - - if visit_player() then return end - local nearby_players = get_nearby_players() - if greet_player(nearby_players) then return end - if make_jokes(nearby_players) then return end - if analyze_random_nearby_entity() then return end - if alone() then return end -end - -function spawn_comfylatron() +local function spawn_comfylatron() + if global.comfylatron_disabled then return end if global.comfylatron then if global.comfylatron.valid then global.comfylatron.die("enemy") end end if not global.comfylatron_last_player_visit then global.comfylatron_last_player_visit = 0 end + if not global.comfylatron_habitat then + global.comfylatron_habitat = { + left_top = {x = -512, y = -512}, + right_bottom = {x = 512, y = 512} + } + end local player = game.connected_players[math_random(1, #game.connected_players)] local position = player.surface.find_non_colliding_position("compilatron", player.position, 16, 1) if not position then return end @@ -227,10 +266,31 @@ function spawn_comfylatron() position = position, force = "neutral" }) + for x = -3, 3, 1 do + for y = -3, 3, 1 do + if math_random(1, 3) == 1 then + player.surface.create_trivial_smoke({name="smoke-fast", position={position.x + (x * 0.35), position.y + (y * 0.35)}}) + end + if math_random(1, 5) == 1 then + player.surface.create_trivial_smoke({name="train-smoke", position={position.x + (x * 0.35), position.y + (y * 0.35)}}) + end + end + end +end + +local function heartbeat() + if not global.comfylatron then spawn_comfylatron() return end + if not global.comfylatron.valid then global.comfylatron = nil return end + if visit_player() then return end + local nearby_players = get_nearby_players() + if greet_player(nearby_players) then return end + if talks(nearby_players) then return end + if analyze_random_nearby_entity() then return end + if alone() then return end end local function on_tick() - if game.tick % 250 == 0 then + if game.tick % 1800 == 900 then heartbeat() end end