Files
Bubberstation/code/modules/ninja/ninja_explosive.dm
SkyratBot a71688c5e3 [MIRROR] [s] Makes used grenades slightly more obvious. Also prevents DOSing admins. [MDB IGNORE] (#11307)
* [s] Makes used grenades slightly more obvious. Also prevents DOSing admins. (#64643)

* Makes used grenades slightly more obvious.

Adds a variable to tell whether a grenade can't detonate properly.
Examining can be used to tell if the grenade has already been used.
A flag on it is set when the grenade detonates so that used grenades can't be reused until it's reset.
It also prevents spamming admins with grenade primed messages since there's no point if the grenade won't work.

* Changes dud var to dud flags.

Changes the name of the dud var to dud_flags to clarify that it is a set of bitfields.
Changes the default value of the dud var to NONE also to clarify that it is a set of bitfields.
Changes the documentation for the dud var to clarify that it is a set of bitfields.

* Fixes eternally armed dud grenades.

Makes the grenades reset their appearance if they reach the end of their fuse while a dud.
Prevents chemical grenades from staying in the 'i am armed' visual state forever.

* [s] Makes used grenades slightly more obvious. Also prevents DOSing admins.

Co-authored-by: TemporalOroboros <TemporalOroboros@gmail.com>
2022-02-06 13:50:40 +00:00

87 lines
2.9 KiB
Plaintext

/**
* # Spider Charge
*
* A unique version of c4 possessed only by the space ninja. Has a stronger blast radius.
* Can only be detonated by space ninjas with the bombing objective. Can only be set up where the objective says it can.
* When it primes, the space ninja responsible will have their objective set to complete.
*
*/
/obj/item/grenade/c4/ninja
name = "spider charge"
desc = "A modified C-4 charge supplied to you by the Spider Clan. Its explosive power has been juiced up, but only works in one specific area."
boom_sizes = list(4, 8, 12)
///Weakref to the mob that has planted the charge
var/datum/weakref/detonator
///The only area that the charge is allowed to be planted, and detonated in
var/area/detonation_area
/obj/item/grenade/c4/ninja/Destroy()
detonator = null
detonation_area = null
return ..()
/**
* set_detonation_area
*
* Proc used to set the allowed location for charge detonation
*
* Arguments
* * datum/antagonist/ninja/ninja_antag - The antag datum for the owner of the c4
*/
/obj/item/grenade/c4/ninja/proc/set_detonation_area(datum/antagonist/ninja/ninja_antag)
if (!ninja_antag)
return
var/datum/objective/plant_explosive/objective = locate() in ninja_antag.objectives
if (!objective)
return
detonation_area = objective.detonation_location
/obj/item/grenade/c4/ninja/afterattack(atom/movable/AM, mob/ninja, flag)
if(!IS_SPACE_NINJA(ninja))
to_chat(ninja, span_notice("While it appears normal, you can't seem to detonate the charge."))
return
if (!check_loc(ninja))
return
detonator = WEAKREF(ninja)
return ..()
/obj/item/grenade/c4/ninja/detonate(mob/living/lanced_by)
if(!check_loc(detonator.resolve())) // if its moved, deactivate the c4
var/obj/item/grenade/c4/ninja/new_c4 = new /obj/item/grenade/c4/ninja(target.loc)
new_c4.detonation_area = detonation_area
new_c4.say("Invalid location!")
target.cut_overlay(plastic_overlay, TRUE)
qdel(src)
return
//Since we already did the checks in afterattack, the denonator must be a ninja with the bomb objective.
if(!detonator)
return
var/mob/ninja = detonator.resolve()
. = ..()
if(!.)
return
if (isnull(ninja))
return
var/datum/antagonist/ninja/ninja_antag = ninja.mind.has_antag_datum(/datum/antagonist/ninja)
var/datum/objective/plant_explosive/objective = locate() in ninja_antag.objectives
objective.completed = TRUE
/**
* check_loc
*
* Checks to see if the c4 is in the correct place when being planted.
*
* Arguments
* * mob/user - The planter of the c4
*/
/obj/item/grenade/c4/ninja/proc/check_loc(mob/user)
if(!detonation_area)
to_chat(user, span_notice("You can't seem to activate the charge. It's location-locked, but you don't know where to detonate it."))
return FALSE
if((get_area(target) != detonation_area) && (get_area(src) != detonation_area))
if (!active)
to_chat(user, span_notice("This isn't the location you're supposed to use this!"))
return FALSE
return TRUE