You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-11-23 22:22:34 +02:00
Mtn: add rewards when completing goals and adjust mystical chest
This commit is contained in:
@@ -744,7 +744,7 @@ local mc_random_rewards =
|
||||
name = 'Movement bonus',
|
||||
str = 'movement',
|
||||
color = { r = 0.00, g = 0.25, b = 0.00 },
|
||||
tooltip = 'Selecting this will grant the team a bonus movement speed for 15 minutes!',
|
||||
tooltip = 'Selecting this will grant the team a bonus movement speed for 30 minutes!',
|
||||
func = (function (player, zone)
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
@@ -757,7 +757,7 @@ local mc_random_rewards =
|
||||
|
||||
mc_rewards.temp_boosts.movement = true
|
||||
|
||||
Task.set_timeout_in_ticks(54000, restore_movement_speed_token, { speed = force.character_running_speed_modifier })
|
||||
Task.set_timeout_in_ticks(108000, restore_movement_speed_token, { speed = force.character_running_speed_modifier })
|
||||
local scale_factor = 0.5 + (zone / 10)
|
||||
local speed = 0.6 * scale_factor
|
||||
if speed > 1 then
|
||||
@@ -775,7 +775,7 @@ local mc_random_rewards =
|
||||
name = 'Mining bonus',
|
||||
str = 'mining',
|
||||
color = { r = 0.00, g = 0.00, b = 0.25 },
|
||||
tooltip = 'Selecting this will grant the team a bonus mining speed for 15 minutes!',
|
||||
tooltip = 'Selecting this will grant the team a bonus mining speed for 30 minutes!',
|
||||
func = (function (player)
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
@@ -788,7 +788,7 @@ local mc_random_rewards =
|
||||
|
||||
mc_rewards.temp_boosts.mining = true
|
||||
|
||||
Task.set_timeout_in_ticks(54000, restore_mining_speed_token)
|
||||
Task.set_timeout_in_ticks(108000, restore_mining_speed_token)
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 1
|
||||
local message = ({ 'locomotive.mining_bonus', player.name })
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
@@ -801,7 +801,7 @@ local mc_random_rewards =
|
||||
name = 'Crafting speed bonus',
|
||||
str = 'crafting',
|
||||
color = { r = 0.00, g = 0.00, b = 0.25 },
|
||||
tooltip = 'Selecting this will grant all players 100% crafting bonus for 15 minutes!',
|
||||
tooltip = 'Selecting this will grant all players 100% crafting bonus for 30 minutes!',
|
||||
func = (function (player)
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
@@ -814,7 +814,7 @@ local mc_random_rewards =
|
||||
|
||||
mc_rewards.temp_boosts.crafting = true
|
||||
|
||||
Task.set_timeout_in_ticks(54000, restore_crafting_speed_token)
|
||||
Task.set_timeout_in_ticks(108000, restore_crafting_speed_token)
|
||||
force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier + 2
|
||||
local message = ({ 'locomotive.crafting_bonus', player.name })
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
|
||||
@@ -5,6 +5,8 @@ local Stateful = require 'maps.mountain_fortress_v3.stateful.table'
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local Core = require 'utils.core'
|
||||
local StatData = require 'utils.datastore.statistics'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
|
||||
|
||||
local math = math
|
||||
@@ -251,6 +253,42 @@ function Public.init_buff_selection(buffs)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.reward_goal_completion()
|
||||
local adjusted_zones = Public.get('adjusted_zones')
|
||||
local locomotive = Public.get('locomotive')
|
||||
if not locomotive then
|
||||
return
|
||||
end
|
||||
if not locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local zone = math.floor((math.abs(locomotive.position.y / Public.zone_settings.zone_depth)) % adjusted_zones.size) + 1
|
||||
|
||||
if math.random(1, 2) == 1 then
|
||||
local players = game.connected_players
|
||||
for i = 1, #players do
|
||||
local rng = math.random(2048, 8192)
|
||||
local scale_factor = 0.8 + (zone / 20)
|
||||
rng = math.floor(rng * scale_factor)
|
||||
local player = players[i]
|
||||
if player and player.valid then
|
||||
if player.can_insert({ name = 'coin', count = rng }) then
|
||||
player.insert({ name = 'coin', count = rng })
|
||||
StatData.get_data(player):increase('coins', rng)
|
||||
end
|
||||
end
|
||||
end
|
||||
return 'Coins have been granted to the whole team'
|
||||
else
|
||||
local rng = math.random(8192, 16384)
|
||||
local scale_factor = 0.8 + (zone / 20)
|
||||
rng = math.floor(rng * scale_factor)
|
||||
RPG.add_to_global_pool(rng)
|
||||
return 'XP has been granted to the global pool'
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set_multi_command_final_battle()
|
||||
local active_surface_index = Public.get('active_surface_index')
|
||||
if not active_surface_index then return end
|
||||
|
||||
@@ -1120,8 +1120,9 @@ local function update_raw()
|
||||
stateful.objectives_completed.randomized_zone = true
|
||||
stateful.objectives_time_spent.randomized_zone = tick
|
||||
play_achievement_unlocked()
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Breach zone[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **Breach zone** has been completed!')
|
||||
local reward = Public.reward_goal_completion()
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Breach zone[/color] has been completed! ' .. reward .. '!')
|
||||
Server.to_discord_embed('Objective: **Breach zone** has been completed! ' .. reward .. '!')
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
end
|
||||
@@ -1145,8 +1146,9 @@ local function update_raw()
|
||||
if not stateful.objectives_completed.supplies then
|
||||
stateful.objectives_completed.supplies = true
|
||||
stateful.objectives_time_spent.supplies = tick
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Produce items[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **Produce items** has been completed!')
|
||||
local reward = Public.reward_goal_completion()
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Produce items[/color] has been completed! ' .. reward .. '!')
|
||||
Server.to_discord_embed('Objective: **Produce items** has been completed! ' .. reward .. '!')
|
||||
play_achievement_unlocked()
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
@@ -1173,8 +1175,9 @@ local function update_raw()
|
||||
stateful.objectives_completed.single_item = true
|
||||
stateful.objectives_time_spent.single_item = tick
|
||||
play_achievement_unlocked()
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Produce item[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **Produce item** has been completed!')
|
||||
local reward = Public.reward_goal_completion()
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Produce item[/color] has been completed! ' .. reward .. '!')
|
||||
Server.to_discord_embed('Objective: **Produce item** has been completed! ' .. reward .. '!')
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
end
|
||||
@@ -1317,8 +1320,9 @@ local function update_raw()
|
||||
if completed and completed == true and not stateful.objectives_completed[objective_name] then
|
||||
stateful.objectives_completed[objective_name] = true
|
||||
stateful.objectives_time_spent[objective_name] = tick
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]' .. objective.discord .. '[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **' .. objective.discord .. '** has been completed!')
|
||||
local reward = Public.reward_goal_completion()
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]' .. objective.discord .. '[/color] has been completed! ' .. reward .. '!')
|
||||
Server.to_discord_embed('Objective: **' .. objective.discord .. '** has been completed! ' .. reward .. '!')
|
||||
play_achievement_unlocked()
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
|
||||
@@ -645,7 +645,7 @@ spells[#spells + 1] =
|
||||
}
|
||||
spells[#spells + 1] =
|
||||
{
|
||||
name = { 'entity-name.big-sand-rock' },
|
||||
name = { 'entity-name.big-rock' },
|
||||
entityName = 'big-sand-rock',
|
||||
raffle = rock_raffle,
|
||||
level = 60,
|
||||
|
||||
Reference in New Issue
Block a user