summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-22 18:08:37 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-22 18:08:37 +0000
commit66be3d8e66260ca148d768b887695729ded98abb (patch)
treec33bb1ccfd358b98cec22e750a395285ba5df31e /src/map/mob.c
parent23d8fb13a79b0378db2ef6860d9b0b68cfacb9d6 (diff)
downloadhercules-66be3d8e66260ca148d768b887695729ded98abb.tar.gz
hercules-66be3d8e66260ca148d768b887695729ded98abb.tar.bz2
hercules-66be3d8e66260ca148d768b887695729ded98abb.tar.xz
hercules-66be3d8e66260ca148d768b887695729ded98abb.zip
- Corrected mob spawn utilization of the delay1/delay2 values (one is respawn delay base, the second is random variance added on top of it). Cleaned up related code.
- Changed abit map_add_block to prevent adding a player object which is invalid (not authed, waiting to be disconnected) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11964 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 1c28584d3..9830dff0e 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -612,24 +612,19 @@ static int mob_delayspawn(int tid, unsigned int tick, int m, int n)
*------------------------------------------*/
int mob_setdelayspawn(struct mob_data *md)
{
- unsigned int spawntime, spawntime1, spawntime2, spawntime3;
-
+ unsigned int spawntime;
if (!md->spawn) //Doesn't has respawn data!
return unit_free(&md->bl,1);
- spawntime1 = md->last_spawntime + md->spawn->delay1;
- spawntime2 = md->last_deadtime + md->spawn->delay2;
- spawntime3 = gettick() + 5000 + rand()%5000; //Lupus
- // spawntime = max(spawntime1,spawntime2,spawntime3);
- if (DIFF_TICK(spawntime1, spawntime2) > 0)
- spawntime = spawntime1;
- else
- spawntime = spawntime2;
- if (DIFF_TICK(spawntime3, spawntime) > 0)
- spawntime = spawntime3;
+ spawntime = md->spawn->delay1; //Base respawn time
+ if (md->spawn->delay2) //random variance
+ spawntime+= rand()%md->spawn->delay2;
+
+ if (spawntime < 5000) //Min respawn time (is it needed?)
+ spawntime = 5000;
- add_timer(spawntime, mob_delayspawn, md->bl.id, 0);
+ add_timer(gettick()+spawntime, mob_delayspawn, md->bl.id, 0);
return 0;
}
@@ -646,7 +641,6 @@ int mob_spawn (struct mob_data *md)
int i=0;
unsigned int c =0, tick = gettick();
- md->last_spawntime = md->last_thinktime = tick;
if (md->bl.prev != NULL)
unit_remove_map(&md->bl,2);
else
@@ -2221,7 +2215,6 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
mob_deleteslave(md);
- md->last_deadtime=tick;
map_freeblock_unlock();