Skip to content

Commit

Permalink
Merge pull request #14 from SPLURT-Station/intento
Browse files Browse the repository at this point in the history
[MODULAR] adds intents
  • Loading branch information
MosleyTheMalO authored Jul 26, 2024
2 parents 7b3fac4 + 04ace4d commit ec3f767
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 0 deletions.
8 changes: 8 additions & 0 deletions code/__DEFINES/~~~splurt_defines/intents.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//INTENT VOODOO SHIT, ABANDON ALL HOPE YE WHO ENTER.

//all different flavors of "falsey"
#define INTENT_HELP 0
#define INTENT_DISARM null
#define INTENT_GRAB ""
//except harm which needs to be the only one that passes if(combat_mode) checks
#define INTENT_HARM TRUE
4 changes: 4 additions & 0 deletions code/__DEFINES/~~~splurt_defines/keybinding.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define COMSIG_KB_HUMAN_SET_INTENT_HELP_DOWN "keybinding_human_set_intent_help_down"
#define COMSIG_KB_HUMAN_SET_INTENT_DISARM_DOWN "keybinding_human_set_intent_disarm_down"
#define COMSIG_KB_HUMAN_SET_INTENT_GRAB_DOWN "keybinding_human_set_intent_grab_down"
#define COMSIG_KB_HUMAN_SET_INTENT_HARM_DOWN "keybinding_human_set_intent_harm_down"
10 changes: 10 additions & 0 deletions code/__HELPERS/~splurt_helpers/mob.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/proc/resolve_intent_name(intent)
switch(intent)
if(INTENT_HELP)
return "help"
if(INTENT_DISARM)
return "disarm"
if(INTENT_GRAB)
return "grab"
if(INTENT_HARM)
return "harm"
15 changes: 15 additions & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@

if(isliving(M))
var/mob/living/L = M
//SPLURT EDIT START
/*
their_combat_mode = L.combat_mode
*/
their_combat_mode = L.combat_mode != INTENT_HELP
//SPLURT EDIT END
they_can_move = L.mobility_flags & MOBILITY_MOVE
//Also spread diseases
for(var/thing in diseases)
Expand Down Expand Up @@ -238,7 +243,12 @@
else if(
!(HAS_TRAIT(M, TRAIT_NOMOBSWAP) || HAS_TRAIT(src, TRAIT_NOMOBSWAP)) &&\
((HAS_TRAIT(M, TRAIT_RESTRAINED) && !too_strong) || !their_combat_mode) &&\
//SPLURT EDIT START
/*
(HAS_TRAIT(src, TRAIT_RESTRAINED) || !combat_mode)
*/
(HAS_TRAIT(src, TRAIT_RESTRAINED) || combat_mode == INTENT_HELP)
//SPLURT EDIT END
)
mob_swap = TRUE
if(mob_swap)
Expand Down Expand Up @@ -281,7 +291,12 @@
//If they're a human, and they're not in help intent, block pushing
if(ishuman(M))
var/mob/living/carbon/human/human = M
//SPLURT EDIT START
/*
if(human.combat_mode)
*/
if(human.combat_mode != INTENT_HELP)
//SPLURT EDIT END
return TRUE
//if they are a cyborg, and they're alive and in combat mode, block pushing
if(iscyborg(M))
Expand Down
46 changes: 46 additions & 0 deletions modular_zzplurt/code/datums/keybinding/human.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/datum/keybinding/human/set_intent
var/set_intent = NONE

/datum/keybinding/human/set_intent/down(client/user)
. = ..()
if(.)
return

var/mob/living/carbon/human/human = user.mob
human.set_combat_mode(set_intent, silent = TRUE)
return TRUE

/datum/keybinding/human/set_intent/help
name = "set_intent_help"
full_name = "Set intent to Help"
hotkey_keys = list("1")
keybind_signal = COMSIG_KB_HUMAN_SET_INTENT_HELP_DOWN
set_intent = INTENT_HELP

/datum/keybinding/human/set_intent/disarm
name = "set_intent_disarm"
full_name = "Set intent to Disarm"
hotkey_keys = list("2")
keybind_signal = COMSIG_KB_HUMAN_SET_INTENT_DISARM_DOWN
set_intent = INTENT_DISARM

/datum/keybinding/human/set_intent/grab
name = "set_intent_grab"
full_name = "Set intent to Grab"
hotkey_keys = list("3")
keybind_signal = COMSIG_KB_HUMAN_SET_INTENT_GRAB_DOWN
set_intent = INTENT_GRAB

/datum/keybinding/human/set_intent/harm
name = "set_intent_harm"
full_name = "Set intent to Harm"
hotkey_keys = list("4")
keybind_signal = COMSIG_KB_HUMAN_SET_INTENT_HARM_DOWN
set_intent = INTENT_HARM


/datum/keybinding/living/disable_combat_mode/can_use(client/user)
return ..() && !ishuman(user.mob)

/datum/keybinding/living/enable_combat_mode/can_use(client/user)
return ..() && !ishuman(user.mob)
21 changes: 21 additions & 0 deletions modular_zzplurt/code/modules/client/click.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/mob/living/carbon/human
var/_last_next_move = 0

/mob/living/carbon/human/ClickOn(atom/A, params)
if(world.time <= next_click)
return
_last_next_move = next_move
return ..()

/mob/living/carbon/human/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers)
if(isliving(attack_target))
switch(combat_mode)
if(INTENT_DISARM)
modifiers -= LEFT_CLICK
modifiers[RIGHT_CLICK] = TRUE
if(INTENT_GRAB)
//CtrlClickOn checks for next_move.. which ClickOn has just set right before calling this.
next_move = _last_next_move
CtrlClickOn(attack_target)
return
return ..()
8 changes: 8 additions & 0 deletions modular_zzplurt/code/modules/hud/_hud.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/datum/hud/human/New(mob/living/carbon/human/owner)
. = ..()
var/index = static_inventory.Find(action_intent)
static_inventory[index] = null
qdel(action_intent)

action_intent = new /atom/movable/screen/intent_toggle(null, src)
static_inventory[index] = action_intent
26 changes: 26 additions & 0 deletions modular_zzplurt/code/modules/hud/screen_objects.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/atom/movable/screen/intent_toggle
name = "intent"
icon_state = "help"
screen_loc = ui_acti

/atom/movable/screen/intent_toggle/update_icon_state()
. = ..()
var/mob/living/owner = hud?.mymob
if(owner)
icon_state = resolve_intent_name(owner.combat_mode)

/atom/movable/screen/intent_toggle/Click(location, control, params)
var/list/modifiers = params2list(params)
var/_x = text2num(modifiers["icon-x"])
var/_y = text2num(modifiers["icon-y"])
var/mob/living/target_mob = usr

if(_x <= 16)
if(_y <= 16)
target_mob.set_combat_mode(INTENT_HARM, silent = TRUE)
else
target_mob.set_combat_mode(INTENT_HELP, silent = TRUE)
else if(_y <= 16)
target_mob.set_combat_mode(INTENT_GRAB, silent = TRUE)
else
target_mob.set_combat_mode(INTENT_DISARM, silent = TRUE)
7 changes: 7 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@
#include "code\__DEFINES\~~bubber_defines\transport.dm"
#include "code\__DEFINES\~~bubber_defines\___HELPERS\global_lists.dm"
#include "code\__DEFINES\~~bubber_defines\research\techweb_nodes.dm"
#include "code\__DEFINES\~~~splurt_defines\intents.dm"
#include "code\__DEFINES\~~~splurt_defines\keybinding.dm"
#include "code\__DEFINES\~~~splurt_defines\traits\declarations.dm"
#include "code\__HELPERS\_auxtools_api.dm"
#include "code\__HELPERS\_lists.dm"
Expand Down Expand Up @@ -626,6 +628,7 @@
#include "code\__HELPERS\~skyrat_helpers\level_traits.dm"
#include "code\__HELPERS\~skyrat_helpers\logging.dm"
#include "code\__HELPERS\~skyrat_helpers\unsorted.dm"
#include "code\__HELPERS\~splurt_helpers\mob.dm"
#include "code\_globalvars\_regexes.dm"
#include "code\_globalvars\admin.dm"
#include "code\_globalvars\arcade.dm"
Expand Down Expand Up @@ -9138,17 +9141,21 @@
#include "modular_zzplurt\code\controllers\configuration\entries\discord.dm"
#include "modular_zzplurt\code\controllers\subsystem\discord.dm"
#include "modular_zzplurt\code\datums\components\crafting\crafting.dm"
#include "modular_zzplurt\code\datums\keybinding\human.dm"
#include "modular_zzplurt\code\game\objects\items\devices\transfer_valve.dm"
#include "modular_zzplurt\code\modules\admin\player_panel.dm"
#include "modular_zzplurt\code\modules\admin\playtimes.dm"
#include "modular_zzplurt\code\modules\admin\transform.dm"
#include "modular_zzplurt\code\modules\atmospherics\machinery\portable\canister.dm"
#include "modular_zzplurt\code\modules\client\click.dm"
#include "modular_zzplurt\code\modules\client\client_procs.dm"
#include "modular_zzplurt\code\modules\client\preferences\player_panel.dm"
#include "modular_zzplurt\code\modules\client\verbs\looc.dm"
#include "modular_zzplurt\code\modules\client\verbs\ooc.dm"
#include "modular_zzplurt\code\modules\discord\tgs_commands.dm"
#include "modular_zzplurt\code\modules\discord\verbs.dm"
#include "modular_zzplurt\code\modules\hud\_hud.dm"
#include "modular_zzplurt\code\modules\hud\screen_objects.dm"
#include "modular_zzplurt\code\modules\mob\mob.dm"
#include "modular_zzplurt\code\modules\mob\mob_defines.dm"
#include "modular_zzplurt\code\modules\mob\dead\new_player\new_player.dm"
Expand Down

0 comments on commit ec3f767

Please sign in to comment.