/* This is an attempt to make some easily reusable "particle" type effect, to stop the code constantly having to be rewritten. An item like the jetpack that uses the ion_trail_follow system, just has one defined, then set up when it is created with New(). Then this same system can just be reused each time it needs to create more trails.A beaker could have a steam_trail_follow system set up, then the steam would spawn and follow the beaker, even if it is carried or thrown. */ /obj/effect/effect name = "effect" icon = 'icons/effects/effects.dmi' mouse_opacity = 0 unacidable = 1//So effect are not targeted by alien acid. /obj/effect/effect/New() ..() if(ticker) cameranet.updateVisibility(src) /obj/effect/effect/Destroy() if(ticker) cameranet.updateVisibility(src) return ..() /datum/effect/proc/fadeOut(var/atom/A, var/frames = 16) if(A.alpha == 0) //Handle already transparent case return if(frames == 0) frames = 1 //We will just assume that by 0 frames, the coder meant "during one frame". var/step = A.alpha / frames for(var/i = 0, i < frames, i++) A.alpha -= step sleep(world.tick_lag) return /obj/effect/effect/water name = "water" icon = 'icons/effects/effects.dmi' icon_state = "extinguish" var/life = 15.0 mouse_opacity = 0 /obj/effect/effect/smoke name = "smoke" icon = 'icons/effects/water.dmi' icon_state = "smoke" opacity = 1 anchored = 0.0 mouse_opacity = 0 var/amount = 8.0 /obj/effect/proc/delete() qdel(src) /obj/effect/effect/water/New() ..() //var/turf/T = src.loc //if(istype(T, /turf)) // T.firelevel = 0 //TODO: FIX spawn( 70 ) delete() return return /obj/effect/effect/water/Move(turf/newloc) //var/turf/T = src.loc //if(istype(T, /turf)) // T.firelevel = 0 //TODO: FIX if(--src.life < 1) //SN src = null delete() if(newloc.density) return 0 .=..() /obj/effect/effect/water/Bump(atom/A) if(reagents) reagents.reaction(A) if(istype(A,/atom/movable)) var/atom/movable/AM = A AM.water_act(life, 310.15, src) return ..() /datum/effect/system var/number = 3 var/cardinals = 0 var/turf/location var/atom/holder var/setup = 0 Destroy() holder = null location = null return ..() proc/set_up(n = 3, c = 0, turf/loc) if(n > 10) n = 10 number = n cardinals = c location = loc setup = 1 proc/attach(atom/atom) holder = atom proc/start() ///////////////////////////////////////////// // GENERIC STEAM SPREAD SYSTEM //Usage: set_up(number of bits of steam, use North/South/East/West only, spawn location) // The attach(atom/atom) proc is optional, and can be called to attach the effect // to something, like a smoking beaker, so then you can just call start() and the steam // will always spawn at the items location, even if it's moved. /* Example: var/datum/effect/system/steam_spread/steam = new /datum/effect/system/steam_spread() -- creates new system steam.set_up(5, 0, mob.loc) -- sets up variables OPTIONAL: steam.attach(mob) steam.start() -- spawns the effect */ ///////////////////////////////////////////// /obj/effect/effect/steam name = "steam" icon = 'icons/effects/effects.dmi' icon_state = "extinguish" density = 0 /datum/effect/system/steam_spread set_up(n = 3, c = 0, turf/loc) if(n > 10) n = 10 number = n cardinals = c location = loc start() var/i = 0 for(i=0, i 10) n = 10 number = n cardinals = c if(istype(loca, /turf/)) location = loca else location = get_turf(loca) start() var/i = 0 for(i=0, i 20) return spawn(0) if(holder) src.location = get_turf(holder) var/obj/effect/effect/sparks/sparks = new /obj/effect/effect/sparks(src.location) src.total_sparks++ var/direction if(src.cardinals) direction = pick(cardinal) else direction = pick(alldirs) for(i=0, i 10) n = 10 number = n cardinals = c if(istype(loca, /turf/)) location = loca else location = get_turf(loca) if(direct) direction = direct start() var/i = 0 for(i=0, i 20) return spawn(0) if(holder) src.location = get_turf(holder) var/obj/effect/effect/harmless_smoke/smoke = new /obj/effect/effect/harmless_smoke(src.location) src.total_smoke++ var/direction = src.direction if(!direction) if(src.cardinals) direction = pick(cardinal) else direction = pick(alldirs) for(i=0, i 20) n = 20 number = n cardinals = c if(istype(loca, /turf/)) location = loca else location = get_turf(loca) if(direct) direction = direct start() var/i = 0 for(i=0, i 20) return spawn(0) if(holder) src.location = get_turf(holder) var/obj/effect/effect/bad_smoke/smoke = new /obj/effect/effect/bad_smoke(src.location) src.total_smoke++ var/direction = src.direction if(!direction) if(src.cardinals) direction = pick(cardinal) else direction = pick(alldirs) for(i=0, i 20) n = 20 number = n cardinals = c carry.copy_to(chemholder, carry.total_volume) if(istype(loca, /turf/)) location = loca else location = get_turf(loca) if(direct) direction = direct if(!silent) var/contained = "" for(var/reagent in carry.reagent_list) contained += " [reagent] " if(contained) contained = "\[[contained]\]" var/area/A = get_area(location) var/where = "[A.name] | [location.x], [location.y]" var/whereLink = "[where]" if(carry && carry.my_atom) if(carry.my_atom.fingerprintslast) var/mob/M = get_mob_by_key(carry.my_atom.fingerprintslast) var/more = "" if(M) more = " " msg_admin_attack("A chemical smoke reaction has taken place in ([whereLink])[contained]. Last associated key is [carry.my_atom.fingerprintslast][more].", 0, 1) log_game("A chemical smoke reaction has taken place in ([where])[contained]. Last associated key is [carry.my_atom.fingerprintslast].") else msg_admin_attack("A chemical smoke reaction has taken place in ([whereLink]). No associated key.", 0, 1) log_game("A chemical smoke reaction has taken place in ([where])[contained]. No associated key.") else msg_admin_attack("A chemical smoke reaction has taken place in ([whereLink]). No associated key. CODERS: carry.my_atom may be null.", 0, 1) log_game("A chemical smoke reaction has taken place in ([where])[contained]. No associated key. CODERS: carry.my_atom may be null.") start(effect_range = 2) var/i = 0 var/color = mix_color_from_reagents(chemholder.reagents.reagent_list) var/obj/effect/effect/chem_smoke/smokeholder = new /obj/effect/effect/chem_smoke(src.location) for(var/atom/A in view(effect_range, smokeholder)) chemholder.reagents.reaction(A) if(iscarbon(A)) var/mob/living/carbon/C = A if(C.can_breathe_gas()) chemholder.reagents.copy_to(C, chemholder.reagents.total_volume) if(istype(A, /obj/machinery/portable_atmospherics/hydroponics)) var/obj/machinery/portable_atmospherics/hydroponics/tray = A chemholder.reagents.copy_to(tray, chemholder.reagents.total_volume) if(istype(A, /obj/effect/plant)) var/obj/effect/plant/plant = A if(chemholder.reagents.has_reagent("atrazine")) plant.die_off() qdel(smokeholder) for(i=0, i 20) return spawn(0) if(holder) src.location = get_turf(holder) var/obj/effect/effect/chem_smoke/smoke = new /obj/effect/effect/chem_smoke(src.location) src.total_smoke++ var/direction = src.direction if(!direction) if(src.cardinals) direction = pick(cardinal) else direction = pick(alldirs) if(color) smoke.icon += color // give the smoke color, if it has any to begin with else // if no color, just use the old smoke icon smoke.icon = 'icons/effects/96x96.dmi' smoke.icon_state = "smoke" for(i=0, i 20) n = 20 number = n cardinals = c if(istype(loca, /turf/)) location = loca else location = get_turf(loca) if(direct) direction = direct start() var/i = 0 for(i=0, i 20) return spawn(0) if(holder) src.location = get_turf(holder) var/obj/effect/effect/sleep_smoke/smoke = new /obj/effect/effect/sleep_smoke(src.location) src.total_smoke++ var/direction = src.direction if(!direction) if(src.cardinals) direction = pick(cardinal) else direction = pick(alldirs) for(i=0, i 20) n = 20 number = n cardinals = c if(istype(loca, /turf/)) location = loca else location = get_turf(loca) if(direct) direction = direct start() var/i = 0 for(i=0, i 20) return spawn(0) if(holder) src.location = get_turf(holder) var/obj/effect/effect/mustard_gas/smoke = new /obj/effect/effect/mustard_gas(src.location) src.total_smoke++ var/direction = src.direction if(!direction) if(src.cardinals) direction = pick(cardinal) else direction = pick(alldirs) for(i=0, i[user] smashes through \the [src].", "You smash through \the [src].") qdel(src) else to_chat(user, "You hit the metal foam but bounce off it.") /obj/structure/foamedmetal/attackby(var/obj/item/I, var/mob/user, params) user.changeNext_move(CLICK_CD_MELEE) user.do_attack_animation(src) if(istype(I, /obj/item/weapon/grab)) var/obj/item/weapon/grab/G = I G.affecting.loc = src.loc user.visible_message("[G.assailant] smashes [G.affecting] through the foamed metal wall.") qdel(I) qdel(src) return if(prob(I.force*20 - metal*25)) user.visible_message("[user] smashes through the foamed metal with \the [I].", "You smash through the foamed metal with \the [I].") qdel(src) else to_chat(user, "You hit the metal foam to no effect.") /obj/structure/foamedmetal/attack_animal(mob/living/simple_animal/M) M.do_attack_animation(src) if(M.melee_damage_upper == 0) M.visible_message("[M] nudges \the [src].") else if(M.attack_sound) playsound(loc, M.attack_sound, 50, 1, 1) M.visible_message("\The [M] [M.attacktext] [src]!") qdel(src) /obj/structure/foamedmetal/attack_alien(mob/living/carbon/alien/humanoid/M) M.visible_message("[M] tears apart \the [src]!"); qdel(src) /obj/structure/foamedmetal/CanPass(atom/movable/mover, turf/target, height=1.5, air_group = 0) if(air_group) return 0 return !density /obj/structure/foamedmetal/CanAtmosPass() return !density /datum/effect/system/reagents_explosion var/amount // TNT equivalent var/flashing = 0 // does explosion creates flash effect? var/flashing_factor = 0 // factor of how powerful the flash effect relatively to the explosion set_up (amt, loc, flash = 0, flash_fact = 0) amount = amt if(istype(loc, /turf/)) location = loc else location = get_turf(loc) flashing = flash flashing_factor = flash_fact return start() if(amount <= 2) var/datum/effect/system/spark_spread/s = new /datum/effect/system/spark_spread s.set_up(2, 1, location) s.start() for(var/mob/M in viewers(5, location)) to_chat(M, "\red The solution violently explodes.") for(var/mob/M in viewers(1, location)) if(prob (50 * amount)) to_chat(M, "\red The explosion knocks you down.") M.Weaken(rand(1,5)) return else var/devastation = -1 var/heavy = -1 var/light = -1 var/flash = -1 // Clamp all values to MAX_EXPLOSION_RANGE if(round(amount/12) > 0) devastation = min (MAX_EX_DEVESTATION_RANGE, devastation + round(amount/12)) if(round(amount/6) > 0) heavy = min (MAX_EX_HEAVY_RANGE, heavy + round(amount/6)) if(round(amount/3) > 0) light = min (MAX_EX_LIGHT_RANGE, light + round(amount/3)) if(flash && flashing_factor) flash += (round(amount/4) * flashing_factor) for(var/mob/M in viewers(8, location)) to_chat(M, "\red The solution violently explodes.") explosion(location, devastation, heavy, light, flash) proc/holder_damage(var/atom/holder) if(holder) var/dmglevel = 4 if(round(amount/8) > 0) dmglevel = 1 else if(round(amount/4) > 0) dmglevel = 2 else if(round(amount/2) > 0) dmglevel = 3 if(dmglevel<4) holder.ex_act(dmglevel) ////////////////////////////////// //////SPARKLE FIREWORKS ///////////////////////////////// //////////////////////////// /obj/effect/sparkles name = "sparkle" icon = 'icons/obj/fireworks.dmi'//findback icon_state = "sparkel" var/amount = 6.0 anchored = 1.0 mouse_opacity = 0 /obj/effect/sparkles/New() ..() var/icon/I = new(src.icon,src.icon_state) var/r = rand(0,255) var/g = rand(0,255) var/b = rand(0,255) log_to_dd("Colour , [r],[g],[b]") I.Blend(rgb(r,g,b),ICON_MULTIPLY) src.icon = I playsound(src.loc, "sparks", 100, 1) var/turf/T = src.loc if(istype(T, /turf)) T.hotspot_expose(3000,100) spawn (100) qdel(src) return /obj/effect/sparkles/Destroy() var/turf/T = src.loc if(istype(T, /turf)) T.hotspot_expose(3000,100) return ..() /obj/effect/sparkles/Move() ..() var/turf/T = src.loc if(istype(T, /turf)) T.hotspot_expose(3000,100) return /datum/effect/system/sparkle_spread var/total_sparks = 0 // To stop it being spammed and lagging! /datum/effect/system/sparkle_spread/set_up(n = 3, c = 0, loca) if(n > 10) n = 10 number = n cardinals = c if(istype(loca, /turf/)) location = loca else location = get_turf(loca) /datum/effect/system/sparkle_spread/start() var/i = 0 for(i=0, i 20) return spawn(0) if(holder) src.location = get_turf(holder) var/obj/effect/sparkles/sparks = new(src.location) src.total_sparks++ var/direction if(src.cardinals) direction = pick(cardinal) else direction = pick(alldirs) for(i=0, i