diff --git a/code/WorkInProgress/Cael_Aislinn/Rust/gyrotron.dm b/code/WorkInProgress/Cael_Aislinn/Rust/gyrotron.dm index f375716b21e..3bb8a9bda9e 100644 --- a/code/WorkInProgress/Cael_Aislinn/Rust/gyrotron.dm +++ b/code/WorkInProgress/Cael_Aislinn/Rust/gyrotron.dm @@ -114,12 +114,10 @@ A.fired() */ proc/Emit() - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) + var/obj/item/projectile/beam/emitter/A = getFromPool(/obj/item/projectile/beam/emitter, loc) A.frequency = frequency A.damage = mega_energy * 500 - // - A.icon_state = "emitter" - playsound(src.loc, 'sound/weapons/emitter.ogg', 25, 1) + playsound(get_turf(src), 'sound/weapons/emitter.ogg', 25, 1) use_power(100 * mega_energy + 500) /*if(prob(35)) var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread diff --git a/code/WorkInProgress/Cael_Aislinn/Supermatter/ZeroPointLaser.dm b/code/WorkInProgress/Cael_Aislinn/Supermatter/ZeroPointLaser.dm index 04c07733df2..ee2b787f7fb 100644 --- a/code/WorkInProgress/Cael_Aislinn/Supermatter/ZeroPointLaser.dm +++ b/code/WorkInProgress/Cael_Aislinn/Supermatter/ZeroPointLaser.dm @@ -92,8 +92,8 @@ src.fire_delay = rand(20,100) src.shot_number = 0 use_power(1000) - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) - playsound(src.loc, 'sound/weapons/emitter.ogg', 25, 1) + var/obj/item/projectile/beam/emitter/A = getFromPool(/obj/item/projectile/beam/emitter, loc) + playsound(get_turf(src), 'sound/weapons/emitter.ogg', 25, 1) if(prob(35)) var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread s.set_up(5, 1, src) diff --git a/code/__HELPERS/experimental.dm b/code/__HELPERS/experimental.dm index 80913214a7e..56a1bada76d 100644 --- a/code/__HELPERS/experimental.dm +++ b/code/__HELPERS/experimental.dm @@ -48,7 +48,7 @@ * WARNING, only supports /mob and /obj. */ -#define DEBUG_OBJECT_POOL 0 +#define DEBUG_OBJECT_POOL 1 #define STARTING_OBJECT_POOL_COUNT 20 var/list/masterPool @@ -64,6 +64,8 @@ var/list/masterPool /obj/structure/grille,\ /obj/effect/effect/sparks)) + initializePool(typesof(/obj/item/projectile/beam)) + world << "\red \b Object Pool Creation Complete!" /* @@ -96,15 +98,9 @@ var/list/masterPool * A, object type * B, location to spawn * - * @return - * -1, if B is not a location - * * Example call: getFromPool(/obj/item/weapon/shard, loc) */ /proc/getFromPool(const/A, const/B) - if (isloc(B) == 0) - return -1 - if (isnull(masterPool[A])) #if DEBUG_OBJECT_POOL world << "DEBUG_OBJECT_POOL: new proc has been called ([A])." @@ -164,4 +160,9 @@ var/list/masterPool * * Example: see, code\game\objects\structures\grille.dm */ -/atom/movable/proc/resetVariables() +/atom/movable + proc/resetVariables() + density = initial(density) + icon = initial(icon) + icon_state = initial(icon_state) + dir = initial(dir) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index bed775a6094..caa4d1c62f4 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -270,7 +270,7 @@ var/turf/T = get_turf(src) var/turf/U = get_turf(A) - var/obj/item/projectile/beam/LE = new /obj/item/projectile/beam( loc ) + var/obj/item/projectile/beam/LE = getFromPool(/obj/item/projectile/beam, loc) LE.icon = 'icons/effects/genetics.dmi' LE.icon_state = "eyelasers" playsound(usr.loc, 'sound/weapons/taser2.ogg', 75, 1) @@ -311,7 +311,7 @@ "You hear the loud crackle of electricity!") var/datum/powernet/PN = cable.get_powernet() var/available = 0 - var/obj/item/projectile/beam/lightning/L = new /obj/item/projectile/beam/lightning/( get_turf(src) ) + var/obj/item/projectile/beam/lightning/L = getFromPool(/obj/item/projectile/beam/lightning, loc) if(PN) available = PN.avail L.damage = PN.get_electrocute_damage() @@ -337,7 +337,8 @@ s.set_up(5, 1, src) s.start() if(L.damage <= 0) - del(L) + //del(L) + returnToPool(L) if(L) playsound(get_turf(src), 'sound/effects/eleczap.ogg', 75, 1) L.tang = L.adjustAngle(get_angle(U,T)) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index f7e77f4e6d3..25dacdacbc9 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -167,7 +167,7 @@ its easier to just keep the beam vertical. //Maxdistance is the longest range the beam will persist before it gives up. var/EndTime=world.time+time var/broken = 0 - var/obj/item/projectile/beam/lightning/light = new + var/obj/item/projectile/beam/lightning/light = getFromPool(/obj/item/projectile/beam/lightning) while(BeamTarget&&world.time friendly name var/list/reagents_to_log=list() + + resetVariables() + origin_tech = initial(origin_tech) + reliability = initial(reliability) + crit_fail = initial(crit_fail) + unacidable = initial(unacidable) + throwforce = initial(throwforce) + attack_verb = initial(attack_verb) + sharp = initial(sharp) + in_use = initial(in_use) + damtype = initial(damtype) + force = initial(force) + reagents_to_log = initial(reagents_to_log) + return ..() + /obj/Destroy() machines -= src processing_objects -= src @@ -134,4 +149,4 @@ var/rendered = "[M.name]: [text]" mo.show_message(rendered, 2) */ - return \ No newline at end of file + return diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 59a7442c005..5e4ad3c47ec 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -12,6 +12,11 @@ var/health = 10 var/destroyed = 0 + + resetVariables() + destroyed = initial(destroyed) + health = initial(health) + /obj/structure/grille/fence/ var/width = 3 health = 50 @@ -242,13 +247,3 @@ health -= 1 healthcheck() ..() - - -/obj/structure/grille/resetVariables() - density = initial(density) - icon_state = initial(icon_state) - destroyed = initial(destroyed) - health = initial(health) - - return ..() - diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index 3c25a77295f..c098eb7c51b 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -121,8 +121,8 @@ else src.fire_delay = rand(20,100) src.shot_number = 0 - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) - playsound(src.loc, 'sound/weapons/emitter.ogg', 25, 1) + var/obj/item/projectile/beam/emitter/A = getFromPool(/obj/item/projectile/beam/emitter, loc) + playsound(get_turf(src), 'sound/weapons/emitter.ogg', 25, 1) if(prob(35)) var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread s.set_up(5, 1, src) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 8686f92d901..e1a3517fe2d 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -52,10 +52,41 @@ var/agony = 0 var/embed = 0 // whether or not the projectile can embed itself in the mob + proc/delete() // Garbage collect the projectiles loc = null + resetVariables() + bumped = initial(bumped) + def_zone = initial(def_zone) + firer = initial(firer) + silenced = initial(silenced) + yo = initial(yo) + xo = initial(xo) + current = initial(current) + shot_from = initial(shot_from) + original = initial(original) + starting = initial(starting) + permutated = initial(permutated) + p_x = initial(p_x) + p_y = initial(p_y) + damage = initial(damage) + damage_type = initial(damage_type) + nodamage = initial(nodamage) + flag = initial(flag) + projectile_type = initial(projectile_type) + kill_count = initial(kill_count) + stun = initial(stun) + weaken = initial(weaken) + paralyze = initial(paralyze) + irradiate = initial(irradiate) + stutter = initial(stutter) + eyeblur = initial(eyeblur) + drowsy = initial(drowsy) + agony = initial(agony) + return ..() + proc/on_hit(var/atom/target, var/blocked = 0) if(blocked >= 2) return 0//Full block if(!isliving(target)) return 0 diff --git a/code/modules/projectiles/projectile/beams.dm b/code/modules/projectiles/projectile/beams.dm index 00cd71f94e1..67e88ba1ca1 100644 --- a/code/modules/projectiles/projectile/beams.dm +++ b/code/modules/projectiles/projectile/beams.dm @@ -1,12 +1,21 @@ +/* + * Use: Caches beam state images and holds turfs that had these images overlaid. + * Structure: + * beam_master + * icon_states/dirs of beams + * image for that beam + * references for fired beams + * icon_states/dirs for each placed beam image + * turfs that have that icon_state/dir + */ var/list/beam_master = list() -//Use: Caches beam state images and holds turfs that had these images overlaid. -//Structure: -//beam_master -// icon_states/dirs of beams -// image for that beam -// references for fired beams -// icon_states/dirs for each placed beam image -// turfs that have that icon_state/dir + + +//Special laser the captains gun uses +/obj/item/projectile/beam/captain + name = "captain laser" + damage = 40 + /obj/item/projectile/beam/lightning invisibility = 101 @@ -22,6 +31,7 @@ var/list/beam_master = list() layer = 3 var/turf/last = null kill_count = 6 + proc/adjustAngle(angle) angle = round(angle) + 45 if(angle > 180) @@ -168,6 +178,11 @@ var/list/beam_master = list() M.playsound_local(src, "explosion", 50, 1) ..() + resetVariables() + tang = initial(tang) + last = initial(last) + return ..() + /obj/item/projectile/beam name = "laser" icon_state = "laser" @@ -187,12 +202,14 @@ var/list/beam_master = list() if((!( current ) || loc == current)) //If we pass our target current = locate(min(max(x + xo, 1), world.maxx), min(max(y + yo, 1), world.maxy), z) if((x == 1 || x == world.maxx || y == 1 || y == world.maxy)) - del(src) //Delete if it passes the world edge + //del(src) //Delete if it passes the world edge + returnToPool(src) return step_towards(src, current) //Move~ if(kill_count < 1) - del(src) + //del(src) + returnToPool(src) kill_count-- if(!bumped && !isturf(original)) @@ -287,6 +304,11 @@ var/list/beam_master = list() return + resetVariables() + frequency = initial(frequency) + return ..() + + /obj/item/projectile/beam/practice name = "laser" icon_state = "laser"