summaryrefslogtreecommitdiff
path: root/src/map/pet.c
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-24 13:33:36 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-24 13:33:36 +0000
commit8cb6244382cb6e1bb8b2edd13bba6b91f9c67b1f (patch)
tree8f7a613a82dbc47716983718bfaf8bbf2f69793c /src/map/pet.c
parent9ef83b403e59be7824e55e2526b5163bdf17f2b6 (diff)
downloadhercules-8cb6244382cb6e1bb8b2edd13bba6b91f9c67b1f.tar.gz
hercules-8cb6244382cb6e1bb8b2edd13bba6b91f9c67b1f.tar.bz2
hercules-8cb6244382cb6e1bb8b2edd13bba6b91f9c67b1f.tar.xz
hercules-8cb6244382cb6e1bb8b2edd13bba6b91f9c67b1f.zip
- Implemented unit_calc_pos (copy from pet_calc_pos) to implement it on Mercenary/Homunculus and don't use x,y-1 always.
- Implemented Mercenary walk to master (same packet as Homunculus). - Starting work on Stats but i will need lot of help. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13121 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pet.c')
-rw-r--r--src/map/pet.c57
1 files changed, 2 insertions, 55 deletions
diff --git a/src/map/pet.c b/src/map/pet.c
index f439c793f..3c3d33d1d 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -56,59 +56,6 @@ int pet_hungry_val(struct pet_data *pd)
return 0;
}
-static int pet_calc_pos(struct pet_data *pd,int tx,int ty,int dir)
-{
- int x,y,dx,dy;
- int i,k;
-
- nullpo_retr(0, pd);
-
- pd->ud.to_x = tx;
- pd->ud.to_y = ty;
-
- if(dir < 0 || dir >= 8)
- return 1;
-
- dx = -dirx[dir]*2;
- dy = -diry[dir]*2;
- x = tx + dx;
- y = ty + dy;
- if(!unit_can_reach_pos(&pd->bl,x,y,0)) {
- if(dx > 0) x--;
- else if(dx < 0) x++;
- if(dy > 0) y--;
- else if(dy < 0) y++;
- if(!unit_can_reach_pos(&pd->bl,x,y,0)) {
- for(i=0;i<12;i++) {
- k = rand()%8;
- dx = -dirx[k]*2;
- dy = -diry[k]*2;
- x = tx + dx;
- y = ty + dy;
- if(unit_can_reach_pos(&pd->bl,x,y,0))
- break;
- else {
- if(dx > 0) x--;
- else if(dx < 0) x++;
- if(dy > 0) y--;
- else if(dy < 0) y++;
- if(unit_can_reach_pos(&pd->bl,x,y,0))
- break;
- }
- }
- if(i>=12) {
- x = tx;
- y = ty;
- if(!unit_can_reach_pos(&pd->bl,x,y,0))
- return 1;
- }
- }
- }
- pd->ud.to_x = x;
- pd->ud.to_y = y;
- return 0;
-}
-
int pet_create_egg(struct map_session_data *sd, int item_id)
{
int pet_id = search_petDB_index(item_id, PET_EGG);
@@ -392,7 +339,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
pd->bl.m = sd->bl.m;
pd->bl.x = sd->bl.x;
pd->bl.y = sd->bl.y;
- pet_calc_pos(pd,sd->bl.x,sd->bl.y,sd->ud.dir);
+ unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
pd->bl.x = pd->ud.to_x;
pd->bl.y = pd->ud.to_y;
pd->bl.id = npc_get_new_npc_id();
@@ -920,7 +867,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
if(pd->ud.walktimer != -1 && check_distance_blxy(&sd->bl, pd->ud.to_x,pd->ud.to_y, 3))
return 0; //Already walking to him
- pet_calc_pos(pd,sd->bl.x,sd->bl.y,sd->ud.dir);
+ unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
if(!unit_walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0))
pet_randomwalk(pd,tick);