diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-08 17:56:31 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-08 17:56:31 +0000 |
commit | 2de9fa2b9bcc944a5671a1965813a56b1e1dfd5c (patch) | |
tree | 14a7873c785ec04068a85dc4148e349d32d2e6a3 /src/map/mob.c | |
parent | 74c9a56b7aa52fff54fa4a34a2f31910307b37eb (diff) | |
download | hercules-2de9fa2b9bcc944a5671a1965813a56b1e1dfd5c.tar.gz hercules-2de9fa2b9bcc944a5671a1965813a56b1e1dfd5c.tar.bz2 hercules-2de9fa2b9bcc944a5671a1965813a56b1e1dfd5c.tar.xz hercules-2de9fa2b9bcc944a5671a1965813a56b1e1dfd5c.zip |
- Fixed @movenpc
- Cleaned up and improved the lootsearch routine to pick nearest item.
- Added INVISIBLE_CLASS to the list of classes supported by npc_get_viewdata
- Fixed trying to set the view_data for npcs who are located on a map, but have no visual data.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5959 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r-- | src/map/mob.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 68addb39c..f717f4f50 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -888,19 +888,17 @@ static int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
{
struct mob_data* md;
- int dist,*itc;
+ struct block_list **target;
+ int dist;
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, md=va_arg(ap,struct mob_data *));
- nullpo_retr(0, itc=va_arg(ap,int *));
+ md=va_arg(ap,struct mob_data *);
+ target= va_arg(ap,struct block_list**);
- if(!md->lootitem || (battle_config.monster_loot_type == 1 && md->lootitem_count >= LOOTITEM_SIZE))
- return 0;
-
if((dist=distance_bl(&md->bl, bl)) < md->db->range2 &&
- mob_can_reach(md,bl,dist, MSS_LOOT) && rand()%1000<1000/(++(*itc)))
- { // It is made a probability, such as within the limits PC.
+ mob_can_reach(md,bl,dist, MSS_LOOT) &&
+ ((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) //New target closer than previous one.
+ ) {
+ (*target) = bl;
md->target_id=bl->id;
md->min_chase=md->db->range3;
md->next_walktime = gettick() + 500; //So that the mob may go after the item inmediately.
@@ -1216,9 +1214,8 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) } else if (!tbl && mode&MD_LOOTER && md->lootitem &&
(md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1))
{ // Scan area for items to loot, avoid trying to loot of the mob is full and can't consume the items.
- i = 0;
map_foreachinrange (mob_ai_sub_hard_lootsearch, &md->bl,
- view_range, BL_ITEM, md, &i);
+ view_range, BL_ITEM, md, &tbl);
}
if (tbl)
|