From 41b64d9917d82e0cb173428376577ee995125155 Mon Sep 17 00:00:00 2001 From: Krausus Date: Fri, 10 Jul 2015 05:00:53 -0400 Subject: [PATCH] Tweaks explosion throwing Explosions now calculate throwing distances sanely, don't spin everything they throw, and don't permanently change the speed things go when thrown by players. --- code/game/atoms_movable.dm | 7 ++----- code/game/objects/explosion.dm | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 70e78c96fc2..ae10059f504 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -110,7 +110,7 @@ if(A.density && !A.throwpass) // **TODO: Better behaviour for windows which are dense, but shouldn't always stop movement src.throw_impact(A,speed) -/atom/movable/proc/throw_at(atom/target, range, speed, thrower) +/atom/movable/proc/throw_at(atom/target, range, speed, thrower, no_spin) if(!target || !src || (flags & NODROP)) return 0 //use a modified version of Bresenham's algorithm to get from the atom's current position to that of the target @@ -119,7 +119,7 @@ src.thrower = thrower src.throw_source = get_turf(src) //store the origin turf if(target.allow_spin) // turns out 1000+ spinning objects being thrown at the singularity creates lag - Iamgoofball - if(!no_spin_thrown) + if(!no_spin_thrown && !no_spin) SpinAnimation(5, 1) var/dist_x = abs(target.x - src.x) var/dist_y = abs(target.y - src.y) @@ -140,9 +140,6 @@ var/area/a = get_area(src.loc) if(dist_x > dist_y) var/error = dist_x/2 - dist_y - - - while(src && target &&((((src.x < target.x && dx == EAST) || (src.x > target.x && dx == WEST)) && dist_travelled < range) || (a && a.has_gravity == 0) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf)) // only stop when we've gone the whole distance (or max throw range) and are on a non-space tile, or hit something, or hit the end of the map, or someone picks it up if(error < 0) diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index 443c553cc3f..fd861b1e99f 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -103,7 +103,7 @@ dist += D.explosion_block var/flame_dist = 0 - var/throw_dist = dist + var/throw_dist = max_range - dist if(dist < flame_range) flame_dist = 1 @@ -126,14 +126,16 @@ //--- THROW ITEMS AROUND --- - var/throw_dir = get_dir(epicenter,T) - for(var/obj/item/I in T) - spawn(0) //Simultaneously not one at a time - if(I && !I.anchored) - var/throw_range = rand(throw_dist, max_range) - var/turf/throw_at = get_ranged_target_turf(I, throw_dir, throw_range) - I.throw_speed = 4 //Temporarily change their throw_speed for embedding purposes (Reset when it finishes throwing, regardless of hitting anything) - I.throw_at(throw_at, throw_range, 2)//Throw it at 2 speed, this is purely visual anyway. + if(throw_dist > 0) + var/throw_dir = get_dir(epicenter,T) + for(var/obj/item/I in T) + spawn(0) //Simultaneously not one at a time + if(I && !I.anchored) + var/throw_mult = 0.5 + (0.5 * rand()) // Between 0.5 and 1.0 + var/throw_range = round((throw_dist + 1) * throw_mult) // Roughly 50% to 100% of throw_dist + if(throw_range > 0) + var/turf/throw_at = get_ranged_target_turf(I, throw_dir, throw_range) + I.throw_at(throw_at, throw_range, 2, no_spin = 1)//Throw it at 2 speed, this is purely visual anyway. var/took = (world.timeofday-start)/10 //You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare