u/Legitimate-Use9076

▲ 1 r/RenPy

How do I make it feel more like Skyrim's lock picking?

​

Like attaching the picks to the key hole like in Skyrim

For some reason I can't insert a video

So here's my code if it helps:

screen lockpick_game():

modal True

add "lock_bg.png"

add "core.png":

anchor (0.5, 0.5)

pos (1900, 810)

rotate core_rotation

zoom 0.6

add "pick2.png":

anchor (0.5, 0.5)

pos (2350, 1220)

rotate core_rotation

zoom 1.5

add "pick.png":

anchor (0.15, 0.95)

pos (1820, 810)

rotate pick_angle

zoom 1.0

frame:

xalign 0.02

yalign 0.02

vbox:

spacing 10

text "Lockpick Health: [pick_health]" size 35

text "Move Mouse = Adjust Pick" size 28

text "Hold SPACE = Turn Lock" size 28

timer 0.01 repeat True action Function(update_pick)

timer 0.01 repeat True action Function(update_lock)

key "keydown_K_SPACE" action SetVariable("turning", True)

key "keyup_K_SPACE" action SetVariable("turning", False)

if unlocked:

text "UNLOCKED":

align (0.5, 0.2)

size 80

color "#FFD700"

timer 1.0 action Return()

if pick_broken:

text "LOCKPICK BROKE":

align (0.5, 0.2)

size 70

color "#FF4444"

timer 1.2 action Return()

init python:

import math

def update_pick():

global pick_angle

mx, my = renpy.get_mouse_pos()

center_x = 1920

center_y = 1080

dx = mx - center_x

dy = my - center_y

angle = math.degrees(math.atan2(dy, dx))

# clamp angle

angle = max(-90, min(90, angle))

pick_angle = angle

def update_lock():

global core_rotation

global unlocked

global pick_health

global pick_broken

if unlocked:

return

if pick_broken:

return

if turning:

distance = abs(pick_angle - sweet_spot)

if distance <= 8:

core_rotation += 4

elif distance <= 25:

max_turn = 90 - distance * 2

if core_rotation < max_turn:

core_rotation += 2

else:

damage_pick()

else:

max_turn = 10

if core_rotation < max_turn:

core_rotation += 1

else:

damage_pick()

if core_rotation >= 90:

core_rotation = 90

unlocked = True

else:

if core_rotation > 0:

core_rotation -= 3

if core_rotation < 0:

core_rotation = 0

def damage_pick():

global pick_health

global pick_broken

pick_health -= 1

if pick_health <= 0:

pick_health = 0

pick_broken = True

renpy.notify("The lockpick snapped!")

reddit.com
u/Legitimate-Use9076 — 12 days ago