Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game master panel part 1 #2

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__DEFINES/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define XENO_AI_CHOOSE_RANDOM_STRAIN (1<<1)

/*
PROBABILITY CALCULATIONS ARE HERE
PROBABILITY CALCULATIONS ARE HERE
*/

#define XENO_SLASH 80
Expand Down
7 changes: 5 additions & 2 deletions code/game/gamemodes/colonialmarines/ai/colonialmarines_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@
/datum/game_mode/colonialmarines/ai/end_round_message()
return ..()

/datum/game_mode/colonialmarines/ai/proc/handle_xeno_spawn(datum/source, mob/living/carbon/xenomorph/X)
/datum/game_mode/colonialmarines/ai/proc/handle_xeno_spawn(datum/source, mob/living/carbon/xenomorph/spawning_xeno, ai_hard_off = FALSE)
SIGNAL_HANDLER
X.make_ai()
if(ai_hard_off)
return

spawning_xeno.make_ai()

/datum/game_mode/colonialmarines/ai/check_win()
if(!game_started || round_finished || SSticker.current_state != GAME_STATE_PLAYING)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ var/list/roundstart_mod_verbs = list(
add_verb(src, /datum/admins/proc/imaginary_friend)
if(CLIENT_HAS_RIGHTS(src, R_BUILDMODE))
add_verb(src, /client/proc/togglebuildmodeself)
add_verb(src, /client/proc/toggle_game_master)
if(CLIENT_HAS_RIGHTS(src, R_SERVER))
add_verb(src, admin_verbs_server)
if(CLIENT_HAS_RIGHTS(src, R_DEBUG))
Expand Down Expand Up @@ -354,6 +355,7 @@ var/list/roundstart_mod_verbs = list(
remove_verb(src, list(
admin_verbs_default,
/client/proc/togglebuildmodeself,
/client/proc/toggle_game_master,
admin_verbs_admin,
admin_verbs_ban,
admin_verbs_minor_event,
Expand Down
131 changes: 131 additions & 0 deletions code/modules/admin/game_master.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/proc/open_game_master_panel(client/using_client)
set name = "Game Master Panel"
set category = "Game Master"

new /datum/game_master(using_client)


/client/proc/toggle_game_master()
set name = "Game Master Panel"
set category = "Game Master"
if(!check_rights(R_ADMIN))
return

if(src)
open_game_master_panel(src)


#define DEFAULT_SPAWN_XENO_STRING XENO_CASTE_DRONE
#define GAME_MASTER_AI_XENOS list(XENO_CASTE_DRONE, XENO_CASTE_RUNNER, XENO_CASTE_CRUSHER)

#define DEFAULT_XENO_AMOUNT_TO_SPAWN 1

#define SPAWN_CLICK_INTERCEPT_ACTION "spawn_click_intercept_action"

/datum/game_master

var/selected_xeno = DEFAULT_SPAWN_XENO_STRING
var/xenos_to_spawn = DEFAULT_XENO_AMOUNT_TO_SPAWN
var/spawn_ai = TRUE
var/spawn_click_intercept = FALSE

var/current_click_intercept_action

/datum/game_master/New(client/using_client)
. = ..()

if(using_client.mob)
tgui_interact(using_client.mob)

/datum/game_master/Destroy(force, ...)
. = ..()

/datum/game_master/ui_data(mob/user)
. = ..()

var/list/data = list()

data["selected_xeno"] = selected_xeno
data["spawn_ai"] = spawn_ai
data["spawn_click_intercept"] = spawn_click_intercept

return data


/datum/game_master/ui_static_data(mob/user)
. = ..()

var/list/data = list()

data["default_spawnable_xeno_string"] = DEFAULT_SPAWN_XENO_STRING
data["spawnable_xenos"] = GAME_MASTER_AI_XENOS

return data


/datum/game_master/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()

switch(action)
if("toggle_click_spawn")
var/client/user_client = ui.user.client
if(user_client.click_intercept == src)
user_client.click_intercept = null
spawn_click_intercept = FALSE
current_click_intercept_action = null
return

user_client.click_intercept = src
spawn_click_intercept = TRUE
current_click_intercept_action = SPAWN_CLICK_INTERCEPT_ACTION
return

if("xeno_spawn_ai_toggle")
spawn_ai = !spawn_ai
return

if("set_selected_xeno")
selected_xeno = params["new_xeno"]
return

if("set_xeno_spawns")
var/new_number = text2num(params["value"])
if(!new_number)
return

xenos_to_spawn = clamp(new_number, 1, 10)
return

/datum/game_master/ui_close(mob/user)
. = ..()

var/client/user_client = user.client
if(user_client?.click_intercept == src)
user_client.click_intercept = null

qdel(src)

/datum/game_master/ui_status(mob/user, datum/ui_state/state)
return UI_INTERACTIVE

/datum/game_master/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GameMaster", "Game Master Menu")
ui.open()

/datum/game_master/proc/InterceptClickOn(mob/user, params, atom/object)
switch(current_click_intercept_action)
if(SPAWN_CLICK_INTERCEPT_ACTION)
var/spawning_xeno_type = RoleAuthority.get_caste_by_text(selected_xeno)

if(!spawning_xeno_type)
to_chat(user, SPAN_NOTICE(SPAN_BOLD("Unable to find xeno type by name: [selected_xeno]")))
return

var/turf/spawn_turf = get_turf(object)

for(var/i = 1 to xenos_to_spawn)
new spawning_xeno_type(spawn_turf, null, XENO_HIVE_NORMAL, !spawn_ai)

return
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/xenomorph/Xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
var/atom/movable/vis_obj/xeno_wounds/wound_icon_carrier
var/atom/movable/vis_obj/xeno_pack/backpack_icon_carrier

/mob/living/carbon/xenomorph/Initialize(mapload, mob/living/carbon/xenomorph/oldXeno, h_number)
/mob/living/carbon/xenomorph/Initialize(mapload, mob/living/carbon/xenomorph/oldXeno, h_number, ai_hard_off = FALSE)
var/area/A = get_area(src)
if(A && A.statistic_exempt)
statistic_exempt = TRUE
Expand Down Expand Up @@ -513,7 +513,7 @@
Decorate()

RegisterSignal(src, COMSIG_MOB_SCREECH_ACT, PROC_REF(handle_screech_act))
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_XENO_SPAWN, src)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_XENO_SPAWN, src, ai_hard_off)

/mob/living/carbon/xenomorph/proc/handle_screech_act(mob/self, mob/living/carbon/xenomorph/queen/queen)
SIGNAL_HANDLER
Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,7 @@ s// DM Environment file for colonialmarines.dme.
#include "code\modules\admin\create_object.dm"
#include "code\modules\admin\create_turf.dm"
#include "code\modules\admin\fax_templates.dm"
#include "code\modules\admin\game_master.dm"
#include "code\modules\admin\holder2.dm"
#include "code\modules\admin\IsBanned.dm"
#include "code\modules\admin\NewBan.dm"
Expand Down
63 changes: 63 additions & 0 deletions tgui/packages/tgui/interfaces/GameMaster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useBackend } from '../backend';
import { Flex, Dropdown, Button, Section } from '../components';
import { Window } from '../layouts';

export const GameMaster = (props, context) => {
const { data, act } = useBackend(context);

return (
<Window width={400} height={400}>
<Window.Content scrollable>
<Section title="Spawning">
<Flex grow direction="column">
<Flex.Item>
<Flex grow>
<Flex.Item>
<Button.Input
fluid
middle
content="###"
onCommit={(e, value) => {
act('set_xeno_spawns', { value });
}}
/>
</Flex.Item>
<Flex.Item grow>
<Dropdown
options={data.spawnable_xenos}
selected={data.default_spawnable_xeno_string}
onSelected={(new_xeno) => {
act('set_selected_xeno', { new_xeno });
}}
/>
</Flex.Item>
</Flex>
</Flex.Item>
<Flex.Item>
<Flex grow>
<Flex.Item>
<Button.Checkbox
checked={data.spawn_ai}
content="AI"
onClick={() => {
act('xeno_spawn_ai_toggle');
}}
/>
</Flex.Item>
<Flex.Item>
<Button
selected={data.spawn_click_intercept}
content="Click Spawn"
onClick={() => {
act('toggle_click_spawn');
}}
/>
</Flex.Item>
</Flex>
</Flex.Item>
</Flex>
</Section>
</Window.Content>
</Window>
);
};
Loading