1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

Merge pull request #282 from ComfyFactory/mtn_v3

Mtn v3 changes and modules changes
This commit is contained in:
Gerkiz 2022-07-11 00:35:46 +02:00 committed by GitHub
commit 96b4a2986b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 1395 additions and 512 deletions

View File

@ -9,19 +9,20 @@ spidertron_unlocked=[color=blue]Mapkeeper:[/color]\nAttention! Spidertron has be
wall_breached=[color=blue]Mapkeeper:[/color]\nSurvivor! Well done. You have completed zone __1__!
first_to_reach=[color=blue]Mapkeeper:[/color]\n__1__ was the first to reach zone __2__.
artillery_warning=[color=blue]Mapkeeper:[/color]\nWarning, Artillery have been spotted north!
cheating_through=__1__ tried to cheat their way north with their spidertron!
hinder=You are too far away from the main locomotive. You cannot go beyond this point.
cheating_through=[color=blue]Mapkeeper:[/color] __1__ tried to cheat their way north with their spidertron!
hinder=[color=blue]Mapkeeper:[/color] You are too far away from the main locomotive. You cannot go beyond this point.
heavy_legs=[color=blue]Mapkeeper:[/color] Your legs feels all of a sudden very heavy.
[entity]
treasure_1=You notice an old crate within the rubble. It's filled with treasure!
treasure_2=You find a chest underneath the broken rocks. It's filled with goodies!
treasure_3=We has found the precious!
treasure_rare_1=Your magic improves. You have found a chest that is filled with rare treasures!
treasure_rare_2=Oh how wonderful. You found a chest underneath the broken rocks. It's filled with rare goodies!
treasure_rare_3=You're a wizard! We have found the rare precious!
treasure_1=[color=blue]Mapkeeper:[/color] You notice an old crate within the rubble. It's filled with treasure!
treasure_2=[color=blue]Mapkeeper:[/color] You find a chest underneath the broken rocks. It's filled with goodies!
treasure_3=[color=blue]Mapkeeper:[/color] We has found the precious!
treasure_rare_1=[color=blue]Mapkeeper:[/color] Your magic improves. You have found a chest that is filled with rare treasures!
treasure_rare_2=[color=blue]Mapkeeper:[/color] Oh how wonderful. You found a chest underneath the broken rocks. It's filled with rare goodies!
treasure_rare_3=[color=blue]Mapkeeper:[/color] You're a wizard! We have found the rare precious!
defeated_1=[color=blue]Mapkeeper:[/color]\nOh no, the biters nom'ed the train away!\nBetter luck next time.
defeated_2=[color=blue]Mapkeeper:[/color]\nI'm not 100% sure, but - apparently the train was chewed away.\nBetter luck next time.
defeated_2=[color=blue]Mapkeeper:[/color]\nApparently the train was chewed away.\nBetter luck next time.
defeated_3=[color=blue]Mapkeeper:[/color]\nYou had one objective - defend the train *-*\nBetter luck next time.
defeated_4=[color=blue]Mapkeeper:[/color]\nLooks like we're resetting cause you did not defend the train ._.\nBetter luck next time.
reset_game=*** Soft-reset is disabled! Server will restart from scenario to load new changes. ***
@ -30,8 +31,8 @@ shutdown_game=*** Soft-reset is disabled! Server will shutdown. Most likely beca
notify_shutdown=Soft-reset is disabled! Server will shutdown. Most likely because of updates.
train_taking_damage=[color=blue]Comfylatron:[/color]\nTrain is taking heavy damage.\nDeploying defense mechanisms.
entity_limit_reached=__1__ limit reached. Purchase more slots at the market!
found_car=__1__ has found a car underneath the rumble!
radar_limit=Another radar is found nearby!
found_car=[color=blue]Mapkeeper:[/color] __1__ has found a car underneath the rumble!
radar_limit=[color=blue]Mapkeeper:[/color] Another radar is found nearby!
[gui]
@ -91,18 +92,18 @@ locomotive_health=__1__ unlocked the last missing piece for the mystical chest!\
[main_market]
chest=Upgrades the amount of chests that can be placed outside.\nCan be purchased multiple times. [__1__/7]
locomotive_max_health=Upgrades the train health.\nCan be purchased multiple times. [__1__/99]
locomotive_xp_aura=Upgrades the XP aura that is around the train. [__1__]
chest=Upgrades the amount of chests that can be placed outside.\nCan be purchased multiple times. [__1__/__2__]
locomotive_max_health=Upgrades the train health.\nCan be purchased multiple times. [__1__/__2__]
locomotive_aura_radius=Upgrades the XP aura that is around the train. [__1__/__2__]\n[Limited to save UPS]
global_car_health_modifier=Grants all cars/tanks/spidertrons a global health modifier.
xp_points_boost=Upgrades the amount of XP points you get inside the XP aura [__1__]
xp_points_boost=Upgrades the amount of XP points you get inside the XP aura [__1__/♾]
mystical_chest=Rerolls the mystical chest.
explosive_bullets=Upgrades ordinary SMG ammo to explosive bullets.
reroll_market_items=Will reroll the items in the market and shuffle prices.
purchase_pickaxe=Upgrade the teams Pickaxe to tier: __1__ [__2__/58]
purchase_pickaxe=Upgrade the teams Pickaxe to tier: __1__ [__2__/__3__]
sold_out=Sold out!
flamethrower_turret=Upgrades the amount of flamethrowers that can be placed. [__1__]
land_mine=Upgrades the amount of landmines that can be placed. [__1__]
flamethrower_turret=Upgrades the amount of flamethrowers that can be placed. [__1__/♾]
land_mine=Upgrades the amount of landmines that can be placed. [__1__/♾]
car=Portable Car Surface\nCan be killed easily.
tank=Portable Tank Surface\nChonk tank, can resist heavy damage.
tank_cannon_na=Tank Cannon\nAvailable after wave __1__.
@ -118,7 +119,13 @@ death_message_6=__1__ got obliterated!
death_message_7=__1__ tried to cheat their way north!
forcefield=Forcefield does not approve.
greeting=[color=blue]Comfylatron:[/color]\nGreetings, __1__!\nPlease read the map info.
death_mode_warning=[color=blue]Comfylatron:[/color]\nCAUTION! Walking outside of the locomotive aura will kill you!
aura_upgrade_warning=[color=blue]Comfylatron:[/color]\nThe locomotive aura range has been upgraded!
damage_mode_warning=[color=blue]Comfylatron:[/color]\nCAUTION! Walking outside of the locomotive aura will slowly kill you!
cleaner=[color=blue]Cleaner:[/color]\n__1__ has left his goodies! Be quick and fetch them!
reset_in=Game will __1__ in __2__ seconds!
diff_set=Difficulty has been set! Game has been set to: [color=green]__1__[/color]
diff_tooltip=Wave Defense is based on amount of players.\nBonus XP on join: __1__.\nMining speed boost: __2__.\nRunning speed boost: __3__.\nCrafting speed boost: __4__.\nMaximum coin per harvest: __5__.\nFlame Turret limit: __6__.\nLandmine limit: __7__.\nLocomotive health: __8__.\nHidden Treasure has __9__ chance to spawn.\nGrace period: __10__ minutes\nSpidertrons unlocks at zone __11__.
[functions]
researched_complete=__1__ has been researched!

View File

@ -90,7 +90,7 @@ locomotive_health=__1__ разблокировал последнюю недос
[main_market]
chest=Увеличивает количество сундуков, которые можно разместить снаружи.\nМожно купить несколько раз. [__1__/7]
locomotive_max_health=Улучшает здоровье поезда.\nМожно купить несколько раз. [__1__/99]
locomotive_xp_aura=Улучшает зону опыта вокруг поезда. [__1__]
locomotive_aura_radius=Улучшает зону опыта вокруг поезда. [__1__]
global_car_health_modifier=Даёт всем автомобилям/танкам/паукотронам глобальный модификатор здоровья.
xp_points_boost=Увеличивает количество очков опыта, которые вы получаете внутри зоны опыта. [__1__]
mystical_chest=Обновляет содержимое загадочного сундука.

View File

@ -77,7 +77,7 @@ new_items_at_market=火车市场已经解锁了新物品!
[main_market]
chest=提高了可以在外面放置的箱子数量.\n可以多次购买.
locomotive_max_health=升级火车生命.\n可以多次购买
locomotive_xp_aura=升级火车周围的经验光环。
locomotive_aura_radius=升级火车周围的经验光环。
xp_points_boost=升级您在经验光环中获得的经验值
explosive_bullets=将普通的SMG弹药升级为爆炸子弹.
reroll_market_items=重置市场的商品并调整价格.

View File

@ -51,7 +51,7 @@ local function enemy_weapon_damage()
}
for k, v in pairs(data) do
local new = Difficulty.get().difficulty_vote_value * v
local new = Difficulty.get().value * v
local e_old = e.get_ammo_damage_modifier(k)

View File

@ -1,3 +1,4 @@
local Modifiers = require 'utils.player_modifiers'
local Collapse = require 'modules.collapse'
local Balance = require 'maps.mountain_fortress_v3.balance'
local RPG = require 'modules.rpg.main'
@ -131,23 +132,41 @@ local compare_player_pos = function(player)
end
local zone = floor((abs(p.y / zone_settings.zone_depth)) % adjusted_zones.size) + 1
local rpg_t = RPG.get_value_from_player(index)
if adjusted_zones.scrap[zone] then
RPG.set_value_to_player(index, 'scrap_zone', true)
if rpg_t and not rpg_t.scrap_zone then
rpg_t.scrap_zone = true
end
else
local has_scrap = RPG.get_value_from_player(index, 'scrap_zone')
if has_scrap then
RPG.set_value_to_player(index, 'scrap_zone', false)
if rpg_t and rpg_t.scrap_zone then
rpg_t.scrap_zone = false
end
end
if adjusted_zones.forest[zone] then
RPG.set_value_to_player(index, 'forest_zone', true)
else
local is_in_forest = RPG.get_value_from_player(index, 'forest_zone')
if is_in_forest then
RPG.set_value_to_player(index, 'forest_zone', false)
if rpg_t and not rpg_t.forest_zone then
rpg_t.forest_zone = true
end
else
if rpg_t and rpg_t.forest_zone then
rpg_t.forest_zone = false
end
end
if adjusted_zones.slow_movement[zone] then
if player.character and player.character.valid then
player.character.character_running_speed_modifier = -0.5
end
if rpg_t and not rpg_t.slow_movement_zone then
player.print(({'breached_wall.heavy_legs'}))
rpg_t.slow_movement_zone = true
end
else
if rpg_t and rpg_t.slow_movement_zone then
rpg_t.slow_movement_zone = false
end
Modifiers.update_player_modifiers(player)
end
end

View File

@ -156,6 +156,40 @@ commands.add_command(
end
)
commands.add_command(
'toggle_orbital_strikes',
'Usable only for admins - toggles orbital strikes!',
function()
local player = game.player
if not player and player.valid then
return
end
if not player.admin then
player.print("[ERROR] You're not admin!", Color.fail)
return
end
local this = WPT.get()
if not this.orbital_strikes_are_you_sure then
this.orbital_strikes_are_you_sure = true
player.print('[WARNING] This command will disable the orbital_strikes in-game, run this command again if you really want to do this!', Color.warning)
return
end
if this.orbital_strikes.enabled then
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled the orbital_strikes module!', {r = 0.98, g = 0.66, b = 0.22})
this.orbital_strikes.enabled = false
else
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled the orbital_strikes module!', {r = 0.98, g = 0.66, b = 0.22})
this.orbital_strikes.enabled = true
end
this.orbital_strikes_are_you_sure = nil
end
)
commands.add_command(
'get_queue_speed',
'Usable only for admins - gets the queue speed of this map!',

View File

@ -1194,11 +1194,14 @@ local function show_mvps(player)
local collapse_amount = Collapse.get_amount()
local diff = Diff.get()
if not diff then
return
end
local time_played = Core.format_time(game.ticks_played)
local total_players = #game.players
local pickaxe_tiers = WPT.pickaxe_upgrades
local tier = WPT.get('pickaxe_tier')
local pick_tier = pickaxe_tiers[tier]
local pickaxe_upgrades = WPT.pickaxe_upgrades
local upgrades = WPT.get('upgrades')
local pick_tier = pickaxe_upgrades[upgrades.pickaxe_tier]
local server_name_matches = Server.check_server_name('Mtn Fortress')
if WPT.get('prestige_system_enabled') then
@ -1207,7 +1210,7 @@ local function show_mvps(player)
local date = Server.get_start_time()
game.server_save('Final_Mtn_Fortress_v3_' .. tostring(date))
local text = {
title = 'Game over <:helper:627426785918713877>',
title = 'Game over!',
description = 'Game statistics from the game is below',
color = 'failure',
field1 = {
@ -1241,7 +1244,7 @@ local function show_mvps(player)
},
field6 = {
text1 = 'Pickaxe Upgrade:',
text2 = pick_tier .. ' (' .. tier .. ')',
text2 = pick_tier .. ' (' .. pick_tier .. ')',
inline = 'true',
emptyField = 'true',
emptyInline = 'true'

View File

@ -1,3 +1,4 @@
local Server = require 'utils.server'
local Token = require 'utils.token'
local Task = require 'utils.task'
local Color = require 'utils.color_presets'
@ -14,6 +15,7 @@ local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
local math2d = require 'math2d'
local Misc = require 'utils.commands.misc'
local Core = require 'utils.core'
local Beams = require 'modules.render_beam'
local zone_settings = WPT.zone_settings
local this = {
@ -72,8 +74,8 @@ local Public = {}
local random = math.random
local floor = math.floor
local round = math.round
local remove = table.remove
local sqrt = math.sqrt
local remove = table.remove
local magic_crafters_per_tick = 3
local magic_fluid_crafters_per_tick = 8
local tile_damage = 50
@ -293,10 +295,58 @@ local artillery_target_callback =
end
)
local function difficulty_and_adjust_prices()
local fixed_prices = WPT.get('marked_fixed_prices')
local difficulty_index = Difficulty.get('index')
for index, price in pairs(fixed_prices) do
if difficulty_index == 2 then
fixed_prices[index] = price * 1.5
elseif difficulty_index == 3 then
fixed_prices[index] = price * 2
end
end
end
local function do_beams_away()
local wave_number = WD.get_wave()
local orbital_strikes = WPT.get('orbital_strikes')
if not orbital_strikes.enabled then
return
end
if wave_number > 1000 then
local difficulty_index = Difficulty.get('index')
local wave_nth = 9999
if difficulty_index == 1 then
wave_nth = 1000
elseif difficulty_index == 2 then
wave_nth = 500
elseif difficulty_index == 3 then
wave_nth = 250
end
if wave_number % wave_nth == 0 then
local active_surface_index = WPT.get('active_surface_index')
local surface = game.get_surface(active_surface_index)
if not orbital_strikes[wave_number] then
orbital_strikes[wave_number] = true
Beams.new_beam_delayed(surface, random(500, 3000))
end
end
end
end
local function do_artillery_turrets_targets()
local art_table = this.art_table
local index = art_table.index
local difficulty_index = Difficulty.get('index')
if difficulty_index == 3 then
return
end
if index > #art_table then
art_table.index = 1
return
@ -375,6 +425,7 @@ local function tick()
do_magic_crafters()
do_magic_fluid_crafters()
do_artillery_turrets_targets()
do_beams_away()
end
Public.deactivate_callback =
@ -817,16 +868,16 @@ function Public.set_difficulty()
local wave_number = WD.get_wave()
local player_count = calc_players()
if not Diff.difficulty_vote_value then
Diff.difficulty_vote_value = 0.1
if not Diff.value then
Diff.value = 0.1
end
if Diff.name == "I'm too young to die" then
wave_defense_table.max_active_biters = 768 + player_count * (90 * Diff.difficulty_vote_value)
elseif Diff.name == 'Hurt me plenty' then
wave_defense_table.max_active_biters = 845 + player_count * (90 * Diff.difficulty_vote_value)
elseif Diff.name == 'Ultra-violence' then
wave_defense_table.max_active_biters = 1000 + player_count * (90 * Diff.difficulty_vote_value)
if Diff.index == 1 then
wave_defense_table.max_active_biters = 768 + player_count * (90 * Diff.value)
elseif Diff.index == 2 then
wave_defense_table.max_active_biters = 845 + player_count * (90 * Diff.value)
elseif Diff.index == 3 then
wave_defense_table.max_active_biters = 1000 + player_count * (90 * Diff.value)
end
if wave_defense_table.max_active_biters >= 4000 then
@ -834,12 +885,12 @@ function Public.set_difficulty()
end
-- threat gain / wave
if Diff.name == "I'm too young to die" then
wave_defense_table.threat_gain_multiplier = 1.2 + player_count * Diff.difficulty_vote_value * 0.1
elseif Diff.name == 'Hurt me plenty' then
wave_defense_table.threat_gain_multiplier = 2 + player_count * Diff.difficulty_vote_value * 0.1
elseif Diff.name == 'Ultra-violence' then
wave_defense_table.threat_gain_multiplier = 4 + player_count * Diff.difficulty_vote_value * 0.1
if Diff.index == 1 then
wave_defense_table.threat_gain_multiplier = 1.2 + player_count * Diff.value * 0.1
elseif Diff.index == 2 then
wave_defense_table.threat_gain_multiplier = 2 + player_count * Diff.value * 0.1
elseif Diff.index == 3 then
wave_defense_table.threat_gain_multiplier = 4 + player_count * Diff.value * 0.1
end
-- local amount = player_count * 0.40 + 2 -- too high?
@ -857,7 +908,7 @@ function Public.set_difficulty()
threat_check = wave_defense_table.threat <= 0
end
if Diff.name == "I'm too young to die" then
if Diff.index == 1 then
if player_count < 10 then
wave_defense_table.wave_interval = 4500
else
@ -866,7 +917,7 @@ function Public.set_difficulty()
if wave_defense_table.wave_interval < 2200 or threat_check then
wave_defense_table.wave_interval = 2200
end
elseif Diff.name == 'Hurt me plenty' then
elseif Diff.index == 2 then
if player_count < 10 then
wave_defense_table.wave_interval = 3000
else
@ -875,7 +926,7 @@ function Public.set_difficulty()
if wave_defense_table.wave_interval < 1900 or threat_check then
wave_defense_table.wave_interval = 1900
end
elseif Diff.name == 'Ultra-violence' then
elseif Diff.index == 3 then
if player_count < 10 then
wave_defense_table.wave_interval = 2000
else
@ -1038,17 +1089,16 @@ function Public.boost_difficulty()
local breached_wall = WPT.get('breached_wall')
local difficulty = Difficulty.get()
local name = difficulty.difficulties[difficulty.difficulty_vote_index].name
if game.tick < difficulty.difficulty_poll_closing_timeout and breached_wall <= 1 then
if not difficulty then
return
end
Difficulty.get().name = name
Difficulty.get().difficulty_poll_closing_timeout = game.tick
local index = difficulty.index
local name = difficulty.name
Difficulty.get().button_tooltip = difficulty.tooltip[difficulty.difficulty_vote_index]
Difficulty.difficulty_gui()
if game.tick < difficulty.closing_timeout and breached_wall <= 1 then
return
end
local message = ({'main.diff_set', name})
local data = {
@ -1058,6 +1108,10 @@ function Public.boost_difficulty()
local force = game.forces.player
local active_surface_index = WPT.get('active_surface_index')
local surface = game.get_surface(active_surface_index)
if index == 1 then
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
force.character_running_speed_modifier = 0.15
force.manual_crafting_speed_modifier = 0.15
@ -1073,7 +1127,90 @@ function Public.boost_difficulty()
WD.set_unit_health_increment_per_wave(0.15)
WD.set_boss_unit_current_health(2)
WD.set_boss_health_increment_per_wave(1.5)
WD.set('death_mode', false)
WPT.set('difficulty_set', true)
elseif index == 2 then
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.25
force.character_running_speed_modifier = 0.1
force.manual_crafting_speed_modifier = 0.1
WPT.set('coin_amount', 2)
WPT.set('upgrades').flame_turret.limit = 10
WPT.set('upgrades').landmine.limit = 50
WPT.set('locomotive_health', 7000)
WPT.set('locomotive_max_health', 7000)
WPT.set('bonus_xp_on_join', 300)
WD.set('next_wave', game.tick + 3600 * 8)
WPT.set('spidertron_unlocked_at_zone', 8)
WD.set_normal_unit_current_health(1.6)
WD.set_unit_health_increment_per_wave(0.5)
WD.set_boss_unit_current_health(3)
WD.set_boss_health_increment_per_wave(5)
WD.set('death_mode', false)
WPT.set('difficulty_set', true)
local damage_warning = ({'main.damage_mode_warning'})
Alert.alert_all_players_location(data, damage_warning)
Core.iter_players(
function(player)
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
if pos then
player.teleport(pos, surface)
else
pos = game.forces.player.get_spawn_position(surface)
player.teleport(pos, surface)
end
end
)
elseif index == 3 then
force.character_running_speed_modifier = 0
force.manual_crafting_speed_modifier = 0
WPT.set('coin_amount', 4)
WPT.set('upgrades').flame_turret.limit = 3
WPT.set('upgrades').landmine.limit = 10
WPT.set('locomotive_health', 5000)
WPT.set('locomotive_max_health', 5000)
WPT.set('bonus_xp_on_join', 50)
WD.set('next_wave', game.tick + 3600 * 5)
WPT.set('spidertron_unlocked_at_zone', 6)
WD.set_normal_unit_current_health(2)
WD.set_unit_health_increment_per_wave(1)
WD.set_boss_unit_current_health(4)
WD.set_boss_health_increment_per_wave(10)
WD.set('death_mode', true)
WPT.set('difficulty_set', true)
Core.iter_players(
function(player)
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
if pos then
player.teleport(pos, surface)
else
pos = game.forces.player.get_spawn_position(surface)
player.teleport(pos, surface)
end
end
)
local upgrades = WPT.get('upgrades')
upgrades.locomotive_aura_radius = upgrades.locomotive_aura_radius + 20
if WPT.get('circle') then
rendering.destroy(WPT.get('circle'))
end
local locomotive = WPT.get('locomotive')
WPT.set(
'circle',
rendering.draw_circle {
surface = active_surface_index,
target = locomotive,
color = locomotive.color,
filled = false,
radius = upgrades.locomotive_aura_radius,
only_in_alt_mode = false
}
)
local aura_upgrade = ({'main.aura_upgrade_warning'})
Alert.alert_all_players_location(data, aura_upgrade)
local death_warning = ({'main.death_mode_warning'})
Alert.alert_all_players_location(data, death_warning)
difficulty_and_adjust_prices()
end
end
function Public.set_spawn_position()
@ -1204,6 +1341,10 @@ function Public.on_player_joined_game(event)
end
local message = ({'main.greeting', player.name})
Alert.alert_player(player, 15, message)
if WPT.get('death_mode') then
local death_message = ({'main.death_mode_warning'})
Alert.alert_player(player, 15, death_message)
end
for item, amount in pairs(starting_items) do
player.insert({name = item, count = amount})
end
@ -1365,6 +1506,15 @@ function Public.on_research_finished(event)
local bonus_drill = game.forces.bonus_drill
local player = game.forces.player
local research_name = research.name
local force = research.force
local technology_prototypes = game.technology_prototypes
if WPT.get('print_tech_to_discord') and force.name == 'player' then
Server.to_discord_bold({'functions.researched_complete', technology_prototypes[research_name].localised_name}, true)
end
research.force.character_inventory_slots_bonus = player.mining_drill_productivity_bonus * 50 -- +5 Slots /
bonus_drill.mining_drill_productivity_bonus = bonus_drill.mining_drill_productivity_bonus + 0.03
if bonus_drill.mining_drill_productivity_bonus >= 3 then

View File

@ -410,8 +410,6 @@ function Public.update_gui(player)
local mined_scrap = WPT.get('mined_scrap')
local biters_killed = WPT.get('biters_killed')
local upgrades = WPT.get('upgrades')
local train_upgrades = WPT.get('train_upgrades')
local chest_limit_outside_upgrades = WPT.get('chest_limit_outside_upgrades')
if rpg_extra.global_pool == 0 then
gui.global_pool.caption = 'XP: 0'
@ -424,12 +422,11 @@ function Public.update_gui(player)
gui.scrap_mined.caption = ' [img=entity.tree-01][img=entity.rock-huge]: ' .. format_number(mined_scrap, true)
gui.scrap_mined.tooltip = ({'gui.amount_harvested'})
local pickaxe_tiers = WPT.pickaxe_upgrades
local tier = WPT.get('pickaxe_tier')
local pick_tier = pickaxe_tiers[tier]
local pickaxe_upgrades = WPT.pickaxe_upgrades
local pick_tier = pickaxe_upgrades[upgrades.pickaxe_tier]
local speed = math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100)
gui.pickaxe_tier.caption = ' [img=item.dummy-steel-axe]: ' .. pick_tier .. ' (' .. tier .. ')'
gui.pickaxe_tier.caption = ' [img=item.dummy-steel-axe]: ' .. pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')'
gui.pickaxe_tier.tooltip = ({'gui.current_pickaxe_tier', pick_tier, speed})
gui.biters_killed.caption = ' [img=entity.small-biter]: ' .. format_number(biters_killed, true)
@ -441,10 +438,10 @@ function Public.update_gui(player)
gui.flame_turret.caption = ' [img=entity.flamethrower-turret]: ' .. format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true)
gui.flame_turret.tooltip = ({'gui.flamethrowers_placed'})
gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(train_upgrades, true)
gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(upgrades.train_upgrades, true)
gui.train_upgrades.tooltip = ({'gui.train_upgrades'})
gui.chest_upgrades.caption = ' [img=entity.steel-chest]: ' .. format_number(chest_limit_outside_upgrades, true)
gui.chest_upgrades.caption = ' [img=entity.steel-chest]: ' .. format_number(upgrades.chests_outside_upgrades, true)
gui.chest_upgrades.tooltip = ({'gui.chest_placed'})
end

View File

@ -213,7 +213,7 @@ local function get_saved_entity(entity, index)
end
local function replace_entity(cars, entity, index)
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
local upgrades = WPT.get('upgrades')
local unit_number = entity.unit_number
local health = floor(2000 * entity.health * 0.002)
for k, car in pairs(cars) do
@ -224,7 +224,7 @@ local function replace_entity(cars, entity, index)
cars[unit_number].saved_entity = nil
cars[unit_number].transfer_entities = car.transfer_entities
cars[unit_number].health_pool = {
enabled = has_upgraded_health_pool or false,
enabled = upgrades.has_upgraded_health_pool or false,
health = health,
max = health
}
@ -1098,7 +1098,7 @@ function Public.create_car(event)
end
local renders = IC.get('renders')
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
local upgrades = WPT.get('upgrades')
local name, mined = get_player_entity(player)
@ -1148,7 +1148,7 @@ function Public.create_car(event)
},
doors = {},
health_pool = {
enabled = has_upgraded_health_pool or false,
enabled = upgrades.has_upgraded_health_pool or false,
health = health,
max = health
},
@ -1352,7 +1352,7 @@ function Public.check_entity_healths()
['spidertron'] = 3000
}
for k, car in pairs(cars) do
for _, car in pairs(cars) do
local m = car.health_pool.health / car.health_pool.max
if car.health_pool.health > car.health_pool.max then

View File

@ -102,8 +102,8 @@ local function on_tick()
if tick % 20 == 1 then
Functions.item_transfer()
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
if has_upgraded_health_pool then
local upgrades = WPT.get('upgrades')
if upgrades.has_upgraded_health_pool then
Functions.check_entity_healths()
end
end
@ -214,8 +214,8 @@ local function on_gui_switch_state_changed(event)
end
local function on_entity_damaged(event)
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
if not has_upgraded_health_pool then
local upgrades = WPT.get('upgrades')
if not upgrades.has_upgraded_health_pool then
return
end
@ -252,8 +252,8 @@ local function on_entity_damaged(event)
end
local function on_player_repaired_entity(event)
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
if not has_upgraded_health_pool then
local upgrades = WPT.get('upgrades')
if not upgrades.has_upgraded_health_pool then
return
end

View File

@ -9,7 +9,6 @@ local Difficulty = require 'modules.difficulty_vote_by_amount'
local RPG = require 'modules.rpg.main'
local Gui = require 'utils.gui'
local Alert = require 'utils.alert'
local Math2D = require 'math2d'
local PermissionGroups = require 'maps.mountain_fortress_v3.locomotive.permission_groups'
local Public = {}
@ -18,6 +17,7 @@ local rpg_main_frame = RPG.main_frame_name
local random = math.random
local floor = math.floor
local round = math.round
local sub = string.sub
local clear_items_upon_surface_entry = {
['entity-ghost'] = true,
@ -33,6 +33,11 @@ local valid_armors = {
['power-armor-mk2'] = true
}
local non_valid_vehicles = {
['car'] = true,
['spider-vehicle'] = true
}
local function add_random_loot_to_main_market(rarity)
local main_market_items = WPT.get('main_market_items')
local items = Market.get_random_item(rarity, true, false)
@ -91,6 +96,109 @@ local function validate_player(player)
return true
end
local function death_effects(player)
local position = {x = player.position.x - 0.75, y = player.position.y - 1}
local b = 0.75
for _ = 1, 5, 1 do
local p = {
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
}
player.surface.create_entity({name = 'flying-text', position = p, text = '☠️', color = {255, math.random(0, 100), 0}})
end
player.play_sound {path = 'utility/axe_fighting', volume_modifier = 0.9}
end
local messages = {
' likes to play in magma.',
' got melted.',
' tried to swim in lava.',
' was incinerated.',
" couldn't put the fire out.",
' was turned into their molten form.'
}
local function is_around_train(data)
local entity = data.entity
local locomotive_aura_radius = data.locomotive_aura_radius + 20
local loco = data.locomotive.position
local position = entity.position
local inside = ((position.x - loco.x) ^ 2 + (position.y - loco.y) ^ 2) < locomotive_aura_radius ^ 2
if inside then
return true
end
return false
end
local function hurt_players_outside_of_aura()
local Diff = Difficulty.get()
if not Diff then
return
end
local difficulty_set = WPT.get('difficulty_set')
if not difficulty_set then
return
end
local death_mode = false
if Diff.index == 1 then
return
elseif Diff.index == 3 then
death_mode = true
end
local loco_surface = WPT.get('loco_surface')
if not (loco_surface and loco_surface.valid) then
return
end
local locomotive = WPT.get('locomotive')
local loco = locomotive.position
local upgrades = WPT.get('upgrades')
local players = game.connected_players
for i = 1, #players do
local player = players[i]
if validate_player(player) then
local map_name = 'mtn_v3'
if sub(player.surface.name, 0, #map_name) == map_name then
local position = player.position
local inside = ((position.x - loco.x) ^ 2 + (position.y - loco.y) ^ 2) < upgrades.locomotive_aura_radius ^ 2
if not inside then
death_effects(player)
player.surface.create_entity({name = 'fire-flame', position = position})
if random(1, 3) == 1 then
player.surface.create_entity({name = 'medium-scorchmark', position = position, force = 'neutral'})
end
local entity = player.character
if entity and entity.valid then
local max_health = floor(player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus)
local vehicle = player.vehicle
if vehicle and vehicle.valid and non_valid_vehicles[vehicle.type] then
player.driving = false
end
if death_mode then
if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end
entity.die()
else
entity.damage(1, 'enemy')
entity.health = entity.health - (max_health / 25)
if entity.health <= 0 then
if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end
entity.die()
end
end
end
end
end
end
end
end
local function give_passive_xp(data)
local xp_floating_text_color = {r = 188, g = 201, b = 63}
local visuals_delay = 1800
@ -98,23 +206,19 @@ local function give_passive_xp(data)
if not (loco_surface and loco_surface.valid) then
return
end
local locomotive_xp_aura = WPT.get('locomotive_xp_aura')
local upgrades = WPT.get('upgrades')
local locomotive = WPT.get('locomotive')
local xp_points = WPT.get('xp_points')
local aura = locomotive_xp_aura
local rpg = data.rpg
local loco = locomotive.position
local area = {
left_top = {x = loco.x - aura, y = loco.y - aura},
right_bottom = {x = loco.x + aura, y = loco.y + aura}
}
for _, player in pairs(game.connected_players) do
if not validate_player(player) then
return
end
local position = player.position
local inside = ((position.x - loco.x) ^ 2 + (position.y - loco.y) ^ 2) < upgrades.locomotive_aura_radius ^ 2
if player.afk_time < 200 and not RPG.get_last_spell_cast(player) then
if Math2D.bounding_box.contains_point(area, player.position) or player.surface.index == loco_surface.index then
if inside or player.surface.index == loco_surface.index then
if player.surface.index == loco_surface.index then
PermissionGroups.add_player_to_permission_group(player, 'limited')
elseif ICFunctions.get_player_surface(player) then
@ -124,7 +228,7 @@ local function give_passive_xp(data)
end
local pos = player.position
RPG.gain_xp(player, 0.5 * (rpg[player.index].bonus + xp_points))
RPG.gain_xp(player, 0.5 * (rpg[player.index].bonus + upgrades.xp_points))
player.create_local_flying_text {
text = '+' .. '',
@ -156,22 +260,6 @@ local function give_passive_xp(data)
end
end
local function is_around_train(data)
local entity = data.entity
local aura = data.aura + 20
local loco = data.locomotive.position
local area = {
left_top = {x = loco.x - aura, y = loco.y - aura},
right_bottom = {x = loco.x + aura, y = loco.y + aura}
}
local pos = entity.position
if Math2D.bounding_box.contains_point(area, pos) then
return true
end
return false
end
local function fish_tag()
local locomotive_cargo = WPT.get('locomotive_cargo')
if not (locomotive_cargo and locomotive_cargo.valid) then
@ -488,13 +576,13 @@ function Public.is_around_train(entity)
end
local surface = game.surfaces[active_surface_index]
local aura = WPT.get('locomotive_xp_aura')
local upgrades = WPT.get('upgrades')
local data = {
locomotive = locomotive,
surface = surface,
entity = entity,
aura = aura
locomotive_aura_radius = upgrades.locomotive_aura_radius
}
local success = is_around_train(data)
@ -508,9 +596,10 @@ function Public.render_train_hp()
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
local locomotive = WPT.get('locomotive')
local locomotive_xp_aura = WPT.get('locomotive_xp_aura')
local upgrades = WPT.get('upgrades')
WPT.set().health_text =
WPT.set(
'health_text',
rendering.draw_text {
text = 'HP: ' .. locomotive_health .. ' / ' .. locomotive_max_health,
surface = surface,
@ -522,8 +611,10 @@ function Public.render_train_hp()
alignment = 'center',
scale_with_zoom = false
}
)
WPT.set().caption =
WPT.set(
'caption',
rendering.draw_text {
text = 'Comfy Choo Choo',
surface = surface,
@ -535,16 +626,19 @@ function Public.render_train_hp()
alignment = 'center',
scale_with_zoom = false
}
)
WPT.set().circle =
WPT.set(
'circle',
rendering.draw_circle {
surface = surface,
target = locomotive,
color = locomotive.color,
filled = false,
radius = locomotive_xp_aura,
radius = upgrades.locomotive_aura_radius,
only_in_alt_mode = true
}
)
end
function Public.transfer_pollution()
@ -567,7 +661,7 @@ function Public.transfer_pollution()
local total_interior_pollution = surface.get_total_pollution()
local pollution = surface.get_total_pollution() * (3 / (4 / 3 + 1)) * Difficulty.get().difficulty_vote_value
local pollution = surface.get_total_pollution() * (3 / (4 / 3 + 1)) * Difficulty.get().value
active_surface.pollute(locomotive.position, pollution)
game.pollution_statistics.on_flow('locomotive', pollution - total_interior_pollution)
surface.clear_pollution()
@ -583,10 +677,12 @@ local function tick()
set_locomotive_health()
validate_index()
fish_tag()
hurt_players_outside_of_aura()
end
if ticker % 120 == 0 then
-- tp_player()
boost_players()
end

View File

@ -16,7 +16,7 @@ local function contains_positions(area)
for _, wagon in pairs(wagons) do
if wagon.entity and wagon.entity.valid then
if wagon.entity.name == 'cargo-wagon' then
if inside(wagon.entity.position, area) then
if inside(wagon.entity.position) then
return true, wagon.entity
end
end
@ -54,15 +54,15 @@ local function on_built_entity(event)
local outside_chests = WPT.get('outside_chests')
local chests_linked_to = WPT.get('chests_linked_to')
local chest_limit_outside_upgrades = WPT.get('chest_limit_outside_upgrades')
local upgrades = WPT.get('upgrades')
local chest_created
local increased = false
for k, data in pairs(outside_chests) do
for _, data in pairs(outside_chests) do
if data and data.chest and data.chest.valid then
if chests_linked_to[train.unit_number] then
local linked_to = chests_linked_to[train.unit_number].count
if linked_to == chest_limit_outside_upgrades then
if linked_to == upgrades.chests_outside_upgrades then
return
end
outside_chests[entity.unit_number] = {chest = entity, position = entity.position, linked = train.unit_number}
@ -80,6 +80,7 @@ local function on_built_entity(event)
end
::continue::
outside_chests[entity.unit_number].render =
rendering.draw_text {
text = '',
surface = entity.surface,
@ -102,6 +103,7 @@ local function on_built_entity(event)
chests_linked_to[train.unit_number] = {count = 1}
chests_linked_to[train.unit_number][entity.unit_number] = true
outside_chests[entity.unit_number].render =
rendering.draw_text {
text = '',
surface = entity.surface,
@ -159,6 +161,9 @@ local function divide_contents()
if not (chest and chest.valid) then
if chests_linked_to[data.linked] then
if chests_linked_to[data.linked][key] then
if data.render and rendering.is_valid(data.render) then
rendering.destroy(data.render)
end
chests_linked_to[data.linked][key] = nil
chests_linked_to[data.linked].count = chests_linked_to[data.linked].count - 1
if chests_linked_to[data.linked].count <= 0 then
@ -175,12 +180,16 @@ local function divide_contents()
target_chest = entity
else
if chests_linked_to[data.linked] then
if chests_linked_to[data.linked][key] then
if data then
if data.render and rendering.is_valid(data.render) then
rendering.destroy(data.render)
end
chests_linked_to[data.linked][key] = nil
chests_linked_to[data.linked].count = chests_linked_to[data.linked].count - 1
if chests_linked_to[data.linked].count <= 0 then
chests_linked_to[data.linked] = nil
end
outside_chests[key] = nil
end
end
goto continue

View File

@ -44,34 +44,28 @@ local function add_space(frame)
end
local function get_items()
local chest_limit_outside_upgrades = WPT.get('chest_limit_outside_upgrades')
local health_upgrades = WPT.get('health_upgrades')
local pickaxe_tier = WPT.get('pickaxe_tier')
local aura_upgrades = WPT.get('aura_upgrades')
local market_limits = WPT.get('market_limits')
local main_market_items = WPT.get('main_market_items')
local xp_points_upgrade = WPT.get('xp_points_upgrade')
local flame_turret = WPT.get('upgrades').flame_turret.bought
local landmine = WPT.get('upgrades').landmine.bought
local upgrades = WPT.get('upgrades')
local fixed_prices = WPT.get('marked_fixed_prices')
local health_upgrades_limit = WPT.get('health_upgrades_limit')
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
local chest_limit_cost = round(fixed_prices.chest_limit_cost * (1 + chest_limit_outside_upgrades))
local health_cost = round(fixed_prices.health_cost * (1 + health_upgrades))
local pickaxe_cost = round(fixed_prices.pickaxe_cost * (0.1 + pickaxe_tier / 2))
local aura_cost = round(fixed_prices.aura_cost * (1 + aura_upgrades))
local xp_point_boost_cost = round(fixed_prices.xp_point_boost_cost * (1 + xp_points_upgrade))
local chests_outside_cost = round(fixed_prices.chests_outside_cost * (1 + upgrades.chests_outside_upgrades))
local health_cost = round(fixed_prices.health_cost * (1 + upgrades.health_upgrades))
local pickaxe_cost = round(fixed_prices.pickaxe_cost * (0.1 + upgrades.pickaxe_tier / 2))
local aura_cost = round(fixed_prices.aura_cost * (1 + upgrades.aura_upgrades))
local xp_point_boost_cost = round(fixed_prices.xp_point_boost_cost * (1 + upgrades.xp_points_upgrade))
local explosive_bullets_cost = round(fixed_prices.explosive_bullets_cost)
local redraw_mystical_chest_cost = round(fixed_prices.redraw_mystical_chest_cost)
local flamethrower_turrets_cost = round(fixed_prices.flamethrower_turrets_cost * (1 + flame_turret))
local land_mine_cost = round(fixed_prices.land_mine_cost * (1 + landmine))
local land_mine_cost = round(fixed_prices.land_mine_cost * (1 + upgrades.landmine.bought))
local car_health_upgrade_pool = fixed_prices.car_health_upgrade_pool_cost
local pickaxe_tiers = WPT.pickaxe_upgrades
local tier = WPT.get('pickaxe_tier')
local offer = pickaxe_tiers[tier]
local pickaxe_upgrades = WPT.pickaxe_upgrades
if pickaxe_tier >= 59 then
local offer = pickaxe_upgrades[upgrades.pickaxe_tier]
if upgrades.pickaxe_tier >= market_limits.pickaxe_tier_limit then
main_market_items['upgrade_pickaxe'] = {
stack = 1,
value = 'coin',
@ -87,7 +81,7 @@ local function get_items()
stack = 1,
value = 'coin',
price = pickaxe_cost,
tooltip = ({'main_market.purchase_pickaxe', offer, pickaxe_tier - 1}),
tooltip = ({'main_market.purchase_pickaxe', offer, upgrades.pickaxe_tier, market_limits.pickaxe_tier_limit}),
sprite = 'achievement/delivery-service',
enabled = true,
upgrade = true,
@ -95,11 +89,11 @@ local function get_items()
}
end
if chest_limit_outside_upgrades == 8 then
if upgrades.chests_outside_upgrades == market_limits.chests_outside_limit then
main_market_items['chest_limit_outside'] = {
stack = 1,
value = 'coin',
price = chest_limit_cost,
price = chests_outside_cost,
tooltip = ({'locomotive.limit_reached'}),
sprite = 'achievement/so-long-and-thanks-for-all-the-fish',
enabled = false,
@ -110,8 +104,8 @@ local function get_items()
main_market_items['chest_limit_outside'] = {
stack = 1,
value = 'coin',
price = chest_limit_cost,
tooltip = ({'main_market.chest', chest_limit_outside_upgrades - 1}),
price = chests_outside_cost,
tooltip = ({'main_market.chest', upgrades.chests_outside_upgrades, market_limits.chests_outside_limit}),
sprite = 'achievement/so-long-and-thanks-for-all-the-fish',
enabled = true,
upgrade = true,
@ -119,7 +113,7 @@ local function get_items()
}
end
if health_upgrades >= health_upgrades_limit then
if upgrades.health_upgrades >= market_limits.health_upgrades_limit then
main_market_items['locomotive_max_health'] = {
stack = 1,
value = 'coin',
@ -135,7 +129,7 @@ local function get_items()
stack = 1,
value = 'coin',
price = health_cost,
tooltip = ({'main_market.locomotive_max_health', health_upgrades - 1}),
tooltip = ({'main_market.locomotive_max_health', upgrades.health_upgrades, market_limits.health_upgrades_limit}),
sprite = 'achievement/getting-on-track',
enabled = true,
upgrade = true,
@ -143,18 +137,31 @@ local function get_items()
}
end
main_market_items['locomotive_xp_aura'] = {
if upgrades.locomotive_aura_radius == market_limits.aura_limit then
main_market_items['locomotive_aura_radius'] = {
stack = 1,
value = 'coin',
price = aura_cost,
tooltip = ({'main_market.locomotive_xp_aura', aura_upgrades}),
tooltip = ({'locomotive.limit_reached'}),
sprite = 'achievement/tech-maniac',
enabled = false,
upgrade = true,
static = true
}
else
main_market_items['locomotive_aura_radius'] = {
stack = 1,
value = 'coin',
price = aura_cost,
tooltip = ({'main_market.locomotive_aura_radius', upgrades.locomotive_aura_radius, market_limits.aura_limit}),
sprite = 'achievement/tech-maniac',
enabled = true,
upgrade = true,
static = true
}
end
if has_upgraded_health_pool then
if upgrades.has_upgraded_health_pool then
main_market_items['car_health_upgrade_pool'] = {
stack = 1,
value = 'coin',
@ -181,7 +188,7 @@ local function get_items()
stack = 1,
value = 'coin',
price = xp_point_boost_cost,
tooltip = ({'main_market.xp_points_boost', xp_points_upgrade}),
tooltip = ({'main_market.xp_points_boost', upgrades.xp_points_upgrade}),
sprite = 'achievement/trans-factorio-express',
enabled = true,
upgrade = true,
@ -199,7 +206,7 @@ local function get_items()
static = true
}
if WPT.get('explosive_bullets') then
if upgrades.explosive_bullets_purchased then
main_market_items['explosive_bullets'] = {
stack = 1,
value = 'coin',
@ -222,6 +229,7 @@ local function get_items()
static = true
}
end
main_market_items['flamethrower_turrets'] = {
stack = 1,
value = 'coin',
@ -236,7 +244,7 @@ local function get_items()
stack = 1,
value = 'coin',
price = land_mine_cost,
tooltip = ({'main_market.land_mine', landmine}),
tooltip = ({'main_market.land_mine', upgrades.landmine.bought}),
sprite = 'achievement/watch-your-step',
enabled = true,
upgrade = true,
@ -802,6 +810,9 @@ local function gui_opened(event)
end
local frame, inside_table = Gui.add_main_frame_with_toolbar(player, 'screen', main_frame_name, nil, close_market_gui_name, 'Market')
if not inside_table then
return
end
frame.auto_center = true
player.opened = frame
@ -933,11 +944,10 @@ local function gui_click(event)
if name == 'upgrade_pickaxe' then
player.remove_item({name = item.value, count = item.price})
this.pickaxe_tier = this.pickaxe_tier + item.stack
this.upgrades.pickaxe_tier = this.upgrades.pickaxe_tier + item.stack
local pickaxe_tiers = WPT.pickaxe_upgrades
local tier = this.pickaxe_tier
local offer = pickaxe_tiers[tier]
local pickaxe_upgrades = WPT.pickaxe_upgrades
local offer = pickaxe_upgrades[this.upgrades.pickaxe_tier]
local message = ({
'locomotive.pickaxe_bought_info',
@ -949,7 +959,7 @@ local function gui_click(event)
Alert.alert_all_players(5, message)
Server.to_discord_bold(
table.concat {
player.name .. ' has upgraded the teams pickaxe to tier ' .. tier .. ' for ' .. format_number(item.price, true) .. ' coins.'
player.name .. ' has upgraded the teams pickaxe to tier ' .. this.upgrades.pickaxe_tier .. ' for ' .. format_number(item.price, true) .. ' coins.'
}
)
@ -963,9 +973,10 @@ local function gui_click(event)
return
end
if name == 'chest_limit_outside' then
if this.chest_limit_outside_upgrades == 7 then
if this.upgrades.chests_outside_upgrades == this.market_limits.chests_outside_limit then
redraw_market_items(data.item_frame, player, data.search_text)
player.print(({'locomotive.chests_full'}), {r = 0.98, g = 0.66, b = 0.22})
return
end
player.remove_item({name = item.value, count = item.price})
@ -976,7 +987,7 @@ local function gui_click(event)
player.name .. ' has bought the chest limit upgrade for ' .. format_number(item.price, true) .. ' coins.'
}
)
this.chest_limit_outside_upgrades = this.chest_limit_outside_upgrades + item.stack
this.upgrades.chests_outside_upgrades = this.upgrades.chests_outside_upgrades + item.stack
redraw_market_items(data.item_frame, player, data.search_text)
redraw_coins_left(data.coins_left, player)
@ -1017,8 +1028,8 @@ local function gui_click(event)
end
end
this.train_upgrades = this.train_upgrades + item.stack
this.health_upgrades = this.health_upgrades + item.stack
this.upgrades.train_upgrades = this.upgrades.train_upgrades + item.stack
this.upgrades.health_upgrades = this.upgrades.health_upgrades + item.stack
rendering.set_text(this.health_text, 'HP: ' .. round(this.locomotive_health) .. ' / ' .. round(this.locomotive_max_health))
redraw_market_items(data.item_frame, player, data.search_text)
@ -1026,7 +1037,12 @@ local function gui_click(event)
return
end
if name == 'locomotive_xp_aura' then
if name == 'locomotive_aura_radius' then
if this.upgrades.locomotive_aura_radius == this.market_limits.aura_limit then
redraw_market_items(data.item_frame, player, data.search_text)
player.print(({'locomotive.limit_reached'}), {r = 0.98, g = 0.66, b = 0.22})
return
end
player.remove_item({name = item.value, count = item.price})
local message = ({'locomotive.aura_bought_info', shopkeeper, player.name, format_number(item.price, true)})
@ -1037,9 +1053,9 @@ local function gui_click(event)
player.name .. ' has bought the locomotive xp aura modifier for ' .. format_number(item.price, true) .. ' coins.'
}
)
this.locomotive_xp_aura = this.locomotive_xp_aura + 5
this.aura_upgrades = this.aura_upgrades + item.stack
this.train_upgrades = this.train_upgrades + item.stack
this.upgrades.locomotive_aura_radius = this.upgrades.locomotive_aura_radius + 5
this.upgrades.aura_upgrades = this.upgrades.aura_upgrades + item.stack
this.upgrades.train_upgrades = this.upgrades.train_upgrades + item.stack
if this.circle then
rendering.destroy(this.circle)
@ -1050,7 +1066,7 @@ local function gui_click(event)
target = this.locomotive,
color = this.locomotive.color,
filled = false,
radius = this.locomotive_xp_aura,
radius = this.upgrades.locomotive_aura_radius,
only_in_alt_mode = true
}
@ -1070,9 +1086,9 @@ local function gui_click(event)
player.name .. ' has bought the XP points modifier for ' .. format_number(item.price) .. ' coins.'
}
)
this.xp_points = this.xp_points + 0.5
this.xp_points_upgrade = this.xp_points_upgrade + item.stack
this.train_upgrades = this.train_upgrades + item.stack
this.upgrades.xp_points = this.upgrades.xp_points + 0.5
this.upgrades.xp_points_upgrade = this.upgrades.xp_points_upgrade + item.stack
this.upgrades.train_upgrades = this.upgrades.train_upgrades + item.stack
redraw_market_items(data.item_frame, player, data.search_text)
redraw_coins_left(data.coins_left, player)
@ -1115,7 +1131,7 @@ local function gui_click(event)
}
)
RPG.enable_explosive_bullets(true)
this.explosive_bullets = true
this.upgrades.explosive_bullets_purchased = true
redraw_market_items(data.item_frame, player, data.search_text)
redraw_coins_left(data.coins_left, player)
@ -1138,8 +1154,7 @@ local function gui_click(event)
player.name .. ' has bought the global car health modifier for ' .. format_number(item.price) .. ' coins.'
}
)
this.has_upgraded_health_pool = true
this.explosive_bullets = true
this.upgrades.has_upgraded_health_pool = true
redraw_market_items(data.item_frame, player, data.search_text)
redraw_coins_left(data.coins_left, player)

View File

@ -41,7 +41,6 @@ local AntiGrief = require 'utils.antigrief'
local Misc = require 'utils.commands.misc'
local Modifiers = require 'utils.player_modifiers'
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
local Reset = require 'functions.soft_reset'
local JailData = require 'utils.datastore.jail_data'
local RPG_Progression = require 'utils.datastore.rpg_data'
local OfflinePlayers = require 'modules.clear_vacant_players'
@ -143,14 +142,11 @@ local announce_new_map =
)
function Public.reset_map()
local Diff = Difficulty.get()
local this = WPT.get()
local wave_defense_table = WD.get_table()
Misc.set('creative_are_you_sure', false)
Misc.set('creative_enabled', false)
Reset.enable_mapkeeper(true)
this.active_surface_index = CS.create_surface()
-- this.soft_reset_counter = CS.get_reset_counter()
@ -250,8 +246,8 @@ function Public.reset_map()
raise_event(Gui_mf.events.reset_map, {player_index = player.index})
end
Difficulty.reset_difficulty_poll({difficulty_poll_closing_timeout = game.tick + 36000})
Diff.gui_width = 20
Difficulty.reset_difficulty_poll({closing_timeout = game.tick + 36000})
Difficulty.set_gui_width(20)
Collapse.set_kill_entities(false)
Collapse.set_kill_specific_entities(collapse_kill)

View File

@ -95,6 +95,7 @@ function Public.reset_table()
-- @end
this.icw_locomotive = nil
this.game_lost = false
this.death_mode = false
this.fullness_enabled = true
this.locomotive_health = 10000
this.locomotive_max_health = 10000
@ -113,16 +114,13 @@ function Public.reset_table()
this.force_chunk = false
this.allow_decon = true
this.allow_decon_main_surface = true
this.train_upgrades = 0
this.flamethrower_damage = {}
this.mined_scrap = 0
this.print_tech_to_discord = true
this.biters_killed = 0
this.cleared_nauvis = false
this.locomotive_xp_aura = 40
this.locomotive_pos = {tbl = {}}
this.trusted_only_car_tanks = true
this.xp_points = 0
this.xp_points_upgrade = 0
--!grief prevention
this.enable_arties = 6 -- default to callback 6
--!snip
@ -143,13 +141,22 @@ function Public.reset_table()
unit_number = {
landmine = {},
flame_turret = {}
},
has_upgraded_health_pool = false,
explosive_bullets_purchased = false,
xp_points_upgrade = 0,
aura_upgrades = 0,
locomotive_aura_radius = 40,
train_upgrades = 0,
xp_points = 0,
health_upgrades = 0,
pickaxe_tier = 1,
chests_outside_upgrades = 1
}
this.orbital_strikes = {
enabled = true
}
this.aura_upgrades = 0
this.pickaxe_tier = 1
this.pickaxe_speed_per_purchase = 0.07
this.health_upgrades = 1
this.health_upgrades_limit = 100
this.breached_wall = 1
this.left_top = {
x = 0,
@ -168,14 +175,19 @@ function Public.reset_table()
this.spill_items_to_surface = false
this.outside_chests = {}
this.chests_linked_to = {}
this.chest_limit_outside_upgrades = 1
this.placed_trains_in_zone = {
limit = 2,
randomized = false,
zones = {}
}
this.market_limits = {
chests_outside_limit = 8,
aura_limit = 100, -- limited to save UPS
pickaxe_tier_limit = 59,
health_upgrades_limit = 100
}
this.marked_fixed_prices = {
chest_limit_cost = 3000,
chests_outside_cost = 3000,
health_cost = 7000,
pickaxe_cost = 3000,
aura_cost = 4000,
@ -187,7 +199,6 @@ function Public.reset_table()
redraw_mystical_chest_cost = 3000
}
this.collapse_grace = true
this.explosive_bullets = false
this.locomotive_biter = nil
this.disconnect_wagon = false
this.collapse_amount = false
@ -218,7 +229,6 @@ function Public.reset_table()
this.market_announce = game.tick + 1200
this.check_heavy_damage = true
this.prestige_system_enabled = false
this.has_upgraded_health_pool = false
this.mystical_chest_enabled = true
this.check_if_threat_below_zero = true
this.mc_rewards = {
@ -228,6 +238,7 @@ function Public.reset_table()
this.adjusted_zones = {
scrap = {},
forest = {},
slow_movement = {},
size = nil,
shuffled_zones = nil
}

View File

@ -817,6 +817,8 @@ local function zone_10(x, y, data, _, adjusted_zones)
local entities = data.entities
local buildings = data.buildings
local treasure = data.treasure
data.forest_zone = true
data.slow_movement_zone = true
local scrapyard = get_perlin('scrapyard', p, seed)
local smol_areas = get_perlin('smol_areas', p, seed + 45000)
@ -2589,6 +2591,7 @@ local function init_terrain(adjusted_zones)
shuffle_again[inc] = map
end
end
shuffle_again = shuffle(shuffle_again)
adjusted_zones.size = size
adjusted_zones.shuffled_zones = shuffle_again
@ -2622,6 +2625,10 @@ local function process_bits(p, data, adjusted_zones)
adjusted_zones.scrap[index] = true
end
if data.slow_movement_zone and not adjusted_zones.slow_movement[index] then
adjusted_zones.slow_movement[index] = true
end
local void_or_tile = WPT.get('void_or_tile')
local x = p.x

View File

@ -5,10 +5,12 @@ local Global = require 'utils.global'
local SpamProtection = require 'utils.spam_protection'
local Event = require 'utils.event'
local BottomFrame = require 'utils.gui.bottom_frame'
local ComfyGui = require 'utils.gui'
local Gui = require 'utils.gui'
local floor = math.floor
local print_color = {r = 120, g = 255, b = 0}
local auto_stash_button_name = Gui.uid()
local this = {
floating_text_y_offsets = {},
whitelist = {},
@ -585,12 +587,12 @@ local function create_gui_button(player)
end
end
else
if ComfyGui.get_mod_gui_top_frame() then
ComfyGui.add_mod_button(
if Gui.get_mod_gui_top_frame() then
Gui.add_mod_button(
player,
{
type = 'sprite-button',
name = 'auto_stash',
name = auto_stash_button_name,
sprite = 'item/wooden-chest',
tooltip = tooltip
}
@ -601,7 +603,7 @@ local function create_gui_button(player)
{
type = 'sprite-button',
sprite = 'item/wooden-chest',
name = 'auto_stash',
name = auto_stash_button_name,
tooltip = tooltip
}
)
@ -645,31 +647,21 @@ local function on_player_joined_game(event)
create_gui_button(game.players[event.player_index])
end
local function on_gui_click(event)
if not event.element then
return
end
if not event.element.valid then
return
end
local player = game.players[event.player_index]
local name = 'auto_stash'
if this.bottom_button then
local data = BottomFrame.get('bottom_quickbar_button')
if data and data[player.index] then
data = data[player.index]
name = data.name
end
end
if event.element.name == name then
local is_spamming = SpamProtection.is_spamming(player, nil, 'Autostash Click')
Gui.on_click(
auto_stash_button_name,
function(event)
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Autostash click')
if is_spamming then
return
end
auto_stash(player, event)
local player = event.player
if not player or not player.valid or not player.character then
return
end
end
auto_stash(event.player, event)
end
)
function Public.insert_into_furnace(value)
if value then
@ -702,6 +694,14 @@ Event.on_configuration_changed(do_whitelist)
Event.on_init(do_whitelist)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_gui_click, on_gui_click)
Event.add(
BottomFrame.events.bottom_quickbar_button_name,
function(data)
local event = data.event
local player = event.player
auto_stash(player, event)
end
)
return Public

View File

@ -41,7 +41,7 @@ function Public.remove_offline_players()
for i = 1, #this.offline_players, 1 do
if this.offline_players[i] and this.offline_players[i].index then
local target = game.get_player(this.offline_players[i].index)
if target then
if target and target.valid then
if target.connected then
this.offline_players[i] = nil
else

View File

@ -50,11 +50,11 @@ local this = {
[2] = '',
[3] = ''
},
difficulty_vote_value = 0.75,
difficulty_vote_index = 1,
value = 0.75,
index = 1,
fair_vote = false,
difficulty_poll_closing_timeout = 54000,
difficulty_player_votes = {},
closing_timeout = 54000,
all_votes = {},
gui_width = 108,
name = "I'm too young to die",
strength_modifier = 1.00,
@ -78,24 +78,24 @@ local function clear_main_frame(player)
end
function Public.difficulty_gui()
local tooltip = 'Current difficulty of the map is ' .. this.difficulties[this.difficulty_vote_index].name .. '.'
local tooltip = 'Current difficulty of the map is ' .. this.difficulties[this.index].name .. '.'
for _, player in pairs(game.connected_players) do
local top = player.gui.top
if top[top_button_name] then
top[top_button_name].caption = this.difficulties[this.difficulty_vote_index].name
top[top_button_name].caption = this.difficulties[this.index].name
top[top_button_name].tooltip = this.button_tooltip or tooltip
top[top_button_name].style.font_color = this.difficulties[this.difficulty_vote_index].print_color
top[top_button_name].style.font_color = this.difficulties[this.index].print_color
else
local b =
top.add {
type = 'button',
caption = this.difficulties[this.difficulty_vote_index].name,
caption = this.difficulties[this.index].name,
tooltip = tooltip,
name = top_button_name
}
b.style.font = 'heading-2'
b.style.font_color = this.difficulties[this.difficulty_vote_index].print_color
b.style.font_color = this.difficulties[this.index].print_color
b.style.minimal_height = 37
b.style.maximal_height = 37
b.style.minimal_width = this.gui_width
@ -148,9 +148,9 @@ local function poll_difficulty(player)
clear_main_frame(player)
end
if game.tick > this.difficulty_poll_closing_timeout then
if game.tick > this.closing_timeout then
if player.online_time ~= 0 then
local t = math.abs(math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600))
local t = math.abs(math.floor((this.closing_timeout - game.tick) / 3600))
local str = 'Votes have closed ' .. t
str = str .. ' minute'
if t > 1 then
@ -163,6 +163,9 @@ local function poll_difficulty(player)
end
local _, inside_frame = Gui.add_main_frame_with_toolbar(player, 'center', main_frame_name, nil, close_main_frame, 'Difficulty')
if not inside_frame then
return
end
for i = 1, #this.difficulties, 1 do
local button_flow =
@ -198,7 +201,7 @@ local function poll_difficulty(player)
timeleft_flow.add(
{
type = 'button',
caption = math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600) .. ' minutes left.'
caption = math.floor((this.closing_timeout - game.tick) / 3600) .. ' minutes left.'
}
)
b.style.font_color = {r = 0.66, g = 0.0, b = 0.66}
@ -215,23 +218,25 @@ local function set_difficulty()
return
end
if this.difficulty_vote_index ~= index then
if this.index ~= index then
local message = table.concat({'*** Map difficulty has changed to ', this.difficulties[index].name, ' difficulty! ***'})
game.print(message, this.difficulties[index].print_color)
Server.to_discord_embed(message)
end
this.difficulty_vote_index = index
this.difficulty_vote_value = this.difficulties[index].value
this.index = index
this.name = this.difficulties[index].name
this.value = this.difficulties[index].value
this.boss_modifier = this.difficulties[index].boss_modifier
this.strength_modifier = this.difficulties[index].strength_modifier
this.button_tooltip = this.tooltip[index]
end
function Public.reset_difficulty_poll(tbl)
if tbl then
this.difficulty_vote_value = tbl.difficulty_vote_value or 0.75
this.difficulty_vote_index = tbl.difficulty_vote_index or 1
this.difficulty_player_votes = {}
this.difficulty_poll_closing_timeout = tbl.difficulty_poll_closing_timeout or game.tick + 54000
this.value = tbl.value or 0.75
this.index = tbl.index or 1
this.all_votes = {}
this.closing_timeout = tbl.closing_timeout or game.tick + 54000
for _, p in pairs(game.connected_players) do
if p.gui.center[main_frame_name] then
clear_main_frame(p)
@ -243,10 +248,10 @@ function Public.reset_difficulty_poll(tbl)
end
Public.difficulty_gui()
else
this.difficulty_vote_value = 0.75
this.difficulty_vote_index = 1
this.difficulty_player_votes = {}
this.difficulty_poll_closing_timeout = game.tick + 54000
this.value = 0.75
this.index = 1
this.all_votes = {}
this.closing_timeout = game.tick + 54000
for _, p in pairs(game.connected_players) do
if p.gui.center[main_frame_name] then
clear_main_frame(p)
@ -262,8 +267,8 @@ end
local function on_player_joined_game(event)
local player = game.get_player(event.player_index)
if game.tick < this.difficulty_poll_closing_timeout then
if not this.difficulty_player_votes[player.name] then
if game.tick < this.closing_timeout then
if not this.all_votes[player.name] then
poll_difficulty(player)
end
else
@ -273,19 +278,19 @@ local function on_player_joined_game(event)
end
local function on_player_left_game(event)
if game.tick > this.difficulty_poll_closing_timeout then
if game.tick > this.closing_timeout then
return
end
local player = game.get_player(event.player_index)
if not this.difficulty_player_votes[player.name] then
if not this.all_votes[player.name] then
return
end
local index = this.difficulty_player_votes[player.name].index
local index = this.all_votes[player.name].index
this.difficulties[index].count = this.difficulties[index].count - 1
if this.difficulties[index].count <= 0 then
this.difficulties[index].count = 0
end
this.difficulty_player_votes[player.name] = nil
this.all_votes[player.name] = nil
set_difficulty()
Public.difficulty_gui()
end
@ -303,7 +308,13 @@ function Public.set_difficulties(...)
end
function Public.set_poll_closing_timeout(...)
this.difficulty_poll_closing_timeout = ...
this.closing_timeout = ...
end
--- Sets gui width
---@param number number
function Public.set_gui_width(number)
this.gui_width = number
end
function Public.get_fair_vote()
@ -322,6 +333,17 @@ function Public.get(key)
end
end
function Public.set(key, value)
if key and (value or value == false) then
this[key] = value
return this[key]
elseif key then
return this[key]
else
return this
end
end
Gui.on_click(
selection_button_name,
function(event)
@ -341,19 +363,19 @@ Gui.on_click(
local i = tonumber(element.parent.name)
if game.tick > this.difficulty_poll_closing_timeout then
if game.tick > this.closing_timeout then
clear_main_frame(player)
return
end
if this.difficulty_player_votes[player.name] and this.difficulty_player_votes[player.name].index == i then
if this.all_votes[player.name] and this.all_votes[player.name].index == i then
player.print('You have already voted for ' .. this.difficulties[i].name .. '.', this.difficulties[i].print_color)
clear_main_frame(player)
return
end
if this.difficulty_player_votes[player.name] then
local index = this.difficulty_player_votes[player.name].index
if this.all_votes[player.name] then
local index = this.all_votes[player.name].index
this.difficulties[index].count = this.difficulties[index].count - 1
if this.difficulties[index].count <= 0 then
this.difficulties[index].count = 0
@ -361,7 +383,7 @@ Gui.on_click(
end
this.difficulties[i].count = this.difficulties[i].count + 1
this.difficulty_player_votes[player.name] = {voted = true, index = i}
this.all_votes[player.name] = {voted = true, index = i}
set_difficulty()
Public.difficulty_gui()
@ -383,7 +405,7 @@ Gui.on_click(
if not player or not player.valid then
return
end
if game.tick > this.difficulty_poll_closing_timeout then
if game.tick > this.closing_timeout then
clear_main_frame(player)
return
end

352
modules/render_beam.lua Normal file
View File

@ -0,0 +1,352 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
local Gui = require 'utils.gui'
local this = {
renders = {}
}
local Public = {}
Public.metatable = {__index = Public}
Global.register(
this,
function(tbl)
this = tbl
for _, render in pairs(this.renders) do
setmetatable(render, Public.metatable)
end
end
)
local target_entities = {
'character',
'tank',
'car',
'radar',
'lab',
'furnace',
'locomotive',
'cargo-wagon',
'fluid-wagon',
'artillery-wagon',
'artillery-turret',
'laser-turret',
'gun-turret',
'flamethrower-turret',
'silo',
'spidertron'
}
local sqrt = math.sqrt
local random = math.random
local remove = table.remove
local speed = 0.06
--- Draws a new render.
---@return integer
function Public:new_render()
local surface = game.get_surface(self.surface_id)
self.render_id = rendering.draw_sprite {target = self.position, sprite = self.sprite, surface = surface}
end
--- Sets a new target for a given render.
---@return table
---@return table
function Public:new_target()
local surface = game.get_surface(self.surface_id)
local position
local entities = surface.find_entities_filtered {type = target_entities}
if entities and #entities > 0 then
position = entities[random(#entities)].position
end
local chunk = surface.get_random_chunk()
local random_position = {x = (chunk.x + random()) * 32, y = (chunk.y + random()) * 32}
return position, random_position
end
--- Subtracts the given positions
---@return table|integer
function Public:subtr()
if not self.position and self.target_position then
return 0
end
return {x = self.target_position.x - self.position.x, y = self.target_position.y - self.position.y}
end
--- Sets the render scale.
function Public:set_render_scalar_size()
if not self.render_id then
return self:validate()
end
rendering.set_y_scale(self.render_id, 3.5) -- 1.5
rendering.set_x_scale(self.render_id, 7) -- 2
rendering.set_color(
self.render_id,
{
r = 1,
g = 0.7,
b = 0.7
}
)
end
--- Gets a random position.
---@return table
function Public:random_position()
return {x = self.position.x + (random() - 0.5) * 64, y = self.position.y + (random() - 0.5) * 64}
end
--- Changes the position of a render.
---@param max_abs number
---@param value boolean
---@return table|nil
function Public:change_position(max_abs, value)
if not self.position or not self.target_position then
return
end
local scalar = 0.9
local subtr = self:subtr()
if value then
subtr.y = subtr.y / scalar
end
local multiply = sqrt(subtr.x * subtr.x + subtr.y * subtr.y)
if (multiply > max_abs) then
local close = max_abs / multiply
subtr = {x = subtr.x * close, y = subtr.y * close}
end
if value then
subtr.y = subtr.y * scalar
end
return {x = self.position.x + subtr.x, y = self.position.y + subtr.y}
end
--- If a render is stuck, give it a new position.
function Public:switch_position()
if random() < 0.4 then
self.target_position = self:random_position()
else
local surface = game.get_surface(self.surface_id)
local chunk = surface.get_random_chunk()
self.target_position = {x = (chunk.x + math.random()) * 32, y = (chunk.y + math.random()) * 32}
end
end
--- Notifies for a new render
function Public:notify_new_beam()
if not self.notify then
self.notify = true
local surface = game.get_surface(self.surface_id)
game.print('[Orbital] A new orbital strike has been spotted at: [gps=' .. self.position.x .. ',' .. self.position.y .. ',' .. surface.name .. ']')
end
end
--- Renders a new chart
function Public:render_chart()
if self.chart then
self.chart.destroy()
end
local surface = game.get_surface(self.surface_id)
self.chart =
game.forces[self.force].add_chart_tag(
surface,
{
icon = {type = 'virtual', name = 'signal-info'},
position = self.position,
text = 'Beam'
}
)
end
--- Sets a new position for a render.
function Public:set_new_position()
self.position = self:change_position(speed, false)
if not self.random_pos_set then
self.random_pos_set = true
self.random_pos_tick = game.tick + 300
end
if self.position.x == self.target_position.x and self.position.y == self.target_position.y then
self:switch_position()
end
if self:validate() then
rendering.set_target(self.render_id, self.position)
self:set_render_scalar_size()
end
end
--- Creates fire flame.
function Public:render_fire_damage()
if random(1, 15) == 1 then
local surface = game.get_surface(self.surface_id)
surface.create_entity({name = 'fire-flame', position = {x = self.position.x, y = self.position.y + 5}})
if random(1, 5) == 1 then
surface.create_entity({name = 'medium-scorchmark', position = {x = self.position.x, y = self.position.y + 5}, force = 'neutral'})
end
end
end
--- Damages entities nearby.
function Public:damage_entities_nearby()
if random(1, 3) == 1 then
local surface = game.get_surface(self.surface_id)
local damage = random(10, 15)
local entities = surface.find_entities_filtered({position = self.position, radius = 20, type = 'simple-entity', invert = true})
for _, entity in pairs(entities) do
if entity.valid then
if entity.health then
if entity.force.name ~= 'enemy' then
entity.damage(damage, 'enemy')
end
end
end
end
end
end
--- Validates if a render is valid.
---@return boolean|integer
function Public:validate()
if not self.render_id then
return self:new_render()
end
if rendering.is_valid(self.render_id) then
return true
end
return false
end
--- Destroys a render.
function Public:destroy_render()
if rendering.is_valid(self.render_id) then
rendering.destroy(self.render_id)
end
return self
end
--- Destroys a render.
function Public:destroy_chart()
if self.chart then
self.chart.destroy()
end
return self
end
--- Removes a render.
function Public:remove_render()
self:destroy_render()
self:destroy_chart()
remove(this.renders, self.id)
return self
end
function Public:work(tick)
if tick < self.ttl then
self:render_chart()
self:notify_new_beam()
self:set_new_position()
self:render_fire_damage()
self:damage_entities_nearby()
if self.random_pos_set and tick > self.random_pos_tick then
self:switch_position()
self.random_pos_set = nil
self.random_pos_tick = nil
end
else
self:remove_render()
end
end
--- Creates a new render.
---@param sprite string
---@param surface userdata
---@param ttl integer|nil
---@param scalar table|nil
---@param delayed number|nil
---@return table
function Public.new(sprite, surface, ttl, scalar, delayed)
local render = setmetatable({}, Public.metatable)
render.surface_id = surface.index
local position, random_position = render:new_target()
render.position = position
render.sprite = sprite
render.force = 'player'
render.target_position = random_position
render.id = #this.renders + 1
if delayed then
render.delayed = game.tick + delayed
render.ttl = ttl or (game.tick + delayed) + 7200 -- 2 minutes duration
else
render.ttl = ttl or game.tick + 7200 -- 2 minutes duration
render:validate()
if not scalar then
render:set_render_scalar_size()
end
end
render.ttl = ttl or game.tick + 7200 -- 2 minutes duration
this.renders[render.id] = render
return render
end
--- Creates a new defined beam
---@param surface userdata
function Public.new_beam(surface)
Public.new(Gui.beam, surface)
end
--- Creates a new defined beam with a delayed action
---@param surface userdata
---@param time number
function Public.new_beam_delayed(surface, time)
Public.new(Gui.beam, surface, nil, nil, time)
end
Event.add(
defines.events.on_tick,
function()
if #this.renders == 0 then
return
end
local tick = game.tick
for id = 1, #this.renders, 1 do
local render = this.renders[id]
if render then
if render.delayed then
if tick > render.delayed then
render:work(tick)
end
else
render:work(tick)
end
end
end
end
)
if _DEBUG then
commands.add_command(
'laser',
'new laser',
function()
local player = game.player
if player and player.valid then
if not player.admin then
return
end
Public.new_beam_delayed(player.surface, 222)
end
end
)
end
return Public

View File

@ -226,4 +226,42 @@ if _DEBUG then
)
end
local RPG_Interface = {
rpg_reset_player = function(player_name)
if player_name then
local player = game.get_player(player_name)
if player and player.valid then
return Public.rpg_reset_player(player)
else
error('Remote call parameter to RPG rpg_reset_player must be a valid player name and not nil.')
end
else
error('Remote call parameter to RPG rpg_reset_player must be a valid player name and not nil.')
end
end,
give_xp = function(amount)
if type(amount) == 'number' then
return Public.give_xp(amount)
else
error('Remote call parameter to RPG give_xp must be number and not nil.')
end
end,
gain_xp = function(player_name, amount)
if player_name then
local player = game.get_player(player_name)
if player and player.valid and type(amount) == 'number' then
return Public.gain_xp(player, amount)
else
error('Remote call parameter to RPG give_xp must be a valid player name and contain amount(number) and not nil.')
end
else
error('Remote call parameter to RPG give_xp must be a valid player name and contain amount(number) and not nil.')
end
end
}
if not remote.interfaces['RPG'] then
remote.add_interface('RPG', RPG_Interface)
end
return Public

View File

@ -19,6 +19,7 @@ local round = math.round
local floor = math.floor
local random = math.random
local abs = math.abs
local sub = string.sub
--RPG Frames
local main_frame_name = Public.main_frame_name
@ -444,7 +445,7 @@ function Public.remove_mana(player, mana_to_remove)
if player.gui.screen[main_frame_name] then
local f = player.gui.screen[main_frame_name]
local data = Gui.get_data(f)
if data.mana and data.mana.valid then
if data and data.mana and data.mana.valid then
data.mana.caption = rpg_t.mana
end
end
@ -483,7 +484,7 @@ function Public.update_mana(player)
if player.gui.screen[main_frame_name] then
local f = player.gui.screen[main_frame_name]
local data = Gui.get_data(f)
if data.mana and data.mana.valid then
if data and data.mana and data.mana.valid then
data.mana.caption = rpg_t.mana
end
end
@ -542,7 +543,7 @@ function Public.reward_mana(player, mana_to_add)
if player.gui.screen[main_frame_name] then
local f = player.gui.screen[main_frame_name]
local data = Gui.get_data(f)
if data.mana and data.mana.valid then
if data and data.mana and data.mana.valid then
data.mana.caption = rpg_t.mana
end
end
@ -589,7 +590,7 @@ function Public.update_health(player)
if player.gui.screen[main_frame_name] then
local f = player.gui.screen[main_frame_name]
local data = Gui.get_data(f)
if data.health and data.health.valid then
if data and data.health and data.health.valid then
data.health.caption = (round(player.character.health * 10) / 10)
end
local shield_gui = player.character.get_inventory(defines.inventory.character_armor)
@ -597,10 +598,10 @@ function Public.update_health(player)
if shield_gui[1].grid then
local shield = math.floor(shield_gui[1].grid.shield)
local shield_max = math.floor(shield_gui[1].grid.max_shield)
if data.shield and data.shield.valid then
if data and data.shield and data.shield.valid then
data.shield.caption = shield
end
if data.shield_max and data.shield_max.valid then
if data and data.shield_max and data.shield_max.valid then
data.shield_max.caption = shield_max
end
end
@ -993,6 +994,36 @@ function Public.give_xp(amount)
end
end
-- Checks if the player is on the correct surface.
function Public.check_is_surface_valid(player)
if is_game_modded() then
return true
end
local is_surface_valid = false
local surface_name = Public.get('rpg_extra').surface_name
if type(surface_name) == 'table' then
for _, tbl_surface in pairs(surface_name) do
if sub(player.surface.name, 0, #surface_name) == tbl_surface then
is_surface_valid = true
end
end
else
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
return false
else
return true
end
end
if not is_surface_valid then
return false
end
return true
end
function Public.rpg_reset_player(player, one_time_reset)
if not player.character then
player.set_controller({type = defines.controllers.god})

View File

@ -30,11 +30,31 @@ local spell1_button_name = Public.spell1_button_name
local spell2_button_name = Public.spell2_button_name
local spell3_button_name = Public.spell3_button_name
local sub = string.sub
local round = math.round
local floor = math.floor
function Public.draw_gui_char_button(player)
if ComfyGui.get_mod_gui_top_frame() then
local b =
ComfyGui.add_mod_button(
player,
{
type = 'sprite-button',
name = draw_main_frame_name,
caption = '[RPG]',
tooltip = 'RPG'
}
)
if b then
b.style.font_color = {165, 165, 165}
b.style.font = 'heading-3'
b.style.minimal_height = 38
b.style.maximal_height = 38
b.style.minimal_width = 50
b.style.padding = 0
b.style.margin = 0
end
else
if player.gui.top[draw_main_frame_name] then
return
end
@ -46,10 +66,22 @@ function Public.draw_gui_char_button(player)
b.style.minimal_width = 50
b.style.padding = 0
b.style.margin = 0
end
end
function Public.update_char_button(player)
local rpg_t = Public.get_value_from_player(player.index)
if ComfyGui.get_mod_gui_top_frame() then
if not ComfyGui.get_button_flow(player)[draw_main_frame_name] or not ComfyGui.get_button_flow(player)[draw_main_frame_name].valid then
Public.draw_gui_char_button(player)
end
if rpg_t.points_left > 0 then
ComfyGui.get_button_flow(player)[draw_main_frame_name].style.font_color = {245, 0, 0}
else
ComfyGui.get_button_flow(player)[draw_main_frame_name].style.font_color = {175, 175, 175}
end
else
if not player.gui.top[draw_main_frame_name] then
Public.draw_gui_char_button(player)
end
@ -58,6 +90,7 @@ function Public.update_char_button(player)
else
player.gui.top[draw_main_frame_name].style.font_color = {175, 175, 175}
end
end
end
local function get_class(player)
@ -162,7 +195,11 @@ local function draw_main_frame(player, location)
if location then
main_frame.location = location
else
main_frame.location = {x = 1, y = 40}
if ComfyGui.get_mod_gui_top_frame() then
main_frame.location = {x = 1, y = 55}
else
main_frame.location = {x = 1, y = 45}
end
end
local data = {}
@ -715,8 +752,7 @@ Gui.on_click(
return
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end
@ -742,8 +778,7 @@ Gui.on_click(
return
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end
@ -808,8 +843,7 @@ Gui.on_click(
return
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end
@ -836,8 +870,7 @@ Gui.on_click(
return
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end
@ -861,8 +894,7 @@ Gui.on_click(
return
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end
@ -886,8 +918,7 @@ Gui.on_click(
return
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end

View File

@ -19,7 +19,6 @@ local nth_tick = Public.nth_tick
--RPG Frames
local main_frame_name = Public.main_frame_name
local sub = string.sub
local round = math.round
local floor = math.floor
local random = math.random
@ -48,8 +47,7 @@ local function on_gui_click(event)
end
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end
@ -459,8 +457,7 @@ local function on_entity_damaged(event)
local p = cause.player
local surface_name = Public.get('rpg_extra').surface_name
if sub(p.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(p) then
return
end
@ -670,16 +667,11 @@ local function on_pre_player_mined_item(event)
return
end
local surface_name = Public.get('rpg_extra').surface_name
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end
local rpg_t = Public.get_value_from_player(player.index)
if not rpg_t then
return
end
if rpg_t.last_mined_entity_position.x == entity.position.x and rpg_t.last_mined_entity_position.y == entity.position.y then
return
end
@ -701,9 +693,6 @@ local function on_pre_player_mined_item(event)
if player.gui.screen[main_frame_name] then
local f = player.gui.screen[main_frame_name]
local data = Gui.get_data(f)
if not data then
return
end
if data.exp_gui and data.exp_gui.valid then
data.exp_gui.caption = floor(rpg_t.xp)
end
@ -858,7 +847,6 @@ end
local function on_player_used_capsule(event)
local enable_mana = Public.get('rpg_extra').enable_mana
local surface_name = Public.get('rpg_extra').surface_name
if not enable_mana then
return
end
@ -875,7 +863,7 @@ local function on_player_used_capsule(event)
return
end
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
if not Public.check_is_surface_valid(player) then
return
end

View File

@ -89,7 +89,7 @@ Public.auto_allocate_nodes_func = {
'Vitality'
}
function Public.reset_table()
function Public.reset_table(migrate)
this.rpg_extra.debug = false
this.rpg_extra.breached_walls = 1
this.rpg_extra.reward_new_players = 0
@ -127,7 +127,9 @@ function Public.reset_table()
['pipe'] = true
}
this.tweaked_crafting_items_enabled = false
if not migrate then
this.rpg_t = {}
end
this.rpg_extra.rpg_xp_yield = {
['behemoth-biter'] = 16,
['behemoth-spitter'] = 16,
@ -161,7 +163,7 @@ end
--- Gets value from player rpg_t table
---@param key string
---@param value string
---@param value string|nil
function Public.get_value_from_player(key, value)
if key and value then
if (this.rpg_t[key] and this.rpg_t[key][value]) then
@ -180,8 +182,8 @@ end
--- Sets value to player rpg_t table
---@param key string
---@param value string
---@param setter string
---@param value string|boolean|number|nil
---@param setter string|boolean|number|nil
function Public.set_value_to_player(key, value, setter)
if key and value then
if (this.rpg_t[key] and this.rpg_t[key][value]) then
@ -227,12 +229,8 @@ function Public.set(key)
end
--- Toggle debug - when you need to troubleshoot.
function Public.toggle_debug()
if this.rpg_extra.debug then
this.rpg_extra.debug = false
else
this.rpg_extra.debug = true
end
function Public.toggle_debug(value)
this.rpg_extra.debug = value or false
return this.rpg_extra.debug
end
@ -278,6 +276,55 @@ function Public.enable_health_and_mana_bars(value)
return this.rpg_extra.enable_health_and_mana_bars
end
--- Toggles the mod gui state.
---@param value boolean
---@param read boolean
function Public.enable_mod_gui(value, read)
if not read then
Gui.set_mod_gui_top_frame(value or false)
end
if Gui.get_mod_gui_top_frame() then
local players = game.connected_players
for i = 1, #players do
local player = players[i]
local top = player.gui.top
if top.mod_gui_top_frame and top.mod_gui_top_frame.valid then
top.mod_gui_top_frame.visible = true
end
for _, child in pairs(top.children) do
if child.caption == '[RPG]' then
child.destroy()
Public.draw_gui_char_button(player)
end
end
end
else
local players = game.connected_players
local count = 0
for i = 1, #players do
local player = players[i]
local top = Gui.get_button_flow(player)
for _, child in pairs(top.children) do
count = count + 1
if child.caption == '[RPG]' then
child.destroy()
Public.draw_gui_char_button(player)
end
end
if count == 0 then
if player.gui.top.mod_gui_top_frame and player.gui.top.mod_gui_top_frame.valid then
player.gui.top.mod_gui_top_frame.visible = false
end
else
if player.gui.top.mod_gui_top_frame and player.gui.top.mod_gui_top_frame.valid then
player.gui.top.mod_gui_top_frame.visible = true
end
end
end
end
end
--- Enables the mana feature that allows players to spawn entities.
---@param value boolean
function Public.enable_mana(value)
@ -388,6 +435,44 @@ function Public.tweaked_crafting_items(tbl)
return this.tweaked_crafting_items
end
function Public.migrate_new_rpg_tbl(player)
local rpg_t = Public.get_value_from_player(player.index, nil)
if rpg_t then
rpg_t.flame_boots = nil
rpg_t.one_punch = nil
rpg_t.points_left = rpg_t.points_to_distribute or 0
rpg_t.points_to_distribute = nil
rpg_t.aoe_punch = false
rpg_t.auto_toggle_features = {
aoe_punch = false,
stone_path = false
}
end
Public.enable_mod_gui(false, true)
local screen = player.gui.screen
for _, child in pairs(screen.children) do
if child.caption and child.caption[1] == 'rpg_settings.spell_name' then
child.destroy()
end
end
end
function Public.migrate_to_new_version()
Public.reset_table(true)
if this.rpg_spells then
this.rpg_spells = nil
end
local players = game.players
for _, player in pairs(players) do
Public.migrate_new_rpg_tbl(player)
end
end
Public.settings_frame_name = settings_frame_name
Public.settings_tooltip_frame = settings_tooltip_frame
Public.close_settings_tooltip_frame = close_settings_tooltip_frame
@ -411,4 +496,11 @@ end
Event.on_init(on_init)
Event.on_configuration_changed(
function()
print('[RPG] Migrating to new version')
Public.migrate_to_new_version()
end
)
return Public

View File

@ -29,6 +29,13 @@ commands.add_command(
return Public.spawn_unit_group(true, true)
end
if param == 'set_wave_1500' then
for _ = 1, 1500 do
Public.set_next_wave()
end
return Public.spawn_unit_group(true, true)
end
if param == 'log_all' then
return Public.toggle_debug()
end

View File

@ -536,7 +536,7 @@ local function increase_biter_damage()
end
local e = game.forces.enemy
local new = Difficulty.get().difficulty_vote_value * 0.04
local new = Difficulty.get('value') * 0.04
local melee = new
local bio = new - 0.02
local e_old_melee = e.get_ammo_damage_modifier('melee')

View File

@ -231,7 +231,7 @@ end
---Message all players at a given location
---@param player LuaPlayer
---@param message string
---@param color string
---@param color string|nil
function Public.alert_all_players_location(player, message, color, duration)
local length = duration or 15
Public.alert_all_players_template(
@ -264,7 +264,7 @@ end
---@param player LuaPlayer
---@param duration number
---@param message string
---@param color string
---@param color string|nil
function Public.alert_player(player, duration, message, color, sprite, volume)
Public.alert_player_template(
player,
@ -321,7 +321,7 @@ end
---Message to all players
---@param duration number
---@param message string
---@param color string
---@param color string|nil
function Public.alert_all_players(duration, message, color, sprite, volume)
local players = game.connected_players
for i = 1, #players do

View File

@ -975,7 +975,7 @@ end
--- Add entity type to the whitelist so it gets logged.
---@param key string
---@param value string
---@param value string|boolean
function Public.whitelist_types(key, value)
if key and value then
this.whitelist_types[key] = value
@ -1027,7 +1027,7 @@ function Public.decon_surface_blacklist(value)
end
--- Defines what the threshold for amount of explosives in chest should be - logged or not.
---@param value string
---@param value number
function Public.explosive_threshold(value)
if value then
this.explosive_threshold = value
@ -1037,7 +1037,7 @@ function Public.explosive_threshold(value)
end
--- Defines what the threshold for amount of times before the script should take action.
---@param value string
---@param value number
function Public.damage_entity_threshold(value)
if value then
this.damage_entity_threshold = value

View File

@ -113,6 +113,16 @@ function Public.iter_connected_players(callback)
end
end
--- Iterates over all players
---@param callback function
function Public.iter_players(callback)
local players = game.players
for i = 1, #players do
local player = players[i]
callback(player)
end
end
function Public.cast_bool(var)
if var then
return true

View File

@ -1,7 +1,3 @@
--luacheck: ignore
local branch_version = '1.1' -- define what game version we're using
local sub = string.sub
-- Non-applicable stages are commented out.
_STAGE = {
--settings = 1,
@ -13,46 +9,3 @@ _STAGE = {
config_change = 7,
runtime = 8
}
function get_game_version()
local get_active_branch = sub(game.active_mods.base, 3, 4)
local is_branch_experimental = sub(branch_version, 3, 4)
if get_active_branch >= is_branch_experimental then
return true
else
return false
end
end
function is_loaded(module)
local res = _G.package.loaded[module]
if res then
return res
else
return false
end
end
function is_game_modded()
local i = 0
for k, _ in pairs(game.active_mods) do
i = i + 1
if i > 1 then
return true
end
end
return false
end
function is_mod_loaded(module)
if not module then
return false
end
local res = script.active_mods[module]
if res then
return true
else
return false
end
end

View File

@ -128,7 +128,7 @@ Gui.on_click(
local top_panel = element.parent.parent
local data = Gui.get_data(top_panel)
if not data or not data.valid then
if not data then
return
end

View File

@ -1,6 +1,5 @@
local Gui = require 'utils.gui'
local Global = require 'utils.global'
local Token = require 'utils.token'
local Color = require 'utils.color_presets'
local Model = require 'utils.debug.model'
@ -92,7 +91,7 @@ Gui.on_click(
input_text_box.text = concat {'global.tokens.', token_id}
input_text_box.style.font_color = Color.black
local id = Token.get_global(token_id)
local id = Global.get_global(token_id)
local content = dump(id) or 'Could not load data.'
if content:find('function_handlers') then
content = '{}' -- desync handler

BIN
utils/files/beam.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -1,52 +1,57 @@
local Event = require 'utils.event_core'
local Token = require 'utils.token'
local Global = {
names = {},
index = 0,
filepath = {}
}
local Global = {}
global.tokens = {}
local names = {}
Global.names = names
local concat = table.concat
function Global.register(tbl, callback)
local filepath = debug.getinfo(2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
local name = filepath:gsub('/', '_')
local token = Token.register_global(tbl)
local token_name = Token.register_global_with_name(name, tbl)
--- Sets a new global
---@param tbl any
---@return integer
---@return string
function Global.set_global(tbl)
local filepath = debug.getinfo(3, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5):gsub('/', '_')
if token then
names[token] = concat {token, ' - ', filepath}
else
names[token_name] = concat {Token.get_global_index(token_name), ' - ', filepath}
Global.index = Global.index + 1
Global.filepath[filepath] = Global.index
Global.names[filepath] = concat {Global.filepath[filepath], ' - ', filepath}
global.tokens[filepath] = tbl
return Global.index, filepath
end
--- Gets a global from global
---@param token number|string
---@return any|nil
function Global.get_global(token)
if global.tokens[token] then
return global.tokens[token]
end
end
function Global.register(tbl, callback)
local token, filepath = Global.set_global(tbl)
Event.on_load(
function()
if token then
callback(Token.get_global(token))
if global.tokens[token] then
callback(Global.get_global(token))
else
callback(Token.get_global_with_name(name))
callback(Global.get_global(filepath))
end
end
)
if token then
return token
else
return token_name
end
return filepath
end
function Global.register_init(tbl, init_handler, callback)
local filepath = debug.getinfo(2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
local name = filepath:gsub('/', '_')
local token = Token.register_global(tbl)
local token_name = Token.register_global_with_name(name, tbl)
if token then
names[token] = concat {token, ' - ', filepath}
else
names[token_name] = concat {Token.get_global_index(token_name), ' - ', filepath}
end
local token, filepath = Global.set_global(tbl)
Event.on_init(
function()
@ -57,18 +62,14 @@ function Global.register_init(tbl, init_handler, callback)
Event.on_load(
function()
if token then
callback(Token.get_global(token))
if global.tokens[token] then
callback(Global.get_global(token))
else
callback(Token.get_global_with_name(name))
callback(Global.get_global(filepath))
end
end
)
if token then
return token
else
return token_name
end
return filepath
end
return Global

View File

@ -34,6 +34,7 @@ Public.token =
end
)
Public.beam = 'file/utils/files/beam.png'
Public.settings_white_icon = 'file/utils/files/settings-white.png'
Public.settings_black_icon = 'file/utils/files/settings-black.png'
Public.pin_white_icon = 'file/utils/files/pin-white.png'
@ -396,7 +397,7 @@ end
--- This adds the given gui to the top gui.
---@param player userdata
---@param frame userdata
---@param frame userdata|table
function Public.add_mod_button(player, frame)
if Public.get_button_flow(player)[frame.name] and Public.get_button_flow(player)[frame.name].valid then
return

View File

@ -19,6 +19,8 @@ Global.register(
local Public = {}
Public.events = {bottom_quickbar_button_name = Event.generate_event_name('bottom_quickbar_button_name')}
local main_frame_name = Gui.uid_name()
local clear_corpse_button_name = Gui.uid_name()
local bottom_quickbar_button_name = Gui.uid_name()
@ -225,6 +227,17 @@ Gui.on_click(
end
)
Gui.on_click(
bottom_quickbar_button_name,
function(event)
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Custom Bottom_quickbar_button_name')
if is_spamming then
return
end
Event.raise(Public.events.bottom_quickbar_button_name, {player = event.player, event = event})
end
)
Event.add(
defines.events.on_player_joined_game,
function(event)

View File

@ -950,14 +950,14 @@ local function on_player_left_game()
end
--- If the different roles should be shown in the player_list.
---@param value string
---@param value boolean
function Public.show_roles_in_list(value)
this.show_roles_in_list = value or false
return this.show_roles_in_list
end
--- Notifies player_list if RPG is enabled or not.
---@param value string
---@param value boolean
function Public.rpg_enabled(value)
this.rpg_enabled = value or false
return this.rpg_enabled

View File

@ -4,6 +4,8 @@ local Poll = {
}
local Token = require 'utils.token'
local Server = require 'utils.server'
local branch_version = '1.1' -- define what game version we're using
local sub = string.sub
--- This module is for the web server to call functions and raise events.
-- Not intended to be called by scripts.
@ -49,4 +51,48 @@ if not remote.interfaces['ServerCommands'] then
remote.add_interface('ServerCommands', SC_Interface)
end
function get_game_version()
local get_active_branch = sub(game.active_mods.base, 3, 4)
local is_branch_experimental = sub(branch_version, 3, 4)
if get_active_branch >= is_branch_experimental then
return true
else
return false
end
end
function is_loaded(module)
local res = _G.package.loaded[module]
if res then
return res
else
return false
end
end
function is_game_modded()
local active_mods = game.active_mods
local i = 0
for _, _ in pairs(active_mods) do
i = i + 1
if i > 1 then
return true
end
end
return false
end
function is_mod_loaded(module)
if not module then
return false
end
local res = game.active_mods[module]
if res then
return true
else
return false
end
end
return ServerCommands

View File

@ -26,54 +26,9 @@ function Token.get(token_id)
return tokens[token_id]
end
global.tokens = {
index = {},
counter = 0
}
function Token.register_global(var)
if #global.tokens == 0 then
return -- migration to newer version
end
local c = #global.tokens + 1
global.tokens[c] = var
return c
end
function Token.register_global_with_name(name, var)
if not global.tokens[name] then
global.tokens[name] = var
end
if not global.tokens.index[name] then
global.tokens.counter = global.tokens.counter + 1
global.tokens.index[name] = global.tokens.counter
end
return name
end
function Token.get_global_index(name)
return global.tokens.index[name]
end
function Token.get_global_with_name(name)
return global.tokens[name]
end
function Token.get_global(token_id)
return global.tokens[token_id]
end
function Token.set_global(token_id, var)
global.tokens[token_id] = var
end
local uid_counter = 100
---@return integer
function Token.uid()
uid_counter = uid_counter + 1