mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 14:39:58 +01:00
[HOST] Removes auto-shoot from gunpointing (#12624)
* woo * pew pew * *actually done now
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
return
|
||||
var/mob/living/L = A
|
||||
if(gunpointing && L == gunpointing.target) //Cancelling a gunpoint by shift + MMB on the target
|
||||
gunpointing.ClickDestroy()
|
||||
gunpointing.click_destroy()
|
||||
else
|
||||
if(!CanGunpointAt(L, TRUE))
|
||||
return
|
||||
|
||||
@@ -9,26 +9,14 @@
|
||||
/datum/gunpoint
|
||||
var/mob/living/source
|
||||
var/mob/living/target
|
||||
var/datum/radial_menu/gunpoint/gunpoint_gui
|
||||
var/allow_move = FALSE
|
||||
var/allow_radio = FALSE
|
||||
var/allow_use = FALSE
|
||||
|
||||
var/obj/item/gun/aimed_gun
|
||||
|
||||
var/safeguard_time = 0
|
||||
var/next_autoshot = 0
|
||||
var/locked = FALSE
|
||||
var/was_running = FALSE
|
||||
|
||||
var/moved_counter = 0
|
||||
|
||||
var/static/radio_forbid = image(icon = 'modular_skyrat/modules/gunpoint/icons/radial_gunpoint.dmi', icon_state = "radial_radio_forbid")
|
||||
var/static/radio_allow = image(icon = 'modular_skyrat/modules/gunpoint/icons/radial_gunpoint.dmi', icon_state = "radial_radio")
|
||||
var/static/use_forbid = image(icon = 'modular_skyrat/modules/gunpoint/icons/radial_gunpoint.dmi', icon_state = "radial_use_forbid")
|
||||
var/static/use_allow = image(icon = 'modular_skyrat/modules/gunpoint/icons/radial_gunpoint.dmi', icon_state = "radial_use")
|
||||
var/static/move_forbid = image(icon = 'modular_skyrat/modules/gunpoint/icons/radial_gunpoint.dmi', icon_state = "radial_move_forbid")
|
||||
var/static/move_allow = image(icon = 'modular_skyrat/modules/gunpoint/icons/radial_gunpoint.dmi', icon_state = "radial_move")
|
||||
|
||||
/datum/gunpoint/New(user, tar, gun)
|
||||
source = user
|
||||
@@ -49,45 +37,25 @@
|
||||
target.gp_effect = new
|
||||
target.vis_contents += target.gp_effect
|
||||
|
||||
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/MovedReact)
|
||||
RegisterSignal(source, COMSIG_MOVABLE_MOVED, .proc/SourceMoved)
|
||||
RegisterSignal(source, COMSIG_MOVABLE_MOVED, .proc/source_moved)
|
||||
|
||||
RegisterSignal(target, COMSIG_MOB_FIRED_GUN, .proc/UseReact)
|
||||
RegisterSignal(source, COMSIG_LIVING_STATUS_STUN, .proc/source_cc)
|
||||
RegisterSignal(source, COMSIG_LIVING_STATUS_KNOCKDOWN, .proc/source_cc)
|
||||
RegisterSignal(source, COMSIG_LIVING_STATUS_PARALYZE, .proc/source_cc)
|
||||
RegisterSignal(source, COMSIG_LIVING_UPDATED_RESTING, .proc/source_updated_resting)
|
||||
|
||||
RegisterSignal(source, COMSIG_LIVING_STATUS_STUN, .proc/SourceCC)
|
||||
RegisterSignal(source, COMSIG_LIVING_STATUS_KNOCKDOWN, .proc/SourceCC)
|
||||
RegisterSignal(source, COMSIG_LIVING_STATUS_PARALYZE, .proc/SourceCC)
|
||||
RegisterSignal(source, COMSIG_LIVING_UPDATED_RESTING, .proc/SourceUpdatedResting)
|
||||
|
||||
RegisterSignal(aimed_gun, COMSIG_ITEM_EQUIPPED,.proc/ClickDestroy)
|
||||
RegisterSignal(aimed_gun, COMSIG_ITEM_DROPPED,.proc/ClickDestroy)
|
||||
|
||||
RegisterSignal(target, COMSIG_MOVABLE_RADIO_TALK_INTO,.proc/RadioReact)
|
||||
|
||||
RegisterSignal(target, COMSIG_MOB_ITEM_ATTACK, .proc/UseReact)
|
||||
RegisterSignal(target, COMSIG_HUMAN_MELEE_UNARMED_ATTACK, .proc/MeleeAttackReact)
|
||||
RegisterSignal(target, COMSIG_ITEM_ATTACK_SELF, .proc/UseReact)
|
||||
RegisterSignal(target, COMSIG_MOB_ITEM_AFTERATTACK, .proc/UseReact)
|
||||
RegisterSignal(aimed_gun, COMSIG_ITEM_EQUIPPED,.proc/click_destroy)
|
||||
RegisterSignal(aimed_gun, COMSIG_ITEM_DROPPED,.proc/click_destroy)
|
||||
|
||||
RegisterSignal(target, COMSIG_PARENT_QDELETING, .proc/Destroy)
|
||||
RegisterSignal(source, COMSIG_PARENT_QDELETING, .proc/Destroy)
|
||||
|
||||
|
||||
addtimer(CALLBACK(src, .proc/LockOn), 7)
|
||||
addtimer(CALLBACK(src, .proc/lock_on), 7)
|
||||
|
||||
/datum/gunpoint/proc/MeleeAttackReact(datum/source_datum, atom/target)
|
||||
SIGNAL_HANDLER
|
||||
if(!CheckContinuity())
|
||||
qdel(src)
|
||||
return
|
||||
if(!allow_use && CanReact())
|
||||
source.log_message("[source] shot [target] because they attacked/disarmed/pulled", LOG_ATTACK)
|
||||
to_chat(source, span_warning("You pull the trigger instinctively to [target.name] actions!"))
|
||||
INVOKE_ASYNC(src, .proc/ShootTarget)
|
||||
|
||||
/datum/gunpoint/proc/LockOn()
|
||||
/datum/gunpoint/proc/lock_on()
|
||||
if(src) //if we're not present then locking on failed and this datum is deleted
|
||||
if(!CheckContinuity())
|
||||
if(!check_continuity())
|
||||
qdel(src)
|
||||
return
|
||||
locked = TRUE
|
||||
@@ -96,15 +64,11 @@
|
||||
to_chat(source, span_notice("<b>You lock onto [target.name]!</b>"))
|
||||
target.visible_message(span_warning("<b>[source.name] holds [target.name] at gunpoint with the [aimed_gun.name]!</b>"), span_userdanger("[source.name] holds you at gunpoint with the [aimed_gun.name]!"))
|
||||
if(target.gunpointed.len == 1)//First case
|
||||
to_chat(target, span_danger("You'll <b>get shot</b> if you <b>use radio</b>, <b>move</b> or <b>interact with items</b>!"))
|
||||
to_chat(target, span_notice("You can however take items out, toss harmless items or drop them."))
|
||||
var/list/choice_list = ConstructChoiceList()
|
||||
gunpoint_gui = show_radial_menu_gunpoint(source, target , choice_list, select_proc = CALLBACK(src, .proc/GunpointGuiReact, source), radius = 42)
|
||||
to_chat(target, span_danger("You can move, but you see that [source.name] has a gun pointed at you!"))
|
||||
if(target.gp_effect.icon_state != "locked")
|
||||
target.gp_effect.icon_state = "locked"
|
||||
safeguard_time = world.time + 30
|
||||
|
||||
/datum/gunpoint/proc/CheckContinuity()
|
||||
/datum/gunpoint/proc/check_continuity()
|
||||
if(!target)
|
||||
return FALSE
|
||||
if(source.CanGunpointAt(target))
|
||||
@@ -113,7 +77,7 @@
|
||||
return FALSE
|
||||
|
||||
/datum/gunpoint/proc/CanReact()
|
||||
if(locked && (world.time >= safeguard_time) && !(target.stat == DEAD || target.stat == HARD_CRIT || target.stat == SOFT_CRIT) && source.next_move <= world.time && next_autoshot <= world.time)
|
||||
if(locked && !(target.stat == DEAD || target.stat == HARD_CRIT || target.stat == SOFT_CRIT) && source.next_move <= world.time)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
@@ -131,138 +95,29 @@
|
||||
target.gunpointed -= src
|
||||
source.gunpointing = null
|
||||
if(locked)
|
||||
QDEL_NULL(gunpoint_gui)
|
||||
target.visible_message(span_notice("[source.name] no longer holds [target.name] at gunpoint."), span_notice("<b>[source.name] no longer holds you at gunpoint.</b>"))
|
||||
source = null
|
||||
target = null
|
||||
aimed_gun = null
|
||||
return ..()
|
||||
|
||||
/datum/gunpoint/proc/ClickDestroy()
|
||||
/datum/gunpoint/proc/click_destroy()
|
||||
SIGNAL_HANDLER
|
||||
if(locked)
|
||||
playsound(get_turf(source), 'modular_skyrat/modules/gunpoint/sound/targetoff.ogg', 50,1)
|
||||
qdel(src)
|
||||
|
||||
/datum/gunpoint/proc/SourceCC(datum/source, amount, update, ignore)
|
||||
/datum/gunpoint/proc/source_cc(datum/source, amount, update, ignore)
|
||||
SIGNAL_HANDLER
|
||||
if(amount && !ignore)
|
||||
qdel(src)
|
||||
|
||||
/datum/gunpoint/proc/ShootTarget()
|
||||
next_autoshot = world.time + 5
|
||||
log_combat(target, source, "auto-shot with aim")
|
||||
aimed_gun.afterattack(target, source)
|
||||
|
||||
/datum/gunpoint/proc/RadioReact(datum/datum_source, obj/item/radio/radio, message, channel, list/spans, datum/language/language, direct)
|
||||
/datum/gunpoint/proc/source_moved(datum/datum_source)
|
||||
SIGNAL_HANDLER
|
||||
if(!allow_radio && CanReact())
|
||||
if(direct)
|
||||
source.log_message("[source] shot [target] because they spoke on radio", LOG_ATTACK)
|
||||
to_chat(source, span_warning("You pull the trigger instinctively as [target.name] speaks on the radio!"))
|
||||
INVOKE_ASYNC(src, .proc/ShootTarget)
|
||||
|
||||
/datum/gunpoint/proc/MovedReact(datum/datum_source, atom/moved, direction, forced)
|
||||
SIGNAL_HANDLER
|
||||
if(!CheckContinuity())
|
||||
qdel(src)
|
||||
return
|
||||
if(!allow_move && CanReact() && !(target.pulledby && target.pulledby == source)) //Don't shoot him if we're pulling them
|
||||
INVOKE_ASYNC(src, .proc/MovedShootProc)
|
||||
|
||||
/datum/gunpoint/proc/MovedShootProc() //This exists in case of someone moving several tiles in one tick, such as dashes or diagonal movement
|
||||
moved_counter += 1
|
||||
var/count = moved_counter
|
||||
sleep(1)
|
||||
if(src && count == moved_counter)
|
||||
source.log_message("[source] shot [target] because they moved", LOG_ATTACK)
|
||||
ShootTarget()
|
||||
|
||||
/datum/gunpoint/proc/UseReact(datum/datum_source)
|
||||
if(!CheckContinuity())
|
||||
qdel(src)
|
||||
return
|
||||
if(!allow_use && CanReact())
|
||||
source.log_message("[source] shot [target] because they used an item", LOG_ATTACK)
|
||||
to_chat(source, span_warning("You pull the trigger instinctively as [target.name] uses an item!"))
|
||||
ShootTarget()
|
||||
|
||||
/datum/gunpoint/proc/SourceMoved(datum/datum_source)
|
||||
SIGNAL_HANDLER
|
||||
if(!CheckContinuity())
|
||||
if(!check_continuity())
|
||||
qdel(src)
|
||||
|
||||
/datum/gunpoint/proc/SourceUpdatedResting(datum/datum_source, resting)
|
||||
/datum/gunpoint/proc/source_updated_resting(datum/datum_source, resting)
|
||||
SIGNAL_HANDLER
|
||||
if(resting)
|
||||
qdel(src)
|
||||
|
||||
/datum/gunpoint/proc/ConstructChoiceList()
|
||||
var/image/radio_image = (allow_radio ? radio_allow : radio_forbid)
|
||||
var/image/use_image = (allow_use ? use_allow : use_forbid)
|
||||
var/image/move_image = (allow_move ? move_allow : move_forbid)
|
||||
var/list/L = list("radio" = radio_image, "use" = use_image, "move" = move_image)
|
||||
return L
|
||||
|
||||
/datum/gunpoint/proc/GunpointGuiReact(mob/living/user,choice)
|
||||
switch(choice)
|
||||
if("radio")
|
||||
allow_radio = !allow_radio
|
||||
if(allow_radio)
|
||||
var/safe = TRUE
|
||||
for(var/datum/gunpoint/gp in target.gunpointed)
|
||||
if(gp.allow_radio == FALSE)
|
||||
safe = FALSE
|
||||
break
|
||||
if(safe)
|
||||
to_chat(target, span_notice("[source.name] signals you can <b>use radio</b>."))
|
||||
else
|
||||
to_chat(target, span_danger("[source.name] signals you can use radio, however other people still don't"))
|
||||
else
|
||||
var/forbid_counts = 0
|
||||
for(var/datum/gunpoint/gp in target.gunpointed)
|
||||
if(gp.allow_radio == FALSE)
|
||||
forbid_counts += 1
|
||||
if(forbid_counts == 1) //Only first one warns the victim
|
||||
to_chat(target, span_danger("[source.name] signals you can't <b>use radio</b>."))
|
||||
if("use")
|
||||
allow_use = !allow_use
|
||||
if(allow_use)
|
||||
var/safe = TRUE
|
||||
for(var/datum/gunpoint/gp in target.gunpointed)
|
||||
if(gp.allow_use == FALSE)
|
||||
safe = FALSE
|
||||
break
|
||||
if(safe)
|
||||
to_chat(target, span_notice("[source.name] signals you can <b>interact with items</b>."))
|
||||
else
|
||||
to_chat(target, span_danger("[source.name] signals you can interact with items, however other people still don't"))
|
||||
else
|
||||
var/forbid_counts = 0
|
||||
for(var/datum/gunpoint/gp in target.gunpointed)
|
||||
if(gp.allow_use == FALSE)
|
||||
forbid_counts += 1
|
||||
if(forbid_counts == 1) //Only first one warns the victim
|
||||
to_chat(target, span_danger("[source.name] signals you can't <b>interact with items</b>."))
|
||||
if("move")
|
||||
allow_move = !allow_move
|
||||
if(allow_move)
|
||||
var/safe = TRUE
|
||||
for(var/datum/gunpoint/gp in target.gunpointed)
|
||||
if(gp.allow_move == FALSE)
|
||||
safe = FALSE
|
||||
break
|
||||
if(safe)
|
||||
to_chat(target, span_notice("[source.name] signals you can <b>move</b>."))
|
||||
else
|
||||
to_chat(target, span_danger("[source.name] signals you can move, however other people still don't"))
|
||||
else
|
||||
var/forbid_counts = 0
|
||||
for(var/datum/gunpoint/gp in target.gunpointed)
|
||||
if(gp.allow_move == FALSE)
|
||||
forbid_counts += 1
|
||||
if(forbid_counts == 1) //Only first one warns the victim
|
||||
to_chat(target, span_danger("[source.name] signals you can't <b>move</b>."))
|
||||
var/list/new_choices = ConstructChoiceList()
|
||||
gunpoint_gui.entry_animation = FALSE
|
||||
gunpoint_gui.change_choices(new_choices,FALSE)
|
||||
|
||||
Reference in New Issue
Block a user