Skip to content

Commit

Permalink
Wielded Weapon Subtype (#2269)
Browse files Browse the repository at this point in the history
* coded

* forgot to save

* new trail line

* Update wielded.dm
  • Loading branch information
CrabbytheCrab authored Jul 24, 2024
1 parent 26d5766 commit b12da28
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
107 changes: 107 additions & 0 deletions code/game/objects/items/ego_weapons/subtype/wielded.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

//EGO Wield Subtype Code
/obj/item/ego_weapon/wield
// Immutable vars - You will never need to modify these
var/wielded = FALSE
//basic stat changes
var/wielded_attack_speed = 1
var/wielded_force = 1
var/wielded_reach = 1
//slow down stuff
var/should_slow = FALSE
var/wielded_slow_down = 1.5
var/current_slow_down = 0
var/wielded_anti_justice_multiplier = 1
//holder stuff and unwield stuff
var/mob/current_holder
var/should_unwield_cooldown = FALSE
var/unwield_time = 3 SECONDS
var/unwield_cooldown
//text
var/wield_stats = "This weapon can be two-handed."
var/wield_special = null

/obj/item/ego_weapon/wield/Initialize()
. = ..()
RegisterSignal(src, COMSIG_TWOHANDED_WIELD, PROC_REF(OnWield))
RegisterSignal(src, COMSIG_TWOHANDED_UNWIELD, PROC_REF(on_unwield))

/obj/item/ego_weapon/wield/ComponentInitialize()
. = ..()
AddComponent(/datum/component/two_handed, force_unwielded=initial(force), force_wielded=wielded_force)

/obj/item/ego_weapon/wield/examine(mob/user)
. = ..()
. += span_notice(wield_stats)
if(wield_special)
. += span_notice(wield_special)

//Equipped setup
/obj/item/ego_weapon/wield/equipped(mob/living/carbon/human/user, slot)
. = ..()
if(!user)
return
current_holder = user
RegisterSignal(current_holder, COMSIG_MOVABLE_MOVED, PROC_REF(UserMoved))

//Destroy setup
/obj/item/ego_weapon/wield/Destroy(mob/user)
UnregisterSignal(current_holder, COMSIG_MOVABLE_MOVED)
current_holder = null
current_slow_down = 0
user.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/wield, multiplicative_slowdown = 0)
return ..()

//Dropped setup
/obj/item/ego_weapon/wield/dropped(mob/user)
. = ..()
if(!user)
return
current_holder = null
UnregisterSignal(current_holder, COMSIG_MOVABLE_MOVED)
current_slow_down = 0
user.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/wield, multiplicative_slowdown = 0)
on_unwield(src,user)

/obj/item/ego_weapon/wield/attack_self(mob/user)
if (should_unwield_cooldown && unwield_cooldown > world.time)
to_chat(user, span_userdanger("You wielded [src] to recently!"))
return
. = ..()

/obj/item/ego_weapon/wield/attack(mob/living/target, mob/living/user)
. = ..()
if(!.)
return FALSE

if(wielded)
DualWieldAttack(target, user)

/obj/item/ego_weapon/wield/proc/DualWieldAttack(mob/living/target, mob/living/user)

/obj/item/ego_weapon/wield/proc/UserMoved(mob/user)
SIGNAL_HANDLER
user.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/wield, multiplicative_slowdown = current_slow_down)

/obj/item/ego_weapon/wield/proc/OnWield(obj/item/source, mob/user)
SIGNAL_HANDLER
wielded = TRUE
attack_speed = wielded_attack_speed
reach = wielded_reach
var/userjust = (get_modified_attribute_level(user, JUSTICE_ATTRIBUTE))
if(should_slow)
current_slow_down = wielded_slow_down + (wielded_anti_justice_multiplier * userjust/JUSTICE_MOVESPEED_DIVISER)//cuts justice speed scaling also
if(should_unwield_cooldown)
unwield_cooldown = unwield_time + world.time

/obj/item/ego_weapon/wield/proc/on_unwield(obj/item/source, mob/user)
SIGNAL_HANDLER
wielded = FALSE
attack_speed = initial(attack_speed)
reach = initial(reach)
current_slow_down = 0

/datum/movespeed_modifier/wield

multiplicative_slowdown = 0
variable = TRUE
1 change: 1 addition & 0 deletions lobotomy-corp13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,7 @@
#include "code\game\objects\items\ego_weapons\subtype\charge.dm"
#include "code\game\objects\items\ego_weapons\subtype\lance.dm"
#include "code\game\objects\items\ego_weapons\subtype\shield.dm"
#include "code\game\objects\items\ego_weapons\subtype\wielded.dm"
#include "code\game\objects\items\fixer_weaponry\swords.dm"
#include "code\game\objects\items\fixerskills\level3.dm"
#include "code\game\objects\items\fixerskills\skills.dm"
Expand Down

0 comments on commit b12da28

Please sign in to comment.