Refactoring hardsuit click checking.

This commit is contained in:
Zuhayr
2015-08-23 02:13:03 +09:30
parent a00ac82221
commit 90e51b87e3
7 changed files with 72 additions and 52 deletions

View File

@@ -89,27 +89,24 @@
*/
/mob/living/silicon/ai/ShiftClickOn(var/atom/A)
A.AIShiftClick(src)
if(A.AIShiftClick(src))
return
..()
/mob/living/silicon/ai/CtrlClickOn(var/atom/A)
A.AICtrlClick(src)
if(A.AICtrlClick(src))
return
..()
/mob/living/silicon/ai/AltClickOn(var/atom/A)
A.AIAltClick(src)
if(A.AIAltClick(src))
return
..()
/mob/living/silicon/ai/MiddleClickOn(var/atom/A)
A.AIMiddleClick(src)
/*
Sticking minor pAI and brain overrides into this because I can.
*/
/mob/living/silicon/pai/MiddleClickOn(var/atom/A)
if(src.loc == src.card)
return A.AIMiddleClick(src)
return ..()
/mob/living/carbon/brain/MiddleClickOn(var/atom/A)
if(istype(src.loc, /obj/item/device/mmi))
return A.AIMiddleClick(src)
return ..()
if(A.AIMiddleClick(src))
return
..()
/*
The following criminally helpful code is just the previous code cleaned up;
I have no idea why it was in atoms.dm instead of respective files.
@@ -131,7 +128,7 @@
Topic(src, list("src"= "\ref[src]", "command"="open", "activate" = "1"), 1) // 1 meaning no window (consistency!)
else
Topic(src, list("src"= "\ref[src]", "command"="open", "activate" = "0"), 1)
return
return 1
/atom/proc/AICtrlClick()
return
@@ -141,15 +138,18 @@
Topic(src, list("src"= "\ref[src]", "command"="bolts", "activate" = "0"), 1)// 1 meaning no window (consistency!)
else
Topic(src, list("src"= "\ref[src]", "command"="bolts", "activate" = "1"), 1)
return 1
/obj/machinery/power/apc/AICtrlClick() // turns off/on APCs.
Topic(src, list("src"= "\ref[src]", "breaker"="1"), 1) // 1 meaning no window (consistency!)
return 1
/obj/machinery/turretid/AICtrlClick() //turns off/on Turrets
Topic(src, list("src"= "\ref[src]", "command"="enable", "value"="[!enabled]"), 1) // 1 meaning no window (consistency!)
return 1
/atom/proc/AIAltClick(var/atom/A)
AltClick(A)
return AltClick(A)
/obj/machinery/door/airlock/AIAltClick() // Electrifies doors.
if(!electrified_until)
@@ -158,17 +158,13 @@
else
// disable/6 is not in Topic; disable/5 disables both temporary and permanent shock
Topic(src, list("src"= "\ref[src]", "command"="electrify_permanently", "activate" = "0"), 1)
return
return 1
/obj/machinery/turretid/AIAltClick() //toggles lethal on turrets
Topic(src, list("src"= "\ref[src]", "command"="lethal", "value"="[!lethal]"), 1) // 1 meaning no window (consistency!)
return 1
/atom/proc/AIMiddleClick(var/mob/living/silicon/user)
var/obj/item/weapon/rig/rig = user.get_rig()
if(rig && rig.wearer && rig.ai_can_move_suit(user, check_user_module = 1))
if(rig.wearer.HardsuitClickOn(src, alert_ai = 1))
message_admins("\The [user] ([user.ckey ? user.ckey : "*no key*"]) forced \the [rig.wearer] ([rig.wearer.ckey ? rig.wearer.ckey : "*no key*"]) to use hardsuit module on \the [src].")
return 1
return 0
/obj/machinery/door/airlock/AIMiddleClick() // Toggles door bolt lights.
@@ -180,7 +176,7 @@
Topic(src, list("src"= "\ref[src]", "command"="lights", "activate" = "1"), 1) // 1 meaning no window (consistency!)
else
Topic(src, list("src"= "\ref[src]", "command"="lights", "activate" = "0"), 1)
return
return 1
//
// Override AdjacentQuick for AltClicking

View File

@@ -280,7 +280,7 @@
else
user.listed_turf = T
user.client.statpanel = T.name
return
return 1
/mob/proc/TurfAdjacent(var/turf/T)
return T.AdjacentQuick(src)

View File

@@ -29,34 +29,53 @@
src << "Somehow you bugged the system. Setting your hardsuit mode to middle-click."
hardsuit_click_mode = MIDDLE_CLICK
/mob/living/carbon/human/MiddleClickOn(atom/A)
/mob/living/MiddleClickOn(atom/A)
if(client && client.hardsuit_click_mode == MIDDLE_CLICK)
if(HardsuitClickOn(A))
return
..()
/mob/living/carbon/human/AltClickOn(atom/A)
/mob/living/AltClickOn(atom/A)
if(client && client.hardsuit_click_mode == ALT_CLICK)
if(HardsuitClickOn(A))
return
..()
/mob/living/carbon/human/CtrlClickOn(atom/A)
/mob/living/CtrlClickOn(atom/A)
if(client && client.hardsuit_click_mode == CTRL_CLICK)
if(HardsuitClickOn(A))
return
..()
/mob/living/carbon/human/proc/HardsuitClickOn(var/atom/A, var/alert_ai = 0)
if(!canClick())
return
if(back)
var/obj/item/weapon/rig/rig = back
if(istype(rig) && rig.selected_module)
rig.selected_module.engage(A, alert_ai)
if(ismob(A)) // No instant mob attacking - though modules have their own cooldowns
setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
return 1
/mob/living/proc/can_use_rig()
return 0
/mob/living/carbon/human/can_use_rig()
return 1
/mob/living/carbon/brain/can_use_rig()
return istype(loc, /obj/item/device/mmi)
/mob/living/silicon/ai/can_use_rig()
return carded
/mob/living/silicon/pai/can_use_rig()
return loc == card
/mob/living/proc/HardsuitClickOn(var/atom/A, var/alert_ai = 0)
if(!can_use_rig() || !canClick())
return 0
var/obj/item/weapon/rig/rig = get_rig()
if(istype(rig) && !rig.offline && rig.selected_module)
if(src != rig.wearer)
if(rig.ai_can_move_suit(src, check_user_module = 1))
message_admins("\The [src] ([src.ckey ? src.ckey : "*no key*"]) is trying to force \the [rig.wearer] ([rig.wearer.ckey ? rig.wearer.ckey : "*no key*"]) to use a hardsuit module.")
else
return 0
rig.selected_module.engage(A, alert_ai)
if(ismob(A)) // No instant mob attacking - though modules have their own cooldowns
setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
return 1
return 0
#undef MIDDLE_CLICK

View File

@@ -105,6 +105,7 @@
if(istype(ai.loc, /turf/))
new /obj/structure/AIcore/deactivated(get_turf(ai))
ai.carded = 1
admin_attack_log(user, ai, "Carded with [src.name]", "Was carded with [src.name]", "used the [src.name] to card")
src.name = "[initial(name)] - [ai.name]"
@@ -127,6 +128,7 @@
/obj/item/device/aicard/proc/clear()
if(carded_ai && istype(carded_ai.loc, /turf))
carded_ai.canmove = 0
carded_ai.carded = 0
name = initial(name)
carded_ai = null
update_icon()

View File

@@ -894,6 +894,9 @@
/obj/item/weapon/rig/get_rig()
return src
/mob/living/carbon/human/get_rig()
return back
#undef ONLY_DEPLOY
#undef ONLY_RETRACT
#undef SEAL_DELAY

View File

@@ -126,7 +126,7 @@
/obj/machinery/portable_atmospherics/hydroponics/AltClick()
if(mechanical && !usr.stat && !usr.lying && Adjacent(usr))
close_lid(usr)
return
return 1
return ..()
/obj/machinery/portable_atmospherics/hydroponics/attack_ghost(var/mob/dead/observer/user)

View File

@@ -81,7 +81,7 @@ var/list/ai_verbs_default = list(
var/datum/ai_icon/selected_sprite // The selected icon set
var/custom_sprite = 0 // Whether the selected icon is custom
var/carded
/mob/living/silicon/ai/proc/add_ai_verbs()
src.verbs |= ai_verbs_default