Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define OPEN 1
- #define CLOSED 0
- #define SCREWSHUT 3
- /obj/structure/shipsystem
- name = "system"
- desc = "..This shouldn't be here. What have you done?"
- density = 1
- anchored = 1
- icon = 'StarTrek13/icons/trek/subsystem_parts.dmi'
- icon_state = "system"
- var/basestate = "system"
- verb_say = "states"
- verb_yell = "blares"
- var/heat = 0
- var/heat_max_threshhold = 10000
- var/maximum_integrity = 1000
- var/integrity
- var/efficiency = 60 // 1 - 100, it's a percentage. If this hits zero, it's going to heat up like one crazy motherfucker
- var/active
- var/failed
- var/panel = SCREWSHUT
- var/repair_stage = 0
- var/brute_damage = 0//Damage that can be repaired by a welder
- var/electric_damage = 0//Damage that can be repaired by wiring (NOTABLY harder to repair, because of a higher skill requirement)
- /obj/structure/shipsystem/New()
- ..()
- integrity = maximum_integrity
- START_PROCESSING(SSobj, src)
- start()
- /obj/structure/shipsystem/update_icon()
- overlays = null
- icon_state = "[basestate]"
- if(active)
- icon_state = "[icon_state]_active"
- if(panel == OPEN)
- overlays += "panel_open"
- /obj/structure/shipsystem/process()
- if(integrity < 0 || heat > heat_max_threshhold && active)
- fail()
- if(active)
- var/heat_gained = 100/efficiency
- if(prob(60))
- heat += heat_gained
- else
- heat--
- /obj/structure/shipsystem/proc/fail()
- active = FALSE
- failed = TRUE
- panel = OPEN
- //STOP_PROCESSING(SSobj, src)
- visible_message("<span class='warning'>The [src] blinks out as sparks spray out!</span>")
- var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
- s.set_up(3, 1, src)
- s.start()
- playsound(src,'sound/effects/sparks4.ogg',50,1)
- update_icon()
- /obj/structure/shipsystem/proc/start()
- active = TRUE
- say("Initializing systems..")
- update_icon()
- /obj/structure/shipsystem/proc/damage(var/damage, var/damtype = "BRUTE", var/modifier = 1)
- if(failed || integrity <= 0)
- return
- if(panel == OPEN)
- modifier++
- if(repair_stage > 1)
- modifier ++
- damage = damage*modifier
- var/end_result = integrity - damage
- if(end_result < 0)
- damage = damage + end_result
- integrity -= damage
- if(damtype == "BRUTE")
- brute_damage += damage
- if(damtype == "BURN")
- electric_damage += damage
- /obj/structure/shipsystem/examine(var/mob/user)
- ..()
- if(panel == CLOSED || panel == SCREWSHUT)
- to_chat(user, "The panel is <b>closed</b>.")
- else
- to_chat(user, "The panel is <b>open</b>.")
- if(panel == OPEN)
- var/datum/skill/skill = user.skills.getskill("construction and maintenance")
- if(skill.value > 2)
- switch(brute_damage)
- if(0)
- to_chat(user, "<span class='info'>The interior structuring of [src] appears fine.</span>")
- if(1 to maximum_integrity*0.20)
- to_chat(user, "<span class='usrdanger'>The internal structuring looks dented.</span>")
- if(maximum_integrity*0.21 to maximum_integrity*0.61)
- to_chat(user, "<span class='usrdanger'>The internal structuring looks damaged.</span>")
- if(maximum_integrity*0.61 to INFINITY)
- to_chat(user, "<span class='usrdanger'>The internal structuring looks severely damaged!.</span>")
- if(!skill.value > 4)
- switch(electric_damage)
- if(0)
- to_chat(user, "<span class='info'>The interior wiring of [src] appears fine.</span>")
- if(1 to maximum_integrity*0.20)
- to_chat(user, "<span class='userdanger'>The internal structuring looks dented.</span>")
- if(maximum_integrity*0.21 to maximum_integrity*0.61)
- to_chat(user, "<span class='userdanger'>The internal structuring looks damaged.</span>")
- if(maximum_integrity*0.61 to INFINITY)
- to_chat(user, "<span class='userdanger'>The internal structuring looks severely damaged!.</span>")
- /obj/structure/shipsystem/attack_hand(var/mob/user)
- add_fingerprint(user)
- switch(panel)
- if(SCREWSHUT)
- to_chat(user, "<span class='userdanger'>[src]'s panel is screwed shut.</span>")
- if(CLOSED)
- to_chat(user, "<span class='info'>You open the [src]'s panel.</span>")
- panel = OPEN
- update_icon()
- return
- if(OPEN)
- to_chat(user, "<span class='info'>You close the [src]'s panel.</span>")
- panel = CLOSED
- update_icon()
- /obj/structure/shipsystem/attackby(var/obj/item/P, var/mob/user)//if(!do_after(user, 10, target = src))
- if(user.a_intent == INTENT_HARM)
- return ..()
- if(istype(P, /obj/item/screwdriver))
- if(panel == OPEN)
- to_chat(user, "<span class='userdanger'>Close the panel before attempting to screw it closed!</span>")
- return //Change me if the screwdriver is later required in repairing
- to_chat(user, "<span class='info'>You [panel ? "un" : ""]screw the panel[panel ? " in." : "."]</span>")
- playsound(src.loc, P.usesound, 50, 1)
- if(panel == SCREWSHUT)
- to_chat(user, "<span class='info'>You unscrew the panel.</span>")
- panel = CLOSED
- return
- panel = SCREWSHUT
- return
- if(istype(P, /obj/item/wirecutters))
- if(panel == CLOSED || panel == SCREWSHUT)
- //attempt to activate
- if(!failed)
- playsound(src.loc, P.usesound, 50, 1)
- if(!active)
- start()
- active = !active
- to_chat(user, "<span class='info'>You [active ? "deactivate" : "activate"] [src].</span>")
- update_icon()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement