diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 29a5a10050..2dc741cc5e 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -76,6 +76,7 @@ GLOBAL_LIST_INIT(admin_verbs_default, list( /datum/admins/proc/toggle_human_ai, /datum/admins/proc/create_human_ai_patrol, /client/proc/open_human_ai_management_panel, + /client/proc/open_human_faction_management_panel, /client/proc/create_human_ai, /client/proc/other_records, )) diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 4773252147..d26378f332 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -137,3 +137,6 @@ /// Holds the human AI manager panel for this client var/datum/human_ai_management_menu/human_ai_menu + + /// Holds the human faction manager panel for this client + var/datum/human_faction_management_menu/human_faction_menu diff --git a/code/modules/mob/living/carbon/human/ai/ai_management_menu.dm b/code/modules/mob/living/carbon/human/ai/ai_management_menu.dm index 72370982df..d3fb8a1ae9 100644 --- a/code/modules/mob/living/carbon/human/ai/ai_management_menu.dm +++ b/code/modules/mob/living/carbon/human/ai/ai_management_menu.dm @@ -126,6 +126,7 @@ return human_ai_menu = new /datum/human_ai_management_menu(src) + human_ai_menu.tgui_interact(mob) /client/proc/create_human_ai() set name = "Create Human AI" diff --git a/code/modules/mob/living/carbon/human/ai/brain/ai_brain.dm b/code/modules/mob/living/carbon/human/ai/brain/ai_brain.dm index 3507d44f75..4977d452c4 100644 --- a/code/modules/mob/living/carbon/human/ai/brain/ai_brain.dm +++ b/code/modules/mob/living/carbon/human/ai/brain/ai_brain.dm @@ -307,5 +307,5 @@ GLOBAL_LIST_EMPTY(human_ai_brains) if(!our_faction) return - our_faction.neutral_factions -= faction + our_faction.remove_neutral_faction(faction) our_faction.reapply_faction_data() diff --git a/code/modules/mob/living/carbon/human/ai/brain/ai_brain_factions.dm b/code/modules/mob/living/carbon/human/ai/brain/ai_brain_factions.dm index 433e0b37b3..830edcf8a2 100644 --- a/code/modules/mob/living/carbon/human/ai/brain/ai_brain_factions.dm +++ b/code/modules/mob/living/carbon/human/ai/brain/ai_brain_factions.dm @@ -1,13 +1,13 @@ /datum/human_ai_faction var/faction = FACTION_NEUTRAL - var/shoot_to_kill = TRUE + VAR_PROTECTED/shoot_to_kill = TRUE - var/list/in_combat_lines = list() - var/list/exit_combat_lines = list() - var/list/squad_member_death_lines = list() + VAR_PROTECTED/list/in_combat_lines = list() + VAR_PROTECTED/list/exit_combat_lines = list() + VAR_PROTECTED/list/squad_member_death_lines = list() - var/list/friendly_factions = list() - var/list/neutral_factions = list() + VAR_PROTECTED/list/friendly_factions = list() + VAR_PROTECTED/list/neutral_factions = list() /datum/human_ai_faction/proc/apply_faction_data(datum/human_ai_brain/brain) if(length(in_combat_lines)) @@ -28,6 +28,47 @@ if(brain.tied_human?.faction == faction) apply_faction_data(brain) +/datum/human_ai_faction/proc/add_friendly_faction(faction) + if(faction in friendly_factions) + return + friendly_factions += faction + if(faction in neutral_factions) + neutral_factions -= faction + reapply_faction_data() + +/datum/human_ai_faction/proc/add_neutral_faction(faction) + if(faction in neutral_factions) + return + neutral_factions += faction + if(faction in friendly_factions) + friendly_factions -= faction + reapply_faction_data() + +/datum/human_ai_faction/proc/remove_friendly_faction(faction) + if(!(faction in friendly_factions)) + return + friendly_factions -= faction + reapply_faction_data() + +/datum/human_ai_faction/proc/remove_neutral_faction(faction) + if(!(faction in neutral_factions)) + return + neutral_factions -= faction + reapply_faction_data() + +/datum/human_ai_faction/proc/get_friendly_factions() + return friendly_factions + +/datum/human_ai_faction/proc/get_neutral_factions() + return neutral_factions + +/datum/human_ai_faction/proc/set_shoot_to_kill(new_kill = TRUE) + shoot_to_kill = new_kill + reapply_faction_data() + +/datum/human_ai_faction/proc/get_shoot_to_kill() + return shoot_to_kill + /datum/human_ai_faction/clf faction = FACTION_CLF friendly_factions = list( diff --git a/code/modules/mob/living/carbon/human/ai/faction_management_panel.dm b/code/modules/mob/living/carbon/human/ai/faction_management_panel.dm new file mode 100644 index 0000000000..a19ec905d6 --- /dev/null +++ b/code/modules/mob/living/carbon/human/ai/faction_management_panel.dm @@ -0,0 +1,145 @@ +/datum/human_faction_management_menu + +/datum/human_faction_management_menu/New() + +/datum/human_faction_management_menu/tgui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "HumanFactionManager") + ui.open() + +/datum/human_faction_management_menu/ui_state(mob/user) + return GLOB.admin_state + +/datum/human_faction_management_menu/ui_data(mob/user) + var/list/data = list() + + data["datumless_factions"] = FACTION_LIST_HUMANOID + FACTION_LIST_XENOMORPH + + data["factions"] = list() + for(var/faction_name in SShuman_ai.human_ai_factions) + var/datum/human_ai_faction/ai_faction = SShuman_ai.human_ai_factions[faction_name] + data["factions"] += list(list( + "name" = ai_faction.faction, + "shoot_to_kill" = ai_faction.get_shoot_to_kill(), + "friendly_factions" = english_list(ai_faction.get_friendly_factions()), + "neutral_factions" = english_list(ai_faction.get_neutral_factions()), + "ref" = REF(ai_faction), + )) + data["datumless_factions"] -= ai_faction.faction + + return data + +/datum/human_faction_management_menu/ui_static_data(mob/user) + var/list/data = list() + + data["all_factions"] = FACTION_LIST_HUMANOID + FACTION_LIST_XENOMORPH + + return data + +/datum/human_faction_management_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + + switch(action) + if("create_faction") + if(!params["faction"]) + return + + var/gotten_faction = params["faction"] + if(gotten_faction in SShuman_ai.human_ai_factions) + return + + var/datum/human_ai_faction/new_faction = new() + new_faction.faction = gotten_faction + SShuman_ai.human_ai_factions[new_faction.faction] = new_faction + return TRUE + + if("set_shoot_to_kill") + if(!params["new_value"] || !params["faction_name"]) + return + + var/gotten_faction = params["faction_name"] + if(!(gotten_faction in SShuman_ai.human_ai_factions)) + return + + var/datum/human_ai_faction/faction_obj = SShuman_ai.human_ai_factions[gotten_faction] + faction_obj.set_shoot_to_kill(text2num(params["new_value"])) + return TRUE + + if("remove_neutral_faction") + if(!params["faction"]) + return + + var/gotten_faction = params["faction"] + if(!(gotten_faction in SShuman_ai.human_ai_factions)) + return + + var/datum/human_ai_faction/faction_obj = SShuman_ai.human_ai_factions[gotten_faction] + var/gotten_input = tgui_input_list(ui.user, "Remove which faction being neutral to [gotten_faction]?", "Remove Neutral Faction", faction_obj.get_neutral_factions()) + if(!gotten_input) + return + + faction_obj.remove_neutral_faction(gotten_input) + return TRUE + + if("remove_friendly_faction") + if(!params["faction"]) + return + + var/gotten_faction = params["faction"] + if(!(gotten_faction in SShuman_ai.human_ai_factions)) + return + + var/datum/human_ai_faction/faction_obj = SShuman_ai.human_ai_factions[gotten_faction] + var/gotten_input = tgui_input_list(ui.user, "Remove which faction being friendly to [gotten_faction]?", "Remove Friendly Faction", faction_obj.get_friendly_factions()) + if(!gotten_input) + return + + faction_obj.remove_friendly_faction(gotten_input) + return TRUE + + if("add_neutral_faction") + if(!params["faction"]) + return + + var/gotten_faction = params["faction"] + if(!(gotten_faction in SShuman_ai.human_ai_factions)) + return + + var/datum/human_ai_faction/faction_obj = SShuman_ai.human_ai_factions[gotten_faction] + var/gotten_input = tgui_input_list(ui.user, "Set which faction being neutral to [gotten_faction]?", "Add Neutral Faction", (FACTION_LIST_HUMANOID + FACTION_LIST_XENOMORPH) - faction_obj.get_neutral_factions()) + if(!gotten_input) + return + + faction_obj.add_neutral_faction(gotten_input) + + if("add_friendly_faction") + if(!params["faction"]) + return + + var/gotten_faction = params["faction"] + if(!(gotten_faction in SShuman_ai.human_ai_factions)) + return + + var/datum/human_ai_faction/faction_obj = SShuman_ai.human_ai_factions[gotten_faction] + var/gotten_input = tgui_input_list(ui.user, "Set which faction being friendly to [gotten_faction]?", "Add Friendly Faction", (FACTION_LIST_HUMANOID + FACTION_LIST_XENOMORPH) - faction_obj.get_friendly_factions()) + if(!gotten_input) + return + + faction_obj.add_friendly_faction(gotten_input) + +/client/proc/open_human_faction_management_panel() + set name = "Human Faction Management Panel" + set category = "Debug.HumanAI" + + if(!check_rights(R_DEBUG)) + return + + if(human_faction_menu) + human_faction_menu.tgui_interact(mob) + return + + human_faction_menu = new /datum/human_faction_management_menu(src) + human_faction_menu.tgui_interact(mob) diff --git a/colonialmarines.dme b/colonialmarines.dme index a825c5e430..d9976e6d6b 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1980,6 +1980,7 @@ #include "code\modules\mob\living\carbon\human\whisper.dm" #include "code\modules\mob\living\carbon\human\ai\ai_equipment.dm" #include "code\modules\mob\living\carbon\human\ai\ai_management_menu.dm" +#include "code\modules\mob\living\carbon\human\ai\faction_management_panel.dm" #include "code\modules\mob\living\carbon\human\ai\action_datums\orders\order_action.dm" #include "code\modules\mob\living\carbon\human\ai\action_datums\orders\patrol_waypoints.dm" #include "code\modules\mob\living\carbon\human\ai\brain\ai_brain_communication.dm" diff --git a/tgui/packages/tgui/interfaces/HumanAIManager.tsx b/tgui/packages/tgui/interfaces/HumanAIManager.tsx index 170164fe7e..2af08a9b3b 100644 --- a/tgui/packages/tgui/interfaces/HumanAIManager.tsx +++ b/tgui/packages/tgui/interfaces/HumanAIManager.tsx @@ -1,19 +1,7 @@ import { useBackend, useLocalState } from '../backend'; -import { - Box, - Button, - LabeledList, - NoticeBox, - ProgressBar, - Section, - Dimmer, - Stack, - Tabs, - Divider, -} from '../components'; +import { Button, Section, Stack, Divider } from '../components'; import { Window } from '../layouts'; -import { InterfaceLockNoticeBox } from './common/InterfaceLockNoticeBox'; -import { classes, BooleanLike } from 'common/react'; +import { BooleanLike } from 'common/react'; type Squad = { id: number; @@ -52,11 +40,11 @@ const AIContext = (props, context) => { const { data, act } = useBackend(); const [squadAssignmentMode, setSquadAssignmentMode] = useLocalState( 'squad_assignment_mode', - false + false, ); const [orderAssignmentMode, setOrderAssignmentMode] = useLocalState( 'order_assignment_mode', - false + false, ); return ( @@ -115,19 +103,19 @@ const AIContext = (props, context) => {
{data.orders.map((order) => ( - + ))}
{data.ai_humans.map((human) => ( - + ))}
{data.squads.map((squad) => ( - + ))}
@@ -140,12 +128,9 @@ const CreatedOrder = (props) => { const { data, act } = useBackend(); const [orderAssignmentMode, setOrderAssignmentMode] = useLocalState( 'order_assignment_mode', - false - ); - const [selectedSquad, setSelectedSquad] = useLocalState( - 'selected_squad', - -1 + false, ); + const [selectedSquad, setSelectedSquad] = useLocalState('selected_squad', -1); return (
{ const context: BackendContext = props.context; const [squadAssignmentMode, setSquadAssignmentMode] = useLocalState( 'squad_assignment_mode', - false - ); - const [selectedSquad, setSelectedSquad] = useLocalState( - 'selected_squad', - -1 + false, ); + const [selectedSquad, setSelectedSquad] = useLocalState('selected_squad', -1); const { data, act } = useBackend(); const gottenSquad: Squad = data.squads[selectedSquad]; return ( @@ -306,15 +288,12 @@ const SquadReadout = (props) => { const { data, act } = useBackend(); const [squadAssignmentMode, setSquadAssignmentMode] = useLocalState( 'squad_assignment_mode', - false - ); - const [selectedSquad, setSelectedSquad] = useLocalState( - 'selected_squad', - -1 + false, ); + const [selectedSquad, setSelectedSquad] = useLocalState('selected_squad', -1); const [orderAssignmentMode, setOrderAssignmentMode] = useLocalState( 'order_assignment_mode', - false + false, ); return (
{ + const { data, act } = useBackend(); + const [selectedToCreateFaction, setSelectedToCreateFaction] = useLocalState( + 'selected_to_create_faction', + '', + ); + return ( + +
+
+ setSelectedToCreateFaction(value)} + /> +
+
+
+
+ +
+ {data.factions.map((faction) => ( + + ))} +
+
+ ); +}; + +const ExistingFaction = (props) => { + const context: BackendContext = props.context; + const { data, act } = useBackend(); + const faction: Faction = props.faction; + return ( +
+
+ Shoot To Kill: {faction.shoot_to_kill} + + act('set_shoot_to_kill', { + faction_name: faction.name, + new_value: value, + }) + } + /> + Friendly Factions: {faction.friendly_factions} + <> +
+
+ ); +}; + +export const HumanFactionManager = (props) => { + return ( + + + + + + ); +};