mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-02 13:02:38 +00:00
Please refer to #20867 and #20870 for a easier view of the changes. Those two PRs show all meaningful changes (hopefully) and doesn't show the files changed with just 3 lines changed. This PR does three things: It makes all children of /obj/ use the same damage system. Previously to make your new machine/structure be destroyable you needed to give it a var/health, and its own version of many damage related proc such as bullet_act(), take_damage(), attacked_by(), attack_animal(), attack_hulk(), ex_act(), etc... But now, all /obj/ use the same version of those procs at the /obj/ level in code/game/obj_defense.dm. All these obj share the same necessary vars: obj_integrity (health), max_integrity, integrity_failure (optional, below that health level failure happens), and the armor list var which was previously only for items, as well as the resistance_flags bitfield. When you want your new object to be destroyable, you only have to give it a value for those vars and maybe override one proc if you want a special behavior but that's it. This reorganization removes a lot of copypasta (most bullet_act() version for each obj were nearly identical). Two new elements are added to the armor list var: fire and acid armor values. How much damage an obj take depends on the armor value for each damage category. But some objects are INDESTRUCTIBLE and simply never take any damage no matter the type. The armor categories are: -melee(punches, item attacks, xeno/animal/hulk attacks, blob attacks, thrown weapons) -bullet -laser -energy (used by projectiles like ionrifle, taser, and also by EMPs) -bio (unused for this, only here because clothes use them when worn) -rad (same) -bomb (self-explanatory) -fire (for fire damage, not for heat damage though) -acid For machines and structures, when their health reaches zero the object is not just deleted but gets somewhat forcedeconstructed (the proc used is shared with the actual deconstruction system) which can drops things. To not frustrates players most of these objects drop most of the elements necessary to rebuild them (think window dropping shards). Machines drop a machine frame and all components for example (but the frame can then be itself smashed to pieces). For clothes, when they are damaged, they get a "damaged" overlay, which can also be seen when worn, similar to the "bloody" overlay. It refactors acid. See #20537. Some objects are ACID_PROOF and take no damage from acid, while others take varying amounts of damage depending on their acid armor value. Some objects are even UNACIDABLE, no acid effect can even land on them. Acid on objects can be washed off using water. It changes some aspect of damage from fires. All /obj/ can now take fire damage and be flammable, instead of just items. And instead of having just FLAMMABLE objs that become ON_FIRE as soon as some fire touch them (paper), we now have objects that are non flammable but do take damage from fire and become ashes if their health reaches zero (only for items). The damage taken varies depending on the obj's fire armor value and total health. There's also still obj and items that are FIRE_PROOF (although some might still be melted by lava if they're not LAVA_PROOF). When a mob is on fire, its clothes now take fire damage and can turn to ashes. Similarly, when a mob takes melee damages, its clothes gets damaged a bit and can turn to shreds. You can repair clothes with cloth that is produceable by botany's biogenerator. It also does many minor things: Clicking a structure/machine with an item on help intent never results in an attack (so you don't destroy a structure while trying to figure out which tool to use). I moved a lot of objects away from /obj/effect, it should only be used for visual effects, decals and stuff, not for things you can hit and destroy. I tweaked a bit how clothes shredding from bombs work. I made a machine or structure un/anchorable with the wrench, I don't remember which object... Since I changed the meaning of the FIRE_PROOF bitflag to actually mean fire immune, I'm buffing the slime extract that you apply on items to make them fire proof. well now they're really 100% fire proof! animals with environment_smash = 1 no longer one-hit destroy tables and stuff, we give them a decent obj_damage value so they can destroy most obj relatively fast depending on the animal. Probably a million things I forgot. If you want to know how the damage system works all you need is the three obj vars "obj_integrity", "max_integrity", "integrity_failure", as well as the armor list var and the resistance_flags bitfield, and read the file obj_defense.dm
271 lines
10 KiB
Plaintext
271 lines
10 KiB
Plaintext
// ********************************************************
|
|
// Here's all the seeds (plants) that can be used in hydro
|
|
// ********************************************************
|
|
|
|
/obj/item/seeds
|
|
icon = 'icons/obj/hydroponics/seeds.dmi'
|
|
icon_state = "seed" // Unknown plant seed - these shouldn't exist in-game.
|
|
w_class = 1
|
|
resistance_flags = FLAMMABLE
|
|
var/plantname = "Plants" // Name of plant when planted.
|
|
var/product // A type path. The thing that is created when the plant is harvested.
|
|
var/species = "" // Used to update icons. Should match the name in the sprites unless all icon_* are overriden.
|
|
|
|
var/growing_icon = 'icons/obj/hydroponics/growing.dmi' //the file that stores the sprites of the growing plant from this seed.
|
|
var/icon_grow // Used to override grow icon (default is "[species]-grow"). You can use one grow icon for multiple closely related plants with it.
|
|
var/icon_dead // Used to override dead icon (default is "[species]-dead"). You can use one dead icon for multiple closely related plants with it.
|
|
var/icon_harvest // Used to override harvest icon (default is "[species]-harvest"). If null, plant will use [icon_grow][growthstages].
|
|
|
|
var/lifespan = 25 // How long before the plant begins to take damage from age.
|
|
var/endurance = 15 // Amount of health the plant has.
|
|
var/maturation = 6 // Used to determine which sprite to switch to when growing.
|
|
var/production = 6 // Changes the amount of time needed for a plant to become harvestable.
|
|
var/yield = 3 // Amount of growns created per harvest. If is -1, the plant/shroom/weed is never meant to be harvested.
|
|
var/oneharvest = 0 // If a plant is cleared from the tray after harvesting, e.g. a carrot.
|
|
var/potency = 10 // The 'power' of a plant. Generally effects the amount of reagent in a plant, also used in other ways.
|
|
var/growthstages = 6 // Amount of growth sprites the plant has.
|
|
var/plant_type = PLANT_NORMAL // 0 = PLANT_NORMAL; 1 = PLANT_WEED; 2 = PLANT_MUSHROOM; 3 = PLANT_ALIEN
|
|
var/rarity = 0 // How rare the plant is. Used for giving points to cargo when shipping off to Centcom.
|
|
var/list/mutatelist = list() // The type of plants that this plant can mutate into.
|
|
var/list/genes = list() // Plant genes are stored here, see plant_genes.dm for more info.
|
|
var/list/reagents_add = list()
|
|
// A list of reagents to add to product.
|
|
// Format: "reagent_id" = potency multiplier
|
|
// Stronger reagents must always come first to avoid being displaced by weaker ones.
|
|
// Total amount of any reagent in plant is calculated by formula: 1 + round(potency * multiplier)
|
|
|
|
var/weed_rate = 1 //If the chance below passes, then this many weeds sprout during growth
|
|
var/weed_chance = 5 //Percentage chance per tray update to grow weeds
|
|
|
|
/obj/item/seeds/New(loc, nogenes = 0)
|
|
..()
|
|
pixel_x = rand(-8, 8)
|
|
pixel_y = rand(-8, 8)
|
|
|
|
if(!icon_grow)
|
|
icon_grow = "[species]-grow"
|
|
|
|
if(!icon_dead)
|
|
icon_dead = "[species]-dead"
|
|
|
|
if(!icon_harvest && plant_type != PLANT_MUSHROOM && yield != -1)
|
|
icon_harvest = "[species]-harvest"
|
|
|
|
if(!nogenes) // not used on Copy()
|
|
genes += new /datum/plant_gene/core/lifespan(lifespan)
|
|
genes += new /datum/plant_gene/core/endurance(endurance)
|
|
if(yield != -1)
|
|
genes += new /datum/plant_gene/core/yield(yield)
|
|
genes += new /datum/plant_gene/core/production(production)
|
|
if(potency != -1)
|
|
genes += new /datum/plant_gene/core/potency(potency)
|
|
|
|
for(var/p in genes)
|
|
if(ispath(p))
|
|
genes -= p
|
|
genes += new p
|
|
|
|
for(var/reag_id in reagents_add)
|
|
genes += new /datum/plant_gene/reagent(reag_id, reagents_add[reag_id])
|
|
|
|
/obj/item/seeds/proc/Copy()
|
|
var/obj/item/seeds/S = new type(null, 1)
|
|
// Copy all the stats
|
|
S.lifespan = lifespan
|
|
S.endurance = endurance
|
|
S.maturation = maturation
|
|
S.production = production
|
|
S.yield = yield
|
|
S.potency = potency
|
|
S.genes = list()
|
|
for(var/g in genes)
|
|
var/datum/plant_gene/G = g
|
|
S.genes += G.Copy()
|
|
S.reagents_add = reagents_add.Copy() // Faster than grabbing the list from genes.
|
|
return S
|
|
|
|
/obj/item/seeds/proc/get_gene(typepath)
|
|
return (locate(typepath) in genes)
|
|
|
|
/obj/item/seeds/proc/reagents_from_genes()
|
|
reagents_add = list()
|
|
for(var/datum/plant_gene/reagent/R in genes)
|
|
reagents_add[R.reagent_id] = R.rate
|
|
|
|
/obj/item/seeds/proc/mutate(lifemut = 2, endmut = 5, productmut = 1, yieldmut = 2, potmut = 25)
|
|
adjust_lifespan(rand(-lifemut,lifemut))
|
|
adjust_endurance(rand(-endmut,endmut))
|
|
adjust_production(rand(-productmut,productmut))
|
|
adjust_yield(rand(-yieldmut,yieldmut))
|
|
adjust_potency(rand(-potmut,potmut))
|
|
|
|
|
|
/obj/item/seeds/bullet_act(obj/item/projectile/Proj) //Works with the Somatoray to modify plant variables.
|
|
if(istype(Proj, /obj/item/projectile/energy/florayield))
|
|
var/rating = 1
|
|
if(istype(loc, /obj/machinery/hydroponics))
|
|
var/obj/machinery/hydroponics/H = loc
|
|
rating = H.rating
|
|
|
|
if(yield == 0)//Oh god don't divide by zero you'll doom us all.
|
|
adjust_yield(1 * rating)
|
|
else if(prob(1/(yield * yield) * 100))//This formula gives you diminishing returns based on yield. 100% with 1 yield, decreasing to 25%, 11%, 6, 4, 2...
|
|
adjust_yield(1 * rating)
|
|
else
|
|
return ..()
|
|
|
|
|
|
// Harvest procs
|
|
/obj/item/seeds/proc/getYield()
|
|
var/return_yield = yield
|
|
|
|
var/obj/machinery/hydroponics/parent = loc
|
|
if(istype(loc, /obj/machinery/hydroponics))
|
|
if(parent.yieldmod == 0)
|
|
return_yield = min(return_yield, 1)//1 if above zero, 0 otherwise
|
|
else
|
|
return_yield *= (parent.yieldmod)
|
|
|
|
return return_yield
|
|
|
|
|
|
/obj/item/seeds/proc/harvest(mob/user = usr)
|
|
var/obj/machinery/hydroponics/parent = loc //for ease of access
|
|
var/t_amount = 0
|
|
var/list/result = list()
|
|
var/output_loc = parent.Adjacent(user) ? user.loc : parent.loc //needed for TK
|
|
var/product_name
|
|
while(t_amount < getYield())
|
|
var/obj/item/weapon/reagent_containers/food/snacks/grown/t_prod = new product(output_loc, src)
|
|
result.Add(t_prod) // User gets a consumable
|
|
if(!t_prod)
|
|
return
|
|
t_amount++
|
|
product_name = t_prod.name
|
|
if(getYield() >= 1)
|
|
feedback_add_details("food_harvested","[product_name]|[getYield()]")
|
|
parent.update_tray()
|
|
|
|
return result
|
|
|
|
|
|
/obj/item/seeds/proc/prepare_result(var/obj/item/weapon/reagent_containers/food/snacks/grown/T)
|
|
if(T.reagents)
|
|
for(var/reagent_id in reagents_add)
|
|
if(reagent_id == "blood") // Hack to make blood in plants always O-
|
|
T.reagents.add_reagent(reagent_id, 1 + round(potency * reagents_add[reagent_id], 1), list("blood_type"="O-"))
|
|
continue
|
|
|
|
T.reagents.add_reagent(reagent_id, 1 + round(potency * reagents_add[reagent_id]), 1)
|
|
return 1
|
|
|
|
|
|
/// Setters procs ///
|
|
/obj/item/seeds/proc/adjust_yield(adjustamt)
|
|
if(yield != -1) // Unharvestable shouldn't suddenly turn harvestable
|
|
yield = Clamp(yield + adjustamt, 0, 10)
|
|
|
|
if(yield <= 0 && plant_type == PLANT_MUSHROOM)
|
|
yield = 1 // Mushrooms always have a minimum yield of 1.
|
|
var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/yield)
|
|
if(C)
|
|
C.value = yield
|
|
|
|
/obj/item/seeds/proc/adjust_lifespan(adjustamt)
|
|
lifespan = Clamp(lifespan + adjustamt, 10, 100)
|
|
var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/lifespan)
|
|
if(C)
|
|
C.value = lifespan
|
|
|
|
/obj/item/seeds/proc/adjust_endurance(adjustamt)
|
|
endurance = Clamp(endurance + adjustamt, 10, 100)
|
|
var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/endurance)
|
|
if(C)
|
|
C.value = endurance
|
|
|
|
/obj/item/seeds/proc/adjust_production(adjustamt)
|
|
if(yield != -1)
|
|
production = Clamp(production + adjustamt, 2, 10)
|
|
var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/production)
|
|
if(C)
|
|
C.value = production
|
|
|
|
/obj/item/seeds/proc/adjust_potency(adjustamt)
|
|
if(potency != -1)
|
|
potency = Clamp(potency + adjustamt, 0, 100)
|
|
var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/potency)
|
|
if(C)
|
|
C.value = potency
|
|
|
|
|
|
/obj/item/seeds/proc/get_analyzer_text() //in case seeds have something special to tell to the analyzer
|
|
var/text = ""
|
|
switch(plant_type)
|
|
if(PLANT_NORMAL)
|
|
text += "- Plant type: Normal plant\n"
|
|
if(PLANT_WEED)
|
|
text += "- Plant type: Weed. Can grow in nutrient-poor soil.\n"
|
|
if(PLANT_MUSHROOM)
|
|
text += "- Plant type: Mushroom. Can grow in dry soil.\n"
|
|
else
|
|
text += "- Plant type: <span class='warning'>UNKNOWN</span> \n"
|
|
if(potency != -1)
|
|
text += "- Potency: [potency]\n"
|
|
if(yield != -1)
|
|
text += "- Yield: [yield]\n"
|
|
text += "- Maturation speed: [maturation]\n"
|
|
if(yield != -1)
|
|
text += "- Production speed: [production]\n"
|
|
text += "- Endurance: [endurance]\n"
|
|
text += "- Lifespan: [lifespan]\n"
|
|
if(rarity)
|
|
text += "- Species Discovery Value: [rarity]\n"
|
|
|
|
text += "*---------*"
|
|
|
|
return text
|
|
|
|
/obj/item/seeds/proc/on_chem_reaction(datum/reagents/S) //in case seeds have some special interaction with special chems
|
|
return
|
|
|
|
/obj/item/seeds/attackby(obj/item/O, mob/user, params)
|
|
if (istype(O, /obj/item/device/plant_analyzer))
|
|
user << "<span class='info'>*---------*\n This is \a <span class='name'>[src]</span>.</span>"
|
|
var/text = get_analyzer_text()
|
|
if(text)
|
|
user << "<span class='notice'>[text]</span>"
|
|
|
|
return
|
|
..() // Fallthrough to item/attackby() so that bags can pick seeds up
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Checks plants for broken tray icons. Use Advanced Proc Call to activate.
|
|
// Maybe some day it would be used as unit test.
|
|
/proc/check_plants_growth_stages_icons()
|
|
var/list/states = icon_states('icons/obj/hydroponics/growing.dmi')
|
|
states |= icon_states('icons/obj/hydroponics/growing_fruits.dmi')
|
|
states |= icon_states('icons/obj/hydroponics/growing_flowers.dmi')
|
|
states |= icon_states('icons/obj/hydroponics/growing_mushrooms.dmi')
|
|
states |= icon_states('icons/obj/hydroponics/growing_vegetables.dmi')
|
|
var/list/paths = typesof(/obj/item/seeds) - /obj/item/seeds - typesof(/obj/item/seeds/sample)
|
|
|
|
for(var/seedpath in paths)
|
|
var/obj/item/seeds/seed = new seedpath
|
|
|
|
for(var/i in 1 to seed.growthstages)
|
|
if("[seed.icon_grow][i]" in states)
|
|
continue
|
|
world << "[seed.name] ([seed.type]) lacks the [seed.icon_grow][i] icon!"
|
|
|
|
if(!(seed.icon_dead in states))
|
|
world << "[seed.name] ([seed.type]) lacks the [seed.icon_dead] icon!"
|
|
|
|
if(seed.icon_harvest) // mushrooms have no grown sprites, same for items with no product
|
|
if(!(seed.icon_harvest in states))
|
|
world << "[seed.name] ([seed.type]) lacks the [seed.icon_harvest] icon!"
|