Files
kiwistation/code/modules/hydroponics/grown/towercap.dm
T
silicons 160175ee8b pass_flags handling refactor + rewrites a part of projectiles for the n-th time (#54924)
Yeah uhh this'll probably need testmerging even after it's done because yeah it's a bit big.
If y'all want me to atomize this into two PRs (pass flags vs projectiles) tell me please. Pass flags would have to go in first though, in that case, as new projectile hit handling will rely on pass_flags_self.
Pass flags:

Pass flags handling now uses an atom variable named pass_flags_self.
If any of these match a pass_flag on a thing trying to pass through, it's allowed through by default.
This makes overriding CanAllowThrough unnecessary for the majority of things. I've however not removed overrides for very.. weird cases, like plastic flaps which uses a prob(60) for letting PASSGLASS things through for god knows why.
LETPASSTHROW is now on pass_flags_self
Projectiles:

Not finalized yet, need to do something to make the system I have in mind have less unneeded overhead + snowflake

Basically, for piercing/phasing/otherwise projectiles that go through things instead of hitting the first dense object, I have them use pass_flags flags for two new variables, projectile_phasing and projectile_piercing. Anything with pass_flags_self in the former gets phased through entirely. Anything in the latter gets hit, and the projectile then goes through. on_hit will also register a piercing hit vs a normal hit (so things like missiles can only explode on a normal hit or otherwise, instead of exploding multiple times. Not needed as missiles qdel(src) right now but it's nice to have for the future).

I still need to decide what to do for hit handling proper, as Bump() is still preferred due to it not being as high-overhead as something like scanning on Moved(). I'm thinking I'll make Moved() only scan for cases where it needs to hit a non-dense object - a prone human the user clicked on, anything special like that. Don't know the exact specifics yet, which is why this is still WIP.

Projectiles now use check_pierce() to determine if it goes through something and hits it, doesn't hit it, or doesn't go through something at all (should delete self after hitting). Will likely make an on_pierce proc to be called post-piercing something so you can have !fun! things like projectiles that go down in damage after piercing something. This will likely deprecate the process_hit proc, or at least make it less awful.

scan_for_hit() is now used to attempt to hit something and will return whether the projectile got deleted or not. It will delete the projectile if the projectile does hit something and fails to pierce through it.

scan_moved_turf() (WIP) will be used for handling moving onto a turf.

permutated has been renamed to impacted. Ricocheting projectiles get it reset, allowing projectiles to pierce and potentially hit something again if it goes back around.

A new unit test has been added checking for projectiles with movement type of PHASING. This is because PHASING completely causes projectiles to break down as projectiles mainly sense collisions through Bump. The small boost in performance from using PHASING instead of having all pass flags active/overriding check_pierce is in my opinion not worth the extra snowflake in scan_moved_turf() I'd have to do to deal with having to check for hits manually rather than Bump()ing things.
Movement types

UNSTOPPABLE renamed to PHASING to better describe what it is, going through and crossing everything but not actually bumping.
Why It's Good For The Game

Better pass flags handling allows for less proc overrides, bitflag checks are far less expensive in general.

Fixes penetrating projectiles like sniper penetrators

This system also allows for better handling of piercing projectiles (see above) without too much snowflake code, as you'd only need to modify on_pierce() if you needed to do special handling like dampening damage per target pierced, and otherwise you could just use the standardized system and just set pass flags to what's needed. If you really need a projectile that pierces almost everything, override check_pierce(), which is still going to be easier than what was done before (even with snowflake handling of UNSTOPPABLE flag process_hit() was extremely ugly, now we don't rely on movement types at all.)
2020-12-10 09:29:27 +13:00

301 lines
9.0 KiB
Plaintext

/obj/item/seeds/tower
name = "pack of tower-cap mycelium"
desc = "This mycelium grows into tower-cap mushrooms."
icon_state = "mycelium-tower"
species = "towercap"
plantname = "Tower Caps"
product = /obj/item/grown/log
lifespan = 80
endurance = 50
maturation = 15
production = 1
yield = 5
potency = 50
growthstages = 3
growing_icon = 'icons/obj/hydroponics/growing_mushrooms.dmi'
icon_dead = "towercap-dead"
genes = list(/datum/plant_gene/trait/plant_type/fungal_metabolism)
mutatelist = list(/obj/item/seeds/tower/steel)
reagents_add = list(/datum/reagent/cellulose = 0.05)
graft_gene = /datum/plant_gene/trait/plant_type/fungal_metabolism
/obj/item/seeds/tower/steel
name = "pack of steel-cap mycelium"
desc = "This mycelium grows into steel logs."
icon_state = "mycelium-steelcap"
species = "steelcap"
plantname = "Steel Caps"
product = /obj/item/grown/log/steel
mutatelist = list()
reagents_add = list(/datum/reagent/cellulose = 0.05, /datum/reagent/iron = 0.05)
rarity = 20
/obj/item/grown/log
seed = /obj/item/seeds/tower
name = "tower-cap log"
desc = "It's better than bad, it's good!"
icon_state = "logs"
force = 5
throwforce = 5
w_class = WEIGHT_CLASS_NORMAL
throw_speed = 2
throw_range = 3
attack_verb_continuous = list("bashes", "batters", "bludgeons", "whacks")
attack_verb_simple = list("bash", "batter", "bludgeon", "whack")
var/plank_type = /obj/item/stack/sheet/mineral/wood
var/plank_name = "wooden planks"
var/static/list/accepted = typecacheof(list(/obj/item/food/grown/tobacco,
/obj/item/food/grown/tea,
/obj/item/food/grown/ambrosia/vulgaris,
/obj/item/food/grown/ambrosia/deus,
/obj/item/food/grown/wheat))
/obj/item/grown/log/attackby(obj/item/W, mob/user, params)
if(W.get_sharpness())
user.show_message("<span class='notice'>You make [plank_name] out of \the [src]!</span>", MSG_VISUAL)
var/seed_modifier = 0
if(seed)
seed_modifier = round(seed.potency / 25)
var/obj/item/stack/plank = new plank_type(user.loc, 1 + seed_modifier)
var/old_plank_amount = plank.amount
for(var/obj/item/stack/ST in user.loc)
if(ST != plank && istype(ST, plank_type) && ST.amount < ST.max_amount)
ST.attackby(plank, user) //we try to transfer all old unfinished stacks to the new stack we created.
if(plank.amount > old_plank_amount)
to_chat(user, "<span class='notice'>You add the newly-formed [plank_name] to the stack. It now contains [plank.amount] [plank_name].</span>")
qdel(src)
if(CheckAccepted(W))
var/obj/item/food/grown/leaf = W
if(HAS_TRAIT(leaf, TRAIT_DRIED))
user.show_message("<span class='notice'>You wrap \the [W] around the log, turning it into a torch!</span>")
var/obj/item/flashlight/flare/torch/T = new /obj/item/flashlight/flare/torch(user.loc)
usr.dropItemToGround(W)
usr.put_in_active_hand(T)
qdel(leaf)
qdel(src)
return
else
to_chat(usr, "<span class='warning'>You must dry this first!</span>")
else
return ..()
/obj/item/grown/log/proc/CheckAccepted(obj/item/I)
return is_type_in_typecache(I, accepted)
/obj/item/grown/log/tree
seed = null
name = "wood log"
desc = "TIMMMMM-BERRRRRRRRRRR!"
/obj/item/grown/log/steel
seed = /obj/item/seeds/tower/steel
name = "steel-cap log"
desc = "It's made of metal."
icon_state = "steellogs"
plank_type = /obj/item/stack/rods
plank_name = "rods"
/obj/item/grown/log/steel/CheckAccepted(obj/item/I)
return FALSE
/obj/item/seeds/bamboo
name = "pack of bamboo seeds"
desc = "A plant known for its flexible and resistant logs."
icon_state = "seed-bamboo"
species = "bamboo"
plantname = "Bamboo"
product = /obj/item/grown/log/bamboo
lifespan = 80
endurance = 70
maturation = 15
production = 2
yield = 5
potency = 50
growthstages = 2
growing_icon = 'icons/obj/hydroponics/growing.dmi'
icon_dead = "bamboo-dead"
genes = list(/datum/plant_gene/trait/repeated_harvest)
/obj/item/grown/log/bamboo
seed = /obj/item/seeds/bamboo
name = "bamboo log"
desc = "A long and resistant bamboo log."
icon_state = "bamboo"
plank_type = /obj/item/stack/sheet/mineral/bamboo
plank_name = "bamboo sticks"
/obj/item/grown/log/bamboo/CheckAccepted(obj/item/I)
return FALSE
/obj/structure/punji_sticks
name = "punji sticks"
desc = "Don't step on this."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "punji"
resistance_flags = FLAMMABLE
max_integrity = 30
density = FALSE
anchored = TRUE
/obj/structure/punji_sticks/Initialize(mapload)
. = ..()
AddComponent(/datum/component/caltrop, 20, 30, 100, CALTROP_BYPASS_SHOES)
/////////BONFIRES//////////
/obj/structure/bonfire
name = "bonfire"
desc = "For grilling, broiling, charring, smoking, heating, roasting, toasting, simmering, searing, melting, and occasionally burning things."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "bonfire"
light_color = LIGHT_COLOR_FIRE
density = FALSE
anchored = TRUE
buckle_lying = 0
pass_flags_self = PASSTABLE | LETPASSTHROW
var/burning = 0
var/burn_icon = "bonfire_on_fire" //for a softer more burning embers icon, use "bonfire_warm"
var/grill = FALSE
var/fire_stack_strength = 5
/obj/structure/bonfire/dense
density = TRUE
/obj/structure/bonfire/prelit/Initialize()
. = ..()
StartBurning()
/obj/structure/bonfire/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/stack/rods) && !can_buckle && !grill)
var/obj/item/stack/rods/R = W
var/choice = input(user, "What would you like to construct?", "Bonfire") as null|anything in list("Stake","Grill")
switch(choice)
if("Stake")
R.use(1)
can_buckle = TRUE
buckle_requires_restraints = TRUE
to_chat(user, "<span class='notice'>You add a rod to \the [src].</span>")
var/mutable_appearance/rod_underlay = mutable_appearance('icons/obj/hydroponics/equipment.dmi', "bonfire_rod")
rod_underlay.pixel_y = 16
underlays += rod_underlay
if("Grill")
R.use(1)
grill = TRUE
to_chat(user, "<span class='notice'>You add a grill to \the [src].</span>")
add_overlay("bonfire_grill")
else
return ..()
if(W.get_temperature())
StartBurning()
if(grill)
if(user.a_intent != INTENT_HARM && !(W.item_flags & ABSTRACT))
if(user.temporarilyRemoveItemFromInventory(W))
W.forceMove(get_turf(src))
var/list/click_params = params2list(params)
//Center the icon where the user clicked.
if(!click_params || !click_params["icon-x"] || !click_params["icon-y"])
return
//Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf)
W.pixel_x = W.base_pixel_x + clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2)
W.pixel_y = W.base_pixel_y + clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2)
else
return ..()
/obj/structure/bonfire/attack_hand(mob/user)
. = ..()
if(.)
return
if(burning)
to_chat(user, "<span class='warning'>You need to extinguish [src] before removing the logs!</span>")
return
if(!has_buckled_mobs() && do_after(user, 50, target = src))
for(var/obj/item/grown/log/L in contents)
L.forceMove(drop_location())
L.pixel_x += rand(1,4)
L.pixel_y += rand(1,4)
if(can_buckle || grill)
new /obj/item/stack/rods(loc, 1)
qdel(src)
return
/obj/structure/bonfire/proc/CheckOxygen()
if(isopenturf(loc))
var/turf/open/O = loc
if(O.air)
var/loc_gases = O.air.gases
if(loc_gases[/datum/gas/oxygen] && loc_gases[/datum/gas/oxygen][MOLES] >= 5)
return TRUE
return FALSE
/obj/structure/bonfire/proc/StartBurning()
if(!burning && CheckOxygen())
icon_state = burn_icon
burning = TRUE
set_light(6)
Burn()
START_PROCESSING(SSobj, src)
/obj/structure/bonfire/fire_act(exposed_temperature, exposed_volume)
StartBurning()
/obj/structure/bonfire/Crossed(atom/movable/AM)
. = ..()
if(burning & !grill)
Burn()
/obj/structure/bonfire/proc/Burn(delta_time = 2)
var/turf/current_location = get_turf(src)
current_location.hotspot_expose(1000, 250 * delta_time, 1)
for(var/A in current_location)
if(A == src)
continue
if(isobj(A))
var/obj/O = A
O.fire_act(1000, 250 * delta_time)
else if(isliving(A))
var/mob/living/L = A
L.adjust_fire_stacks(fire_stack_strength * 0.5 * delta_time)
L.IgniteMob()
/obj/structure/bonfire/proc/Cook(delta_time = 2)
var/turf/current_location = get_turf(src)
for(var/A in current_location)
if(A == src)
continue
else if(isliving(A)) //It's still a fire, idiot.
var/mob/living/L = A
L.adjust_fire_stacks(fire_stack_strength * 0.5 * delta_time)
L.IgniteMob()
else if(istype(A, /obj/item) && DT_PROB(10, delta_time))
var/obj/item/O = A
O.microwave_act()
/obj/structure/bonfire/process(delta_time)
if(!CheckOxygen())
extinguish()
return
if(!grill)
Burn(delta_time)
else
Cook(delta_time)
/obj/structure/bonfire/extinguish()
if(burning)
icon_state = "bonfire"
burning = 0
set_light(0)
STOP_PROCESSING(SSobj, src)
/obj/structure/bonfire/buckle_mob(mob/living/M, force = FALSE, check_loc = TRUE)
if(..())
M.pixel_y += 13
/obj/structure/bonfire/unbuckle_mob(mob/living/buckled_mob, force=FALSE)
if(..())
buckled_mob.pixel_y -= 13