You've already forked ComfyFactorio
							
							
				mirror of
				https://github.com/ComfyFactory/ComfyFactorio.git
				synced 2025-10-30 23:47:41 +02:00 
			
		
		
		
	Mtn v3 - changes to rpg and misc states
This commit is contained in:
		| @@ -33,9 +33,9 @@ next_level_name=NEXT LEVEL | ||||
| strength_name=STRENGTH | ||||
| strength_tooltip=Increases inventory slots, mining speed.\nIncreases melee damage and amount of robot followers.\nIncreases range damage. | ||||
| magic_name=MAGIC | ||||
| magic_tooltip=Increases reach distance.\nIncreases repair speed. Enables spawning entities. | ||||
| magic_tooltip=Increases reach distance.\nIncreases repair speed.\nEnables spawning entities. | ||||
| dexterity_name=DEXTERITY | ||||
| dexterity_tooltip=Increases running and crafting speed. | ||||
| dexterity_tooltip=Increases running and crafting speed.\nHas a chance to grant a temporary speed buff when crafting items.\nHas a chance to dupe items that gets handcrafted. | ||||
| vitality_name=VITALITY | ||||
| vitality_tooltip=Increases health.\nIncreases melee life on-hit.\nIncreases healing power by using fish. | ||||
| points_to_dist=POINTS LEFT | ||||
|   | ||||
| @@ -404,7 +404,7 @@ function Public.on_mothership_chunk_generated(event) | ||||
| 		for y = 0, 31, 1 do | ||||
| 			local position = {x = left_top.x + x, y = left_top.y + y} | ||||
| 			if is_mothership(position) then | ||||
| 				table.insert(tiles, {name = 'black-refined-concrete', position = position}) | ||||
| 				table.insert(tiles, {name = 'stone-path', position = position}) | ||||
| 			else | ||||
| 				table.insert(tiles, {name = 'out-of-map', position = position}) | ||||
| 			end | ||||
|   | ||||
| @@ -20,6 +20,7 @@ local BottomFrame = require 'utils.gui.bottom_frame' | ||||
| local Modifiers = require 'utils.player_modifiers' | ||||
|  | ||||
| local zone_settings = Public.zone_settings | ||||
| local remove_boost_movement_speed_on_respawn | ||||
| local de = defines.events | ||||
|  | ||||
| local this = { | ||||
| @@ -779,56 +780,21 @@ local function calc_players() | ||||
|     return total | ||||
| end | ||||
|  | ||||
| local retry_final_boost_movement_speed_on_respawn = | ||||
| remove_boost_movement_speed_on_respawn = | ||||
|     Token.register( | ||||
|     function(data) | ||||
|         local player = data.player | ||||
|         local old_speed = data.old_speed | ||||
|         if not player or not player.valid then | ||||
|             return | ||||
|         end | ||||
|         if not player.character or not player.character.valid then | ||||
|             Task.set_timeout_in_ticks(10, remove_boost_movement_speed_on_respawn, {player = player}) | ||||
|             return | ||||
|         end | ||||
|         player.character.character_running_speed_modifier = old_speed | ||||
|         player.print('Movement speed bonus removed!', Color.info) | ||||
|         local rpg_t = RPG.get_value_from_player(player.index) | ||||
|         rpg_t.has_custom_spell_active = nil | ||||
|     end | ||||
| ) | ||||
|  | ||||
| local retry_boost_movement_speed_on_respawn = | ||||
|     Token.register( | ||||
|     function(data) | ||||
|         local player = data.player | ||||
|         local old_speed = data.old_speed | ||||
|         if not player or not player.valid then | ||||
|             return | ||||
|         end | ||||
|         if not player.character or not player.character.valid then | ||||
|             Task.set_timeout_in_ticks(10, retry_final_boost_movement_speed_on_respawn, {player = player, old_speed = old_speed}) | ||||
|             return | ||||
|         end | ||||
|         player.character.character_running_speed_modifier = old_speed | ||||
|         player.print('Movement speed bonus removed!', Color.info) | ||||
|         local rpg_t = RPG.get_value_from_player(player.index) | ||||
|         rpg_t.has_custom_spell_active = nil | ||||
|     end | ||||
| ) | ||||
|         Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'v3_move_boost') | ||||
|         Modifiers.update_player_modifiers(player) | ||||
|  | ||||
| local remove_boost_movement_speed_on_respawn = | ||||
|     Token.register( | ||||
|     function(data) | ||||
|         local player = data.player | ||||
|         local old_speed = data.old_speed | ||||
|         if not player or not player.valid then | ||||
|             return | ||||
|         end | ||||
|         if not player.character or not player.character.valid then | ||||
|             Task.set_timeout_in_ticks(10, retry_boost_movement_speed_on_respawn, {player = player, old_speed = old_speed}) | ||||
|             return | ||||
|         end | ||||
|         player.character.character_running_speed_modifier = old_speed | ||||
|         player.print('Movement speed bonus removed!', Color.info) | ||||
|         local rpg_t = RPG.get_value_from_player(player.index) | ||||
|         rpg_t.has_custom_spell_active = nil | ||||
| @@ -849,11 +815,10 @@ local boost_movement_speed_on_respawn = | ||||
|         local rpg_t = RPG.get_value_from_player(player.index) | ||||
|         rpg_t.has_custom_spell_active = true | ||||
|  | ||||
|         local old_speed = player.character_running_speed_modifier | ||||
|         local new_speed = player.character_running_speed_modifier + 1 | ||||
|         Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'v3_move_boost', 1) | ||||
|         Modifiers.update_player_modifiers(player) | ||||
|  | ||||
|         Task.set_timeout_in_ticks(800, remove_boost_movement_speed_on_respawn, {player = player, old_speed = old_speed}) | ||||
|         player.character.character_running_speed_modifier = new_speed | ||||
|         Task.set_timeout_in_ticks(800, remove_boost_movement_speed_on_respawn, {player = player}) | ||||
|         player.print('Movement speed bonus applied! Be quick and fetch your corpse!', Color.info) | ||||
|     end | ||||
| ) | ||||
|   | ||||
| @@ -5,6 +5,7 @@ local Token = require 'utils.token' | ||||
| local MapFunctions = require 'tools.map_functions' | ||||
|  | ||||
| local random = math.random | ||||
| local floor = math.floor | ||||
|  | ||||
| local function initial_cargo_boxes() | ||||
|     return { | ||||
| @@ -80,14 +81,13 @@ local place_tiles_token = | ||||
|             return | ||||
|         end | ||||
|  | ||||
|         MapFunctions.draw_noise_tile_circle(position, 'hazard-concrete-right', surface, 12) | ||||
|         MapFunctions.draw_noise_tile_circle(position, 'black-refined-concrete', surface, 12) | ||||
|     end | ||||
| ) | ||||
|  | ||||
| local set_loco_tiles = | ||||
| local set_loco_cargo = | ||||
|     Token.register( | ||||
|     function(data) | ||||
|         local position = data.position | ||||
|         local surface = data.surface | ||||
|         if not surface or not surface.valid then | ||||
|             return | ||||
| @@ -97,24 +97,18 @@ local set_loco_tiles = | ||||
|  | ||||
|         local p = {} | ||||
|  | ||||
|         ---@diagnostic disable-next-line: count-down-loop | ||||
|         for x = position.x - 5, 1, 3 do | ||||
|             if x == -1 then | ||||
|                 x = x - 1 | ||||
|             end | ||||
|             if x == 0 then | ||||
|                 x = x + 1 | ||||
|             end | ||||
|             for y = 1, position.y + 5, 2 do | ||||
|                 if random(1, 3) == 1 then | ||||
|                     p[#p + 1] = {x = x, y = y} | ||||
|         local rad = 16 ^ 2 | ||||
|         for x = -15, 15, 1 do | ||||
|             for y = 0, 67, 1 do | ||||
|                 local va = floor((0 - x) ^ 2 + (53 - y) ^ 2) | ||||
|                 if ((va < rad - 50) and (va > rad - 100)) then | ||||
|                     if random(1, 3) == 1 then | ||||
|                         p[#p + 1] = {x = x, y = y} | ||||
|                     end | ||||
|                 end | ||||
|             end | ||||
|         end | ||||
|  | ||||
|         MapFunctions.draw_noise_tile_circle(position, 'hazard-concrete-right', surface, 12) | ||||
|         Task.set_timeout_in_ticks(300, place_tiles_token, {surface = surface, position = position}) | ||||
|  | ||||
|         for i = 1, #cargo_boxes, 1 do | ||||
|             if not p[i] then | ||||
|                 break | ||||
| @@ -183,13 +177,6 @@ function Public.locomotive_spawn(surface, position) | ||||
|         ) | ||||
|     end | ||||
|  | ||||
|     local data = { | ||||
|         surface = surface, | ||||
|         position = position | ||||
|     } | ||||
|  | ||||
|     Task.set_timeout_in_ticks(50, set_loco_tiles, data) | ||||
|  | ||||
|     for y = -1, 0, 0.05 do | ||||
|         local scale = random(50, 100) * 0.01 | ||||
|         rendering.draw_sprite( | ||||
| @@ -218,9 +205,16 @@ function Public.locomotive_spawn(surface, position) | ||||
|     end | ||||
|  | ||||
|     ICW.register_wagon(this.locomotive_cargo) | ||||
|  | ||||
|     this.icw_locomotive = locomotive | ||||
|  | ||||
|     local data = { | ||||
|         surface = locomotive.surface | ||||
|     } | ||||
|  | ||||
|     Task.set_timeout_in_ticks(15, place_tiles_token, {surface = surface, position = position}) | ||||
|     Task.set_timeout_in_ticks(300, place_tiles_token, {surface = surface, position = position}) | ||||
|     Task.set_timeout_in_ticks(50, set_loco_cargo, data) | ||||
|  | ||||
|     game.forces.player.set_spawn_position({0, 19}, locomotive.surface) | ||||
| end | ||||
|  | ||||
|   | ||||
| @@ -67,7 +67,10 @@ local spread_particles_token = | ||||
|     end | ||||
| ) | ||||
|  | ||||
| local function notify_won_to_discord() | ||||
| local function notify_won_to_discord(buff) | ||||
|     if not buff then | ||||
|         return error('Buff is required when sending message to discord.', 2) | ||||
|     end | ||||
|     local server_name_matches = Server.check_server_name('Mtn Fortress') | ||||
|  | ||||
|     local stateful = Public.get_stateful() | ||||
| @@ -116,6 +119,11 @@ local function notify_won_to_discord() | ||||
|             text1 = 'Connected players:', | ||||
|             text2 = total_connected_players, | ||||
|             inline = 'false' | ||||
|         }, | ||||
|         field7 = { | ||||
|             text1 = 'Buff granted:', | ||||
|             text2 = buff.name, | ||||
|             inline = 'false' | ||||
|         } | ||||
|     } | ||||
|     if server_name_matches then | ||||
| @@ -918,8 +926,8 @@ local function update_raw() | ||||
|                 play_game_won() | ||||
|                 Server.to_discord_embed('Game won!') | ||||
|                 stateful.rounds_survived = stateful.rounds_survived + 1 | ||||
|                 Stateful.save_settings() | ||||
|                 notify_won_to_discord() | ||||
|                 local buff = Stateful.save_settings() | ||||
|                 notify_won_to_discord(buff) | ||||
|                 local locomotive = Public.get('locomotive') | ||||
|                 if locomotive and locomotive.valid then | ||||
|                     locomotive.surface.spill_item_stack(locomotive.position, {name = 'coin', count = 512}, false) | ||||
| @@ -967,8 +975,8 @@ local function update_raw() | ||||
|             WD.nuke_wave_gui() | ||||
|             Server.to_discord_embed('Game won!') | ||||
|             stateful.rounds_survived = stateful.rounds_survived + 1 | ||||
|             Stateful.save_settings() | ||||
|             notify_won_to_discord() | ||||
|             local buff = Stateful.save_settings() | ||||
|             notify_won_to_discord(buff) | ||||
|             local locomotive = Public.get('locomotive') | ||||
|             if locomotive and locomotive.valid then | ||||
|                 locomotive.surface.spill_item_stack(locomotive.position, {name = 'coin', count = 512}, false) | ||||
|   | ||||
| @@ -722,7 +722,8 @@ local apply_settings_token = | ||||
| ) | ||||
|  | ||||
| function Public.save_settings() | ||||
|     this.buffs[#this.buffs + 1] = get_random_buff() | ||||
|     local granted_buff = get_random_buff() | ||||
|     this.buffs[#this.buffs + 1] = granted_buff | ||||
|  | ||||
|     local settings = { | ||||
|         rounds_survived = this.rounds_survived, | ||||
| @@ -737,6 +738,8 @@ function Public.save_settings() | ||||
|     else | ||||
|         Server.set_data(dataset, dataset_key_dev, settings) | ||||
|     end | ||||
|  | ||||
|     return granted_buff | ||||
| end | ||||
|  | ||||
| function Public.reset_stateful(refresh_gui, clear_buffs) | ||||
|   | ||||
| @@ -3,7 +3,7 @@ local Task = require 'utils.task' | ||||
| local Gui = require 'utils.gui' | ||||
| local Color = require 'utils.color_presets' | ||||
| local BiterHealthBooster = require 'modules.biter_health_booster_v2' | ||||
| local P = require 'utils.player_modifiers' | ||||
| local Modifiers = require 'utils.player_modifiers' | ||||
| local Token = require 'utils.token' | ||||
| local Alert = require 'utils.alert' | ||||
| local Math2D = require 'math2d' | ||||
| @@ -43,6 +43,19 @@ local travelings = { | ||||
|     'comfylatron coming through' | ||||
| } | ||||
|  | ||||
| local restore_crafting_boost_token = | ||||
|     Token.register( | ||||
|     function(event) | ||||
|         local player_index = event.player_index | ||||
|         local player = game.get_player(player_index) | ||||
|         if not player or not player.valid then | ||||
|             return | ||||
|         end | ||||
|  | ||||
|         Public.restore_crafting_boost(player) | ||||
|     end | ||||
| ) | ||||
|  | ||||
| local desync = | ||||
|     Token.register( | ||||
|     function(data) | ||||
| @@ -281,9 +294,9 @@ local repair_buildings = | ||||
|         local entity = data.entity | ||||
|         if entity and entity.valid then | ||||
|             local rng = 0.1 | ||||
|             if math.random(1, 5) == 1 then | ||||
|             if random(1, 5) == 1 then | ||||
|                 rng = 0.2 | ||||
|             elseif math.random(1, 8) == 1 then | ||||
|             elseif random(1, 8) == 1 then | ||||
|                 rng = 0.4 | ||||
|             end | ||||
|             local to_heal = entity.prototype.max_health * rng | ||||
| @@ -308,9 +321,9 @@ function Public.repair_aoe(player, position) | ||||
| end | ||||
|  | ||||
| function Public.suicidal_comfylatron(pos, surface) | ||||
|     local str = travelings[math.random(1, #travelings)] | ||||
|     local str = travelings[random(1, #travelings)] | ||||
|     local symbols = {'', '!', '!', '!!', '..'} | ||||
|     str = str .. symbols[math.random(1, #symbols)] | ||||
|     str = str .. symbols[random(1, #symbols)] | ||||
|     local text = str | ||||
|     local e = | ||||
|         surface.create_entity( | ||||
| @@ -765,18 +778,18 @@ function Public.update_player_stats(player) | ||||
|     local rpg_extra = Public.get('rpg_extra') | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     local strength = rpg_t.strength - 10 | ||||
|     P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', round(strength * 0.2, 3)) | ||||
|     P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', round(strength * 0.006, 3)) | ||||
|     P.update_single_modifier(player, 'character_maximum_following_robot_count_bonus', 'rpg', round(strength / 2 * 0.03, 3)) | ||||
|     Modifiers.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', round(strength * 0.2, 3)) | ||||
|     Modifiers.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', round(strength * 0.006, 3)) | ||||
|     Modifiers.update_single_modifier(player, 'character_maximum_following_robot_count_bonus', 'rpg', round(strength / 2 * 0.03, 3)) | ||||
|  | ||||
|     local magic = rpg_t.magicka - 10 | ||||
|     local v = magic * 0.22 | ||||
|     P.update_single_modifier(player, 'character_build_distance_bonus', 'rpg', math.min(60, round(v * 0.12, 3))) | ||||
|     P.update_single_modifier(player, 'character_item_drop_distance_bonus', 'rpg', math.min(60, round(v * 0.05, 3))) | ||||
|     P.update_single_modifier(player, 'character_reach_distance_bonus', 'rpg', math.min(60, round(v * 0.12, 3))) | ||||
|     P.update_single_modifier(player, 'character_loot_pickup_distance_bonus', 'rpg', math.min(20, round(v * 0.12, 3))) | ||||
|     P.update_single_modifier(player, 'character_item_pickup_distance_bonus', 'rpg', math.min(20, round(v * 0.12, 3))) | ||||
|     P.update_single_modifier(player, 'character_resource_reach_distance_bonus', 'rpg', math.min(20, round(v * 0.05, 3))) | ||||
|     Modifiers.update_single_modifier(player, 'character_build_distance_bonus', 'rpg', math.min(60, round(v * 0.12, 3))) | ||||
|     Modifiers.update_single_modifier(player, 'character_item_drop_distance_bonus', 'rpg', math.min(60, round(v * 0.05, 3))) | ||||
|     Modifiers.update_single_modifier(player, 'character_reach_distance_bonus', 'rpg', math.min(60, round(v * 0.12, 3))) | ||||
|     Modifiers.update_single_modifier(player, 'character_loot_pickup_distance_bonus', 'rpg', math.min(20, round(v * 0.12, 3))) | ||||
|     Modifiers.update_single_modifier(player, 'character_item_pickup_distance_bonus', 'rpg', math.min(20, round(v * 0.12, 3))) | ||||
|     Modifiers.update_single_modifier(player, 'character_resource_reach_distance_bonus', 'rpg', math.min(20, round(v * 0.05, 3))) | ||||
|     if rpg_t.mana_max >= rpg_extra.mana_limit then | ||||
|         rpg_t.mana_max = rpg_extra.mana_limit | ||||
|     else | ||||
| @@ -784,10 +797,10 @@ function Public.update_player_stats(player) | ||||
|     end | ||||
|  | ||||
|     local dexterity = rpg_t.dexterity - 10 | ||||
|     P.update_single_modifier(player, 'character_running_speed_modifier', 'rpg', round(dexterity * 0.0010, 3)) -- reduced since too high speed kills UPS. | ||||
|     P.update_single_modifier(player, 'character_crafting_speed_modifier', 'rpg', round(dexterity * 0.015, 3)) | ||||
|     P.update_single_modifier(player, 'character_health_bonus', 'rpg', round((rpg_t.vitality - 10) * 6, 3)) | ||||
|     P.update_player_modifiers(player) | ||||
|     Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'rpg', round(dexterity * 0.0010, 3)) -- reduced since too high speed kills UPS. | ||||
|     Modifiers.update_single_modifier(player, 'character_crafting_speed_modifier', 'rpg', round(dexterity * 0.015, 3)) | ||||
|     Modifiers.update_single_modifier(player, 'character_health_bonus', 'rpg', round((rpg_t.vitality - 10) * 6, 3)) | ||||
|     Modifiers.update_player_modifiers(player) | ||||
| end | ||||
|  | ||||
| function Public.level_up_effects(player) | ||||
| @@ -796,10 +809,10 @@ function Public.level_up_effects(player) | ||||
|     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) | ||||
|             (position.x + 0.4) + (b * -1 + random(0, b * 20) * 0.1), | ||||
|             position.y + (b * -1 + random(0, b * 20) * 0.1) | ||||
|         } | ||||
|         player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}}) | ||||
|         player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, random(0, 100), 0}}) | ||||
|     end | ||||
|     player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.50} | ||||
| end | ||||
| @@ -810,19 +823,19 @@ function Public.cast_spell(player, failed) | ||||
|     if not failed then | ||||
|         for _ = 1, 3, 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) | ||||
|                 (position.x + 0.4) + (b * -1 + random(0, b * 20) * 0.1), | ||||
|                 position.y + (b * -1 + random(0, b * 20) * 0.1) | ||||
|             } | ||||
|             player.surface.create_entity({name = 'flying-text', position = p, text = '✔️', color = {255, math.random(0, 100), 0}}) | ||||
|             player.surface.create_entity({name = 'flying-text', position = p, text = '✔️', color = {255, random(0, 100), 0}}) | ||||
|         end | ||||
|         player.play_sound {path = 'utility/scenario_message', volume_modifier = 1} | ||||
|     else | ||||
|         for _ = 1, 3, 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) | ||||
|                 (position.x + 0.4) + (b * -1 + random(0, b * 20) * 0.1), | ||||
|                 position.y + (b * -1 + random(0, b * 20) * 0.1) | ||||
|             } | ||||
|             player.surface.create_entity({name = 'flying-text', position = p, text = '✖', color = {255, math.random(0, 100), 0}}) | ||||
|             player.surface.create_entity({name = 'flying-text', position = p, text = '✖', color = {255, random(0, 100), 0}}) | ||||
|         end | ||||
|         player.play_sound {path = 'utility/cannot_build', volume_modifier = 1} | ||||
|     end | ||||
| @@ -834,14 +847,61 @@ function Public.xp_effects(player) | ||||
|     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) | ||||
|             (position.x + 0.4) + (b * -1 + random(0, b * 20) * 0.1), | ||||
|             position.y + (b * -1 + random(0, b * 20) * 0.1) | ||||
|         } | ||||
|         player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}}) | ||||
|         player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, random(0, 100), 0}}) | ||||
|     end | ||||
|     player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.50} | ||||
| end | ||||
|  | ||||
| function Public.boost_effects(player) | ||||
|     local position = {x = player.position.x - 0.75, y = player.position.y - 1} | ||||
|     local b = 0.75 | ||||
|     for _ = 1, 10, 1 do | ||||
|         local p = { | ||||
|             (position.x + 0.4) + (b * -1 + random(0, b * 20) * 0.1), | ||||
|             position.y + (b * -1 + random(0, b * 20) * 0.1) | ||||
|         } | ||||
|         player.surface.create_entity({name = 'flying-text', position = p, text = '♻️', color = {random(0, 100), random(0, 100), 0}}) | ||||
|     end | ||||
| end | ||||
|  | ||||
| function Public.set_crafting_boost(player, get_dex_modifier) | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     if not rpg_t then | ||||
|         return false | ||||
|     end | ||||
|  | ||||
|     if rpg_t.crafting_boost then | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     Public.boost_effects(player) | ||||
|  | ||||
|     rpg_t.crafting_boost = get_dex_modifier * 0.03 | ||||
|     local bonus_length = 3600 * get_dex_modifier * 0.003 | ||||
|     rpg_t.old_character_crafting_speed_modifier = player.character_crafting_speed_modifier | ||||
|     Modifiers.update_single_modifier(player, 'character_crafting_speed_modifier', 'crafting_boost', rpg_t.crafting_boost) | ||||
|     Modifiers.update_player_modifiers(player) | ||||
|     Task.set_timeout_in_ticks(bonus_length, restore_crafting_boost_token, {player_index = player.index}) | ||||
| end | ||||
|  | ||||
| function Public.restore_crafting_boost(player) | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     if not rpg_t then | ||||
|         return false | ||||
|     end | ||||
|  | ||||
|     if not rpg_t.crafting_boost then | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     rpg_t.crafting_boost = nil | ||||
|     rpg_t.old_character_crafting_speed_modifier = nil | ||||
|     Modifiers.update_single_modifier(player, 'character_crafting_speed_modifier', 'crafting_boost') | ||||
| end | ||||
|  | ||||
| function Public.get_range_modifier(player) | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     if not rpg_t then | ||||
| @@ -863,6 +923,20 @@ function Public.get_melee_modifier(player) | ||||
|     return total | ||||
| end | ||||
|  | ||||
| function Public.get_dex_modifier(player) | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     if not rpg_t then | ||||
|         return false | ||||
|     end | ||||
|  | ||||
|     if rpg_t.dexterity < 100 then | ||||
|         return 0 | ||||
|     end | ||||
|  | ||||
|     local total = (rpg_t.dexterity - 10) * 0.10 | ||||
|     return total | ||||
| end | ||||
|  | ||||
| function Public.get_player_level(player) | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     if not rpg_t then | ||||
| @@ -980,6 +1054,18 @@ function Public.get_aoe_punch_chance(player) | ||||
|     return chance | ||||
| end | ||||
|  | ||||
| function Public.get_crafting_bonus_chance(player) | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     if rpg_t.dexterity < 100 then | ||||
|         return 0 | ||||
|     end | ||||
|     local chance = round(rpg_t.dexterity * 0.007, 1) | ||||
|     if chance > 100 then | ||||
|         chance = 100 | ||||
|     end | ||||
|     return chance | ||||
| end | ||||
|  | ||||
| function Public.get_extra_following_robots(player) | ||||
|     local rpg_t = Public.get_value_from_player(player.index) | ||||
|     local strength = rpg_t.strength | ||||
| @@ -1307,7 +1393,7 @@ function Public.global_pool(players, count) | ||||
|  | ||||
|     local pool = math.floor(rpg_extra.global_pool) | ||||
|  | ||||
|     local random_amount = math.random(5000, 10000) | ||||
|     local random_amount = random(5000, 10000) | ||||
|  | ||||
|     if pool <= random_amount then | ||||
|         return | ||||
|   | ||||
| @@ -735,6 +735,27 @@ local function on_player_crafted_item(event) | ||||
|  | ||||
|     local final_xp = recipe.energy * amount | ||||
|  | ||||
|     local get_dex_modifier = Public.get_dex_modifier(player) | ||||
|     if get_dex_modifier >= 10 then | ||||
|         local chance = Public.get_crafting_bonus_chance(player) * 10 | ||||
|         local r = random(0, 1999) | ||||
|         local success = r < chance | ||||
|         if success then | ||||
|             Public.set_crafting_boost(player, get_dex_modifier) | ||||
|             local d = random(0, 2999) | ||||
|             local item_dupe = d < chance | ||||
|             if item_dupe and final_xp < 6 then | ||||
|                 local reward = { | ||||
|                     name = item.name, | ||||
|                     count = 1 | ||||
|                 } | ||||
|                 if player.can_insert(reward) then | ||||
|                     player.insert(reward) | ||||
|                 end | ||||
|             end | ||||
|         end | ||||
|     end | ||||
|  | ||||
|     Public.gain_xp(player, final_xp) | ||||
|     Public.reward_mana(player, amount) | ||||
| end | ||||
|   | ||||
| @@ -101,10 +101,11 @@ function Public.update_single_modifier(player, modifier, category, value) | ||||
|     for k, _ in pairs(player_modifiers) do | ||||
|         if modifiers[k] == modifier and player_modifiers[k] then | ||||
|             if category then | ||||
|                 if not player_modifiers[k][category] then | ||||
|                     player_modifiers[k][category] = 0 | ||||
|                 if value then | ||||
|                     player_modifiers[k][category] = value | ||||
|                 else | ||||
|                     player_modifiers[k][category] = nil | ||||
|                 end | ||||
|                 player_modifiers[k][category] = value | ||||
|  | ||||
|                 if not this.creative_enabled then | ||||
|                     if category == 'rpg' and modifiers[k] == 'character_inventory_slots_bonus' and player_modifiers[k][category] >= this.rpg_inventory_slot_limit then | ||||
|   | ||||
		Reference in New Issue
	
	Block a user