diff options
-rw-r--r-- | npc/020-1/misc.txt | 3 | ||||
-rw-r--r-- | npc/functions/riddle.txt | 35 |
2 files changed, 16 insertions, 22 deletions
diff --git a/npc/020-1/misc.txt b/npc/020-1/misc.txt index 9c1188491..6b5a41619 100644 --- a/npc/020-1/misc.txt +++ b/npc/020-1/misc.txt @@ -117,8 +117,7 @@ OnInit: // Description: // Barber. -// LOCATION TODO -020-1,55,65,0 script Camilot NPC_ELVEN_FEMALE_ARMOR_SHOP,{ +020-1,88,76,0 script Camilot NPC_ELVEN_FEMALE_ARMOR_SHOP,{ function setRace { clear; setnpcdialogtitle l("Debug - Modify Race"); diff --git a/npc/functions/riddle.txt b/npc/functions/riddle.txt index fb503e3b3..4ccde67d8 100644 --- a/npc/functions/riddle.txt +++ b/npc/functions/riddle.txt @@ -12,9 +12,9 @@ // TODO: levenshtein(), similar_text(), and maybe even soundex() function script riddlevalidation { - .@answer$ = strtolower(getarg(0)); - .@good$ = strtolower(getarg(1)); - .@good_translated$ = strtolower(getarg(2)); + .@answer$ = strip(strtolower(getarg(0))); + .@good$ = strip(strtolower(getarg(1))); + .@good_translated$ = strip(strtolower(getarg(2))); .@size_answer = getstrlen(.@answer$); .@size_good = getstrlen(.@good$); @@ -23,14 +23,15 @@ function script riddlevalidation { .@max = max(.@size_answer, .@size_good_translated, .@size_good); // Input is too long. - if (.@max > 20) - { + if (.@max > 30) { return false; } - .@size_good *= 70; - .@size_good_translated *= 70; + // if 90% of the word is correct + .@size_good *= 90; + .@size_good_translated *= 90; + freeloop(true); for (.@i = 0; .@i < .@max; .@i++) { .@correct = 0; @@ -38,24 +39,17 @@ function script riddlevalidation { for (.@k = .@k_translated = .@j = .@i; .@j < .@max; .@j++) { - if (charat(.@answer$, .@j) == charat(.@good$, .@k)) - { + if (charat(.@answer$, .@j) == charat(.@good$, .@k)) { .@correct++; .@k++; - } - else - { + } else { .@correct--; } - if (charat(.@answer$, .@j) == - charat(.@good_translated$, .@k_translated)) - { + if (charat(.@answer$, .@j) == charat(.@good_translated$, .@k_translated)) { .@correct_translated++; .@k_translated++; - } - else - { + } else { .@correct_translated--; } } @@ -64,11 +58,12 @@ function script riddlevalidation { .@correct_translated *= 100; if (.@correct >= .@size_good || - .@correct_translated >= .@size_good_translated) - { + .@correct_translated >= .@size_good_translated) { + freeloop(false); return true; } } + freeloop(false); return false; } |