Advertisement
Whoneedspacee

Untitled

Nov 13th, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.19 KB | None | 0 0
  1. /datum/action/cooldown/charge
  2. name = "Charge"
  3. icon_icon = 'icons/mob/actions/actions_items.dmi'
  4. button_icon_state = "sniper_zoom"
  5. desc = "Allows you to charge at a chosen position."
  6. cooldown_time = 15
  7. text_cooldown = FALSE
  8. click_to_activate = TRUE
  9. shared_cooldown = MOB_SHARED_COOLDOWN
  10. var/charge_delay = 3
  11. var/charge_past = 2
  12. var/charge_speed = 0.7
  13. var/charge_damage = 30
  14. var/destroy_objects = TRUE
  15. var/list/revving_charge = list()
  16. var/list/charging = list()
  17.  
  18. /datum/action/cooldown/charge/New(Target, delay, past, speed, damage, destroy)
  19. . = ..()
  20. if(delay)
  21. charge_delay = delay
  22. if(past)
  23. charge_past = past
  24. if(speed)
  25. charge_speed = speed
  26. if(damage)
  27. charge_damage = damage
  28. if(destroy)
  29. destroy_objects = destroy
  30.  
  31. /datum/action/cooldown/charge/Activate(atom/target_atom)
  32. // start pre-cooldown so that the ability can't come up while the charge is happening
  33. StartCooldown(100)
  34. do_charge(owner, target_atom, charge_delay, charge_past)
  35. StartCooldown()
  36.  
  37. /datum/action/cooldown/charge/proc/do_charge(atom/movable/charger, atom/target_atom, delay, past)
  38. if(!target_atom || target_atom == owner)
  39. return
  40. var/chargeturf = get_turf(target_atom)
  41. if(!chargeturf)
  42. return
  43. charger.setDir(get_dir(charger, target_atom))
  44. var/turf/T = get_ranged_target_turf(chargeturf, charger.dir, past)
  45. if(!T)
  46. return
  47. new /obj/effect/temp_visual/dragon_swoop/bubblegum(T)
  48. revving_charge[charger] = TRUE
  49. charging[charger] = TRUE
  50. RegisterSignal(charger, COMSIG_MOVABLE_BUMP, .proc/on_bump)
  51. RegisterSignal(charger, COMSIG_MOVABLE_PRE_MOVE, .proc/on_move)
  52. RegisterSignal(charger, COMSIG_MOVABLE_MOVED, .proc/on_moved)
  53. DestroySurroundings(charger)
  54. walk(charger, 0)
  55. charger.setDir(get_dir(charger, target_atom))
  56. var/obj/effect/temp_visual/decoy/D = new /obj/effect/temp_visual/decoy(charger.loc, charger)
  57. animate(D, alpha = 0, color = "#FF0000", transform = matrix()*2, time = 3)
  58. SLEEP_CHECK_DEATH(delay, charger)
  59. revving_charge[charger] = FALSE
  60. var/distance = get_dist(charger, T)
  61. for(var/i in 1 to distance)
  62. walk(charger, get_dir(charger, T), charge_speed)
  63. SLEEP_CHECK_DEATH(charge_speed, charger)
  64. /* sometimes on the second charge on bubblegums triple charge he is way behind with this and idk why
  65. walk_towards(charger, T, charge_speed)
  66. SLEEP_CHECK_DEATH(distance * charge_speed, charger) */
  67. walk(charger, 0) // cancel the movement
  68. charging[charger] = FALSE
  69. SEND_SIGNAL(owner, COMSIG_FINISHED_CHARGE)
  70. UnregisterSignal(charger, COMSIG_MOVABLE_BUMP)
  71. UnregisterSignal(charger, COMSIG_MOVABLE_PRE_MOVE)
  72. UnregisterSignal(charger, COMSIG_MOVABLE_MOVED)
  73. return TRUE
  74.  
  75. /datum/action/cooldown/charge/proc/DestroySurroundings(atom/movable/charger)
  76. if(!destroy_objects)
  77. return
  78. for(var/dir in GLOB.cardinals)
  79. var/turf/T = get_step(charger, dir)
  80. if(QDELETED(T))
  81. continue
  82. if(T.Adjacent(charger))
  83. if(iswallturf(T) || ismineralturf(T))
  84. T.attack_animal(charger)
  85. continue
  86. for(var/obj/O in T.contents)
  87. if(!O.Adjacent(charger))
  88. continue
  89. if((ismachinery(O) || isstructure(O)) && O.density && !O.IsObscured())
  90. O.attack_animal(charger)
  91. break
  92.  
  93. /datum/action/cooldown/charge/proc/on_bump(atom/movable/source, atom/A)
  94. if(charging[source])
  95. if(isturf(A) || isobj(A) && A.density)
  96. if(isobj(A))
  97. SSexplosions.med_mov_atom += A
  98. else
  99. SSexplosions.medturf += A
  100. DestroySurroundings()
  101. hit_target(source, A, charge_damage)
  102.  
  103. /datum/action/cooldown/charge/proc/hit_target(atom/movable/source, atom/A, damage_dealt)
  104. if(!isliving(A))
  105. return
  106. var/mob/living/L = A
  107. L.visible_message("<span class='danger'>[source] slams into [L]!</span>", "<span class='userdanger'>[source] tramples you into the ground!</span>")
  108. source.forceMove(get_turf(L))
  109. L.apply_damage(damage_dealt, BRUTE, wound_bonus = CANT_WOUND)
  110. playsound(get_turf(L), 'sound/effects/meteorimpact.ogg', 100, TRUE)
  111. shake_camera(L, 4, 3)
  112. shake_camera(source, 2, 3)
  113.  
  114. /datum/action/cooldown/charge/proc/on_move(atom/source)
  115. if(charging[source])
  116. new /obj/effect/temp_visual/decoy/fading(source.loc, source)
  117. DestroySurroundings(source)
  118. if(revving_charge[source])
  119. return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
  120.  
  121. /datum/action/cooldown/charge/proc/on_moved(atom/source)
  122. if(charging[source])
  123. DestroySurroundings(source)
  124.  
  125. /datum/action/cooldown/charge/triple_charge
  126. name = "Triple Charge"
  127. desc = "Allows you to charge three times at a chosen position."
  128. charge_delay = 6
  129.  
  130. /datum/action/cooldown/charge/triple_charge/Activate(var/atom/target_atom)
  131. StartCooldown(100)
  132. for(var/i in 0 to 2)
  133. do_charge(owner, target_atom, charge_delay - 2 * i, charge_past)
  134. StartCooldown()
  135.  
  136. /datum/action/cooldown/charge/hallucination_charge
  137. name = "Hallucination Charge"
  138. icon_icon = 'icons/effects/bubblegum.dmi'
  139. button_icon_state = "smack ya one"
  140. desc = "Allows you to create hallucinations that charge around your target."
  141. cooldown_time = 20
  142. charge_delay = 6
  143. var/hallucination_damage = 15
  144. var/enraged = FALSE
  145.  
  146. /datum/action/cooldown/charge/hallucination_charge/Activate(var/atom/target_atom)
  147. StartCooldown(100)
  148. if(!enraged)
  149. hallucination_charge(target_atom, 6, 8, 0, 6, TRUE)
  150. StartCooldown(cooldown_time * 0.5)
  151. return
  152. for(var/i in 0 to 2)
  153. hallucination_charge(target_atom, 4, 9 - i, 0, 4, TRUE)
  154. for(var/i in 0 to 2)
  155. do_charge(owner, target_atom, charge_delay - 2 * i, charge_past)
  156. StartCooldown()
  157.  
  158. /datum/action/cooldown/charge/hallucination_charge/do_charge(atom/movable/charger, atom/target_atom, delay, past)
  159. . = ..()
  160. if(charger != owner)
  161. qdel(charger)
  162.  
  163. /datum/action/cooldown/charge/hallucination_charge/proc/hallucination_charge(atom/target_atom, clone_amount, delay, past, radius, use_self)
  164. var/starting_angle = rand(1, 360)
  165. if(!radius)
  166. return
  167. var/angle_difference = 360 / clone_amount
  168. var/self_placed = FALSE
  169. for(var/i = 1 to clone_amount)
  170. var/angle = (starting_angle + angle_difference * i)
  171. var/turf/place = locate(target_atom.x + cos(angle) * radius, target_atom.y + sin(angle) * radius, target_atom.z)
  172. if(!place)
  173. continue
  174. if(use_self && !self_placed)
  175. owner.forceMove(place)
  176. self_placed = TRUE
  177. continue
  178. var/mob/living/simple_animal/hostile/megafauna/bubblegum/hallucination/B = new /mob/living/simple_animal/hostile/megafauna/bubblegum/hallucination(place)
  179. INVOKE_ASYNC(src, .proc/do_charge, B, target_atom, delay, past)
  180. if(use_self)
  181. do_charge(owner, target_atom, delay, past)
  182.  
  183. /datum/action/cooldown/charge/hallucination_charge/hit_target(atom/movable/source, atom/A, damage_dealt)
  184. var/applied_damage = charge_damage
  185. if(source != owner)
  186. applied_damage = hallucination_damage
  187. . = ..(source, A, applied_damage)
  188.  
  189. /datum/action/cooldown/charge/hallucination_charge/hallucination_surround
  190. name = "Surround Target"
  191. icon_icon = 'icons/turf/walls/wall.dmi'
  192. button_icon_state = "wall-0"
  193. desc = "Allows you to create hallucinations that charge around your target."
  194. charge_delay = 6
  195. charge_past = 2
  196.  
  197. /datum/action/cooldown/charge/hallucination_charge/hallucination_surround/Activate(var/atom/target_atom)
  198. StartCooldown(100)
  199. for(var/i in 1 to 5)
  200. hallucination_charge(target_atom, 2, 8, 2, 2, FALSE)
  201. do_charge(owner, target_atom, charge_delay, charge_past)
  202. StartCooldown()
  203.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement