|
@@ -308,6 +308,8 @@ const char* parse_syntax(const char* p);
|
|
|
static int parse_syntax_for_flag = 0;
|
|
|
|
|
|
extern short current_equip_item_index; //for New CARDS Scripts. It contains Inventory Index of the EQUIP_SCRIPT caller item. [Lupus]
|
|
|
+extern unsigned int current_equip_combo_pos;
|
|
|
+
|
|
|
int potion_flag=0; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex]
|
|
|
int potion_hp=0, potion_per_hp=0, potion_sp=0, potion_per_sp=0;
|
|
|
int potion_target=0;
|
|
@@ -4044,14 +4046,24 @@ static int db_script_free_code_sub(DBKey key, DBData *data, va_list ap)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-void script_run_autobonus(const char *autobonus, int id, int pos)
|
|
|
+void script_run_autobonus(const char *autobonus, struct map_session_data *sd, unsigned int pos)
|
|
|
{
|
|
|
struct script_code *script = (struct script_code *)strdb_get(autobonus_db, autobonus);
|
|
|
|
|
|
if( script )
|
|
|
{
|
|
|
- current_equip_item_index = pos;
|
|
|
- run_script(script,0,id,0);
|
|
|
+ int j;
|
|
|
+ ARR_FIND( 0, EQI_MAX, j, sd->equip_index[j] >= 0 && sd->status.inventory[sd->equip_index[j]].equip == pos );
|
|
|
+ if( j < EQI_MAX ) {
|
|
|
+ //Single item autobonus
|
|
|
+ current_equip_item_index = sd->equip_index[j];
|
|
|
+ current_equip_combo_pos = 0;
|
|
|
+ } else {
|
|
|
+ //Combo autobonus
|
|
|
+ current_equip_item_index = -1;
|
|
|
+ current_equip_combo_pos = pos;
|
|
|
+ }
|
|
|
+ run_script(script,0,sd->bl.id,0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -8455,7 +8467,7 @@ BUILDIN_FUNC(bonus)
|
|
|
|
|
|
BUILDIN_FUNC(autobonus)
|
|
|
{
|
|
|
- unsigned int dur;
|
|
|
+ unsigned int dur, pos;
|
|
|
short rate;
|
|
|
short atk_type = 0;
|
|
|
TBL_PC* sd;
|
|
@@ -8465,13 +8477,18 @@ BUILDIN_FUNC(autobonus)
|
|
|
if( sd == NULL )
|
|
|
return 0; // no player attached
|
|
|
|
|
|
- if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip )
|
|
|
+ if (current_equip_combo_pos)
|
|
|
+ pos = current_equip_combo_pos;
|
|
|
+ else
|
|
|
+ pos = sd->status.inventory[current_equip_item_index].equip;
|
|
|
+
|
|
|
+ if((sd->state.autobonus&pos) == pos)
|
|
|
return 0;
|
|
|
|
|
|
rate = script_getnum(st,3);
|
|
|
dur = script_getnum(st,4);
|
|
|
bonus_script = script_getstr(st,2);
|
|
|
- if( !rate || !dur || !bonus_script )
|
|
|
+ if( !rate || !dur || !pos || !bonus_script )
|
|
|
return 0;
|
|
|
|
|
|
if( script_hasdata(st,5) )
|
|
@@ -8480,7 +8497,7 @@ BUILDIN_FUNC(autobonus)
|
|
|
other_script = script_getstr(st,6);
|
|
|
|
|
|
if( pc_addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus),
|
|
|
- bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
|
|
|
+ bonus_script,rate,dur,atk_type,other_script,pos,false) )
|
|
|
{
|
|
|
script_add_autobonus(bonus_script);
|
|
|
if( other_script )
|
|
@@ -8492,7 +8509,7 @@ BUILDIN_FUNC(autobonus)
|
|
|
|
|
|
BUILDIN_FUNC(autobonus2)
|
|
|
{
|
|
|
- unsigned int dur;
|
|
|
+ unsigned int dur, pos;
|
|
|
short rate;
|
|
|
short atk_type = 0;
|
|
|
TBL_PC* sd;
|
|
@@ -8502,13 +8519,18 @@ BUILDIN_FUNC(autobonus2)
|
|
|
if( sd == NULL )
|
|
|
return 0; // no player attached
|
|
|
|
|
|
- if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip )
|
|
|
+ if (current_equip_combo_pos)
|
|
|
+ pos = current_equip_combo_pos;
|
|
|
+ else
|
|
|
+ pos = sd->status.inventory[current_equip_item_index].equip;
|
|
|
+
|
|
|
+ if((sd->state.autobonus&pos) == pos)
|
|
|
return 0;
|
|
|
|
|
|
rate = script_getnum(st,3);
|
|
|
dur = script_getnum(st,4);
|
|
|
bonus_script = script_getstr(st,2);
|
|
|
- if( !rate || !dur || !bonus_script )
|
|
|
+ if( !rate || !dur || !pos || !bonus_script )
|
|
|
return 0;
|
|
|
|
|
|
if( script_hasdata(st,5) )
|
|
@@ -8517,7 +8539,7 @@ BUILDIN_FUNC(autobonus2)
|
|
|
other_script = script_getstr(st,6);
|
|
|
|
|
|
if( pc_addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2),
|
|
|
- bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
|
|
|
+ bonus_script,rate,dur,atk_type,other_script,pos,false) )
|
|
|
{
|
|
|
script_add_autobonus(bonus_script);
|
|
|
if( other_script )
|
|
@@ -8529,7 +8551,7 @@ BUILDIN_FUNC(autobonus2)
|
|
|
|
|
|
BUILDIN_FUNC(autobonus3)
|
|
|
{
|
|
|
- unsigned int dur;
|
|
|
+ unsigned int dur, pos;
|
|
|
short rate,atk_type;
|
|
|
TBL_PC* sd;
|
|
|
const char *bonus_script, *other_script = NULL;
|
|
@@ -8539,7 +8561,12 @@ BUILDIN_FUNC(autobonus3)
|
|
|
if( sd == NULL )
|
|
|
return 0; // no player attached
|
|
|
|
|
|
- if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip )
|
|
|
+ if (current_equip_combo_pos)
|
|
|
+ pos = current_equip_combo_pos;
|
|
|
+ else
|
|
|
+ pos = sd->status.inventory[current_equip_item_index].equip;
|
|
|
+
|
|
|
+ if((sd->state.autobonus&pos) == pos)
|
|
|
return 0;
|
|
|
|
|
|
rate = script_getnum(st,3);
|
|
@@ -8548,14 +8575,14 @@ BUILDIN_FUNC(autobonus3)
|
|
|
get_val(st, data); // Convert into value in case of a variable
|
|
|
atk_type = ( data_isstring(data) ? skill_name2id(script_getstr(st,5)) : script_getnum(st,5) );
|
|
|
bonus_script = script_getstr(st,2);
|
|
|
- if( !rate || !dur || !atk_type || !bonus_script )
|
|
|
+ if( !rate || !dur || !pos || !atk_type || !bonus_script )
|
|
|
return 0;
|
|
|
|
|
|
if( script_hasdata(st,6) )
|
|
|
other_script = script_getstr(st,6);
|
|
|
|
|
|
if( pc_addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3),
|
|
|
- bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,true) )
|
|
|
+ bonus_script,rate,dur,atk_type,other_script,pos,true) )
|
|
|
{
|
|
|
script_add_autobonus(bonus_script);
|
|
|
if( other_script )
|