Skip to content

Commit

Permalink
last pr before custom crafting
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealScarHomie authored and Koshenko committed Mar 6, 2024
1 parent 8b3343c commit af1397d
Show file tree
Hide file tree
Showing 23 changed files with 323 additions and 84 deletions.
1 change: 1 addition & 0 deletions mojave/__DEFINES/do_afters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DOAFTER_SOURCE_FISHING "doafter_fishing"
#define DOAFTER_SOURCE_BREAKICE "doafter_breakice"
#define DOAFTER_SOURCE_DOORS "doafter_doors"
#define DOAFTER_SOURCE_LOCKS "doafter_doors"
#define DOAFTER_SOURCE_TELESCOPICROD "doafter_telescopicrod"
#define DOAFTER_SOURCE_CRATEOPEN "doafter_crateopen"
#define DOAFTER_SOURCE_CHOPTREE "doafter_choptree"
Expand Down
3 changes: 3 additions & 0 deletions mojave/__DEFINES/tools.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Defines for tools

#define TOOL_FISHINGROD "fishingrod"
#define TOOL_PLIERS "pliers"
#define TOOL_RULER "ruler"
#define TOOL_LENS "lens"
20 changes: 14 additions & 6 deletions mojave/code/modules/locks/keys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
worn_icon_state = "empty_placeholder"
w_class = WEIGHT_CLASS_SMALL
ms13_flags_1 = KEY_ITEM
obj_flags = UNIQUE_RENAME | UNIQUE_RENAME_NO_DESCRIPTION //so you can keep track of yo keys
grid_width = 32
grid_height = 32
drop_sound = 'mojave/sound/ms13effects/keydrop.ogg'
pickup_sound = 'mojave/sound/ms13effects/keygrab.ogg'
//Custom key shape for corresponding with the identical lock type pins
//Bitts seperated into sloppy seperates so players can edit them and interaction with keys
var/bitt_amount = 6
var/bitt_1
var/bitt_2
var/bitt_3
Expand All @@ -31,12 +33,18 @@

/obj/item/ms13/key/proc/generate_key_order()
var/static/list/bitting_levels = list("A","B","C","D","E","F")
bitt_1 = pick(bitting_levels)
bitt_2 = pick(bitting_levels)
bitt_3 = pick(bitting_levels)
bitt_4 = pick(bitting_levels)
bitt_5 = pick(bitting_levels)
bitt_6 = pick(bitting_levels)
if(bitt_amount == 6)
bitt_1 = pick(bitting_levels)
bitt_2 = pick(bitting_levels)
bitt_3 = pick(bitting_levels)
bitt_4 = pick(bitting_levels)
bitt_5 = pick(bitting_levels)
bitt_6 = pick(bitting_levels)
if(bitt_amount == 4)
bitt_1 = pick(bitting_levels)
bitt_2 = pick(bitting_levels)
bitt_3 = pick(bitting_levels)
bitt_4 = pick(bitting_levels)

/obj/item/ms13/key/test

Expand Down
Empty file.
12 changes: 12 additions & 0 deletions mojave/code/modules/locks/keys/key_types.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/obj/item/ms13/key/brass
name = "brass key"
desc = "A simple brass key, dont lose it."
icon_state = "brass"
inhand_icon_state = "brass_key"

/obj/item/ms13/key/scrap
name = "makeshift key"
desc = "A crude piece of metal with a jagged protusion, looks like a key."
icon_state = "scrap"
inhand_icon_state = "scrap_key"
bitt_amount = 4
Empty file.
30 changes: 30 additions & 0 deletions mojave/code/modules/locks/lock/lock_types.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/obj/item/ms13/lock/scrap
name = "makeshift lock"
desc = "A crude and makeshift scrap lock, enough to keep people out of your stuff."
icon_state = "scrap"
inhand_icon_state = "scrap_lock"
lock_difficulty = 12
pin_amount = 4

/obj/item/ms13/lock/scrap/unlocked
pre_locked = FALSE

/obj/item/ms13/lock/brass
name = "brass lock"
desc = "A refined and intricate brass lock, keeps people out."
icon_state = "brass"
inhand_icon_state = "brass_lock"
lock_difficulty = 3

/obj/item/ms13/lock/brass/unlocked
pre_locked = FALSE

/obj/item/ms13/lock/advanced
name = "advanced lock"
desc = "A high tech and experimental piece of locking technology, impervious to lockpicking."
icon_state = "advanced"
inhand_icon_state = "advanced_lock"
can_be_lockpicked = FALSE

/obj/item/ms13/lock/advanced/unlocked
pre_locked = FALSE
93 changes: 63 additions & 30 deletions mojave/code/modules/locks/locks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
var/lock_difficulty = 10
//Custom pin shapes for corresponding with the identical key type bitts
//Pins seperated into sloppy seperates so players can edit them and interaction with locks
var/pin_amount = 6
var/pin_1
var/pin_2
var/pin_3
Expand All @@ -31,11 +32,15 @@
var/pin_6
//is the lock pre_locked on spawn - randomise on init
var/pre_locked = TRUE
//if the lock can be lockpicked after being placed
var/can_be_lockpicked = TRUE

/obj/item/ms13/lock/Initialize()
. = ..()
if(pre_locked)
item_lock_locked = TRUE
if(can_be_lockpicked & pre_locked)
AddComponent(/datum/component/lockpickable, difficulty = lock_difficulty)
AddElement(/datum/element/world_icon, null, icon, 'mojave/icons/objects/tools/locks_inventory.dmi')
generate_pin_order()

Expand All @@ -45,12 +50,18 @@

/obj/item/ms13/lock/proc/generate_pin_order()
var/static/list/pin_lengths = list("A","B","C","D","E","F")
pin_1 = pick(pin_lengths)
pin_2 = pick(pin_lengths)
pin_3 = pick(pin_lengths)
pin_4 = pick(pin_lengths)
pin_5 = pick(pin_lengths)
pin_6 = pick(pin_lengths)
if(pin_amount == 6)
pin_1 = pick(pin_lengths)
pin_2 = pick(pin_lengths)
pin_3 = pick(pin_lengths)
pin_4 = pick(pin_lengths)
pin_5 = pick(pin_lengths)
pin_6 = pick(pin_lengths)
if(pin_amount == 4) // change to some sort of for thing in the future idc rn
pin_1 = pick(pin_lengths)
pin_2 = pick(pin_lengths)
pin_3 = pick(pin_lengths)
pin_4 = pick(pin_lengths)

/obj/item/ms13/lock/attack_self(mob/user, list/modifiers)
. = ..()
Expand All @@ -69,6 +80,8 @@
icon_state = initial(icon_state)
lock_open = FALSE
item_lock_locked = TRUE
if(can_be_lockpicked & pre_locked)
AddComponent(/datum/component/lockpickable, difficulty = lock_difficulty)
to_chat(user, span_notice("You clasp the [name] shut."))
playsound(src, 'mojave/sound/ms13effects/lock_clasp.ogg', 50, TRUE)
return
Expand Down Expand Up @@ -104,31 +117,51 @@
if(!item_lock_locked)
to_chat(user, span_notice("The [name] is not shut, clasp it closed to lock."))
return
if(key.bitt_1 != pin_1)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_2 != pin_2)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_3 != pin_3)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_4 != pin_4)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_5 != pin_5)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_6 != pin_6)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(pin_amount == 6)
if(key.bitt_1 != pin_1)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_2 != pin_2)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_3 != pin_3)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_4 != pin_4)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_5 != pin_5)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_6 != pin_6)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(pin_amount == 4)
if(key.bitt_1 != pin_1)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_2 != pin_2)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_3 != pin_3)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_4 != pin_4)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(item_lock_locked)
var/datum/component/lockpickable/lockpickable = GetComponent(/datum/component/lockpickable)
qdel(lockpickable)
playsound(src, 'mojave/sound/ms13effects/key_unlock.ogg', 50, TRUE)
to_chat(user, span_notice("You unlock the [name]. It pops open."))
item_lock_locked = FALSE
Expand Down
124 changes: 81 additions & 43 deletions mojave/code/modules/locks/obj_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,51 +53,71 @@
/obj/attackby(obj/item/I, mob/living/user, params) //good lordy this is some bad code, didnt know much back in 2022 and I can confirm this is levels of slopitude that I didnt know possible from me, but hell it works
//key interactions
if(I.ms13_flags_1 & KEY_ITEM || LOCKING_ITEM && ms13_flags_1 & LOCKABLE_1) //lil more soul for yah
if(I.ms13_flags_1 & LOCKING_ITEM && lock)
if(I == src)
return //don't do an animation if attacking self
var/pixel_x_diff = 0
var/pixel_y_diff = 0

var/direction = get_dir(user, src)
if(direction & NORTH)
pixel_y_diff = 8
else if(direction & SOUTH)
pixel_y_diff = -8

if(direction & EAST)
pixel_x_diff = 8
else if(direction & WEST)
pixel_x_diff = -8
animate(user, pixel_x = user.pixel_x + pixel_x_diff, pixel_y = user.pixel_y + pixel_y_diff, time = 1, easing=BACK_EASING|EASE_IN, flags = ANIMATION_PARALLEL)
animate(user, pixel_x = user.pixel_x - pixel_x_diff, pixel_y = user.pixel_y - pixel_y_diff, time = 2, easing=SINE_EASING, flags = ANIMATION_PARALLEL)
if(I.ms13_flags_1 & KEY_ITEM && lock)
var/obj/item/ms13/key/key = I
if(lock_locked)
if(!do_after(user, 0.5 SECONDS, interaction_key = DOAFTER_SOURCE_LOCKS))
return
if(I == src)
return //don't do an animation if attacking self
var/pixel_x_diff = 0
var/pixel_y_diff = 0

var/direction = get_dir(user, src)
if(direction & NORTH)
pixel_y_diff = 8
else if(direction & SOUTH)
pixel_y_diff = -8

if(direction & EAST)
pixel_x_diff = 8
else if(direction & WEST)
pixel_x_diff = -8
animate(user, pixel_x = user.pixel_x + pixel_x_diff, pixel_y = user.pixel_y + pixel_y_diff, time = 1, easing=BACK_EASING|EASE_IN, flags = ANIMATION_PARALLEL)
animate(user, pixel_x = user.pixel_x - pixel_x_diff, pixel_y = user.pixel_y - pixel_y_diff, time = 2, easing=SINE_EASING, flags = ANIMATION_PARALLEL)
//alignment checks
if(key.bitt_1 != lock.pin_1)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_2 != lock.pin_2)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_3 != lock.pin_3)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_4 != lock.pin_4)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_5 != lock.pin_5)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_6 != lock.pin_6)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(lock.pin_amount == 6)
if(key.bitt_1 != lock.pin_1)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_2 != lock.pin_2)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_3 != lock.pin_3)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_4 != lock.pin_4)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_5 != lock.pin_5)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_6 != lock.pin_6)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(lock.pin_amount == 4)
if(key.bitt_1 != lock.pin_1)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_2 != lock.pin_2)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_3 != lock.pin_3)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(key.bitt_4 != lock.pin_4)
playsound(src, 'mojave/sound/ms13effects/lockpicking/lockpick_tension_11.ogg', 50, TRUE)
to_chat(user, span_notice("The key dosen't turn in [name]."))
return
if(!lock.item_lock_locked)
playsound(src, 'mojave/sound/ms13effects/key_lock.ogg', 50, TRUE)
to_chat(user, span_notice("You lock the [name]."))
Expand Down Expand Up @@ -143,10 +163,28 @@
to_chat(user, span_warning("The [name] is open, close it first."))
return
if(!potential_lock.item_lock_locked && potential_lock.lock_open)
if(!do_after(user, 0.5 SECONDS, src))
if(!do_after(user, 1 SECONDS, src))
return
if(!user.transferItemToLoc(potential_lock, src))
return
if(I == src)
return //don't do an animation if attacking self
var/pixel_x_diff = 0
var/pixel_y_diff = 0

var/direction = get_dir(user, src)
if(direction & NORTH)
pixel_y_diff = 8
else if(direction & SOUTH)
pixel_y_diff = -8

if(direction & EAST)
pixel_x_diff = 8
else if(direction & WEST)
pixel_x_diff = -8
animate(user, pixel_x = user.pixel_x + pixel_x_diff, pixel_y = user.pixel_y + pixel_y_diff, time = 1, easing=BACK_EASING|EASE_IN, flags = ANIMATION_PARALLEL)
animate(user, pixel_x = user.pixel_x - pixel_x_diff, pixel_y = user.pixel_y - pixel_y_diff, time = 2, easing=SINE_EASING, flags = ANIMATION_PARALLEL)

lock = potential_lock
can_be_picked = TRUE
lock.item_lock_locked = TRUE
Expand Down
1 change: 1 addition & 0 deletions mojave/effects/spawners/lootdrop/guarenteed/miscloot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
/obj/item/shovel/ms13/rake,
/obj/item/ms13/brick,
/obj/item/knife/ms13/scissors,
/obj/item/ms13/ruler,
/obj/item/lighter/ms13/zippo,
/obj/item/reagent_containers/ms13/lighterfluid,
/obj/item/storage/box/matches/ms13,
Expand Down
1 change: 1 addition & 0 deletions mojave/effects/spawners/lootdrop/miscloot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
/obj/item/shovel/ms13/rake,
/obj/item/ms13/brick,
/obj/item/knife/ms13/scissors,
/obj/item/ms13/ruler,
/obj/item/lighter/ms13/zippo,
/obj/item/reagent_containers/ms13/lighterfluid,
/obj/item/storage/box/matches/ms13,
Expand Down
Binary file modified mojave/icons/objects/crafting/materials_world.dmi
Binary file not shown.
Loading

0 comments on commit af1397d

Please sign in to comment.