mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Optimized the code regarding the beam projectiles leaving a fleeting beam behind them, however the count of deletions is still quite high despite this. 30-50 deletions per second.
Also fixed the code for evidence bags.
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
icon = 'storage.dmi'
|
icon = 'storage.dmi'
|
||||||
icon_state = "evidenceobj"
|
icon_state = "evidenceobj"
|
||||||
w_class = 1
|
w_class = 1
|
||||||
|
var/image/overlay_image
|
||||||
|
|
||||||
/obj/item/weapon/evidencebag/afterattack(obj/item/O, mob/user as mob)
|
/obj/item/weapon/evidencebag/afterattack(obj/item/O, mob/user as mob)
|
||||||
if(!in_range(O,user))
|
if(!in_range(O,user))
|
||||||
@@ -47,7 +48,8 @@
|
|||||||
user.visible_message("\The [user] puts \a [O] into \a [src]", "You put \the [O] inside \the [src].",\
|
user.visible_message("\The [user] puts \a [O] into \a [src]", "You put \the [O] inside \the [src].",\
|
||||||
"You hear a rustle as someone puts something into a plastic bag.")
|
"You hear a rustle as someone puts something into a plastic bag.")
|
||||||
icon_state = "evidence"
|
icon_state = "evidence"
|
||||||
overlays += O
|
overlay_image = image(O.icon, O.icon_state, layer, O.dir)
|
||||||
|
overlays += overlay_image
|
||||||
desc = "An evidence bag containing \a [O]. [O.desc]"
|
desc = "An evidence bag containing \a [O]. [O.desc]"
|
||||||
O.loc = src
|
O.loc = src
|
||||||
w_class = O.w_class
|
w_class = O.w_class
|
||||||
@@ -59,7 +61,8 @@
|
|||||||
var/obj/item/I = contents[1]
|
var/obj/item/I = contents[1]
|
||||||
user.visible_message("\The [user] takes \a [I] out of \a [src]", "You take \the [I] out of \the [src].",\
|
user.visible_message("\The [user] takes \a [I] out of \a [src]", "You take \the [I] out of \the [src].",\
|
||||||
"You hear someone rustle around in a plastic bag, and remove something.")
|
"You hear someone rustle around in a plastic bag, and remove something.")
|
||||||
overlays -= I
|
overlays -= overlay_image
|
||||||
|
del overlay_image
|
||||||
user.put_in_hands(I)
|
user.put_in_hands(I)
|
||||||
w_class = 1
|
w_class = 1
|
||||||
icon_state = "evidenceobj"
|
icon_state = "evidenceobj"
|
||||||
@@ -67,7 +70,6 @@
|
|||||||
|
|
||||||
else
|
else
|
||||||
user << "\The [src] is empty."
|
user << "\The [src] is empty."
|
||||||
icon_state = "evidenceobj"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
/obj/item/weapon/storage/box/evidence
|
/obj/item/weapon/storage/box/evidence
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
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
|
||||||
|
|
||||||
/obj/item/projectile/beam
|
/obj/item/projectile/beam
|
||||||
name = "laser"
|
name = "laser"
|
||||||
icon_state = "laser"
|
icon_state = "laser"
|
||||||
@@ -7,46 +17,63 @@
|
|||||||
flag = "laser"
|
flag = "laser"
|
||||||
eyeblur = 4
|
eyeblur = 4
|
||||||
var/frequency = 1
|
var/frequency = 1
|
||||||
var/ID = 0
|
|
||||||
var/main = 0
|
|
||||||
|
|
||||||
fired()
|
fired()
|
||||||
main = 1
|
var/reference = "\ref[src]" //So we do not have to recalculate it a ton
|
||||||
ID = rand(0,1000)
|
var/first = 1 //So we don't make the overlay in the same tile as the firer
|
||||||
var/first = 1
|
|
||||||
var/obj/effect/effect/laserdealer/lasor = new /obj/effect/effect/laserdealer(null)
|
|
||||||
spawn(0)
|
spawn(0)
|
||||||
lasor.setup(ID)
|
while(!bumped) //Move until we hit something
|
||||||
spawn(0)
|
step_towards(src, current) //Move~
|
||||||
while(!bumped)
|
|
||||||
step_towards(src, current)
|
|
||||||
for(var/mob/living/M in loc)
|
for(var/mob/living/M in loc)
|
||||||
Bump(M)
|
Bump(M) //Bump anyone we touch
|
||||||
if((!( current ) || loc == current))
|
|
||||||
|
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)
|
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))
|
if((x == 1 || x == world.maxx || y == 1 || y == world.maxy))
|
||||||
del(src)
|
del(src) //Delete if it passes the world edge
|
||||||
return
|
return
|
||||||
if(!first)
|
|
||||||
var/obj/item/projectile/beam/new_beam = new src.type(loc)
|
if(!first) //Add the overlay as we pass over tiles
|
||||||
processing_objects.Remove(new_beam)
|
var/target_dir = get_dir(src, current) //So we don't call this too much
|
||||||
new_beam.dir = get_dir(src, current)
|
|
||||||
new_beam.ID = ID
|
//If the icon has not been added yet
|
||||||
new_beam.icon_state = icon_state
|
if( !("[icon_state][target_dir]" in beam_master) )
|
||||||
|
var/image/I = image(icon,icon_state,10,target_dir) //Generate it.
|
||||||
|
beam_master["[icon_state][target_dir]"] = I //And cache it!
|
||||||
|
|
||||||
|
//Finally add the overlay
|
||||||
|
loc.overlays += beam_master["[icon_state][target_dir]"]
|
||||||
|
|
||||||
|
//Add the turf to a list in the beam master so they can be cleaned up easily.
|
||||||
|
if(reference in beam_master)
|
||||||
|
var/list/turf_master = beam_master[reference]
|
||||||
|
if("[icon_state][target_dir]" in turf_master)
|
||||||
|
var/list/turfs = turf_master["[icon_state][target_dir]"]
|
||||||
|
turfs += loc
|
||||||
|
else
|
||||||
|
turf_master["[icon_state][target_dir]"] = list(loc)
|
||||||
|
else
|
||||||
|
var/list/turfs = list()
|
||||||
|
turfs["[icon_state][target_dir]"] = list(loc)
|
||||||
|
beam_master[reference] = turfs
|
||||||
else
|
else
|
||||||
first = 0
|
first = 0
|
||||||
|
|
||||||
|
cleanup(reference)
|
||||||
return
|
return
|
||||||
|
|
||||||
/obj/effect/effect/laserdealer
|
proc/cleanup(reference) //Waits .3 seconds then removes the overlay.
|
||||||
name = "laserdealio"
|
src = null
|
||||||
|
sleep(3)
|
||||||
proc/setup(var/ID = 0)
|
var/list/turf_master = beam_master[reference]
|
||||||
sleep(5)
|
for(var/laser_state in turf_master)
|
||||||
for(var/obj/item/projectile/beam/beam in world)
|
var/list/turfs = turf_master[laser_state]
|
||||||
if(ID == beam.ID)
|
for(var/turf/T in turfs)
|
||||||
del(beam)
|
T.overlays -= beam_master[laser_state]
|
||||||
spawn(0)
|
return
|
||||||
del(src)
|
|
||||||
|
|
||||||
/obj/item/projectile/practice
|
/obj/item/projectile/practice
|
||||||
name = "laser"
|
name = "laser"
|
||||||
|
|||||||
Reference in New Issue
Block a user