From abd3a36c49df86834ef2ee77f3eec2b5e17ec798 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Tue, 8 Jan 2019 23:34:34 -0200 Subject: Rewrite Arnea, I think with my current skills, I'm capable to pull out this. --- npc/003-10/arnea.txt | 92 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 22 deletions(-) (limited to 'npc/003-10') diff --git a/npc/003-10/arnea.txt b/npc/003-10/arnea.txt index d2f6979e6..7ccc26723 100644 --- a/npc/003-10/arnea.txt +++ b/npc/003-10/arnea.txt @@ -15,7 +15,7 @@ L_Menu: mesn; mesq l("Welcome to the Arena. Select your action"); menu - //l("Create new arena"), L_NewArena, + l("Create new arena"), L_NewArena, l("Join existing arena"), L_JoinArena, rif(is_staff(), l("Debug Information")), L_Debug, l("Information"), L_Info, @@ -34,38 +34,59 @@ L_NewArena: rif(Zeny > .price, l("Rent arena")), -, l("Give Up"), L_Quit; - // Register to HTTable $@ARENAS (or override existing entry) your ID and a password - //.@PASSWORD=(getcharid(0)**1.137); - .@PASSWORD=(gettime(7)*4)+24+getcharid(0)+getcharid(3); - htput($@ARENAS, str(.@PASSWORD), getcharid(0)); + mes ""; + mesn; + mesq l("Please type a password for your Arena, it must be unique."); + input .@user_password$; - // XXX - Important Note - XXX - // map name MUST be only 4 chars long (eg. "abcd") on char instances - .@ID=getcharid(0); - .@MAP$="AREN@"+str(.@ID); + // Leaving blank will close + if (.@user_password$ == "") + close; - // Check if arena was already created - if(has_instance2("AREN@"+.@ID) < 0) { + .@m = htget($@ARENAS, .@user_password$, -1); + if (.@m > 0) { + mes ""; mesn; - mesq l("You already purchased an arena, and password is @@", .@PASSWORD); + mesq l("Sorry, this password was already used on another arena."); next; - goto L_Menu; + /* + mesn; + mesq l("You'll need to think on a new password!"); + next; + mesn; + mesq l("If you don't know what to use, try using the current date or something."); + next; + */ + mesn; + mesq l("Now, let's try again."); + next; + goto L_NewArena; } + + // XXX - Important Note - XXX + // map name MUST be only 4 chars long (eg. "abcd") on char instances + .@ID=.curinst; + .curinst+=1; + htput($@ARENAS, .@user_password$, .@ID); + + .@MAP$="ARENA@"+str(.@ID); + // Create the arena - .@INSTID = instance_create("ARX@"+(.@ID), getcharid(3), IOT_CHAR); + .@INSTID = instance_create("ARX@"+(.@ID), 0, IOT_NONE); .@instanceMapName$ = instance_attachmap("003-13", .@INSTID, 0, .@MAP$); instance_set_timeout(1800, 1800, .@INSTID); instance_init(.@INSTID); + // You are only charged once arena is all set Zeny=Zeny-.price; dispbottom l("Arena created, it can be used for 30 minutes."); - dispbottom l("Room password: @@", .@PASSWORD); + dispbottom l("Room password: @@", .@user_password$); mes ""; mesn; mes l("Arena created, it can be used for 30 minutes."); - mes l("Room password: @@", .@PASSWORD); + mes l("Room password: @@", .@user_password$); if (is_staff()) mes l("Inst @@ Map @@", .@INSTID, .@instanceMapName$); next; @@ -74,24 +95,41 @@ L_NewArena: L_JoinArena: // FIXME + /* warp "003-13", 31, 31; close; + */ mes ""; mesn; mesq l("Okay, to join an arena, you need the unique password. Leave blank if you don't know."); - input .@user_password; - .@m = htget($@ARENAS, str(.@user_password), -1); + input .@user_password$; + .@m = htget($@ARENAS, .@user_password$, -1); if (.@m > 0) { - if(has_instance2("AREN@"+.@m) >= 0) { - warp "AREN@"+str(.@m), 31,31; - } else { + /* + if(has_instance2("ARENA@"+.@m) >= 0) { + warp "ARENA@"+str(.@m), 31,31; + */ + if (.@m < .curinst+2000) { + // Delete the arena entry so this doesn't happens anymore + htput $@ARENAS, .@user_password$, 0; + // Explain this arena has expired mes ""; mesn; mesq l("Sorry, that arena is already closed."); next; mesn; mesq l("All arenas stay open for only 30 minutes after being purchased."); + } else { + closeclientdialog; + // If the arena has expired, this will fail. + // But because dialog was closed, players won't notice anything. + // It won't have any visual effect, just like when you don't use a password. + // However, a debug message will be printed to console. + // If I start seeing spam of this debug message, I'll take appopriate + // measures, including and not limited to permanent ban, including IP ban. + warp "ARENA@"+.@m, 31, 31; + dispbottom l("Good luck!"); } } close; @@ -116,7 +154,7 @@ L_Info: next; mesq l("Guards use it to spar against each other on friendly matches, to see who is stronger."); next; - mesq l("We arranged a small underground room for that, while the Colliseum doesn't get done."); + mesq l("We arranged a small underground room for that, because the Colliseum is too far away."); next; goto L_Menu; @@ -136,10 +174,20 @@ OnInit: .distance = 5; //.alwaysVisible = true; // This is dumb, why Jesusalva put it here? .price=1000; + .curinst=1001; npcsit; // create hashtable $@ARENAS = htnew(); + // Structure: + // Password, Instance Control ID + end; + +// Every half hour, advance curinst in 1000. +// This way, we don't need to use/rely-on hasinstance2() +OnMinute30: +OnMinute60: + .curinst+=1000; end; // Protect bugs by disabling NPC on new year. This NPC have two days off for vacations B-) -- cgit v1.2.3-70-g09d2