forked from MrMelbert/MapleStationCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You walk faster with canes on missing limbs (MrMelbert#459)
- Loading branch information
Showing
5 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
maplestation_modules/code/datums/components/limbless_aid.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/// Attach to items that help mobs missing limbs move faster when held. | ||
/datum/component/limbless_aid | ||
/// What slot flags must the parent item have to provide the bonus? | ||
var/required_slot = ITEM_SLOT_HANDS | ||
/// How much should the movespeed be modified? | ||
var/movespeed_mod = 0.5 | ||
|
||
/datum/component/limbless_aid/Initialize(required_slot = ITEM_SLOT_HANDS, movespeed_mod = 0.5) | ||
if(!isitem(parent)) | ||
return COMPONENT_INCOMPATIBLE | ||
|
||
src.required_slot = required_slot | ||
src.movespeed_mod = movespeed_mod | ||
|
||
/datum/component/limbless_aid/RegisterWithParent() | ||
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip)) | ||
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(on_drop)) | ||
|
||
var/obj/item/item_parent = parent | ||
if(isliving(item_parent.loc)) | ||
var/mob/living/wearer = item_parent.loc | ||
on_equip(parent, wearer, wearer.get_slot_by_item(parent)) | ||
|
||
/datum/component/limbless_aid/UnregisterFromParent() | ||
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)) | ||
|
||
var/obj/item/item_parent = parent | ||
if(isliving(item_parent.loc)) | ||
var/mob/living/wearer = item_parent.loc | ||
UnregisterSignal(wearer, COMSIG_LIVING_LIMBLESS_MOVESPEED_UPDATE) | ||
wearer.update_limbless_movespeed_mod() | ||
|
||
/datum/component/limbless_aid/proc/on_equip(obj/item/source, mob/living/user, slot) | ||
SIGNAL_HANDLER | ||
|
||
if(!(slot & required_slot)) | ||
return | ||
|
||
RegisterSignal(user, COMSIG_LIVING_LIMBLESS_MOVESPEED_UPDATE, PROC_REF(modify_movespeed), override = TRUE) | ||
user.update_limbless_movespeed_mod() | ||
|
||
/datum/component/limbless_aid/proc/on_drop(obj/item/source, mob/living/user) | ||
SIGNAL_HANDLER | ||
|
||
UnregisterSignal(user, COMSIG_LIVING_LIMBLESS_MOVESPEED_UPDATE) | ||
user.update_limbless_movespeed_mod() | ||
|
||
/datum/component/limbless_aid/proc/modify_movespeed(mob/living/source, list/modifiers) | ||
SIGNAL_HANDLER | ||
|
||
modifiers += movespeed_mod |