You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-09-16 09:06:21 +02:00
tweaks and fixes
This commit is contained in:
@@ -740,7 +740,7 @@ end
|
||||
---@param player <LuaPlayer>
|
||||
---@param position <EventPosition>
|
||||
---@param msg <string>
|
||||
function Public.insert_into_capsule_history(player, position)
|
||||
function Public.insert_into_capsule_history(player, position, msg)
|
||||
if not this.capsule_history[player.index] then
|
||||
this.capsule_history[player.index] = {}
|
||||
end
|
||||
@@ -749,6 +749,7 @@ function Public.insert_into_capsule_history(player, position)
|
||||
end
|
||||
local t = math.abs(math.floor((game.tick) / 3600))
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. msg
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(position.x)
|
||||
str = str .. ' Y:'
|
||||
|
@@ -372,7 +372,7 @@ local function draw_main_frame(left, player)
|
||||
Gui.set_data(forward_button, data)
|
||||
|
||||
update_poll_viewer(data)
|
||||
--
|
||||
--
|
||||
|
||||
--[[
|
||||
frame.add {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local map_data = require 'maps.crab_defender.crab_defender'
|
||||
local map_data = require 'maps.crab_defender.map'
|
||||
|
||||
local random = math.random
|
||||
local abs = math.abs
|
||||
@@ -102,7 +102,6 @@ local ores = {'coal', 'iron-ore', 'copper-ore', 'stone'}
|
||||
|
||||
local function plankton_territory(position, seed, ent)
|
||||
local noise = simplex_noise(position.x * 0.009, position.y * 0.009, seed)
|
||||
local d = 196
|
||||
|
||||
if get_pos(position.x, position.y) then
|
||||
return
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,13 @@ local starting_items = {
|
||||
['stone'] = 12
|
||||
}
|
||||
|
||||
local disable_tech = function()
|
||||
game.forces.player.technologies['landfill'].enabled = false
|
||||
game.forces.player.technologies['optics'].researched = true
|
||||
game.forces.player.technologies['artillery'].researched = false
|
||||
game.forces.player.technologies['atomic-bomb'].enabled = false
|
||||
end
|
||||
|
||||
function Public.reset_game()
|
||||
FDT.reset_table()
|
||||
Poll.reset()
|
||||
@@ -55,6 +62,8 @@ function Public.reset_game()
|
||||
end
|
||||
end
|
||||
|
||||
disable_tech()
|
||||
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.seed = math_random(10000, 99999)
|
||||
map_gen_settings.height = 2048
|
||||
@@ -115,8 +124,6 @@ function Public.reset_game()
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
game.map_settings.pollution.enabled = false
|
||||
|
||||
game.forces['player'].technologies['atomic-bomb'].enabled = false
|
||||
|
||||
if not game.forces.decoratives then
|
||||
game.create_force('decoratives')
|
||||
end
|
||||
@@ -127,7 +134,6 @@ function Public.reset_game()
|
||||
game.remove_offline_players()
|
||||
|
||||
game.map_settings.enemy_expansion.enabled = false
|
||||
game.forces['player'].technologies['artillery'].researched = false
|
||||
|
||||
is_branch_18 = is_branch_18 .. sub(branch_version, 6, 7)
|
||||
get_active_version = get_active_version .. sub(game.active_mods.base, 6, 7)
|
||||
@@ -135,8 +141,8 @@ function Public.reset_game()
|
||||
game.reset_time_played()
|
||||
end
|
||||
|
||||
this.market_health = 500
|
||||
this.market_max_health = 500
|
||||
this.market_health = 1000
|
||||
this.market_max_health = 1000
|
||||
this.spawn_area_generated = false
|
||||
end
|
||||
|
||||
@@ -1424,8 +1430,9 @@ local on_tick = function()
|
||||
end
|
||||
if game.tick % 180 == 0 then
|
||||
if surface then
|
||||
game.forces.player.chart(surface, {{-428, -24}, {-575, -126}})
|
||||
game.forces.player.chart(surface, {{577, -24}, {724, -126}})
|
||||
game.forces.player.chart(surface, {{-428, -24}, {-675, -326}})
|
||||
game.forces.player.chart(surface, {{577, -24}, {824, -326}})
|
||||
game.forces.player.chart(surface, {{248, 0}, {-248, 200}})
|
||||
if Diff.difficulty_vote_index then
|
||||
this.wave_interval = this.difficulties_votes[Diff.difficulty_vote_index].wave_interval
|
||||
end
|
||||
|
2054
maps/crab_defender/map.lua
Normal file
2054
maps/crab_defender/map.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -46,8 +46,8 @@ function Public.reset_table()
|
||||
this.boss_biters = {}
|
||||
this.acid_lines_delay = {}
|
||||
this.entity_limits = {
|
||||
['gun-turret'] = {placed = 1, limit = 2, str = 'gun turret', slot_price = 75},
|
||||
['laser-turret'] = {placed = 0, limit = 1, str = 'laser turret', slot_price = 300},
|
||||
['gun-turret'] = {placed = 1, limit = 2, str = 'gun turret', slot_price = 40},
|
||||
['laser-turret'] = {placed = 0, limit = 1, str = 'laser turret', slot_price = 200},
|
||||
['artillery-turret'] = {placed = 0, limit = 1, str = 'artillery turret', slot_price = 500},
|
||||
['flamethrower-turret'] = {placed = 0, limit = 0, str = 'flamethrower turret', slot_price = 50000},
|
||||
['land-mine'] = {placed = 0, limit = 1, str = 'mine', slot_price = 20}
|
||||
|
@@ -7,7 +7,7 @@ Public.events = {breached_wall = Event.generate_event_name('breached_wall')}
|
||||
|
||||
function Public.init_enemy_weapon_damage()
|
||||
local data = {
|
||||
['artillery-shell'] = -0.85,
|
||||
['artillery-shell'] = -1.3,
|
||||
['biological'] = 0,
|
||||
['bullet'] = 0,
|
||||
['cannon-shell'] = 0,
|
||||
|
@@ -2,8 +2,7 @@ local Collapse = require 'modules.collapse'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Balance = require 'maps.mountain_fortress_v3.balance'
|
||||
local RPG_Settings = require 'modules.rpg.table'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Functions = require 'modules.rpg.functions'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Alert = require 'utils.alert'
|
||||
local Event = require 'utils.event'
|
||||
@@ -21,7 +20,7 @@ local collapse_message =
|
||||
Token.register(
|
||||
function(data)
|
||||
local pos = data.position
|
||||
local message = keeper .. 'Warning, collapse has begun!'
|
||||
local message = keeper .. 'Warning, Collapse has begun!'
|
||||
local collapse_position = {
|
||||
position = pos
|
||||
}
|
||||
@@ -63,6 +62,7 @@ local function distance(player)
|
||||
local bonus = rpg_t[player.index].bonus
|
||||
local breached_wall = WPT.get('breached_wall')
|
||||
local bonus_xp_on_join = WPT.get('bonus_xp_on_join')
|
||||
local enable_arties = WPT.get('enable_arties')
|
||||
|
||||
local distance_to_center = floor(sqrt(player.position.x ^ 2 + player.position.y ^ 2))
|
||||
local location = distance_to_center
|
||||
@@ -90,7 +90,9 @@ local function distance(player)
|
||||
}
|
||||
Task.set_timeout_in_ticks(360, first_player_to_zone, data)
|
||||
if breached_wall == 5 then
|
||||
Task.set_timeout_in_ticks(360, artillery_warning)
|
||||
if enable_arties == 6 then
|
||||
Task.set_timeout_in_ticks(360, artillery_warning)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not Collapse.start_now() then
|
||||
@@ -106,7 +108,7 @@ local function distance(player)
|
||||
bonus = bonus
|
||||
}
|
||||
Task.set_timeout_in_ticks(1, zone_complete, data)
|
||||
RPG.gain_xp(player, bonus_xp_on_join * bonus)
|
||||
Functions.gain_xp(player, bonus_xp_on_join * bonus)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@@ -72,6 +72,13 @@ local function set_objective_health(final_damage_amount)
|
||||
return
|
||||
end
|
||||
|
||||
if not this.locomotive then
|
||||
return
|
||||
end
|
||||
if not this.locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if this.locomotive_health <= 5000 then
|
||||
if not this.poison_deployed then
|
||||
for i = 1, 2, 1 do
|
||||
@@ -112,13 +119,6 @@ local function protect_entities(event)
|
||||
local this = WPT.get()
|
||||
local entity = event.entity
|
||||
|
||||
if not this.locomotive then
|
||||
return
|
||||
end
|
||||
if not this.locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if entity.force.index ~= 1 then
|
||||
return
|
||||
end --Player Force
|
||||
|
@@ -8,7 +8,8 @@ local this = {
|
||||
power_sources = {index = 1},
|
||||
refill_turrets = {index = 1},
|
||||
magic_crafters = {index = 1},
|
||||
magic_fluid_crafters = {index = 1}
|
||||
magic_fluid_crafters = {index = 1},
|
||||
art_table = {index = 1}
|
||||
}
|
||||
|
||||
Global.register(
|
||||
@@ -24,6 +25,15 @@ local magic_crafters_per_tick = 3
|
||||
local magic_fluid_crafters_per_tick = 8
|
||||
local floor = math.floor
|
||||
|
||||
local artillery_target_entities = {
|
||||
'character',
|
||||
'tank',
|
||||
'car',
|
||||
'furnace',
|
||||
'straight-rail',
|
||||
'curved-rail'
|
||||
}
|
||||
|
||||
local function fast_remove(tbl, index)
|
||||
local count = #tbl
|
||||
if index > count then
|
||||
@@ -186,6 +196,88 @@ local function do_magic_fluid_crafters()
|
||||
magic_fluid_crafters.index = index
|
||||
end
|
||||
|
||||
local artillery_target_callback =
|
||||
Token.register(
|
||||
function(data)
|
||||
local position = data.position
|
||||
local entity = data.entity
|
||||
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local tx, ty = position.x, position.y
|
||||
|
||||
local pos = entity.position
|
||||
local x, y = pos.x, pos.y
|
||||
local dx, dy = tx - x, ty - y
|
||||
local d = dx * dx + dy * dy
|
||||
if d >= 1024 then -- 32 ^ 2
|
||||
entity.surface.create_entity {
|
||||
name = 'artillery-projectile',
|
||||
position = position,
|
||||
target = entity,
|
||||
speed = 1.5
|
||||
}
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local function do_artillery_turrets_targets()
|
||||
local art_table = this.art_table
|
||||
local index = art_table.index
|
||||
|
||||
if index > #art_table then
|
||||
art_table.index = 1
|
||||
return
|
||||
end
|
||||
|
||||
art_table.index = index + 1
|
||||
|
||||
local outpost = art_table[index]
|
||||
|
||||
local now = game.tick
|
||||
if now - outpost.last_fire_tick < 480 then
|
||||
return
|
||||
end
|
||||
|
||||
local turrets = outpost.artillery_turrets
|
||||
for i = #turrets, 1, -1 do
|
||||
local turret = turrets[i]
|
||||
if not turret.valid then
|
||||
fast_remove(turrets, i)
|
||||
end
|
||||
end
|
||||
|
||||
local count = #turrets
|
||||
if count == 0 then
|
||||
fast_remove(art_table, index)
|
||||
return
|
||||
end
|
||||
|
||||
outpost.last_fire_tick = now
|
||||
|
||||
local turret = turrets[1]
|
||||
local area = outpost.artillery_area
|
||||
local surface = turret.surface
|
||||
|
||||
local entities = surface.find_entities_filtered {area = area, name = artillery_target_entities}
|
||||
|
||||
if #entities == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local position = turret.position
|
||||
|
||||
for i = 1, count do
|
||||
local entity = entities[math.random(#entities)]
|
||||
if entity and entity.valid then
|
||||
local data = {position = position, entity = entity}
|
||||
Task.set_timeout_in_ticks(i * 60, artillery_target_callback, data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function add_magic_crafter_output(entity, output, distance)
|
||||
local magic_fluid_crafters = this.magic_fluid_crafters
|
||||
local magic_crafters = this.magic_crafters
|
||||
@@ -212,6 +304,7 @@ local function tick()
|
||||
do_refill_turrets()
|
||||
do_magic_crafters()
|
||||
do_magic_fluid_crafters()
|
||||
do_artillery_turrets_targets()
|
||||
end
|
||||
|
||||
Public.deactivate_callback =
|
||||
@@ -304,6 +397,39 @@ Public.refill_turret_callback =
|
||||
end
|
||||
)
|
||||
|
||||
Public.refill_artillery_turret_callback =
|
||||
Token.register(
|
||||
function(turret, data)
|
||||
local refill_turrets = this.refill_turrets
|
||||
local art_table = this.art_table
|
||||
local index = art_table.index
|
||||
|
||||
turret.direction = 3
|
||||
|
||||
refill_turrets[#refill_turrets + 1] = {turret = turret, data = data.callback_data}
|
||||
|
||||
local artillery_data = art_table[index]
|
||||
if not artillery_data then
|
||||
artillery_data = {}
|
||||
end
|
||||
|
||||
local artillery_turrets = artillery_data.artillery_turrets
|
||||
if not artillery_turrets then
|
||||
artillery_turrets = {}
|
||||
artillery_data.artillery_turrets = artillery_turrets
|
||||
|
||||
local pos = turret.position
|
||||
local x, y = pos.x, pos.y
|
||||
artillery_data.artillery_area = {{x - 112, y}, {x + 112, y + 212}}
|
||||
artillery_data.last_fire_tick = 0
|
||||
|
||||
art_table[#art_table + 1] = artillery_data
|
||||
end
|
||||
|
||||
artillery_turrets[#artillery_turrets + 1] = turret
|
||||
end
|
||||
)
|
||||
|
||||
Public.refill_liquid_turret_callback =
|
||||
Token.register(
|
||||
function(turret, data)
|
||||
|
@@ -1,6 +1,5 @@
|
||||
local Event = require 'utils.event'
|
||||
local RPG_Settings = require 'modules.rpg.table'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Gui = require 'utils.gui'
|
||||
local format_number = require 'util'.format_number
|
||||
|
@@ -257,10 +257,7 @@ local function construct_wagon_doors(icw, wagon)
|
||||
local area = wagon.area
|
||||
local surface = wagon.surface
|
||||
|
||||
local main_tile_name = 'tutorial-grid'
|
||||
if wagon.entity.type == 'locomotive' then
|
||||
main_tile_name = 'black-refined-concrete'
|
||||
end
|
||||
local main_tile_name = 'black-refined-concrete'
|
||||
|
||||
for _, x in pairs({area.left_top.x - 1, area.right_bottom.x + 0.5}) do
|
||||
local p = {x, area.left_top.y + 30}
|
||||
@@ -381,10 +378,7 @@ function Public.create_wagon_room(icw, wagon)
|
||||
local surface = wagon.surface
|
||||
local area = wagon.area
|
||||
|
||||
local main_tile_name = 'tutorial-grid'
|
||||
if wagon.entity.type == 'locomotive' then
|
||||
main_tile_name = 'black-refined-concrete'
|
||||
end
|
||||
local main_tile_name = 'black-refined-concrete'
|
||||
|
||||
local tiles = {}
|
||||
for x = -3, 2, 1 do
|
||||
|
@@ -3,11 +3,12 @@ local Event = require 'utils.event'
|
||||
local Market = require 'maps.mountain_fortress_v3.basic_markets'
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Session = require 'utils.session_data'
|
||||
local Difficulty = require 'modules.difficulty_vote'
|
||||
local Jailed = require 'utils.jail_data'
|
||||
local RPG_Settings = require 'modules.rpg.table'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local Functions = require 'modules.rpg.functions'
|
||||
local Gui = require 'utils.gui'
|
||||
local Server = require 'utils.server'
|
||||
local Alert = require 'utils.alert'
|
||||
@@ -17,6 +18,7 @@ local format_number = require 'util'.format_number
|
||||
local Public = {}
|
||||
local concat = table.concat
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local rpg_main_frame = RPG_Settings.main_frame_name
|
||||
|
||||
local shopkeeper = '[color=blue]Shopkeeper:[/color]\n'
|
||||
|
||||
@@ -58,15 +60,15 @@ end
|
||||
function Public.add_player_to_permission_group(player, group)
|
||||
local jailed = Jailed.get_jailed_table()
|
||||
local enable_permission_group_disconnect = WPT.get('disconnect_wagon')
|
||||
local tracker = Session.get_tracker_table()
|
||||
local session = Session.get_session_table()
|
||||
|
||||
if player.admin then
|
||||
return
|
||||
end
|
||||
|
||||
local playtime = player.online_time
|
||||
if tracker[player.name] then
|
||||
playtime = player.online_time + tracker[player.name]
|
||||
if session[player.name] then
|
||||
playtime = player.online_time + session[player.name]
|
||||
end
|
||||
|
||||
if jailed[player.name] then
|
||||
@@ -86,7 +88,7 @@ function Public.add_player_to_permission_group(player, group)
|
||||
end
|
||||
|
||||
local not_trusted = game.permissions.get_group('not_trusted')
|
||||
if playtime < 2592000 then -- 12 hours
|
||||
if playtime < 5184000 then -- 24 hours
|
||||
if not not_trusted then
|
||||
not_trusted = game.permissions.create_group('not_trusted')
|
||||
not_trusted.set_allows_action(defines.input_action.cancel_craft, false)
|
||||
@@ -155,7 +157,7 @@ local function property_boost(data)
|
||||
then
|
||||
Public.add_player_to_permission_group(player, 'locomotive')
|
||||
local pos = player.position
|
||||
RPG.gain_xp(player, 0.3 * (rpg[player.index].bonus + this.xp_points))
|
||||
Functions.gain_xp(player, 0.5 * (rpg[player.index].bonus + this.xp_points))
|
||||
|
||||
player.create_local_flying_text {
|
||||
text = '+' .. '',
|
||||
@@ -166,6 +168,13 @@ local function property_boost(data)
|
||||
}
|
||||
rpg[player.index].xp_since_last_floaty_text = 0
|
||||
rpg[player.index].last_floaty_text = game.tick + visuals_delay
|
||||
if player.gui.left[rpg_main_frame] then
|
||||
local f = player.gui.left[rpg_main_frame]
|
||||
local d = Gui.get_data(f)
|
||||
if d.exp_gui and d.exp_gui.valid then
|
||||
d.exp_gui.caption = math.floor(rpg[player.index].xp)
|
||||
end
|
||||
end
|
||||
else
|
||||
Public.add_player_to_permission_group(player, 'default')
|
||||
end
|
||||
@@ -257,9 +266,11 @@ local function set_locomotive_health()
|
||||
if not this.locomotive then
|
||||
return
|
||||
end
|
||||
|
||||
if not this.locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local locomotive_health = WPT.get('locomotive_health')
|
||||
local locomotive_max_health = WPT.get('locomotive_max_health')
|
||||
local m = locomotive_health / locomotive_max_health
|
||||
@@ -276,12 +287,13 @@ local function validate_index()
|
||||
if not locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local icw_locomotive = WPT.get('icw_locomotive')
|
||||
local loco_surface = icw_locomotive.surface
|
||||
local unit_surface = locomotive.unit_number
|
||||
local locomotive_surface = game.surfaces[icw_table.wagons[unit_surface].surface.index]
|
||||
if not loco_surface.valid then
|
||||
WPT.get().loco_surface = locomotive_surface
|
||||
WPT.set().loco_surface = locomotive_surface
|
||||
end
|
||||
end
|
||||
|
||||
@@ -924,7 +936,7 @@ local function gui_click(event)
|
||||
format_number(item.price, true) .. ' coins.'
|
||||
Alert.alert_all_players(10, message)
|
||||
|
||||
RPG.rpg_reset_player(player, true)
|
||||
Functions.rpg_reset_player(player, true)
|
||||
|
||||
redraw_market_items(data.item_frame, player, data.search_text)
|
||||
redraw_coins_left(data.coins_left, player)
|
||||
@@ -1130,9 +1142,11 @@ local function contains_positions(area)
|
||||
|
||||
local wagons = ICW.get_table('wagons')
|
||||
for _, wagon in pairs(wagons) do
|
||||
if wagon.entity.name == 'cargo-wagon' then
|
||||
if inside(wagon.entity.position, area) then
|
||||
return true, wagon.entity
|
||||
if wagon.entity and wagon.entity.valid then
|
||||
if wagon.entity.name == 'cargo-wagon' then
|
||||
if inside(wagon.entity.position, area) then
|
||||
return true, wagon.entity
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1348,7 +1362,7 @@ local function add_random_loot_to_main_market(rarity)
|
||||
tooltip = types[v.offer.item].localised_name,
|
||||
upgrade = false
|
||||
}
|
||||
if ticker >= 9 then
|
||||
if ticker >= 12 then
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -1425,31 +1439,6 @@ local function on_console_chat(event)
|
||||
shoo(event)
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local ticker = game.tick
|
||||
|
||||
if ticker % 30 == 0 then
|
||||
place_market()
|
||||
validate_index()
|
||||
set_locomotive_health()
|
||||
fish_tag()
|
||||
divide_contents()
|
||||
end
|
||||
|
||||
if ticker % 120 == 0 then
|
||||
Public.boost_players_around_train()
|
||||
end
|
||||
|
||||
if ticker % 2500 == 0 then
|
||||
Public.transfer_pollution()
|
||||
end
|
||||
|
||||
if ticker % 1800 == 0 then
|
||||
set_player_spawn()
|
||||
refill_fish()
|
||||
end
|
||||
end
|
||||
|
||||
function Public.close_gui_player(frame)
|
||||
if not frame then
|
||||
return
|
||||
@@ -1647,9 +1636,9 @@ function Public.get_items()
|
||||
|
||||
local chest_limit_cost = 2500 * (1 + chest_limit_outside_upgrades)
|
||||
local health_cost = 10000 * (1 + health_upgrades)
|
||||
local aura_cost = 5000 * (1 + aura_upgrades)
|
||||
local xp_point_boost_cost = 7500 * (1 + xp_points_upgrade)
|
||||
local flamethrower_turrets_cost = 3000 * (1 + flame_turret)
|
||||
local aura_cost = 4000 * (1 + aura_upgrades)
|
||||
local xp_point_boost_cost = 5000 * (1 + xp_points_upgrade)
|
||||
local flamethrower_turrets_cost = 2500 * (1 + flame_turret)
|
||||
local land_mine_cost = 2 * (1 + landmine)
|
||||
local skill_reset_cost = 100000
|
||||
|
||||
@@ -1825,6 +1814,32 @@ function Public.get_items()
|
||||
upgrade = false,
|
||||
static = true
|
||||
}
|
||||
main_market_items['tank-cannon'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 20000,
|
||||
tooltip = 'Portable Tank Machine\nAvailable after wave 700.',
|
||||
upgrade = false,
|
||||
static = true,
|
||||
enabled = false
|
||||
}
|
||||
main_market_items['tank-machine-gun'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 7000,
|
||||
tooltip = 'Portable Tank Pewpew\nAvailable after wave 700.',
|
||||
upgrade = false,
|
||||
static = true,
|
||||
enabled = false
|
||||
}
|
||||
local wave_number = WD.get_wave()
|
||||
if wave_number >= 700 then
|
||||
main_market_items['tank-cannon'].enabled = true
|
||||
main_market_items['tank-cannon'].tooltip = 'Portable Tank Machine'
|
||||
main_market_items['tank-machine-gun'].enabled = true
|
||||
main_market_items['tank-machine-gun'].tooltip = 'Portable Tank Pewpew'
|
||||
end
|
||||
|
||||
return main_market_items
|
||||
end
|
||||
|
||||
@@ -1861,6 +1876,34 @@ function Public.enable_poison_defense()
|
||||
end
|
||||
end
|
||||
|
||||
local boost_players = Public.boost_players_around_train
|
||||
local pollute_area = Public.transfer_pollution
|
||||
|
||||
local function tick()
|
||||
local ticker = game.tick
|
||||
|
||||
if ticker % 30 == 0 then
|
||||
set_locomotive_health()
|
||||
place_market()
|
||||
validate_index()
|
||||
fish_tag()
|
||||
divide_contents()
|
||||
end
|
||||
|
||||
if ticker % 120 == 0 then
|
||||
boost_players()
|
||||
end
|
||||
|
||||
if ticker % 2500 == 0 then
|
||||
pollute_area()
|
||||
end
|
||||
|
||||
if ticker % 1800 == 0 then
|
||||
set_player_spawn()
|
||||
refill_fish()
|
||||
end
|
||||
end
|
||||
|
||||
Public.place_market = place_market
|
||||
|
||||
Event.on_nth_tick(5, tick)
|
||||
|
@@ -2,6 +2,7 @@ require 'maps.mountain_fortress_v3.generate'
|
||||
require 'maps.mountain_fortress_v3.commands'
|
||||
require 'maps.mountain_fortress_v3.breached_wall'
|
||||
|
||||
require 'modules.rpg.main'
|
||||
require 'modules.autofill'
|
||||
require 'modules.dynamic_landfill'
|
||||
require 'modules.shotgun_buff'
|
||||
@@ -27,8 +28,8 @@ local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Map = require 'modules.map_info'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local RPG_Settings = require 'modules.rpg.table'
|
||||
local RPG_Func = require 'modules.rpg.functions'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Functions = require 'maps.mountain_fortress_v3.functions'
|
||||
local Event = require 'utils.event'
|
||||
@@ -232,7 +233,7 @@ function Public.reset_map()
|
||||
game.reset_time_played()
|
||||
WPT.reset_table()
|
||||
Map_score.reset_score()
|
||||
RPG.rpg_reset_all_players()
|
||||
RPG_Func.rpg_reset_all_players()
|
||||
RPG_Settings.set_surface_name('mountain_fortress_v3')
|
||||
RPG_Settings.enable_health_and_mana_bars(true)
|
||||
RPG_Settings.enable_wave_defense(true)
|
||||
@@ -384,6 +385,16 @@ local on_player_joined_game = function(event)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if not this.locomotive or not this.locomotive.valid then
|
||||
return
|
||||
end
|
||||
if player.position.y > this.locomotive.position.y then
|
||||
player.teleport(
|
||||
surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5),
|
||||
surface
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local on_player_left_game = function()
|
||||
@@ -722,7 +733,7 @@ local on_tick = function()
|
||||
has_the_game_ended()
|
||||
chunk_load()
|
||||
|
||||
if game.tick % 1800 == 0 then
|
||||
if game.tick % 1200 == 0 then
|
||||
remove_offline_players()
|
||||
boost_difficulty()
|
||||
collapse_after_wave_100()
|
||||
|
@@ -54,21 +54,9 @@ local function create_particles(surface, name, position, amount, cause_position)
|
||||
end
|
||||
|
||||
local function compute_fullness(player)
|
||||
local inv = player.get_inventory(defines.inventory.character_main)
|
||||
local max_stacks = #inv
|
||||
local num_stacks = 0
|
||||
local free_slots = player.get_main_inventory().count_empty_stacks()
|
||||
|
||||
local contents = inv.get_contents()
|
||||
for item, count in pairs(contents) do
|
||||
local stack_size = 1
|
||||
if game.item_prototypes[item].stackable then
|
||||
stack_size = game.item_prototypes[item].stack_size
|
||||
end
|
||||
|
||||
num_stacks = num_stacks + count / stack_size
|
||||
end
|
||||
|
||||
return num_stacks / max_stacks
|
||||
return free_slots
|
||||
end
|
||||
|
||||
local function mining_chances_ores()
|
||||
@@ -160,7 +148,6 @@ local function randomness(data)
|
||||
local entity = data.entity
|
||||
local player = data.player
|
||||
local this = data.this
|
||||
local fullness_limit = this.fullness_limit
|
||||
local fullness_enabled = this.fullness_enabled
|
||||
local harvest
|
||||
local harvest_amount
|
||||
@@ -172,7 +159,7 @@ local function randomness(data)
|
||||
|
||||
debug_print(player.name .. ' is ' .. fullness .. '% full.')
|
||||
|
||||
if fullness >= fullness_limit then
|
||||
if fullness == 0 then
|
||||
if player.character then
|
||||
player.character.health = player.character.health - math.random(50, 100)
|
||||
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
||||
@@ -207,15 +194,27 @@ local function randomness(data)
|
||||
)
|
||||
|
||||
if harvest_amount > max_spill then
|
||||
player.surface.spill_item_stack(position, {name = harvest, count = max_spill}, true)
|
||||
if this.spill_items_to_surface then
|
||||
player.surface.spill_item_stack(position, {name = harvest, count = max_spill}, true)
|
||||
else
|
||||
player.insert({name = harvest, count = max_spill})
|
||||
end
|
||||
harvest_amount = harvest_amount - max_spill
|
||||
local inserted_count = player.insert({name = harvest, count = harvest_amount})
|
||||
harvest_amount = harvest_amount - inserted_count
|
||||
if harvest_amount > 0 then
|
||||
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
|
||||
if this.spill_items_to_surface then
|
||||
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
|
||||
else
|
||||
player.insert({name = harvest, count = harvest_amount})
|
||||
end
|
||||
end
|
||||
else
|
||||
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
|
||||
if this.spill_items_to_surface then
|
||||
player.surface.spill_item_stack(position, {name = harvest, count = harvest_amount}, true)
|
||||
else
|
||||
player.insert({name = harvest, count = harvest_amount})
|
||||
end
|
||||
end
|
||||
local particle = particles[harvest]
|
||||
create_particles(player.surface, particle, position, 64, {x = player.position.x, y = player.position.y})
|
||||
|
@@ -33,7 +33,6 @@ function Public.reset_table()
|
||||
this.icw_locomotive = nil
|
||||
this.debug = false
|
||||
this.fullness_enabled = true
|
||||
this.fullness_limit = 0.95
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
this.train_upgrades = 0
|
||||
@@ -45,6 +44,9 @@ function Public.reset_table()
|
||||
this.locomotive_xp_aura = 40
|
||||
this.xp_points = 0
|
||||
this.xp_points_upgrade = 0
|
||||
--!grief prevention
|
||||
this.enable_arties = 5 -- default to callback 6
|
||||
--!snip
|
||||
this.poison_deployed = false
|
||||
this.upgrades = {
|
||||
showed_text = false,
|
||||
@@ -80,6 +82,7 @@ function Public.reset_table()
|
||||
this.difficulty_set = false
|
||||
this.bonus_xp_on_join = 150
|
||||
this.main_market_items = {}
|
||||
this.spill_items_to_surface = false
|
||||
this.outside_chests = {}
|
||||
this.chests_linked_to = {}
|
||||
this.chest_limit_outside_upgrades = 1
|
||||
|
@@ -68,7 +68,7 @@ local callback = {
|
||||
[3] = {callback = Functions.refill_turret_callback, data = uranium_rounds_magazine_ammo},
|
||||
[4] = {callback = Functions.power_source_callback, data = laser_turrent_power_source},
|
||||
[5] = {callback = Functions.refill_liquid_turret_callback, data = light_oil_ammo},
|
||||
[6] = {callback = Functions.refill_turret_callback, data = artillery_shell_ammo}
|
||||
[6] = {callback = Functions.refill_artillery_turret_callback, data = artillery_shell_ammo}
|
||||
}
|
||||
|
||||
local turret_list = {
|
||||
@@ -215,6 +215,7 @@ local function wall(data)
|
||||
local surface = data.surface
|
||||
local treasure = data.treasure
|
||||
local stone_wall = {callback = Functions.disable_minable_callback}
|
||||
local enable_arties = WPT.get('enable_arties')
|
||||
|
||||
local x, y = Public.increment_value(data)
|
||||
|
||||
@@ -345,12 +346,12 @@ local function wall(data)
|
||||
elseif math.random(1, 2) == 1 then
|
||||
spawn_turret(entities, p, 5)
|
||||
elseif math.random(1, 8) == 1 then
|
||||
spawn_turret(entities, p, 6)
|
||||
spawn_turret(entities, p, enable_arties)
|
||||
end
|
||||
end
|
||||
elseif math.abs(p.y) > Public.level_depth * 5.5 then
|
||||
if math.random(1, 32) == 1 then
|
||||
spawn_turret(entities, p, math.random(3, 6))
|
||||
spawn_turret(entities, p, math.random(3, enable_arties))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1571,9 +1572,9 @@ end
|
||||
|
||||
Public.levels = {
|
||||
process_level_2_position,
|
||||
process_level_4_position,
|
||||
process_level_1_position,
|
||||
process_level_2_position,
|
||||
process_level_3_position,
|
||||
process_level_6_position,
|
||||
process_level_2_position,
|
||||
process_level_3_position,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
local Event = require 'utils.event'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
|
||||
local tick_tacks = {'*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*'}
|
||||
local tick_tacks = {'*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*', '( ͡° ͜ʖ ͡°)'}
|
||||
|
||||
local kaboom_weights = {
|
||||
{name = 'grenade', chance = 7},
|
||||
|
@@ -3,10 +3,18 @@ local RPG = require 'modules.rpg.table'
|
||||
local Gui = require 'utils.gui'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Token = require 'utils.token'
|
||||
local Alert = require 'utils.alert'
|
||||
|
||||
local Public = {}
|
||||
|
||||
local level_up_floating_text_color = {0, 205, 0}
|
||||
local visuals_delay = RPG.visuals_delay
|
||||
local xp_floating_text_color = RPG.xp_floating_text_color
|
||||
local teller_level_limit = RPG.teller_level_limit
|
||||
local experience_levels = RPG.experience_levels
|
||||
local teller_global_pool = RPG.teller_global_pool
|
||||
local rpg_frame_icons = RPG.rpg_frame_icons
|
||||
local points_per_level = RPG.points_per_level
|
||||
|
||||
--RPG Frames
|
||||
local main_frame_name = RPG.main_frame_name
|
||||
@@ -93,6 +101,49 @@ local function set_bar(min, max, id, mana)
|
||||
end
|
||||
end
|
||||
|
||||
local function level_up(player)
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local RPG_GUI = package.loaded['modules.rpg.gui']
|
||||
|
||||
local distribute_points_gain = 0
|
||||
for i = rpg_t[player.index].level + 1, #experience_levels, 1 do
|
||||
if rpg_t[player.index].xp > experience_levels[i] then
|
||||
rpg_t[player.index].level = i
|
||||
distribute_points_gain = distribute_points_gain + points_per_level
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if distribute_points_gain == 0 then
|
||||
return
|
||||
end
|
||||
RPG_GUI.draw_level_text(player)
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + distribute_points_gain
|
||||
RPG_GUI.update_char_button(player)
|
||||
table.shuffle_table(rpg_frame_icons)
|
||||
if player.gui.left[main_frame_name] then
|
||||
RPG_GUI.toggle(player, true)
|
||||
end
|
||||
Public.level_up_effects(player)
|
||||
end
|
||||
|
||||
local function add_to_global_pool(amount, personal_tax)
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
|
||||
if not rpg_extra.global_pool then
|
||||
return
|
||||
end
|
||||
local fee
|
||||
if personal_tax then
|
||||
fee = amount * rpg_extra.personal_tax_rate
|
||||
else
|
||||
fee = amount * 0.3
|
||||
end
|
||||
|
||||
rpg_extra.global_pool = rpg_extra.global_pool + fee
|
||||
return amount - fee
|
||||
end
|
||||
|
||||
function Public.suicidal_comfylatron(pos, surface)
|
||||
local str = travelings[math.random(1, #travelings)]
|
||||
local symbols = {'', '!', '!', '!!', '..'}
|
||||
@@ -184,11 +235,10 @@ function Public.update_mana(player)
|
||||
if player.character and player.character.valid then
|
||||
if not rpg_t[player.index].mana_bar then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
set_bar(rpg_t[player.index].mana, rpg_t[player.index].mana_max, rpg_t[player.index].mana_bar, true)
|
||||
elseif not rendering.is_valid(rpg_t[player.index].mana_bar) then
|
||||
rpg_t[player.index].mana_bar = create_manabar(player, 0.5)
|
||||
set_bar(rpg_t[player.index].mana, rpg_t[player.index].mana_max, rpg_t[player.index].mana_bar, true)
|
||||
end
|
||||
set_bar(rpg_t[player.index].mana, rpg_t[player.index].mana_max, rpg_t[player.index].mana_bar, true)
|
||||
end
|
||||
else
|
||||
if rpg_t[player.index].mana_bar then
|
||||
@@ -214,11 +264,11 @@ function Public.update_health(player)
|
||||
)
|
||||
if not rpg_t[player.index].health_bar then
|
||||
rpg_t[player.index].health_bar = create_healthbar(player, 0.5)
|
||||
set_bar(player.character.health, max_life, rpg_t[player.index].health_bar)
|
||||
elseif not rendering.is_valid(rpg_t[player.index].health_bar) then
|
||||
rpg_t[player.index].health_bar = create_healthbar(player, 0.5)
|
||||
set_bar(player.character.health, max_life, rpg_t[player.index].health_bar)
|
||||
end
|
||||
set_bar(player.character.health, max_life, rpg_t[player.index].health_bar)
|
||||
|
||||
if player.gui.left[main_frame_name] then
|
||||
local f = player.gui.left[main_frame_name]
|
||||
local data = Gui.get_data(f)
|
||||
@@ -365,4 +415,239 @@ function Public.get_magicka(player)
|
||||
return (rpg_t[player.index].magicka - 10) * 0.10
|
||||
end
|
||||
|
||||
--- Gives connected player some bonus xp if the map was preemptively shut down.
|
||||
-- amount (integer) -- 10 levels
|
||||
-- local Public = require 'modules.rpg_v2' Public.give_xp(512)
|
||||
function Public.give_xp(amount)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if not Public.validate_player(player) then
|
||||
return
|
||||
end
|
||||
Public.gain_xp(player, amount)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.rpg_reset_player(player, one_time_reset)
|
||||
if not player.character then
|
||||
player.set_controller({type = defines.controllers.god})
|
||||
player.create_character()
|
||||
end
|
||||
local RPG_GUI = package.loaded['modules.rpg.gui']
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
if one_time_reset then
|
||||
local total = rpg_t[player.index].total
|
||||
if not total then
|
||||
total = 0
|
||||
end
|
||||
local old_level = rpg_t[player.index].level
|
||||
local old_points_to_distribute = rpg_t[player.index].points_to_distribute
|
||||
local old_xp = rpg_t[player.index].xp
|
||||
rpg_t[player.index] = {
|
||||
level = 1,
|
||||
xp = 0,
|
||||
strength = 10,
|
||||
magicka = 10,
|
||||
dexterity = 10,
|
||||
vitality = 10,
|
||||
mana = 0,
|
||||
mana_max = 0,
|
||||
last_spawned = 0,
|
||||
dropdown_select_index = 1,
|
||||
flame_boots = false,
|
||||
enable_entity_spawn = false,
|
||||
health_bar = rpg_t[player.index].health_bar,
|
||||
mana_bar = rpg_t[player.index].mana_bar,
|
||||
points_to_distribute = 0,
|
||||
last_floaty_text = visuals_delay,
|
||||
xp_since_last_floaty_text = 0,
|
||||
reset = true,
|
||||
capped = false,
|
||||
bonus = rpg_extra.breached_walls or 1,
|
||||
rotated_entity_delay = 0,
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = false,
|
||||
stone_path = false,
|
||||
one_punch = false
|
||||
}
|
||||
rpg_t[player.index].points_to_distribute = old_points_to_distribute + total
|
||||
rpg_t[player.index].xp = old_xp
|
||||
rpg_t[player.index].level = old_level
|
||||
else
|
||||
rpg_t[player.index] = {
|
||||
level = 1,
|
||||
xp = 0,
|
||||
strength = 10,
|
||||
magicka = 10,
|
||||
dexterity = 10,
|
||||
vitality = 10,
|
||||
mana = 0,
|
||||
mana_max = 0,
|
||||
last_spawned = 0,
|
||||
dropdown_select_index = 1,
|
||||
flame_boots = false,
|
||||
enable_entity_spawn = false,
|
||||
points_to_distribute = 0,
|
||||
last_floaty_text = visuals_delay,
|
||||
xp_since_last_floaty_text = 0,
|
||||
reset = false,
|
||||
capped = false,
|
||||
total = 0,
|
||||
bonus = 1,
|
||||
rotated_entity_delay = 0,
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = false,
|
||||
stone_path = false,
|
||||
one_punch = false
|
||||
}
|
||||
end
|
||||
RPG_GUI.draw_gui_char_button(player)
|
||||
RPG_GUI.draw_level_text(player)
|
||||
RPG_GUI.update_char_button(player)
|
||||
RPG_GUI.update_player_stats(player)
|
||||
end
|
||||
|
||||
function Public.rpg_reset_all_players()
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
for k, _ in pairs(rpg_t) do
|
||||
rpg_t[k] = nil
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
Public.rpg_reset_player(p)
|
||||
end
|
||||
rpg_extra.breached_walls = 1
|
||||
rpg_extra.reward_new_players = 0
|
||||
rpg_extra.global_pool = 0
|
||||
end
|
||||
|
||||
function Public.gain_xp(player, amount, added_to_pool, text)
|
||||
if not Public.validate_player(player) then
|
||||
return
|
||||
end
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
|
||||
if Public.level_limit_exceeded(player) then
|
||||
add_to_global_pool(amount, false)
|
||||
if not rpg_t[player.index].capped then
|
||||
rpg_t[player.index].capped = true
|
||||
local message = teller_level_limit .. 'You have hit the max level for the current zone.'
|
||||
Alert.alert_player_warning(player, 10, message)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local text_to_draw
|
||||
|
||||
if rpg_t[player.index].capped then
|
||||
rpg_t[player.index].capped = false
|
||||
end
|
||||
|
||||
if not added_to_pool then
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
|
||||
local fee = amount - add_to_global_pool(amount, true)
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got fee: ' .. fee)
|
||||
amount = math.round(amount, 3) - fee
|
||||
if rpg_extra.difficulty then
|
||||
amount = amount + rpg_extra.difficulty
|
||||
end
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got after fee: ' .. amount)
|
||||
else
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
|
||||
end
|
||||
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp + amount
|
||||
rpg_t[player.index].xp_since_last_floaty_text = rpg_t[player.index].xp_since_last_floaty_text + amount
|
||||
|
||||
if not experience_levels[rpg_t[player.index].level + 1] then
|
||||
return
|
||||
end
|
||||
|
||||
if rpg_t[player.index].xp >= experience_levels[rpg_t[player.index].level + 1] then
|
||||
level_up(player)
|
||||
end
|
||||
|
||||
if rpg_t[player.index].last_floaty_text > game.tick then
|
||||
if not text then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if text then
|
||||
text_to_draw = '+' .. math.floor(amount) .. ' xp'
|
||||
else
|
||||
text_to_draw = '+' .. math.floor(rpg_t[player.index].xp_since_last_floaty_text) .. ' xp'
|
||||
end
|
||||
|
||||
player.create_local_flying_text {
|
||||
text = text_to_draw,
|
||||
position = player.position,
|
||||
color = xp_floating_text_color,
|
||||
time_to_live = 340,
|
||||
speed = 2
|
||||
}
|
||||
|
||||
rpg_t[player.index].xp_since_last_floaty_text = 0
|
||||
rpg_t[player.index].last_floaty_text = game.tick + visuals_delay
|
||||
end
|
||||
|
||||
function Public.global_pool(players, count)
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
|
||||
if not rpg_extra.global_pool then
|
||||
return
|
||||
end
|
||||
|
||||
local pool = math.floor(rpg_extra.global_pool)
|
||||
|
||||
local random_amount = math.random(5000, 10000)
|
||||
|
||||
if pool <= random_amount then
|
||||
return
|
||||
end
|
||||
|
||||
if pool >= 20000 then
|
||||
pool = 20000
|
||||
end
|
||||
|
||||
local share = pool / count
|
||||
|
||||
RPG.debug_log('RPG - Share per player:' .. share)
|
||||
|
||||
for i = 1, #players do
|
||||
local p = players[i]
|
||||
if p.afk_time < 5000 then
|
||||
if not Public.level_limit_exceeded(p) then
|
||||
Public.gain_xp(p, share, false, true)
|
||||
Public.xp_effects(p)
|
||||
else
|
||||
share = share / 10
|
||||
rpg_extra.leftover_pool = rpg_extra.leftover_pool + share
|
||||
RPG.debug_log('RPG - player capped: ' .. p.name .. '. Amount to pool:' .. share)
|
||||
end
|
||||
else
|
||||
local message = teller_global_pool .. p.name .. ' received nothing. Reason: AFK'
|
||||
Alert.alert_player_warning(p, 10, message)
|
||||
share = share / 10
|
||||
rpg_extra.leftover_pool = rpg_extra.leftover_pool + share
|
||||
RPG.debug_log('RPG - player AFK: ' .. p.name .. '. Amount to pool:' .. share)
|
||||
end
|
||||
end
|
||||
|
||||
rpg_extra.global_pool = rpg_extra.leftover_pool or 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--- Distributes the global xp pool to every connected player.
|
||||
function Public.distribute_pool()
|
||||
local count = #game.connected_players
|
||||
local players = game.connected_players
|
||||
Public.global_pool(players, count)
|
||||
print('Distributed the global XP pool')
|
||||
end
|
||||
|
||||
Public.add_to_global_pool = add_to_global_pool
|
||||
|
||||
return Public
|
||||
|
@@ -28,11 +28,12 @@ function Public.draw_gui_char_button(player)
|
||||
if player.gui.top[draw_main_frame_name] then
|
||||
return
|
||||
end
|
||||
local b = player.gui.top.add({type = 'sprite-button', name = draw_main_frame_name, caption = 'CHAR'})
|
||||
local b =
|
||||
player.gui.top.add({type = 'sprite-button', name = draw_main_frame_name, caption = '[RPG]', tooltip = 'RPG'})
|
||||
b.style.font_color = {165, 165, 165}
|
||||
b.style.font = 'heading-1'
|
||||
b.style.minimal_height = 38
|
||||
b.style.minimal_width = 60
|
||||
b.style.font = 'heading-3'
|
||||
b.style.minimal_height = 34
|
||||
b.style.minimal_width = 50
|
||||
b.style.padding = 0
|
||||
b.style.margin = 0
|
||||
end
|
||||
@@ -92,10 +93,23 @@ local function add_gui_stat(element, value, width, tooltip, name, color)
|
||||
e.style.maximal_height = 38
|
||||
e.style.minimal_height = 38
|
||||
e.style.font = 'default-bold'
|
||||
e.style.font_color = {222, 222, 222}
|
||||
e.style.horizontal_align = 'center'
|
||||
e.style.vertical_align = 'center'
|
||||
e.style.font_color = color or nil
|
||||
e.style.font_color = color or {222, 222, 222}
|
||||
return e
|
||||
end
|
||||
|
||||
local function add_elem_stat(element, value, width, height, font, tooltip, name, color)
|
||||
local e = element.add({type = 'sprite-button', name = name or nil, caption = value})
|
||||
e.tooltip = tooltip or ''
|
||||
e.style.maximal_width = width
|
||||
e.style.minimal_width = width
|
||||
e.style.maximal_height = height
|
||||
e.style.minimal_height = height
|
||||
e.style.font = font or 'default-bold'
|
||||
e.style.horizontal_align = 'center'
|
||||
e.style.vertical_align = 'center'
|
||||
e.style.font_color = color or {222, 222, 222}
|
||||
return e
|
||||
end
|
||||
|
||||
@@ -152,36 +166,47 @@ local function draw_main_frame(player)
|
||||
return
|
||||
end
|
||||
|
||||
local frame =
|
||||
local main_frame =
|
||||
player.gui.left.add(
|
||||
{type = 'frame', name = main_frame_name, direction = 'vertical', style = 'changelog_subheader_frame'}
|
||||
{
|
||||
type = 'frame',
|
||||
name = main_frame_name,
|
||||
caption = 'RPG',
|
||||
direction = 'vertical'
|
||||
}
|
||||
)
|
||||
|
||||
local data = {}
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
|
||||
frame.style.maximal_height = 800
|
||||
frame.style.maximal_width = 440
|
||||
frame.style.minimal_width = 440
|
||||
frame.style.use_header_filler = false
|
||||
frame.style.top_padding = 4
|
||||
frame.style.bottom_padding = 4
|
||||
frame.style.left_padding = 4
|
||||
frame.style.right_padding = 10
|
||||
local inside_frame =
|
||||
main_frame.add {
|
||||
type = 'frame',
|
||||
style = 'deep_frame_in_shallow_frame'
|
||||
}
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.padding = 0
|
||||
inside_frame_style.maximal_height = 800
|
||||
|
||||
local inside_table =
|
||||
inside_frame.add {
|
||||
type = 'table',
|
||||
column_count = 1
|
||||
}
|
||||
|
||||
local scroll_pane =
|
||||
frame.add {
|
||||
inside_table.add {
|
||||
type = 'scroll-pane',
|
||||
direction = 'vertical',
|
||||
vertical_scroll_policy = 'always',
|
||||
vertical_scroll_policy = 'never',
|
||||
horizontal_scroll_policy = 'never'
|
||||
}
|
||||
scroll_pane.style.minimal_width = 400
|
||||
scroll_pane.style.maximal_width = 450
|
||||
scroll_pane.style.minimal_height = 600
|
||||
scroll_pane.style.horizontally_squashable = false
|
||||
scroll_pane.style.vertically_squashable = false
|
||||
local scroll_style = scroll_pane.style
|
||||
scroll_style.vertically_squashable = true
|
||||
scroll_style.bottom_padding = 2
|
||||
scroll_style.left_padding = 2
|
||||
scroll_style.right_padding = 2
|
||||
scroll_style.top_padding = 2
|
||||
|
||||
--!top table
|
||||
local main_table = scroll_pane.add({type = 'table', column_count = 2})
|
||||
@@ -191,7 +216,15 @@ local function draw_main_frame(player)
|
||||
local rank = add_gui_stat(main_table, get_class(player), 200, 'You´re a ' .. get_class(player) .. '.')
|
||||
rank.style.font = 'default-large-bold'
|
||||
|
||||
add_gui_stat(main_table, 'SETTINGS', 200, 'RPG settings!', settings_button_name)
|
||||
add_elem_stat(
|
||||
main_table,
|
||||
'SETTINGS',
|
||||
200,
|
||||
35,
|
||||
nil,
|
||||
'Configure your RPG player-settings here!',
|
||||
settings_button_name
|
||||
)
|
||||
|
||||
add_separator(scroll_pane, 400)
|
||||
|
||||
@@ -210,7 +243,8 @@ local function draw_main_frame(player)
|
||||
end
|
||||
|
||||
add_gui_description(scroll_table, 'EXPERIENCE', 100)
|
||||
add_gui_stat(scroll_table, math.floor(rpg_t[player.index].xp), 125, gain_info_tooltip)
|
||||
local exp_gui = add_gui_stat(scroll_table, math.floor(rpg_t[player.index].xp), 125, gain_info_tooltip)
|
||||
data.exp_gui = exp_gui
|
||||
|
||||
add_gui_description(scroll_table, ' ', 75)
|
||||
add_gui_description(scroll_table, ' ', 75)
|
||||
@@ -416,9 +450,9 @@ local function draw_main_frame(player)
|
||||
add_separator(scroll_pane, 400)
|
||||
|
||||
Public.update_char_button(player)
|
||||
data.frame = frame
|
||||
data.frame = main_frame
|
||||
|
||||
Gui.set_data(frame, data)
|
||||
Gui.set_data(main_frame, data)
|
||||
end
|
||||
|
||||
function Public.draw_level_text(player)
|
||||
@@ -617,7 +651,7 @@ Gui.on_click(
|
||||
if reset_gui_input and reset_gui_input.valid and reset_gui_input.state then
|
||||
if not rpg_t[player.index].reset then
|
||||
rpg_t[player.index].reset = true
|
||||
Public.rpg_reset_player(player, true)
|
||||
Functions.rpg_reset_player(player, true)
|
||||
end
|
||||
end
|
||||
if health_bar_gui_input and health_bar_gui_input.valid then
|
||||
|
@@ -2,125 +2,24 @@ local Gui = require 'utils.gui'
|
||||
local Event = require 'utils.event'
|
||||
local AntiGrief = require 'antigrief'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Alert = require 'utils.alert'
|
||||
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Math2D = require 'math2d'
|
||||
|
||||
--RPG Modules
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local Settings = require 'modules.rpg.settings'
|
||||
local Functions = require 'modules.rpg.functions'
|
||||
local RPG_GUI = require 'modules.rpg.gui'
|
||||
|
||||
--RPG Settings
|
||||
local enemy_types = RPG.enemy_types
|
||||
local die_cause = RPG.die_cause
|
||||
local rpg_frame_icons = RPG.rpg_frame_icons
|
||||
local points_per_level = RPG.points_per_level
|
||||
local nth_tick = RPG.nth_tick
|
||||
local visuals_delay = RPG.visuals_delay
|
||||
local xp_floating_text_color = RPG.xp_floating_text_color
|
||||
local teller_global_pool = RPG.teller_global_pool
|
||||
local teller_level_limit = RPG.teller_level_limit
|
||||
local experience_levels = RPG.experience_levels
|
||||
|
||||
--RPG Frames
|
||||
local draw_main_frame_name = RPG.draw_main_frame_name
|
||||
local main_frame_name = RPG.main_frame_name
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function level_up(player)
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
|
||||
local distribute_points_gain = 0
|
||||
for i = rpg_t[player.index].level + 1, #experience_levels, 1 do
|
||||
if rpg_t[player.index].xp > experience_levels[i] then
|
||||
rpg_t[player.index].level = i
|
||||
distribute_points_gain = distribute_points_gain + points_per_level
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if distribute_points_gain == 0 then
|
||||
return
|
||||
end
|
||||
RPG_GUI.draw_level_text(player)
|
||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + distribute_points_gain
|
||||
RPG_GUI.update_char_button(player)
|
||||
table.shuffle_table(rpg_frame_icons)
|
||||
if player.gui.left[main_frame_name] then
|
||||
RPG_GUI.toggle(player, true)
|
||||
end
|
||||
Functions.level_up_effects(player)
|
||||
end
|
||||
|
||||
local function add_to_global_pool(amount, personal_tax)
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
|
||||
if not rpg_extra.global_pool then
|
||||
return
|
||||
end
|
||||
local fee
|
||||
if personal_tax then
|
||||
fee = amount * rpg_extra.personal_tax_rate
|
||||
else
|
||||
fee = amount * 0.3
|
||||
end
|
||||
|
||||
rpg_extra.global_pool = rpg_extra.global_pool + fee
|
||||
return amount - fee
|
||||
end
|
||||
|
||||
local function global_pool(players, count)
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
|
||||
if not rpg_extra.global_pool then
|
||||
return
|
||||
end
|
||||
|
||||
local pool = math.floor(rpg_extra.global_pool)
|
||||
|
||||
local random_amount = math.random(5000, 10000)
|
||||
|
||||
if pool <= random_amount then
|
||||
return
|
||||
end
|
||||
|
||||
if pool >= 20000 then
|
||||
pool = 20000
|
||||
end
|
||||
|
||||
local share = pool / count
|
||||
|
||||
RPG.debug_log('RPG - Share per player:' .. share)
|
||||
|
||||
for i = 1, #players do
|
||||
local p = players[i]
|
||||
if p.afk_time < 5000 then
|
||||
if not Functions.level_limit_exceeded(p) then
|
||||
Public.gain_xp(p, share, false, true)
|
||||
Functions.xp_effects(p)
|
||||
else
|
||||
share = share / 10
|
||||
rpg_extra.leftover_pool = rpg_extra.leftover_pool + share
|
||||
RPG.debug_log('RPG - player capped: ' .. p.name .. '. Amount to pool:' .. share)
|
||||
end
|
||||
else
|
||||
local message = teller_global_pool .. p.name .. ' received nothing. Reason: AFK'
|
||||
Alert.alert_player_warning(p, 10, message)
|
||||
share = share / 10
|
||||
rpg_extra.leftover_pool = rpg_extra.leftover_pool + share
|
||||
RPG.debug_log('RPG - player AFK: ' .. p.name .. '. Amount to pool:' .. share)
|
||||
end
|
||||
end
|
||||
|
||||
rpg_extra.global_pool = rpg_extra.leftover_pool or 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event.element then
|
||||
return
|
||||
@@ -259,7 +158,7 @@ local function on_entity_died(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
Public.gain_xp(event.entity.last_user, 1)
|
||||
Functions.gain_xp(event.entity.last_user, 1)
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -302,10 +201,10 @@ local function on_entity_died(event)
|
||||
end
|
||||
|
||||
if rpg_extra.turret_kills_to_global_pool then
|
||||
add_to_global_pool(amount, false)
|
||||
Functions.add_to_global_pool(amount, false)
|
||||
end
|
||||
else
|
||||
add_to_global_pool(0.5, false)
|
||||
Functions.add_to_global_pool(0.5, false)
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -338,13 +237,13 @@ local function on_entity_died(event)
|
||||
if rpg_extra.rpg_xp_yield[event.entity.name] then
|
||||
local amount = rpg_extra.rpg_xp_yield[event.entity.name] * (1 / health_pool[2])
|
||||
if rpg_extra.turret_kills_to_global_pool then
|
||||
local inserted = add_to_global_pool(amount, true)
|
||||
Public.gain_xp(player, inserted, true)
|
||||
local inserted = Functions.add_to_global_pool(amount, true)
|
||||
Functions.gain_xp(player, inserted, true)
|
||||
else
|
||||
Public.gain_xp(player, amount)
|
||||
Functions.gain_xp(player, amount)
|
||||
end
|
||||
else
|
||||
Public.gain_xp(player, 0.5 * (1 / health_pool[2]))
|
||||
Functions.gain_xp(player, 0.5 * (1 / health_pool[2]))
|
||||
end
|
||||
end
|
||||
return
|
||||
@@ -357,13 +256,13 @@ local function on_entity_died(event)
|
||||
if rpg_extra.rpg_xp_yield[event.entity.name] then
|
||||
local amount = rpg_extra.rpg_xp_yield[event.entity.name]
|
||||
if rpg_extra.turret_kills_to_global_pool then
|
||||
local inserted = add_to_global_pool(amount, true)
|
||||
Public.gain_xp(player, inserted, true)
|
||||
local inserted = Functions.add_to_global_pool(amount, true)
|
||||
Functions.gain_xp(player, inserted, true)
|
||||
else
|
||||
Public.gain_xp(player, amount)
|
||||
Functions.gain_xp(player, amount)
|
||||
end
|
||||
else
|
||||
Public.gain_xp(player, 0.5)
|
||||
Functions.gain_xp(player, 0.5)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -460,7 +359,9 @@ local function give_player_flameboots(player)
|
||||
if player.gui.left[main_frame_name] then
|
||||
local f = player.gui.left[main_frame_name]
|
||||
local data = Gui.get_data(f)
|
||||
data.mana.caption = rpg_t[player.index].mana
|
||||
if data.mana and data.mana.valid then
|
||||
data.mana.caption = rpg_t[player.index].mana
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -673,7 +574,7 @@ local function on_player_repaired_entity(event)
|
||||
if not player.character then
|
||||
return
|
||||
end
|
||||
Public.gain_xp(player, 0.05)
|
||||
Functions.gain_xp(player, 0.05)
|
||||
|
||||
local repair_speed = Functions.get_magicka(player)
|
||||
if repair_speed <= 0 then
|
||||
@@ -692,7 +593,7 @@ local function on_player_rotated_entity(event)
|
||||
return
|
||||
end
|
||||
rpg_t[player.index].rotated_entity_delay = game.tick + 20
|
||||
Public.gain_xp(player, 0.20)
|
||||
Functions.gain_xp(player, 0.20)
|
||||
end
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
@@ -717,7 +618,7 @@ local function on_player_changed_position(event)
|
||||
if player.character.driving then
|
||||
return
|
||||
end
|
||||
Public.gain_xp(player, 1.0)
|
||||
Functions.gain_xp(player, 1.0)
|
||||
end
|
||||
|
||||
local building_and_mining_blacklist = {
|
||||
@@ -757,7 +658,15 @@ local function on_pre_player_mined_item(event)
|
||||
xp_amount = (1.5 + event.entity.prototype.max_health * 0.0035) * distance_multiplier
|
||||
end
|
||||
|
||||
Public.gain_xp(player, xp_amount)
|
||||
if player.gui.left[main_frame_name] then
|
||||
local f = player.gui.left[main_frame_name]
|
||||
local data = Gui.get_data(f)
|
||||
if data.exp_gui and data.exp_gui.valid then
|
||||
data.exp_gui.caption = math.floor(rpg_t[player.index].xp)
|
||||
end
|
||||
end
|
||||
|
||||
Functions.gain_xp(player, xp_amount)
|
||||
end
|
||||
|
||||
local function on_player_crafted_item(event)
|
||||
@@ -775,14 +684,14 @@ local function on_player_crafted_item(event)
|
||||
|
||||
local amount = 0.30 * math.random(1, 2)
|
||||
|
||||
Public.gain_xp(player, event.recipe.energy * amount)
|
||||
Functions.gain_xp(player, event.recipe.energy * amount)
|
||||
end
|
||||
|
||||
local function on_player_respawned(event)
|
||||
local player = game.players[event.player_index]
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
if not rpg_t[player.index] then
|
||||
Public.rpg_reset_player(player)
|
||||
Functions.rpg_reset_player(player)
|
||||
return
|
||||
end
|
||||
RPG_GUI.update_player_stats(player)
|
||||
@@ -796,9 +705,9 @@ local function on_player_joined_game(event)
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
if not rpg_t[player.index] then
|
||||
Public.rpg_reset_player(player)
|
||||
Functions.rpg_reset_player(player)
|
||||
if rpg_extra.reward_new_players > 10 then
|
||||
Public.gain_xp(player, rpg_extra.reward_new_players)
|
||||
Functions.gain_xp(player, rpg_extra.reward_new_players)
|
||||
end
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
@@ -925,6 +834,10 @@ local function on_player_used_capsule(event)
|
||||
return
|
||||
end
|
||||
|
||||
if not player.character or not player.character.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if string.sub(player.surface.name, 0, #surface_name) ~= surface_name then
|
||||
return
|
||||
end
|
||||
@@ -1018,6 +931,16 @@ local function on_player_used_capsule(event)
|
||||
end
|
||||
if object.obj_to_create == 'suicidal_comfylatron' then
|
||||
Functions.suicidal_comfylatron(position, surface)
|
||||
p('You wave your wand and ' .. object_name .. ' is on the run!', Color.success)
|
||||
elseif object.obj_to_create == 'warp-gate' then
|
||||
player.teleport(
|
||||
surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5),
|
||||
surface
|
||||
)
|
||||
rpg_t[player.index].mana = 0
|
||||
player.character.health = 10
|
||||
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
||||
p('Warped home with minor bruises.', Color.info)
|
||||
elseif projectile_types[obj_name] then
|
||||
for i = 1, object.amount do
|
||||
local damage_area = {
|
||||
@@ -1031,11 +954,14 @@ local function on_player_used_capsule(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
p('You wave your wand and ' .. object_name .. ' appears.', Color.success)
|
||||
else
|
||||
if object.target then
|
||||
surface.create_entity({name = obj_name, position = position, force = force, target = target_pos, speed = 1})
|
||||
p('You wave your wand and ' .. object_name .. ' appears.', Color.success)
|
||||
elseif object.obj_to_create == 'fish' then
|
||||
player.insert({name = 'raw-fish', count = object.amount})
|
||||
p('You wave your wand and ' .. object_name .. ' appears.', Color.success)
|
||||
elseif surface.can_place_entity {name = obj_name, position = position} then
|
||||
if object.biter then
|
||||
local e = surface.create_entity({name = obj_name, position = position, force = force})
|
||||
@@ -1043,18 +969,21 @@ local function on_player_used_capsule(event)
|
||||
else
|
||||
surface.create_entity({name = obj_name, position = position, force = force})
|
||||
end
|
||||
p('You wave your wand and ' .. object_name .. ' appears.', Color.success)
|
||||
else
|
||||
p('Can´t create entity at given location.', Color.fail)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local msg = player.name .. ' casted ' .. object.name .. '. '
|
||||
|
||||
rpg_t[player.index].last_spawned = game.tick + object.tick
|
||||
Functions.update_mana(player)
|
||||
|
||||
AntiGrief.insert_into_capsule_history(player, position)
|
||||
AntiGrief.insert_into_capsule_history(player, position, msg)
|
||||
|
||||
return p('You wave your wand and ' .. object_name .. ' appears.', Color.success)
|
||||
return
|
||||
end
|
||||
|
||||
local function tick()
|
||||
@@ -1065,7 +994,7 @@ local function tick()
|
||||
local enable_mana = RPG.get('rpg_extra').enable_mana
|
||||
|
||||
if ticker % nth_tick == 0 then
|
||||
global_pool(players, count)
|
||||
Functions.global_pool(players, count)
|
||||
end
|
||||
|
||||
if ticker % 30 == 0 then
|
||||
@@ -1079,201 +1008,6 @@ local function tick()
|
||||
end
|
||||
end
|
||||
|
||||
--- Gives connected player some bonus xp if the map was preemptively shut down.
|
||||
-- amount (integer) -- 10 levels
|
||||
-- local Public = require 'modules.rpg_v2' Public.give_xp(512)
|
||||
function Public.give_xp(amount)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if not Functions.validate_player(player) then
|
||||
return
|
||||
end
|
||||
Public.gain_xp(player, amount)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.rpg_reset_player(player, one_time_reset)
|
||||
if not player.character then
|
||||
player.set_controller({type = defines.controllers.god})
|
||||
player.create_character()
|
||||
end
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
if one_time_reset then
|
||||
local total = rpg_t[player.index].total
|
||||
if not total then
|
||||
total = 0
|
||||
end
|
||||
local old_level = rpg_t[player.index].level
|
||||
local old_points_to_distribute = rpg_t[player.index].points_to_distribute
|
||||
local old_xp = rpg_t[player.index].xp
|
||||
rpg_t[player.index] = {
|
||||
level = 1,
|
||||
xp = 0,
|
||||
strength = 10,
|
||||
magicka = 10,
|
||||
dexterity = 10,
|
||||
vitality = 10,
|
||||
mana = 0,
|
||||
mana_max = 0,
|
||||
last_spawned = 0,
|
||||
dropdown_select_index = 1,
|
||||
flame_boots = false,
|
||||
enable_entity_spawn = false,
|
||||
health_bar = rpg_t[player.index].health_bar,
|
||||
mana_bar = rpg_t[player.index].mana_bar,
|
||||
points_to_distribute = 0,
|
||||
last_floaty_text = visuals_delay,
|
||||
xp_since_last_floaty_text = 0,
|
||||
reset = true,
|
||||
capped = false,
|
||||
bonus = rpg_extra.breached_walls or 1,
|
||||
rotated_entity_delay = 0,
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = false,
|
||||
stone_path = false,
|
||||
one_punch = false
|
||||
}
|
||||
rpg_t[player.index].points_to_distribute = old_points_to_distribute + total
|
||||
rpg_t[player.index].xp = old_xp
|
||||
rpg_t[player.index].level = old_level
|
||||
else
|
||||
rpg_t[player.index] = {
|
||||
level = 1,
|
||||
xp = 0,
|
||||
strength = 10,
|
||||
magicka = 10,
|
||||
dexterity = 10,
|
||||
vitality = 10,
|
||||
mana = 0,
|
||||
mana_max = 0,
|
||||
last_spawned = 0,
|
||||
dropdown_select_index = 1,
|
||||
flame_boots = false,
|
||||
enable_entity_spawn = false,
|
||||
points_to_distribute = 0,
|
||||
last_floaty_text = visuals_delay,
|
||||
xp_since_last_floaty_text = 0,
|
||||
reset = false,
|
||||
capped = false,
|
||||
total = 0,
|
||||
bonus = 1,
|
||||
rotated_entity_delay = 0,
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = false,
|
||||
stone_path = false,
|
||||
one_punch = false
|
||||
}
|
||||
end
|
||||
RPG_GUI.draw_gui_char_button(player)
|
||||
RPG_GUI.draw_level_text(player)
|
||||
RPG_GUI.update_char_button(player)
|
||||
RPG_GUI.update_player_stats(player)
|
||||
end
|
||||
|
||||
function Public.rpg_reset_all_players()
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
for k, _ in pairs(rpg_t) do
|
||||
rpg_t[k] = nil
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
Public.rpg_reset_player(p)
|
||||
end
|
||||
rpg_extra.breached_walls = 1
|
||||
rpg_extra.reward_new_players = 0
|
||||
rpg_extra.global_pool = 0
|
||||
end
|
||||
|
||||
function Public.gain_xp(player, amount, added_to_pool, text)
|
||||
if not Functions.validate_player(player) then
|
||||
return
|
||||
end
|
||||
local rpg_extra = RPG.get('rpg_extra')
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
|
||||
if Functions.level_limit_exceeded(player) then
|
||||
add_to_global_pool(amount, false)
|
||||
if not rpg_t[player.index].capped then
|
||||
rpg_t[player.index].capped = true
|
||||
local message = teller_level_limit .. 'You have hit the max level for the current zone.'
|
||||
Alert.alert_player_warning(player, 10, message)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local text_to_draw
|
||||
|
||||
if rpg_t[player.index].capped then
|
||||
rpg_t[player.index].capped = false
|
||||
end
|
||||
|
||||
if not added_to_pool then
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
|
||||
local fee = amount - add_to_global_pool(amount, true)
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got fee: ' .. fee)
|
||||
amount = math.round(amount, 3) - fee
|
||||
if rpg_extra.difficulty then
|
||||
amount = amount + rpg_extra.difficulty
|
||||
end
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got after fee: ' .. amount)
|
||||
else
|
||||
RPG.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
|
||||
end
|
||||
|
||||
rpg_t[player.index].xp = rpg_t[player.index].xp + amount
|
||||
rpg_t[player.index].xp_since_last_floaty_text = rpg_t[player.index].xp_since_last_floaty_text + amount
|
||||
|
||||
if player.gui.left[main_frame_name] then
|
||||
local f = player.gui.left[main_frame_name]
|
||||
local data = Gui.get_data(f)
|
||||
Gui.set_data(f, data)
|
||||
end
|
||||
|
||||
if not experience_levels[rpg_t[player.index].level + 1] then
|
||||
return
|
||||
end
|
||||
|
||||
if rpg_t[player.index].xp >= experience_levels[rpg_t[player.index].level + 1] then
|
||||
level_up(player)
|
||||
end
|
||||
|
||||
if rpg_t[player.index].last_floaty_text > game.tick then
|
||||
if not text then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if text then
|
||||
text_to_draw = '+' .. math.floor(amount) .. ' xp'
|
||||
else
|
||||
text_to_draw = '+' .. math.floor(rpg_t[player.index].xp_since_last_floaty_text) .. ' xp'
|
||||
end
|
||||
|
||||
player.create_local_flying_text {
|
||||
text = text_to_draw,
|
||||
position = player.position,
|
||||
color = xp_floating_text_color,
|
||||
time_to_live = 340,
|
||||
speed = 2
|
||||
}
|
||||
|
||||
rpg_t[player.index].xp_since_last_floaty_text = 0
|
||||
rpg_t[player.index].last_floaty_text = game.tick + visuals_delay
|
||||
end
|
||||
|
||||
--- Distributes the global xp pool to every connected player.
|
||||
function Public.distribute_pool()
|
||||
local count = #game.connected_players
|
||||
local players = game.connected_players
|
||||
global_pool(players, count)
|
||||
print('Distributed the global XP pool')
|
||||
end
|
||||
|
||||
--- Pass along the main_button and main_frame
|
||||
Public.main_frame_name = main_frame_name
|
||||
Public.draw_main_frame_name = draw_main_frame_name
|
||||
Public.settings_frame_name = Settings.settings_frame_name
|
||||
|
||||
if _DEBUG then
|
||||
commands.add_command(
|
||||
'give_xp',
|
||||
@@ -1294,7 +1028,7 @@ if _DEBUG then
|
||||
return
|
||||
end
|
||||
p('Distributed ' .. param .. ' of xp.')
|
||||
Public.give_xp(param)
|
||||
Functions.give_xp(param)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1313,5 +1047,3 @@ Event.add(defines.events.on_player_rotated_entity, on_player_rotated_entity)
|
||||
Event.add(defines.events.on_pre_player_mined_item, on_pre_player_mined_item)
|
||||
Event.add(defines.events.on_player_used_capsule, on_player_used_capsule)
|
||||
Event.on_nth_tick(10, tick)
|
||||
|
||||
return Public
|
||||
|
@@ -39,21 +39,31 @@ function Public.extra_settings(player)
|
||||
}
|
||||
)
|
||||
main_frame.auto_center = true
|
||||
|
||||
local main_frame_style = main_frame.style
|
||||
main_frame_style.width = 500
|
||||
|
||||
local info_text =
|
||||
main_frame.add({type = 'label', caption = 'Common RPG settings. These settings are per player basis.'})
|
||||
local info_text_style = info_text.style
|
||||
info_text_style.single_line = false
|
||||
info_text_style.bottom_padding = 5
|
||||
info_text_style.left_padding = 5
|
||||
info_text_style.right_padding = 5
|
||||
info_text_style.top_padding = 5
|
||||
info_text_style.width = 370
|
||||
local inside_frame = main_frame.add {type = 'frame', style = 'inside_shallow_frame'}
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.padding = 0
|
||||
local inside_table = inside_frame.add {type = 'table', column_count = 1}
|
||||
local inside_table_style = inside_table.style
|
||||
inside_table_style.vertical_spacing = 0
|
||||
|
||||
local scroll_pane = main_frame.add({type = 'scroll-pane'})
|
||||
inside_table.add({type = 'line'})
|
||||
|
||||
local info_text =
|
||||
inside_table.add({type = 'label', caption = 'Common RPG settings. These settings are per player basis.'})
|
||||
local info_text_style = info_text.style
|
||||
info_text_style.font = 'default-bold'
|
||||
info_text_style.padding = 0
|
||||
info_text_style.left_padding = 10
|
||||
info_text_style.horizontal_align = 'left'
|
||||
info_text_style.vertical_align = 'bottom'
|
||||
info_text_style.font_color = {0.55, 0.55, 0.99}
|
||||
|
||||
inside_table.add({type = 'line'})
|
||||
|
||||
local scroll_pane = inside_table.add({type = 'scroll-pane'})
|
||||
local scroll_style = scroll_pane.style
|
||||
scroll_style.vertically_squashable = true
|
||||
scroll_style.maximal_height = 800
|
||||
@@ -317,9 +327,34 @@ function Public.extra_settings(player)
|
||||
flame_boots_gui_input.tooltip = 'Not enough mana.\nChecked = true\nUnchecked = false'
|
||||
end
|
||||
end
|
||||
|
||||
if rpg_extra.enable_mana then
|
||||
local mana_frame = inside_table.add({type = 'scroll-pane'})
|
||||
local mana_style = mana_frame.style
|
||||
mana_style.vertically_squashable = true
|
||||
mana_style.bottom_padding = 5
|
||||
mana_style.left_padding = 5
|
||||
mana_style.right_padding = 5
|
||||
mana_style.top_padding = 5
|
||||
|
||||
mana_frame.add({type = 'line'})
|
||||
|
||||
local label = mana_frame.add({type = 'label', caption = 'Mana Settings:'})
|
||||
label.style.font = 'default-bold'
|
||||
label.style.padding = 0
|
||||
label.style.left_padding = 10
|
||||
label.style.horizontal_align = 'left'
|
||||
label.style.vertical_align = 'bottom'
|
||||
label.style.font_color = {0.55, 0.55, 0.99}
|
||||
|
||||
mana_frame.add({type = 'line'})
|
||||
|
||||
local setting_grid_2 = mana_frame.add({type = 'table', column_count = 2})
|
||||
|
||||
local mana_grid = mana_frame.add({type = 'table', column_count = 2})
|
||||
|
||||
local enable_entity =
|
||||
setting_grid.add(
|
||||
setting_grid_2.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Enable spawning with raw-fish?',
|
||||
@@ -332,10 +367,11 @@ function Public.extra_settings(player)
|
||||
enable_entity_style.height = 35
|
||||
enable_entity_style.vertical_align = 'center'
|
||||
|
||||
local entity_input = setting_grid.add({type = 'flow'})
|
||||
local entity_input = setting_grid_2.add({type = 'flow'})
|
||||
local entity_input_style = entity_input.style
|
||||
entity_input_style.height = 35
|
||||
entity_input_style.vertical_align = 'center'
|
||||
entity_input_style.horizontal_align = 'right'
|
||||
local entity_mod
|
||||
if rpg_t[player.index].enable_entity_spawn then
|
||||
entity_mod = rpg_t[player.index].enable_entity_spawn
|
||||
@@ -345,7 +381,7 @@ function Public.extra_settings(player)
|
||||
enable_entity_gui_input = create_input_element(entity_input, 'boolean', entity_mod)
|
||||
|
||||
local conjure_label =
|
||||
setting_grid.add(
|
||||
mana_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'Select what entity to spawn',
|
||||
@@ -364,7 +400,7 @@ function Public.extra_settings(player)
|
||||
conjure_label_style.height = 35
|
||||
conjure_label_style.vertical_align = 'center'
|
||||
|
||||
local conjure_input = setting_grid.add({type = 'flow'})
|
||||
local conjure_input = mana_grid.add({type = 'flow'})
|
||||
local conjure_input_style = conjure_input.style
|
||||
conjure_input_style.height = 35
|
||||
conjure_input_style.vertical_align = 'center'
|
||||
|
@@ -7,7 +7,7 @@ Public.conjure_items = {
|
||||
level = 10,
|
||||
type = 'item',
|
||||
mana_cost = 35,
|
||||
tick = 160,
|
||||
tick = 100,
|
||||
enabled = true
|
||||
},
|
||||
[2] = {
|
||||
@@ -16,7 +16,7 @@ Public.conjure_items = {
|
||||
level = 2,
|
||||
type = 'item',
|
||||
mana_cost = 30,
|
||||
tick = 160,
|
||||
tick = 100,
|
||||
enabled = true
|
||||
},
|
||||
[3] = {
|
||||
@@ -25,7 +25,7 @@ Public.conjure_items = {
|
||||
level = 10,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 260,
|
||||
tick = 200,
|
||||
enabled = true
|
||||
},
|
||||
[4] = {
|
||||
@@ -34,7 +34,7 @@ Public.conjure_items = {
|
||||
level = 15,
|
||||
type = 'item',
|
||||
mana_cost = 50,
|
||||
tick = 360,
|
||||
tick = 300,
|
||||
enabled = true
|
||||
},
|
||||
[5] = {
|
||||
@@ -43,7 +43,7 @@ Public.conjure_items = {
|
||||
level = 3,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 160,
|
||||
tick = 100,
|
||||
enabled = true
|
||||
},
|
||||
[6] = {
|
||||
@@ -52,7 +52,7 @@ Public.conjure_items = {
|
||||
level = 20,
|
||||
type = 'item',
|
||||
mana_cost = 50,
|
||||
tick = 260,
|
||||
tick = 200,
|
||||
enabled = true
|
||||
},
|
||||
[7] = {
|
||||
@@ -61,7 +61,7 @@ Public.conjure_items = {
|
||||
level = 60,
|
||||
type = 'item',
|
||||
mana_cost = 60,
|
||||
tick = 360,
|
||||
tick = 300,
|
||||
enabled = true
|
||||
},
|
||||
[8] = {
|
||||
@@ -70,7 +70,7 @@ Public.conjure_items = {
|
||||
level = 3,
|
||||
type = 'item',
|
||||
mana_cost = 40,
|
||||
tick = 160,
|
||||
tick = 100,
|
||||
enabled = true
|
||||
},
|
||||
[9] = {
|
||||
@@ -79,7 +79,7 @@ Public.conjure_items = {
|
||||
level = 20,
|
||||
type = 'item',
|
||||
mana_cost = 50,
|
||||
tick = 260,
|
||||
tick = 200,
|
||||
enabled = true
|
||||
},
|
||||
[10] = {
|
||||
@@ -88,7 +88,7 @@ Public.conjure_items = {
|
||||
level = 60,
|
||||
type = 'item',
|
||||
mana_cost = 60,
|
||||
tick = 360,
|
||||
tick = 300,
|
||||
enabled = true
|
||||
},
|
||||
[11] = {
|
||||
@@ -97,7 +97,7 @@ Public.conjure_items = {
|
||||
level = 80,
|
||||
type = 'entity',
|
||||
mana_cost = 80,
|
||||
tick = 420,
|
||||
tick = 350,
|
||||
enabled = true
|
||||
},
|
||||
[12] = {
|
||||
@@ -210,11 +210,11 @@ Public.conjure_items = {
|
||||
level = 70,
|
||||
type = 'special',
|
||||
mana_cost = 90,
|
||||
tick = 200,
|
||||
tick = 100,
|
||||
enabled = true
|
||||
},
|
||||
[22] = {
|
||||
name = 'Fire my lazors!!',
|
||||
name = 'Shoop Da Whoop!!',
|
||||
obj_to_create = 'railgun-beam',
|
||||
target = false,
|
||||
amount = 3,
|
||||
@@ -224,7 +224,7 @@ Public.conjure_items = {
|
||||
level = 50,
|
||||
type = 'special',
|
||||
mana_cost = 66,
|
||||
tick = 320,
|
||||
tick = 200,
|
||||
enabled = true
|
||||
},
|
||||
[23] = {
|
||||
@@ -263,11 +263,22 @@ Public.conjure_items = {
|
||||
damage = false,
|
||||
range = 30,
|
||||
force = 'player',
|
||||
level = 60,
|
||||
level = 50,
|
||||
type = 'special',
|
||||
mana_cost = 200,
|
||||
tick = 320,
|
||||
enabled = true
|
||||
},
|
||||
[26] = {
|
||||
name = 'Warp Gate',
|
||||
obj_to_create = 'warp-gate',
|
||||
target = true,
|
||||
force = 'player',
|
||||
level = 60,
|
||||
type = 'special',
|
||||
mana_cost = 300,
|
||||
tick = 2000,
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user