Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Pinguin Potential Plans #873

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions map_gen/maps/pinguin/cutscene.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--no clue what this will be used for yet (if at all)
45 changes: 45 additions & 0 deletions map_gen/maps/pinguin/icebergs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +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


--
5 changes: 5 additions & 0 deletions map_gen/maps/pinguin/scenario.lua
Original file line number Diff line number Diff line change
@@ -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?
208 changes: 208 additions & 0 deletions map_gen/shared/silly_player_names.lua
Original file line number Diff line number Diff line change
@@ -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
)
89 changes: 47 additions & 42 deletions resources/naming_words.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ Module.adverbs = {

Module.adjectives = {
'Amazing',
'Arctic',
'Arctic',
'Arctic',
'Arctic',
'Arctic',
'Arctic',
'Arctic',
'Arctic',
'Arctic',
'Arctic',
'Attractive',
'Awesome',
'Beautiful',
Expand All @@ -160,6 +170,16 @@ Module.adjectives = {
'Chubby',
'Clever',
'Clumsy',
'Cold',
'Cold',
'Cold',
'Cold',
'Cold',
'Cold',
'Cold',
'Cold',
'Cold',
'Cold',
'Dazzling',
'Delightful',
'Eager',
Expand All @@ -170,6 +190,16 @@ Module.adjectives = {
'Fantastic',
'Fantastical',
'Fierce',
'Frigid',
'Frigid',
'Frigid',
'Frigid',
'Frigid',
'Frigid',
'Frigid',
'Frigid',
'Frigid',
'Frigid',
'Gentle',
'Glamorous',
'Gorgeous',
Expand Down Expand Up @@ -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