Files
Bubberstation/code/game/objects/items/inducer.dm
Qustinnus 707fc287b4 Replaces intents with combat mode (#56601)
About The Pull Request

This PR removes intents and replaces them with a combat mode. An explanation of what this means can be found below
Major changes:

    Disarm and Grab intents have been removed.
    Harm/Help is now combat mode, toggled by F or 4 by default
    The context/verb/popup menu now only works when you do shift+right-click
    Right click is now disarm, both in and out of combat mode.
    Grabbing is now on ctrl-click.
    If you're in combat mode, and are currently grabbing/pulling someone, and ctrl-click somewhere else, it will not release the grab (To prevent misclicks)

Minor interaction changes:

Right click to dissasemble tables, racks, filing cabinets (When holding the right tool to do so)
Left click to stunbaton, right click to harmbaton
Right click to tip cows
Right click to malpractice surgery
Right click to hold people at gunpoint (if youre holding a gun)
Why It's Good For The Game

Intents heavily cripple both the code and the UI design of interactions. While I understand that a lot of people will dislike this PR as they are used to intents, they are one of our weakest links in terms of explaining to players how to do specific things, and require a lot more keypresses to do compared to this.

As an example, martial arts can now be done without having to juggle 1 2 3 and 4 to switch intents quickly.

As some of you who saw the first combat mode PR, the context menu used to be disabled in combat mode. In this version it is instead on shift-right click ensuring that you can always use it in the same way.

In this version, combat mode also no longer prevents you from attacking with items when you would so before, as this was something that was commonly complained about.

The full intention of this shift in control scheme is that right click will become "secondary interaction" for items, which prevents some of the awkward juggling we have now with item modes etcetera.
Changelog

cl Qustinnus
add: Intents have been replaced with a combat mode. For more info find the PR here: #56601
/cl
2021-02-04 16:37:32 +13:00

194 lines
5.2 KiB
Plaintext

/obj/item/inducer
name = "inducer"
desc = "A tool for inductively charging internal power cells."
icon = 'icons/obj/tools.dmi'
icon_state = "inducer-engi"
inhand_icon_state = "inducer-engi"
lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi'
force = 7
var/powertransfer = 1000
var/opened = FALSE
var/cell_type = /obj/item/stock_parts/cell/high
var/obj/item/stock_parts/cell/cell
var/recharging = FALSE
/obj/item/inducer/Initialize()
. = ..()
if(!cell && cell_type)
cell = new cell_type
/obj/item/inducer/proc/induce(obj/item/stock_parts/cell/target, coefficient)
var/totransfer = min(cell.charge,(powertransfer * coefficient))
var/transferred = target.give(totransfer)
cell.use(transferred)
cell.update_icon()
target.update_icon()
/obj/item/inducer/get_cell()
return cell
/obj/item/inducer/emp_act(severity)
. = ..()
if(cell && !(. & EMP_PROTECT_CONTENTS))
cell.emp_act(severity)
/obj/item/inducer/attack_obj(obj/O, mob/living/carbon/user)
if(user.combat_mode)
return ..()
if(cantbeused(user))
return
if(recharge(O, user))
return
return ..()
/obj/item/inducer/proc/cantbeused(mob/user)
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to use [src]!</span>")
return TRUE
if(!cell)
to_chat(user, "<span class='warning'>[src] doesn't have a power cell installed!</span>")
return TRUE
if(!cell.charge)
to_chat(user, "<span class='warning'>[src]'s battery is dead!</span>")
return TRUE
return FALSE
/obj/item/inducer/attackby(obj/item/W, mob/user)
if(W.tool_behaviour == TOOL_SCREWDRIVER)
W.play_tool_sound(src)
if(!opened)
to_chat(user, "<span class='notice'>You unscrew the battery compartment.</span>")
opened = TRUE
update_icon()
return
else
to_chat(user, "<span class='notice'>You close the battery compartment.</span>")
opened = FALSE
update_icon()
return
if(istype(W, /obj/item/stock_parts/cell))
if(opened)
if(!cell)
if(!user.transferItemToLoc(W, src))
return
to_chat(user, "<span class='notice'>You insert [W] into [src].</span>")
cell = W
update_icon()
return
else
to_chat(user, "<span class='warning'>[src] already has \a [cell] installed!</span>")
return
if(cantbeused(user))
return
if(recharge(W, user))
return
return ..()
/obj/item/inducer/proc/recharge(atom/movable/A, mob/user)
if(!isturf(A) && user.loc == A)
return FALSE
if(recharging)
return TRUE
else
recharging = TRUE
var/obj/item/stock_parts/cell/C = A.get_cell()
var/obj/O
var/coefficient = 1
if(istype(A, /obj/item/gun/energy))
to_chat(user, "<span class='alert'>Error unable to interface with device.</span>")
return FALSE
if(istype(A, /obj/item/clothing/suit/space))
to_chat(user, "<span class='alert'>Error unable to interface with device.</span>")
return FALSE
if(istype(A, /obj))
O = A
if(C)
var/done_any = FALSE
if(C.charge >= C.maxcharge)
to_chat(user, "<span class='notice'>[A] is fully charged!</span>")
recharging = FALSE
return TRUE
user.visible_message("<span class='notice'>[user] starts recharging [A] with [src].</span>", "<span class='notice'>You start recharging [A] with [src].</span>")
while(C.charge < C.maxcharge)
if(do_after(user, 10, target = user) && cell.charge)
done_any = TRUE
induce(C, coefficient)
do_sparks(1, FALSE, A)
if(O)
O.update_icon()
else
break
if(done_any) // Only show a message if we succeeded at least once
user.visible_message("<span class='notice'>[user] recharged [A]!</span>", "<span class='notice'>You recharged [A]!</span>")
recharging = FALSE
return TRUE
recharging = FALSE
/obj/item/inducer/attack(mob/M, mob/living/user)
if(user.combat_mode)
return ..()
if(cantbeused(user))
return
if(recharge(M, user))
return
return ..()
/obj/item/inducer/attack_self(mob/user)
if(opened && cell)
user.visible_message("<span class='notice'>[user] removes [cell] from [src]!</span>", "<span class='notice'>You remove [cell].</span>")
cell.update_icon()
user.put_in_hands(cell)
cell = null
update_icon()
/obj/item/inducer/examine(mob/living/M)
. = ..()
if(cell)
. += "<span class='notice'>Its display shows: [DisplayEnergy(cell.charge)].</span>"
else
. += "<span class='notice'>Its display is dark.</span>"
if(opened)
. += "<span class='notice'>Its battery compartment is open.</span>"
/obj/item/inducer/update_overlays()
. = ..()
if(opened)
if(!cell)
. += "inducer-nobat"
else
. += "inducer-bat"
/obj/item/inducer/sci
icon_state = "inducer-sci"
inhand_icon_state = "inducer-sci"
desc = "A tool for inductively charging internal power cells. This one has a science color scheme, and is less potent than its engineering counterpart."
cell_type = null
powertransfer = 500
opened = TRUE
/obj/item/inducer/sci/Initialize()
. = ..()
update_icon()
/obj/item/inducer/syndicate
icon_state = "inducer-syndi"
inhand_icon_state = "inducer-syndi"
desc = "A tool for inductively charging internal power cells. This one has a suspicious colour scheme, and seems to be rigged to transfer charge at a much faster rate."
powertransfer = 2000
cell_type = /obj/item/stock_parts/cell/super