Files
Aurora.3/code/game/objects/items/devices/hacktool.dm
Alberyk 76b743a986 Adds the Aut'akh unathi (#5919)
* Base work for the unathi robot subspecies.

* Adds metabolism species, kidney vars, and the robot unathi organs.

* Moves some action buttons to organs, pretty much a bay port right now. Todo: the unathi and alien stuff should also go here.

* First autakh implant power.

* Fixes the organs action button this time.

* Finishes more implants, and interactions with flashs and vaurca.

* Prepare for great changes.

* Drops the real bomb, boss.

* He who fights with monsters.

* Far more work into augments and limb removing powers.

* Limb verbs should be good now.

* A LOT of work into the assited organ, allowing it to bleed and etc, as well adding a new chem that will stop bleeding in their case.

* Probably the last work on implants.

* Some extra touches.

* Some tweaks to the species.

* More fixes and adds kyre's sprites.

* More runtime fixes.

* Fixes the species name too.

* Fixes travis.

* Updates this file too to work with the new tools procs.

* Adds changelog

* Fixed changelog.

* Unathi hair and lore description.

* Some tweaks to this too.

* Locks away them for now, they will be released after we got all the events and etc done.

* Changes this chemical.

* Fixes an airlock runtime.

* Adds the non scan flag to the autakh, mostly due to some bizzare interactions with changelings and cloning.

* Organs removal changes; can't take out the organ if it is too damage.

* Restricts them back again.

* Robotic organs now have the proper icons and names.

* Adds sprites for their organs and some extra tweaks.

* Fixes this missing icon.

* emp should also now hurt assited organs.

* Tweaks more organ related things.

* Fixes the head not being properly set as well.

* Fixes their flags.

* fixes the flag for real this time.

* Poze's review.

* Changes the au'takh organ buttons to don't be animated.

* Helps with adminbus or something.

* Fowl's requested changes.

* Fixes a typo.

* Robotic limb's brute and burn mods are now controlled by the limb model.

* Fowl's changes once more.

* Stops some spam.

* More grammar.

* No eal.

* Skull's review.
2019-01-23 19:27:44 +01:00

101 lines
3.2 KiB
Plaintext

/obj/item/device/multitool/hacktool
var/is_hacking = 0
var/max_known_targets
var/in_hack_mode = 0
var/list/known_targets
var/list/supported_types
var/datum/topic_state/default/must_hack/hack_state
/obj/item/device/multitool/hacktool/New()
..()
known_targets = list()
max_known_targets = 5 + rand(1,3)
supported_types = list(/obj/machinery/door/airlock)
hack_state = new(src)
/obj/item/device/multitool/hacktool/Destroy()
for(var/T in known_targets)
var/atom/target = T
destroyed_event.unregister(target, src)
known_targets.Cut()
qdel(hack_state)
hack_state = null
return ..()
/obj/item/device/multitool/hacktool/attackby(var/obj/item/W, var/mob/user)
if(W.isscrewdriver())
in_hack_mode = !in_hack_mode
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
else
..()
/obj/item/device/multitool/hacktool/resolve_attackby(atom/A, mob/user)
sanity_check()
if(!in_hack_mode)
return ..()
if(!attempt_hack(user, A))
return 0
A.ui_interact(user, state = hack_state)
return 1
/obj/item/device/multitool/hacktool/proc/attempt_hack(var/mob/user, var/atom/target)
if(is_hacking)
user << "<span class='warning'>You are already hacking!</span>"
return 0
if(!is_type_in_list(target, supported_types))
user << "\icon[src] <span class='warning'>Unable to hack this target!</span>"
return 0
var/found = known_targets.Find(target)
if(found)
known_targets.Swap(1, found) // Move the last hacked item first
return 1
user << "<span class='notice'>You begin hacking \the [target]...</span>"
is_hacking = 1
// On average hackin takes ~30 seconds. Fairly small random span to avoid people simply aborting and trying again
var/hack_result = do_after(user, (20 SECONDS + rand(0, 10 SECONDS) + rand(0, 10 SECONDS)))
is_hacking = 0
if(hack_result && in_hack_mode)
user << "<span class='notice'>Your hacking attempt was succesful!</span>"
playsound(src.loc, 'sound/piano/A#6.ogg', 75)
else
user << "<span class='warning'>Your hacking attempt failed!</span>"
return 0
known_targets.Insert(1, target) // Insert the newly hacked target first,
destroyed_event.register(target, src, /obj/item/device/multitool/hacktool/proc/on_target_destroy)
return 1
/obj/item/device/multitool/hacktool/proc/sanity_check()
if(max_known_targets < 1) max_known_targets = 1
// Cut away the oldest items if the capacity has been reached
if(known_targets.len > max_known_targets)
for(var/i = (max_known_targets + 1) to known_targets.len)
var/atom/A = known_targets[i]
destroyed_event.unregister(A, src)
known_targets.Cut(max_known_targets + 1)
/obj/item/device/multitool/hacktool/proc/on_target_destroy(var/target)
known_targets -= target
/datum/topic_state/default/must_hack
var/obj/item/device/multitool/hacktool/hacktool
/datum/topic_state/default/must_hack/New(var/hacktool)
src.hacktool = hacktool
..()
/datum/topic_state/default/must_hack/Destroy()
hacktool = null
return ..()
/datum/topic_state/default/must_hack/can_use_topic(var/src_object, var/mob/user)
if(!hacktool || !hacktool.in_hack_mode || !(src_object in hacktool.known_targets))
return STATUS_CLOSE
return ..()