mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Re-adding object pooling for beam projectiles. Fixed the double damage bug with a spawn().
What was happening was returntopool was nulling the variable that prevented the projectile from bumping something twice, and for whatever reason despite having no loc the proj would bump the same mob twice then be in the void again. The spawn() allows the bump proc to finish and then the projectile is returned to the pool.
This commit is contained in:
@@ -67,13 +67,14 @@
|
||||
proc/check_fire(var/mob/living/target as mob, var/mob/living/user as mob) //Checks if you can hit them or not.
|
||||
if(!istype(target) || !istype(user))
|
||||
return 0
|
||||
var/obj/item/projectile/test/in_chamber = new /obj/item/projectile/test(get_step_to(user,target)) //Making the test....
|
||||
var/obj/item/projectile/test/in_chamber = getFromPool(/obj/item/projectile/test, get_step_to(user, target)) //Making the test....
|
||||
in_chamber.target = target
|
||||
in_chamber.flags = flags //Set the flags...
|
||||
in_chamber.pass_flags = pass_flags //And the pass flags to that of the real projectile...
|
||||
in_chamber.firer = user
|
||||
var/output = in_chamber.process() //Test it!
|
||||
del(in_chamber) //No need for it anymore
|
||||
//del(in_chamber) //No need for it anymore
|
||||
returnToPool(in_chamber)
|
||||
return output //Send it back to the gun!
|
||||
|
||||
Bump(atom/A as mob|obj|turf|area)
|
||||
@@ -164,10 +165,11 @@
|
||||
O.bullet_act(src)
|
||||
for(var/mob/M in A)
|
||||
M.bullet_act(src, def_zone)
|
||||
if(!istype(src, /obj/item/projectile/beam/lightning))
|
||||
spawn()//if(!istype(src, /obj/item/projectile/beam/lightning))
|
||||
density = 0
|
||||
invisibility = 101
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
return 1
|
||||
|
||||
|
||||
@@ -182,14 +184,16 @@
|
||||
|
||||
process()
|
||||
if(kill_count < 1)
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
return
|
||||
kill_count--
|
||||
spawn while(src)
|
||||
if((!( current ) || loc == current))
|
||||
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)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
return
|
||||
step_towards(src, current)
|
||||
sleep(1)
|
||||
@@ -201,9 +205,11 @@
|
||||
return
|
||||
proc/dumbfire(var/dir) // for spacepods, go snowflake go
|
||||
if(!dir)
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
if(kill_count < 1)
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
kill_count--
|
||||
spawn while(src)
|
||||
var/turf/T = get_step(src, dir)
|
||||
|
||||
@@ -163,7 +163,8 @@ var/list/beam_master = list()
|
||||
if(src.loc != current)
|
||||
tang = adjustAngle(get_angle(src.loc,current))
|
||||
icon_state = "[tang]"
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
return
|
||||
/*cleanup(reference) //Waits .3 seconds then removes the overlay.
|
||||
//world << "setting invisibility"
|
||||
@@ -194,12 +195,16 @@ 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(isnull(loc))
|
||||
return
|
||||
if(kill_count < 1)
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
return
|
||||
kill_count--
|
||||
|
||||
@@ -239,16 +244,20 @@ var/list/beam_master = list()
|
||||
var/reference = "\ref[src]" //So we do not have to recalculate it a ton
|
||||
var/first = 1 //So we don't make the overlay in the same tile as the firer
|
||||
if(!dir)
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
spawn while(src) //Move until we hit something
|
||||
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
|
||||
var/turf/T = get_step(src, dir)
|
||||
step_towards(src, T) //Move~
|
||||
|
||||
if(isnull(loc))
|
||||
return
|
||||
if(kill_count < 1)
|
||||
del(src)
|
||||
//del(src)
|
||||
returnToPool(src)
|
||||
kill_count--
|
||||
|
||||
if(!bumped && !isturf(original))
|
||||
|
||||
@@ -192,10 +192,12 @@ obj/item/projectile/kinetic/New()
|
||||
// Now we bump as a bullet, if the atom is a non-turf.
|
||||
if(!isturf(A))
|
||||
..(A)
|
||||
qdel(src) // Comment this out if you want to shoot through the asteroid, ERASER-style.
|
||||
//qdel(src) // Comment this out if you want to shoot through the asteroid, ERASER-style.
|
||||
returnToPool(src)
|
||||
return 1
|
||||
else
|
||||
qdel(src)
|
||||
//qdel(src)
|
||||
returnToPool(src)
|
||||
return 0
|
||||
|
||||
/obj/item/effect/kinetic_blast
|
||||
|
||||
Reference in New Issue
Block a user