From cdb6765ea728e53885191c5f28fed8baae4e0da2 Mon Sep 17 00:00:00 2001 From: theorangeangle <36866626+theorangeangle@users.noreply.github.com> Date: Thu, 14 Mar 2019 22:36:51 -0500 Subject: [PATCH 1/5] foundation for project pinguin --- map_gen/maps/pinguin/icebergs.lua | 3 +++ map_gen/maps/pinguin/new_names.lua | 22 ++++++++++++++++++++++ map_gen/maps/pinguin/scenario.lua | 5 +++++ 3 files changed, 30 insertions(+) create mode 100644 map_gen/maps/pinguin/icebergs.lua create mode 100644 map_gen/maps/pinguin/new_names.lua create mode 100644 map_gen/maps/pinguin/scenario.lua diff --git a/map_gen/maps/pinguin/icebergs.lua b/map_gen/maps/pinguin/icebergs.lua new file mode 100644 index 000000000..9a4436e5e --- /dev/null +++ b/map_gen/maps/pinguin/icebergs.lua @@ -0,0 +1,3 @@ +--most features will be time-based, controlled by scenario.lua with one new feature enabled per hour +--some will be tied to evolution (marathon mode) or on_research_complete (armor switch) and will be enabled from map start +--golden goose is an exception diff --git a/map_gen/maps/pinguin/new_names.lua b/map_gen/maps/pinguin/new_names.lua new file mode 100644 index 000000000..0a717d9fc --- /dev/null +++ b/map_gen/maps/pinguin/new_names.lua @@ -0,0 +1,22 @@ +-- for project pinguin, all players will be anonymous. +-- you will get a new name on death, on login, or anytime it's too complicated to keep track of who is who. +-- the default tags will be replaced with penguin breeds + +--new tag names +'Adelie' +'African' +'Chinstrap' +'Emperor' +'Erect-crested' +'Fiordland' +'Galapagos' +'Gentoo' +'Humboldt' +'King' +'Little' +'Macaroni' +'Magellanic' +'Rockhopper' +'Royal' +'Snares' +'Yellow-eyed' diff --git a/map_gen/maps/pinguin/scenario.lua b/map_gen/maps/pinguin/scenario.lua new file mode 100644 index 000000000..685a61a90 --- /dev/null +++ b/map_gen/maps/pinguin/scenario.lua @@ -0,0 +1,5 @@ +-- this file contains all information related to map generation and control of new features. +-- a new feature will be enabled each hour, announced in chat and then never referenced again. +-- new_names.lua will have the player and tag names to fit in with the theme +-- icebergs.lua will contain all the features themselves +--no clue currently what mapgen should be, other than maybe a large iceberg? From cae917b8557ded5b752e48af1c5350f109d5cbed Mon Sep 17 00:00:00 2001 From: theorangeangle <36866626+theorangeangle@users.noreply.github.com> Date: Thu, 14 Mar 2019 23:15:57 -0500 Subject: [PATCH 2/5] layed out desired features --- map_gen/maps/pinguin/cutscene.lua | 1 + map_gen/maps/pinguin/icebergs.lua | 42 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 map_gen/maps/pinguin/cutscene.lua diff --git a/map_gen/maps/pinguin/cutscene.lua b/map_gen/maps/pinguin/cutscene.lua new file mode 100644 index 000000000..be3ff02d7 --- /dev/null +++ b/map_gen/maps/pinguin/cutscene.lua @@ -0,0 +1 @@ +--no clue what this will be used for yet (if at all) diff --git a/map_gen/maps/pinguin/icebergs.lua b/map_gen/maps/pinguin/icebergs.lua index 9a4436e5e..0bad27d0f 100644 --- a/map_gen/maps/pinguin/icebergs.lua +++ b/map_gen/maps/pinguin/icebergs.lua @@ -1,3 +1,45 @@ --most features will be time-based, controlled by scenario.lua with one new feature enabled per hour --some will be tied to evolution (marathon mode) or on_research_complete (armor switch) and will be enabled from map start --golden goose is an exception + + +--turrets have a 90% chance of being on player force when placed + + +--on_entity_mined: 0.01% chance to spawn another ore (every patch becomes a mixed ore patch) + + +--assemblers cannot be crafted in assemblers (manual craft ONLY for that item, all tiers) + + +--crafting underground belt/pipes will no longer give an even number + + +--player color changes each time they send a message + + +--on_research_complete, your armor is switched with a random player + + +--logistic robots have a small change of becoming distractor/destroyer bots when exiting the roboport + + +--cargo wagon becomes fluid wagon and vice versa when a player enters the wagon. it reverts when they exit. + + +--during the night, random entities will take small amounts of damage + + +--player walking direction is reversed at each evolution benchmark (0.1, 0.2, 0.3, etc) + + +--marathon mode enabled at 0.5 evolution + + +--small biters are replaced with compilatrons in hail hydra + + +--all players share the same health bar, proportional to the # of people online + + +-- From 35cb9ff644b688a7cae90a397e865033a1f433b7 Mon Sep 17 00:00:00 2001 From: theorangeangle <36866626+theorangeangle@users.noreply.github.com> Date: Thu, 28 Mar 2019 12:48:54 -0500 Subject: [PATCH 3/5] removed "restore_name" functions --- map_gen/shared/silly_player_names.lua | 208 ++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 map_gen/shared/silly_player_names.lua diff --git a/map_gen/shared/silly_player_names.lua b/map_gen/shared/silly_player_names.lua new file mode 100644 index 000000000..e3b418c31 --- /dev/null +++ b/map_gen/shared/silly_player_names.lua @@ -0,0 +1,208 @@ +local table = require 'utils.table' +local Game = require 'utils.game' +local Event = require 'utils.event' +local naming_words = require 'resources.naming_words' +local Utils = require 'utils.core' +local Global = require 'utils.global' +local Rank = require 'features.rank_system' +local ScenarioInfo = require 'features.gui.info' +local Command = require 'utils.command' +local Ranks = require 'resources.ranks' + +local format = string.format +local random = math.random + +ScenarioInfo.add_map_extra_info('- On this map you will be assigned a new name, which resets when leaving the world.\n' .. '- If you dislike your name you can /name-roll for a new one') + +global.silly_regulars = {} +local data_silly_names = {} +data_silly_names.silly_names = {} +data_silly_names.silly_name_store = {} +data_silly_names.silly_names_count = {0} +data_silly_names.silly_name_store = {} +data_silly_names.actual_name = {} + +local name_combinations = #naming_words.adverbs * #naming_words.adjectives * 1 +local table_size_ceiling = math.min(name_combinations * 0.25, 10000) + +Global.register( + { + data_silly_names = data_silly_names + }, + function(tbl) + data_silly_names = tbl.data_silly_names + end +) + +--- Takes a player's real name, current silly name, and old silly name and adjusts +-- the silly_regulars table accordingly +local function check_regular(real_name, silly_name, old_silly_name) + if Rank.equal(real_name, Ranks.regular) then + global.silly_regulars[silly_name] = true + if old_silly_name then + global.silly_regulars[old_silly_name] = nil + end + end +end + +--- Creates name by combining elements from the passed table +-- @param words_table including adverbs, adjectives, and nouns +-- @param player_name string with player's name +-- @returns string with player's silly name +-- TODO: Config option to set the name style +local function create_name(words_table, player_name) + local adverb, adjective --, noun + adverb = words_table[random(#words_table)] + adjective = words_table[random(#words_table)] + --noun = words_table[random(#words_table)] + local name = format('%s_%s_%s', adverb, adjective, player_name) + return string.gsub(name, "%s+", "_") +end + +--- Calls create_name until a unique name is returned +-- @param words_table including adverbs, adjectives, and nouns +-- @param player_name string with player's name +-- @returns string with player's silly name +local function create_unique_name(words_table, player_name) + local silly_names = data_silly_names.silly_names + local name = create_name(words_table, player_name) + + while table.contains(silly_names, name) do + name = create_name(words_table, player_name) + end + return name +end + +--- Assigns a player a name, stores their old and silly names +-- @param player LuaPlayer, the player to change the name of +local function name_player(player) + local real_name = data_silly_names.actual_name[player.index] or player.name + local old_silly_name + + -- If we don't have a player's actual name yet, store it + if data_silly_names.actual_name[player.index] then + old_silly_name = player.name + else + data_silly_names.actual_name[player.index] = real_name + end + + -- Because create_unique_name enters a while loop looking for a _unique_ name, + -- we ensure the table never contains all possible combinations by having a ceiling + if data_silly_names.silly_names_count[1] > table_size_ceiling then + table.clear_table(data_silly_names.silly_names, true) + data_silly_names.silly_names_count[1] = 0 + end + + local name = create_unique_name(naming_words, real_name) + data_silly_names.silly_names[#data_silly_names.silly_names + 1] = name + data_silly_names.silly_names_count[1] = data_silly_names.silly_names_count[1] + 1 + + local str = format('%s will now be known as: %s', player.name, name) + game.print(str) + local admin_str = format('%s (ID: %s)', str, player.index) + Utils.print_admins(admin_str, nil) + player.name = name + + -- After they have their name, we need to ensure compatibility with the regulars system + check_regular(real_name, name, old_silly_name) +end + +--- Passes _event_ on to name_players +local function player_joined(event) + local player = Game.get_player_by_index(event.player_index) + if data_silly_names.silly_name_store[event.player_index] then + player.name = data_silly_names.silly_name_store[event.player_index] + else + name_player(player) + end +end + +--- Passes target or player on to name_players +local function name_player_command(args, player) + local target + local target_name = args.player + + if target_name then + target = game.players[target_name] + if player and not player.admin then + -- Yes param, yes player, no admin/server = fail, non-admins, non-server cannot use command on others + Game.player_print("Sorry you don't have permission to use the roll-name command on other players.") + return + else + -- Yes param, yes admin/server = check target + if target then + -- Yes param, yes admin/server, yes target = change name + name_player(target) + return + else + -- Yes param, yes admin/server, no target = fail, wrong player name + Game.player_print(table.concat {"Sorry, player '", target_name, "' was not found."}) + return + end + end + else + -- No param = change self name + name_player(player) + return + end +end + +--- Prints the original name of the target +local function check_name(args) + local current_name = args.player + + local target = game.players[current_name] + if not target then + Game.player_print('player ' .. current_name .. ' not found') + return + end + + local actual_name = data_silly_names.actual_name[target.index] + Game.player_print(target.name .. ' is actually: ' .. actual_name) +end + +--- Prints the index of the target +local function get_player_id(args) + local target_name = args.player + + local target = game.players[target_name] + if not target then + Game.player_print('player ' .. target_name .. ' not found') + return + end + + Game.player_print(format('name: %s -- index: %s', target_name, target.index)) +end + +Event.add(defines.events.on_player_joined_game, player_joined) + +Command.add( + 'name-roll', + { + description = 'Assigns you a random, silly name. (Admins can use this command on players)', + arguments = {'player'}, + default_values = {player = false} + }, + name_player_command +) + +Command.add( + 'name-check', + { + description = 'Check the original name of a player with a silly name', + arguments = {'player'}, + allowed_by_server = true + }, + check_name +) + +Command.add( + 'get-player-id', + { + description = 'Gets the index of a player', + arguments = {'player'}, + required_rank = Ranks.admin, + allowed_by_server = true + }, + get_player_id +) From 5e741132030905725d25ee3ba3c6fc357818a8fb Mon Sep 17 00:00:00 2001 From: theorangeangle <36866626+theorangeangle@users.noreply.github.com> Date: Thu, 28 Mar 2019 12:49:11 -0500 Subject: [PATCH 4/5] renamed from christmas to pinguin --- resources/naming_words.lua | 89 ++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/resources/naming_words.lua b/resources/naming_words.lua index e36c45d64..96fd17dd6 100644 --- a/resources/naming_words.lua +++ b/resources/naming_words.lua @@ -148,6 +148,16 @@ Module.adverbs = { Module.adjectives = { 'Amazing', + 'Arctic', + 'Arctic', + 'Arctic', + 'Arctic', + 'Arctic', + 'Arctic', + 'Arctic', + 'Arctic', + 'Arctic', + 'Arctic', 'Attractive', 'Awesome', 'Beautiful', @@ -160,6 +170,16 @@ Module.adjectives = { 'Chubby', 'Clever', 'Clumsy', + 'Cold', + 'Cold', + 'Cold', + 'Cold', + 'Cold', + 'Cold', + 'Cold', + 'Cold', + 'Cold', + 'Cold', 'Dazzling', 'Delightful', 'Eager', @@ -170,6 +190,16 @@ Module.adjectives = { 'Fantastic', 'Fantastical', 'Fierce', + 'Frigid', + 'Frigid', + 'Frigid', + 'Frigid', + 'Frigid', + 'Frigid', + 'Frigid', + 'Frigid', + 'Frigid', + 'Frigid', 'Gentle', 'Glamorous', 'Gorgeous', @@ -206,48 +236,23 @@ Module.adjectives = { } Module.nouns = { - 'Advent', - 'Angel', - 'Bear', - 'Bell', - 'Candy_Cane', - 'Caroler', - 'Chestnut', - 'Christmas_Stocking', - 'Decoration', - 'Elf', - 'Feast', - 'Fruit_Cake', - 'Garland', - 'Gift', - 'Grinch', - 'Ham', - 'Helper', - 'Holiday_Dinner', - 'Holiday_Sweater', - 'Holly', - 'Ice_Skate', - 'Ivy', - 'Menora', - 'Miracle', - 'Mistletoe', - 'Ornament', - 'Package', - 'Party', - 'Present', - 'Reindeer', - 'Ribbon', - 'Scarf', - 'Scrooge', - 'Sleigh', - 'Snowball', - 'Snowflake', - 'Snowman', - 'Sugarplum', - 'Toy', - 'Tree', - 'Turkey', - 'Wreath', + 'Adelie Pinguin', + 'Adelie Pinguin', + 'Chinstrap Pinguin', + 'Emperor Pinguin', + 'Erect-crested Pinguin', + 'Fiordland Pinguin', + 'Galapagos Pinguin', + 'Gentoo Pinguin', + 'Humboldt Pinguin', + 'King Pinguin', + 'Little Pinguin', + 'Macaroni Pinguin', + 'Magellanic Pinguin', + 'Rockhopper Pinguin', + 'Royal Pinguin', + 'Snares Pinguin', + 'Yellow-eyed Pinguin', } return Module From 9407671121b34df5b37dbb822f6a0f693df6913c Mon Sep 17 00:00:00 2001 From: theorangeangle <36866626+theorangeangle@users.noreply.github.com> Date: Thu, 28 Mar 2019 12:51:02 -0500 Subject: [PATCH 5/5] Delete new_names.lua --- map_gen/maps/pinguin/new_names.lua | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 map_gen/maps/pinguin/new_names.lua diff --git a/map_gen/maps/pinguin/new_names.lua b/map_gen/maps/pinguin/new_names.lua deleted file mode 100644 index 0a717d9fc..000000000 --- a/map_gen/maps/pinguin/new_names.lua +++ /dev/null @@ -1,22 +0,0 @@ --- for project pinguin, all players will be anonymous. --- you will get a new name on death, on login, or anytime it's too complicated to keep track of who is who. --- the default tags will be replaced with penguin breeds - ---new tag names -'Adelie' -'African' -'Chinstrap' -'Emperor' -'Erect-crested' -'Fiordland' -'Galapagos' -'Gentoo' -'Humboldt' -'King' -'Little' -'Macaroni' -'Magellanic' -'Rockhopper' -'Royal' -'Snares' -'Yellow-eyed'