summaryrefslogtreecommitdiff
path: root/src/map/pet.c
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-20 14:11:43 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-20 14:11:43 +0000
commitce070c5d8303a15fec032721e0163bdce4e84c33 (patch)
tree8fe5d38dec3a05af1c2e82571318d76e78d754fe /src/map/pet.c
parent3d791e7ca59391cab1fb2054fd97b221fce3bb99 (diff)
downloadhercules-ce070c5d8303a15fec032721e0163bdce4e84c33.tar.gz
hercules-ce070c5d8303a15fec032721e0163bdce4e84c33.tar.bz2
hercules-ce070c5d8303a15fec032721e0163bdce4e84c33.tar.xz
hercules-ce070c5d8303a15fec032721e0163bdce4e84c33.zip
* Added skill requirements for the new guild skills
* Allow Emergency Recall to be cast in guild castles * Add 'minimum job level required' for skill_tree reading - Berserk now requires job level 50 * Added Spring Trap to be able to trigger ankle snare traps that aren't activated yet * Added a fix in guild.c by Mellowz * Some rewrites on the pet skill bonuses system * Check whether a monster is still alive before starting a status change git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1142 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pet.c')
-rw-r--r--src/map/pet.c89
1 files changed, 32 insertions, 57 deletions
diff --git a/src/map/pet.c b/src/map/pet.c
index b4dddc372..c48f92970 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -596,14 +596,14 @@ int pet_remove_map(struct map_session_data *sd)
struct pet_data *pd=sd->pd; // [Valaris]
if(pd->skillbonustimer!=-1) pd->skillbonustimer=-1;
- if(pd->skillbonusduration!=-1) pd->skillbonusduration=-1;
- if(pd->skilltype !=-1) pd->skilltype=-1;
- if(pd->skillval !=-1) pd->skillval=-1;
+ pd->skilltype=0;
+ pd->skillval=0;
if(pd->skilltimer!=-1) pd->skilltimer=-1;
- if(pd->skillduration!=-1) pd->skillduration=-1;
- if(pd->skillbonustype!=-1) pd->skillbonustype=-1;
- if(pd->skillbonusval!=-1) pd->skillbonusval=-1;
- if(sd->perfect_hiding==1) sd->perfect_hiding=0; // end additions
+ pd->state.skillbonus=-1;
+ pd->skillduration=0;
+ pd->skillbonustype=0;
+ pd->skillbonusval=0;
+ if(sd->perfect_hiding==1) sd->perfect_hiding=0; // end additions
pet_changestate(sd->pd,MS_IDLE,0);
if(sd->pet_hungry_timer != -1)
@@ -737,9 +737,13 @@ int pet_data_init(struct map_session_data *sd)
pd->move_fail_count = 0;
pd->next_walktime = pd->attackabletime = pd->last_thinktime = gettick();
pd->msd = sd;
-
+
map_addiddb(&pd->bl);
+ // initialise
+ pd->state.skillbonus = -1;
+ run_script(pet_db[i].script,0,sd->bl.id,0);
+
if(sd->pet_hungry_timer != -1)
pet_hungry_timer_delete(sd);
if(battle_config.pet_hungry_delay_rate != 100)
@@ -1407,29 +1411,13 @@ int pet_delay_item_drop2(int tid,unsigned int tick,int id,int data)
* pet bonus giving skills [Valaris]
*------------------------------------------
*/
-
-int pet_skill_bonus(struct map_session_data *sd,struct pet_data *pd,int type,int val,int duration,int timer,int data)
-{
- if(pd==NULL || sd==NULL)
- return 1;
-
- pd->skillbonustype=type;
- pd->skillbonusval=val;
- pd->skillduration=duration;
- pd->skilltimer=timer;
-
- pd->skillbonustimer=add_timer(gettick()+pd->skilltimer*1000,pet_skill_bonus_timer,sd->bl.id,0);
-
- return 0;
-
-}
-
int pet_skill_bonus_timer(int tid,unsigned int tick,int id,int data)
{
- struct map_session_data *sd=(struct map_session_data*)map_id2bl(id);
+ struct map_session_data *sd=map_id2sd(id);
struct pet_data *pd;
+ int timer = 0;
- if(sd==NULL || sd->bl.type!=BL_PC)
+ if(sd==NULL)
return 1;
pd=sd->pd;
@@ -1440,38 +1428,26 @@ int pet_skill_bonus_timer(int tid,unsigned int tick,int id,int data)
if(pd->skillbonustimer != tid)
return 0;
- pd->skillbonustimer=-1;
-
- pc_bonus(sd,pd->skillbonustype,pd->skillbonusval);
- if(pd->skillbonustype < 56) clif_updatestatus(sd,pd->skillbonustype);
- pd->skillbonusduration=add_timer(gettick()+pd->skillduration*1000,pet_skill_bonus_duration,sd->bl.id,0);
-
- return 0;
-}
-
-int pet_skill_bonus_duration(int tid,unsigned int tick,int id,int data)
-{
- struct map_session_data *sd=(struct map_session_data*)map_id2bl(id);
- struct pet_data *pd;
-
- if(sd==NULL || sd->bl.type!=BL_PC)
- return 1;
-
- pd=sd->pd;
-
- if(pd==NULL || pd->bl.type!=BL_PET)
- return 1;
-
- if(pd->skillbonusduration != tid)
- return 0;
-
- pd->skillbonusduration=-1;
+ // determine the time for the next timer
+ if (pd->state.skillbonus == 0) {
+ // pet bonuses are not active at the moment, so,
+ pd->state.skillbonus = 1;
+ timer = pd->skillduration; // the duration for pet bonuses to be in effect
+ } else if (pd->state.skillbonus == 1) {
+ // pet bonuses are already active, so,
+ pd->state.skillbonus = 0;
+ timer = pd->skilltimer; // the duration which pet bonuses will be reactivated again
+ }
- pc_bonus(sd,pd->skillbonustype,-pd->skillbonusval);
- if(pd->skillbonustype < 56) clif_updatestatus(sd,pd->skillbonustype);
+ if (pd->state.skillbonus == 1 && sd->petDB)
+ run_script(sd->petDB->script,0,sd->bl.id,0);
- pet_skill_bonus(sd,pd,pd->skillbonustype,pd->skillbonusval,pd->skillduration,pd->skilltimer,0);
+ // add/remove our bonuses, which will be handled by sd->petbonus[]
+ status_calc_pc(sd, 0);
+ // wait for the next timer
+ if (timer) pd->skillbonustimer=add_timer(gettick()+timer,pet_skill_bonus_timer,sd->bl.id,0);
+
return 0;
}
@@ -1693,7 +1669,6 @@ int do_init_pet(void)
add_timer_func_list(pet_hungry,"pet_hungry");
add_timer_func_list(pet_ai_hard,"pet_ai_hard");
add_timer_func_list(pet_skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris]
- add_timer_func_list(pet_skill_bonus_duration,"pet_skill_bonus_duration"); // [Valaris]
add_timer_func_list(pet_recovery_timer,"pet_recovery_timer"); // [Valaris]
add_timer_func_list(pet_mag_timer,"pet_mag_timer"); // [Valaris]
add_timer_func_list(pet_heal_timer,"pet_heal_timer"); // [Valaris]