mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 01:34:01 +00:00
Fix all of the define sanity failures, either by adding an `#undef` where needed or moving them to a file in `code/__DEFINES` 
232 lines
10 KiB
Plaintext
232 lines
10 KiB
Plaintext
/*
|
|
MICROFUSION CELL SYSTEM
|
|
|
|
Microfusion cells are small battery units that house controlled nuclear fusion within, and that fusion is converted into useable energy.
|
|
|
|
They cannot be charged as standard, and require upgrades to do so.
|
|
|
|
These are basically advanced cells.
|
|
*/
|
|
|
|
/// The amount of cell charge drained during a drain failure.
|
|
#define MICROFUSION_CELL_DRAIN_FAILURE STANDARD_CELL_CHARGE * 0.5
|
|
/// The heavy EMP range for when a cell suffers an EMP failure.
|
|
#define MICROFUSION_CELL_EMP_HEAVY_FAILURE 2
|
|
/// The light EMP range for when a cell suffers an EMP failure.
|
|
#define MICROFUSION_CELL_EMP_LIGHT_FAILURE 4
|
|
/// The radiation range for when a cell suffers a radiation failure.
|
|
#define MICROFUSION_CELL_RADIATION_RANGE_FAILURE 1
|
|
|
|
/// The lower most time for a microfusion cell meltdown.
|
|
#define MICROFUSION_CELL_FAILURE_LOWER (10 SECONDS)
|
|
/// The upper most time for a microfusion cell meltdown.
|
|
#define MICROFUSION_CELL_FAILURE_UPPER (15 SECONDS)
|
|
|
|
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion //Just a standard cell.
|
|
name = "microfusion cell"
|
|
desc = "A standard-issue microfusion cell, produced by Micron Control Systems. \
|
|
For safety reasons, they cannot be charged unless they are inside of a \
|
|
compatible Micron Control Systems firearm."
|
|
icon = 'modular_skyrat/modules/microfusion/icons/microfusion_cells.dmi'
|
|
charging_icon = "mf_in" //This is stored in cell.dmi in the aesthetics module
|
|
icon_state = "microfusion"
|
|
w_class = WEIGHT_CLASS_NORMAL
|
|
maxcharge = STANDARD_CELL_CHARGE //12 shots
|
|
chargerate = 0 //Standard microfusion cells can't be recharged when outside of a gun
|
|
empty = TRUE //MF cells should start empty
|
|
microfusion_readout = TRUE
|
|
charge_light_type = "microfusion"
|
|
|
|
/// A hard referenced list of upgrades currently attached to the weapon.
|
|
var/list/attachments = list()
|
|
/// Are we melting down? For icon stuffs.
|
|
var/meltdown = FALSE
|
|
/// How many upgrades can you have on this cell?
|
|
var/max_attachments = 1
|
|
/// Hard ref to the parent gun.
|
|
var/obj/item/gun/microfusion/parent_gun
|
|
/// Do we play an alarm when empty?
|
|
var/empty_alarm = TRUE
|
|
/// What sound do we play when empty?
|
|
var/empty_alarm_sound = 'sound/items/weapons/gun/general/empty_alarm.ogg'
|
|
/// Do we have the self charging upgrade?
|
|
var/self_charging = FALSE
|
|
/// We use this to edit the reload time of the gun
|
|
var/reloading_time = 4 SECONDS
|
|
/// We use this to edit the tactical reload time of the gun
|
|
var/reloading_time_tactical = 6 SECONDS
|
|
/// The probability of the cell failing, either through being makeshift or being used in something it shouldn't
|
|
var/fail_prob = 10
|
|
|
|
/obj/item/stock_parts/power_store/cell
|
|
/// Is this cell stabilised? (used in microfusion guns)
|
|
var/stabilised = FALSE
|
|
/// Do we show the microfusion readout instead of KJ?
|
|
var/microfusion_readout = FALSE
|
|
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/Destroy()
|
|
if(attachments.len)
|
|
for(var/obj/item/iterating_item as anything in attachments)
|
|
iterating_item.forceMove(get_turf(src))
|
|
attachments = null
|
|
parent_gun = null
|
|
return ..()
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/attackby(obj/item/attacking_item, mob/living/user, params)
|
|
if(istype(attacking_item, /obj/item/microfusion_cell_attachment))
|
|
add_attachment(attacking_item, user)
|
|
return
|
|
return ..()
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/emp_act(severity)
|
|
var/prob_percent = charge / 100 * severity
|
|
if(prob(prob_percent) && !meltdown && !stabilised)
|
|
process_instability()
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/use(amount, force = FALSE)
|
|
if(!parent_gun) // If an MCR cell is used in anything that's not an MCR, you might have problems
|
|
if(prob(fail_prob))
|
|
process_instability()
|
|
if(charge >= amount)
|
|
var/check_if_empty = charge - amount
|
|
if(check_if_empty < amount && empty_alarm && !self_charging)
|
|
playsound(src, empty_alarm_sound, 50)
|
|
return ..()
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/proc/process_instability()
|
|
var/seconds_to_explode = rand(MICROFUSION_CELL_FAILURE_LOWER, MICROFUSION_CELL_FAILURE_UPPER)
|
|
meltdown = TRUE
|
|
say("Malfunction in [seconds_to_explode / 10] seconds!")
|
|
playsound(src, 'sound/machines/warning-buzzer.ogg', 30, FALSE, FALSE)
|
|
add_filter("rad_glow", 2, list("type" = "outline", "color" = "#ff5e0049", "size" = 2))
|
|
addtimer(CALLBACK(src, PROC_REF(process_failure)), seconds_to_explode)
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/proc/process_failure()
|
|
remove_filter("rad_glow")
|
|
playsound(src, 'sound/effects/spray.ogg', 70)
|
|
switch(rand(1, 4))
|
|
if(1) // Charge drain
|
|
charge = clamp(charge - MICROFUSION_CELL_DRAIN_FAILURE, 0, maxcharge)
|
|
if(2) // Explosion
|
|
explode()
|
|
if(3) // Emp pulse
|
|
empulse(get_turf(src), 2, 4, FALSE) // 2 Heavy, 4 Light
|
|
if(4) // Deathly radiation pulse
|
|
radiation_pulse(src, 2, RAD_MEDIUM_INSULATION, 30)
|
|
meltdown = FALSE
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/update_overlays()
|
|
. = ..()
|
|
for(var/obj/item/microfusion_cell_attachment/microfusion_cell_attachment as anything in attachments)
|
|
. += microfusion_cell_attachment.attachment_overlay_icon_state
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/screwdriver_act(mob/living/user, obj/item/tool)
|
|
if(!attachments.len)
|
|
balloon_alert(user, "no attachments!")
|
|
return
|
|
remove_attachments()
|
|
playsound(src, 'sound/items/tools/screwdriver.ogg', 70, TRUE)
|
|
balloon_alert(user, "attachments removed")
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/process(seconds_per_tick)
|
|
for(var/obj/item/microfusion_cell_attachment/microfusion_cell_attachment as anything in attachments)
|
|
microfusion_cell_attachment.process_attachment(src, seconds_per_tick)
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/proc/inserted_into_weapon()
|
|
chargerate = STANDARD_CELL_CHARGE * 0.2
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/examine(mob/user)
|
|
. = ..()
|
|
. += span_notice("It can hold [max_attachments] attachment(s).")
|
|
. += span_warning("Inserting this into anything other than a microfusion rifle might be a terrible idea.")
|
|
if(attachments.len)
|
|
for(var/obj/item/microfusion_cell_attachment/microfusion_cell_attachment as anything in attachments)
|
|
. += span_notice("It has a [microfusion_cell_attachment.name] installed.")
|
|
. += span_notice("Use a <b>screwdriver</b> to remove the attachments.")
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/proc/add_attachment(obj/item/microfusion_cell_attachment/microfusion_cell_attachment, mob/living/user, obj/item/gun/microfusion/microfusion_gun)
|
|
if(attachments.len >= max_attachments)
|
|
balloon_alert(user, "can't attach more!")
|
|
return FALSE
|
|
if(is_type_in_list(microfusion_cell_attachment, attachments))
|
|
balloon_alert(user, "already installed!")
|
|
return FALSE
|
|
attachments += microfusion_cell_attachment
|
|
microfusion_cell_attachment.forceMove(src)
|
|
microfusion_cell_attachment.add_attachment(src)
|
|
balloon_alert(user, "installed attachment")
|
|
playsound(src, 'sound/effects/structure_stress/pop2.ogg', 70, TRUE)
|
|
update_appearance()
|
|
return TRUE
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/proc/remove_attachments()
|
|
for(var/obj/item/microfusion_cell_attachment/microfusion_cell_attachment in attachments)
|
|
microfusion_cell_attachment.remove_attachment(src)
|
|
microfusion_cell_attachment.forceMove(get_turf(src))
|
|
attachments -= microfusion_cell_attachment
|
|
update_appearance()
|
|
|
|
/datum/crafting_recipe/makeshift/microfusion_cell
|
|
name = "Makeshift Microfusion Cell"
|
|
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WIRECUTTER, TOOL_WELDER)
|
|
result = /obj/item/stock_parts/power_store/cell/microfusion/makeshift
|
|
reqs = list(
|
|
/obj/item/trash/can = 1,
|
|
/obj/item/stack/sheet/iron = 1,
|
|
/obj/item/stack/cable_coil = 1,
|
|
)
|
|
time = 12 SECONDS
|
|
category = CAT_MISC
|
|
|
|
//WHY WOULD YOU MAKE THIS?
|
|
/obj/item/stock_parts/power_store/cell/microfusion/makeshift
|
|
name = "makeshift microfusion cell"
|
|
desc = "An... Apparatus, comprised of an everyday aluminum can with several civilian-grade batteries tightly packed together and plugged in. This vaguely resembles a microfusion cell, if you tilt your head to a precise fifty degree angle. While the effects on enemy combatants may be dubious, it will certainly do incredible damage to the gun's warranty. What the hell were you thinking when you came up with this?"
|
|
icon_state = "microfusion_makeshift"
|
|
maxcharge = STANDARD_CELL_CHARGE * 0.5
|
|
max_attachments = 0
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/makeshift/use(amount, force = FALSE)
|
|
if(prob(fail_prob))
|
|
process_instability()
|
|
return ..()
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/enhanced
|
|
name = "enhanced microfusion cell"
|
|
desc = "A second generation microfusion cell, weighing about the same as the standard-issue cell and having the same space for attachments; however, it has a higher capacity."
|
|
icon_state = "microfusion_enhanced"
|
|
maxcharge = STANDARD_CELL_CHARGE * 1.4
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/advanced
|
|
name = "advanced microfusion cell"
|
|
desc = "A third generation microfusion cell, boasting a much higher shot count. Additionally, these come with support for up to three modifications to the cell itself."
|
|
icon_state = "microfusion_advanced"
|
|
maxcharge = STANDARD_CELL_CHARGE * 1.5
|
|
max_attachments = 2
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/bluespace
|
|
name = "bluespace microfusion cell"
|
|
desc = "A fourth generation microfusion cell, employing bluespace technology to store power in a medium that's bigger on the inside. This has the highest capacity of any man-portable cell, and has flexibility for four different attachments to the cell itself."
|
|
icon_state = "microfusion_bluespace"
|
|
maxcharge = STANDARD_CELL_CHARGE * 1.6
|
|
max_attachments = 3
|
|
|
|
/obj/item/stock_parts/power_store/cell/microfusion/nanocarbon
|
|
name = "nanocarbon fusion cell"
|
|
desc = "This cell combines both top-of-the-line nanotech and advanced microfusion power to brute force the most common issue of Nanotrasen Asset Protection operatives, ammunition, through sheer volume. Intended for use with Nanotrasen-brand capacitor arrays only. Warranty void if dropped in toilet."
|
|
icon_state = "microfusion_nanocarbon"
|
|
maxcharge = STANDARD_CELL_CHARGE * 60 // Wanted to put 69 here to fit with the 420 but eh this werks too
|
|
max_attachments = 420
|
|
|
|
|
|
#undef MICROFUSION_CELL_DRAIN_FAILURE
|
|
#undef MICROFUSION_CELL_EMP_HEAVY_FAILURE
|
|
#undef MICROFUSION_CELL_EMP_LIGHT_FAILURE
|
|
#undef MICROFUSION_CELL_RADIATION_RANGE_FAILURE
|
|
|
|
#undef MICROFUSION_CELL_FAILURE_LOWER
|
|
#undef MICROFUSION_CELL_FAILURE_UPPER
|