mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 11:37:40 +01:00
Object pool for beam projectile, minor changes to object pool.
Conflicts: code/WorkInProgress/Cael_Aislinn/Rust/gyrotron.dm code/WorkInProgress/Cael_Aislinn/Supermatter/ZeroPointLaser.dm code/game/objects/structures/grille.dm code/modules/power/singularity/emitter.dm code/modules/projectiles/projectile.dm code/modules/projectiles/projectile/beams.dm
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
+1
-1
@@ -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<EndTime&&get_dist(src,BeamTarget)<maxdistance&&z==BeamTarget.z)
|
||||
//If the BeamTarget gets deleted, the time expires, or the BeamTarget gets out
|
||||
//of range or to another z-level, then the beam will stop. Otherwise it will
|
||||
|
||||
@@ -1020,7 +1020,8 @@ Auto Patrol: []"},
|
||||
if((src.lasercolor == "b") && (src.disabled == 0))
|
||||
if(istype(Proj, /obj/item/projectile/beam/lastertag/red))
|
||||
src.disabled = 1
|
||||
del (Proj)
|
||||
//del (Proj)
|
||||
returnToPool(Proj)
|
||||
sleep(100)
|
||||
src.disabled = 0
|
||||
else
|
||||
@@ -1028,7 +1029,8 @@ Auto Patrol: []"},
|
||||
else if((src.lasercolor == "r") && (src.disabled == 0))
|
||||
if(istype(Proj, /obj/item/projectile/beam/lastertag/blue))
|
||||
src.disabled = 1
|
||||
del (Proj)
|
||||
//del (Proj)
|
||||
returnToPool(Proj)
|
||||
sleep(100)
|
||||
src.disabled = 0
|
||||
else
|
||||
|
||||
@@ -213,17 +213,17 @@
|
||||
if (src.lasers)
|
||||
switch(lasertype)
|
||||
if(1)
|
||||
A = new /obj/item/projectile/beam( loc )
|
||||
A = getFromPool(/obj/item/projectile/beam, loc)
|
||||
if(2)
|
||||
A = new /obj/item/projectile/beam/heavylaser( loc )
|
||||
A = getFromPool(/obj/item/projectile/beam/heavylaser, loc)
|
||||
if(3)
|
||||
A = new /obj/item/projectile/beam/pulse( loc )
|
||||
A = getFromPool(/obj/item/projectile/beam/pulse, loc)
|
||||
if(4)
|
||||
A = new /obj/item/projectile/change( loc )
|
||||
if(5)
|
||||
A = new /obj/item/projectile/beam/lastertag/blue( loc )
|
||||
A = getFromPool(/obj/item/projectile/beam/lastertag/blue, loc)
|
||||
if(6)
|
||||
A = new /obj/item/projectile/beam/lastertag/red( loc )
|
||||
A = getFromPool(/obj/item/projectile/beam/lastertag/red, loc)
|
||||
A.original = target
|
||||
use_power(500)
|
||||
else
|
||||
|
||||
@@ -158,6 +158,10 @@ steam.start() -- spawns the effect
|
||||
|
||||
var/amount = 6.0
|
||||
|
||||
resetVariables()
|
||||
amount = initial(amount)
|
||||
return ..()
|
||||
|
||||
/obj/effect/effect/sparks/New()
|
||||
..()
|
||||
playsound(src.loc, "sparks", 100, 1)
|
||||
|
||||
@@ -19,6 +19,21 @@
|
||||
// What reagents should be logged when transferred TO this object?
|
||||
// Reagent ID => 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 = "<span class='game say'><span class='name'>[M.name]: </span> <span class='message'>[text]</span></span>"
|
||||
mo.show_message(rendered, 2)
|
||||
*/
|
||||
return
|
||||
return
|
||||
|
||||
@@ -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 ..()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user