Advertisement
Cdey78

Untitled

Jun 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. #define OPEN 1
  2. #define CLOSED 0
  3. #define SCREWSHUT 3
  4.  
  5. /obj/structure/shipsystem
  6. name = "system"
  7. desc = "..This shouldn't be here. What have you done?"
  8. density = 1
  9. anchored = 1
  10.  
  11. icon = 'StarTrek13/icons/trek/subsystem_parts.dmi'
  12. icon_state = "system"
  13. var/basestate = "system"
  14.  
  15. verb_say = "states"
  16. verb_yell = "blares"
  17.  
  18. var/heat = 0
  19. var/heat_max_threshhold = 10000
  20. var/maximum_integrity = 1000
  21. var/integrity
  22. var/efficiency = 60 // 1 - 100, it's a percentage. If this hits zero, it's going to heat up like one crazy motherfucker
  23. var/active
  24. var/failed
  25.  
  26. var/panel = SCREWSHUT
  27. var/repair_stage = 0
  28. var/brute_damage = 0//Damage that can be repaired by a welder
  29. var/electric_damage = 0//Damage that can be repaired by wiring (NOTABLY harder to repair, because of a higher skill requirement)
  30.  
  31. /obj/structure/shipsystem/New()
  32. ..()
  33. integrity = maximum_integrity
  34. START_PROCESSING(SSobj, src)
  35. start()
  36.  
  37. /obj/structure/shipsystem/update_icon()
  38. overlays = null
  39. icon_state = "[basestate]"
  40. if(active)
  41. icon_state = "[icon_state]_active"
  42. if(panel == OPEN)
  43. overlays += "panel_open"
  44.  
  45. /obj/structure/shipsystem/process()
  46. if(integrity < 0 || heat > heat_max_threshhold && active)
  47. fail()
  48.  
  49. if(active)
  50. var/heat_gained = 100/efficiency
  51. if(prob(60))
  52. heat += heat_gained
  53. else
  54. heat--
  55.  
  56. /obj/structure/shipsystem/proc/fail()
  57. active = FALSE
  58. failed = TRUE
  59. panel = OPEN
  60. //STOP_PROCESSING(SSobj, src)
  61. visible_message("<span class='warning'>The [src] blinks out as sparks spray out!</span>")
  62. var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
  63. s.set_up(3, 1, src)
  64. s.start()
  65. playsound(src,'sound/effects/sparks4.ogg',50,1)
  66. update_icon()
  67.  
  68. /obj/structure/shipsystem/proc/start()
  69. active = TRUE
  70. say("Initializing systems..")
  71. update_icon()
  72.  
  73. /obj/structure/shipsystem/proc/damage(var/damage, var/damtype = "BRUTE", var/modifier = 1)
  74. if(failed || integrity <= 0)
  75. return
  76.  
  77. if(panel == OPEN)
  78. modifier++
  79. if(repair_stage > 1)
  80. modifier ++
  81. damage = damage*modifier
  82.  
  83. var/end_result = integrity - damage
  84. if(end_result < 0)
  85. damage = damage + end_result
  86. integrity -= damage
  87.  
  88. if(damtype == "BRUTE")
  89. brute_damage += damage
  90. if(damtype == "BURN")
  91. electric_damage += damage
  92.  
  93. /obj/structure/shipsystem/examine(var/mob/user)
  94. ..()
  95.  
  96. if(panel == CLOSED || panel == SCREWSHUT)
  97. to_chat(user, "The panel is <b>closed</b>.")
  98. else
  99. to_chat(user, "The panel is <b>open</b>.")
  100. if(panel == OPEN)
  101. var/datum/skill/skill = user.skills.getskill("construction and maintenance")
  102. if(skill.value > 2)
  103. switch(brute_damage)
  104. if(0)
  105. to_chat(user, "<span class='info'>The interior structuring of [src] appears fine.</span>")
  106. if(1 to maximum_integrity*0.20)
  107. to_chat(user, "<span class='usrdanger'>The internal structuring looks dented.</span>")
  108. if(maximum_integrity*0.21 to maximum_integrity*0.61)
  109. to_chat(user, "<span class='usrdanger'>The internal structuring looks damaged.</span>")
  110. if(maximum_integrity*0.61 to INFINITY)
  111. to_chat(user, "<span class='usrdanger'>The internal structuring looks severely damaged!.</span>")
  112. if(!skill.value > 4)
  113. switch(electric_damage)
  114. if(0)
  115. to_chat(user, "<span class='info'>The interior wiring of [src] appears fine.</span>")
  116. if(1 to maximum_integrity*0.20)
  117. to_chat(user, "<span class='userdanger'>The internal structuring looks dented.</span>")
  118. if(maximum_integrity*0.21 to maximum_integrity*0.61)
  119. to_chat(user, "<span class='userdanger'>The internal structuring looks damaged.</span>")
  120. if(maximum_integrity*0.61 to INFINITY)
  121. to_chat(user, "<span class='userdanger'>The internal structuring looks severely damaged!.</span>")
  122.  
  123. /obj/structure/shipsystem/attack_hand(var/mob/user)
  124. add_fingerprint(user)
  125. switch(panel)
  126. if(SCREWSHUT)
  127. to_chat(user, "<span class='userdanger'>[src]'s panel is screwed shut.</span>")
  128. if(CLOSED)
  129. to_chat(user, "<span class='info'>You open the [src]'s panel.</span>")
  130. panel = OPEN
  131. update_icon()
  132. return
  133. if(OPEN)
  134. to_chat(user, "<span class='info'>You close the [src]'s panel.</span>")
  135. panel = CLOSED
  136. update_icon()
  137.  
  138.  
  139. /obj/structure/shipsystem/attackby(var/obj/item/P, var/mob/user)//if(!do_after(user, 10, target = src))
  140. if(user.a_intent == INTENT_HARM)
  141. return ..()
  142.  
  143. if(istype(P, /obj/item/screwdriver))
  144. if(panel == OPEN)
  145. to_chat(user, "<span class='userdanger'>Close the panel before attempting to screw it closed!</span>")
  146. return //Change me if the screwdriver is later required in repairing
  147. to_chat(user, "<span class='info'>You [panel ? "un" : ""]screw the panel[panel ? " in." : "."]</span>")
  148. playsound(src.loc, P.usesound, 50, 1)
  149. if(panel == SCREWSHUT)
  150. to_chat(user, "<span class='info'>You unscrew the panel.</span>")
  151. panel = CLOSED
  152. return
  153. panel = SCREWSHUT
  154. return
  155.  
  156. if(istype(P, /obj/item/wirecutters))
  157. if(panel == CLOSED || panel == SCREWSHUT)
  158. //attempt to activate
  159. if(!failed)
  160. playsound(src.loc, P.usesound, 50, 1)
  161. if(!active)
  162. start()
  163. active = !active
  164. to_chat(user, "<span class='info'>You [active ? "deactivate" : "activate"] [src].</span>")
  165. update_icon()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement