Lottery: Difference between revisions

From Revenant Elegy Wiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Jackpot Lottery}}
[[Category:Custom NPCs]]
[[Category:Custom NPCs]]


Line 37: Line 36:


A player holding 5 of 50 tickets sold has a 10% chance of winning. Buying more tickets always improves odds, up to the per-player cap.
A player holding 5 of 50 tickets sold has a 10% chance of winning. Buying more tickets always improves odds, up to the per-player cap.
== GM Commands ==
{| class="wikitable"
! Command !! Minimum Level !! Description
|-
| <code>@lottodraw</code> || 99 || Forces an immediate draw and announces it server-wide
|}
== Technical Notes ==
* Prize and pool totals are computed in SQL to avoid 32-bit integer overflow on high-volume servers.
* Prizes are written directly to the winner's character row in the database, so they are received even if the player is offline at the time of the draw.
* The chatroom display updates after every ticket purchase, every scheduled draw, and every minute tick so that passersby always see the current jackpot.
* Changing <code>.draw_interval</code> only affects the ''next'' scheduled draw. To reset the timer immediately, delete the global variable <code>$lottery_next_draw</code> via <code>@setglobalvar</code> and then reload the NPC with <code>@reloadnpc</code>.
* If a winner accumulates multiple prizes before claiming (e.g., wins back-to-back rounds), the unclaimed amounts stack and are paid out together.
== Database Tables ==
The system creates two tables automatically on first load:
; <code>lottery_tickets</code>
: Stores ticket purchases per player per round. Cleared at the end of each round.
; <code>lottery_winnings</code>
: Holds unclaimed prizes. A row persists until the winner visits the NPC and claims their winnings. On duplicate wins the prize column accumulates.
== See Also ==
* [[Economy]]
* [[Zeny]]
* [[Prontera]]

Latest revision as of 09:43, 6 April 2026


The Lottery is a pool-based raffle system that allows players to purchase tickets for a chance to win a large zeny prize. Tickets are sold continuously throughout a round; at the end of each round a winner is drawn at random and awarded a percentage of the total pool.

The current jackpot is displayed as a live chatroom bubble above the NPC's head, updated after every purchase and every draw.

How It Works

Buying Tickets

Players speak to the Lottery Master NPC in Prontera (147, 174) to purchase tickets for the current round. Each ticket costs 100,000z. A player may hold up to 10 tickets per round. Tickets can be purchased one at a time or in bulk up to the remaining allowance.

Zeny is deducted immediately upon confirming the purchase. If a player does not have sufficient funds, or has already reached the ticket cap, the purchase is declined.

The Draw

A draw is performed automatically on a scheduled interval (every 7 days). At draw time the script:

  1. Totals all tickets sold in the current round.
  2. Computes the prize as a percentage of the total pool (95%).
  3. Selects a winning ticket at random - each ticket a player holds represents one entry, so more tickets means proportionally better odds.
  4. The winner will be announced server-wide and can collect their winnings any time at the NPC.

If no tickets were sold when the draw fires, the round is simply skipped and a new one begins.

Claiming Winnings

When a winner speaks to the Lottery Master NPC, they are shown their unclaimed prize and given the option to claim it immediately. The zeny is added directly to their character whether they are online or offline at the time of the draw. Winnings accumulate if a player wins multiple rounds before claiming.

Odds

Odds are proportional to the number of tickets held relative to the total tickets sold that round.

Win probability  =  Your tickets ÷ Total tickets sold

A player holding 5 of 50 tickets sold has a 10% chance of winning. Buying more tickets always improves odds, up to the per-player cap.