mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
[MIRROR] Modifies "MobSpawner" and Adds ability to set-up mob AI through the interface (#6685)
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: Raeschen <rycoop29@gmail.com>
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
// The path of the mob to be spawned
|
||||
var/path
|
||||
|
||||
//The ai type path to be assigned to the mob
|
||||
var/use_custom_ai = FALSE
|
||||
var/ai_type = ""
|
||||
var/faction = ""
|
||||
var/intent = ""
|
||||
var/new_path = TRUE //Sets default ai vars based on path. Tracked explicitly because tgui_act wouldn't make it work, used in tgui_data thusly
|
||||
|
||||
// Defines if the location of the spawned mob should be bound of the users position
|
||||
var/loc_lock = FALSE
|
||||
|
||||
@@ -28,26 +35,40 @@
|
||||
data["initial_y"] = usr.y;
|
||||
data["initial_z"] = usr.z;
|
||||
|
||||
|
||||
return data
|
||||
|
||||
/datum/eventkit/mob_spawner/tgui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
data["loc_lock"] = loc_lock;
|
||||
data["loc_lock"] = loc_lock
|
||||
if(loc_lock)
|
||||
data["loc_x"] = usr.x;
|
||||
data["loc_y"] = usr.y;
|
||||
data["loc_z"] = usr.z;
|
||||
data["loc_x"] = usr.x
|
||||
data["loc_y"] = usr.y
|
||||
data["loc_z"] = usr.z
|
||||
|
||||
data["path"] = path;
|
||||
data["use_custom_ai"] = use_custom_ai
|
||||
|
||||
|
||||
if(path)
|
||||
var/mob/M = new path();
|
||||
var/mob/M = new path()
|
||||
if(M)
|
||||
data["default_path_name"] = M.name;
|
||||
data["default_desc"] = M.desc;
|
||||
data["default_flavor_text"] = M.flavor_text;
|
||||
qdel(M);
|
||||
data["default_path_name"] = M.name
|
||||
data["default_desc"] = M.desc
|
||||
data["default_flavor_text"] = M.flavor_text
|
||||
if(new_path && istype(M, /mob/living))
|
||||
var/mob/living/L = M
|
||||
ai_type = (L.ai_holder_type ? L.ai_holder_type : /datum/ai_holder/simple_mob/inert)
|
||||
faction = (L.faction ? L.faction : "neutral")
|
||||
intent = (L.a_intent ? L.a_intent : I_HELP)
|
||||
new_path = FALSE
|
||||
qdel(L)
|
||||
qdel(M)
|
||||
data["ai_type"] = ai_type
|
||||
data["faction"] = faction
|
||||
data["intent"] = intent
|
||||
|
||||
|
||||
return data
|
||||
|
||||
@@ -63,7 +84,20 @@
|
||||
var/newPath = tgui_input_list(usr, "Please select the new path of the mob you want to spawn.", items = choices)
|
||||
|
||||
path = newPath
|
||||
|
||||
new_path = TRUE
|
||||
return TRUE
|
||||
if("toggle_custom_ai")
|
||||
use_custom_ai = !use_custom_ai
|
||||
return TRUE
|
||||
if("set_faction")
|
||||
faction = sanitize(tgui_input_text(usr, "Please input your mobs' faction", "Faction", (faction ? faction : "neutral")))
|
||||
return TRUE
|
||||
if("set_intent")
|
||||
intent = tgui_input_list(usr, "Please select preferred intent", "Select Intent", list(I_HELP, I_HURT), (intent ? intent : I_HELP))
|
||||
return TRUE
|
||||
if("set_ai_path")
|
||||
ai_type = tgui_input_list(usr, "Select AI path. Not all subtypes are compatible!", "AI type", \
|
||||
typesof(/datum/ai_holder/), (ai_type ? ai_type : /datum/ai_holder/simple_mob/inert))
|
||||
return TRUE
|
||||
if("loc_lock")
|
||||
loc_lock = !loc_lock
|
||||
@@ -99,6 +133,18 @@
|
||||
M.name = sanitize(name)
|
||||
M.desc = sanitize(params["desc"])
|
||||
M.flavor_text = sanitize(params["flavor_text"])
|
||||
if(use_custom_ai)
|
||||
if(istype(M, /mob/living))
|
||||
var/mob/living/L = M
|
||||
L.ai_holder_type = ai_type
|
||||
L.faction = faction
|
||||
L.a_intent = intent
|
||||
L.initialize_ai_holder()
|
||||
L.AdjustSleeping(-100)
|
||||
else
|
||||
to_chat(usr, span_notice("You can only set AI for subtypes of mob/living!"))
|
||||
|
||||
|
||||
|
||||
/*
|
||||
WIP: Radius around selected coords
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BooleanLike } from '../../common/react';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Button, Flex, Input, Knob, LabeledList, NumberInput, Section, Tabs, TextArea } from '../components';
|
||||
import { Button, Divider, Flex, Input, Knob, LabeledList, NumberInput, Section, Tabs, TextArea } from '../components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
type Data = {
|
||||
@@ -10,6 +10,11 @@ type Data = {
|
||||
default_desc: string;
|
||||
default_flavor_text: string;
|
||||
|
||||
use_custom_ai: BooleanLike;
|
||||
ai_type: string;
|
||||
faction: string;
|
||||
intent: string;
|
||||
|
||||
default_speak_emotes: string[];
|
||||
|
||||
loc_lock: BooleanLike;
|
||||
@@ -58,6 +63,14 @@ const GeneralMobSettings = (props, context) => {
|
||||
'name',
|
||||
data.default_path_name
|
||||
);
|
||||
const [ai_type] = useLocalState(context, 'aiType', data.ai_type);
|
||||
const [use_custom_ai] = useLocalState(
|
||||
context,
|
||||
'toggleCustomAi',
|
||||
data.use_custom_ai
|
||||
);
|
||||
const [faction] = useLocalState(context, 'setMobFaction', data.faction);
|
||||
const [intent] = useLocalState(context, 'setIntent', data.intent);
|
||||
const [desc, setDesc] = useLocalState(context, 'desc', data.default_desc);
|
||||
const [flavorText, setFlavorText] = useLocalState(
|
||||
context,
|
||||
@@ -114,6 +127,9 @@ const GeneralMobSettings = (props, context) => {
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
<Section title="General Settings">
|
||||
<Flex horizontal>
|
||||
<Flex.Item FlexGrow>
|
||||
<Section title="Positional Settings">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Spawn (X/Y/Z) Coords">
|
||||
@@ -152,6 +168,48 @@ const GeneralMobSettings = (props, context) => {
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
<Flex.Item>
|
||||
<Divider vertical />
|
||||
</Flex.Item>
|
||||
<Flex.Item FlexGrow>
|
||||
<Section
|
||||
title="AI settings"
|
||||
buttons={
|
||||
<Button
|
||||
selected={use_custom_ai}
|
||||
fill
|
||||
content="Use Custom AI"
|
||||
onClick={() => act('toggle_custom_ai')}
|
||||
/>
|
||||
}>
|
||||
<LabeledList>
|
||||
<LabeledList.Item>
|
||||
<Button
|
||||
fluid
|
||||
content={ai_type || 'Choose AI Type'}
|
||||
onClick={(val) => act('set_ai_path')}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item>
|
||||
<Button
|
||||
fluid
|
||||
content={faction || 'Set Faction'}
|
||||
onClick={(val) => act('set_faction')}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item>
|
||||
<Button
|
||||
fluid
|
||||
content={intent || 'Set Intent'}
|
||||
onClick={(val) => act('set_intent')}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
</Section>
|
||||
<Section title="Descriptions">
|
||||
<Flex>
|
||||
<Flex.Item width="50%">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BooleanLike } from '../../common/react';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Button, Flex, Input, Knob, LabeledList, NumberInput, Section, Tabs, TextArea } from '../components';
|
||||
import { Button, Divider, Flex, Input, Knob, LabeledList, NumberInput, Section, Tabs, TextArea } from '../components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
type Data = {
|
||||
@@ -10,6 +10,11 @@ type Data = {
|
||||
default_desc: string;
|
||||
default_flavor_text: string;
|
||||
|
||||
use_custom_ai: BooleanLike;
|
||||
ai_type: string;
|
||||
faction: string;
|
||||
intent: string;
|
||||
|
||||
default_speak_emotes: string[];
|
||||
|
||||
loc_lock: BooleanLike;
|
||||
@@ -58,6 +63,14 @@ const GeneralMobSettings = (props, context) => {
|
||||
'name',
|
||||
data.default_path_name
|
||||
);
|
||||
const [ai_type] = useLocalState(context, 'aiType', data.ai_type);
|
||||
const [use_custom_ai] = useLocalState(
|
||||
context,
|
||||
'toggleCustomAi',
|
||||
data.use_custom_ai
|
||||
);
|
||||
const [faction] = useLocalState(context, 'setMobFaction', data.faction);
|
||||
const [intent] = useLocalState(context, 'setIntent', data.intent);
|
||||
const [desc, setDesc] = useLocalState(context, 'desc', data.default_desc);
|
||||
const [flavorText, setFlavorText] = useLocalState(
|
||||
context,
|
||||
@@ -114,6 +127,9 @@ const GeneralMobSettings = (props, context) => {
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
<Section title="General Settings">
|
||||
<Flex horizontal>
|
||||
<Flex.Item FlexGrow>
|
||||
<Section title="Positional Settings">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Spawn (X/Y/Z) Coords">
|
||||
@@ -152,6 +168,48 @@ const GeneralMobSettings = (props, context) => {
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
<Flex.Item>
|
||||
<Divider vertical />
|
||||
</Flex.Item>
|
||||
<Flex.Item FlexGrow>
|
||||
<Section
|
||||
title="AI settings"
|
||||
buttons={
|
||||
<Button
|
||||
selected={use_custom_ai}
|
||||
fill
|
||||
content="Use Custom AI"
|
||||
onClick={() => act('toggle_custom_ai')}
|
||||
/>
|
||||
}>
|
||||
<LabeledList>
|
||||
<LabeledList.Item>
|
||||
<Button
|
||||
fluid
|
||||
content={ai_type || 'Choose AI Type'}
|
||||
onClick={(val) => act('set_ai_path')}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item>
|
||||
<Button
|
||||
fluid
|
||||
content={faction || 'Set Faction'}
|
||||
onClick={(val) => act('set_faction')}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item>
|
||||
<Button
|
||||
fluid
|
||||
content={intent || 'Set Intent'}
|
||||
onClick={(val) => act('set_intent')}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
</Section>
|
||||
<Section title="Descriptions">
|
||||
<Flex>
|
||||
<Flex.Item width="50%">
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user