- Corrected map_random_dir algorithm

- Fixed homunc natural heal and little code cleanup

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8327 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
toms 2006-08-17 22:38:25 +00:00
parent 6a8503e7b1
commit ed8b093cc2
7 changed files with 27 additions and 101 deletions

View File

@ -3,6 +3,9 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/08/17
* Corrected map_random_dir algorithm [Toms]
* Fixed homunc natural heal and little code cleanup [Toms]
2006/08/16
* Fixed being unable to recast Adrenaline Rush to reset the duration
timers. [Skotlex]

View File

@ -266,7 +266,7 @@
//240,0,0,0,0,0,0,5,0,no,0,0,0,none,0 //AM_CREATECREATURE#Life Creation#
//241,0,0,0,0,0,0,5,0,no,0,0,0,none,0 //AM_CULTIVATION#Cultivation#
//242,0,0,0,0,0,0,5,0,no,0,0,0,none,0 //AM_FLAMECONTROL#Flame Control#
243,0,0,4,0,1,0,1,0,no,0,0,0,none,0 //AM_CALLHOMUN#Call Homunculus#
243,0,0,4,0,1,1,1,0,no,0,0,0,none,0 //AM_CALLHOMUN#Call Homunculus#
244,0,0,4,0,1,0,1,0,no,0,0,0,none,0 //AM_REST#Peaceful Rest#
//245,0,0,0,0,0,0,10,0,no,0,0,0,none,0 //AM_DRILLMASTER#Drillmaster#
//246,9,0,0,0,0,0,10,0,no,0,0,0,none,0 //AM_HEALHOMUN#Heal Homunculus#

View File

@ -1511,7 +1511,7 @@ void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[or
int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
int fd;
int i,j,c,len=4,id/*, inf2*/;
int i,j,len=4,id/*, inf2*/;
nullpo_retr(0, sd);
nullpo_retr(0, sd->hd);
@ -1521,7 +1521,7 @@ int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
fd=sd->fd;
WFIFOW(fd,0)=0x235;
for ( i = c = 0; i < MAX_HOMUNSKILL; i++){
for ( i = 0; i < MAX_HOMUNSKILL; i++){
if( (id = sd->homunculus.hskill[i].id) != 0 ){
j = id - HM_SKILLBASE - 1 ;
WFIFOW(fd,len ) = id ;
@ -1533,7 +1533,6 @@ int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH) ;
WFIFOB(fd,len+36) = (sd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, sd->homunculus.class_))?1:0;
len+=37;
c++;
}
}
WFIFOW(fd,2)=len;
@ -1558,7 +1557,7 @@ void clif_homskillup(struct map_session_data *sd, int skill_num) { //[orn]
range = status_get_range(&sd->bl) - (range + 1);
WFIFOW(fd,8) = range;
WFIFOB(fd,10) = (sd->homunculus.hskill[skillid].lv < skill_get_max(sd->homunculus.hskill[skillid].id)) ? 1 : 0;
WFIFOSET(fd,packet_len_table[0x10e]);
WFIFOSET(fd,packet_len_table[0x239]);
return;
}

View File

@ -2170,7 +2170,7 @@ int map_random_dir(struct block_list *bl, short *x, short *y) {
do {
j = rand()%8; //Pick a random direction
segment = rand()%dist; //Pick a random interval from the whole vector in that direction
segment = 1+(rand()%dist); //Pick a random interval from the whole vector in that direction
xi = bl->x + segment*dirx[j];
segment = (short)sqrt(dist2 - segment*segment); //The complement of the previously picked segment
yi = bl->y + segment*diry[j];

View File

@ -975,9 +975,6 @@ struct homun_data {
int target_id,attacked_id;
int natural_heal_timer; //[orn]
int hp_sub,sp_sub;
int inchealhptick,inchealsptick;
int nhealhp,nhealsp,nshealhp,nshealsp,nsshealhp,nsshealsp;
unsigned short regenhp,regensp;
unsigned long exp_next;

View File

@ -419,80 +419,8 @@ void merc_hom_heal(struct homun_data *hd,int hp,int sp)
clif_hominfo(hd->master,hd,0);
}
static unsigned int natural_heal_prev_tick,natural_heal_diff_tick;
static void merc_natural_heal_hp(struct homun_data *hd)
{
nullpo_retv(hd);
// ShowDebug("merc_natural_heal_hp (1) : homunculus = %s | hd->ud.walktimer = %d |\n", hd->name, hd->ud.walktimer) ;
if(hd->ud.walktimer == -1) {
hd->inchealhptick += natural_heal_diff_tick;
}
else {
hd->inchealhptick = 0;
return;
}
// ShowDebug("merc_natural_heal_hp (2) : homunculus = %s | hd->regenhp = %d |\n", hd->name, hd->regenhp) ;
if (hd->battle_status.hp != hd->battle_status.max_hp) {
if ((unsigned int)status_heal(&hd->bl, hd->regenhp, 0, 1) < hd->regenhp)
{ //At full.
hd->inchealhptick = 0;
return;
}
}
return;
}
static void merc_natural_heal_sp(struct homun_data *hd)
{
nullpo_retv(hd);
// ShowDebug("merc_natural_heal_sp (1) : homunculus = %s | hd->regensp = %d |\n", hd->name, hd->regensp) ;
if (hd->battle_status.sp != hd->battle_status.max_sp) {
if ((unsigned int)status_heal(&hd->bl, 0, hd->regensp, 1) < hd->regensp)
{ //At full.
hd->inchealsptick = 0;
return;
}
}
return;
}
/*==========================================
* HP/SP natural heal
*------------------------------------------
*/
//static int merc_natural_heal_sub(struct homun_data *hd,va_list ap) {
static int merc_natural_heal_sub(struct homun_data *hd,int tick) {
// int tick;
nullpo_retr(0, hd);
// tick = va_arg(ap,int);
// -- moonsoul (if conditions below altered to disallow natural healing if under berserk status)
if ( status_isdead(&hd->bl) ||
( ( hd->sc.count ) &&
( (hd->sc.data[SC_POISON].timer != -1 ) || ( hd->sc.data[SC_BLEEDING].timer != -1 ) )
)
) { //Cannot heal neither natural or special.
hd->hp_sub = hd->inchealhptick = 0;
hd->sp_sub = hd->inchealsptick = 0;
} else { //natural heal
merc_natural_heal_hp(hd);
merc_natural_heal_sp(hd);
}
return 0;
}
/*==========================================
* orn
* Homunculus natural heal hp/sp
*------------------------------------------
*/
int merc_natural_heal(int tid,unsigned int tick,int id,int data)
@ -515,14 +443,13 @@ int merc_natural_heal(int tid,unsigned int tick,int id,int data)
hd->natural_heal_timer = -1;
if(sd->homunculus.vaporize || sd->homunculus.hp == 0)
// Can't heal if homunc is vaporized, dead or under poison/bleeding effect
if (sd->homunculus.vaporize || status_isdead(&hd->bl) || ( hd->sc.count && ( hd->sc.data[SC_POISON].timer != -1 || hd->sc.data[SC_BLEEDING].timer != -1 ) ) )
return 1;
natural_heal_diff_tick = DIFF_TICK(tick,natural_heal_prev_tick);
merc_natural_heal_sub(hd, tick);
status_heal(&hd->bl, hd->regenhp, hd->regensp, 1);
natural_heal_prev_tick = tick;
sd->hd->natural_heal_timer = add_timer(gettick()+battle_config.natural_healhp_interval, merc_natural_heal,sd->bl.id,0);
sd->hd->natural_heal_timer = add_timer(tick+battle_config.natural_healhp_interval, merc_natural_heal,sd->bl.id,0);
return 0;
}
@ -1113,7 +1040,6 @@ int do_init_merc (void)
memset(homunculus_db,0,sizeof(homunculus_db)); //[orn]
read_homunculusdb(); //[orn]
// Add homunc timer function to timer func list [Toms]
natural_heal_prev_tick = gettick();
add_timer_func_list(merc_natural_heal, "merc_natural_heal");
add_timer_func_list(merc_hom_hungry, "merc_hom_hungry");
return 0;

View File

@ -2532,10 +2532,11 @@ void status_calc_bl_sub_pc(struct map_session_data *sd, unsigned long flag)
//Calculates some attributes that depends on modified stats from status changes.
void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
{
TBL_PC * sd;
struct status_data *status = &hd->battle_status, *b_status = &hd->base_status;
int skill = 0;
if (!hd->master)
if (!(sd = hd->master))
return; //Don't do anything if there isn't a master...
if(flag&(SCB_MAXHP|SCB_VIT))
@ -2554,8 +2555,8 @@ void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
if(hd->regenhp < 1) hd->regenhp = 1;
// Skill-related Adamantium Skin
if((skill=merc_hom_checkskill(hd->master,HAMI_SKIN)) > 0) {
status->max_hp = hd->master->homunculus.max_hp + skill * 2 * hd->master->homunculus.max_hp / 100 ;
if((skill=merc_hom_checkskill(sd,HAMI_SKIN)) > 0) {
status->max_hp = sd->homunculus.max_hp + skill * 2 * sd->homunculus.max_hp / 100 ;
hd->regenhp += skill * 5 * hd->regenhp / 100 ;
}
@ -2564,10 +2565,10 @@ void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
}
if(flag&SCB_DEF)
{
status->def = hd->master->homunculus.level / 10 + status->vit / 5 ;
status->def = sd->homunculus.level / 10 + status->vit / 5 ;
if(hd->sc.data[SC_DEFENCE].timer != -1)
status->def += hd->sc.data[SC_DEFENCE].val2;
if((skill=merc_hom_checkskill(hd->master,HAMI_SKIN)) > 0) {
if((skill=merc_hom_checkskill(sd,HAMI_SKIN)) > 0) {
status->def += skill * 4 ;
}
}
@ -2576,7 +2577,7 @@ void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
flag|=SCB_MAXSP;
// Skill-related Instruction Change
if((skill = merc_hom_checkskill(hd->master,HVAN_INSTRUCT)) > 0) {
if((skill = merc_hom_checkskill(sd,HVAN_INSTRUCT)) > 0) {
if ( skill == 5 ) {
status->int_ += 3 ;
} else if ( skill == 1 ) {
@ -2593,8 +2594,8 @@ void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
}
}
if((skill = merc_hom_checkskill(hd->master,HLIF_BRAIN)) > 0) {
status->max_sp = hd->master->homunculus.max_sp + skill * 2 * hd->master->homunculus.max_sp / 100 ;
if((skill = merc_hom_checkskill(sd,HLIF_BRAIN)) > 0) {
status->max_sp = sd->homunculus.max_sp + skill * 2 * sd->homunculus.max_sp / 100 ;
hd->regensp += skill * 3 * hd->regensp / 100 ;
if ( skill == 5 ) {
status->max_sp *= 103 / 100 ;
@ -2605,7 +2606,7 @@ void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
}
}
status->mdef = hd->master->homunculus.level / 10 + status->int_ / 5 ;
status->mdef = sd->homunculus.level / 10 + status->int_ / 5 ;
status->max_sp = status_calc_maxsp(&hd->bl, &hd->sc, status->max_sp);
if(status->max_sp > (unsigned int)battle_config.max_sp)
@ -2629,8 +2630,8 @@ void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
if(flag&(SCB_BATK|SCB_WATK)) {
status->rhw.atk = status->rhw.atk2 = status->str + ( status->str / 10 ) * ( status->str / 10 ) ;
status->rhw.atk += status->dex ;
if ( (status->str + hd->master->homunculus.level) > status->dex )
status->rhw.atk2 += status->str + hd->master->homunculus.level ;
if ( (status->str + sd->homunculus.level) > status->dex )
status->rhw.atk2 += status->str + sd->homunculus.level ;
else
status->rhw.atk2 += status->dex ;
@ -2684,7 +2685,7 @@ void status_calc_bl_sub_hom(struct homun_data *hd, unsigned long flag) //[orn]
SCB_BATK|SCB_WATK|SCB_MATK|SCB_ASPD|SCB_SPEED|
SCB_RANGE|SCB_MAXHP|SCB_MAXSP)
)
clif_hominfo(hd->master,hd,0);
clif_hominfo(sd,hd,0);
}
void status_calc_bl(struct block_list *bl, unsigned long flag)