|
@@ -2524,10 +2524,13 @@ int pc_disguise(struct map_session_data *sd, int class_)
|
|
|
* @param id: Skill to cast
|
|
|
* @param lv: Skill level
|
|
|
* @param rate: Success chance
|
|
|
- * @param flag: Battle flag
|
|
|
+ * @param battle_flag: Battle flag
|
|
|
* @param card_id: Used to prevent card stacking
|
|
|
+ * @param flag: Flags used for extra arguments
|
|
|
+ * &1: forces the skill to be casted on target, rather than self
|
|
|
+ * &2: random skill level in [1..lv] is chosen
|
|
|
*/
|
|
|
-static void pc_bonus_autospell(std::vector<s_autospell> &spell, short id, short lv, short rate, short flag, unsigned short card_id)
|
|
|
+static void pc_bonus_autospell(std::vector<s_autospell> &spell, uint16 id, uint16 lv, short rate, short battle_flag, t_itemid card_id, uint8 flag)
|
|
|
{
|
|
|
if (spell.size() == MAX_PC_BONUS) {
|
|
|
ShowWarning("pc_bonus_autospell: Reached max (%d) number of autospells per character!\n", MAX_PC_BONUS);
|
|
@@ -2537,19 +2540,19 @@ static void pc_bonus_autospell(std::vector<s_autospell> &spell, short id, short
|
|
|
if (!rate)
|
|
|
return;
|
|
|
|
|
|
- if (!(flag&BF_RANGEMASK))
|
|
|
- flag |= BF_SHORT | BF_LONG; //No range defined? Use both.
|
|
|
- if (!(flag&BF_WEAPONMASK))
|
|
|
- flag |= BF_WEAPON; //No attack type defined? Use weapon.
|
|
|
- if (!(flag&BF_SKILLMASK)) {
|
|
|
- if (flag&(BF_MAGIC | BF_MISC))
|
|
|
- flag |= BF_SKILL; //These two would never trigger without BF_SKILL
|
|
|
- if (flag&BF_WEAPON)
|
|
|
- flag |= BF_NORMAL; //By default autospells should only trigger on normal weapon attacks.
|
|
|
+ if (!(battle_flag&BF_RANGEMASK))
|
|
|
+ battle_flag |= BF_SHORT | BF_LONG; //No range defined? Use both.
|
|
|
+ if (!(battle_flag&BF_WEAPONMASK))
|
|
|
+ battle_flag |= BF_WEAPON; //No attack type defined? Use weapon.
|
|
|
+ if (!(battle_flag&BF_SKILLMASK)) {
|
|
|
+ if (battle_flag&(BF_MAGIC | BF_MISC))
|
|
|
+ battle_flag |= BF_SKILL; //These two would never trigger without BF_SKILL
|
|
|
+ if (battle_flag&BF_WEAPON)
|
|
|
+ battle_flag |= BF_NORMAL; //By default autospells should only trigger on normal weapon attacks.
|
|
|
}
|
|
|
|
|
|
for (auto &it : spell) {
|
|
|
- if ((it.card_id == card_id || it.rate < 0 || rate < 0) && it.id == id && it.lv == lv && it.flag == flag) {
|
|
|
+ if ((it.card_id == card_id || it.rate < 0 || rate < 0) && it.id == id && it.lv == lv && it.flag == battle_flag) {
|
|
|
if (!battle_config.autospell_stacking && it.rate > 0 && rate > 0) // Stacking disabled
|
|
|
return;
|
|
|
it.rate = cap_value(it.rate + rate, -10000, 10000);
|
|
@@ -2565,8 +2568,9 @@ static void pc_bonus_autospell(std::vector<s_autospell> &spell, short id, short
|
|
|
entry.id = id;
|
|
|
entry.lv = lv;
|
|
|
entry.rate = cap_value(rate, -10000, 10000);
|
|
|
- entry.flag = flag;
|
|
|
+ entry.battle_flag = battle_flag;
|
|
|
entry.card_id = card_id;
|
|
|
+ entry.flag = flag;
|
|
|
|
|
|
spell.push_back(entry);
|
|
|
}
|
|
@@ -2579,8 +2583,11 @@ static void pc_bonus_autospell(std::vector<s_autospell> &spell, short id, short
|
|
|
* @param lv: Skill level
|
|
|
* @param rate: Success chance
|
|
|
* @param card_id: Used to prevent card stacking
|
|
|
+ * @param flag: Flags used for extra arguments
|
|
|
+ * &1: forces the skill to be casted on self, rather than on the target of skill
|
|
|
+ * &2: random skill level in [1..lv] is chosen
|
|
|
*/
|
|
|
-static void pc_bonus_autospell_onskill(std::vector<s_autospell> &spell, short src_skill, short id, short lv, short rate, unsigned short card_id)
|
|
|
+static void pc_bonus_autospell_onskill(std::vector<s_autospell> &spell, uint16 src_skill, uint16 id, uint16 lv, short rate, t_itemid card_id, uint8 flag)
|
|
|
{
|
|
|
if (spell.size() == MAX_PC_BONUS) {
|
|
|
ShowWarning("pc_bonus_autospell_onskill: Reached max (%d) number of autospells per character!\n", MAX_PC_BONUS);
|
|
@@ -2595,11 +2602,12 @@ static void pc_bonus_autospell_onskill(std::vector<s_autospell> &spell, short sr
|
|
|
if (rate < -10000 || rate > 10000)
|
|
|
ShowWarning("pc_bonus_onskill: Item bonus rate %d exceeds -10000~10000 range, capping.\n", rate);
|
|
|
|
|
|
- entry.flag = src_skill;
|
|
|
+ entry.trigger_skill = src_skill;
|
|
|
entry.id = id;
|
|
|
entry.lv = lv;
|
|
|
entry.rate = cap_value(rate, -10000, 10000);
|
|
|
entry.card_id = card_id;
|
|
|
+ entry.flag = flag;
|
|
|
|
|
|
spell.push_back(entry);
|
|
|
}
|
|
@@ -4455,7 +4463,7 @@ void pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
|
|
|
{
|
|
|
int target = skill_get_inf(type2); //Support or Self (non-auto-target) skills should pick self.
|
|
|
target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !skill_get_inf2(type2, INF2_NOTARGETSELF));
|
|
|
- pc_bonus_autospell(sd->autospell, target?-type2:type2, type3, val, 0, current_equip_card_id);
|
|
|
+ pc_bonus_autospell(sd->autospell, type2, type3, val, 0, current_equip_card_id, target ? 0 : 1);
|
|
|
}
|
|
|
break;
|
|
|
case SP_AUTOSPELL_WHENHIT: // bonus3 bAutoSpellWhenHit,sk,y,n;
|
|
@@ -4463,7 +4471,7 @@ void pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
|
|
|
{
|
|
|
int target = skill_get_inf(type2); //Support or Self (non-auto-target) skills should pick self.
|
|
|
target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !skill_get_inf2(type2, INF2_NOTARGETSELF));
|
|
|
- pc_bonus_autospell(sd->autospell2, target?-type2:type2, type3, val, BF_NORMAL|BF_SKILL, current_equip_card_id);
|
|
|
+ pc_bonus_autospell(sd->autospell2, type2, type3, val, BF_NORMAL|BF_SKILL, current_equip_card_id, target ? 0 : 1);
|
|
|
}
|
|
|
break;
|
|
|
case SP_ADD_MONSTER_DROP_ITEMGROUP: // bonus3 bAddMonsterDropItemGroup,ig,r,n;
|
|
@@ -4581,12 +4589,12 @@ void pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type
|
|
|
switch(type){
|
|
|
case SP_AUTOSPELL: // bonus4 bAutoSpell,sk,y,n,i;
|
|
|
if(sd->state.lr_flag != 2)
|
|
|
- pc_bonus_autospell(sd->autospell, (val&1?type2:-type2), (val&2?-type3:type3), type4, 0, current_equip_card_id);
|
|
|
+ pc_bonus_autospell(sd->autospell, type2, type3, type4, 0, current_equip_card_id, val);
|
|
|
break;
|
|
|
|
|
|
case SP_AUTOSPELL_WHENHIT: // bonus4 bAutoSpellWhenHit,sk,y,n,i;
|
|
|
if(sd->state.lr_flag != 2)
|
|
|
- pc_bonus_autospell(sd->autospell2, (val&1?type2:-type2), (val&2?-type3:type3), type4, BF_NORMAL|BF_SKILL, current_equip_card_id);
|
|
|
+ pc_bonus_autospell(sd->autospell2, type2, type3, type4, BF_NORMAL|BF_SKILL, current_equip_card_id, val);
|
|
|
break;
|
|
|
|
|
|
case SP_AUTOSPELL_ONSKILL: // bonus4 bAutoSpellOnSkill,sk,x,y,n;
|
|
@@ -4595,7 +4603,7 @@ void pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type
|
|
|
int target = skill_get_inf(type3); //Support or Self (non-auto-target) skills should pick self.
|
|
|
target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !skill_get_inf2(type3, INF2_NOTARGETSELF));
|
|
|
|
|
|
- pc_bonus_autospell_onskill(sd->autospell3, type2, target?-type3:type3, type4, val, current_equip_card_id);
|
|
|
+ pc_bonus_autospell_onskill(sd->autospell3, type2, type3, type4, val, current_equip_card_id, target ? 0 : 1);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -4664,17 +4672,17 @@ void pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type
|
|
|
switch(type){
|
|
|
case SP_AUTOSPELL: // bonus5 bAutoSpell,sk,y,n,bf,i;
|
|
|
if(sd->state.lr_flag != 2)
|
|
|
- pc_bonus_autospell(sd->autospell, (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
|
|
|
+ pc_bonus_autospell(sd->autospell, type2, type3, type4, type5, current_equip_card_id, val);
|
|
|
break;
|
|
|
|
|
|
case SP_AUTOSPELL_WHENHIT: // bonus5 bAutoSpellWhenHit,sk,y,n,bf,i;
|
|
|
if(sd->state.lr_flag != 2)
|
|
|
- pc_bonus_autospell(sd->autospell2, (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
|
|
|
+ pc_bonus_autospell(sd->autospell2, type2, type3, type4, type5, current_equip_card_id, val);
|
|
|
break;
|
|
|
|
|
|
case SP_AUTOSPELL_ONSKILL: // bonus5 bAutoSpellOnSkill,sk,x,y,n,i;
|
|
|
if(sd->state.lr_flag != 2)
|
|
|
- pc_bonus_autospell_onskill(sd->autospell3, type2, (val&1?-type3:type3), (val&2?-type4:type4), type5, current_equip_card_id);
|
|
|
+ pc_bonus_autospell_onskill(sd->autospell3, type2, type3, type4, type5, current_equip_card_id, val);
|
|
|
break;
|
|
|
|
|
|
case SP_ADDEFF_ONSKILL: // bonus5 bAddEffOnSkill,sk,eff,n,y,t;
|