diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index f4f2d4d4ec6..87560b65d20 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -779,4 +779,15 @@ obj/item/weapon/circuitboard/rdserver origin_tech = "programming=1;engineering=2" req_components = list( /obj/item/weapon/stock_parts/console_screen = 1, - /obj/item/weapon/stock_parts/matter_bin = 3) \ No newline at end of file + /obj/item/weapon/stock_parts/matter_bin = 3) + +/obj/item/weapon/circuitboard/clawgame + name = "circuit board (Claw Game)" + build_path = /obj/machinery/arcade/claw + board_type = "machine" + origin_tech = "programming=2" + req_components = list( + /obj/item/weapon/stock_parts.matter_bin = 1, + /obj/item/weapon/stock_parts/manipulator = 1, + /obj/item/stack/cable_coil = 5, + /obj/item/stack/sheet/glass = 1) \ No newline at end of file diff --git a/code/modules/arcade/arcade_base.dm b/code/modules/arcade/arcade_base.dm index 15600e145c0..8a3a1ae7009 100644 --- a/code/modules/arcade/arcade_base.dm +++ b/code/modules/arcade/arcade_base.dm @@ -34,6 +34,23 @@ else user << "\The [src.name] has [tokens] play credits!" +/obj/machinery/arcade/interact(mob/user as mob) + if(stat & BROKEN || panel_open) + return 0 + if(!tokens && !freeplay) + user << "\The [src.name] doesn't have enough credits to play! Pay first!" + return 0 + if(!playing && (tokens || freeplay)) + user.set_machine(src) + playing = 1 + if(!freeplay) + tokens -= 1 + return 1 + if(playing && (src != user.machine)) + user << "Someone else is already playing this machine, please wait your turn!" + return 0 + return 1 + /obj/machinery/arcade/attackby(var/obj/item/O as obj, var/mob/user as mob, params) if(istype(O, /obj/item/weapon/screwdriver) && anchored) playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) diff --git a/code/modules/arcade/arcade_prize.dm b/code/modules/arcade/arcade_prize.dm new file mode 100644 index 00000000000..30374d31a52 --- /dev/null +++ b/code/modules/arcade/arcade_prize.dm @@ -0,0 +1,24 @@ + +/obj/item/toy/prizeball + name = "prize ball" + desc = "A toy is a toy, but a prize ball could be anything! It could even be a toy!" + icon = 'icons/obj/arcade.dmi' + icon_state = "prizeball_1" + var/opening = 0 + +/obj/item/toy/prizeball/New() + ..() + icon_state = pick("prizeball_1","prizeball_2","prizeball_3") + +/obj/item/toy/prizeball/attack_self(mob/user as mob) + if(opening) + return + opening = 1 + playsound(src.loc, 'sound/items/bubblewrap.ogg', 30, 1, extrarange = -4, falloff = 10) + icon_state = "prizeconfetti" + src.color = pick(random_color_list) + var/prize_inside = pick(/obj/random/carp_plushie, /obj/random/plushie, /obj/random/figure) //will add ticket bundles later + spawn(10) + user.unEquip(src) + new prize_inside(user.loc) + qdel(src) \ No newline at end of file diff --git a/code/modules/arcade/claw_game.dm b/code/modules/arcade/claw_game.dm index 26cdbe3c3d0..fb7d41d487e 100644 --- a/code/modules/arcade/claw_game.dm +++ b/code/modules/arcade/claw_game.dm @@ -1,10 +1,12 @@ +/var/claw_game_html = null /obj/machinery/arcade/claw name = "Claw Game" desc = "One of the most infuriating ways to win a toy." icon = 'icons/obj/arcade.dmi' - icon_state = "clawmachine_on" + icon_state = "clawmachine_1_on" token_price = 15 + var/machine_image = "_1" var/bonus_prize_chance = 5 //chance to dispense a SECOND prize if you win, increased by matter bin rating //This is to make sure the images are available @@ -16,13 +18,18 @@ 'icons/obj/arcade_images/prizeorbs.png') /obj/machinery/arcade/claw/New() + machine_image = pick("_1", "_2") + update_icon() component_parts = list() - //component_parts += new /obj/item/weapon/circuitboard/clawgame(null) + component_parts += new /obj/item/weapon/circuitboard/clawgame(null) component_parts += new /obj/item/weapon/stock_parts/matter_bin(null) component_parts += new /obj/item/weapon/stock_parts/manipulator(null) component_parts += new /obj/item/stack/cable_coil(null, 5) component_parts += new /obj/item/stack/sheet/glass(null, 1) RefreshParts() + if(!claw_game_html) + claw_game_html = file2text('code/modules/arcade/crane.html') + claw_game_html = replacetext(claw_game_html, "/* ref src */", "\ref[src]") /obj/machinery/arcade/claw/RefreshParts() var/bin_upgrades = 0 @@ -32,52 +39,46 @@ /obj/machinery/arcade/claw/update_icon() if(stat & BROKEN) - icon_state = "clawmachine_broken" + icon_state = "clawmachine[machine_image]_broken" else if(panel_open) - icon_state = "clawmachine_open" + icon_state = "clawmachine[machine_image]_open" else if(stat & NOPOWER) - icon_state = "clawmachine_off" + icon_state = "clawmachine[machine_image]_off" else - icon_state = "clawmachine_on" + icon_state = "clawmachine[machine_image]_on" return /obj/machinery/arcade/claw/proc/win() - icon_state = "clawmachine_win" - usr << "YOU WIN!" - //if(prob(bonus_prize_chance)) + icon_state = "clawmachine[machine_image]_win" + visible_message("[src.name] beeps, \"WINNER!\"") + if(prob(bonus_prize_chance)) //double prize mania! - // new /obj/item/toy/prizeball(get_turf(src)) - //new /obj/item/toy/prizeball(get_turf(src)) - spawn(5) + new /obj/item/toy/prizeball(get_turf(src)) + new /obj/item/toy/prizeball(get_turf(src)) + playsound(src.loc, 'sound/arcade/Win.ogg', 50, 1, extrarange = -3, falloff = 10) + spawn(10) update_icon() /obj/machinery/arcade/claw/attack_hand(mob/user as mob) interact(user) /obj/machinery/arcade/claw/interact(mob/user as mob) - if(stat & BROKEN || panel_open) + if(!..()) return - if(!tokens && !freeplay) - user << "The game doesn't have enough credits to play! Pay first!" - return - if(!playing && tokens) - user.set_machine(src) - playing = 1 - if(!freeplay) - tokens -= 1 - if(playing && (src != user.machine)) - user << "Someone else is already playing, please wait your turn!" - return - user << browse_rsc('page.css') for(var/i=1, i<=img_resources.len, i++) user << browse_rsc(img_resources[i]) - user << browse('crane.html', "window=Claw Game;size=600x600") + user << browse(claw_game_html, "window=arcade;size=700x600;can_close=0") return /obj/machinery/arcade/claw/Topic(href, list/href_list) if(..()) return - if(href_list["prizeWon"]) - usr << browse(null, "window=Claw Game") //just in case - win() + var/prize_won = null + prize_won = href_list["prizeWon"] + if(!isnull(prize_won)) + usr.unset_machine() + playing = 0 + usr << browse(null, "window=arcade") //just in case + if(prize_won == "1") + win() diff --git a/code/modules/arcade/crane.html b/code/modules/arcade/crane.html index 9ae0cc151c9..04c89c868b4 100644 --- a/code/modules/arcade/crane.html +++ b/code/modules/arcade/crane.html @@ -49,7 +49,7 @@ setTimeout(function(){ state='falling'; $('#debug-streak').html(0); //reset streak - document.getElementById("lose_btn").click(); + setTimeout(gameShutDown(),500); //end game because you dropped it },4*error+300); } @@ -99,16 +99,7 @@ state='hidden'; prizeWon = true; - document.getElementById("win_btn").click(); - - //$('#debug-streak').html(parseInt($('#debug-streak').html())+1); //inc streak - - //spawn new prize - /* - setTimeout(function(){ - prizes[prizes.length] = new Prize(prizes.length,{top: Math.ceil(Math.random()*100),left: original_left},crane);} - ,1000); - */ + gameShutDown(); } CheckBoundaries(); @@ -182,7 +173,7 @@ if(keys["right"] && !state) //right left += hspd; - if(keys["down"] && !state) { //space + if(keys["down"] && !state) { //drop state = 'down'; $('#'+id+' #crane-claw').css(frames['open']); @@ -256,11 +247,13 @@ } function gameShutDown(){ - if(prizeWon != true) - document.getElementById("lose_btn").click(); + var close_game_link = '