mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
(Revival) Mining bar (#31284)
* Starting rework of this * Slight fix * Fixing compile issues * Updating more code * More updates * More updates * Proper name * Removing unused comsig file * Fixing up map * Makes components work * Make this show up * Specific type, maybe? * Vault fixes, plus makes component actually process * Say proc finally works with events now * Calling in wrong registered thing * Unneeded * Ports hearing to hear component * Area exit phrase for him too * Actual event * Testing this out for fun * Some more * Compiles * Path * Disambiguates this * No more runtiming * Some cleanliness * Makes this parsing less rigid * This too * Much much less rigid * This shouldn't be in this then * Make it rotate * Here Co-authored-by: kanef <kanef9x@protonmail.com>
This commit is contained in:
26
code/modules/components/ai/area_territorial.dm
Normal file
26
code/modules/components/ai/area_territorial.dm
Normal file
@@ -0,0 +1,26 @@
|
||||
/datum/component/ai/area_territorial
|
||||
var/enter_signal
|
||||
var/list/enter_args
|
||||
var/exit_signal
|
||||
var/list/exit_args
|
||||
var/area/territory = null
|
||||
|
||||
/datum/component/ai/area_territorial/proc/SetArea(var/area/new_area)
|
||||
if(territory)
|
||||
territory.unregister_event(/event/comp_ai_cmd_area_enter, src, .proc/area_enter)
|
||||
territory.unregister_event(/event/comp_ai_cmd_area_exit, src, .proc/area_exit)
|
||||
territory = new_area
|
||||
territory.register_event(/event/comp_ai_cmd_area_enter, src, .proc/area_enter)
|
||||
territory.register_event(/event/comp_ai_cmd_area_exit, src, .proc/area_exit)
|
||||
|
||||
/datum/component/ai/area_territorial/proc/area_enter(var/obj/enterer)
|
||||
if(isliving(enterer)) // No ghosts
|
||||
INVOKE_EVENT(parent, enter_signal, enter_args)
|
||||
|
||||
/datum/component/ai/area_territorial/proc/area_exit(var/obj/exiter)
|
||||
if(isliving(exiter)) // No ghosts
|
||||
INVOKE_EVENT(parent, exit_signal, exit_args)
|
||||
|
||||
/datum/component/ai/area_territorial/say
|
||||
enter_signal = /event/comp_ai_cmd_specific_say
|
||||
exit_signal = /event/comp_ai_cmd_specific_say
|
||||
52
code/modules/components/ai/conversation.dm
Normal file
52
code/modules/components/ai/conversation.dm
Normal file
@@ -0,0 +1,52 @@
|
||||
/datum/component/ai/conversation
|
||||
var/list/messages = list()
|
||||
|
||||
/datum/component/ai/conversation/initialize()
|
||||
parent.register_event(/event/comp_ai_cmd_say, src, .proc/cmd_say)
|
||||
parent.register_event(/event/comp_ai_cmd_specific_say, src, .proc/cmd_specific_say)
|
||||
return TRUE
|
||||
|
||||
/datum/component/ai/conversation/Destroy()
|
||||
parent.unregister_event(/event/comp_ai_cmd_say, src, .proc/cmd_say)
|
||||
parent.unregister_event(/event/comp_ai_cmd_specific_say, src, .proc/cmd_specific_say)
|
||||
..()
|
||||
|
||||
/datum/component/ai/conversation/proc/cmd_say()
|
||||
if(isliving(parent))
|
||||
var/mob/living/M=parent
|
||||
M.say("[pick(messages)]")
|
||||
|
||||
/datum/component/ai/conversation/proc/cmd_specific_say(var/list/to_say)
|
||||
if(isliving(parent))
|
||||
var/mob/living/M=parent
|
||||
M.say("[pick(to_say)]")
|
||||
|
||||
/datum/component/ai/conversation/auto
|
||||
var/speech_prob = 30
|
||||
var/next_speech
|
||||
var/speech_delay
|
||||
var/datum/component/ai/target_finder/finder = null
|
||||
|
||||
/datum/component/ai/conversation/auto/initialize()
|
||||
if(..())
|
||||
finder = parent.get_component(/datum/component/ai/target_finder/simple_view)
|
||||
active_components += src
|
||||
return TRUE
|
||||
|
||||
/datum/component/ai/conversation/auto/Destroy()
|
||||
active_components -= src
|
||||
..()
|
||||
|
||||
/datum/component/ai/conversation/auto/process()
|
||||
if(finder && next_speech < world.time && prob(speech_prob))
|
||||
var/listener
|
||||
for(var/mob/living/M in finder.cmd_find_targets())
|
||||
if(M == src)
|
||||
continue
|
||||
if(M.isDead()) //No speaking to the dead
|
||||
continue
|
||||
listener = TRUE
|
||||
break
|
||||
if(listener)
|
||||
next_speech = world.time+speech_delay
|
||||
cmd_say()
|
||||
43
code/modules/components/ai/hearing.dm
Normal file
43
code/modules/components/ai/hearing.dm
Normal file
@@ -0,0 +1,43 @@
|
||||
/datum/component/ai/hearing
|
||||
var/hear_signal
|
||||
var/list/required_messages = list()
|
||||
var/list/hear_args
|
||||
var/response_delay = 10
|
||||
|
||||
/datum/component/ai/hearing/initialize()
|
||||
parent.register_event(/event/comp_ai_cmd_hear, src, .proc/on_hear)
|
||||
return TRUE
|
||||
|
||||
/datum/component/ai/hearing/Destroy()
|
||||
parent.unregister_event(/event/comp_ai_cmd_hear, src, .proc/on_hear)
|
||||
..()
|
||||
|
||||
/datum/component/ai/hearing/proc/on_hear(var/datum/speech/speech)
|
||||
var/filtered_message = speech.message
|
||||
filtered_message = replacetext(filtered_message , "?" , "") //Ignores punctuation.
|
||||
filtered_message = replacetext(filtered_message , "!" , "") //Ignores punctuation.
|
||||
filtered_message = replacetext(filtered_message , "." , "") //Ignores punctuation.
|
||||
filtered_message = replacetext(filtered_message , "," , "") //Ignores punctuation.
|
||||
if(speech.speaker != parent)
|
||||
if(!required_messages.len)
|
||||
sleep(response_delay)
|
||||
INVOKE_EVENT(parent, hear_signal, hear_args)
|
||||
else
|
||||
for(var/message in required_messages)
|
||||
if(findtext(filtered_message,message))
|
||||
sleep(response_delay)
|
||||
INVOKE_EVENT(parent, hear_signal, hear_args)
|
||||
return
|
||||
|
||||
/datum/component/ai/hearing/say
|
||||
hear_signal = /event/comp_ai_cmd_say
|
||||
|
||||
/datum/component/ai/hearing/say_response
|
||||
hear_signal = /event/comp_ai_cmd_specific_say
|
||||
|
||||
/datum/component/ai/hearing/say_response/time
|
||||
required_messages = list("what time is it","whats the time","do you have the time")
|
||||
|
||||
/datum/component/ai/hearing/say_response/time/on_hear(var/datum/speech/speech)
|
||||
hear_args = list("The current time is [worldtime2text()].")
|
||||
..()
|
||||
Reference in New Issue
Block a user