summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-08 01:55:58 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-08 01:55:58 +0000
commit12c59ee92f231545497b901bf16fee77f080bfea (patch)
treea5ac684163795a0ab89a1164066c5ea3fe7d75a9 /src
parentf325738db0ff69176476cac7f11e0460bfdbcba4 (diff)
downloadhercules-12c59ee92f231545497b901bf16fee77f080bfea.tar.gz
hercules-12c59ee92f231545497b901bf16fee77f080bfea.tar.bz2
hercules-12c59ee92f231545497b901bf16fee77f080bfea.tar.xz
hercules-12c59ee92f231545497b901bf16fee77f080bfea.zip
- Fixed some missing max levels for npc skills
- Expanded isloggedin script command to support an optional argument (char id) - Expanded warpparty command to accept target "Leader", this will warp the party to the leader. - Added a summon structure to handle non-dead-branch mob-groups since the current implementation totally fails for mob groups that don't have MANY integrants - Fixed mobs not attempting an IDLE skill right before unlocking a target. - Removed a useless variable in the pet_data structure git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10961 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/mob.c36
-rw-r--r--src/map/script.c29
3 files changed, 56 insertions, 10 deletions
diff --git a/src/map/map.h b/src/map/map.h
index 6fca83945..745e2013c 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -981,7 +981,6 @@ struct pet_data {
struct pet_db *petDB;
int pet_hungry_timer;
int target_id;
- short n;
struct {
unsigned skillbonus : 1;
} state;
diff --git a/src/map/mob.c b/src/map/mob.c
index 60c5ad603..a7c8f878c 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -56,6 +56,12 @@ struct mob_db *mob_db(int index) { if (index < 0 || index > MAX_MOB_DB || mob_db
static struct eri *item_drop_ers; //For loot drops delay structures.
static struct eri *item_drop_list_ers;
+
+static struct {
+ int qty;
+ int class_[150];
+} summon[MAX_RANDOMMONSTER];
+
#define CLASSCHANGE_BOSS_NUM 21
/*==========================================
@@ -249,7 +255,10 @@ int mob_get_random_id(int type, int flag, int lv)
return 0;
}
do {
- class_ = rand() % MAX_MOB_DB;
+ if (type)
+ class_ = summon[type].class_[rand()%summon[type].qty];
+ else //Dead branch
+ class_ = rand() % MAX_MOB_DB;
mob = mob_db(class_);
} while ((mob == mob_dummy ||
mob_is_clone(class_) ||
@@ -986,7 +995,7 @@ int mob_unlocktarget(struct mob_data *md,int tick)
md->state.skillstate = MSS_IDLE;
case MSS_IDLE:
// Idle skill.
- if (!(++md->ud.walk_count%IDLE_SKILL_INTERVAL) &&
+ if ((md->target_id || !(++md->ud.walk_count%IDLE_SKILL_INTERVAL)) &&
mobskill_use(md, tick, -1))
break;
//Random walk.
@@ -3555,6 +3564,8 @@ static int mob_read_randommonster(void)
"mob_boss.txt",
"mob_pouch.txt"};
+ memset(&summon, 0, sizeof(summon));
+
for(i=0;i<MAX_RANDOMMONSTER;i++){
mob_db_data[0]->summonper[i] = 1002; // 設定し忘れた場合はポリンが出るようにしておく
sprintf(line, "%s/%s", db_path, mobfile[i]);
@@ -3565,7 +3576,7 @@ static int mob_read_randommonster(void)
}
while(fgets(line, sizeof(line), fp))
{
- int class_,per;
+ int class_;
if(line[0] == '/' && line[1] == '/')
continue;
memset(str,0,sizeof(str));
@@ -3579,9 +3590,22 @@ static int mob_read_randommonster(void)
continue;
class_ = atoi(str[0]);
- per=atoi(str[2]);
- if(mob_db(class_) != mob_dummy)
- mob_db_data[class_]->summonper[i]=per;
+ if(mob_db(class_) == mob_dummy)
+ continue;
+ mob_db_data[class_]->summonper[i]=atoi(str[2]);
+ if (i) {
+ if (summon[i].qty < sizeof(summon[i].class_)/sizeof(summon[i].class_[0])) //MvPs
+ summon[i].class_[summon[i].qty++] = class_;
+ else {
+ ShowDebug("Can't store more random mobs from %s, increase size of mob.c:summon variable!\n", mobfile[i]);
+ break;
+ }
+ }
+ }
+ if (i && !summon[i].qty)
+ { //At least have the default here.
+ summon[i].class_[0] = mob_db_data[0]->summonper[i];
+ summon[i].qty = 1;
}
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n",mobfile[i]);
diff --git a/src/map/script.c b/src/map/script.c
index 54866ba5d..ec68e2b9f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4215,7 +4215,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(warpwaitingpc,"sii?"),
BUILDIN_DEF(attachrid,"i"),
BUILDIN_DEF(detachrid,""),
- BUILDIN_DEF(isloggedin,"i"),
+ BUILDIN_DEF(isloggedin,"i?"),
BUILDIN_DEF(setmapflagnosave,"ssii"),
BUILDIN_DEF(setmapflag,"si*"),
BUILDIN_DEF(removemapflag,"si"),
@@ -5118,6 +5118,26 @@ BUILDIN_FUNC(warpparty)
}
}
}
+ else if(strcmp(str,"Leader")==0)
+ {
+ for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
+ if (i == MAX_PARTY || !p->data[i].sd) //Leader not found / not online
+ return 0;
+ if(map[p->data[i].sd->bl.m].flag.nowarpto)
+ return 0;
+ mapindex = p->data[i].sd->mapindex;
+ x = p->data[i].sd->bl.x;
+ y = p->data[i].sd->bl.y;
+ for (i = 0; i < MAX_PARTY; i++)
+ {
+ pl_sd = p->data[i].sd;
+ if (!pl_sd)
+ continue;
+ if(map[pl_sd->bl.m].flag.noreturn || map[pl_sd->bl.m].flag.nowarp)
+ continue;
+ pc_setpos(pl_sd,mapindex,x,y,3);
+ }
+ }
else
{
mapindex = mapindex_name2id(str);
@@ -9195,8 +9215,11 @@ BUILDIN_FUNC(detachrid)
*------------------------------------------*/
BUILDIN_FUNC(isloggedin)
{
- push_val(st->stack,C_INT, map_id2sd(
- script_getnum(st,2) )!=NULL );
+ TBL_PC* sd = map_id2sd(script_getnum(st,2));
+ if (script_hasdata(st,3) && sd &&
+ sd->status.char_id != script_getnum(st,3))
+ sd = NULL;
+ push_val(st->stack,C_INT,sd!=NULL);
return 0;
}