summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-03 02:51:45 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-03 02:51:45 +0000
commitdd90153762be1de239e2e6d244dd25d50e5c2fe4 (patch)
tree75a2e3b38d74a859b731357bcfd03a1ebdfa138f /src
parent6c1bf412e2ed8a8578c55149dd64e3755499f2af (diff)
downloadhercules-dd90153762be1de239e2e6d244dd25d50e5c2fe4.tar.gz
hercules-dd90153762be1de239e2e6d244dd25d50e5c2fe4.tar.bz2
hercules-dd90153762be1de239e2e6d244dd25d50e5c2fe4.tar.xz
hercules-dd90153762be1de239e2e6d244dd25d50e5c2fe4.zip
- Added the skill-related variables to pet_data, removed the pet skill delay structure.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5440 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c3
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/pet.c57
-rw-r--r--src/map/skill.c12
4 files changed, 27 insertions, 48 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 4a5105d84..f985f69f2 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -129,8 +129,7 @@ int battle_getcurrentskill(struct block_list *bl)
case BL_MOB:
return ((struct mob_data*)bl)->skillid;
case BL_PET:
- return 0; //Skill data is not stored for pets...
- break;
+ return ((struct pet_data*)bl)->skillid;
case BL_SKILL:
{
struct skill_unit * su = (struct skill_unit*)bl;
diff --git a/src/map/map.h b/src/map/map.h
index ddbb776ee..a7a10c168 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -950,6 +950,9 @@ struct pet_data {
struct skill_unit_group skillunit[MAX_MOBSKILLUNITGROUP]; // [Valaris]
struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET]; // [Valaris]
struct map_session_data *msd;
+
+ int skilltarget;
+ short skillx,skilly,skillid,skilllv;
};
enum { MS_IDLE,MS_WALK,MS_ATTACK,MS_DEAD,MS_DELAY };
diff --git a/src/map/pet.c b/src/map/pet.c
index 77df949b2..edbe3d5dc 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -206,7 +206,7 @@ static int pet_attack(struct pet_data *pd,unsigned int tick,int data)
}
static int petskill_castend(struct pet_data *pd,unsigned int tick,int data);
-static int petskill_castend2(struct pet_data *pd, struct block_list *target, short skill_id, short skill_lv, short skill_x, short skill_y, unsigned int tick);
+static int petskill_castend2(struct pet_data *pd, struct block_list *target, unsigned int tick);
/*==========================================
* Pet Attack Skill [Skotlex]
@@ -232,14 +232,6 @@ static int pet_attackskill(struct pet_data *pd, unsigned int tick, int data)
return 0;
}
-struct castend_delay { //[Skotlex] For passing skill info after casting
- struct pet_data *src;
- int target;
- short id;
- short lv;
- short x,y;
-};
-
/*==========================================
* Pet Skill Use [Skotlex]
*------------------------------------------
@@ -247,7 +239,6 @@ struct castend_delay { //[Skotlex] For passing skill info after casting
int petskill_use(struct pet_data *pd, struct block_list *target, short skill_id, short skill_lv, unsigned int tick)
{
int casttime;
- struct castend_delay *dat;
nullpo_retr(0, pd);
Assert((pd->msd == 0) || (pd->msd->pd == pd));
@@ -272,27 +263,23 @@ int petskill_use(struct pet_data *pd, struct block_list *target, short skill_id,
pd->attackabletime = tick;
pd->state.state=MS_ATTACK;
+ pd->skilltarget = target->id;
+ pd->skillid = skill_id;
+ pd->skilllv = skill_lv;
+ pd->skillx = target->x;
+ pd->skilly = target->y;
if (casttime > 0)
{
pd->attackabletime += casttime;
-
- dat = (struct castend_delay *)aCalloc(1, sizeof(struct castend_delay));
- dat->src = pd;
- dat->target = target->id;
- dat->id = skill_id;
- dat->lv = skill_lv;
- dat->x = target->x;
- dat->y = target->y;
-
pd->state.casting_flag = 1;
if (skill_get_inf(skill_id) & INF_GROUND_SKILL)
- clif_skillcasting( &pd->bl, pd->bl.id, 0, dat->x, dat->y, skill_id,casttime);
+ clif_skillcasting( &pd->bl, pd->bl.id, 0, pd->skillx, pd->skilly, skill_id,casttime);
else
- clif_skillcasting( &pd->bl, pd->bl.id, dat->target, 0,0, skill_id,casttime);
+ clif_skillcasting( &pd->bl, pd->bl.id, target->id, 0,0, skill_id,casttime);
- pd->timer = add_timer(pd->attackabletime,pet_timer,pd->bl.id,(int)dat);
+ pd->timer = add_timer(pd->attackabletime,pet_timer,pd->bl.id,0);
} else {
- petskill_castend2(pd, target, skill_id, skill_lv, target->x, target->y, tick);
+ petskill_castend2(pd, target, tick);
}
return 0;
}
@@ -303,12 +290,10 @@ int petskill_use(struct pet_data *pd, struct block_list *target, short skill_id,
*/
static int petskill_castend(struct pet_data *pd,unsigned int tick,int data)
{
- struct castend_delay *dat = (struct castend_delay *)data;
- struct block_list *target = map_id2bl(dat->target);
+ struct block_list *target = map_id2bl(pd->skilltarget);
pd->state.casting_flag = 0;
- if (dat && pd == dat->src)
- petskill_castend2(pd, target, dat->id, dat->lv, dat->x, dat->y, tick);
- aFree(dat);
+ pd->skilltarget = 0;
+ petskill_castend2(pd, target, tick);
return 0;
}
@@ -316,23 +301,24 @@ static int petskill_castend(struct pet_data *pd,unsigned int tick,int data)
* Pet Attack Cast End2 [Skotlex]
*------------------------------------------
*/
-static int petskill_castend2(struct pet_data *pd, struct block_list *target, short skill_id, short skill_lv, short skill_x, short skill_y, unsigned int tick)
+static int petskill_castend2(struct pet_data *pd, struct block_list *target, unsigned int tick)
{ //Invoked after the casting time has passed.
int delaytime =0;
-
- nullpo_retr(0, pd);
-
+ int skill_id = pd->skillid, skill_lv = pd->skilllv;
+
pd->state.state=MS_IDLE;
if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
{ //Area skill
- skill_castend_pos2(&pd->bl, skill_x, skill_y, skill_id, skill_lv, tick,0);
+ skill_castend_pos2(&pd->bl, pd->skillx, pd->skilly, pd->skillid, pd->skilllv, tick,0);
+ pd->skillx = pd->skilly = 0;
} else { //Targeted Skill
if (!target)
- return 0;
+ return 0;
if(!check_distance_bl(&pd->bl, target,
skill_get_range2(&pd->bl, skill_id, skill_lv)))
return 0;
+
if (!status_check_skilluse(&pd->bl, target, skill_id, 1))
return 0;
if (skill_get_casttype(skill_id) == CAST_NODAMAGE)
@@ -344,10 +330,11 @@ static int petskill_castend2(struct pet_data *pd, struct block_list *target, sho
if (pd->timer != -1) //The above skill casting could had changed the state (Abracadabra?)
return 0;
+ pd->skillid = pd->skilllv = 0;
delaytime = skill_delayfix(&pd->bl,skill_id, skill_lv, 0);
if (delaytime < MIN_PETTHINKTIME)
delaytime = status_get_adelay(&pd->bl);
- pd->attackabletime = tick + delaytime;
+ pd->attackabletime = tick + delaytime;
if (pd->target_id)
{ //Resume attacking
pd->state.state=MS_ATTACK;
diff --git a/src/map/skill.c b/src/map/skill.c
index 0a08e459e..6d74de30b 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -8863,18 +8863,8 @@ int skill_castcancel (struct block_list *bl, int type)
ShowError("delete timer error : skillid : %d\n", md->skillid);
return 0;
} if (bl->type == BL_PET) {
- struct pet_data *pd = (struct pet_data*)bl;
- pd->state.casting_flag = 0;
+ ((struct pet_data*)bl)->state.casting_flag = 0;
clif_skillcastcancel(bl);
- if (pd->timer != -1)
- { //Free the data attached to casting. [Skotlex]
- struct TimerData *td = get_timer(pd->timer);
- if (td && td->data)
- {
- aFree((struct cast_end_delay*)td->data);
- td->data = 0;
- }
- }
//The timer is not deleted as the pet's attack will be resumed.
return 0;
}