diff options
-rw-r--r-- | Changelog-Trunk.txt | 7 | ||||
-rw-r--r-- | npc/Changelog.txt | 1 | ||||
-rw-r--r-- | npc/sample/npc_test_setitemx.txt | 70 | ||||
-rw-r--r-- | src/map/itemdb.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 74 |
5 files changed, 146 insertions, 8 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index ab859ec1b..c6c6a75fd 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,13 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/03/02 + * Added new script function: setiteminfo. Now you can make custom items [Lupus] + - Updated script function setitemscript(itemID,script,WhichScript) + now u can set one of 3 item scripts: use/update, equip, unequip + But it works only if the original item had 3 non empty scriptsin ITEM_DB + can't fix this issue yet + - Check npc/sample/npc_test_setitemx.txt as example of setiteminfo & setitemscript 2007/03/01 * Fixed the definition of warpwaitingpc so that it allows an optional argument (number of people to warp). diff --git a/npc/Changelog.txt b/npc/Changelog.txt index 248e57b60..b62ed0652 100644 --- a/npc/Changelog.txt +++ b/npc/Changelog.txt @@ -28,6 +28,7 @@ Date Added ====== 2007/03/01 * The Sign: Fixed possible exploit, thanks to happylight [Lupus] + - Added npc/sample/npc_test_setitemx.txt 2007/02/28 * Fixes to Merchant/Smith skill quests according to ragnainfo wiki [DracoRPG] - Added missing 1 Banana Juice requirement to Cart Revolution quest diff --git a/npc/sample/npc_test_setitemx.txt b/npc/sample/npc_test_setitemx.txt new file mode 100644 index 000000000..1e8d021e4 --- /dev/null +++ b/npc/sample/npc_test_setitemx.txt @@ -0,0 +1,70 @@ +//by Lupus.
+// SVN TRUNK 9940+ only
+
+//setiteminfo(itemID,n,Value), where n
+// 0 value_buy;
+// 1 value_sell;
+// 2 type;
+// 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc..
+// if = 0, then monsters don't drop it at all (rare or a quest item)
+// if = 10000, then this item is sold in NPC shops only
+// 4 sex;
+// 5 equip;
+// 6 weight;
+// 7 atk;
+// 8 def;
+// 9 range;
+// 10 slot;
+// 11 look;
+// 12 elv;
+// 13 wlv;
+
+prontera.gat,164,161,5 script Lupus 1013,{
+ menu "Make Knife[3] Edible",M_1,
+ "Make Apple Equippable",M_2,
+ "Edible Knife = Full SP",M_3,
+ "Knife = Weapon + 3 Notes",M_4;
+ close;
+
+M_1:
+ //WORKS!
+ mes "Ok. We Made Knife[3] Edible";
+ setiteminfo(1201,2,0); //type = 0 : potion
+ setitemscript(1201,"{dispbottom \"* You used Knife[3]\";}");
+ close;
+
+M_2:
+ //WORKS!
+ mes "Ok. We Made Apple Equippable";
+ //item type -> headgear
+ setiteminfo(512,2,5); //type = 5
+ //where to equip to
+ setiteminfo(512,5,512); //equip = 512
+ //set as headgear location
+ setiteminfo(512,11,256); //loc = 256
+ //set Headgear Sprite ID
+ setiteminfo(512,14,85); //view id = 85
+
+ setitemscript(512,"{dispbottom \"* Other item's changed\";}",0);
+ setitemscript(512,"{dispbottom \"* Equipped\";}",1);
+ setitemscript(512,"{dispbottom \"* Unequipped\";}",2);
+ close;
+
+M_3:
+ //WORKS!
+ mes "Ok. Now Edible Knife[3] restores your SP";
+ setitemscript(1201,2,0);
+ setitemscript(1201,"{dispbottom \"* You ate Knife[3] + Full SP\"; percentheal 0,100;}");
+ close;
+
+M_4:
+ //WORKS!
+ mes "Ok. We Made Knife... a weapon. But added 3 notes.";
+ setiteminfo(1201,2,4); //type = 4 : weapon again
+ setitemscript(1201,"{dispbottom \"* 1 Used\";}",0);
+ setitemscript(1201,"{dispbottom \"* 2 Equipped\";}",1);
+ setitemscript(1201,"{dispbottom \"* 3 Unequipped\";}",2);
+ close;
+
+}
+
diff --git a/src/map/itemdb.h b/src/map/itemdb.h index e8f1a07ef..55b02ab55 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -51,6 +51,7 @@ struct item_data { int look; int elv; int wlv; + int view_id; //Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command // some script commands should be revised as well... unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) @@ -73,7 +74,6 @@ struct item_data { unsigned autoequip: 1; } flag; short gm_lv_trade_override; //GM-level to override trade_restriction - int view_id; }; struct item_group { diff --git a/src/map/script.c b/src/map/script.c index 62a656e01..09f84afbd 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3793,6 +3793,7 @@ BUILDIN_FUNC(charisalpha);//isalpha [valaris] BUILDIN_FUNC(fakenpcname); // [Lance] BUILDIN_FUNC(compare); // Lordalfa, to bring strstr to Scripting Engine BUILDIN_FUNC(getiteminfo); //[Lupus] returns Items Buy / sell Price, etc info +BUILDIN_FUNC(setiteminfo); //[Lupus] set Items Buy / sell Price, etc info BUILDIN_FUNC(getequipcardid); //[Lupus] returns card id from quipped item card slot N // [zBuffer] List of mathematics commands ---> BUILDIN_FUNC(sqrt); @@ -4130,6 +4131,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(fakenpcname,"ssi"), // [Lance] BUILDIN_DEF(compare,"ss"), // Lordalfa - To bring strstr to scripting Engine. BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info + BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info BUILDIN_DEF(getequipcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item // [zBuffer] List of mathematics commands ---> BUILDIN_DEF(sqrt,"i"), @@ -4151,7 +4153,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(autoequip,"ii"), BUILDIN_DEF(setbattleflag,"ss"), BUILDIN_DEF(getbattleflag,"s"), - BUILDIN_DEF(setitemscript,"is"), //Set NEW item bonus script. Lupus + BUILDIN_DEF(setitemscript,"is*"), //Set NEW item bonus script. Lupus BUILDIN_DEF(disguise,"i"), //disguise player. Lupus BUILDIN_DEF(undisguise,"*"), //undisguise player. Lupus BUILDIN_DEF(getmonsterinfo,"ii"), //Lupus @@ -9882,6 +9884,7 @@ BUILDIN_FUNC(getitemslots) 11 look; 12 elv; 13 wlv; + 14 view id *------------------------------------------ */ BUILDIN_FUNC(getiteminfo) @@ -9903,6 +9906,50 @@ BUILDIN_FUNC(getiteminfo) } /*========================================== + * Set some values of an item [Lupus] + * Price, Weight, etc... + setiteminfo(itemID,n,Value), where n + 0 value_buy; + 1 value_sell; + 2 type; + 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc.. + if = 0, then monsters don't drop it at all (rare or a quest item) + if = 10000, then this item is sold in NPC shops only + 4 sex; + 5 equip; + 6 weight; + 7 atk; + 8 def; + 9 range; + 10 slot; + 11 look; + 12 elv; + 13 wlv; + 14 view id + * Returns Value or -1 if the wrong field's been set + *------------------------------------------ + */ +BUILDIN_FUNC(setiteminfo) +{ + int item_id,n,value; + int *item_arr; + struct item_data *i_data; + + item_id = conv_num(st,& (st->stack->stack_data[st->start+2])); + n = conv_num(st,& (st->stack->stack_data[st->start+3])); + value = conv_num(st,& (st->stack->stack_data[st->start+4])); + i_data = itemdb_exists(item_id); + + if (i_data && n>=0 && n<14) { + item_arr = (int*)&i_data->value_buy; + item_arr[n] = value; + push_val(st->stack,C_INT,value); + } else + push_val(st->stack,C_INT,-1); + return 0; +} + +/*========================================== * Returns value from equipped item slot n [Lupus] getequipcardid(num,slot) where @@ -12133,23 +12180,36 @@ BUILDIN_FUNC(npcshopattach) /*========================================== * Returns some values of an item [Lupus] * Price, Weight, etc... - setiteminfo(itemID,"{new item bonus script}"); + setitemscript(itemID,"{new item bonus script}",[n]); + Where n: + 0 - script + 1 - Equip script + 2 - Unequip script *------------------------------------------ */ BUILDIN_FUNC(setitemscript) { - int item_id; + int item_id,n=0; char *script; struct item_data *i_data; + struct script_code *dstscript; item_id = conv_num(st,& (st->stack->stack_data[st->start+2])); script = conv_str(st,& (st->stack->stack_data[st->start+3])); + if( st->end>st->start+4 ) + n=conv_num(st,& (st->stack->stack_data[st->start+4])); i_data = itemdb_exists(item_id); - if (i_data && script!=NULL && script[0]=='{') { - if(i_data->script!=NULL) - script_free_code(i_data->script); - i_data->script = parse_script(script, "script_setitemscript", 0, 0); + if (i_data && script!=NULL && script[0]=='{' && n<3) { + if(n==2) + dstscript = i_data->unequip_script; + else if(n==1) + dstscript = i_data->equip_script; + else + dstscript = i_data->script; + if(dstscript) + script_free_code(dstscript); + dstscript = parse_script(script, "script_setitemscript", 0, 0); push_val(st->stack,C_INT,1); } else push_val(st->stack,C_INT,0); |