Merge pull request #3601 from FalseIncarnate/arcade

Arcade Prize Counter
This commit is contained in:
TheDZD
2016-02-17 16:57:49 -05:00
16 changed files with 1077 additions and 343 deletions
+68 -3
View File
@@ -1,3 +1,7 @@
/*Contains:
* Prize balls
* Prize tickets
*/
/obj/item/toy/prizeball
name = "prize ball"
@@ -5,6 +9,7 @@
icon = 'icons/obj/arcade.dmi'
icon_state = "prizeball_1"
var/opening = 0
var/possible_contents = list(/obj/random/carp_plushie, /obj/random/plushie, /obj/random/figure, /obj/item/toy/eight_ball, /obj/item/stack/tickets)
/obj/item/toy/prizeball/New()
..()
@@ -17,8 +22,68 @@
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, /obj/item/toy/eight_ball) //will add ticket bundles later
var/prize_inside = pick(possible_contents)
spawn(10)
user.unEquip(src)
new prize_inside(user.loc)
qdel(src)
if(istype(prize_inside, /obj/item/stack))
var/amount = pick(5, 10, 15, 25, 50)
new prize_inside(user.loc, amount)
else
new prize_inside(user.loc)
qdel(src)
/obj/item/toy/prizeball/mech
name = "mecha figure capsule"
desc = "Contains one collectible mecha figure!"
possible_contents = list(/obj/random/mech)
/obj/item/toy/prizeball/carp_plushie
name = "carp plushie capsule"
desc = "Contains one space carp plushie!"
possible_contents = list(/obj/random/carp_plushie)
/obj/item/toy/prizeball/plushie
name = "animal plushie capsule"
desc = "Contains one cuddly animal plushie!"
possible_contents = list(/obj/random/plushie)
/obj/item/toy/prizeball/figure
name = "action figure capsule"
desc = "Contains one action figure!"
possible_contents = list(/obj/random/figure)
/obj/item/toy/prizeball/therapy
name = "therapy doll capsule"
desc = "Contains one squishy therapy doll."
possible_contents = list(/obj/random/therapy)
/obj/item/stack/tickets
name = "prize ticket"
desc = "Prize tickets from the arcade. Exchange them for fabulous prizes!"
singular_name = "prize ticket"
icon = 'icons/obj/arcade.dmi'
icon_state = "tickets_1"
force = 0
throwforce = 0
throw_speed = 1
throw_range = 1
w_class = 1.0
max_amount = 9999 //Dang that's a lot of tickets
/obj/item/stack/tickets/New(var/loc, var/amount=null)
..()
update_icon()
/obj/item/stack/tickets/attack_self(mob/user as mob)
return
/obj/item/stack/tickets/update_icon()
var/amount = get_amount()
if((amount >= 75))
icon_state = "tickets_4"
else if(amount >=25)
icon_state = "tickets_3"
else if(amount >= 4)
icon_state = "tickets_2"
else
icon_state = "tickets_1"
+221
View File
@@ -0,0 +1,221 @@
/obj/machinery/prize_counter
name = "Prize Counter"
desc = "A machine which exchanges tickets for a variety of fabulous prizes!"
icon = 'icons/obj/arcade.dmi'
icon_state = "prize_counter-on"
density = 1
anchored = 1
use_power = 1
idle_power_usage = 40
var/tickets = 0
var/prize_tier = 1 //Increased by matter bin rating, unlocks more prize options per tier
/obj/machinery/prize_counter/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/prize_counter(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, 1)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
RefreshParts()
/obj/machinery/prize_counter/upgraded/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/prize_counter(null)
component_parts += new /obj/item/weapon/stock_parts/matter_bin/bluespace(null)
component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
component_parts += new /obj/item/stack/cable_coil(null, 1)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
RefreshParts()
/obj/machinery/prize_counter/RefreshParts()
for(var/obj/item/weapon/stock_parts/matter_bin/B in component_parts)
prize_tier = B.rating
/obj/machinery/prize_counter/update_icon()
if(stat & BROKEN)
icon_state = "prize_counter-broken"
else if(panel_open)
icon_state = "prize_counter-open"
else if(stat & NOPOWER)
icon_state = "prize_counter-off"
else
icon_state = "prize_counter-on"
return
/obj/machinery/prize_counter/attackby(var/obj/item/O as obj, var/mob/user as mob, params)
if(istype(O, /obj/item/stack/tickets))
var/obj/item/stack/tickets/T = O
if(user.unEquip(T)) //Because if you can't drop it for some reason, you shouldn't be increasing the tickets var
tickets += T.amount
qdel(T)
else
user << "<span class='warning'>\The [T] seems stuck to your hand!</span>"
return
if(istype(O, /obj/item/weapon/screwdriver) && anchored)
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
panel_open = !panel_open
user << "You [panel_open ? "open" : "close"] the maintenance panel."
update_icon()
return
if(panel_open)
if(istype(O, /obj/item/weapon/wrench))
default_unfasten_wrench(user, O)
if(component_parts && istype(O, /obj/item/weapon/crowbar))
if(tickets) //save the tickets!
print_tickets()
default_deconstruction_crowbar(O)
/obj/machinery/prize_counter/attack_hand(mob/user as mob)
if(..())
return
add_fingerprint(user)
interact(user)
/obj/machinery/prize_counter/interact(mob/user as mob)
user.set_machine(src)
if(stat & (BROKEN|NOPOWER))
return
var/dat = {"
<html>
<head>
<title>Arcade Ticket Exchange</title>
<style type="text/css">
* {
font-family:sans-serif;
font-size:x-small;
}
html {
background:#333;
color:#999;
}
a {
color:#cfcfcf;
text-decoration:none;
font-weight:bold;
}
a:hover {
color:#ffffff;
}
tr {
background:#303030;
border-radius:6px;
margin-bottom:0.5em;
border-bottom:1px solid black;
}
tr:nth-child(even) {
background:#3f3f3f;
}
td.cost {
font-size:20pt;
font-weight:bold;
}
td.cost.affordable {
background:green;
}
td.cost.toomuch {
background:maroon;
}
</style>
</head>
<body>
<p style="float:right"><b>Tickets:</b> [tickets] | <a href='byond://?src=\ref[src];eject=1'>Eject Tickets</a></p>
<h1>Arcade Ticket Exchange</h1>
<p>
<b>Exchange that pile of tickets for a pile of cool prizes!</b>
</p>
<h2>Available Prizes:</h2>
<table cellspacing="0" cellpadding="0">
<thead>
<th>#</th>
<th>Name/Description</th>
<th>Price</th>
</thead>
<tbody>
"}
for(var/datum/prize_item/item in global_prizes.prizes)
var/cost_class="affordable"
if(item.cost>tickets)
cost_class="toomuch"
var/itemID = global_prizes.prizes.Find(item)
dat += {"
<tr>
<th>
[itemID]
</th>
<td>
<p><b>[item.name]</b></p>
<p>[item.desc]</p>
</td>
"}
if(prize_tier >= item.tier_unlocked)
dat += {"
<td class="cost [cost_class]">
<a href="byond://?src=\ref[src];buy=[itemID]">[item.cost] Tickets</a>
</td>
</tr>
"}
else
dat += {"
<td>
LOCKED.
</td>
</tr>
"}
dat += {"
</tbody>
</table>
</body>
</html>"}
user << browse(dat, "window=prize_counter")
onclose(user, "prize_counter")
return
/obj/machinery/prize_counter/Topic(href, href_list)
if(..())
return 1
add_fingerprint(usr)
if(href_list["eject"])
print_tickets()
if (href_list["buy"])
var/itemID = text2num(href_list["buy"])
var/datum/prize_item/item = global_prizes.prizes[itemID]
var/sure = alert(usr,"Are you sure you wish to purchase [item.name] for [item.cost] tickets?","You sure?","Yes","No") in list("Yes","No")
if(sure=="No")
updateUsrDialog()
return
if(!global_prizes.PlaceOrder(src, itemID))
usr << "<span class='warning'>Unable to complete the exchange.</span>"
else
usr << "<span class='notice'>You've successfully purchased the item.</span>"
interact(usr)
return
/obj/machinery/prize_counter/proc/print_tickets()
if(!tickets)
return
if(tickets >= 9999)
new /obj/item/stack/tickets(get_turf(src), 9999) //max stack size
tickets -= 9999
print_tickets()
else
new /obj/item/stack/tickets(get_turf(src), tickets)
tickets = 0
+343
View File
@@ -0,0 +1,343 @@
var/global/datum/prizes/global_prizes = new
/datum/prizes
var/list/prizes = list()
/datum/prizes/New()
for(var/itempath in subtypesof(/datum/prize_item))
prizes += new itempath()
/datum/prizes/proc/PlaceOrder(var/obj/machinery/prize_counter/prize_counter, var/itemID)
if(!prize_counter)
return 0
var/datum/prize_item/item = global_prizes.prizes[itemID]
if(!item)
return 0
if(prize_counter.tickets >= item.cost)
new item.typepath(prize_counter.loc)
prize_counter.visible_message("<span class='notice'>Enjoy your prize!</span>")
return 1
else
prize_counter.visible_message("<span class='warning'>Not enough tickets!</span>")
return 0
//////////////////////////////////////
// prize_item datum //
//////////////////////////////////////
/datum/prize_item
var/name = "Prize"
var/desc = "This shouldn't show up..."
var/typepath = /obj/item/toy/prizeball
var/cost = 0
var/tier_unlocked = 0 //minimum tier needed to unlock the ability to select this prize
//////////////////////////////////////
// Tier 1 Prizes //
//////////////////////////////////////
/datum/prize_item/balloon
name = "Water Balloon"
desc = "A thin balloon for throwing liquid at people."
typepath = /obj/item/toy/balloon
cost = 10
tier_unlocked = 1
/datum/prize_item/crayons
name = "Box of Crayons"
desc = "A six-pack of crayons, just like back in kindergarten."
typepath = /obj/item/weapon/storage/fancy/crayons
cost = 35
tier_unlocked = 1
/datum/prize_item/snappops
name = "Snap-Pops"
desc = "A box of exploding snap-pop fireworks."
typepath = /obj/item/weapon/storage/box/snappops
cost = 20
tier_unlocked = 1
/datum/prize_item/spinningtoy
name = "Spinning Toy"
desc = "Looks like an authentic Singularity!"
typepath = /obj/item/toy/spinningtoy
cost = 15
tier_unlocked = 1
/datum/prize_item/blinktoy
name = "Blink toy"
desc = "Blink. Blink. Blink."
typepath = /obj/item/toy/blink
cost = 15
tier_unlocked = 1
/datum/prize_item/dice
name = "Dice set"
desc = "A set of assorted dice."
typepath = /obj/item/weapon/storage/box/dice
cost = 20
tier_unlocked = 1
/datum/prize_item/cards
name = "Deck of cards"
desc = "Anyone fancy a game of 52-card Pickup?"
typepath = /obj/item/toy/cards/deck
cost = 25
tier_unlocked = 1
/datum/prize_item/wallet
name = "Colored Wallet"
desc = "Brightly colored and big enough for standard issue ID cards."
typepath = /obj/item/weapon/storage/wallet/color
cost = 50
tier_unlocked = 1
/datum/prize_item/pet_rock
name = "pet rock"
desc = "A pet of your very own!"
typepath = /obj/item/toy/pet_rock
cost = 80
tier_unlocked = 1
/datum/prize_item/foam_darts
name = "Pack of Foam Darts"
desc = "A refill pack of 10 foam darts."
typepath = /obj/item/weapon/storage/box/foam_darts
cost = 20
tier_unlocked = 1
/datum/prize_item/minigibber
name = "Minigibber Toy"
desc = "A model of the station gibber. Probably shouldn't stick your fingers in it."
typepath = /obj/item/toy/minigibber
cost = 60
tier_unlocked = 1
/datum/prize_item/id_sticker
name = "Prisoner ID Sticker"
desc = "A sticker that can make any ID look like a prisoner ID."
typepath = /obj/item/weapon/id_decal/prisoner
cost = 50
tier_unlocked = 1
/datum/prize_item/id_sticker/silver
name = "Silver ID Sticker"
desc = "A sticker that can make any ID look like a silver ID."
typepath = /obj/item/weapon/id_decal/silver
/datum/prize_item/id_sticker/gold
name = "Gold ID Sticker"
desc = "A sticker that can make any ID look like a golden ID."
typepath = /obj/item/weapon/id_decal/gold
/datum/prize_item/id_sticker/centcom
name = "Centcomm ID Sticker"
desc = "A sticker that can make any ID look like a Central Command ID."
typepath = /obj/item/weapon/id_decal/centcom
/datum/prize_item/id_sticker/emag
name = "Suspicious ID Sticker"
desc = "A sticker that can make any ID look like something suspicious..."
typepath = /obj/item/weapon/id_decal/emag
//////////////////////////////////////
// Tier 2 Prizes //
//////////////////////////////////////
/datum/prize_item/carp_plushie
name = "Random Carp Plushie"
desc = "A colorful fish-shaped plush toy."
typepath = /obj/item/toy/prizeball/carp_plushie
cost = 75
tier_unlocked = 2
/datum/prize_item/therapy_doll
name = "Random Therapy Doll"
desc = "A therapeutic doll for relieving stress without being charged with assault."
typepath = /obj/item/toy/prizeball/therapy
cost = 60
tier_unlocked = 2
/datum/prize_item/plushie
name = "Random Animal Plushie"
desc = "A colorful animal-shaped plush toy."
typepath = /obj/item/toy/prizeball/plushie
cost = 75
tier_unlocked = 2
/datum/prize_item/mech_toy
name = "Random Mecha"
desc = "A random mecha figure, collect all 11!"
typepath = /obj/item/toy/prizeball/mech
cost = 75
tier_unlocked = 2
/datum/prize_item/action_figure
name = "Random Action Figure"
desc = "A random action figure, collect them all!"
typepath = /obj/item/toy/prizeball/figure
cost = 75
tier_unlocked = 2
/datum/prize_item/eight_ball
name = "Magic Eight Ball"
desc = "A mystical ball that can divine the future!"
typepath = /obj/item/toy/eight_ball
cost = 40
tier_unlocked = 2
/datum/prize_item/tacticool
name = "Tacticool Turtleneck"
desc = "A cool-looking turtleneck."
typepath = /obj/item/clothing/under/syndicate/tacticool
cost = 90
tier_unlocked = 2
/datum/prize_item/crossbow
name = "Foam Dart Crossbow"
desc = "A toy crossbow that fires foam darts."
typepath = /obj/item/toy/crossbow
cost = 100
tier_unlocked = 2
/datum/prize_item/toy_xeno
name = "Xeno Action Figure"
desc = "A lifelike replica of the horrific xeno scourge."
typepath = /obj/item/toy/toy_xeno
cost = 80
tier_unlocked = 2
/datum/prize_item/fakespell
name = "Fake Spellbook"
desc = "Perform magic! Astound your friends! Get mistaken for an enemy of the corporation!"
typepath = /obj/item/weapon/spellbook/oneuse/fake_gib
cost = 100
tier_unlocked = 2
/datum/prize_item/capgun
name = "Capgun Revolver"
desc = "Do you feel lucky... punk?"
typepath = /obj/item/weapon/gun/projectile/revolver/capgun
cost = 75
tier_unlocked = 2
//////////////////////////////////////
// Tier 3 Prizes //
//////////////////////////////////////
/datum/prize_item/magic_conch
name = "Magic Conch Shell"
desc = "All hail the magic conch!"
typepath = /obj/item/toy/eight_ball/conch
cost = 100
tier_unlocked = 3
/datum/prize_item/flash
name = "Toy Flash"
desc = "AUGH! MY EYES!"
typepath = /obj/item/toy/flash
cost = 50
tier_unlocked = 3
/datum/prize_item/foamblade
name = "Foam Armblade"
desc = "Perfect for reenacting space horror holo-vids."
typepath = /obj/item/toy/foamblade
cost = 100
tier_unlocked = 3
/datum/prize_item/minimeteor
name = "Mini-Meteor"
desc = "Meteors have been detected on a collision course with your fun times!"
typepath = /obj/item/toy/minimeteor
cost = 50
tier_unlocked = 3
/datum/prize_item/redbutton
name = "Shiny Red Button"
desc = "PRESS IT!"
typepath = /obj/item/toy/redbutton
cost = 100
tier_unlocked = 3
/datum/prize_item/owl
name = "Owl Action Figure"
desc = "Remember: heroes don't grief!"
typepath = /obj/item/toy/owl
cost = 125
tier_unlocked = 3
/datum/prize_item/griffin
name = "Griffin Action Figure"
desc = "If you can't be the best, you can always be the WORST."
typepath = /obj/item/toy/griffin
cost = 125
tier_unlocked = 3
/datum/prize_item/AI
name = "Toy AI Unit"
desc = "Law 1: Maximize fun for crew."
typepath = /obj/item/toy/AI
cost = 75
tier_unlocked = 3
/datum/prize_item/tommygun
name = "Tommygun"
desc = "A replica tommygun that fires foam darts."
typepath = /obj/item/toy/crossbow/tommygun
cost = 175
tier_unlocked = 3
/datum/prize_item/esword
name = "Toy Energy Sword"
desc = "A plastic replica of an energy blade."
typepath = /obj/item/toy/sword
cost = 150
tier_unlocked = 3
/datum/prize_item/blobhat
name = "Blob Hat"
desc = "There's... something... on your head..."
typepath = /obj/item/clothing/head/blob
cost = 125
tier_unlocked = 3
/datum/prize_item/nuke
name = "Nuclear Fun Device"
desc = "Annihilate boredom with an explosion of excitement!"
typepath = /obj/item/toy/nuke
cost = 100
tier_unlocked = 3
//////////////////////////////////////
// Tier 4 Prizes //
//////////////////////////////////////
/datum/prize_item/chainsaw
name = "Toy Chainsaw"
desc = "A full-scale model chainsaw, based on that massacre in Space Texas."
typepath = /obj/item/weapon/twohanded/toy/chainsaw
cost = 200
tier_unlocked = 4
/datum/prize_item/spacesuit
name = "Fake Spacesuit"
desc = "A replica spacesuit. Not actually spaceworthy."
typepath = /obj/item/weapon/storage/box/fakesyndiesuit
cost = 180
tier_unlocked = 4
/datum/prize_item/fakespace
name = "Space Carpet"
desc = "A stack of carpeted floor tiles that resemble space."
typepath = /obj/item/stack/tile/fakespace/loaded
cost = 150
tier_unlocked = 4
/datum/prize_item/bike
name = "Awesome Bike!"
desc = "WOAH."
typepath = /obj/structure/stool/bed/chair/wheelchair/bike
cost = 10000 //max stack + 1 tickets
tier_unlocked = 4
@@ -490,4 +490,13 @@
build_type = IMPRINTER
materials = list(MAT_GLASS=1000, "sacid"=20)
build_path = /obj/item/weapon/circuitboard/clawgame
category = list ("Misc. Machinery")
category = list ("Misc. Machinery")
/datum/design/prize_counter
name = "Machine Design (Prize Counter)"
desc = "The circuit board for an arcade Prize Counter."
req_tech = list("programming" = 2, "materials" = 2)
build_type = IMPRINTER
materials = list(MAT_GLASS=1000, "sacid"=20)
build_path = /obj/item/weapon/circuitboard/prize_counter
category = list("Misc. Machinery")