Skip to content

Commit

Permalink
sawmill update + high-efficiency engine
Browse files Browse the repository at this point in the history
adds powered sawmill and fixes the math for time calculation

adds a costly engine that consumed very little fuel (but weights a fuckton so it shouldnt be used for vehicles)
  • Loading branch information
KanohaShinobi committed Feb 22, 2024
1 parent 6e66c03 commit 02a6174
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 6 deletions.
18 changes: 18 additions & 0 deletions code/game/objects/items/stacks/stack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,24 @@ obj/item/stack/Crossed(var/obj/item/stack/S)
if (NR.amount <= 0)
qdelHandReturn(H.r_hand, H)

else if (recipe.result_type == /obj/structure/sawmill/powered)
if (H.getStatCoeff("crafting") < 2.2)
H << SPAN_DANGER("This is too complex for your skill level.")
return
if (!istype(H.l_hand, /obj/item/stack/material/electronics) && !istype(H.r_hand, /obj/item/stack/material/electronics))
user << SPAN_WARNING("You need to have electronic circuits in the other hand to craft the powered saw mill.")
return
if (istype(H.l_hand, /obj/item/stack/material/woodplank))
var/obj/item/stack/material/woodplank/NR = H.l_hand
NR.amount -= 200
if (NR.amount <= 0)
qdelHandReturn(H.l_hand, H)
else if (istype(H.r_hand, /obj/item/stack/material/woodplank))
var/obj/item/stack/material/woodplank/NR = H.r_hand
NR.amount -= 200
if (NR.amount <= 0)
qdelHandReturn(H.r_hand, H)

else if (recipe.result_type == /obj/structure/religious/totem)
newtotem = new /obj/structure/religious/totem
if (H.original_job_title == "Red Goose Tribesman")
Expand Down
29 changes: 28 additions & 1 deletion code/modules/1713/machinery/engines/engines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
if (steelamt == 0)
return

var/display = list("Turbine Engine (73 sheets per 1000 cc)","Hot Bulb Engine (33 sheets per 1000 cc)","4-Stroke Gasoline Engine (50 sheets per 1000 cc)","4-Stroke Ethanol-Gasoline Engine (60 sheets per 1000 cc)","2-Stroke Gasoline Engine (40 sheets per 1000 cc)","Diesel Engine (40 sheets per 1000 cc)","Biodiesel Engine (45 sheets per 1000 cc)","Hesselman Engine (43 sheets per 1000 cc)", "Cancel")
var/display = list("Turbine Engine (73 sheets per 1000 cc)","Hot Bulb Engine (33 sheets per 1000 cc)","4-Stroke Gasoline Engine (50 sheets per 1000 cc)","High Efficiency 4-Stroke Gasoline Engine (100 sheets per 1000 cc)","4-Stroke Ethanol-Gasoline Engine (60 sheets per 1000 cc)","2-Stroke Gasoline Engine (40 sheets per 1000 cc)","Diesel Engine (40 sheets per 1000 cc)","Biodiesel Engine (45 sheets per 1000 cc)","Hesselman Engine (43 sheets per 1000 cc)", "Cancel")
var/choice = WWinput(H, "What engine do you want to make?", "Engines", "Cancel", display)
if (choice == "Cancel")
return
Expand Down Expand Up @@ -378,6 +378,33 @@
else
done = FALSE
return
else if (choice == "High Efficiency 4-Stroke Gasoline Engine (100 sheets per 1000 cc)")
enginesize = input(H, "Choose the engine size, in cc: (minimum 100, maximum 30000)") as num
enginesize = Clamp(enginesize, 100, 30000)
if ((enginesize/1000)*100 > steelamt)
H << "You don't have enough steel. You need [(enginesize/1000)*100] and you have [steelamt]. Try building a smaller engine."
return
else
H << "You start building the engine..."
done = TRUE
if (do_after(H,200,src))
if (done)
if (istype(H.l_hand, /obj/item/stack/material/steel))
H.l_hand.amount -= (enginesize/1000)*100
else if (istype(H.r_hand, /obj/item/stack/material/steel))
H.r_hand.amount -= (enginesize/1000)*100
var/obj/structure/engine/internal/gasoline/efficient/NEN = new/obj/structure/engine/internal/gasoline/efficient(get_turf(H))
NEN.enginesize = enginesize
NEN.weight = 40*(NEN.enginesize/1000)
NEN.name = "[NEN.enginesize]cc 4-S gasoline engine"
NEN.maxpower *= (NEN.enginesize/1000)
NEN.fuelefficiency *= (NEN.enginesize/1000)
H << "You finish building the engine."
done = FALSE
return
else
done = FALSE
return
else if (choice == "4-Stroke Ethanol-Gasoline Engine (60 sheets per 1000 cc)")
enginesize = input(H, "Choose the engine size, in cc: (minimum 80, maximum 30000)") as num
enginesize = Clamp(enginesize, 80, 30000)
Expand Down
16 changes: 16 additions & 0 deletions code/modules/1713/machinery/engines/internal_combustion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@
running_snd = 'sound/machines/gasoline_loop.ogg'
ending_snd = 'sound/machines/gasoline_ending.ogg'

/obj/structure/engine/internal/gasoline/efficient
name = "efficient four-stroke gasoline engine"
desc = "A relatively expensive but efficient four-stroke gasoline engine."
icon = 'icons/obj/engines32.dmi'
icon_state = "gasoline_static"
engineclass = "gasoline"

maxpower = 100
torque = 1.2
fuelefficiency = 0.003
fuels = list("gasoline")

starting_snd = 'sound/machines/gasoline_starting.ogg'
running_snd = 'sound/machines/gasoline_loop.ogg'
ending_snd = 'sound/machines/gasoline_ending.ogg'

/obj/structure/engine/internal/gasoline/twostroke
name = "two-stroke gasoline engine"
desc = "A cheap and simple two-stroke gasoline engine."
Expand Down
93 changes: 88 additions & 5 deletions code/modules/1713/production.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// no_emotes - set it to TRUE if no emotes when procedure work
// no_msg - set it to TRUE if no messages to user when procedure work
// change_mood_coefficient - set this multiplicator not 1 if you want greater or less effect to mood
// EUREKA_chance, breakthrough_chance, fail_chance, EPIC_fail_chance - in percents, by default they are 0.5, 5, 5 and 0.5
// EUREKA_chance, breakthrough_chance, fail_chance, EPIC_fail_chance - in percents, by default they are 0.5, 5, 5 and 0.5 ||Shinobi|| not anymore, no fails
var/equal_distribution = 0
var/exp_gain = work_amount/10/2 //1 exp for every 2 seconds of work
var/e_c = EUREKA_chance * 100
Expand Down Expand Up @@ -125,6 +125,9 @@

//TO DO TODO: make this procedure global using
/obj/structure/proc/wrench_action(var/mob/living/human/H)
if (powersource)
to_chat(H, SPAN_NOTICE("Remove the cables first."))
return
if(!not_movable)
playsound(src.loc, 'sound/items/Ratchet.ogg', 100, TRUE)
H.visible_message(
Expand Down Expand Up @@ -2202,13 +2205,44 @@
icon_state = "sawmill"
bound_width = 64
bound_height = 32

/obj/structure/sawmill/powered
name = "Powered Saw Mill"
desc = "A large powered saw mill, used to cut logs into planks. This one produces 4 planks per log."
icon = 'icons/obj/plankage_64.dmi'
bound_width = 64
bound_height = 32
icon_state = "sawmill_power"
powerneeded = 1

/obj/structure/sawmill/proc/check_power()
if (!powersource || !powerneeded)
return FALSE
else
if (powersource.powered && ((powersource.powerflow-powersource.currentflow) >= powerneeded))
if (!powered)
powersource.update_power(powerneeded,1)
powered = TRUE
powersource.currentflow += powerneeded
powersource.lastupdate2 = world.time
return TRUE
else
powered = FALSE
return

/obj/structure/sawmill/proc/finish_work()
check_power()
if (current_work)
current_user.visible_message(
"<span class='notice'>You can see how [current_user.name] made [current_work.name] on \a [src.name].</span>",
"<span class='notice'>You finish producing \the [current_work.name].</span>",
"<span class='notice'>The sounds of \the [src.name] were gone.</span>")
icon_state = "primitive_sawmill"
if (istype(src, /obj/structure/sawmill/large))
icon_state = "sawmill"
else if (istype(src, /obj/structure/sawmill/powered))
icon_state = "sawmill_power"
else
icon_state = "primitive_sawmill"
qdel(current_material)
var/obj/item/stack/this_production = new current_work.type(null, current_work.amount, FALSE) //deleting and creating for sterilization effect (we need really new object)
current_user.put_in_active_hand(this_production)
Expand All @@ -2227,23 +2261,32 @@
work_time_amount = 0

/obj/structure/sawmill/proc/produce(var/obj/item/stack/W, var/mob/living/human/H, var/obj/item/stack/P)
check_power()
if (!H.in_mood())
return
if(!anchored)
H << "<span class='warning'>\The [src] needs to be fixed in place before anything can be cut.</span>"
return
if(istype(src, /obj/structure/sawmill/powered) && powered == FALSE)
H << "<span class='warning'>\The [src] needs to be powered before anything can be cut.</span>"
return
if (current_work)
H << "<span class='warning'>\The [src.name] is busy, wait for the saw blade to finish cutting.</span>"
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
icon = 'icons/obj/plankage_64.dmi'
icon_state = "sawmill1"
work_time_amount = round(10000/(W.amount*3+47)) //The efficiency increases with the amount of material. For 1 material we get 20 deciseconds, for 50 material - 254 deciseconds.
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
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
icon_state = "primitive_sawmill1"
work_time_amount = round(20000/(W.amount*3+47)) //The efficiency increases with the amount of material. For 1 material we get 20 deciseconds, for 50 material - 254 deciseconds.
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
current_user = H
H.visible_message(
Expand All @@ -2257,6 +2300,8 @@
else
if (istype(src, /obj/structure/sawmill/large))
icon_state = "sawmill"
else if (istype(src, /obj/structure/sawmill/powered))
icon_state = "sawmill_power"
else
icon_state = "primitive_sawmill"
//20% - with no penalty, 30% - little mood decreasing, 25% - mood decreasing,
Expand Down Expand Up @@ -2326,7 +2371,8 @@
current_material = null
current_user = null

/obj/structure/sawmill/attackby(var/obj/item/stack/W as obj, var/mob/living/human/H as mob)
/obj/structure/sawmill/attackby(var/obj/item/stack/W as obj, var/mob/living/human/H as mob, var/obj/item/I)
check_power()
if (istype(W, /obj/item/stack/material/wood))
produce(W, H, /obj/item/stack/material/woodplank)
return
Expand All @@ -2336,6 +2382,43 @@
if (istype(W,/obj/item/weapon/hammer))
hammer_action(H, W, 150, list("/obj/item/stack/material/wood"), list(6))
return
if (istype(W, /obj/item/stack/cable_coil))
if (powersource)
H << "There's already a cable connected here! Split it further from the [src]."
return
var/obj/item/stack/cable_coil/CC = W
powersource = CC.place_turf(get_turf(src), H, turn(get_dir(H,src),180))
if (!powersource)
return
powersource.connections += src
var/opdir1 = 0
var/opdir2 = 0
if (powersource.tiledir == "horizontal")
opdir1 = 4
opdir2 = 8
else if (powersource.tiledir == "vertical")
opdir1 = 1
opdir2 = 2
powersource.update_icon()

if (opdir1 != 0 && opdir2 != 0)
for(var/obj/structure/cable/NCOO in get_turf(get_step(powersource,opdir1)))
if ((NCOO.tiledir == powersource.tiledir) && NCOO != powersource)
if (!(powersource in NCOO.connections) && !list_cmp(powersource.connections, NCOO.connections))
NCOO.connections += powersource
if (!(NCOO in powersource.connections) && !list_cmp(powersource.connections, NCOO.connections))
powersource.connections += NCOO
H << "You connect the two cables."

for(var/obj/structure/cable/NCOC in get_turf(get_step(powersource,opdir2)))
if ((NCOC.tiledir == powersource.tiledir) && NCOC != powersource)
if (!(powersource in NCOC.connections) && !list_cmp(powersource.connections, NCOC.connections))
NCOC.connections += powersource
if (!(NCOC in powersource.connections) && !list_cmp(powersource.connections, NCOC.connections))
powersource.connections += NCOC
H << "You connect the cable to the [src]."
else
..()
..(W, H)

/obj/structure/sawmill/initialize()
Expand Down
1 change: 1 addition & 0 deletions config/crafting/material_recipes_global.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,7 @@ RECIPE: /material/wood/soft/,gunsmithing bench,/obj/structure/gunbench,13,180,1,
RECIPE: /material/wood/soft/,ethanol distillery,/obj/structure/distillery,15,180,1,1,economy & production,45,0,0,8,null
RECIPE: /material/wood/,primitive saw mill,/obj/structure/sawmill,28,60,1,1,economy & production,15,0,0,8,null
RECIPE: /material/wood/soft,large saw mill,/obj/structure/sawmill/large,100,60,1,1,economy & production,45,0,0,8,null
RECIPE: /material/wood/soft,powered saw mill,/obj/structure/sawmill/powered,200,60,1,1,economy & production,100,0,0,8,null


RECIPE: /material/wood/soft/,market stall,/obj/structure/vending/sales/market_stall,25,150,1,1,economy & production,24,0,0,8,null
Expand Down
Binary file modified icons/obj/plankage_64.dmi
Binary file not shown.

0 comments on commit 02a6174

Please sign in to comment.