From 6859bee5720898aa7fa2e65f460fc795fa6bbf7b Mon Sep 17 00:00:00 2001 From: Lupus Date: Tue, 8 Mar 2005 21:23:51 +0000 Subject: fixed script command 'isequippedcnt' added new script command for new cards 'cardscnt' (to fix cards exploits! should check old cards, too) fixed @jail / @unjail SAVE POINT abuse git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1217 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/atcommand.c | 4 ++-- src/map/script.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++------- src/map/status.c | 8 +++++-- 3 files changed, 61 insertions(+), 12 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 9fea47dee..fdd3143a5 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6422,8 +6422,8 @@ int atcommand_unjail( if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) { clif_displaymessage(fd, msg_table[119]); // This player is not in jails. return -1; - } else if (pc_setpos(pl_sd, "prontera.gat", 156, 191, 3) == 0) { - pc_setsavepoint(pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera + } else if (pc_setpos(pl_sd, "prontera.gat", 0, 0, 3) == 0) { //old coords: 156,191 + pc_setsavepoint(pl_sd, "prontera.gat", 0, 0); // Save char respawn point in Prontera clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera. } else { diff --git a/src/map/script.c b/src/map/script.c index 35964f3bc..961c4b5e5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -89,6 +89,8 @@ struct Script_Config script_config; static int parse_cmd_if=0; static int parse_cmd; +extern int current_equip_item_index; //for New CARS Scripts. It contains Inventory Index of the EQUIP_SCRIPT caller item. [Lupus] + /*========================================== * ローカルプロトタイプ宣言 (必要な物のみ) *------------------------------------------ @@ -308,6 +310,7 @@ int buildin_isnight(struct script_state *st); // [celest] int buildin_isday(struct script_state *st); // [celest] int buildin_isequipped(struct script_state *st); // [celest] int buildin_isequippedcnt(struct script_state *st); // [celest] +int buildin_cardscnt(struct script_state *st); // [Lupus] int buildin_getusersname(struct script_state *st); //jA commands added [Lupus] int buildin_dispbottom(struct script_state *st); int buildin_recovery(struct script_state *st); @@ -554,6 +557,7 @@ struct { {buildin_isday,"isday",""}, // check whether it is day time [Celest] {buildin_isequipped,"isequipped","i*"}, // check whether another item/card has been equipped [Celest] {buildin_isequippedcnt,"isequippedcnt","i*"}, // check how many items/cards are being equipped [Celest] + {buildin_cardscnt,"cardscnt","i*"}, // check how many items/cards are being equipped in the same arm [Lupus] #ifdef PCRE_SUPPORT {buildin_defpattern, "defpattern", "iss"}, // Define pattern to listen for [MouseJstr] {buildin_activatepset, "activatepset", "i"}, // Activate a pattern set [MouseJstr] @@ -6930,7 +6934,7 @@ int buildin_isequippedcnt(struct script_state *st) continue; for (j=0; j<10; j++) { - int index, type, flag = 0; + int index, type; index = sd->equip_index[j]; if(index < 0) continue; if(j == 9 && sd->equip_index[8] == index) continue; @@ -6941,22 +6945,17 @@ int buildin_isequippedcnt(struct script_state *st) if(sd->inventory_data[index]) { if (type == 4 || type == 5) { if (sd->inventory_data[index]->nameid == id) - flag = 1; + ret++; //[Lupus] } else if (type == 6) { for(k=0; kinventory_data[index]->slot; k++) { if (sd->status.inventory[index].card[0]!=0x00ff && sd->status.inventory[index].card[0]!=0x00fe && sd->status.inventory[index].card[0]!=(short)0xff00 && sd->status.inventory[index].card[k] == id) { - flag = 1; - break; + ret++; //[Lupus] } } } - if (flag) { - ret++; - break; - } } } } @@ -6964,6 +6963,52 @@ int buildin_isequippedcnt(struct script_state *st) push_val(st->stack,C_INT,ret); return 0; } + +/*================================================ + * Check how many given inserted cards in the CURRENT + * weapon - used for 2/15's cards patch [Lupus] + *------------------------------------------------ + */ +int buildin_cardscnt(struct script_state *st) +{ + struct map_session_data *sd; + int i, k, id = 1; + int ret = 0; + + sd = script_rid2sd(st); + + for (i=0; id!=0; i++) { + FETCH (i+2, id) else id = 0; + if (id <= 0) + continue; + + int index, type; + index = current_equip_item_index; //we get CURRENT WEAPON inventory index from status.c [Lupus] + if(index < 0) continue; + + type = itemdb_type(id); + + if(sd->inventory_data[index]) { + if (type == 4 || type == 5) { + if (sd->inventory_data[index]->nameid == id) + ret++; + } else if (type == 6) { + for(k=0; kinventory_data[index]->slot; k++) { + if (sd->status.inventory[index].card[0]!=0x00ff && + sd->status.inventory[index].card[0]!=0x00fe && + sd->status.inventory[index].card[0]!=(short)0xff00 && + sd->status.inventory[index].card[k] == id) { + ret++; + } + } + } + } + } + push_val(st->stack,C_INT,ret); +// push_val(st->stack,C_INT,current_equip_item_index); + return 0; +} + // // 実行部main // diff --git a/src/map/status.c b/src/map/status.c index f81952518..de2efce5a 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -268,6 +268,10 @@ int percentrefinery[5][10]; // static int atkmods[3][20]; // 武器ATKサイズ修正(size_fix.txt) static char job_bonus[3][MAX_PC_CLASS][MAX_LEVEL]; +int current_equip_item_index; //Contains inventory index of an equipped item. To pass it into the EQUP_SCRIPT [Lupus] +//we need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only +//to avoid cards exploits + /*========================================== * 精錬ボーナス *------------------------------------------ @@ -537,7 +541,7 @@ int status_calc_pc(struct map_session_data* sd,int first) } for(i=0;i<10;i++) { - index = sd->equip_index[i]; + current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] if(index < 0) continue; if(i == 9 && sd->equip_index[8] == index) @@ -594,7 +598,7 @@ int status_calc_pc(struct map_session_data* sd,int first) // ?備品によるステ?タス?化はここで?行 for(i=0;i<10;i++) { - index = sd->equip_index[i]; + current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] if(index < 0) continue; if(i == 9 && sd->equip_index[8] == index) -- cgit v1.2.3-70-g09d2