|
@@ -1984,6 +1984,8 @@ int pc_disguise(struct map_session_data *sd, int class_)
|
|
#define PC_BONUS_CHK_CLASS(cl,bonus) { if (!CHK_CLASS((cl))) { PC_BONUS_SHOW_ERROR((bonus),Class,(cl)); }}
|
|
#define PC_BONUS_CHK_CLASS(cl,bonus) { if (!CHK_CLASS((cl))) { PC_BONUS_SHOW_ERROR((bonus),Class,(cl)); }}
|
|
/// Check for valid Size, break & show error message if invalid Size
|
|
/// Check for valid Size, break & show error message if invalid Size
|
|
#define PC_BONUS_CHK_SIZE(sz,bonus) { if (!CHK_MOBSIZE((sz))) { PC_BONUS_SHOW_ERROR((bonus),Size,(sz)); }}
|
|
#define PC_BONUS_CHK_SIZE(sz,bonus) { if (!CHK_MOBSIZE((sz))) { PC_BONUS_SHOW_ERROR((bonus),Size,(sz)); }}
|
|
|
|
+/// Check for valid SC, break & show error message if invalid SC
|
|
|
|
+#define PC_BONUS_CHK_SC(sc,bonus) { if ((sc) <= SC_NONE || (sc) >= SC_MAX) { PC_BONUS_SHOW_ERROR((bonus),Effect,(sc)); }}
|
|
|
|
|
|
static void pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short flag, unsigned short card_id)
|
|
static void pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short flag, unsigned short card_id)
|
|
{
|
|
{
|
|
@@ -2046,21 +2048,35 @@ static void pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
-static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag)
|
|
|
|
|
|
+/**
|
|
|
|
+ * Add inflict effect bonus for player while attacking/atatcked
|
|
|
|
+ * @param effect Effect array
|
|
|
|
+ * @param max Max array
|
|
|
|
+ * @param sc SC/Effect type
|
|
|
|
+ * @param rate Success chance
|
|
|
|
+ * @param arrow_rate success chance if bonus comes from arrow-type item
|
|
|
|
+ * @param flag Target flag
|
|
|
|
+ * @param duration Duration. If 0 use default duration lookup for associated skill with level 7
|
|
|
|
+ **/
|
|
|
|
+static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type sc, short rate, short arrow_rate, unsigned char flag, unsigned int duration)
|
|
{
|
|
{
|
|
uint16 i;
|
|
uint16 i;
|
|
|
|
+
|
|
if (!(flag&(ATF_SHORT|ATF_LONG)))
|
|
if (!(flag&(ATF_SHORT|ATF_LONG)))
|
|
- flag|=ATF_SHORT|ATF_LONG; //Default range: both
|
|
|
|
|
|
+ flag |= ATF_SHORT|ATF_LONG; //Default range: both
|
|
if (!(flag&(ATF_TARGET|ATF_SELF)))
|
|
if (!(flag&(ATF_TARGET|ATF_SELF)))
|
|
- flag|=ATF_TARGET; //Default target: enemy.
|
|
|
|
|
|
+ flag |= ATF_TARGET; //Default target: enemy.
|
|
if (!(flag&(ATF_WEAPON|ATF_MAGIC|ATF_MISC)))
|
|
if (!(flag&(ATF_WEAPON|ATF_MAGIC|ATF_MISC)))
|
|
- flag|=ATF_WEAPON; //Default type: weapon.
|
|
|
|
|
|
+ flag |= ATF_WEAPON; //Default type: weapon.
|
|
|
|
+
|
|
|
|
+ if (!duration)
|
|
|
|
+ duration = skill_get_time2(status_sc2skill(sc),7);
|
|
|
|
|
|
for (i = 0; i < max && effect[i].flag; i++) {
|
|
for (i = 0; i < max && effect[i].flag; i++) {
|
|
- if (effect[i].id == id && effect[i].flag == flag)
|
|
|
|
- {
|
|
|
|
|
|
+ if (effect[i].sc == sc && effect[i].flag == flag) {
|
|
effect[i].rate += rate;
|
|
effect[i].rate += rate;
|
|
effect[i].arrow_rate += arrow_rate;
|
|
effect[i].arrow_rate += arrow_rate;
|
|
|
|
+ effect[i].duration = max(effect[i].duration, duration);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2068,20 +2084,33 @@ static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id
|
|
ShowWarning("pc_bonus_addeff: Reached max (%d) number of add effects per character!\n", max);
|
|
ShowWarning("pc_bonus_addeff: Reached max (%d) number of add effects per character!\n", max);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- effect[i].id = id;
|
|
|
|
|
|
+ effect[i].sc = sc;
|
|
effect[i].rate = rate;
|
|
effect[i].rate = rate;
|
|
effect[i].arrow_rate = arrow_rate;
|
|
effect[i].arrow_rate = arrow_rate;
|
|
effect[i].flag = flag;
|
|
effect[i].flag = flag;
|
|
|
|
+ effect[i].duration = duration;
|
|
}
|
|
}
|
|
|
|
|
|
-static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill, unsigned char target)
|
|
|
|
|
|
+/**
|
|
|
|
+ * Add inflict effect bonus for player while attacking using skill
|
|
|
|
+ * @param effect Effect array
|
|
|
|
+ * @param max Max array
|
|
|
|
+ * @param sc SC/Effect type
|
|
|
|
+ * @param rate Success chance
|
|
|
|
+ * @param flag Target flag
|
|
|
|
+ * @param duration Duration. If 0 use default duration lookup for associated skill with level 7
|
|
|
|
+ **/
|
|
|
|
+static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type sc, short rate, short skill_id, unsigned char target, unsigned int duration)
|
|
{
|
|
{
|
|
uint8 i;
|
|
uint8 i;
|
|
- for( i = 0; i < max && effect[i].skill; i++ )
|
|
|
|
- {
|
|
|
|
- if( effect[i].id == id && effect[i].skill == skill && effect[i].target == target )
|
|
|
|
- {
|
|
|
|
|
|
+
|
|
|
|
+ if (!duration)
|
|
|
|
+ duration = skill_get_time2(status_sc2skill(sc),7);
|
|
|
|
+
|
|
|
|
+ for( i = 0; i < max && effect[i].skill_id; i++ ) {
|
|
|
|
+ if( effect[i].sc == sc && effect[i].skill_id == skill_id && effect[i].target == target ) {
|
|
effect[i].rate += rate;
|
|
effect[i].rate += rate;
|
|
|
|
+ effect[i].duration = max(effect[i].duration, duration);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2089,10 +2118,11 @@ static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max,
|
|
ShowWarning("pc_bonus_addeff_onskill: Reached max (%d) number of add effects on skill per character!\n", max);
|
|
ShowWarning("pc_bonus_addeff_onskill: Reached max (%d) number of add effects on skill per character!\n", max);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- effect[i].id = id;
|
|
|
|
|
|
+ effect[i].sc = sc;
|
|
effect[i].rate = rate;
|
|
effect[i].rate = rate;
|
|
- effect[i].skill = skill;
|
|
|
|
|
|
+ effect[i].skill_id = skill_id;
|
|
effect[i].target = target;
|
|
effect[i].target = target;
|
|
|
|
+ effect[i].duration = duration;
|
|
}
|
|
}
|
|
|
|
|
|
/** Adjust/add drop rate modifier for player
|
|
/** Adjust/add drop rate modifier for player
|
|
@@ -3071,20 +3101,14 @@ void pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
|
|
sd->subclass[type2]+=val;
|
|
sd->subclass[type2]+=val;
|
|
break;
|
|
break;
|
|
case SP_ADDEFF: // bonus2 bAddEff,eff,n;
|
|
case SP_ADDEFF: // bonus2 bAddEff,eff,n;
|
|
- if (type2 <= SC_NONE || type2 >= SC_MAX) {
|
|
|
|
- ShowError("pc_bonus2: SP_ADDEFF: %d invalid effect.\n", type2);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ PC_BONUS_CHK_SC(type2,SP_ADDEFF);
|
|
pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
|
|
pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
|
|
- sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0);
|
|
|
|
|
|
+ sd->state.lr_flag != 2 ? val : 0, sd->state.lr_flag == 2 ? val : 0, 0, 0);
|
|
break;
|
|
break;
|
|
case SP_ADDEFF2: // bonus2 bAddEff2,eff,n;
|
|
case SP_ADDEFF2: // bonus2 bAddEff2,eff,n;
|
|
- if (type2 <= SC_NONE || type2 >= SC_MAX) {
|
|
|
|
- ShowError("pc_bonus2: SP_ADDEFF2: %d is invalid effect.\n", type2);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ PC_BONUS_CHK_SC(type2,SP_ADDEFF2);
|
|
pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
|
|
pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
|
|
- sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, ATF_SELF);
|
|
|
|
|
|
+ sd->state.lr_flag != 2 ? val : 0, sd->state.lr_flag == 2 ? val : 0, ATF_SELF, 0);
|
|
break;
|
|
break;
|
|
case SP_RESEFF: // bonus2 bResEff,eff,n;
|
|
case SP_RESEFF: // bonus2 bResEff,eff,n;
|
|
if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
|
|
if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
|
|
@@ -3270,12 +3294,9 @@ void pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
|
|
sd->critaddrace[type2] += val*10;
|
|
sd->critaddrace[type2] += val*10;
|
|
break;
|
|
break;
|
|
case SP_ADDEFF_WHENHIT: // bonus2 bAddEffWhenHit,eff,n;
|
|
case SP_ADDEFF_WHENHIT: // bonus2 bAddEffWhenHit,eff,n;
|
|
- if (type2 <= SC_NONE || type2 >= SC_MAX) {
|
|
|
|
- ShowError("pc_bonus2: SP_ADDEFF_WHENHIT: %d is invalid effect.\n", type2);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ PC_BONUS_CHK_SC(type2,SP_ADDEFF_WHENHIT);
|
|
if(sd->state.lr_flag != 2)
|
|
if(sd->state.lr_flag != 2)
|
|
- pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, val, 0, 0);
|
|
|
|
|
|
+ pc_bonus_addeff(sd->addeff_atked, ARRAYLENGTH(sd->addeff_atked), (sc_type)type2, val, 0, 0, 0);
|
|
break;
|
|
break;
|
|
case SP_SKILL_ATK: // bonus2 bSkillAtk,sk,n;
|
|
case SP_SKILL_ATK: // bonus2 bSkillAtk,sk,n;
|
|
if(sd->state.lr_flag == 2)
|
|
if(sd->state.lr_flag == 2)
|
|
@@ -3702,30 +3723,21 @@ void pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
|
|
break;
|
|
break;
|
|
|
|
|
|
case SP_ADDEFF: // bonus3 bAddEff,eff,n,y;
|
|
case SP_ADDEFF: // bonus3 bAddEff,eff,n,y;
|
|
- if (type2 <= SC_NONE || type2 >= SC_MAX) {
|
|
|
|
- ShowError("pc_bonus3: SP_ADDEFF: %d is not supported.\n", type2);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ PC_BONUS_CHK_SC(type2,SP_ADDEFF);
|
|
pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
|
|
pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
|
|
- sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, val);
|
|
|
|
|
|
+ sd->state.lr_flag != 2 ? type3 : 0, sd->state.lr_flag == 2 ? type3 : 0, val, 0);
|
|
break;
|
|
break;
|
|
|
|
|
|
case SP_ADDEFF_WHENHIT: // bonus3 bAddEffWhenHit,eff,n,y;
|
|
case SP_ADDEFF_WHENHIT: // bonus3 bAddEffWhenHit,eff,n,y;
|
|
- if (type2 <= SC_NONE || type2 >= SC_MAX) {
|
|
|
|
- ShowError("pc_bonus3: SP_ADDEFF_WHENHIT: %d is not supported.\n", type2);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ PC_BONUS_CHK_SC(type2,SP_ADDEFF_WHENHIT);
|
|
if(sd->state.lr_flag != 2)
|
|
if(sd->state.lr_flag != 2)
|
|
- pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, type3, 0, val);
|
|
|
|
|
|
+ pc_bonus_addeff(sd->addeff_atked, ARRAYLENGTH(sd->addeff_atked), (sc_type)type2, type3, 0, val, 0);
|
|
break;
|
|
break;
|
|
|
|
|
|
case SP_ADDEFF_ONSKILL: // bonus3 bAddEffOnSkill,sk,eff,n;
|
|
case SP_ADDEFF_ONSKILL: // bonus3 bAddEffOnSkill,sk,eff,n;
|
|
- if (type3 <= SC_NONE || type3 >= SC_MAX) {
|
|
|
|
- ShowError("pc_bonus3: SP_ADDEFF_ONSKILL: %d is not supported.\n", type3);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ PC_BONUS_CHK_SC(type2,SP_ADDEFF_ONSKILL);
|
|
if( sd->state.lr_flag != 2 )
|
|
if( sd->state.lr_flag != 2 )
|
|
- pc_bonus_addeff_onskill(sd->addeff3, ARRAYLENGTH(sd->addeff3), (sc_type)type3, val, type2, ATF_TARGET);
|
|
|
|
|
|
+ pc_bonus_addeff_onskill(sd->addeff_onskill, ARRAYLENGTH(sd->addeff_onskill), (sc_type)type3, val, type2, ATF_TARGET, 0);
|
|
break;
|
|
break;
|
|
|
|
|
|
case SP_ADDELE: // bonus3 bAddEle,e,x,bf;
|
|
case SP_ADDELE: // bonus3 bAddEle,e,x,bf;
|
|
@@ -3795,13 +3807,22 @@ void pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
+ case SP_ADDEFF: // bonus4 bAddEff,eff,n,y,t;
|
|
|
|
+ PC_BONUS_CHK_SC(type3,SP_ADDEFF);
|
|
|
|
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
|
|
|
|
+ sd->state.lr_flag != 2 ? type3 : 0, sd->state.lr_flag == 2 ? type3 : 0, type4, val);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SP_ADDEFF_WHENHIT: // bonus4 bAddEffWhenHit,eff,n,y,t;
|
|
|
|
+ PC_BONUS_CHK_SC(type3,SP_ADDEFF_WHENHIT);
|
|
|
|
+ if (sd->state.lr_flag != 2)
|
|
|
|
+ pc_bonus_addeff(sd->addeff_atked, ARRAYLENGTH(sd->addeff_atked), (sc_type)type2, type3, 0, 0, val);
|
|
|
|
+ break;
|
|
|
|
+
|
|
case SP_ADDEFF_ONSKILL: // bonus4 bAddEffOnSkill,sk,eff,n,y;
|
|
case SP_ADDEFF_ONSKILL: // bonus4 bAddEffOnSkill,sk,eff,n,y;
|
|
- if (type2 <= SC_NONE || type2 >= SC_MAX) {
|
|
|
|
- ShowError("pc_bonus4: SP_ADDEFF_ONSKILL: %d is not supported.\n", type2);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ PC_BONUS_CHK_SC(type3,SP_ADDEFF_ONSKILL);
|
|
if( sd->state.lr_flag != 2 )
|
|
if( sd->state.lr_flag != 2 )
|
|
- pc_bonus_addeff_onskill(sd->addeff3, ARRAYLENGTH(sd->addeff3), (sc_type)type3, type4, type2, val);
|
|
|
|
|
|
+ pc_bonus_addeff_onskill(sd->addeff_onskill, ARRAYLENGTH(sd->addeff_onskill), (sc_type)type3, type4, type2, val, 0);
|
|
break;
|
|
break;
|
|
|
|
|
|
case SP_SET_DEF_RACE: // bonus4 bSetDefRace,r,n,t,y;
|
|
case SP_SET_DEF_RACE: // bonus4 bSetDefRace,r,n,t,y;
|
|
@@ -3856,6 +3877,12 @@ void pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type
|
|
if(sd->state.lr_flag != 2)
|
|
if(sd->state.lr_flag != 2)
|
|
pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, (val&1?-type3:type3), (val&2?-type4:type4), type5, current_equip_card_id);
|
|
pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, (val&1?-type3:type3), (val&2?-type4:type4), type5, current_equip_card_id);
|
|
break;
|
|
break;
|
|
|
|
+
|
|
|
|
+ case SP_ADDEFF_ONSKILL: // bonus5 bAddEffOnSkill,sk,eff,n,y,t;
|
|
|
|
+ PC_BONUS_CHK_SC(type3,SP_ADDEFF_ONSKILL);
|
|
|
|
+ if( sd->state.lr_flag != 2 )
|
|
|
|
+ pc_bonus_addeff_onskill(sd->addeff_onskill, ARRAYLENGTH(sd->addeff_onskill), (sc_type)type3, type4, type2, type5, val);
|
|
|
|
+ break;
|
|
|
|
|
|
default:
|
|
default:
|
|
ShowWarning("pc_bonus5: unknown type %d %d %d %d %d %d!\n",type,type2,type3,type4,type5,val);
|
|
ShowWarning("pc_bonus5: unknown type %d %d %d %d %d %d!\n",type,type2,type3,type4,type5,val);
|