Codice:
quest Capsule_shop begin state start begin
when 9009.chat."Capsule shop" begin
say_title ( "Capsule shop" )
say ( )
if pc.is_gm () then
if game.get_event_flag ( "Jackpot" ) == 0 then
say_reward ( "Attualmente non è impostato alcun jackpot." )
say ( "Scegli il jackpot:" )
say ( )
local Scelta = select ( "Item", "Yang", "Annulla" )
if Scelta == 1 then
say_title ( "Capsule shop" )
say ( )
say ( "Inserisci l'ID dell'item:" )
say ( )
local ID = input ( )
game.set_event_flag ( "Jackpot", ID )
say_title ( "Capsule shop" )
say ( )
say ( "Inserisci il numero di capsule:" )
say_reward ( "P.S. Maggiore è il numero, minore è la possibilità di vincere il jackpot." )
say ( )
local Capsule = input ( )
game.set_event_flag ( "Capsule", Capsule )
local Capsula_vincente = math.random ( Capsule )
say_title ( "Capsule shop" )
say ( )
say ( "Inserisci il prezzo delle capsule:" )
say ( )
local Prezzo = input ( )
game.set_event_flag ( "Prezzo", Prezzo )
say_title ( "Capsule shop" )
say ( )
say_title ( "Il jackpot è stato impostato correttamente." )
say ( )
notice_all ( "Il nuovo jackpot è l'item " .. item_name ( game.get_event_flag ( "Jackpot" ) ) .. " e la quantità di capsule è " .. game.get_event_flag ( "Capsule" ) .. " al prezzo di " .. game.get_event_flag ( "Prezzo" ) .. " yang cadauna." )
notice_all ( "Buona fortuna!" )
elseif Scelta == 2 then
say_title ( "Capsule shop" )
say ( )
say ( "Inserisci l'ammontare del jackpot:" )
say ( )
local Ammontare = input ( )
game.set_event_flag ( "Jackpot" , 1 )
game.set_event_flag ( "Ammontare" , Ammontare )
say_title ( "Capsule shop" )
say ( )
say ( "Inserisci il numero di capsule:" )
say_reward ( "P.S. Maggiore è il numero, minore è la possibilità di vincere il jackpot." )
say ( )
local Capsule = input ( )
game.set_event_flag ( "Capsule", Capsule )
local Capsula_Vincente = math.random ( Capsule )
say_title ( "Capsule shop" )
say ( )
say ( "Inserisci il prezzo delle capsule:" )
say ( )
local Prezzo = input ( )
game.set_event_flag ( "Prezzo", Prezzo )
say_title ( "Capsule shop" )
say ( )
say_title ( "Il jackpot è stato impostato correttamente." )
say ( )
notice_all ( "Il nuovo jackpot è " .. game.get_event_flag ( "Ammontare" ) .. " yang e la quantità di capsule è " .. game.get_event_flag ( "Capsule" ) .. " al prezzo di " .. game.get_event_flag ( "Prezzo" ) .. " yang cadauna." )
notice_all ( "Buona fortuna!" )
end
else
say_title ( "Capsule shop" )
say ( )
say ( "Il jackpot è già stato stabilito." )
if game.get_event_flag ( "Jackpot" ) == 1 then
say_title ( "L'attuale jackpot è " .. game.get_event_flag ( "Ammontare" ) .. " yang." )
say ( )
say_reward ( "Vuoi rimuovere questo jackpot?" )
local Siono = select ( "Si", "No" )
if Siono == 1 then
game.set_event_flag ( "Jackpot", 0 )
game.set_event_flag ( "Capsule", 0 )
game.set_event_flag ( "Ammontare", 0 )
say_title ( "Capsule shop" )
say ( )
say_title ( "Il jackpot è stato rimosso correttamente." )
say ( )
notice_all ( "Attualmente non è disponibile nessun jackpot." )
end
elseif game.get_event_flag ( "Jackpot" ) > 1 then
say_title ( "L'attuale jackpot è l'item " .. item_name ( game.get_event_flag ( "Jackpot" ) ) .. "." )
say ( )
say_reward ( "Vuoi rimuovere questo jackpot?" )
local Siono = select ( "Si", "No" )
if Siono == 1 then
game.set_event_flag ( "Jackpot", 0 )
game.set_event_flag ( "Capsule", 0 )
game.set_event_flag ( "Ammontare", 0 )
game.set_event_flag ( "Prezzo", 0 )
game.set_event_flag ( "Capsula_vincente", 0 )
say_title ( "Capsule shop" )
say ( )
say_title ( "Il jackpot è stato rimosso correttamente." )
say ( )
notice_all ( "Attualmente non è disponibile nessun jackpot." )
end
end
end
else
if game.get_event_flag ( "Jackpot" ) == 0 then
say_reward ( "Non c'è nessun jackpot attualmente." )
else
if game.get_event_flag ( "Jackpot" ) == 1 then
say_title ( "Il jackpot attuale è " .. game.get_event_flag ( "Ammontare" ) .. " yang." )
else
say_title ( "Il jackpot attuale è l'item " .. item_name ( game.get_event_flag ( "Jackpot" ) ) .. "." )
end
say_reward ( "L'attuale prezzo delle capsule è " .. game.get_event_flag ( "Prezzo" ) .. " yang cadauna." )
local Scelta = select ( "Compra capsule", "Cos'e' e come funziona il capsule shop", "Chiudi" )
if Scelta == 1 then
say_title ( "Capsule shop" )
say ( )
say ( "Quante capsule vuoi acquistare?" )
say_reward ( "Rimangono " .. game.get_event_flag ( "Capsule" ) .. "." )
say ( "Quante desideri acquistarne?" )
say ( )
local n = input ( )
if n >= game.get_event_flag ( "Capsule" ) then
say_title ( "Capsule shop" )
say ( )
say_reward ( "Così facendo acquisterai tutte le capsule." )
say ( "Vuoi continuare?" )
say ( )
local Siono = select ( "Si", "No" )
if Siono == 1 then
if pc.get_gold ( ) >= n * game.get_event_flag ( "Prezzo" ) then
pc.give_gold ( - n * game.get_event_flag ( "Prezzo" ) )
pc.give_item ( game.get_event_flag ( "Jackpot" ), 1 )
pc.give_gold ( "Ammontare" )
game.set_event_flag ( "Jackpot", 0 )
game.set_event_flag ( "Capsule", 0 )
game.set_event_flag ( "Ammontare", 0 )
game.set_event_flag ( "Prezzo", 0 )
game.set_event_flag ( "Capsula_vincente", 0 )
notice_all ( pc.get_name () .. " ha vinto il jackpot." )
say_title ( "Capsule shop" )
say ( )
say_title ( "Complimenti, hai vinto il jackpot." )
say ( )
else
say_title ( "Capsule shop" )
say ( )
say_reward ( "Non hai abbastanza denaro per acquistare tutte queste capsule." )
say ( )
end
end
else
if pc.get_gold ( ) >= n * game.get_event_flag ( "Prezzo" ) then
if game.get_event_flag ( "Capsule" ) == game.get_event_flag ( "Capsula_vincente" ) or game.get_event_flag ( "Capsula_vincente" ) > game.get_event_flag ( "Capsule" ) - n then
pc.give_gold ( - n * game.get_event_flag ( "Prezzo" ) )
pc.give_item ( game.get_event_flag ( "Jackpot" ), 1 )
pc.give_gold ( game.get_event_flag ( "Ammontare" ) )
game.set_event_flag ( "Jackpot", 0 )
game.set_event_flag ( "Capsule", 0 )
game.set_event_flag ( "Ammontare", 0 )
game.set_event_flag ( "Prezzo", 0 )
game.set_event_flag ( "Capsula_vincente", 0 )
notice_all ( pc.get_name () .. " ha vinto il jackpot." )
say_title ( "Capsule shop" )
say ( )
say_title ( "Complimenti, hai vinto il jackpot." )
say ( )
else
pc.give_gold ( - n * game.get_event_flag ( "Prezzo" ) )
game.set_event_flag ( "Capsule" , game.get_event_flag ( "Capsule" ) - n )
say_title ( "Capsule shop" )
say ( )
say_reward ( "Mi spiace, non hai vinto il jackpot." )
end
else
say_title ( "Capsule shop" )
say ( )
say_reward ( "Non hai abbastanza denaro." )
end
end
elseif Scelta == 2 then
say_title ( "Capsule shop" )
say ( )
say ( "Grazie al capsule shop potrai vincere dei premi davvero interessanti" )
say ( "consistenti in item molto rari o in una grande quantità di yang." )
say ( )
say ( "Vincere è semplice: bisogna solo avere molta fortuna." )
say ( "Acquista tutte le capsule che vuoi e se tra quelle acquistate" )
say ( " è presente la capsula vicente ( scelta in maniera casuale )" )
say ( "vincerai il jackpot." )
say ( )
say ( "Cosa aspetti, tenta anche tu la fortuna!" )
say_title ( "P.S. Se tutto questo è possibile è anche grazie a MaKri303!" )
say ( )
end
end
end
end
end
end
La quest si compila, il GM può settare la ricompensa, ma i PG non possono comprare le capsule e, sinceramente parlando, non sono riuscito a trovare l'errore, quindi se qualcuno ha voglia faccia pure.

Cosa fa la quest?
Il GM, o un qualsiasi altro membro dello staff, setta il jackpot, che può essere un item o yang, setta il numero di capsule e il pezzo di quest'ultime e il "Dio Random" deciderà la capsula vincente. I PG compreranno le capsule e se tra quelle comprate sarà presente la capsula vincente riceveranno il jackpot.
Note aggiuntive:
La quest, una volta corretta, può essere migliorata in diversi punti. Ecco alcuni miei consigli:
1 - quando i player comprano le capsule possono ricevere "realmente" delle capsule ( forzieri ) con all'interno premi di consolazione, di valore inferiore al jackpot ovviamente;
2 - si può aggiungere un input per settare il numero di item da mettere in palio;
3 - se mi viene in mente qualcos'altro lo aggiungo.
Forza ragazzi mettetevi al lavoro!
