Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
added chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
MewMew committed Dec 18, 2018
1 parent 2e4a006 commit 1801b1c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
43 changes: 43 additions & 0 deletions chatbot.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local event = require 'utils.event'
local message_color = {r = 0.5, g = 0.3, b = 1}

local brain = {
[1] = {"Our Discord server is at https://comfyplay.net/discord"},
[2] = {"Need an admin? Type @Mods in game chat to notify moderators!", "Or put a message in the discord help channel."}
}

local links = {
["discord"] = brain[1],
["admin"] = brain[2],
["administrator"] = brain[2],
["mod"] = brain[2],
["moderator"] = brain[2],
["grief"] = brain[2],
["troll"] = brain[2],
["trolling"] = brain[2],
["stealing"] = brain[2],
["stole"] = brain[2],
["griefer"] = brain[2]
}

local function on_player_created(event)
local player = game.players[event.player_index]
player.print("Join the comfy discord >> comfyplay.net/discord", message_color)
end

local function on_console_chat(event)
local message = event.message
message = string.lower(message)
for word in string.gmatch(message, "%a+") do
if links[word] then
local player = game.players[event.player_index]
for _, bot_answer in pairs(links[word]) do
player.print(bot_answer, message_color)
end
return
end
end
end

event.add(defines.events.on_player_created, on_player_created)
event.add(defines.events.on_console_chat, on_console_chat)
11 changes: 5 additions & 6 deletions control.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "utils.utils"
require "utils.corpse_util"
require "bot"
require "chatbot"
require "session_tracker"
require "antigrief"
require "antigrief_admin_panel"
Expand All @@ -20,22 +21,20 @@ require "score"
--require "maps.labyrinth"
--require "maps.spaghettorio"
--require "maps.spiral_troopers"
--require "maps.fish_defender"
require "maps.fish_defender"
--require "maps.crossing"
--require "maps.spooky_forest"
--require "maps.atoll"
require "maps.tank_battles"
--require "maps.tank_battles"
--require "maps.empty_map"
-----------------------------

local Event = require 'utils.event'

local function player_created(event)
local function on_player_created(event)
local player = game.players[event.player_index]
player.gui.top.style = 'slot_table_spacing_horizontal_flow'
player.gui.left.style = 'slot_table_spacing_vertical_flow'

player.print("Join the comfy discord >> comfyplay.net/discord", {r = 110, g = 0, b = 220})
end

function spaghetti()
Expand Down Expand Up @@ -65,4 +64,4 @@ function spaghetti()
game.forces["player"].technologies["worker-robots-speed-6"].enabled = false
end

Event.add(defines.events.on_player_created, player_created)
Event.add(defines.events.on_player_created, on_player_created)
8 changes: 5 additions & 3 deletions maps/fish_defender.lua
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,17 @@ local function on_entity_died(event)
local damage = 25
if global.endgame_modifier then damage = 25 + math.ceil((global.endgame_modifier * 0.025), 0) end
if damage > 75 then damage = 75 end
damage_entities_in_radius(event.entity.position, 1 + math.floor(global.wave_count * 0.001), damage)
damage_entities_in_radius(event.entity.position, 1, damage)
--damage_entities_in_radius(event.entity.position, 1 + math.floor(global.wave_count * 0.001), damage)
end

if event.entity.name == "big-biter" then
event.entity.surface.create_entity({name = "uranium-cannon-shell-explosion", position = event.entity.position})
local damage = 35
if global.endgame_modifier then damage = 50 + math.ceil((global.endgame_modifier * 0.05), 0) end
if global.endgame_modifier then damage = 35 + math.ceil((global.endgame_modifier * 0.05), 0) end
if damage > 150 then damage = 150 end
damage_entities_in_radius(event.entity.position, 2 + math.floor(global.wave_count * 0.001), damage)
damage_entities_in_radius(event.entity.position, 2, damage)
--damage_entities_in_radius(event.entity.position, 2 + math.floor(global.wave_count * 0.001), damage)
end

if event.entity.name == "behemoth-biter" then
Expand Down
4 changes: 2 additions & 2 deletions maps/spooky_forest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ local function on_entity_died(event)
if math_random(1, 2) ~= 1 then
local name = ore_spawn_raffle[math.random(1,#ore_spawn_raffle)]
local pos = {x = event.entity.position.x, y = event.entity.position.y}
local amount_modifier = math.ceil(1 + game.forces.enemy.evolution_factor * 15)
local size_modifier = math.floor(game.forces.enemy.evolution_factor * 5)
local amount_modifier = math.ceil(1 + game.forces.enemy.evolution_factor * 10)
local size_modifier = math.floor(game.forces.enemy.evolution_factor * 4)
if name == "crude-oil" then
map_functions.draw_oil_circle(pos, name, surface, 4, math.ceil(100000 * amount_modifier))
else
Expand Down

0 comments on commit 1801b1c

Please sign in to comment.