diff options
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/captcha.txt | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/npc/functions/captcha.txt b/npc/functions/captcha.txt index 3635ff67e..d7dc45aae 100644 --- a/npc/functions/captcha.txt +++ b/npc/functions/captcha.txt @@ -17,6 +17,7 @@ // 2 - Display warnings (@captcha_lastwarning/@captcha_lastwarningt) // 4 - Botter Syndrome enabled // 8 - Disable during events +// 16 - Allow players to treat each other // CaptchName, names the number function script CaptchName { @@ -133,11 +134,97 @@ OnCall: } end; +OnClinic: + // Syndrome disabled, ignore + if (!$CAPTCHA & 4) + end; + // Command disabled, ignore + if (!$CAPTCHA & 16) + end; + // You haven't learned how to treat anyone + if (getq(General_Narrator) < 1 && !getq(CandorQuest_Nurse)) + end; + // You cannot treat anyone + if (array_find($CAPTCHA_BLIST, getcharid(3)) >= 0) + end; + // Verify the target + .@request$ = ""; + .@request$ += implode(.@atcmd_parameters$, " "); + // TODO: Quest - Treat a NPC with Botter's Syndrome (Trainer?) + // Player is not attached or is yourself + .@id = getcharid(3, .@request$); + if (!.@id) { + Exception("Player not found.", RB_ISFATAL|RB_DISPBOTTOM); + } else if (.@id == getcharid(3)) { + Exception("You cannot treat yourself.", RB_ISFATAL|RB_DISPBOTTOM); + } + // You already treated someone recently + if (CHAREG_CLEANUP+300 > gettimetick(2)) + Exception(sprintf("You need to be online for longer than %d minute(s) to treat someone.", 5), RB_ISFATAL|RB_DISPBOTTOM); + if (@treatcaptcha+300 > gettimetick(2)) + Exception(sprintf("You need to wait %s before treat someone else again.", FuzzyTime(@treatcaptcha+300)), RB_ISFATAL|RB_DISPBOTTOM); + // Treatment confirmation + mes ".:: " + l("Treatment") + " ::."; + mes l("Botter Syndrome is a common ailment which, while it mostly affect bots, even regular adventurers and NPCs may contract."); + mes l("If you believe \"%s\" is ##Bnot##b botting, then you may treat them yourself."); + mes ""; + mes l("- Treating a nearby player will almost always succeed."); + mes l("- Treating a player in the same map has <70%% chance of succeeding."); + mes l("- Treating a player in another map has <30%% chance of succeeding."); + mes l("- Treating a bot may result in the Alliance confiscating your treatment kit."); + mes l("- Treating yourself via an alt may also result in a %s for one of your accounts.", b(l("permanent ban"))); + mes ""; + mes l("It takes %d minute(s) to treat someone else after this.", 5); + next; + mesc ("Do you want to treat \"%s\"?", b(.@request$)), 1; + if (askyesno() == ASK_NO) { + closeclientdialog; + end; + } + // Regardless of whatever happens now, the treatment was attempted + .@m1$ = getmap(); + .@caster = getcharid(3); + .@chance = 30; + .@benef$ = strcharinfo(0); + @treatcaptcha = gettimetick(2); + closeclientdialog; + // Attach the one you intend to heal + if (attachplayer(.@id)) { + // Not infected, so do nothing + if (!getstatus(SC_BOTTER_SYNDROME)) + end; + // Same map check + getmapxy(.@m$, .@x, .@y, 0); + if (.@m$ == .@m1$) { + .@chance = 70; + // Check if caster and treated are visible + .@c=getunits(BL_PC, .@pcs, MAX_CYCLE_PC, .@m$, .@x-14, .@y-14, .@x+14, .@y+14); + for (.@i = 0; .@i < .@c; .@i++) { + if (.@pcs[.@i] == .@caster) { + .@chance = 100; + break; + } // Caster loop + } // for loop + } // Map loop + // The chance is further modified by how intense the syndrome is + // Every 5% effect steals 1% of treatment chance + .@chance -= limit(0, getstatus(SC_BOTTER_SYNDROME, 1) / 5, 25); + // Now we have .@chance, so decide if treatment worked + if (rand2(100) < .@chance) { + sc_end SC_BOTTER_SYNDROME; + dispbottom l("Your %s was treated by %s.", b(l("Botter's Syndrome")),.@benef$); + } else { + dispbottom l("%s tried to treat your syndrome, but was NOT successful.", .@benef$); + } + } // attachplayer() + end; + OnInit: .thr=180; // Seconds to reply .cooldown=3600; // Captcha Immunity .antiflood=18; // Seconds between captcha failed attempts bindatcmd "captcha", "@captcha::OnCall", 0, 0, 0; + bindatcmd "treat", "@captcha::OnClinic", 0, 0, 0; initnpctimer; end; |