From 1d64bade9bfaa713d4b744c1c3e56f0461ae56a6 Mon Sep 17 00:00:00 2001 From: savethetreez Date: Tue, 28 May 2024 17:53:50 +0200 Subject: [PATCH 1/2] Hand saw code More efficient than a hatchet, saw mills produce much more planks --- code/modules/1713/production.dm | 6 +- code/modules/materials/material_sheets.dm | 73 +++++++++++++++-------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/code/modules/1713/production.dm b/code/modules/1713/production.dm index 2c8538bee9..12f2bced66 100644 --- a/code/modules/1713/production.dm +++ b/code/modules/1713/production.dm @@ -2275,17 +2275,17 @@ H << "\The [src.name] is busy, wait for the saw blade to finish cutting." return if (istype(src, /obj/structure/sawmill/large)) - current_work = new P(null, W.amount * 2, FALSE) //in fact for information purpose only we really need new object + current_work = new P(null, W.amount * 10, FALSE) //in fact for information purpose only we really need new object icon = 'icons/obj/plankage_64.dmi' icon_state = "sawmill1" work_time_amount = round(0.1*(W.amount*8+47)) //The efficiency increases with the amount of material. For 1 material we get 20 deciseconds, for 50 material - 254 deciseconds. else if (istype(src, /obj/structure/sawmill/powered) && powered == TRUE) - current_work = new P(null, W.amount * 4, FALSE) //in fact for information purpose only we really need new object + current_work = new P(null, W.amount * 12, FALSE) //in fact for information purpose only we really need new object icon = 'icons/obj/plankage_64.dmi' icon_state = "sawmill_power1" work_time_amount = round(0.1*(W.amount*4+47)) //The efficiency increases with the amount of material. For 1 material we get 20 deciseconds, for 50 material - 254 deciseconds. else - current_work = new P(null, W.amount, FALSE) //in fact for information purpose only we really need new object + current_work = new P(null, W.amount * 4, FALSE) //in fact for information purpose only we really need new object icon_state = "primitive_sawmill1" work_time_amount = round(0.1*(W.amount*12+47)) //The efficiency increases with the amount of material. For 1 material we get 20 deciseconds, for 50 material - 254 deciseconds. current_material = W diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm index 985a9203f7..36c6bc6ee5 100644 --- a/code/modules/materials/material_sheets.dm +++ b/code/modules/materials/material_sheets.dm @@ -432,30 +432,55 @@ if (src.amount < 2) to_chat(user, "You don't have enough material to try.") return - else - // Check if splitting process is already in progress - if (splitting_in_progress) - to_chat(user, SPAN_DANGER("\The [src] are already being split.")) - return - // Set splitting_in_progress to TRUE to indicate the process has started - splitting_in_progress = TRUE - - // Start the splitting process - user.visible_message("[user.name] starts carving \the [src] into a plank using \the [T].", "You start carving \the [src] into a plank.") - playsound(loc, 'sound/effects/woodfile.ogg', 100, TRUE) - - // Set a delay for the splitting process - if (!do_after(user, (80/(user.getStatCoeff("strength"))), src)) // Was originally dividing by SH.chopping_speed after getstatcoeff but the flint hatchet has a faster chopping_speed than an iron one. TODO: refactor the speeds. - splitting_in_progress = FALSE // In case we abort mid-way. - return - // Finish the splitting process - user.visible_message("[user.name] finishes carving \the [src] into a plank.", "You finish carving \the [src] into a plank.") - src.use(2) - var/obj/item/stack/material/woodplank/dropwood = new /obj/item/stack/material/woodplank(get_turf(user)) - dropwood.amount = 1 // You might expect to obtain anywhere from 2 to 4 planks from a single log. TODO: skill-based plank output - dropwood.update_strings() - splitting_in_progress = FALSE // Reset the variable to FALSE after the splitting process is complete - + // Check if splitting process is already in progress + if (splitting_in_progress) + to_chat(user, SPAN_WARNING("\The [src] are already being split.")) + return + // Set splitting_in_progress to TRUE to indicate the process has started + splitting_in_progress = TRUE + + // Start the splitting process + user.visible_message("[user.name] starts carving \the [src] into a plank using \the [T].", "You start carving \the [src] into a plank.") + playsound(loc, 'sound/effects/woodfile.ogg', 100, TRUE) + + // Set a delay for the splitting process + if (!do_after(user, (80/(user.getStatCoeff("strength"))), src)) // Was originally dividing by SH.chopping_speed after getstatcoeff but the flint hatchet has a faster chopping_speed than an iron one. TODO: refactor the speeds. + splitting_in_progress = FALSE // In case we abort mid-way. + return + // Finish the splitting process + user.visible_message("[user.name] finishes carving \the [src] into a plank.", "You finish carving \the [src] into a plank.") + src.use(2) + var/obj/item/stack/material/woodplank/dropwood = new /obj/item/stack/material/woodplank(get_turf(user)) + dropwood.amount = 1 // You might expect to obtain anywhere from 2 to 4 planks from a single log. TODO: skill-based plank output + dropwood.update_strings() + splitting_in_progress = FALSE // Reset the variable to FALSE after the splitting process is complete + if (istype(T, /obj/item/weapon/saw)) + // Check if there's enough material + if (src.amount < 1) + to_chat(user, "You don't have enough planks to saw.") + return + // Check if splititng process is already in progress + if (splitting_in_progress) + to_chat(user, SPAN_WARNING("\The [src] are already being sawed.")) + return + // Set splitting_in_progress to TRUE to indicate the process has started + splitting_in_progress = TRUE + + // Start the splitting process + user.visible_message("[user.name] starts sawing \the [src] into planks using \the [T].", "You start sawing \the [src] into planks.") + playsound(loc, 'sound/effects/woodfile.ogg', 100, TRUE) + + // Set a delay for the splitting process + if (!do_after(user, (60/(user.getStatCoeff("strength"))), src)) + splitting_in_progress = FALSE // In case we abort mid-way. + return + // Finish the splitting process + user.visible_message("[user.name] finishes sawing \the [src] into planks.", "You finish carving \the [src] into planks.") + src.use(1) + var/obj/item/stack/material/woodplank/dropwood = new /obj/item/stack/material/woodplank(get_turf(user)) + dropwood.amount = 4 + dropwood.update_strings() + splitting_in_progress = FALSE // Reset the variable to FALSE after the splitting process is complete return ..() /obj/item/stack/material/woodplank From 17f0653f410e2c24b82fb0025a7f9ff2b42b95d1 Mon Sep 17 00:00:00 2001 From: savethetreez Date: Tue, 28 May 2024 17:54:18 +0200 Subject: [PATCH 2/2] Small clean ups Wanted to rewrite the SL code, but gave up. --- code/game/jobs/job_controller.dm | 80 +++++++++++++++++--------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 59eeb79b6f..13fbde6b57 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -89,24 +89,25 @@ var/global/datum/controller/occupations/job_master /datum/controller/occupations/proc/set_factions2(var/autobalance_nr = 0) var/list/randomfaction = list("Civilization A Citizen","Civilization B Citizen","Civilization C Citizen","Civilization D Citizen","Civilization E Citizen","Civilization F Citizen") if (map.availablefactions_run == TRUE) - if (autobalance_nr <= 8) - map.availablefactions = list("Civilization A Citizen") - to_chat(world, "Only one civilization is enabled: [civname_a].") - else if (autobalance_nr > 8 && autobalance_nr <= 16) - map.availablefactions = list("Civilization A Citizen","Civilization B Citizen") - to_chat(world, "Two civilizations are enabled: [civname_a], [civname_b].") - else if (autobalance_nr > 16 && autobalance_nr <= 24) - map.availablefactions = list("Civilization A Citizen","Civilization B Citizen","Civilization C Citizen") - to_chat(world, "Three civilizations are enabled: [civname_a], [civname_b], [civname_c].") - else if (autobalance_nr > 24 && autobalance_nr <= 30) - map.availablefactions = list("Civilization A Citizen","Civilization B Citizen","Civilization C Citizen","Civilization D Citizen") - to_chat(world, "Four civilizations are enabled: [civname_a], [civname_b], [civname_c], [civname_d].") - else if (autobalance_nr > 30 && autobalance_nr <= 36) - map.availablefactions = list("Civilization A Citizen","Civilization B Citizen","Civilization C Citizen","Civilization D Citizen","Civilization E Citizen") - to_chat(world, "Five civilizations are enabled: [civname_a], [civname_b], [civname_c], [civname_d], [civname_e].") - else if (autobalance_nr > 36) - map.availablefactions = randomfaction - to_chat(world, "All the 6 civilizations are enabled: [civname_a], [civname_b], [civname_c], [civname_d], [civname_e], [civname_f].") + switch(autobalance_nr) + if (0 to 8) + map.availablefactions = list("Civilization A Citizen") + to_chat(world, "Only one civilization is enabled: [civname_a].") + if (9 to 16) + map.availablefactions = list("Civilization A Citizen","Civilization B Citizen") + to_chat(world, "Two civilizations are enabled: [civname_a], [civname_b].") + if (17 to 24) + map.availablefactions = list("Civilization A Citizen","Civilization B Citizen","Civilization C Citizen") + to_chat(world, "Three civilizations are enabled: [civname_a], [civname_b], [civname_c].") + if (25 to 30) + map.availablefactions = list("Civilization A Citizen","Civilization B Citizen","Civilization C Citizen","Civilization D Citizen") + to_chat(world, "Four civilizations are enabled: [civname_a], [civname_b], [civname_c], [civname_d].") + if (31 to 36) + map.availablefactions = list("Civilization A Citizen","Civilization B Citizen","Civilization C Citizen","Civilization D Citizen","Civilization E Citizen") + to_chat(world, "Five civilizations are enabled: [civname_a], [civname_b], [civname_c], [civname_d], [civname_e].") + if (37 to INFINITY) + map.availablefactions = randomfaction + to_chat(world, "All the 6 civilizations are enabled: [civname_a], [civname_b], [civname_c], [civname_d], [civname_e], [civname_f].") map.availablefactions_run = FALSE return @@ -228,6 +229,7 @@ var/global/datum/controller/occupations/job_master HSL = HM else if (map.faction2_squad_leaders[H.squad] && !map.faction2_squad_leaders[H.squad].original_job.is_tankcom) HSL = map.faction2_squad_leaders[H.squad] + if (HSL && HSL.stat == CONSCIOUS) var/found = FALSE for(var/mob/living/human/EN in range(6,HSL)) @@ -252,7 +254,8 @@ var/global/datum/controller/occupations/job_master spawnloc = get_turf(HSL) break H.forceMove(spawnloc) - HSL << "[H] has arrived at your squad." + to_chat(HSL, "[H] has arrived at your squad.") + // make sure we have the right ambience for our new location spawn (1) var/area/H_area = get_area(H) @@ -266,26 +269,29 @@ var/global/datum/controller/occupations/job_master SpawnAtFob(H) if (!H.spawned_at_fob) if (map.ID == MAP_GULAG13) - if(H.nationality == "German") - spawn_location = "JoinLateCivG" - else if(H.nationality == "Polish") - spawn_location = "JoinLateCivP" - else if(H.nationality == "Ukrainian") - spawn_location = "JoinLateCivU" - if (!spawn_location && H.original_job) - spawn_location = H.original_job.spawn_location + switch(H.nationality) + if ("German") + spawn_location = "JoinLateCivG" + if ("Polish") + spawn_location = "JoinLateCivP" + if ("Ukrainian") + spawn_location = "JoinLateCivU" if (map.ID == MAP_TRIBES || map.ID == MAP_FOUR_KINGDOMS || map.ID == MAP_THREE_TRIBES) if (H.original_job_title in map.availablefactions) - if (H.original_job_title == "Human tribesman") - spawn_location = "JoinLateIND1" - else if (H.original_job_title == "Crustacean tribesman") - spawn_location = "JoinLateIND2" - else if (H.original_job_title == "Orc tribesman") - spawn_location = "JoinLateIND3" - else if (H.original_job_title == "Lizard tribesman") - spawn_location = "JoinLateIND4" + switch(H.original_job_title) + if ("Human tribesman") + spawn_location = "JoinLateIND1" + if ("Crustacean tribesman") + spawn_location = "JoinLateIND2" + if ("Orc tribesman") + spawn_location = "JoinLateIND3" + if ("Lizard tribesman") + spawn_location = "JoinLateIND4" else spawn_location = "JoinLateIND5" + + if (!spawn_location && H.original_job) + spawn_location = H.original_job.spawn_location var/turf/spawnpoint = null var/list/turfs = latejoin_turfs[spawn_location] @@ -336,7 +342,7 @@ var/global/datum/controller/occupations/job_master valid_spawns += T if (blocked) - H << SPAN_WARNING("Cannot spawn at this FOB because an enemy is nearby.") + to_chat(H, SPAN_WARNING("Cannot spawn at this FOB because an enemy is nearby.")) SpawnAtFob(H) return @@ -349,7 +355,7 @@ var/global/datum/controller/occupations/job_master H_area.play_ambience(H) return else - H << SPAN_WARNING("No valid spawnpoints were found at this FOB.") + to_chat(H, SPAN_WARNING("No valid spawnpoints were found at this FOB.")) SpawnAtFob(H) return