Skip to content

Commit

Permalink
Added item bonus bSubSkill.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKeiKun committed Apr 6, 2021
1 parent dcef2c2 commit 8b9ec2a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions db/constants.conf
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ constants_db: {
bSubDefEle: 2063
bMagicSubDefEle: 2064
bStateNoRecoverRace: 2065
bSubSkill: 2066

comment__: "Equip index"
/* reference to script.c::script_defaults():equip[] array used for easy-conversion */
Expand Down
1 change: 1 addition & 0 deletions doc/item_bonus.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ bonus bCritAtkRate,`n`; | Increase critical damage by +`n`%
bonus bNoWeaponDamage,`n`; | Prevents from receiving `n`% physical damage
bonus bNoMagicDamage,`n`; | Prevents from receiving `n`% magical effect (Attack, Healing, Support spells are all blocked)
bonus bNoMiscDamage,`n`; | Adds `n`% reduction to received misc damage
bonus2 bSubSkill,`sk`,`n`; | Reduce damage received from `sk` skill by `n`%

Heal | Description
:-------------------------------- | :-------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/map/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3673,6 +3673,7 @@ static struct Damage battle_calc_magic_attack(struct block_list *src, struct blo
flag.imdef = (nk&NK_IGNORE_DEF)? 1 : 0;

sd = BL_CAST(BL_PC, src);
struct map_session_data *tsd = BL_CAST(BL_PC, target);

sc = status->get_sc(src);

Expand Down Expand Up @@ -3905,6 +3906,8 @@ static struct Damage battle_calc_magic_attack(struct block_list *src, struct blo
))
flag.imdef = 1;
}
if (tsd && (i = pc->sub_skillatk_bonus(tsd, skill_id)))
ad.damage -= ad.damage * i / 100;

ad.damage = battle->calc_defense(BF_MAGIC, src, target, skill_id, skill_lv, ad.damage, flag.imdef, 0);

Expand Down Expand Up @@ -4347,6 +4350,8 @@ static struct Damage battle_calc_misc_attack(struct block_list *src, struct bloc
}
if (sd && (i = pc->skillatk_bonus(sd, rskill)) != 0)
md.damage += md.damage*i/100;
if (tsd && (i = pc->sub_skillatk_bonus(tsd, rskill)) != 0)
md.damage -= md.damage * i / 100;
}
if( (i = battle->adjust_skill_damage(src->m,skill_id)) )
md.damage = md.damage * i / 100;
Expand Down Expand Up @@ -5455,6 +5460,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl
}
}

if (tsd && skill_id && (i = pc->sub_skillatk_bonus(tsd, skill_id)))
ATK_ADDRATE(-i);

if((!flag.idef || !flag.idef2)
#ifdef RENEWAL
&& (!flag.distinct || flag.tdef)
Expand Down
1 change: 1 addition & 0 deletions src/map/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ enum status_point_types { //we better clean up this enum and change it name [Hem
SP_SUB_DEF_ELE = 2063,
SP_MAGIC_SUB_DEF_ELE = 2064,
SP_STATE_NO_RECOVER_RACE = 2065,
SP_SUB_SKILL = 2066,

#ifndef SP_LAST_KNOWN
SP_LAST_KNOWN
Expand Down
30 changes: 30 additions & 0 deletions src/map/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3838,6 +3838,22 @@ static int pc_bonus2(struct map_session_data *sd, int type, int type2, int val)
}
break;
#endif
case SP_SUB_SKILL:
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->subskill), i, sd->subskill[i].id == 0 || sd->subskill[i].id == type2);
if (i == ARRAYLENGTH(sd->subskill)) {
ShowDebug("script->run: bonus2 bSubSkill reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",
ARRAYLENGTH(sd->subskill), type2, val);
break;
}
if (sd->subskill[i].id == type2) {
sd->subskill[i].val += val;
} else {
sd->subskill[i].id = type2;
sd->subskill[i].val = val;
}
break;
default:
ShowWarning("pc_bonus2: unknown type %d %d %d!\n",type,type2,val);
Assert_report(0);
Expand Down Expand Up @@ -7889,6 +7905,19 @@ static int pc_skillatk_bonus(struct map_session_data *sd, uint16 skill_id)
return bonus;
}

static int pc_sub_skillatk_bonus(struct map_session_data *sd, uint16 skill_id)
{
int i, bonus = 0;
nullpo_ret(sd);

ARR_FIND(0, ARRAYLENGTH(sd->subskill), i, sd->subskill[i].id == skill_id);

if (i < ARRAYLENGTH(sd->subskill))
bonus = sd->subskill[i].val;

return bonus;
}

static int pc_skillheal_bonus(struct map_session_data *sd, uint16 skill_id)
{
int i, bonus = sd->bonus.add_heal_rate;
Expand Down Expand Up @@ -12843,6 +12872,7 @@ void pc_defaults(void)
pc->autocast_remove = pc_autocast_remove;

pc->skillatk_bonus = pc_skillatk_bonus;
pc->sub_skillatk_bonus = pc_sub_skillatk_bonus;
pc->skillheal_bonus = pc_skillheal_bonus;
pc->skillheal2_bonus = pc_skillheal2_bonus;

Expand Down
3 changes: 2 additions & 1 deletion src/map/pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ BEGIN_ZEROED_BLOCK; // this block will be globally zeroed at the beginning of st
struct { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills.
unsigned int id;
int val;
} skillatk[MAX_PC_BONUS], skillusesprate[MAX_PC_BONUS], skillusesp[MAX_PC_BONUS], skillheal[5], skillheal2[5], skillblown[MAX_PC_BONUS], skillcast[MAX_PC_BONUS], skillcooldown[MAX_PC_BONUS], skillfixcast[MAX_PC_BONUS], skillvarcast[MAX_PC_BONUS], skillfixcastrate[MAX_PC_BONUS];
} skillatk[MAX_PC_BONUS], skillusesprate[MAX_PC_BONUS], skillusesp[MAX_PC_BONUS], skillheal[5], skillheal2[5], skillblown[MAX_PC_BONUS], skillcast[MAX_PC_BONUS], skillcooldown[MAX_PC_BONUS], skillfixcast[MAX_PC_BONUS], skillvarcast[MAX_PC_BONUS], skillfixcastrate[MAX_PC_BONUS], subskill[MAX_PC_BONUS];
struct {
int value;
int rate;
Expand Down Expand Up @@ -1060,6 +1060,7 @@ END_ZEROED_BLOCK; /* End */
void (*autocast_remove) (struct map_session_data *sd, enum autocast_type type, int skill_id, int skill_lv);

int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id);
int (*sub_skillatk_bonus) (struct map_session_data *sd, uint16 skill_id);
int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id);
int (*skillheal2_bonus) (struct map_session_data *sd, uint16 skill_id);

Expand Down
1 change: 1 addition & 0 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -10555,6 +10555,7 @@ static BUILDIN(bonus)
case SP_VARCASTRATE:
case SP_FIXCASTRATE:
case SP_SKILL_USE_SP:
case SP_SUB_SKILL:
// these bonuses support skill names
if (script_isstringtype(st, 3)) {
val1 = skill->name2id(script_getstr(st, 3));
Expand Down

0 comments on commit 8b9ec2a

Please sign in to comment.