|
@@ -1894,7 +1894,17 @@ static int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, e
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
-static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int class_, int race, int rate)
|
|
|
|
|
|
+/** Adjust/add drop rate modifier for player
|
|
|
|
+* @param drop: sd->add_drop (struct s_add_drop)
|
|
|
|
+* @param max: max stacked bonus
|
|
|
|
+* @param id: item id that will be dropped
|
|
|
|
+* @param group: group id
|
|
|
|
+* @param class_: target class
|
|
|
|
+* @param race: target race
|
|
|
|
+* @param rate: rate value
|
|
|
|
+* @return true/false: false if max limit is reached
|
|
|
|
+*/
|
|
|
|
+static void pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int class_, int race, int rate)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
//Apply config rate adjustment settings.
|
|
//Apply config rate adjustment settings.
|
|
@@ -1924,28 +1934,33 @@ static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id
|
|
{ //Both are absolute rates.
|
|
{ //Both are absolute rates.
|
|
if (drop[i].rate < rate)
|
|
if (drop[i].rate < rate)
|
|
drop[i].rate = rate;
|
|
drop[i].rate = rate;
|
|
- } else
|
|
|
|
- if(drop[i].rate < 0 && rate < 0) {
|
|
|
|
|
|
+ } else if(drop[i].rate < 0 && rate < 0) {
|
|
//Both are relative rates.
|
|
//Both are relative rates.
|
|
if (drop[i].rate > rate)
|
|
if (drop[i].rate > rate)
|
|
drop[i].rate = rate;
|
|
drop[i].rate = rate;
|
|
} else if (rate < 0) //Give preference to relative rate.
|
|
} else if (rate < 0) //Give preference to relative rate.
|
|
drop[i].rate = rate;
|
|
drop[i].rate = rate;
|
|
- return 1;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(i == max) {
|
|
if(i == max) {
|
|
ShowWarning("pc_bonus: Reached max (%d) number of added drops per character!\n", max);
|
|
ShowWarning("pc_bonus: Reached max (%d) number of added drops per character!\n", max);
|
|
- return 0;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
drop[i].id = id;
|
|
drop[i].id = id;
|
|
drop[i].group = group;
|
|
drop[i].group = group;
|
|
- drop[i].race |= race;
|
|
|
|
|
|
+ if(race>RC_NONE_ && race<RC_MAX)
|
|
|
|
+ drop[i].race = 1<<race;
|
|
|
|
+ else
|
|
|
|
+ drop[i].race = race;
|
|
|
|
+ if(class_>CLASS_NONE && class_<CLASS_MAX)
|
|
|
|
+ drop[i].class_ = 1<<class_;
|
|
|
|
+ else
|
|
|
|
+ drop[i].class_ = class_;
|
|
drop[i].rate = rate;
|
|
drop[i].rate = rate;
|
|
- return 1;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-int pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short flag,const char *other_script,unsigned short pos,bool onskill)
|
|
|
|
|
|
+bool pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short flag,const char *other_script,unsigned short pos,bool onskill)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
|
|
|
|
@@ -1953,7 +1968,7 @@ int pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short
|
|
if( i == max )
|
|
if( i == max )
|
|
{
|
|
{
|
|
ShowWarning("pc_addautobonus: Reached max (%d) number of autobonus per character!\n", max);
|
|
ShowWarning("pc_addautobonus: Reached max (%d) number of autobonus per character!\n", max);
|
|
- return 0;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
if( !onskill )
|
|
if( !onskill )
|
|
@@ -1978,13 +1993,14 @@ int pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short
|
|
bonus[i].pos = pos;
|
|
bonus[i].pos = pos;
|
|
bonus[i].bonus_script = aStrdup(script);
|
|
bonus[i].bonus_script = aStrdup(script);
|
|
bonus[i].other_script = other_script?aStrdup(other_script):NULL;
|
|
bonus[i].other_script = other_script?aStrdup(other_script):NULL;
|
|
- return 1;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
-int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,char max,bool restore)
|
|
|
|
|
|
+void pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,char max,bool restore)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
- nullpo_ret(sd);
|
|
|
|
|
|
+ if (!sd)
|
|
|
|
+ return;
|
|
|
|
|
|
for( i = 0; i < max; i++ )
|
|
for( i = 0; i < max; i++ )
|
|
{
|
|
{
|
|
@@ -2014,14 +2030,12 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c
|
|
autobonus[i].rate = autobonus[i].atk_type = autobonus[i].duration = autobonus[i].pos = 0;
|
|
autobonus[i].rate = autobonus[i].atk_type = autobonus[i].duration = autobonus[i].pos = 0;
|
|
autobonus[i].active = INVALID_TIMER;
|
|
autobonus[i].active = INVALID_TIMER;
|
|
}
|
|
}
|
|
-
|
|
|
|
- return 0;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus)
|
|
|
|
|
|
+void pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus)
|
|
{
|
|
{
|
|
- nullpo_ret(sd);
|
|
|
|
- nullpo_ret(autobonus);
|
|
|
|
|
|
+ if (!sd || !autobonus)
|
|
|
|
+ return;
|
|
|
|
|
|
if( autobonus->other_script )
|
|
if( autobonus->other_script )
|
|
{
|
|
{
|
|
@@ -2034,8 +2048,6 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus)
|
|
autobonus->active = add_timer(gettick()+autobonus->duration, pc_endautobonus, sd->bl.id, (intptr_t)autobonus);
|
|
autobonus->active = add_timer(gettick()+autobonus->duration, pc_endautobonus, sd->bl.id, (intptr_t)autobonus);
|
|
sd->state.autobonus |= autobonus->pos;
|
|
sd->state.autobonus |= autobonus->pos;
|
|
status_calc_pc(sd,0);
|
|
status_calc_pc(sd,0);
|
|
-
|
|
|
|
- return 0;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data)
|
|
int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data)
|