mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Fixes #9447.
The inteliCard now has a NanoUI interface, allowing it to utilize custom CanUseTopic() checks depending on context, in-hand or in-rig.
This commit is contained in:
@@ -1321,6 +1321,7 @@
|
|||||||
#include "code\modules\nano\interaction\contained.dm"
|
#include "code\modules\nano\interaction\contained.dm"
|
||||||
#include "code\modules\nano\interaction\default.dm"
|
#include "code\modules\nano\interaction\default.dm"
|
||||||
#include "code\modules\nano\interaction\inventory.dm"
|
#include "code\modules\nano\interaction\inventory.dm"
|
||||||
|
#include "code\modules\nano\interaction\inventory_deep.dm"
|
||||||
#include "code\modules\nano\interaction\physical.dm"
|
#include "code\modules\nano\interaction\physical.dm"
|
||||||
#include "code\modules\nano\interaction\self.dm"
|
#include "code\modules\nano\interaction\self.dm"
|
||||||
#include "code\modules\nano\interaction\zlevel.dm"
|
#include "code\modules\nano\interaction\zlevel.dm"
|
||||||
|
|||||||
@@ -18,93 +18,70 @@
|
|||||||
user << "<b>ERROR ERROR ERROR</b>"
|
user << "<b>ERROR ERROR ERROR</b>"
|
||||||
|
|
||||||
/obj/item/device/aicard/attack_self(mob/user)
|
/obj/item/device/aicard/attack_self(mob/user)
|
||||||
if (!in_range(src, user))
|
ui_interact(user)
|
||||||
return
|
|
||||||
user.set_machine(src)
|
|
||||||
var/dat = "<TT><B>Intelicard</B><BR>"
|
|
||||||
var/laws
|
|
||||||
for(var/mob/living/silicon/ai/A in src)
|
|
||||||
dat += "Stored AI: [A.name]<br>System integrity: [A.system_integrity()]%<br>"
|
|
||||||
|
|
||||||
for (var/datum/ai_law/law in A.laws.all_laws())
|
/obj/item/device/aicard/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = inventory_state)
|
||||||
laws += "[law.get_index()]: [law.law]<BR>"
|
var/data[0]
|
||||||
|
data["has_ai"] = carded_ai != null
|
||||||
|
if(carded_ai)
|
||||||
|
data["name"] = carded_ai.name
|
||||||
|
data["integrity"] = carded_ai.system_integrity()
|
||||||
|
data["radio"] = !carded_ai.aiRadio.disabledAi
|
||||||
|
data["wireless"] = !carded_ai.control_disabled
|
||||||
|
data["operational"] = carded_ai.stat != DEAD
|
||||||
|
data["flushing"] = flush
|
||||||
|
|
||||||
dat += "Laws:<br>[laws]<br>"
|
var/laws[0]
|
||||||
|
for(var/datum/ai_law/AL in carded_ai.laws.all_laws())
|
||||||
|
laws[++laws.len] = list("index" = AL.get_index(), "law" = sanitize(AL.law))
|
||||||
|
data["laws"] = laws
|
||||||
|
data["has_laws"] = laws.len
|
||||||
|
|
||||||
if (A.stat == 2)
|
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||||
dat += "<b>AI nonfunctional</b>"
|
if (!ui)
|
||||||
else
|
ui = new(user, src, ui_key, "aicard.tmpl", "[name]", 600, 400, state = state)
|
||||||
if (!src.flush)
|
ui.set_initial_data(data)
|
||||||
dat += {"<A href='byond://?src=\ref[src];choice=Wipe'>Wipe AI</A>"}
|
ui.open()
|
||||||
else
|
ui.set_auto_update(1)
|
||||||
dat += "<b>Wipe in progress</b>"
|
|
||||||
dat += "<br>"
|
|
||||||
dat += {"<a href='byond://?src=\ref[src];choice=Wireless'>[A.control_disabled ? "Enable" : "Disable"] Wireless Activity</a>"}
|
|
||||||
dat += "<br>"
|
|
||||||
dat += {"<a href='byond://?src=\ref[src];choice=Radio'>[A.aiRadio.disabledAi ? "Enable" : "Disable"] Subspace Transceiver</a>"}
|
|
||||||
dat += "<br>"
|
|
||||||
dat += {"<a href='byond://?src=\ref[src];choice=Close'> Close</a>"}
|
|
||||||
user << browse(dat, "window=aicard")
|
|
||||||
onclose(user, "aicard")
|
|
||||||
return
|
|
||||||
|
|
||||||
/obj/item/device/aicard/Topic(href, href_list)
|
/obj/item/device/aicard/Topic(href, href_list, nowindow, state)
|
||||||
|
if(..())
|
||||||
|
return 1
|
||||||
|
|
||||||
var/mob/U = usr
|
if(!carded_ai)
|
||||||
if (get_dist(get_turf(U),get_turf(src)) > 1 || U.machine != src)//If they are not in range of 1 or less or their machine is not the card (ie, clicked on something else).
|
return 1
|
||||||
U << browse(null, "window=aicard")
|
|
||||||
U.unset_machine()
|
|
||||||
return
|
|
||||||
|
|
||||||
add_fingerprint(U)
|
var/user = usr
|
||||||
U.set_machine(src)
|
if (href_list["wipe"])
|
||||||
|
var/confirm = alert("Are you sure you want to wipe this card's memory? This cannot be undone once started.", "Confirm Wipe", "Yes", "No")
|
||||||
|
if(confirm == "Yes" && (CanUseTopic(user, state) == STATUS_INTERACTIVE))
|
||||||
|
admin_attack_log(user, carded_ai, "Wiped using \the [src.name]", "Was wiped with \the [src.name]", "used \the [src.name] to wipe")
|
||||||
|
flush = 1
|
||||||
|
carded_ai.suiciding = 1
|
||||||
|
carded_ai << "Your core files are being wiped!"
|
||||||
|
while (carded_ai && carded_ai.stat != 2)
|
||||||
|
carded_ai.adjustOxyLoss(2)
|
||||||
|
carded_ai.updatehealth()
|
||||||
|
sleep(10)
|
||||||
|
flush = 0
|
||||||
|
if (href_list["radio"])
|
||||||
|
carded_ai.aiRadio.disabledAi = text2num(href_list["radio"])
|
||||||
|
carded_ai << "<span class='warning'>Your Subspace Transceiver has been [carded_ai.aiRadio.disabledAi ? "disabled" : "enabled"]!</span>"
|
||||||
|
user << "<span class='notice'>You [carded_ai.aiRadio.disabledAi ? "disable" : "enable"] the AI's Subspace Transceiver.</span>"
|
||||||
|
if (href_list["wireless"])
|
||||||
|
carded_ai.control_disabled = text2num(href_list["wireless"])
|
||||||
|
carded_ai << "<span class='warning'>Your wireless interface has been [carded_ai.control_disabled ? "disabled" : "enabled"]!</span>"
|
||||||
|
user << "<span class='notice'>You [carded_ai.control_disabled ? "disable" : "enable"] the AI's wireless interface.</span>"
|
||||||
|
update_icon()
|
||||||
|
|
||||||
switch(href_list["choice"])//Now we switch based on choice.
|
return 1
|
||||||
if ("Close")
|
|
||||||
U << browse(null, "window=aicard")
|
|
||||||
U.unset_machine()
|
|
||||||
return
|
|
||||||
|
|
||||||
if ("Radio")
|
|
||||||
for(var/mob/living/silicon/ai/A in src)
|
|
||||||
A.aiRadio.disabledAi = !A.aiRadio.disabledAi
|
|
||||||
A << "Your Subspace Transceiver has been: [A.aiRadio.disabledAi ? "disabled" : "enabled"]"
|
|
||||||
U << "You [A.aiRadio.disabledAi ? "Disable" : "Enable"] the AI's Subspace Transceiver"
|
|
||||||
|
|
||||||
if ("Wipe")
|
|
||||||
var/confirm = alert("Are you sure you want to wipe this card's memory? This cannot be undone once started.", "Confirm Wipe", "Yes", "No")
|
|
||||||
if(confirm == "Yes")
|
|
||||||
if(isnull(src)||!in_range(src, U)||U.machine!=src)
|
|
||||||
U << browse(null, "window=aicard")
|
|
||||||
U.unset_machine()
|
|
||||||
return
|
|
||||||
else
|
|
||||||
flush = 1
|
|
||||||
for(var/mob/living/silicon/ai/A in src)
|
|
||||||
A.suiciding = 1
|
|
||||||
A << "Your core files are being wiped!"
|
|
||||||
while (A.stat != 2)
|
|
||||||
A.adjustOxyLoss(2)
|
|
||||||
A.updatehealth()
|
|
||||||
sleep(10)
|
|
||||||
flush = 0
|
|
||||||
|
|
||||||
if ("Wireless")
|
|
||||||
for(var/mob/living/silicon/ai/A in src)
|
|
||||||
A.control_disabled = !A.control_disabled
|
|
||||||
A << "The intelicard's wireless port has been [A.control_disabled ? "disabled" : "enabled"]!"
|
|
||||||
update_icon()
|
|
||||||
attack_self(U)
|
|
||||||
|
|
||||||
/obj/item/device/aicard/update_icon()
|
/obj/item/device/aicard/update_icon()
|
||||||
var/mob/living/silicon/ai/occupant = locate() in src
|
|
||||||
overlays.Cut()
|
overlays.Cut()
|
||||||
if(occupant)
|
if(carded_ai)
|
||||||
if (occupant.control_disabled)
|
if (!carded_ai.control_disabled)
|
||||||
overlays -= image('icons/obj/pda.dmi', "aicard-on")
|
|
||||||
else
|
|
||||||
overlays += image('icons/obj/pda.dmi', "aicard-on")
|
overlays += image('icons/obj/pda.dmi', "aicard-on")
|
||||||
if(occupant.stat)
|
if(carded_ai.stat)
|
||||||
icon_state = "aicard-404"
|
icon_state = "aicard-404"
|
||||||
else
|
else
|
||||||
icon_state = "aicard-full"
|
icon_state = "aicard-full"
|
||||||
@@ -112,23 +89,23 @@
|
|||||||
icon_state = "aicard"
|
icon_state = "aicard"
|
||||||
|
|
||||||
/obj/item/device/aicard/proc/grab_ai(var/mob/living/silicon/ai/ai, var/mob/living/user)
|
/obj/item/device/aicard/proc/grab_ai(var/mob/living/silicon/ai/ai, var/mob/living/user)
|
||||||
|
|
||||||
if(!ai.client)
|
if(!ai.client)
|
||||||
user << "\red <b>ERROR</b>: \black [name] data core is offline. Unable to download."
|
user << "<span class='danger'>ERROR:</span> [name] data core is offline. Unable to download."
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if(locate(/mob/living/silicon/ai) in src)
|
if(carded_ai)
|
||||||
user << "\red <b>Transfer failed</b>: \black Existing AI found on remote terminal. Remove existing AI to install a new one."
|
user << "<span class='danger'>Transfer failed:</span> Existing AI found on remote terminal. Remove existing AI to install a new one."
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if(ai.is_malf())
|
if(ai.is_malf())
|
||||||
user << "\red <b>ERROR</b>: \black Remote transfer interface disabled."
|
user << "<span class='danger'>ERROR:</span> Remote transfer interface disabled."
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if(istype(ai.loc, /turf/))
|
if(istype(ai.loc, /turf/))
|
||||||
new /obj/structure/AIcore/deactivated(get_turf(ai))
|
new /obj/structure/AIcore/deactivated(get_turf(ai))
|
||||||
|
|
||||||
src.name = "inteliCard - [ai.name]"
|
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]"
|
||||||
|
|
||||||
ai.loc = src
|
ai.loc = src
|
||||||
ai.cancel_camera()
|
ai.cancel_camera()
|
||||||
@@ -137,11 +114,6 @@
|
|||||||
ai.aiRadio.disabledAi = 1
|
ai.aiRadio.disabledAi = 1
|
||||||
carded_ai = ai
|
carded_ai = ai
|
||||||
|
|
||||||
|
|
||||||
ai.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been carded with [src.name] by [user.name] ([user.ckey])</font>")
|
|
||||||
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Used the [src.name] to card [ai.name] ([ai.ckey])</font>")
|
|
||||||
msg_admin_attack("[user.name] ([user.ckey]) used the [src.name] to card [ai.name] ([ai.ckey]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
|
|
||||||
|
|
||||||
if(ai.client)
|
if(ai.client)
|
||||||
ai << "You have been downloaded to a mobile storage device. Remote access lost."
|
ai << "You have been downloaded to a mobile storage device. Remote access lost."
|
||||||
if(user.client)
|
if(user.client)
|
||||||
@@ -151,7 +123,7 @@
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
/obj/item/device/aicard/proc/clear()
|
/obj/item/device/aicard/proc/clear()
|
||||||
name = "inteliCard"
|
name = initial(name)
|
||||||
carded_ai = null
|
carded_ai = null
|
||||||
update_icon()
|
update_icon()
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@
|
|||||||
if(!target)
|
if(!target)
|
||||||
if(ai_card)
|
if(ai_card)
|
||||||
if(istype(ai_card,/obj/item/device/aicard))
|
if(istype(ai_card,/obj/item/device/aicard))
|
||||||
ai_card.attack_self(H)
|
ai_card.ui_interact(H, state = deep_inventory_state)
|
||||||
else
|
else
|
||||||
eject_ai(H)
|
eject_ai(H)
|
||||||
update_verb_holder()
|
update_verb_holder()
|
||||||
|
|||||||
@@ -234,7 +234,7 @@
|
|||||||
SetupStat(R)
|
SetupStat(R)
|
||||||
|
|
||||||
/mob/proc/SetupStat(var/obj/item/weapon/rig/R)
|
/mob/proc/SetupStat(var/obj/item/weapon/rig/R)
|
||||||
if(R && !R.canremove && R.installed_modules.len && statpanel("Hardsuit Modules"))
|
if(src == usr && R && !R.canremove && R.installed_modules.len && statpanel("Hardsuit Modules"))
|
||||||
var/cell_status = R.cell ? "[R.cell.charge]/[R.cell.maxcharge]" : "ERROR"
|
var/cell_status = R.cell ? "[R.cell.charge]/[R.cell.maxcharge]" : "ERROR"
|
||||||
statpanel("Hardsuit Modules", "Suit charge", cell_status)
|
statpanel("Hardsuit Modules", "Suit charge", cell_status)
|
||||||
for(var/obj/item/rig_module/module in R.installed_modules)
|
for(var/obj/item/rig_module/module in R.installed_modules)
|
||||||
|
|||||||
10
code/modules/nano/interaction/inventory_deep.dm
Normal file
10
code/modules/nano/interaction/inventory_deep.dm
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
This state checks if src_object is contained anywhere in the user's inventory, including bags, etc.
|
||||||
|
*/
|
||||||
|
/var/global/datum/topic_state/deep_inventory_state/deep_inventory_state = new()
|
||||||
|
|
||||||
|
/datum/topic_state/deep_inventory_state/can_use_topic(var/src_object, var/mob/user)
|
||||||
|
if(!user.contains(src_object))
|
||||||
|
return STATUS_CLOSE
|
||||||
|
|
||||||
|
return user.shared_nano_interaction()
|
||||||
97
nano/templates/aicard.tmpl
Normal file
97
nano/templates/aicard.tmpl
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<!--
|
||||||
|
Title: inteliCard interface
|
||||||
|
Used In File(s): \code\game\objects\items\devices\aicard.dm
|
||||||
|
-->
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
table.borders {
|
||||||
|
width:95%;
|
||||||
|
margin-left:2.4%;
|
||||||
|
margin-right:2.4%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.borders, table.borders tr {
|
||||||
|
border: 1px solid White;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.law_index {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.state {
|
||||||
|
width: 63px;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.add {
|
||||||
|
width: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.edit {
|
||||||
|
width: 36px;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.delete {
|
||||||
|
width: 53px;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.law_type {
|
||||||
|
width: 65px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.position {
|
||||||
|
width: 37px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{{if data.has_ai}}
|
||||||
|
<div class="item">
|
||||||
|
<div class="itemLabelNarrow">
|
||||||
|
Integrity:
|
||||||
|
</div>
|
||||||
|
<div class="itemContentWide">
|
||||||
|
{{:data.integrity}}%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{if data.has_laws}}
|
||||||
|
<table class='borders'>
|
||||||
|
<tr><td class='law_index'>Index</td><td>Law</td></tr>
|
||||||
|
|
||||||
|
<div class="itemLabelNarrow">
|
||||||
|
Laws:
|
||||||
|
</div>
|
||||||
|
{{for data.laws}}
|
||||||
|
<tr><td valign="top">{{:value.index}}.</td><td>{{:value.law}}</td></tr>
|
||||||
|
{{/for}}
|
||||||
|
</table>
|
||||||
|
{{else}}
|
||||||
|
<span class='notice'>No laws found.</span>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if data.operational}}
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><span class='itemLabelWidest'>Radio Subspace Transceiver</span></td>
|
||||||
|
<td>{{:helper.link("Enabled", null, {'radio' : 0}, data.radio ? 'selected' : null)}}</td>
|
||||||
|
<td>{{:helper.link("Disabled", null, {'radio' : 1}, data.radio ? null : 'redButton' )}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr><td><span class='itemLabelWidest'>Wireless Interface</span></td>
|
||||||
|
<td>{{:helper.link("Enabled", null, {'wireless' : 0}, data.wireless ? 'selected' : null)}}</td>
|
||||||
|
<td>{{:helper.link("Disabled", null, {'wireless' : 1}, data.wireless ? null : 'redButton' )}}</td>
|
||||||
|
</tr>
|
||||||
|
{{if data.flushing}}
|
||||||
|
<tr><td><span class='notice'>AI wipe in progress...</span></td></tr>
|
||||||
|
{{else}}
|
||||||
|
<tr>
|
||||||
|
<td><span class='itemLabelWidest'>Wipe AI</span></td>
|
||||||
|
<td>{{:helper.link("Wipe", 'radiation', {'wipe' : 1}, null, 'redButton')}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/if}}
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
Stored AI: <span class='notice'>No AI detected.</span>
|
||||||
|
{{/if}}
|
||||||
Reference in New Issue
Block a user