mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 02:54:41 +01:00
Claw Games!
Adds claw games, the absolute most-infuriating arcade game known to mankind. - Uses new fancy HTML5 / Javascript code stuff - Is buildable! - Science can produce the board with programming 2 - Requires a matter bin, manipulator, some cables, and a sheet of glass - Costs money! - Accepts cash or ID swipes, 15 credits per play token - Dispenses prizeballs! - Open them for a random plushie, carp plushie, or action figure! - Two sets of sprites, thanks to FoS and Stephanov Notes for the coders / future: This provides a basic example for introducing new HTML5 / Javascript arcade games, as well as a base type machine to use for such games. While this may seem silly, this proves that we are not doom to have to tolerate only the battle game and Orion Trail forever, and can even make our own games for the arcade.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
@@ -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("<span class='game say'><span class='name'>[src.name]</span> beeps, \"WINNER!\"</span>")
|
||||
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()
|
||||
|
||||
@@ -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 = '<h2>TRY AGAIN!<a href="byond://?src=/* ref src */;prizeWon=0">\[Close Game\]</a>'
|
||||
if(prizeWon)
|
||||
close_game_link = '<h2>YOU WON!</h2><br><a href="byond://?src=/* ref src */;prizeWon=1">\[Close Game\]</a>'
|
||||
document.getElementById('game').innerHTML = '<center><h1> GAME OVER!</h1><br>'+close_game_link+'</center>'
|
||||
}</script>
|
||||
</head>
|
||||
<body onunload="gameShutDown()">
|
||||
<body>
|
||||
|
||||
<div id='game' style='position: relative;'>
|
||||
<div id="background"></div>
|
||||
@@ -279,8 +272,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div style='position: absolute; top: 550px'>
|
||||
<br><button id="play_btn" onclick="gameStartUp()">Play Now!</button><a id="win_btn" href='byond://?src=\ref[src];prizeWon=1' hidden="true"></a><a id="lose_btn" href='byond://?src=\ref[src];prizeWon=0' hidden="true"></a>
|
||||
<div id='controls' style='position: absolute; top: 550px'>
|
||||
<br><button id="play_btn" onclick="gameStartUp()">Play Now!</button> <button id="close_btn" onclick="gameShutDown()">Close Game.</button>
|
||||
<br>
|
||||
<button onmouseover="joystickControlOn('left')" onmouseout="joystickControlOff('left')">/==<br>\==</button>
|
||||
<button onmousedown="joystickControlOn('down')" onmouseup="joystickControlOff('down')">DROP<br>CLAW</button>
|
||||
|
||||
@@ -463,11 +463,21 @@
|
||||
category = list ("Misc. Machinery")
|
||||
|
||||
/datum/design/mining_equipment_vendor
|
||||
name = "Machine Design (Mining Rewards Vender Board)"
|
||||
desc = "The circuit board for a Mining Rewards Vender."
|
||||
name = "Machine Design (Mining Rewards Vendor Board)"
|
||||
desc = "The circuit board for a Mining Rewards Vendor."
|
||||
id = "mining_equipment_vendor"
|
||||
req_tech = list("programming" = 1, "engineering" = 2)
|
||||
build_type = IMPRINTER
|
||||
materials = list(MAT_GLASS=1000, "sacid"=20)
|
||||
build_path = /obj/item/weapon/circuitboard/mining_equipment_vendor
|
||||
category = list ("Misc. Machinery")
|
||||
|
||||
/datum/design/clawgame
|
||||
name = "Machine Design (Claw Game Board)"
|
||||
desc = "The circuit board for a Claw Game."
|
||||
id = "clawgame"
|
||||
req_tech = list("programming" = 2)
|
||||
build_type = IMPRINTER
|
||||
materials = list(MAT_GLASS=1000, "sacid"=20)
|
||||
build_path = /obj/item/weapon/circuitboard/clawgame
|
||||
category = list ("Misc. Machinery")
|
||||
Reference in New Issue
Block a user