Files
Yogstation/code/_onclick/ai.dm
TheGamerdk 2e787af654 AI Rework | 2024 edition (#21266)
* fix ui

* oops

* Fixes map bibby broke

* Revert "Fixes map bibby broke"

This reverts commit af1d1c610e.

* e

* Unfucks deltastation

* stuff

* cleans things after bibby

* Fix subcontroller cache

* Fixed APCs and air alarms not working when connected to a subcontroller

* bunch of fixes

* job icon

* tcomms server

Update traffic_control.dm

* make compile

* Update synthetic.dm

* Update synthetic.dm

* Update access.dm

* er

* le runtime

* Update ai_data_core.dm

* le dupe

* wall

* Update decentralized_ai.dm

* Update decentralized_ai.dm

* e

* Update wy_synths.dm

* we do a little trolling

* e

* small cahnges

* more minor changes

* Create conflict_fixer.dmm

* Create conflict_fixer - Kopi.dmm

* minor map cahnges

* broken maps

* oops

* bon

* Update ainetworkinterface.dm

* Update ainetworkinterface.dm

* Update ai.dm

* lol

* light

* fixes

* e

* Update synth_pod.dm

* e

* Update synth_os.dm

* Update objective.dm

* fixes

* Update synthetic.dm

* e

* antag

* tweaks

* e

* Update VRSleeper.js

* e

* Update synth_pod.dm

* Update synth_pod.dm

* 1

* Update synth_pod.dm

* Update synth_os.dm

* Update synthetic.dm

* fixes

* headset and ID go boom

* Update wy_synths.dm

* Update robot_parts.dm

* cremator

* Update communications.dm

* Update synthetic.dm

* no synth control

* Update synthetic.dm

* Update ai_dashboard.dm

* Update miscellaneous.dm

* Update miscellaneous.dm

* Update headset.dm

* Update damage_procs.dm

* Update server_cabinet.dm

* minor fixes

* Update miscellaneous.dm

* Update rack_creator.dm

* Update synthetic.dm

* compiles

* fixes

* brainless

* access request

* cofnlict

* fixes

* controller

* Update yogstation.dme

* Update yogstation.dme

* s

* maps

* Update NtosSynthManager.js

* unrevert this lol

* eat

* Update wy_synths.dm

* sigh

* e

* Update wy_synths.dm

* sigh

* fixed ma

* Update synthetic.dm

* better

* Update ethernet_cable.dm

* Update computer.dm

* Update computer.dm

* i hate this

* Update ai_laws.dm

* Update hardsuit.dm

* initialize

* sigh

* Update synth_os.dm

* Update master_subcontroller.dm

* Update master_subcontroller.dm

* Update synth_requester.dm

* Update synth_requester.dm

* Update room_lockdown.dm

* small fixes

* propa sprite matey

* no latejoin lol

* Update synth_os.dm

* maps fixed

* compiles

* Update brain_item.dm

* fixes

* mappers

* Update hud.dmi

* Update passworddoor.dm

* button puzzle

* mine stuff

* Update yogstation.dme

* le map

* changes

* ye

* Update abandoned_mine.dm

* Update _puzzles.dm

* bingus

* Update abandoned_mine.dm

* maps

* e

* no more quirks

* e

* DMI merge conflict resolver (from TG)

* update yogstation map

* Minor away mission changes

* forgot something

* proper fix

* donut

* maps

* asteroid

* gax

* all maps done

* Update synthetic.dm

* makes it compile

* Update backstabs.dm

* more compile!

* fix this map

* bad item

* remove broken objects

* gax

* Update ticker.dm

* pdas

* omg save the file

* Update networking_machines.dm

* area string moment

* s

* awkward

* revival

* Update ai_dashboard.dm

* fixes

* fixed floopy

* less difficult

* this is important

* Update ai_network.dm

* maps

* fixes the maps

* wHAT

* WHAT

* wet

* start fixing conflicts

* Update yogstation.dme

* start fixing map conflicts

* Update DonutStation.dmm

* updates

* donut conflicts

* update box

* Update IceMeta.dmm

* icon diffs

* Update crew.dm

* Update unsorted.dm

* Update layers.dm

* Update YogStation.dmm

* conflicts

* Update IceMeta.dmm

* will this finally fix it

* Update IceMeta.dmm

* fix all this SHIT

* what

* more shit ugh

* what!

* Update DonutStation.dmm

* Update AsteroidStation.dmm

* Update AsteroidStation.dmm

* Update dead.dm

* Update catwalk_plating.dm

* Update catwalk_plating.dm

---------

Co-authored-by: adamsong <adamsong@users.noreply.github.com>
Co-authored-by: wejengin2 <48154165+wejengin2@users.noreply.github.com>
Co-authored-by: Byemoh <baiomurang@gmail.com>
2024-04-01 16:32:09 -05:00

235 lines
6.6 KiB
Plaintext

/*
AI ClickOn()
Note currently ai restrained() returns 0 in all cases,
therefore restrained code has been removed
The AI can double click to move the camera (this was already true but is cleaner),
or double click a mob to track them.
Note that AI have no need for the adjacency proc, and so this proc is a lot cleaner.
*/
/mob/living/silicon/ai/DblClickOn(atom/A, params)
if(control_disabled || incapacitated())
return
if(ismob(A))
ai_actual_track(A)
else
A.move_camera_by_click()
/mob/living/silicon/ai/ClickOn(atom/A, params)
if(world.time <= next_click)
return
next_click = world.time + 1
if(multicam_on)
var/turf/T = get_turf(A)
if(T)
for(var/atom/movable/screen/movable/pic_in_pic/ai/P in T.vis_locs)
if(P.ai == src)
P.Click(params)
break
if(check_click_intercept(params,A))
return
if(control_disabled || incapacitated())
return
var/turf/pixel_turf = get_turf_pixel(A)
if(isnull(pixel_turf))
return
if(!can_see(A))
if(isturf(A)) //On unmodified clients clicking the static overlay clicks the turf underneath
return //So there's no point messaging admins
message_admins("[ADMIN_LOOKUPFLW(src)] failed can_see on AI click of [A] (Turf Loc: [ADMIN_VERBOSEJMP(pixel_turf)]))")
log_admin("[key_name(src)] failed can_see on AI click of [A] (Turf Loc: [AREACOORD(pixel_turf)])")
return
var/list/modifiers = params2list(params)
if(modifiers["shift"] && modifiers["ctrl"])
CtrlShiftClickOn(A)
return
if(modifiers["middle"])
if(controlled_mech) //Are we piloting a mech? Placed here so the modifiers are not overridden.
controlled_mech.click_action(A, src, params) //Override AI normal click behavior.
return
if(modifiers["shift"])
ShiftClickOn(A)
return
if(modifiers["alt"]) // alt and alt-gr (rightalt)
AltClickOn(A)
return
if(modifiers["ctrl"])
CtrlClickOn(A)
return
if(world.time <= next_move)
return
if(aicamera.in_camera_mode)
aicamera.camera_mode_off()
aicamera.captureimage(pixel_turf, usr)
return
if(waypoint_mode)
waypoint_mode = 0
set_waypoint(A)
return
A.attack_ai(src)
/*
AI has no need for the UnarmedAttack() and RangedAttack() procs,
because the AI code is not generic; attack_ai() is used instead.
The below is only really for safety, or you can alter the way
it functions and re-insert it above.
*/
/mob/living/silicon/ai/UnarmedAttack(atom/A)
A.attack_ai(src)
/mob/living/silicon/ai/RangedAttack(atom/A)
A.attack_ai(src)
/atom/proc/attack_ai(mob/user)
return
/*
Since the AI handles shift, ctrl, and alt-click differently
than anything else in the game, atoms have separate procs
for AI shift, ctrl, and alt clicking.
*/
/mob/living/silicon/ai/CtrlShiftClickOn(atom/A)
A.AICtrlShiftClick(src)
/mob/living/silicon/ai/ShiftClickOn(atom/A)
A.AIShiftClick(src)
/mob/living/silicon/ai/CtrlClickOn(atom/A)
A.AICtrlClick(src)
/mob/living/silicon/ai/AltClickOn(atom/A)
A.AIAltClick(src)
/*
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.
*/
/* Questions: Instead of an Emag check on every function, can we not add to airlocks onclick if emag return? */
/* Atom Procs */
/atom/proc/AICtrlClick()
return
/atom/proc/AIAltClick(mob/living/silicon/ai/user)
AltClick(user)
return
/atom/proc/AIShiftClick()
return
/atom/proc/AICtrlShiftClick()
return
/* Airlocks */
/obj/machinery/door/airlock/AICtrlClick() // Bolts doors
if((obj_flags & EMAGGED) || (obj_flags & CMAGGED))
return
var/mob/living/silicon/ai/AI = usr
if(istype(AI) && !AI.has_subcontroller_connection(get_area(src)))
to_chat(AI, span_warning("No connection to subcontroller detected. Priming servos..."))
if(!do_after(AI, 1 SECONDS, src, IGNORE_USER_LOC_CHANGE))
return
toggle_bolt(usr)
add_hiddenprint(usr)
/obj/machinery/door/airlock/AIAltClick() // Eletrifies doors.
if((obj_flags & EMAGGED) || (obj_flags & CMAGGED))
return
var/mob/living/silicon/ai/AI = usr
if(istype(AI) && !AI.has_subcontroller_connection(get_area(src)))
to_chat(AI, span_warning("No connection to subcontroller detected. Priming servos..."))
if(!do_after(AI, 1 SECONDS, src, IGNORE_USER_LOC_CHANGE))
return
if(!secondsElectrified)
shock_perm(usr)
else
shock_restore(usr)
/obj/machinery/door/airlock/AIShiftClick() // Opens and closes doors!
if((obj_flags & EMAGGED) || (obj_flags & CMAGGED))
return
var/mob/living/silicon/ai/AI = usr
if(istype(AI) && !AI.has_subcontroller_connection(get_area(src)))
to_chat(AI, span_warning("No connection to subcontroller detected. Priming servos..."))
if(!do_after(AI, 1 SECONDS, src, IGNORE_USER_LOC_CHANGE))
return
user_toggle_open(usr)
add_hiddenprint(usr)
/obj/machinery/door/airlock/AICtrlShiftClick() // Sets/Unsets Emergency Access Override
if((obj_flags & EMAGGED) || (obj_flags & CMAGGED))
return
var/mob/living/silicon/ai/AI = usr
if(istype(AI) && !AI.has_subcontroller_connection(get_area(src)))
to_chat(AI, span_warning("No connection to subcontroller detected. Priming servos..."))
if(!do_after(AI, 1 SECONDS, src, IGNORE_USER_LOC_CHANGE))
return
toggle_emergency(usr)
add_hiddenprint(usr)
/* APC */
/obj/machinery/power/apc/AICtrlClick() // turns off/on APCs.
var/mob/living/silicon/ai/AI = usr
if(istype(AI) && !AI.has_subcontroller_connection(get_area(src)))
to_chat(AI, span_warning("No connection to subcontroller detected. Polling APC..."))
if(!do_after(AI, 1 SECONDS, src, IGNORE_USER_LOC_CHANGE))
return
if(can_use(usr, 1))
toggle_breaker(usr)
/* AI Turrets */
/obj/machinery/turretid/AIAltClick() //toggles lethal on turrets
if(ailock)
return
toggle_lethal(usr)
/obj/machinery/turretid/AICtrlClick() //turns off/on Turrets
if(ailock)
return
toggle_on(usr)
/* Holopads */
/obj/machinery/holopad/AIAltClick(mob/living/silicon/ai/user)
hangup_all_calls()
add_hiddenprint(usr)
/* Humans (With upgrades) */
/mob/living/carbon/human/AIShiftClick(mob/living/silicon/ai/user)
if(user.client && (user.client.eye == user.eyeobj || user.client.eye == user.loc))
if(user.canExamineHumans)
user.examinate(src)
if(user.canCameraMemoryTrack)
if(name == "Unknown")
to_chat(user, span_warning("Unable to track 'Unknown' persons! Their name must be visible."))
return
if(src == user.cameraMemoryTarget)
to_chat(user, span_warning("Stop tracking this individual? <a href='?src=[REF(user)];stopTrackHuman=1'>\[UNTRACK\]</a>"))
else
to_chat(user, span_warning("Track this individual? <a href='?src=[REF(user)];trackHuman=[src.name]'>\[TRACK\]</a>"))
return
//
// Override TurfAdjacent for AltClicking
//
/mob/living/silicon/ai/TurfAdjacent(turf/T)
return (GLOB.cameranet && GLOB.cameranet.checkTurfVis(T))