From 2a58dd54a95060c22dfbcef0ca32027103854d61 Mon Sep 17 00:00:00 2001 From: nullbear Date: Sun, 11 Sep 2016 01:46:26 -0700 Subject: [PATCH] Adds explosion helper proc w/ diminishing returns (#20319) * Adds new explosion proc Adds a new proc for calling explosions, which uses 'power' instead of a set of ranges. Power (1 - 100) is based on minimum explosions size (0, 0, 1) to maximum explosion size (5, 10, 20) Formula keeps explosions within a 'sane' range. So while it is possible to bypass maxcap using this, it will require a LOT of work. I've done some balance testing, and a halfcap (2,5,10) can be made using a double bluespace beaker of water and potassium. A (3,7,14) can be made using black powder, and the largest bluespace grenade explosion can be made using nitroglycerine, at (6, 12, 24) which is only slightly larger than maxcap. You can check out https://www.desmos.com/calculator/pgfz0gqqxf to see how the explosive power affects range. T is 'units of explosion' and P is a multiplier. Multipliers for explosive reagents are: water/potass = 1/10, black powder/meth = 1/6, nitroglycerin = 1/2. * Clarity Changes Renames dynamic explosion proc for clarity. Makes dyn_x explosions scaleable with DYN_EX_SCALE variable. Adds debug dyn_x verbs, and a dyn_x drop_bomb proc to fun admin verbs. * Adjusts formula better efficiency and readability. Adds debug proc for changing explosion scale. Adds a comment containing common power/explosion sizes. * oops --- code/_globalvars/configuration.dm | 1 + .../effects/effect_system/effects_other.dm | 22 +------- code/game/objects/explosion.dm | 14 +++++ code/modules/admin/admin_verbs.dm | 51 +++++++++++++++++++ 4 files changed, 68 insertions(+), 20 deletions(-) diff --git a/code/_globalvars/configuration.dm b/code/_globalvars/configuration.dm index e18125ab284..21155f2d2dd 100644 --- a/code/_globalvars/configuration.dm +++ b/code/_globalvars/configuration.dm @@ -41,4 +41,5 @@ var/MAX_EX_HEAVY_RANGE = 7 var/MAX_EX_LIGHT_RANGE = 14 var/MAX_EX_FLASH_RANGE = 14 var/MAX_EX_FLAME_RANGE = 14 +var/DYN_EX_SCALE = 0.5 diff --git a/code/game/objects/effects/effect_system/effects_other.dm b/code/game/objects/effects/effect_system/effects_other.dm index fe303b4782c..585dfedf0ab 100644 --- a/code/game/objects/effects/effect_system/effects_other.dm +++ b/code/game/objects/effects/effect_system/effects_other.dm @@ -105,7 +105,7 @@ if(explosion_message) location.visible_message("The solution violently explodes!", \ "You hear an explosion!") - if (amount <= 2) + if (amount < 1) var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread s.set_up(2, 1, location) s.start() @@ -116,22 +116,4 @@ M.Weaken(rand(1,5)) return else - var/devastation = -1 - var/heavy = -1 - var/light = -1 - var/flash = -1 - - // Clamp all values to MAX_EXPLOSION_RANGE - if (round(amount/12) > 0) - devastation = min (MAX_EX_DEVESTATION_RANGE, devastation + round(amount/12)) - - if (round(amount/6) > 0) - heavy = min (MAX_EX_HEAVY_RANGE, heavy + round(amount/6)) - - if (round(amount/3) > 0) - light = min (MAX_EX_LIGHT_RANGE, light + round(amount/3)) - - if (flashing && flashing_factor) - flash += (round(amount/4) * flashing_factor) - - explosion(location, devastation, heavy, light, flash) + dyn_explosion(location, amount, flashing_factor) \ No newline at end of file diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index 248a17a77f0..2802cce4314 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -246,4 +246,18 @@ T.color = null T.maptext = "" +proc/dyn_explosion(turf/epicenter, power, flash_range, adminlog = 1, ignorecap = 1, flame_range = 0 ,silent = 0, smoke = 1) + if(!power) + return + var/range = 0 + range = round((2 * power)**DYN_EX_SCALE) + explosion(epicenter, round(range * 0.25), round(range * 0.5), round(range), flash_range*range, adminlog, ignorecap, flame_range*range, silent, smoke) +// Using default dyn_ex scale: +// 100 explosion power is a (5, 10, 20) explosion. +// 75 explosion power is a (4, 8, 17) explosion. +// 50 explosion power is a (3, 7, 14) explosion. +// 25 explosion power is a (2, 5, 10) explosion. +// 10 explosion power is a (1, 3, 6) explosion. +// 5 explosion power is a (0, 1, 3) explosion. +// 1 explosion power is a (0, 0, 1) explosion. \ No newline at end of file diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index c67f8d1c3b2..43cd0a61fdc 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -82,6 +82,8 @@ var/list/admin_verbs_fun = list( /client/proc/cmd_admin_dress, /client/proc/cmd_admin_gib_self, /client/proc/drop_bomb, + /client/proc/set_dynex_scale, + /client/proc/drop_dynex_bomb, /client/proc/cinematic, /client/proc/one_click_antag, /client/proc/send_space_ninja, @@ -142,6 +144,9 @@ var/list/admin_verbs_debug = list( /client/proc/check_bomb_impacts, /proc/machine_upgrade, /client/proc/populate_world, + /client/proc/get_dynex_power, //*debug verbs for dynex explosions. + /client/proc/get_dynex_range, //*debug verbs for dynex explosions. + /client/proc/set_dynex_scale, /client/proc/cmd_display_del_log, /client/proc/reset_latejoin_spawns, /client/proc/create_outfits, @@ -196,6 +201,10 @@ var/list/admin_verbs_hideable = list( /client/proc/cmd_admin_dress, /client/proc/cmd_admin_gib_self, /client/proc/drop_bomb, + /client/proc/drop_dynex_bomb, + /client/proc/get_dynex_range, + /client/proc/get_dynex_power, + /client/proc/set_dynex_scale, /client/proc/cinematic, /client/proc/send_space_ninja, /client/proc/cmd_admin_add_freeform_ai_law, @@ -514,6 +523,48 @@ var/list/admin_verbs_hideable = list( message_admins("[ckey] creating an admin explosion at [epicenter.loc].") feedback_add_details("admin_verb","DB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! +/client/proc/drop_dynex_bomb() + set category = "Special Verbs" + set name = "Drop DynEx Bomb" + set desc = "Cause an explosion of varying strength at your location." + + var/ex_power = input("Explosive Power:") as null|num + var/turf/epicenter = mob.loc + if(ex_power && epicenter) + dyn_explosion(epicenter, ex_power) + message_admins("[ckey] creating an admin explosion at [epicenter.loc].") + feedback_add_details("admin_verb","DDXB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + +/client/proc/get_dynex_range() + set category = "Debug" + set name = "Get DynEx Range" + set desc = "Get the estimated range of a bomb, using explosive power." + + var/ex_power = input("Explosive Power:") as null|num + var/range = round((2 * ex_power)**DYN_EX_SCALE) + usr << "Estimated Explosive Range: (Devestation: [round(range*0.25)], Heavy: [round(range*0.5)], Light: [round(range)])" + +/client/proc/get_dynex_power() + set category = "Debug" + set name = "Get DynEx Power" + set desc = "Get the estimated required power of a bomb, to reach a specific range." + + var/ex_range = input("Light Explosion Range:") as null|num + var/power = (0.5 * ex_range)**(1/DYN_EX_SCALE) + usr << "Estimated Explosive Power: [power]" + +/client/proc/set_dynex_scale() + set category = "Debug" + set name = "Set DynEx Scale" + set desc = "Set the scale multiplier of dynex explosions. The default is 0.5." + + var/ex_scale = input("New DynEx Scale:") as null|num + if(!ex_scale) + return + DYN_EX_SCALE = ex_scale + log_admin("[key_name(usr)] has modified Dynamic Explosion Scale: [ex_scale]") + message_admins("[key_name_admin(usr)] has modified Dynamic Explosion Scale: [ex_scale]") + /client/proc/give_spell(mob/T in mob_list) set category = "Fun" set name = "Give Spell"