mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-01-05 23:13:06 +00:00
[MIRROR] Adds means for staff to initialize new mob ai or modify existing ai type (#6676)
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: CHOMPStation2 <chompsation2@gmail.com>
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
<option value='?_src_=vars;[HrefToken()];make_skeleton=\ref[src]'>Make 2spooky</option>
|
<option value='?_src_=vars;[HrefToken()];make_skeleton=\ref[src]'>Make 2spooky</option>
|
||||||
|
|
||||||
<option value='?_src_=vars;[HrefToken()];direct_control=\ref[src]'>Assume Direct Control</option>
|
<option value='?_src_=vars;[HrefToken()];direct_control=\ref[src]'>Assume Direct Control</option>
|
||||||
|
<option value='?_src_=vars;[HrefToken()];give_ai=\ref[src]'>Enable/Modify A.I</option>
|
||||||
<option value='?_src_=vars;[HrefToken()];drop_everything=\ref[src]'>Drop Everything</option>
|
<option value='?_src_=vars;[HrefToken()];drop_everything=\ref[src]'>Drop Everything</option>
|
||||||
|
|
||||||
<option value='?_src_=vars;[HrefToken()];regenerateicons=\ref[src]'>Regenerate Icons</option>
|
<option value='?_src_=vars;[HrefToken()];regenerateicons=\ref[src]'>Regenerate Icons</option>
|
||||||
|
|||||||
@@ -157,6 +157,29 @@
|
|||||||
if(usr.client)
|
if(usr.client)
|
||||||
usr.client.cmd_assume_direct_control(M)
|
usr.client.cmd_assume_direct_control(M)
|
||||||
|
|
||||||
|
else if(href_list["give_ai"])
|
||||||
|
if(!check_rights(0)) return
|
||||||
|
|
||||||
|
var/mob/M = locate(href_list["give_ai"])
|
||||||
|
if(!istype(M, /mob/living))
|
||||||
|
to_chat(usr, span_notice("This can only be used on instances of type /mob/living"))
|
||||||
|
return
|
||||||
|
var/mob/living/L = M
|
||||||
|
if(L.client || L.teleop)
|
||||||
|
to_chat(usr, span_warning("This cannot be used on player mobs!"))
|
||||||
|
return
|
||||||
|
|
||||||
|
if(L.ai_holder) //Cleaning up the original ai
|
||||||
|
var/ai_holder_old = L.ai_holder
|
||||||
|
L.ai_holder = null
|
||||||
|
qdel(ai_holder_old) //Only way I could make #TESTING - Unable to be GC'd to stop. del() logs show it works.
|
||||||
|
L.ai_holder_type = tgui_input_list(usr, "Choose AI holder", "AI Type", typesof(/datum/ai_holder/))
|
||||||
|
L.initialize_ai_holder()
|
||||||
|
L.faction = sanitize(tgui_input_text(usr, "Please input AI faction", "AI faction", "neutral"))
|
||||||
|
L.a_intent = tgui_input_list(usr, "Please choose AI intent", "AI intent", list(I_HURT, I_HELP))
|
||||||
|
if(tgui_alert(usr, "Make mob wake up? This is needed for carbon mobs.", "Wake mob?", list("Yes", "No")) == "Yes")
|
||||||
|
L.AdjustSleeping(-100)
|
||||||
|
|
||||||
else if(href_list["make_skeleton"])
|
else if(href_list["make_skeleton"])
|
||||||
if(!check_rights(R_FUN)) return
|
if(!check_rights(R_FUN)) return
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,8 @@
|
|||||||
var/ai_holder_type = null // Which ai_holder datum to give to the mob when initialized. If null, nothing happens.
|
var/ai_holder_type = null // Which ai_holder datum to give to the mob when initialized. If null, nothing happens.
|
||||||
|
|
||||||
/mob/living/Initialize()
|
/mob/living/Initialize()
|
||||||
if(ai_holder_type)
|
if(!ai_holder)
|
||||||
ai_holder = new ai_holder_type(src)
|
initialize_ai_holder()
|
||||||
if(istype(src, /mob/living/carbon/human))
|
|
||||||
var/mob/living/carbon/human/H = src
|
|
||||||
H.hud_used = new /datum/hud(H)
|
|
||||||
H.create_mob_hud(H.hud_used)
|
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/mob/living/Destroy()
|
/mob/living/Destroy()
|
||||||
@@ -37,6 +33,22 @@
|
|||||||
ai_holder.manage_processing(AI_PROCESSING)
|
ai_holder.manage_processing(AI_PROCESSING)
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
|
//Extracted from mob/living/Initialize() so that we may call it at any time after a mob was created
|
||||||
|
/mob/living/proc/initialize_ai_holder()
|
||||||
|
if(ai_holder) //Making double sure we clean up and properly GC the original ai_holder
|
||||||
|
var/old_holder = ai_holder
|
||||||
|
ai_holder = null
|
||||||
|
qdel(old_holder)
|
||||||
|
if(ai_holder_type)
|
||||||
|
ai_holder = new ai_holder_type(src)
|
||||||
|
if(!ai_holder)
|
||||||
|
log_debug("[src] could not initialize ai_holder of type [ai_holder_type]")
|
||||||
|
return
|
||||||
|
if(istype(src, /mob/living/carbon/human))
|
||||||
|
var/mob/living/carbon/human/H = src
|
||||||
|
H.hud_used = new /datum/hud(H)
|
||||||
|
H.create_mob_hud(H.hud_used)
|
||||||
|
|
||||||
/datum/ai_holder
|
/datum/ai_holder
|
||||||
var/mob/living/holder = null // The mob this datum is going to control.
|
var/mob/living/holder = null // The mob this datum is going to control.
|
||||||
var/stance = STANCE_IDLE // Determines if the mob should be doing a specific thing, e.g. attacking, following, standing around, etc.
|
var/stance = STANCE_IDLE // Determines if the mob should be doing a specific thing, e.g. attacking, following, standing around, etc.
|
||||||
|
|||||||
Reference in New Issue
Block a user