Files
Bubberstation/code/game/objects/items/weapons/flamethrower.dm
phil235 5f835bfc26 Obj damaging system, acid damage, and fire damage refactor (WIP) (#20793)
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
2016-10-10 11:14:59 +13:00

242 lines
6.9 KiB
Plaintext

/obj/item/weapon/flamethrower
name = "flamethrower"
desc = "You are a firestarter!"
icon = 'icons/obj/flamethrower.dmi'
icon_state = "flamethrowerbase"
item_state = "flamethrower_0"
flags = CONDUCT
force = 3
throwforce = 10
throw_speed = 1
throw_range = 5
w_class = 3
materials = list(MAT_METAL=500)
origin_tech = "combat=1;plasmatech=2;engineering=2"
resistance_flags = FIRE_PROOF
var/status = 0
var/throw_amount = 100
var/lit = 0 //on or off
var/operating = 0//cooldown
var/obj/item/weapon/weldingtool/weldtool = null
var/obj/item/device/assembly/igniter/igniter = null
var/obj/item/weapon/tank/internals/plasma/ptank = null
var/warned_admins = 0 //for the message_admins() when lit
/obj/item/weapon/flamethrower/Destroy()
if(weldtool)
qdel(weldtool)
if(igniter)
qdel(igniter)
if(ptank)
qdel(ptank)
return ..()
/obj/item/weapon/flamethrower/process()
if(!lit)
STOP_PROCESSING(SSobj, src)
return null
var/turf/location = loc
if(istype(location, /mob/))
var/mob/M = location
if(M.is_holding(src))
location = M.loc
if(isturf(location)) //start a fire if possible
location.hotspot_expose(700, 2)
return
/obj/item/weapon/flamethrower/update_icon()
cut_overlays()
if(igniter)
add_overlay("+igniter[status]")
if(ptank)
add_overlay("+ptank")
if(lit)
add_overlay("+lit")
item_state = "flamethrower_1"
else
item_state = "flamethrower_0"
return
/obj/item/weapon/flamethrower/afterattack(atom/target, mob/user, flag)
if(flag) return // too close
// Make sure our user is still holding us
if(user && user.get_active_held_item() == src)
var/turf/target_turf = get_turf(target)
if(target_turf)
var/turflist = getline(user, target_turf)
add_logs(user, target, "flamethrowered", src)
flame_turf(turflist)
/obj/item/weapon/flamethrower/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/weapon/wrench) && !status)//Taking this apart
var/turf/T = get_turf(src)
if(weldtool)
weldtool.loc = T
weldtool = null
if(igniter)
igniter.loc = T
igniter = null
if(ptank)
ptank.loc = T
ptank = null
new /obj/item/stack/rods(T)
qdel(src)
return
else if(istype(W, /obj/item/weapon/screwdriver) && igniter && !lit)
status = !status
user << "<span class='notice'>[igniter] is now [status ? "secured" : "unsecured"]!</span>"
update_icon()
return
else if(isigniter(W))
var/obj/item/device/assembly/igniter/I = W
if(I.secured)
return
if(igniter)
return
if(!user.unEquip(W))
return
I.loc = src
igniter = I
update_icon()
return
else if(istype(W,/obj/item/weapon/tank/internals/plasma))
if(ptank)
user << "<span class='notice'>There is already a plasma tank loaded in [src]!</span>"
return
if(!user.unEquip(W))
return
ptank = W
W.loc = src
update_icon()
return
else if(istype(W, /obj/item/device/analyzer) && ptank)
atmosanalyzer_scan(ptank.air_contents, user)
else
return ..()
/obj/item/weapon/flamethrower/attack_self(mob/user)
if(user.stat || user.restrained() || user.lying)
return
user.set_machine(src)
if(!ptank)
user << "<span class='notice'>Attach a plasma tank first!</span>"
return
var/dat = text("<TT><B>Flamethrower (<A HREF='?src=\ref[src];light=1'>[lit ? "<font color='red'>Lit</font>" : "Unlit"]</a>)</B><BR>\n Tank Pressure: [ptank.air_contents.return_pressure()]<BR>\nAmount to throw: <A HREF='?src=\ref[src];amount=-100'>-</A> <A HREF='?src=\ref[src];amount=-10'>-</A> <A HREF='?src=\ref[src];amount=-1'>-</A> [throw_amount] <A HREF='?src=\ref[src];amount=1'>+</A> <A HREF='?src=\ref[src];amount=10'>+</A> <A HREF='?src=\ref[src];amount=100'>+</A><BR>\n<A HREF='?src=\ref[src];remove=1'>Remove plasmatank</A> - <A HREF='?src=\ref[src];close=1'>Close</A></TT>")
user << browse(dat, "window=flamethrower;size=600x300")
onclose(user, "flamethrower")
return
/obj/item/weapon/flamethrower/Topic(href,href_list[])
if(href_list["close"])
usr.unset_machine()
usr << browse(null, "window=flamethrower")
return
if(usr.stat || usr.restrained() || usr.lying)
return
usr.set_machine(src)
if(href_list["light"])
if(!ptank)
return
if(!status)
return
lit = !lit
if(lit)
START_PROCESSING(SSobj, src)
if(!warned_admins)
message_admins("[key_name_admin(usr)]<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A> (<A HREF='?_src_=holder;adminplayerobservefollow=\ref[usr]'>FLW</A>) has lit a flamethrower.")
warned_admins = 1
if(href_list["amount"])
throw_amount = throw_amount + text2num(href_list["amount"])
throw_amount = max(50, min(5000, throw_amount))
if(href_list["remove"])
if(!ptank)
return
usr.put_in_hands(ptank)
ptank = null
lit = 0
usr.unset_machine()
usr << browse(null, "window=flamethrower")
for(var/mob/M in viewers(1, loc))
if((M.client && M.machine == src))
attack_self(M)
update_icon()
return
/obj/item/weapon/flamethrower/CheckParts(list/parts_list)
..()
weldtool = locate(/obj/item/weapon/weldingtool) in contents
igniter = locate(/obj/item/device/assembly/igniter) in contents
weldtool.status = 0
igniter.secured = 0
status = 1
update_icon()
//Called from turf.dm turf/dblclick
/obj/item/weapon/flamethrower/proc/flame_turf(turflist)
if(!lit || operating)
return
operating = 1
var/turf/previousturf = get_turf(src)
for(var/turf/T in turflist)
if(T == previousturf)
continue //so we don't burn the tile we be standin on
if(!T.CanAtmosPass(previousturf))
break
ignite_turf(T)
sleep(1)
previousturf = T
operating = 0
for(var/mob/M in viewers(1, loc))
if((M.client && M.machine == src))
attack_self(M)
return
/obj/item/weapon/flamethrower/proc/ignite_turf(turf/target, release_amount = 0.05)
//TODO: DEFERRED Consider checking to make sure tank pressure is high enough before doing this...
//Transfer 5% of current tank air contents to turf
var/datum/gas_mixture/air_transfer = ptank.air_contents.remove_ratio(release_amount)
if(air_transfer.gases["plasma"])
air_transfer.gases["plasma"][MOLES] *= 5
target.assume_air(air_transfer)
//Burn it based on transfered gas
target.hotspot_expose((ptank.air_contents.temperature*2) + 380,500)
//location.hotspot_expose(1000,500,1)
SSair.add_to_active(target, 0)
return
/obj/item/weapon/flamethrower/full/New(var/loc)
..()
if(!weldtool)
weldtool = new /obj/item/weapon/weldingtool(src)
weldtool.status = 0
if(!igniter)
igniter = new /obj/item/device/assembly/igniter(src)
igniter.secured = 0
status = 1
update_icon()
/obj/item/weapon/flamethrower/full/tank/New(var/loc)
..()
ptank = new /obj/item/weapon/tank/internals/plasma/full(src)
update_icon()
/obj/item/weapon/flamethrower/hit_reaction(mob/living/carbon/human/owner, attack_text, final_block_chance, damage, attack_type)
if(ptank && damage && attack_type == PROJECTILE_ATTACK && prob(15))
owner.visible_message("<span class='danger'>[attack_text] hits the fueltank on [owner]'s [src], rupturing it! What a shot!</span>")
var/target_turf = get_turf(owner)
ignite_turf(target_turf, 100)
qdel(ptank)
return 1 //It hit the flamethrower, not them