Slot machine

Holiness

New member
Messages
23
Points
0
So I was wondering, is it possible to create a script that uses almost the same dynamic of one player catching a pet? I mean:

- Talk to npc

- Pay some zeny

- Slot machine (the one you see when catching a pet) appears

If "SUCCESS" -> you'll get a prize.

If "Failure" -> talk again to the npc.


Not sure if it's possible, but would be awesome if it was.

 
You would need a custom command to send the clif packet of both of those images. Something like slotmachine(<0|1>);

Where 0 is fail and 1 is pass. Then you can just calculate the random chance by using rand(1,100) and properly telling which version of the command to use.

OR

you could just make a set of images and produce the same effect using cutin animations

 
oh, is it difficult to create such custom command? q_q if yes, then I'll just use the cutins

 
- Slot machine (the one you see when catching a pet) appears

Not sure if it's possible, but would be awesome if it was.
seems impossibleI tested it

src/map/script.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)diff --git a/src/map/script.c b/src/map/script.cindex cbea20e..0d1a416 100644--- a/src/map/script.c+++ b/src/map/script.c@@ -18778,10 +18778,27 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st) return script->add_builtin(&buildin, true); } +BUILDIN(catch_process) {+ TBL_PC *sd = script->rid2sd(st);+ if ( sd )+ clif->catch_process(sd);+ return true;+}++BUILDIN(pet_roulette) {+ TBL_PC *sd = script->rid2sd(st);+ if ( sd )+ clif->pet_roulette( sd, script_getnum(st,2) ? 1:0 );+ return true;+}++ #define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args } #define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args } void script_parse_builtin(void) { struct script_function BUILDIN[] = {+ BUILDIN_DEF(catch_process,""),+ BUILDIN_DEF(pet_roulette,"i"), // NPC interaction BUILDIN_DEF(mes,"s*"), BUILDIN_DEF(next,""),
Code:
-	script	jdskjsf	-1,{OnInit:	bindatcmd "petcatch", strnpcinfo(0)+"::Onbbb";	bindatcmd "petroll", strnpcinfo(0)+"::Onaaa";	end;Onaaa:	pet_roulette( atoi( .@atcmd_parameters$ ) );	end;Onbbb:	catch_process();	end;}
the clif->catch_process demands the player to click on the monster (poring)Alt+1 to execute @petcatch, and the cursor change into monster taming one,

after click on the poring only the machine start rolling,

I Alt+2 (@petroll 0) and gets fail without monster, Alt+3 (@petroll 1) gets success but without monster too

seems like there's no known way to just make the machine appear ... probably need some client hexing already

EDIT: its not difficult to write the command, but doesn't look promising

yeah better use cutin

PS: reminds me of this

http://rathena.org/board/topic/90717-r-color-game-machine/?hl=cutin#entry236736

 
Last edited by a moderator:
@Annieruru - Is it possible to send the client a dummy mob Id? As in, also send a packet to the client saying you clicked on a mob? If not the yeah, cutin is the way to go.

Edit: Okay here is the script with Cutins. I simplified it quite a bit, so there isn't much room for customizations unless you know what your doing =P

prontera,152,176,4 script SlotMachine 563,{mes "Do you want to play a game?","It costs: "+ .zeny +" zeny to play.";if( select("YES:NO") == 2 || Zeny < .zeny ){ close; }while( @menu == 1 ){Zeny -= .zeny;.@a = rand(1,100);if( .@a < atoi(.animate$[0]) ){ .@a = 1; } else { .@a = 2; }.@b = 1;while( .@b < atoi(.animate$[.@a]) ) { cutin .animate$[3] + .@b,4; sleep2 ( ( atoi(.animate$[4]) * 1000 ) / atoi(.animate$[1]) ); .@b++; }if( .@a == 1 ){ cutin .animate$[3] + atoi(.animate$[1]),4; dispbottom "Failed"; } else { cutin .animate$[3] + atoi(.animate$[2]),4; getitem .prize[0], .prize[1]; }if( select("Another Round:I'm done") == 2 || Zeny < .zeny ){ cutin "",255; close; }}end;OnInit://[0] = Fail Rate//[1] = Fail (Do not change)//[2] = Success (Do not change)//[3] = File Name (Do not change)//[4] = Animation Time (Do not change, for best results )setarray .animate$[0],"30","29","33","slot_","3";setarray .prize[0],501,10;.zeny = 100;end;}

And Also, the cutin files: slot_machine.rar

Just add these to your:  data/texture/À¯ÀúÀÎÅÍÆäÀ̽º/illust folder.

 

Attachments

Last edited by a moderator:
@Annieruru - Is it possible to send the client a dummy mob Id? As in, also send a packet to the client saying you clicked on a mob? If not the yeah, cutin is the way to go.
no, the server send packet to tell the client to change cursor into monster tamingits the client that send the packet to tell the server about which mob ID was tamed

 
Oh okay. Well, i made the script with cutin so meh. No need to try and fight the client =p

 
thank you all for your precious help
default_biggrin.png
!

 
Back
Top