summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-03 20:00:33 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-03 20:00:33 +0000
commit7689b26c216bb9de59d7ddfcbe9c45c18cfb7cc4 (patch)
tree38fc970c9b971dae33515eaff4fea45192a8d44e /src/map/pc.c
parent7bb91031c6b244781f6637dc87dafa5835326888 (diff)
downloadhercules-7689b26c216bb9de59d7ddfcbe9c45c18cfb7cc4.tar.gz
hercules-7689b26c216bb9de59d7ddfcbe9c45c18cfb7cc4.tar.bz2
hercules-7689b26c216bb9de59d7ddfcbe9c45c18cfb7cc4.tar.xz
hercules-7689b26c216bb9de59d7ddfcbe9c45c18cfb7cc4.zip
- Added bonuses bSPRegenRate, bHPRegenRate. They behave like the opposite of bHPLossRate/bSPLossRate, making you gain x Hp/Sp every y ms.
- Added bonus bIgnoreMdefRate, used to ignore a % of the target's mdef when using magic attacks (bonus2 will ignore part of the mdef of all targets, bonus3 receives a race argument) - You can now use bonus2 bCastRate to adjust the cast rate of a single skill. - Cleaned the code for bleeding (hp-loss) and extended it to handle regen as well. - Some small cleanups in the pc_bonus functions - Removed bonus3 bHpLossRate since it was doing nothing and is not used. - Corrected bGetZeny bonus to be like in Aegis. The amount received is from 1 to the given amount, you can use negative zeny values to use an amount dependant on mob's level (amount*lv). - Updated doc/item_bonus.txt with all these changes - Anti-Magic/Stone-Skin now increase/decrease def/mdef only and in an absolute mode (+20*lv rather than +20%*lv). Also the duration is greatly decreased (x/15) when used on players. - Now when a player uses a strip skill without having it in the skill tree (auto-casted) the duration will be 0, the equipment will be stripped without causing the status change that blocks reequipping. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11112 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c134
1 files changed, 95 insertions, 39 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 30d012b5e..5a43f0af3 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1632,6 +1632,12 @@ int pc_bonus(struct map_session_data *sd,int type,int val)
if(sd->state.lr_flag != 2)
sd->misc_def_rate += val;
break;
+ case SP_IGNORE_MDEF_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->ignore_mdef[RC_NONBOSS] += val;
+ sd->ignore_mdef[RC_BOSS] += val;
+ }
+ break;
case SP_IGNORE_MDEF_ELE:
if(val >= ELE_MAX) {
if(battle_config.error_log)
@@ -2203,7 +2209,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
}
if(sd->state.lr_flag != 2)
- pc_bonus_addeff(sd->addeff2, MAX_PC_BONUS, type2, val, 0,
+ pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), type2, val, 0,
ATF_SHORT|ATF_TARGET);
break;
case SP_SKILL_ATK:
@@ -2239,21 +2245,39 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
}
break;
case SP_ADD_SKILL_BLOW:
- for (i = 0; i < MAX_PC_BONUS && sd->skillblown[i].id != 0 && sd->skillblown[i].id != type2; i++);
- if (i == MAX_PC_BONUS)
+ if(sd->state.lr_flag == 2)
+ break;
+ for (i = 0; i < ARRAYLENGTH(sd->skillblown) && sd->skillblown[i].id && sd->skillblown[i].id != type2; i++);
+ if (i == ARRAYLENGTH(sd->skillblown))
{ //Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("run_script: bonus2 bSkillBlown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", MAX_PC_BONUS, type2, val);
+ ShowDebug("run_script: bonus2 bSkillBlown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillblown), type2, val);
break;
}
- if(sd->state.lr_flag != 2) {
- if (sd->skillblown[i].id == type2)
- sd->skillblown[i].val += val;
- else {
- sd->skillblown[i].id = type2;
- sd->skillblown[i].val = val;
- }
+ if(sd->skillblown[i].id == type2)
+ sd->skillblown[i].val += val;
+ else {
+ sd->skillblown[i].id = type2;
+ sd->skillblown[i].val = val;
}
break;
+
+ case SP_CASTRATE:
+ if(sd->state.lr_flag == 2)
+ break;
+ for (i = 0; i < ARRAYLENGTH(sd->skillcast) && sd->skillcast[i].id && sd->skillblown[i].id != type2; i++);
+ if (i == ARRAYLENGTH(sd->skillcast))
+ { //Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("run_script: bonus2 bCastRate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillcast), type2, val);
+ break;
+ }
+ if(sd->skillcast[i].id == type2)
+ sd->skillcast[i].val += val;
+ else {
+ sd->skillcast[i].id = type2;
+ sd->skillcast[i].val = val;
+ }
+ break;
+
case SP_ADD_DAMAGE_BY_CLASS:
if(sd->state.lr_flag != 2) {
for(i=0;i<sd->add_dmg_count;i++) {
@@ -2271,8 +2295,14 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
case SP_HP_LOSS_RATE:
if(sd->state.lr_flag != 2) {
- sd->hp_loss_value = type2;
- sd->hp_loss_rate = val;
+ sd->hp_loss.value = type2;
+ sd->hp_loss.rate = val;
+ }
+ break;
+ case SP_HP_REGEN_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->hp_regen.value = type2;
+ sd->hp_regen.rate = val;
}
break;
case SP_ADDRACE2:
@@ -2325,8 +2355,14 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
case SP_SP_LOSS_RATE:
if(sd->state.lr_flag != 2) {
- sd->sp_loss_value = type2;
- sd->sp_loss_rate = val;
+ sd->sp_loss.value = type2;
+ sd->sp_loss.rate = val;
+ }
+ break;
+ case SP_SP_REGEN_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->sp_regen.value = type2;
+ sd->sp_regen.rate = val;
}
break;
case SP_HP_DRAIN_VALUE_RACE:
@@ -2345,6 +2381,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->left_weapon.sp_drain[type2].value += val;
}
break;
+ case SP_IGNORE_MDEF_RATE:
+ if(sd->state.lr_flag != 2)
+ sd->ignore_mdef[type2] += val;
+ break;
default:
if(battle_config.error_log)
@@ -2371,13 +2411,6 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
if(sd->state.lr_flag != 2)
pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, skill_get_inf(type2)&INF_SELF_SKILL?-type2:type2, type3, val, 0, current_equip_card_id);
break;
- case SP_HP_LOSS_RATE:
- if(sd->state.lr_flag != 2) {
- sd->hp_loss_value = type2;
- sd->hp_loss_rate = type3;
- sd->hp_loss_type = val;
- }
- break;
case SP_SP_DRAIN_RATE:
if(!sd->state.lr_flag) {
sd->right_weapon.sp_drain[RC_NONBOSS].rate += type2;
@@ -4919,7 +4952,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
if (sd->menuskill_id)
sd->menuskill_id = sd->menuskill_val = 0;
//Reset ticks.
- sd->hp_loss_tick = sd->sp_loss_tick = 0;
+ sd->hp_loss.tick = sd->sp_loss.tick = sd->hp_regen.tick = sd->sp_regen.tick = 0;
pc_setglobalreg(sd,"PC_DIE_COUNTER",++sd->die_counter);
@@ -6828,25 +6861,19 @@ void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick)
{
int hp = 0, sp = 0;
- if (sd->hp_loss_value > 0) {
- sd->hp_loss_tick += diff_tick;
- if (sd->hp_loss_tick >= sd->hp_loss_rate) {
- do {
- hp += sd->hp_loss_value;
- sd->hp_loss_tick -= sd->hp_loss_rate;
- } while (sd->hp_loss_tick >= sd->hp_loss_rate);
- sd->hp_loss_tick = 0;
+ if (sd->hp_loss.value) {
+ sd->hp_loss.tick += diff_tick;
+ while (sd->hp_loss.tick >= sd->hp_loss.rate) {
+ hp += sd->hp_loss.value;
+ sd->hp_loss.tick -= sd->hp_loss.rate;
}
}
- if (sd->sp_loss_value > 0) {
- sd->sp_loss_tick += diff_tick;
- if (sd->sp_loss_tick >= sd->sp_loss_rate) {
- do {
- sp += sd->sp_loss_value;
- sd->sp_loss_tick -= sd->sp_loss_rate;
- } while (sd->sp_loss_tick >= sd->sp_loss_rate);
- sd->sp_loss_tick = 0;
+ if (sd->sp_loss.value) {
+ sd->sp_loss.tick += diff_tick;
+ while (sd->sp_loss.tick >= sd->sp_loss.rate) {
+ sp += sd->sp_loss.value;
+ sd->sp_loss.tick -= sd->sp_loss.rate;
}
}
@@ -6856,6 +6883,35 @@ void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick)
return;
}
+//Character regen. Flag is used to know which types of regen can take place.
+//&1: HP regen
+//&2: SP regen
+void pc_regen (struct map_session_data *sd, unsigned int diff_tick, int flag)
+{
+ int hp = 0, sp = 0;
+
+ if (sd->hp_regen.value && flag&1) {
+ sd->hp_regen.tick += diff_tick;
+ while (sd->hp_regen.tick >= sd->hp_regen.rate) {
+ hp += sd->hp_regen.value;
+ sd->hp_regen.tick -= sd->hp_regen.rate;
+ }
+ }
+
+ if (sd->sp_regen.value && flag&2) {
+ sd->sp_regen.tick += diff_tick;
+ while (sd->sp_regen.tick >= sd->sp_regen.rate) {
+ sp += sd->sp_regen.value;
+ sd->sp_regen.tick -= sd->sp_regen.rate;
+ }
+ }
+
+ if (hp > 0 || sp > 0)
+ status_heal(&sd->bl, hp, sp, 2);
+
+ return;
+}
+
/*==========================================
* セ?ブポイントの保存
*------------------------------------------*/