Files
kiwistation/code/game/objects/items/devices/violin.dm
T
MrPerson fa7a89b25b Instrument tweaks
The piano will stop playing once you walk away from it or get stunned.

The song BPM of the piano and violin will generally speaking be wrong because of discrepancies between the sleep between notes and world.tick_lag. I've solved this by locking BPM to points where the stated BPM will actually be the case because tempo == world.tick_lag.

Example
Current:
song @ 5 tempo - 120 BPM: c, c/2, c -> note -> sleep(5) -> 6 ticks (5.4 time passes) -> note -> sleep(2.5) -> 3 ticks (2.7 time passes) -> note.

With this PR:
song @ 5.4 tempo - 111 BPM: c, c/2, c -> note -> sleep(5.4) -> 6 ticks (5.4 time passes) -> note/2 -> sleep(2.7) -> 3 ticks (2.7 time passes) -> note.

I was hoping this would make the damn things sound better but then I realized it wasn't actually messing anything up. Oh well.
2015-03-20 20:40:36 -07:00

41 lines
1.1 KiB
Plaintext

//copy pasta of the space piano, don't hurt me -Pete
/obj/item/device/violin
name = "space violin"
desc = "A wooden musical instrument with four strings and a bow. \"The devil went down to space, he was looking for an assistant to grief.\""
icon = 'icons/obj/musician.dmi'
icon_state = "violin"
item_state = "violin"
force = 10
var/datum/song/handheld/song
hitsound = "swing_hit"
/obj/item/device/violin/New()
song = new("violin", src)
song.instrumentExt = "ogg"
/obj/item/device/violin/Destroy()
qdel(song)
song = null
..()
/obj/item/device/violin/initialize()
song.tempo = song.sanitize_tempo(song.tempo) // tick_lag isn't set when the map is loaded
..()
/obj/item/device/violin/attack_self(mob/user as mob)
if(!user.IsAdvancedToolUser())
user << "<span class='danger'>You don't have the dexterity to do this!</span>"
return 1
interact(user)
/obj/item/device/violin/interact(mob/user as mob)
if(!user)
return
if(!isliving(user) || user.stat || user.restrained() || user.lying)
return
user.set_machine(src)
song.interact(user)