From f3d09e092e2335a72da3295eb78e6ce727a29c5d Mon Sep 17 00:00:00 2001 From: GinjaNinja32 Date: Thu, 9 Jul 2015 16:25:47 +0100 Subject: [PATCH 1/4] Removes the approximations cheap_pythag and cheap_hypotenuse, since they're anything *but* cheap --- code/__HELPERS/game.dm | 12 ------------ code/controllers/_DynamicAreaLighting_TG.dm | 2 +- code/game/objects/effects/chemsmoke.dm | 4 ++-- code/game/objects/explosion.dm | 8 +------- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index d1182862744..af253f4b019 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -61,18 +61,6 @@ /proc/isNotAdminLevel(var/level) return !isAdminLevel(level) -//Magic constants obtained by using linear regression on right-angled triangles of sides 0=dy) return (k1*dx) + (k2*dy) //No sqrt or powers :) - else return (k2*dx) + (k1*dy) -#undef k1 -#undef k2 - /proc/circlerange(center=usr,radius=3) var/turf/centerturf = get_turf(center) diff --git a/code/controllers/_DynamicAreaLighting_TG.dm b/code/controllers/_DynamicAreaLighting_TG.dm index efa2a226b1f..ae570e919c4 100644 --- a/code/controllers/_DynamicAreaLighting_TG.dm +++ b/code/controllers/_DynamicAreaLighting_TG.dm @@ -115,7 +115,7 @@ datum/light_source dist = 0 else #ifdef LIGHTING_CIRCULAR - dist = cheap_hypotenuse(A.x, A.y, __x, __y) + dist = sqrt((A.x - __x)**2 + (A.y - __y)**2) #else dist = max(abs(A.x - __x), abs(A.y - __y)) #endif diff --git a/code/game/objects/effects/chemsmoke.dm b/code/game/objects/effects/chemsmoke.dm index 357996351d6..0b31bca4ad2 100644 --- a/code/game/objects/effects/chemsmoke.dm +++ b/code/game/objects/effects/chemsmoke.dm @@ -65,7 +65,7 @@ //build affected area list for(var/turf/T in view(range, location)) //cull turfs to circle - if(cheap_pythag(T.x - location.x, T.y - location.y) <= range) + if(sqrt((T.x - location.x)**2 + (T.y - location.y)**2) <= range) targetTurfs += T //make secondary list for reagents that affect walls @@ -145,7 +145,7 @@ if(istype(A, /obj/effect/effect/smoke/chem)) //skip the item if it is chem smoke continue else if(istype(A, /mob)) - var/dist = cheap_pythag(T.x - location.x, T.y - location.y) + var/dist = sqrt((T.x - location.x)**2 + (T.y - location.y)**2) if(!dist) dist = 1 R.reaction_mob(A, volume = R.volume / dist) diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index 9c61234a077..c9e1654eb55 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -1,11 +1,5 @@ //TODO: Flash range does nothing currently -//A very crude linear approximatiaon of pythagoras theorem. -/proc/cheap_pythag(var/dx, var/dy) - dx = abs(dx); dy = abs(dy); - if(dx>=dy) return dx + (0.5*dy) //The longest side add half the shortest side approximates the hypotenuse - else return dy + (0.5*dx) - ///// Z-Level Stuff proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1, z_transfer = 1) ///// Z-Level Stuff @@ -88,7 +82,7 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa var/z0 = epicenter.z for(var/turf/T in range(epicenter, max_range)) - var/dist = cheap_pythag(T.x - x0,T.y - y0) + var/dist = sqrt((T.x - x0)**2 + (T.y - y0)**2) if(dist < devastation_range) dist = 1 else if(dist < heavy_impact_range) dist = 2 From 5011f9b80625602caeffc47b519d88b5722e0e65 Mon Sep 17 00:00:00 2001 From: HarpyEagle Date: Thu, 9 Jul 2015 17:26:15 -0400 Subject: [PATCH 2/4] Fixes virus infectionchance oversight Fixes oversight in minormutate() that would cause viruses to become extremely infectious after spreading to another person. --- code/modules/virus2/disease2.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/virus2/disease2.dm b/code/modules/virus2/disease2.dm index c1852a0cb98..6d9ca33526a 100644 --- a/code/modules/virus2/disease2.dm +++ b/code/modules/virus2/disease2.dm @@ -118,7 +118,7 @@ //uniqueID = rand(0,10000) var/datum/disease2/effectholder/holder = pick(effects) holder.minormutate() - infectionchance = min(50,infectionchance + rand(0,10)) + //infectionchance = min(50,infectionchance + rand(0,10)) /datum/disease2/disease/proc/majormutate() uniqueID = rand(0,10000) From 6fb6237816115faf63c4e39409234089460af5a0 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Thu, 9 Jul 2015 23:00:22 -0400 Subject: [PATCH 3/4] Fixes #9984 Fixes capgun and dart crossbow inhands. --- code/game/objects/items/toys.dm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items/toys.dm b/code/game/objects/items/toys.dm index 6d741b7f6dc..40bcd1d9a9f 100644 --- a/code/game/objects/items/toys.dm +++ b/code/game/objects/items/toys.dm @@ -142,7 +142,11 @@ desc = "There are 0 caps left. Looks almost like the real thing! Ages 8 and up. Please recycle in an autolathe when you're out of caps!" icon = 'icons/obj/gun.dmi' icon_state = "revolver" - item_state = "gun" + item_state = "revolver" + item_icons = list( + icon_l_hand = 'icons/mob/items/lefthand_guns.dmi', + icon_r_hand = 'icons/mob/items/righthand_guns.dmi', + ) flags = CONDUCT slot_flags = SLOT_BELT|SLOT_HOLSTER w_class = 3.0 @@ -221,6 +225,10 @@ icon = 'icons/obj/gun.dmi' icon_state = "crossbow" item_state = "crossbow" + item_icons = list( + icon_l_hand = 'icons/mob/items/lefthand_guns.dmi', + icon_r_hand = 'icons/mob/items/righthand_guns.dmi', + ) w_class = 2.0 attack_verb = list("attacked", "struck", "hit") var/bullets = 5 From d1b15fc601a63224f7224b5fa0ab4138d095946a Mon Sep 17 00:00:00 2001 From: mwerezak Date: Fri, 10 Jul 2015 01:02:16 -0400 Subject: [PATCH 4/4] Fixes a couple more virus oversights/bugs Fixes contact viruses spreading through windows, fixes bad copypasta in infection_spreading_check() --- code/modules/virus2/helpers.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/virus2/helpers.dm b/code/modules/virus2/helpers.dm index feb7aec6a63..2628274f7b8 100644 --- a/code/modules/virus2/helpers.dm +++ b/code/modules/virus2/helpers.dm @@ -50,7 +50,7 @@ proc/infection_check(var/mob/living/carbon/M, var/vector = "Airborne") if (vector == "Airborne") var/obj/item/I = M.wear_mask if (istype(I)) - protection = max(protection, round(0.06*I.armor["bio"])) + protection = max(protection, I.armor["bio"]) return prob(protection) @@ -147,12 +147,12 @@ proc/airborne_can_reach(turf/source, turf/target) // log_debug("Could not reach target") if (vector == "Contact") - if (in_range(src, victim)) + if (Adjacent(victim)) // log_debug("In range, infecting") infect_virus2(victim,V) //contact goes both ways - if (victim.virus2.len > 0 && vector == "Contact") + if (victim.virus2.len > 0 && vector == "Contact" && Adjacent(victim)) // log_debug("Spreading [vector] diseases from [victim] to [src]") var/nudity = 1