mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
Replaces money lotto event with an actual six number lotto (#32830)
* Replaces money lotto event with an actual six number lotto * Can_start odds * Takes from jackpot * Persistent jackpot buildup * Fix * Fix * Tied to amount of stuff bought from this and prices * Real var name * More sanity * Cleanup * Cleanup * Starting value just in case * Persistence tweaks * Seems more accurate * Return of the newscasting * Reducing draw to 32, adding in defines * Here? * Clearer defines * Forgot this one * Sanity * Sanity * Attempt at luck * Real sanity * More sanity * Implemented in practice * As defines * Proper divide * Sanity * More in-depth luck systewm * Fix * Sanity * Always gets this number if so * Better here * Line cutdown * Better? * Better again * Changes it to this system * Fix * Better times * Proper length * This too * Better system * Lotto tickets for a limited time only * Fixes announcer nudity * Adds to list * Reformats this back into startWhen var Co-authored-by: kanef <kanef9x@protonmail.com>
This commit is contained in:
@@ -321,3 +321,11 @@ var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
|
||||
/proc/map_range(old_value, old_bottom, old_top, new_bottom, new_top)
|
||||
var/new_value = (old_value - old_bottom) / (old_top - old_bottom) * (new_top - new_bottom) + new_bottom
|
||||
return new_value
|
||||
|
||||
/proc/factorial(num)
|
||||
. = 1
|
||||
for(var/i in 1 to num)
|
||||
. *= i
|
||||
|
||||
#define permutations(amount,sample) (factorial(amount) / factorial(amount - sample))
|
||||
#define combinations(amount,sample) (factorial(amount) / (factorial(sample) * factorial(amount - sample)))
|
||||
|
||||
@@ -238,13 +238,13 @@ var/datum/subsystem/persistence_misc/SSpersistence_misc
|
||||
/datum/persistence_task/highscores/proc/clear_records()
|
||||
data = list()
|
||||
fdel(file(file_path))
|
||||
|
||||
|
||||
//stores map votes for code/modules/html_interface/voting/voting.dm
|
||||
/datum/persistence_task/vote
|
||||
execute = TRUE
|
||||
name = "Persistent votes"
|
||||
file_path = "data/persistence/votes.json"
|
||||
|
||||
|
||||
/datum/persistence_task/vote/on_init()
|
||||
var/list/to_read = read_file()
|
||||
if(!to_read)
|
||||
@@ -281,3 +281,18 @@ var/datum/subsystem/persistence_misc/SSpersistence_misc
|
||||
|
||||
/datum/persistence_task/ape_mode/on_shutdown()
|
||||
write_file(list("ape_mode" = ape_mode))
|
||||
|
||||
//Lotto
|
||||
|
||||
/datum/persistence_task/lotto_jackpot
|
||||
execute = TRUE
|
||||
name = "Lotto jackpot"
|
||||
file_path = "data/persistence/lotto_jackpot.json"
|
||||
|
||||
/datum/persistence_task/lotto_jackpot/on_init()
|
||||
data = read_file()
|
||||
if(length(data))
|
||||
station_jackpot = max(1000000,min(200000000, data["station_jackpot"])) //1 - 200 mil
|
||||
|
||||
/datum/persistence_task/lotto_jackpot/on_shutdown()
|
||||
write_file(list("station_jackpot" = max(1000000,station_jackpot)))
|
||||
|
||||
@@ -433,7 +433,7 @@ The access requirements on the Asteroid Shuttles' consoles have now been revoked
|
||||
theme = "malfdelta"
|
||||
alertlevel = "delta"
|
||||
|
||||
/datum/command_alert/malf_win
|
||||
/datum/command_alert/malf_win
|
||||
name = "AI Malfunctioning Win"
|
||||
alert = 'sound/effects/static/static4.ogg'
|
||||
|
||||
@@ -777,3 +777,11 @@ The access requirements on the Asteroid Shuttles' consoles have now been revoked
|
||||
/datum/command_alert/old_vendotron_teleport/announce()
|
||||
message = "A bluespace tear of unknown origin is formi!g w£thi$ !$@ cu&ic met£#s o£ [station_name()] plea$e-BZZZZZZZT Come on down for fabulous, splendiferous, one of a kind goods at reasona#le pri$es! We'%e prac@ic£all% giving #$e@ away! All $ales a#$ fi@%l-BZZZT excercise caution and report any anomalous activity."
|
||||
..()
|
||||
|
||||
/datum/command_alert/lotto_announce
|
||||
alert_title = "Central Command Grand Slam -Stellar- Lottery"
|
||||
message = "A lotto number draw is scheduled to happen within the next 5 minutes. All nearby entertainment monitors will be broadcasting the results"
|
||||
|
||||
/datum/command_alert/lotto_winner
|
||||
alert_title = "Grand Slam -Stellar- Lottery Winner!"
|
||||
message = "Congratulations to John Nanotrasen for winning the Central Command Grand Slam -Stellar- Lottery Fund! He walks home with a million credits!"
|
||||
|
||||
@@ -3746,6 +3746,7 @@ var/global/num_vending_terminals = 1
|
||||
/obj/item/toy/lotto_ticket/supermatter_surprise = 5
|
||||
)
|
||||
prices = list(
|
||||
/obj/item/weapon/paper/lotto_numbers = 1,
|
||||
/obj/item/toy/lotto_ticket/gold_rush = 5,
|
||||
/obj/item/toy/lotto_ticket/diamond_hands = 10,
|
||||
/obj/item/toy/lotto_ticket/phazon_fortune = 20,
|
||||
@@ -3753,7 +3754,44 @@ var/global/num_vending_terminals = 1
|
||||
)
|
||||
|
||||
pack = /obj/structure/vendomatpack/lotto
|
||||
var/list/winning_numbers = list()
|
||||
|
||||
var/station_jackpot = 1000000
|
||||
|
||||
/obj/machinery/vending/lotto/examine(mob/user)
|
||||
..()
|
||||
to_chat(user,"<span class='notice'>Today's winning jackpot is [station_jackpot >= 1000000 ? "[round(station_jackpot/1000000,0.1)]m" : station_jackpot] credits!</span>")
|
||||
if(winning_numbers && winning_numbers.len)
|
||||
to_chat(user,"<span class='notice'>The winning numbers are [english_list(winning_numbers)]</span>")
|
||||
|
||||
#define LOTTO_SAMPLE 6
|
||||
#define LOTTO_BALLCOUNT 32 //lottery is a topdefine/bottomdefine system
|
||||
#if LOTTO_BALLCOUNT < LOTTO_SAMPLE
|
||||
#define LOTTO_BALLCOUNT LOTTO_SAMPLE
|
||||
#endif
|
||||
|
||||
/obj/item/weapon/paper/lotto_numbers
|
||||
name = "Lotto numbers"
|
||||
desc = "A piece of papers with numbers that can be cashed out at randomly announced draws. Rarely wins."
|
||||
info = "The numbers on this paper are:<br>"
|
||||
var/list/winning_numbers = list()
|
||||
|
||||
var/global/list/obj/item/weapon/paper/lotto_numbers/lotto_papers = list()
|
||||
|
||||
/obj/item/weapon/paper/lotto_numbers/New()
|
||||
..()
|
||||
lotto_papers += src
|
||||
for(var/i in 1 to LOTTO_SAMPLE)
|
||||
var/newnumber = 0
|
||||
do
|
||||
newnumber = rand(1,LOTTO_BALLCOUNT)
|
||||
while(newnumber in winning_numbers)
|
||||
winning_numbers.Add(newnumber)
|
||||
info += "[i == LOTTO_SAMPLE ? ": " : ""][newnumber][i < LOTTO_SAMPLE ? " " : ""]"
|
||||
|
||||
/obj/item/weapon/paper/lotto_numbers/Destroy()
|
||||
lotto_papers -= src
|
||||
..()
|
||||
|
||||
/obj/machinery/vending/lotto/proc/AnnounceWinner(var/obj/machinery/vending/lotto/lottovend, var/mob/living/carbon/human/character, var/winnings)
|
||||
var/rank = character.mind.role_alt_title
|
||||
@@ -3774,21 +3812,80 @@ var/global/num_vending_terminals = 1
|
||||
if(!T.revealed)
|
||||
playsound(src, "buzz-sigh", 50, 1)
|
||||
visible_message("<b>[src]</b>'s monitor flashes, \"This ticket cannot be read until the film is scratched off.\"")
|
||||
return
|
||||
if(!T.iswinner)
|
||||
else if(!T.iswinner)
|
||||
playsound(src, "buzz-sigh", 50, 1)
|
||||
visible_message("<b>[src]</b>'s monitor flashes, \"This ticket is not a winning ticket.\"")
|
||||
else
|
||||
visible_message("<b>[src]</b>'s monitor flashes, \"Withdrawing [T.winnings] credits from the Central Command Lottery Fund!\"")
|
||||
dispense_cash(T.winnings, get_turf(src))
|
||||
playsound(src, "polaroid", 50, 1)
|
||||
dispense_funds(T.winnings)
|
||||
if(T.winnings >= 10000)
|
||||
AnnounceWinner(src,user,T.winnings)
|
||||
log_admin("([user.ckey]/[user]) won a large lottery prize of [T.winnings] credits.")
|
||||
qdel(T)
|
||||
if(istype(I, /obj/item/weapon/paper/lotto_numbers))
|
||||
if(!winning_numbers.len)
|
||||
playsound(src, "buzz-sigh", 50, 1)
|
||||
visible_message("<b>[src]</b>'s monitor flashes, \"These numbers cannot be redeemed until the lotto draw.\"")
|
||||
return
|
||||
var/obj/item/weapon/paper/lotto_numbers/LN = I
|
||||
if(winning_numbers.len != LN.winning_numbers.len || LN.winning_numbers.len != LOTTO_SAMPLE)
|
||||
CRASH("Someone didn't make the lotto ticket winning numbers the right length or same length as the event's.")
|
||||
var/bonusmatch = winning_numbers[LOTTO_SAMPLE] == LN.winning_numbers[LOTTO_SAMPLE]
|
||||
var/matches = 0
|
||||
for(var/i in 1 to (winning_numbers.len - 1))
|
||||
if(winning_numbers[i] == LN.winning_numbers[i])
|
||||
matches++
|
||||
if(!bonusmatch || matches < (LOTTO_SAMPLE - 4))
|
||||
playsound(src, "buzz-sigh", 50, 1)
|
||||
visible_message("<b>[src]</b>'s monitor flashes, \"These numbers have no win. [bonusmatch ? "(Not enough matches, [matches+1] of at least [LOTTO_SAMPLE - 3])" : "(Bonus number not matched)"]\"")
|
||||
return
|
||||
else
|
||||
var/final_jackpot = station_jackpot / (10 ** ((LOTTO_SAMPLE-1)-matches)) //n-3 total (including bonus) matches divides by 1000, n-2 by 100, n-1 by 10 and n by 1
|
||||
if(matches >= (LOTTO_SAMPLE - 1))
|
||||
var/datum/command_alert/lotto_winner/LW = new
|
||||
LW.message = "Congratulations to [user] for winning the Central Command Grand Slam -Stellar- Lottery Fund and walking home with [final_jackpot] credits!"
|
||||
command_alert(LW)
|
||||
winning_numbers.Cut() // Reset this, we had a winner
|
||||
var/datum/feed_message/newMsg = new /datum/feed_message
|
||||
newMsg.author = "Nanotrasen Editor"
|
||||
newMsg.is_admin_message = 1
|
||||
|
||||
newMsg.body = "TC Daily wishes to congratulate <b>[user]</b> for recieving the Tau Ceti-Nanotrasen Stellar Slam Lottery, and receiving the out of this world sum of [final_jackpot] credits!"
|
||||
|
||||
for(var/datum/feed_channel/FC in news_network.network_channels)
|
||||
if(FC.channel_name == "Tau Ceti Daily")
|
||||
FC.messages += newMsg
|
||||
break
|
||||
|
||||
for(var/obj/machinery/newscaster/NEWSCASTER in allCasters)
|
||||
NEWSCASTER.newsAlert("Tau Ceti Daily")
|
||||
|
||||
for(var/obj/item/device/pda/PDA in PDAs)
|
||||
var/datum/pda_app/newsreader/reader = locate(/datum/pda_app/newsreader) in PDA.applications
|
||||
if(reader)
|
||||
reader.newsAlert("Tau Ceti Daily")
|
||||
else
|
||||
AnnounceWinner(src,user,final_jackpot)
|
||||
dispense_funds(final_jackpot)
|
||||
log_admin("([user.ckey]/[user]) won [final_jackpot] credits from the lottery!")
|
||||
qdel(LN)
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/vending/lotto/proc/dispense_funds(var/amount)
|
||||
if(station_jackpot <= 0)
|
||||
playsound(src, "buzz-sigh", 50, 1)
|
||||
visible_message("<b>[src]</b>'s monitor flashes, \"The Central Command Lottery Fund is empty, and cannot dispense money.\"")
|
||||
return
|
||||
visible_message("<b>[src]</b>'s monitor flashes, \"Withdrawing [amount] credits from the Central Command Lottery Fund!\"")
|
||||
dispense_cash(amount, get_turf(src))
|
||||
playsound(src, "polaroid", 50, 1)
|
||||
station_jackpot -= (min(station_jackpot,amount))
|
||||
|
||||
|
||||
/obj/machinery/vending/lotto/vend(datum/data/vending_product/R, mob/user, by_voucher = 0)
|
||||
..()
|
||||
station_jackpot = min(200000000, station_jackpot + (R.price * 10000)) //Up to 200 million
|
||||
|
||||
/obj/machinery/vending/lotto/throw_item()
|
||||
var/mob/living/target = locate() in view(7, src)
|
||||
|
||||
|
||||
@@ -860,6 +860,7 @@ var/global/floorIsLava = 0
|
||||
<A href='?src=\ref[src];secretsfun=ionstorm'>Spawn an Ion Storm</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=comms_blackout'>Trigger a communication blackout</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=pda_spam'>Trigger a wave of PDA spams</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=money_lotto'>Start a lotto draw</A><BR>
|
||||
<a href='?src=\ref[src];secretsfun=pick_event'>Pick a random event from all possible random events (WARNING, NOT ALL ARE GUARANTEED TO WORK).</A><BR>
|
||||
<BR>
|
||||
<B>Fun Secrets</B><BR>
|
||||
|
||||
@@ -3589,6 +3589,10 @@
|
||||
feedback_inc("admin_secrets_fun_used",1)
|
||||
feedback_add_details("admin_secrets_fun_used","PDA")
|
||||
new /datum/event/pda_spam
|
||||
if("money_lotto")
|
||||
feedback_inc("admin_secrets_fun_used",1)
|
||||
feedback_add_details("admin_secrets_fun_used","PDA")
|
||||
new /datum/event/money_lotto
|
||||
|
||||
if("carp")
|
||||
feedback_inc("admin_secrets_fun_used",1)
|
||||
|
||||
@@ -1,41 +1,105 @@
|
||||
/datum/event/money_lotto
|
||||
endWhen = 301
|
||||
announceWhen = 300
|
||||
var/winner_name = "John Smith"
|
||||
var/winner_sum = 0
|
||||
var/deposit_success = 0
|
||||
startWhen = 2
|
||||
announceWhen = 1
|
||||
var/list/winning_numbers = list()
|
||||
|
||||
/datum/event/money_lotto/can_start()
|
||||
return 20
|
||||
|
||||
/datum/event/money_lotto/start()
|
||||
winner_sum = pick(5000, 10000, 50000, 100000, 500000, 1000000, 1500000)
|
||||
if(all_money_accounts.len)
|
||||
var/datum/money_account/D = pick(all_money_accounts)
|
||||
D.money += winner_sum
|
||||
/datum/event/money_lotto/setup()
|
||||
startWhen = rand(5,10) * 60
|
||||
|
||||
new /datum/transaction(D, "Winner!", winner_sum, "Biesel TCD Terminal #[rand(111,333)]", "Tau Ceti Daily Grand Slam -Stellar- Lottery")
|
||||
/datum/event/money_lotto/start()
|
||||
var/list/luck_skewed_papers = list()
|
||||
for(var/obj/item/weapon/paper/lotto_numbers/LN in lotto_papers)
|
||||
if(LN.fingerprintslast)
|
||||
var/client/foundclient = directory[ckey(LN.fingerprintslast)]
|
||||
if(foundclient)
|
||||
var/mob/foundmob = foundclient.mob
|
||||
if(foundmob)
|
||||
luck_skewed_papers[LN] = foundmob.luck()
|
||||
|
||||
var/luck_copy_amount = 0
|
||||
var/list/copied_winning_numbers = list()
|
||||
if(luck_skewed_papers.len)
|
||||
var/obj/item/weapon/paper/lotto_numbers/picked_ticket = pickweight(luck_skewed_papers)
|
||||
if(picked_ticket.fingerprintslast)
|
||||
var/client/foundclient = directory[ckey(picked_ticket.fingerprintslast)]
|
||||
if(foundclient)
|
||||
var/mob/foundmob = foundclient.mob
|
||||
for(var/i in LOTTO_SAMPLE-3 to LOTTO_SAMPLE)
|
||||
if(foundmob?.lucky_prob(100/combinations(LOTTO_BALLCOUNT,i), luckfactor = 1/12000, maxskew = 49.9))
|
||||
luck_copy_amount = i
|
||||
copied_winning_numbers = picked_ticket.winning_numbers.Copy()
|
||||
|
||||
var/list/nums_to_copy = list()
|
||||
if(luck_copy_amount)
|
||||
nums_to_copy.Add(LOTTO_SAMPLE)
|
||||
for(var/i in 1 to (luck_copy_amount-1))
|
||||
var/num_to_copy = 0
|
||||
do
|
||||
num_to_copy = rand(1,LOTTO_SAMPLE-1)
|
||||
while(num_to_copy in nums_to_copy)
|
||||
nums_to_copy.Add(num_to_copy)
|
||||
|
||||
for(var/i in 1 to LOTTO_SAMPLE)
|
||||
if((i in nums_to_copy) && copied_winning_numbers.len)
|
||||
winning_numbers.Add(copied_winning_numbers[i])
|
||||
else
|
||||
var/newnumber = 0
|
||||
do
|
||||
newnumber = rand(1,LOTTO_BALLCOUNT)
|
||||
while(newnumber in winning_numbers)
|
||||
winning_numbers.Add(newnumber)
|
||||
|
||||
var/mob/living/carbon/human/dummy/announcer = null
|
||||
for(var/obj/machinery/computer/security/telescreen/entertainment/E in machines)
|
||||
if(E.active_camera?.c_tag != "Arena")
|
||||
var/list/cameras = E.get_available_cameras()
|
||||
if(!("Arena" in cameras))
|
||||
continue
|
||||
|
||||
var/obj/machinery/camera/selected_camera = cameras["Arena"]
|
||||
E.active_camera = selected_camera
|
||||
|
||||
if(!selected_camera)
|
||||
continue
|
||||
|
||||
E.active_camera.camera_twitch()
|
||||
E.update_active_camera_screen()
|
||||
if(!announcer && E.active_camera)
|
||||
var/turf/T = get_turf(E.active_camera)
|
||||
announcer = new(T)
|
||||
announcer.generate_name()
|
||||
var/datum/outfit/special/with_id/nt_rep/NT = new
|
||||
NT.equip(announcer,TRUE)
|
||||
|
||||
if(announcer)
|
||||
announcer.say("Hello and welcome to another edition of Central Command's Grand Slam -Stellar- Lottery. The numbers are now due to be announced.")
|
||||
spawn(8 SECONDS) // This has to be sleep instead of spawn for some reason
|
||||
for(var/i in 1 to winning_numbers.len)
|
||||
sleep(2 SECONDS)
|
||||
announcer.say("[i < winning_numbers.len ? "T" : "And finally t"]he [i]\th number[i == 1 ? " of the draw" : ""] is [winning_numbers[i]].[i == winning_numbers.len ? " Be sure to collect any winnings. This concludes another edition of the Central Command Grand Slam -Stellar- Lottery." : ""]")
|
||||
for(var/obj/machinery/vending/lotto/L in machines)
|
||||
L.winning_numbers = winning_numbers.Copy()
|
||||
for(var/datum/data/vending_product/R in L.product_records)
|
||||
if(R.product_path == /obj/item/weapon/paper/lotto_numbers)
|
||||
L.product_records.Remove(R)
|
||||
spawn(5 SECONDS)
|
||||
announcer.forceMove(null)
|
||||
qdel(announcer)
|
||||
else
|
||||
kill()
|
||||
for(var/obj/machinery/computer/security/telescreen/entertainment/E in machines)
|
||||
E.say("Central Command's Grand Slam -Stellar- Lottery is off air due to technical difficulties. The numbers have been relayed to us as [english_list(winning_numbers)]. We apologize for the inconvenience.")
|
||||
for(var/obj/machinery/vending/lotto/L in machines)
|
||||
L.winning_numbers = winning_numbers.Copy()
|
||||
for(var/datum/data/vending_product/R in L.product_records)
|
||||
if(R.product_path == /obj/item/weapon/paper/lotto_numbers)
|
||||
L.product_records.Remove(R)
|
||||
|
||||
/datum/event/money_lotto/announce()
|
||||
var/datum/feed_message/newMsg = new /datum/feed_message
|
||||
newMsg.author = "Nanotrasen Editor"
|
||||
newMsg.is_admin_message = 1
|
||||
|
||||
newMsg.body = "TC Daily wishes to congratulate <b>[winner_name]</b> for recieving the Tau Ceti Stellar Slam Lottery, and receiving the out of this world sum of [winner_sum] credits!"
|
||||
if(!deposit_success)
|
||||
newMsg.body += "<br>Unfortunately, we were unable to verify the account details provided, so we were unable to transfer the money. Send a cheque containing the sum of $500 to TCD 'Stellar Slam' office on Biesel Prime containing updated details, and it'll be resent within the month."
|
||||
|
||||
for(var/datum/feed_channel/FC in news_network.network_channels)
|
||||
if(FC.channel_name == "Tau Ceti Daily")
|
||||
FC.messages += newMsg
|
||||
break
|
||||
|
||||
for(var/obj/machinery/newscaster/NEWSCASTER in allCasters)
|
||||
NEWSCASTER.newsAlert("Tau Ceti Daily")
|
||||
|
||||
for(var/obj/item/device/pda/PDA in PDAs)
|
||||
var/datum/pda_app/newsreader/reader = locate(/datum/pda_app/newsreader) in PDA.applications
|
||||
if(reader)
|
||||
reader.newsAlert("Tau Ceti Daily")
|
||||
var/datum/command_alert/lotto_announce/LA = new
|
||||
LA.message = "A lotto number draw is scheduled to happen within the next [startWhen / 60] minutes. All nearby entertainment monitors will be broadcasting the results"
|
||||
command_alert(LA)
|
||||
for(var/obj/machinery/vending/lotto/V in machines)
|
||||
V.build_inventory(list(/obj/item/weapon/paper/lotto_numbers = 20))
|
||||
|
||||
Reference in New Issue
Block a user