summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-16 19:30:28 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-16 19:30:28 +0000
commit6196f0e6d34dba214a1598d7df7ab2f07b860a07 (patch)
treedb3fff0e89fab29becb961f39b968751a78cd6a2 /src/map
parent8d048f50359a01b56e1224ff8664f0a22ee8821d (diff)
downloadhercules-6196f0e6d34dba214a1598d7df7ab2f07b860a07.tar.gz
hercules-6196f0e6d34dba214a1598d7df7ab2f07b860a07.tar.bz2
hercules-6196f0e6d34dba214a1598d7df7ab2f07b860a07.tar.xz
hercules-6196f0e6d34dba214a1598d7df7ab2f07b860a07.zip
- Modified the "guardian" spawn script command, it no longer receives a "amount" argument (since that only leads to trouble), if the class is negative, it'll pick a random class the same way the monster spawn script command does, and if you pass a spawn position with coordinates equal or less to 0, a random spot in the map will be taken. However you can't use "this" as a map name anymore since these script commands do not need an attached player.
- Guardian spawning will now fail if you attempt to spawn a guardian that already exists on the same position. - Collapsed clif_party_main_info and clif_party_join_info into a single function: clif_party_member_info - Collapsed config settings "sg_miracle_skill_min_duration" and "sg_miracle_skill_max_duration" into "sg_miracle_skill_duration", which defaults to an hour. - Miracle of the Sun, Moon and Stars can now retrigger to lenghten it's effect, and it is cancelled on warp/map-change. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9871 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c1
-rw-r--r--src/map/battle.c17
-rw-r--r--src/map/battle.h3
-rw-r--r--src/map/clif.c49
-rw-r--r--src/map/clif.h3
-rw-r--r--src/map/mob.c75
-rw-r--r--src/map/mob.h3
-rw-r--r--src/map/party.c8
-rw-r--r--src/map/script.c24
-rw-r--r--src/map/unit.c11
10 files changed, 74 insertions, 120 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 8382d6e14..e4fb32e80 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -7670,7 +7670,6 @@ int atcommand_changeleader(const int fd, struct map_session_data* sd, const char
intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
//Update info.
- clif_party_main_info(p,-1);
clif_party_info(p,NULL);
return 0;
diff --git a/src/map/battle.c b/src/map/battle.c
index eb20c1c43..e1db71d4f 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3839,8 +3839,7 @@ static const struct battle_data_int {
{ "night_duration", &battle_config.night_duration }, // added by [Yor]
{ "max_heal", &battle_config.max_heal },
{ "mob_remove_delay", &battle_config.mob_remove_delay },
- { "sg_miracle_skill_min_duration", &battle_config.sg_miracle_skill_duration_min },
- { "sg_miracle_skill_max_duration", &battle_config.sg_miracle_skill_duration_max },
+ { "sg_miracle_skill_duration", &battle_config.sg_miracle_skill_duration },
{ "hvan_explosion_intimate", &battle_config.hvan_explosion_intimate }, //[orn]
};
@@ -4220,8 +4219,7 @@ void battle_set_defaults() {
battle_config.mob_max_sc_def = 5000;
battle_config.sg_miracle_skill_ratio=1;
battle_config.sg_angel_skill_ratio=1;
- battle_config.sg_miracle_skill_duration_min=3000000;
- battle_config.sg_miracle_skill_duration_max=9000000;
+ battle_config.sg_miracle_skill_duration=3600000;
battle_config.autospell_stacking = 0;
battle_config.override_mob_names = 0;
battle_config.min_chat_delay = 0;
@@ -4398,18 +4396,7 @@ void battle_validate_conf() {
if (battle_config.sg_miracle_skill_ratio > 10000)
battle_config.sg_miracle_skill_ratio = 10000;
-
- if (battle_config.sg_miracle_skill_duration_min < 1000)
- battle_config.sg_miracle_skill_duration_min = 1000;
-
- //Store duration variation in the max setting
- battle_config.sg_miracle_skill_duration_max -=
- battle_config.sg_miracle_skill_duration_min;
-
- if (battle_config.sg_miracle_skill_duration_max < 2000)
- battle_config.sg_miracle_skill_duration_max = 2000;
-
if (battle_config.skill_steal_max_tries >= UCHAR_MAX)
battle_config.skill_steal_max_tries = UCHAR_MAX;
diff --git a/src/map/battle.h b/src/map/battle.h
index 6d2d8a7db..12e217218 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -425,8 +425,7 @@ extern struct Battle_Config {
unsigned short sg_angel_skill_ratio;
unsigned short sg_miracle_skill_ratio;
- int sg_miracle_skill_duration_min;
- int sg_miracle_skill_duration_max;
+ int sg_miracle_skill_duration;
unsigned short autospell_stacking; //Enables autospell cards to stack. [Skotlex]
unsigned short override_mob_names; //Enables overriding spawn mob names with the mob_db names. [Skotlex]
unsigned short min_chat_delay; //Minimum time between client messages. [Skotlex]
diff --git a/src/map/clif.c b/src/map/clif.c
index 9a7d941f2..a10a27501 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -5681,56 +5681,27 @@ int clif_party_created(struct map_session_data *sd,int flag)
return 0;
}
-int clif_party_main_info(struct party_data *p, int fd)
+int clif_party_member_info(struct party_data *p, struct map_session_data *sd)
{
- struct map_session_data *sd;
- int i;
unsigned char buf[96];
-
- for (i=0; i<MAX_PARTY && !p->party.member[i].leader; i++);
- if (i >= MAX_PARTY) return 0; //Should never happen...
- sd = p->data[i].sd;
- WBUFW(buf,0)=0x1e9;
- WBUFL(buf,2)= p->party.member[i].account_id;
- WBUFL(buf,6)= 0; //We don't know yet what this long is about.
- WBUFW(buf,10)=sd?sd->bl.x:0;
- WBUFW(buf,12)=sd?sd->bl.y:0;
- WBUFB(buf,14)=(p->party.member[i].online)?0:1; //This byte is also unconfirmed...
- memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
- memcpy(WBUFP(buf,39), p->party.member[i].name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), mapindex_id2name(p->party.member[i].map), MAP_NAME_LENGTH);
- WBUFB(buf,79) = (p->party.item&1)?1:0;
- WBUFB(buf,80) = (p->party.item&2)?1:0;
- if(fd>=0){
- WFIFOHEAD(fd,packet_len(0x1e9));
- memcpy(WFIFOP(fd,0),buf,packet_len(0x1e9));
- WFIFOSET(fd,packet_len(0x1e9));
- return 1;
- }
- if (!sd) {
- for (i=0; i<MAX_PARTY && !p->data[i].sd; i++)
+ if (!sd) { //Pick any party member (this call is used when changing item share rules)
+ int i;
+ for (i=0; i<MAX_PARTY && !p->data[i].sd; i++);
if (i >= MAX_PARTY) return 0; //Should never happen...
- sd=p->data[i].sd;
+ sd = p->data[i].sd;
}
- clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY);
- return 1;
-}
-
-int clif_party_join_info(struct party *p, struct map_session_data *sd)
-{
- unsigned char buf[96];
WBUFW(buf,0)=0x1e9;
WBUFL(buf,2)= sd->status.account_id;
WBUFL(buf,6)= 0; //Apparently setting this to 1 makes you adoptable.
WBUFW(buf,10)=sd->bl.x;
WBUFW(buf,12)=sd->bl.y;
- WBUFB(buf,14)=0; //Unconfirmed byte.
- memcpy(WBUFP(buf,15), p->name, NAME_LENGTH);
+ WBUFB(buf,14)=0; //Unconfirmed byte, could be online/offline.
+ memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
memcpy(WBUFP(buf,63), mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
- WBUFB(buf,79) = (p->item&1)?1:0;
- WBUFB(buf,80) = (p->item&2)?1:0;
- clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY_WOS);
+ WBUFB(buf,79) = (p->party.item&1)?1:0;
+ WBUFB(buf,80) = (p->party.item&2)?1:0;
+ clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY);
return 1;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index 8f658819a..5ce426f96 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -253,8 +253,7 @@ int clif_movetoattack(struct map_session_data *sd,struct block_list *bl);
// party
int clif_party_created(struct map_session_data *sd,int flag);
-int clif_party_main_info(struct party_data *p, int fd);
-int clif_party_join_info(struct party *p, struct map_session_data *sd);
+int clif_party_member_info(struct party_data *p, struct map_session_data *sd);
int clif_party_info(struct party_data *p, struct map_session_data *sd);
int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd);
int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag);
diff --git a/src/map/mob.c b/src/map/mob.c
index 783248742..cc2fa146f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -456,28 +456,30 @@ static int mob_spawn_guardian_sub(int tid,unsigned int tick,int id,int data)
* Summoning Guardians [Valaris]
*------------------------------------------
*/
-int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
- int x,int y,const char *mobname,int class_,int amount,const char *event,int guardian)
+int mob_spawn_guardian(char *mapname,short x,short y,const char *mobname,int class_,const char *event,int guardian)
{
struct mob_data *md=NULL;
struct spawn_data data;
struct guild *g=NULL;
struct guild_castle *gc;
- int m, count;
+ int m;
memset(&data, 0, sizeof(struct spawn_data));
data.num = 1;
- if( sd && strcmp(mapname,"this")==0)
- m=sd->bl.m;
- else
- m=map_mapname2mapid(mapname);
+ m=map_mapname2mapid(mapname);
- if(m<0 || amount<=0)
+ if(m<0)
+ {
+ ShowWarning("mob_spawn_guardian: Map [%s] not found.\n", mapname);
return 0;
+ }
data.m = m;
- data.num = amount;
- if(class_<0)
- return 0;
+ data.num = 1;
+ if(class_<=0) {
+ class_ = mob_get_random_id(-class_-1, 1, 99);
+ if (!class_) return 0;
+ }
+
data.class_ = class_;
if(guardian < 0 || guardian >= MAX_GUARDIANS)
@@ -485,15 +487,12 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
ShowError("mob_spawn_guardian: Invalid guardian index %d for guardian %d (castle map %s)\n", guardian, class_, map[m].name);
return 0;
}
- if (amount > 1)
- ShowWarning("mob_spawn_guardian: Spawning %d guardians in position %d (castle map %s)\n", amount, map[m].name);
- if(sd){
- if(x<=0) x=sd->bl.x;
- if(y<=0) y=sd->bl.y;
+ if((x<=0 || y<=0) && !map_search_freecell(NULL, m, &x, &y, -1,-1, 0))
+ {
+ ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, map[m].name);
+ return 0;
}
- else if(x<=0 || y<=0)
- ShowWarning("mob_spawn_guardian: Invalid coordinates (%d,%d)\n",x,y);
data.x = x;
data.y = y;
strncpy(data.name, mobname, NAME_LENGTH-1);
@@ -513,26 +512,32 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
g = guild_search(gc->guild_id);
if (gc->guardian[guardian].id)
- ShowWarning("mob_spawn_guardian: Spawning guardian in position %d which already has a guardian (castle map %s)\n", guardian, map[m].name);
-
- for(count=0;count<data.num;count++){
- md= mob_spawn_dataset(&data);
- md->guardian_data = aCalloc(1, sizeof(struct guardian_data));
- md->guardian_data->number = guardian;
- md->guardian_data->guild_id = gc->guild_id;
- md->guardian_data->castle = gc;
- gc->guardian[guardian].id = md->bl.id;
- if (g)
+ { //Check if guardian already exists, refuse to spawn if so.
+ struct mob_data *md2 = (TBL_MOB*)map_id2bl(gc->guardian[guardian].id);
+ if (md2 && md2->bl.type == BL_MOB &&
+ md2->guardian_data && md2->guardian_data->number == guardian)
{
- md->guardian_data->emblem_id = g->emblem_id;
- memcpy (md->guardian_data->guild_name, g->name, NAME_LENGTH);
- md->guardian_data->guardup_lv = guild_checkskill(g,GD_GUARDUP);
- } else if (md->guardian_data->guild_id)
- add_timer(gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
- mob_spawn(md);
+ ShowError("mob_spawn_guardian: Attempted to spawn guardian in position %d which already has a guardian (castle map %s)\n", guardian, map[m].name);
+ return 0;
+ }
}
- return (amount>0)?md->bl.id:0;
+ md= mob_spawn_dataset(&data);
+ md->guardian_data = aCalloc(1, sizeof(struct guardian_data));
+ md->guardian_data->number = guardian;
+ md->guardian_data->guild_id = gc->guild_id;
+ md->guardian_data->castle = gc;
+ gc->guardian[guardian].id = md->bl.id;
+ if (g)
+ {
+ md->guardian_data->emblem_id = g->emblem_id;
+ memcpy (md->guardian_data->guild_name, g->name, NAME_LENGTH);
+ md->guardian_data->guardup_lv = guild_checkskill(g,GD_GUARDUP);
+ } else if (md->guardian_data->guild_id)
+ add_timer(gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
+ mob_spawn(md);
+
+ return md->bl.id;
}
/*==========================================
diff --git a/src/map/mob.h b/src/map/mob.h
index 0828629bd..f13cce8da 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -157,8 +157,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
int x0,int y0,int x1,int y1,
const char *mobname,int class_,int amount,const char *event);
-int mob_spawn_guardian(struct map_session_data *sd,char *mapname, // Spawning Guardians [Valaris]
- int x,int y,const char *mobname,int class_,int amount,const char *event,int guardian); // Spawning Guardians [Valaris]
+int mob_spawn_guardian(char *mapname,short x,short y,const char *mobname,int class_,const char *event,int guardian); // Spawning Guardians [Valaris]
int mob_guardian_guildchange(struct block_list *bl,va_list ap); //Change Guardian's ownership. [Skotlex]
int mob_randomwalk(struct mob_data *md,int tick);
diff --git a/src/map/party.c b/src/map/party.c
index dfa8c0e9e..5b9e19497 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -242,7 +242,7 @@ int party_recv_info(struct party *sp)
sd = p->data[i].sd;
if(!sd || sd->state.party_sent)
continue;
- clif_party_main_info(p,-1);
+ clif_party_member_info(p,sd);
clif_party_option(p,sd,0x100);
clif_party_info(p,NULL);
sd->state.party_sent=1;
@@ -339,7 +339,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
sd->state.party_sent=0;
sd->status.party_id=party_id;
party_check_conflict(sd);
- clif_party_join_info(&p->party,sd);
+ clif_party_member_info(p,sd);
clif_party_hp(sd);
clif_party_xy(sd);
clif_charnameupdate(sd); //Update char name's display [Skotlex]
@@ -472,7 +472,7 @@ int party_optionchanged(int party_id,int account_id,int exp,int item,int flag)
}
if(!(flag&0x10) && p->party.item != item) {
p->party.item=item;
- clif_party_main_info(p,-1);
+ clif_party_member_info(p,sd);
}
if(flag&0x01) //Send denied message
clif_party_option(p,sd,flag);
@@ -538,7 +538,7 @@ void party_send_movemap(struct map_session_data *sd)
if(p){
party_check_member(&p->party);
if(sd->status.party_id==p->party.party_id){
- clif_party_main_info(p,sd->fd);
+ clif_party_member_info(p,sd);
clif_party_option(p,sd,0x100);
clif_party_info(p,sd);
sd->state.party_sent=1;
diff --git a/src/map/script.c b/src/map/script.c
index a211bf73b..e64034276 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4010,7 +4010,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(soundeffect,"si"),
BUILDIN_DEF(soundeffectall,"si*"), // SoundEffectAll [Codemaster]
BUILDIN_DEF(strmobinfo,"ii"), // display mob data [Valaris]
- BUILDIN_DEF(guardian,"siisii??"), // summon guardians
+ BUILDIN_DEF(guardian,"siisi??"), // summon guardians
BUILDIN_DEF(guardianinfo,"i"), // display guardian data [Valaris]
BUILDIN_DEF(petskillbonus,"iiii"), // [Valaris]
BUILDIN_DEF(petrecovery,"ii"), // [Valaris]
@@ -9626,12 +9626,12 @@ BUILDIN_FUNC(strmobinfo)
/*==========================================
* Summon guardians [Valaris]
- * guardian "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"}{,<guardian index>};
+ * guardian "<map name>",<x>,<y>,"<name to show>",<mob id>,{,"<event label>"}{,<guardian index>};
*------------------------------------------
*/
BUILDIN_FUNC(guardian)
{
- int class_=0,amount=1,x=0,y=0,guardian=0;
+ int class_=0,x=0,y=0,guardian=0;
char *str,*map,*evt="";
struct script_data *data;
@@ -9640,21 +9640,20 @@ BUILDIN_FUNC(guardian)
y =conv_num(st,script_getdata(st,4));
str =conv_str(st,script_getdata(st,5));
class_=conv_num(st,script_getdata(st,6));
- amount=conv_num(st,script_getdata(st,7));
- if( script_hasdata(st,9) )
+ if( script_hasdata(st,8) )
{// "<event label>",<guardian index>
- evt=conv_str(st,script_getdata(st,8));
- guardian=conv_num(st,script_getdata(st,9));
- } else if( script_hasdata(st,8) ){
- data=script_getdata(st,8);
+ evt=conv_str(st,script_getdata(st,7));
+ guardian=conv_num(st,script_getdata(st,8));
+ } else if( script_hasdata(st,7) ){
+ data=script_getdata(st,7);
get_val(st,data);
if( data_isstring(data) )
{// "<event label>"
- evt=conv_str(st,script_getdata(st,8));
+ evt=conv_str(st,script_getdata(st,7));
} else if( data_isint(data) )
{// <guardian index>
- guardian=conv_num(st,script_getdata(st,8));
+ guardian=conv_num(st,script_getdata(st,7));
} else {
ShowError("buildin_guardian: invalid data type for argument #8 (%d).", data->type);
report_src(st);
@@ -9663,8 +9662,7 @@ BUILDIN_FUNC(guardian)
}
check_event(st, evt);
-
- mob_spawn_guardian(map_id2sd(st->rid),map,x,y,str,class_,amount,evt,guardian);
+ mob_spawn_guardian(map,x,y,str,class_,evt,guardian);
return 0;
}
diff --git a/src/map/unit.c b/src/map/unit.c
index 7383aed1c..80e0137cf 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -183,15 +183,10 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
}
if (
(sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR &&
- sd->sc.data[SC_MIRACLE].timer==-1 &&
!(ud->walk_count%WALK_SKILL_INTERVAL) &&
rand()%10000 < battle_config.sg_miracle_skill_ratio
- ) { //SG_MIRACLE [Komurka]
- clif_displaymessage(sd->fd,"[Miracle of the Sun, Moon and Stars]");
- sc_start(&sd->bl,SC_MIRACLE,100,1,
- battle_config.sg_miracle_skill_duration_min+
- rand()%battle_config.sg_miracle_skill_duration_max);
- }
+ ) //SG_MIRACLE [Komurka]
+ sc_start(&sd->bl,SC_MIRACLE,100,1,battle_config.sg_miracle_skill_duration);
} else if (md) {
if(battle_config.mob_warp&1 && map_getcell(bl->m,x,y,CELL_CHKNPC) &&
npc_touch_areanpc2(bl)) // Enable mobs to step on warps. [Skotlex]
@@ -1656,6 +1651,8 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
status_change_end(bl, SC_GOSPEL, -1);
if (sc->data[SC_CHANGE].timer!=-1)
status_change_end(bl, SC_CHANGE, -1);
+ if (sc->data[SC_MIRACLE].timer!=-1)
+ status_change_end(bl, SC_MIRACLE, -1);
}
if (bl->type&BL_CHAR) {