From bd4e344a476439af984995540cb3d037752981c8 Mon Sep 17 00:00:00 2001 From: euphyy Date: Fri, 23 Nov 2012 03:22:28 +0000 Subject: * Added Guillotine Cross job quest, again thanks to Muad_Dib! (bugreport:5834) * Follow-up r16941: added documentation. * Updated WOE Controller script to v1.4, which modifies LoadEvent mapflag settings for easier cross-compatibility and standardizes script format. * Minor tweaks here and there. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16947 54d463be-8e91-2dee-dedb-b68131a5f0ec --- doc/sample/npc_test_checkweight.txt | 164 ++++++++++++++++++++++++++++++++++++ doc/sample/npc_test_chekweight.txt | 164 ------------------------------------ doc/script_commands.txt | 32 +++---- 3 files changed, 181 insertions(+), 179 deletions(-) create mode 100644 doc/sample/npc_test_checkweight.txt delete mode 100644 doc/sample/npc_test_chekweight.txt (limited to 'doc') diff --git a/doc/sample/npc_test_checkweight.txt b/doc/sample/npc_test_checkweight.txt new file mode 100644 index 000000000..195ff856e --- /dev/null +++ b/doc/sample/npc_test_checkweight.txt @@ -0,0 +1,164 @@ +//===== rAthena Script ======================================= +//= Sample: CheckWeight +//===== By: ================================================== +//= rAthena Dev Team +//===== Current Version: ===================================== +//= 20121113 +//===== Description: ========================================= +//= Demonstrates 'checkweight' command. +//============================================================ + +prontera,161,181,6 script ChkSpace 763,{ + +function ChkResult; +function FinalReport; + +L_RESET: + resetlvl(1); + getinventorylist; + for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){ + delitem(@inventorylist_id[.@i],@inventorylist_amount[.@i]); //clear inventory + } + + +L_TEST1: //basic backward chk + .@testid = 0; + .@succes = 0; + .@ret = checkweight(512,10); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success + .@ret = checkweight("Apple",10); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success + .@ret = checkweight(6320,33000); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure too many item amount item weight=0 + .@ret = checkweight("Premium_Reset_Stone",33000); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure too many item amount + .@ret = checkweight(717,500); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success weight based on max weight=2030 + .@ret = checkweight(717,1000); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure weight based on max weight=2030 + .@ret = checkweight(2794,100); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success + .@ret = checkweight(2794,101); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure (with MAX_INVENTORY = 100) + .@ret = checkweight(-1,1); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide item id + .@ret = checkweight(512,0); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide amount + + debugmes "End backward test"; + FinalReport(.@testid,.@succes); + + +L_TEST2: //update using list test + .@testid = 0; + .@succes = 0; + + .@ret = checkweight(512,10,513,10); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success + .@ret = checkweight("Apple",10,"Banana",10); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success + .@ret = checkweight(512,80,513,33000); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure + .@ret = checkweight("Apple",80,"Banana",33000); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure too many item amount + .@ret = checkweight("Apple",10,"Banana",21,512); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalid nb of args + .@ret = checkweight(717,500,716,100); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be succes weight 1800/2030 + .@ret = checkweight(717,500,716,500); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure weight 3000/2030 + .@ret = checkweight(2794,95,2795,5); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success + .@ret = checkweight(2794,95,2795,10); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure (with MAX_INVENTORY = 100) + .@ret = checkweight(512,1,-1,1); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide item id + .@ret = checkweight(512,1,513,0); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide amount + .@ret = checkweight(6320,31000,6320,2000); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure overamount inventory + .@ret = checkweight(512,1,513,1,514,1,515,1); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be sucess + + debugmes "End update by list tests"; + FinalReport(.@testid,.@succes); + +L_TEST3: //update using array tests + .@testid = 0; + .@succes = 0; + + setarray .@item[0], 512,513,514,515; + setarray .@count[0], 1,5,9,12; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be sucess + cleararray .@item[0], 0, 4; + cleararray .@count[0], 0, 4; + setarray .@item[0], 512,513,514,515; + setarray .@count[0], 1,5,-1,12; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, invalide amout + cleararray .@item[0], 0, 4; + cleararray .@count[0], 0, 4; + setarray .@item[0], 512,513,514,-1; + setarray .@count[0], 1,5,15,12; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, invalide id + cleararray .@item[0], 0, 4; + cleararray .@count[0], 0, 4; + setarray .@item[0], 717,715,716,714; + setarray .@count[0], 300,300,300,300; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, total by weight + cleararray .@item[0], 0, 4; + cleararray .@count[0], 0, 4; + setarray .@item[0], 6320,6320; + setarray .@count[0], 31000,2000; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, total by weight + cleararray .@item[0], 0, 2; + cleararray .@count[0], 0, 2; + setarray .@item[0], 2794,2795; + setarray .@count[0], 95,5; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success + setarray .@count[0], 95,10; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure overamount item + cleararray .@item[0], 0, 2; + cleararray .@count[0], 0, 2; + setarray .@item[0], 6320,6320,512; + setarray .@count[0], 1,3; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, size mistmatch + cleararray .@item[0], 0, 3; + cleararray .@count[0], 0, 2; + setarray .@item[0], 6320,6320; + setarray .@count[0], 1,3,5; + .@ret = checkweight2(.@item,.@count); + set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, size mistmatch + + + debugmes "End update by array tests"; + FinalReport(.@testid,.@succes); + +L_FINAL: + end; + + + function ChkResult { + .@tid = getarg(0); + .@expected = getarg(1); + .@ret = getarg(2); + .@sucess = (.@ret==.@expected); + debugmes "Test "+.@tid+" = "+(.@sucess?"Sucess":"Fail"); + return .@sucess; + } + + function FinalReport { + .@tdone = getarg(0); + .@succes = getarg(1); + debugmes "Results = Pass : "+.@succes+"/"+.@tdone+" Fails : "+(.@tdone-.@succes)+"/"+.@tdone; + if(.@succes != .@tdone) { debugmes "Some failure as occured, enable chkresult print to found out"; } + return; + } +} diff --git a/doc/sample/npc_test_chekweight.txt b/doc/sample/npc_test_chekweight.txt deleted file mode 100644 index 1f4d1d2d8..000000000 --- a/doc/sample/npc_test_chekweight.txt +++ /dev/null @@ -1,164 +0,0 @@ -//===== rAthena Script ======================================= -//= Sample: ChekWeight -//===== By: ================================================== -//= rAthena Dev Team -//===== Current Version: ===================================== -//= 20121113 -//===== Description: ========================================= -//= Demonstrates ChekWeight commands. -//============================================================ - -new_1-1,56,106,5 script ChkSpace 763,{ - -function ChkResult; -function FinalReport; - -L_RESET: - resetlvl(1); - getinventorylist; - for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){ - delitem(@inventorylist_id[.@i],@inventorylist_amount[.@i]); //clear inventory - } - - -L_TEST1: //basic backward chk - .@testid = 0; - .@succes = 0; - .@ret = checkweight(512,10); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success - .@ret = checkweight("Apple",10); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success - .@ret = checkweight(6320,33000); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure too many item amount item weight=0 - .@ret = checkweight("Premium_Reset_Stone",33000); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure too many item amount - .@ret = checkweight(717,500); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success weight based on max weight=2030 - .@ret = checkweight(717,1000); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure weight based on max weight=2030 - .@ret = checkweight(2794,100); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success - .@ret = checkweight(2794,101); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure (with MAX_INVENTORY = 100) - .@ret = checkweight(-1,1); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide item id - .@ret = checkweight(512,0); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide amount - - debugmes "End backward test"; - FinalReport(.@testid,.@succes); - - -L_TEST2: //update using list test - .@testid = 0; - .@succes = 0; - - .@ret = checkweight(512,10,513,10); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success - .@ret = checkweight("Apple",10,"Banana",10); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success - .@ret = checkweight(512,80,513,33000); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure - .@ret = checkweight("Apple",80,"Banana",33000); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure too many item amount - .@ret = checkweight("Apple",10,"Banana",21,512); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalid nb of args - .@ret = checkweight(717,500,716,100); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be succes weight 1800/2030 - .@ret = checkweight(717,500,716,500); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure weight 3000/2030 - .@ret = checkweight(2794,95,2795,5); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success - .@ret = checkweight(2794,95,2795,10); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure (with MAX_INVENTORY = 100) - .@ret = checkweight(512,1,-1,1); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide item id - .@ret = checkweight(512,1,513,0); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure invalide amount - .@ret = checkweight(6320,31000,6320,2000); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure overamount inventory - .@ret = checkweight(512,1,513,1,514,1,515,1); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be sucess - - debugmes "End update by list tests"; - FinalReport(.@testid,.@succes); - -L_TEST3: //update using array tests - .@testid = 0; - .@succes = 0; - - setarray .@item[0], 512,513,514,515; - setarray .@count[0], 1,5,9,12; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be sucess - cleararray .@item[0], 0, 4; - cleararray .@count[0], 0, 4; - setarray .@item[0], 512,513,514,515; - setarray .@count[0], 1,5,-1,12; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, invalide amout - cleararray .@item[0], 0, 4; - cleararray .@count[0], 0, 4; - setarray .@item[0], 512,513,514,-1; - setarray .@count[0], 1,5,15,12; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, invalide id - cleararray .@item[0], 0, 4; - cleararray .@count[0], 0, 4; - setarray .@item[0], 717,715,716,714; - setarray .@count[0], 300,300,300,300; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, total by weight - cleararray .@item[0], 0, 4; - cleararray .@count[0], 0, 4; - setarray .@item[0], 6320,6320; - setarray .@count[0], 31000,2000; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, total by weight - cleararray .@item[0], 0, 2; - cleararray .@count[0], 0, 2; - setarray .@item[0], 2794,2795; - setarray .@count[0], 95,5; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success - setarray .@count[0], 95,10; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure overamount item - cleararray .@item[0], 0, 2; - cleararray .@count[0], 0, 2; - setarray .@item[0], 6320,6320,512; - setarray .@count[0], 1,3; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, size mistmatch - cleararray .@item[0], 0, 3; - cleararray .@count[0], 0, 2; - setarray .@item[0], 6320,6320; - setarray .@count[0], 1,3,5; - .@ret = checkweight2(.@item,.@count); - set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, size mistmatch - - - debugmes "End update by array tests"; - FinalReport(.@testid,.@succes); - -L_FINAL: - end; - - - function ChkResult { - .@tid = getarg(0); - .@expected = getarg(1); - .@ret = getarg(2); - .@sucess = (.@ret==.@expected); - debugmes "Test "+.@tid+" = "+(.@sucess?"Sucess":"Fail"); - return .@sucess; - } - - function FinalReport { - .@tdone = getarg(0); - .@succes = getarg(1); - debugmes "Results = Pass : "+.@succes+"/"+.@tdone+" Fails : "+(.@tdone-.@succes)+"/"+.@tdone; - if(.@succes != .@tdone) { debugmes "Some failure as occured, enable chkresult print to found out"; } - return; - } -} diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 7d7124f34..2a7d4329b 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3316,39 +3316,41 @@ aren't. You can also pass the char_id to check for both account and char id. --------------------------------------- -*checkweight(,) -*checkweight("",) +*checkweight(,{,,,,,...}); +*checkweight("",{,"",,"",,...}); +*checkweight2(,); -This function will compute and return 1 if the total weight of a specified +These functions will compute and return 1 if the total weight of the specified number of specific items does not exceed the invoking character's carrying capacity, and 0 otherwise. It is important to see if a player can carry the items you expect to give them, failing to do that may open your script up to abuse or create some very unfair errors. -This function, in addition to checking to see if the player is capable of -holding a set amount of items, also ensures the player has room in their +The second function will check an array of items and amounts, and also +returns 1 on success and 0 on failure. + +The functions, in addition to checking to see if the player is capable of +holding a set amount of items, also ensure the player has room in their inventory for the item(s) they will be receiving. Like 'getitem', this function will also accept an 'english name' from the database as an argument. +Example 1: + if (checkweight(512,10)) { getitem 512,10; } else { - mes "Sorry you cannot hold this amount of apples"; + mes "Sorry, you cannot hold this amount of apples!"; } - close; -Or to put this another way: +Example 2: - if (checkweight("Apple",10) == 0) { - mes "Sorry you cannot hold this amount of apples"; - } else { - getitem 512,10; + setarray .@item[0],512,513,514; + setarray .@amount[0],10,5,5; + if (!checkweight(.@item,.@amount)) { + mes "Sorry, you cannot hold this amount of fruit!"; } - close; - -Both examples have the same effect. --------------------------------------- -- cgit v1.2.3-70-g09d2