Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cain & Abel (new mining loot) #12

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__byond_version_compat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//Update this whenever you need to take advantage of more recent byond features
#define MIN_COMPILER_VERSION 515
#define MIN_COMPILER_BUILD 1642
#define MIN_COMPILER_BUILD 1635
#if (DM_VERSION < MIN_COMPILER_VERSION || DM_BUILD < MIN_COMPILER_BUILD) && !defined(SPACEMAN_DMM) && !defined(OPENDREAM)
//Don't forget to update this part
#error Your version of BYOND is too out-of-date to compile this project. Go to https://secure.byond.com/download and update.
Expand Down
6 changes: 3 additions & 3 deletions code/datums/beam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
visuals.layer = beam_layer
visuals.update_appearance()
Draw()
RegisterSignal(origin, COMSIG_MOVABLE_MOVED, PROC_REF(redrawing))
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(redrawing))
RegisterSignals(origin, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING), PROC_REF(redrawing))
RegisterSignals(target, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING), PROC_REF(redrawing))

/**
* Triggered by signals set up when the beam is set up. If it's still sane to create a beam, it removes the old beam, creates a new one. Otherwise it kills the beam.
Expand All @@ -101,7 +101,7 @@
*/
/datum/beam/proc/redrawing(atom/movable/mover, atom/oldloc, direction)
SIGNAL_HANDLER
if(origin && target && get_dist(origin,target)<max_distance && origin.z == target.z)
if(!QDELETED(origin) && !QDELETED(target) && get_dist(origin,target)<max_distance && origin.z == target.z)
QDEL_LIST(elements)
INVOKE_ASYNC(src, PROC_REF(Draw))
else
Expand Down
4 changes: 2 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@
return throw_at(target, range, speed, thrower, spin, diagonals_first, callback, force, gentle)

///If this returns FALSE then callback will not be called.
/atom/movable/proc/throw_at(atom/target, range, speed, mob/thrower, spin = TRUE, diagonals_first = FALSE, datum/callback/callback, force = MOVE_FORCE_STRONG, gentle = FALSE, quickstart = TRUE)
/atom/movable/proc/throw_at(atom/target, range, speed, mob/thrower, spin = TRUE, diagonals_first = FALSE, datum/callback/callback, force = MOVE_FORCE_STRONG, gentle = FALSE, quickstart = TRUE, throw_datum_typepath = /datum/thrownthing)
. = FALSE

if(QDELETED(src))
Expand Down Expand Up @@ -1380,7 +1380,7 @@
else
target_zone = thrower.zone_selected

var/datum/thrownthing/thrown_thing = new(src, target, get_dir(src, target), range, speed, thrower, diagonals_first, force, gentle, callback, target_zone)
var/datum/thrownthing/thrown_thing = new throw_datum_typepath(src, target, get_dir(src, target), range, speed, thrower, diagonals_first, force, gentle, callback, target_zone)

var/dist_x = abs(target.x - src.x)
var/dist_y = abs(target.y - src.y)
Expand Down
8 changes: 6 additions & 2 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

/// Angle of the icon, used for piercing and slashing attack animations, clockwise from *east-facing* sprites
var/icon_angle = 0
///icon file for an alternate attack icon
var/attack_icon
///icon state for an alternate attack icon
var/attack_icon_state

///Icon file for mob worn overlays.
var/icon/worn_icon
Expand Down Expand Up @@ -878,7 +882,7 @@
else
playsound(hit_atom, 'sound/items/weapons/throwtap.ogg', 1, volume, -1)

/obj/item/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, gentle = FALSE, quickstart = TRUE)
/obj/item/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, gentle = FALSE, quickstart = TRUE, throw_type_path = /datum/thrownthing)
if(HAS_TRAIT(src, TRAIT_NODROP))
return
thrownby = WEAKREF(thrower)
Expand Down Expand Up @@ -1568,7 +1572,7 @@
if (isnull(used_item))
return

var/image/attack_image = image(icon = used_item)
var/image/attack_image = isnull(used_item.attack_icon) ? image(icon = used_item) : image(icon = used_item.attack_icon, icon_state = used_item.attack_icon_state)
attack_image.plane = attacked_atom.plane + 1
// Scale the icon.
attack_image.transform *= 0.5
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/table_clock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
span_notice("You hear repeated smashing!"),
)

/obj/item/table_clock/throw_at(atom/target, range, speed, mob/thrower, spin, diagonals_first, datum/callback/callback, force, gentle, quickstart)
/obj/item/table_clock/throw_at(atom/target, range, speed, mob/thrower, spin, diagonals_first, datum/callback/callback, force, gentle, quickstart, throw_type_path = /datum/thrownthing)
. = ..()
if(!.)
return
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/handcuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@
///Reference of the mob we will attempt to snare
var/datum/weakref/ensnare_mob_ref

/obj/item/restraints/legcuffs/bola/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, gentle = FALSE, quickstart = TRUE)
/obj/item/restraints/legcuffs/bola/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, gentle = FALSE, quickstart = TRUE, throw_type_path = /datum/thrownthing)
if(!..())
return
playsound(src.loc,'sound/items/weapons/bolathrow.ogg', 75, TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
. = ..()
. += span_notice("Throw this at objects or creatures to freeze them, it will boomerang back so be cautious!")

/obj/item/freeze_cube/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, gentle, quickstart = TRUE)
/obj/item/freeze_cube/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, gentle, quickstart = TRUE, throw_type_path = /datum/thrownthing)
. = ..()
if(!.)
return
Expand Down
150 changes: 150 additions & 0 deletions code/modules/mining/lavaland/cain_and_abel/_cain_and_abel.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#define THROW_MODE_CRYSTALS "throw_mode_crystals"
#define THROW_MODE_LAUNCH "throw_mode_launch"

/obj/item/cain_and_abel
name = "Cain & Abel"
desc = "I cry I pray mon Dieu."
icon = 'icons/obj/mining_zones/artefacts.dmi'
lefthand_file = 'icons/mob/inhands/equipment/kitchen_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/kitchen_lefthand.dmi' //same sprite as lefthand
icon_state = "cain_and_abel"
inhand_icon_state = "cain_and_abel"
attack_verb_continuous = list("attacks", "saws", "slices", "tears", "lacerates", "rips", "dices", "cuts")
attack_verb_simple = list("attack", "saw", "slice", "tear", "lacerate", "rip", "dice", "cut")
force = 15
attack_speed = 6
actions_types = list(/datum/action/cooldown/dagger_swing)
hitsound = 'sound/items/weapons/bladeslice.ogg'
w_class = WEIGHT_CLASS_SMALL
sharpness = SHARP_EDGED
light_range = 3
light_power = 2
light_color = "#3db9db"
reach = 2
attack_icon = 'icons/effects/effects.dmi'
attack_icon_state = "cain_abel_attack"
///our current combo count
var/combo_count = 0
///the maximum combo we can reach
var/max_combo = 6
///percentage boost we get on every combo
var/damage_boost = 1.15
///pixel offsets of our wisps
var/static/list/wisp_offsets = list(
list(9, 12),
list(14, 0),
list(9, -12),
list(-9, 12),
list(-14, 0),
list(-9, -12),
)
///what throw mode we're using
var/throw_mode = THROW_MODE_CRYSTALS
///flames we have up!
var/list/current_wisps = list()
///cooldown till we can throw blades again
COOLDOWN_DECLARE(throw_cooldown)

/obj/item/cain_and_abel/Initialize(mapload)
. = ..()
AddComponent(/datum/component/two_handed, require_twohands = TRUE, force_unwielded = force, force_wielded = force)


/obj/item/cain_and_abel/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change)
. = ..()
if(!isliving(old_loc))
return

unset_user(old_loc)

/obj/item/cain_and_abel/proc/unset_user(mob/living/source)
if(HAS_TRAIT(source, TRAIT_RELAYING_ATTACKER))
source.RemoveElement(/datum/element/relay_attackers)

set_combo(new_value = 0, user = source)
UnregisterSignal(source, list(COMSIG_ATOM_WAS_ATTACKED))


/obj/item/cain_and_abel/equipped(mob/user, slot)
. = ..()

if(!(slot & ITEM_SLOT_HANDS))
unset_user(user)
return

if(!HAS_TRAIT(user, TRAIT_RELAYING_ATTACKER))
user.AddElement(/datum/element/relay_attackers)

RegisterSignal(user, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked))

/obj/item/cain_and_abel/proc/on_attacked(datum/source, atom/attacker, attack_flags)
SIGNAL_HANDLER
set_combo(new_value = 0, user = source)

/obj/item/cain_and_abel/ranged_interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers)
if(get_dist(interacting_with, user) > 9 || interacting_with.z != user.z)
return ITEM_INTERACT_BLOCKING

if(!length(current_wisps))
user.balloon_alert(user, "no wisps!")
return

for(var/index in 0 to (length(current_wisps) - 1))
addtimer(CALLBACK(src, PROC_REF(fire_wisp), user, interacting_with), index * 0.15 SECONDS)

set_combo(new_value = 0, user = user)

/obj/item/cain_and_abel/attack(mob/living/target, mob/living/carbon/human/user)
if(!istype(target) || target.mob_size < MOB_SIZE_LARGE || target.stat == DEAD)
return ..()

var/old_force = force
var/bonus_value = combo_count || 1
force = CEILING((bonus_value * damage_boost) * force, 1)
. = ..()
force = old_force
set_combo(new_value = combo_count + 1, user = user)

/obj/item/cain_and_abel/attack_self(mob/user)
. = ..()
if(.)
return TRUE
throw_mode = (throw_mode == THROW_MODE_CRYSTALS) ? THROW_MODE_LAUNCH : THROW_MODE_CRYSTALS
user.balloon_alert(user, "crystals [throw_mode == THROW_MODE_CRYSTALS ? "activated" : "deactivated"]")
return TRUE

/obj/item/cain_and_abel/proc/set_combo(new_value, mob/living/user)
combo_count = (new_value <= max_combo) ? new_value : 0
handle_wisps(user)

/obj/item/cain_and_abel/proc/handle_wisps(mob/living/user)
var/should_remove = length(current_wisps) > combo_count
var/wisps_to_alter = abs(combo_count - length(current_wisps))

for(var/i = 1, i <= wisps_to_alter, i++)
if(!should_remove)
add_wisp(user)
continue
var/obj/my_wisp = current_wisps[i]
remove_wisp(my_wisp)

/obj/item/cain_and_abel/proc/add_wisp(mob/living/user)
var/obj/effect/overlay/blood_wisp/new_wisp = new(src)
current_wisps += new_wisp
var/list/position = wisp_offsets[length(current_wisps)]
user.vis_contents += new_wisp
new_wisp.pixel_x = position[1]
new_wisp.pixel_y = position[2]
RegisterSignal(new_wisp, COMSIG_QDELETING, PROC_REF(on_wisp_delete))

/obj/item/cain_and_abel/proc/on_wisp_delete(datum/source)
SIGNAL_HANDLER
current_wisps -= source
UnregisterSignal(source, COMSIG_QDELETING)

/obj/item/cain_and_abel/proc/fire_wisp(atom/user, atom/target)
user.fire_projectile(/obj/projectile/dagger_wisp, target)

/obj/item/cain_and_abel/proc/remove_wisp(obj/wisp_to_remove)
animate(wisp_to_remove, alpha = 0, time = 0.2 SECONDS)
QDEL_IN(wisp_to_remove, 0.2 SECONDS)
26 changes: 26 additions & 0 deletions code/modules/mining/lavaland/cain_and_abel/dagger_abilities.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/datum/action/cooldown/dagger_swing
name = "Dagger swing"
desc = "Swing your daggers around."
button_icon = 'icons/obj/mining_zones/artefacts.dmi'
button_icon_state = "cain_and_abel"
background_icon_state = "bg_default"
overlay_icon_state = "bg_default_border"
cooldown_time = 20 SECONDS

/datum/action/cooldown/dagger_swing/Activate(atom/target_atom)
. = ..()
var/mob/living/living_owner = owner
living_owner.apply_status_effect(/datum/status_effect/dagger_swinging)

var/static/list/possible_sounds = list(
'sound/items/weapons/cain_and_abel/dagger_slash_1.ogg',
'sound/items/weapons/cain_and_abel/dagger_slash_2.ogg',
'sound/items/weapons/cain_and_abel/dagger_slash_3.ogg',
'sound/items/weapons/cain_and_abel/dagger_slash_4.ogg',
'sound/items/weapons/cain_and_abel/dagger_slash_5.ogg',
'sound/items/weapons/cain_and_abel/dagger_slash_6.ogg',
)

var/list/sounds_to_pick_from = possible_sounds.Copy()
for(var/index in 0 to 5)
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(playsound), owner, pick_n_take(sounds_to_pick_from), 65, TRUE), 0.15 SECONDS * index)
Loading
Loading