diff --git a/code/game/objects/items/grenades/plastic.dm b/code/game/objects/items/grenades/plastic.dm index 89ad58bf1a1..39f6159177b 100644 --- a/code/game/objects/items/grenades/plastic.dm +++ b/code/game/objects/items/grenades/plastic.dm @@ -91,6 +91,7 @@ if(!user.temporarilyRemoveItemFromInventory(src)) return target = bomb_target + active = TRUE message_admins("[ADMIN_LOOKUPFLW(user)] planted [name] on [target.name] at [ADMIN_VERBOSEJMP(target)] with [det_time] second fuse") log_game("[key_name(user)] planted [name] on [target.name] at [AREACOORD(user)] with a [det_time] second fuse") diff --git a/code/modules/ninja/ninja_explosive.dm b/code/modules/ninja/ninja_explosive.dm index 2e87264f059..746313099cc 100644 --- a/code/modules/ninja/ninja_explosive.dm +++ b/code/modules/ninja/ninja_explosive.dm @@ -10,22 +10,46 @@ 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) - var/mob/detonator = null + ///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/afterattack(atom/movable/AM, mob/user, flag) - var/datum/antagonist/ninja/ninja_antag = user.mind.has_antag_datum(/datum/antagonist/ninja) - if(!ninja_antag) - to_chat(user, span_notice("While it appears normal, you can't seem to detonate the charge.")) +/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 - if (!check_loc(user, ninja_antag)) + var/datum/objective/plant_explosive/objective = locate() in ninja_antag.objectives + if (!objective) return - detonator = user + 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) - var/datum/antagonist/ninja/ninja_antag = detonator.mind.has_antag_datum(/datum/antagonist/ninja) - if(!check_loc(detonator, ninja_antag)) // if its moved, deactivate the c4 - new /obj/item/grenade/c4/ninja(target.loc) + 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 @@ -33,18 +57,27 @@ //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 (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 -/obj/item/grenade/c4/ninja/proc/check_loc(mob/user, datum/antagonist/ninja/ninja_antag) - var/datum/objective/plant_explosive/objective = locate() in ninja_antag.objectives - if(!objective) +/** + * 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(objective.detonation_location != get_area(user)) - if (active) - say("Invalid location!") // TODO: make c4 code not be complete shit and actually set active to true - else + 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 diff --git a/code/modules/ninja/outfit.dm b/code/modules/ninja/outfit.dm index 8fc07803478..dca30db4324 100644 --- a/code/modules/ninja/outfit.dm +++ b/code/modules/ninja/outfit.dm @@ -15,8 +15,11 @@ implants = list(/obj/item/implant/explosive) -/datum/outfit/ninja/post_equip(mob/living/carbon/human/H) - if(istype(H.wear_suit, suit)) - var/obj/item/clothing/suit/space/space_ninja/S = H.wear_suit - if(istype(H.belt, belt)) - S.energyKatana = H.belt +/datum/outfit/ninja/post_equip(mob/living/carbon/human/human) + if(istype(human.wear_suit, suit)) + var/obj/item/clothing/suit/space/space_ninja/ninja_suit = human.wear_suit + if(istype(human.belt, belt)) + ninja_suit.energyKatana = human.belt + if(istype(human.l_store, l_pocket)) + var/obj/item/grenade/c4/ninja/charge = human.l_store + charge.set_detonation_area(human.mind?.has_antag_datum(/datum/antagonist/ninja))