summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-14 23:38:11 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-14 23:38:11 +0000
commit1382b22cd68bf90f2adc4ae13187416982f9a12f (patch)
tree60602ab8f3578407bffbd1859603c3a586c52256 /src
parent78474fe9877675f3fc173f0b7e7235fd6c105067 (diff)
downloadhercules-1382b22cd68bf90f2adc4ae13187416982f9a12f.tar.gz
hercules-1382b22cd68bf90f2adc4ae13187416982f9a12f.tar.bz2
hercules-1382b22cd68bf90f2adc4ae13187416982f9a12f.tar.xz
hercules-1382b22cd68bf90f2adc4ae13187416982f9a12f.zip
Guardian hp handling code removal (see bugreport:342)
- removed guardian hp from the castle data structure, database, savefiles and various script functions (use upgrade_svn11914.sql) - removed guardian hp calculation and manipulation from the castle manager npc, now the hp values are updated by the server itself (glitch: when castle defense changes, all guardians are healed to full) - tweaked script function 'guardianinfo' to provide some data needed by the manager npc (currently available are hp, maxhp and visibility); also, it doesn't need a player attached to execute anymore The whole thing is experimental, use at your own risk (seems to work though...) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11915 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/char/int_guild.c133
-rw-r--r--src/char_sql/int_guild.c48
-rw-r--r--src/common/mmo.h5
-rw-r--r--src/map/battle.c4
-rw-r--r--src/map/guild.c43
-rw-r--r--src/map/map.c6
-rw-r--r--src/map/map.h7
-rw-r--r--src/map/mob.c13
-rw-r--r--src/map/script.c77
-rw-r--r--src/map/status.c7
10 files changed, 103 insertions, 240 deletions
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 7112666ce..1e47d9fb2 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -309,13 +309,11 @@ int inter_guildcastle_tostr(char *str, struct guild_castle *gc)
{
int len;
- len = sprintf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", // added Guardian HP [Valaris]
+ len = sprintf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE,
gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC,
gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible,
- gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible,
- gc->guardian[0].hp, gc->guardian[1].hp, gc->guardian[2].hp, gc->guardian[3].hp,
- gc->guardian[4].hp, gc->guardian[5].hp, gc->guardian[6].hp, gc->guardian[7].hp);
+ gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible);
return 0;
}
@@ -324,77 +322,40 @@ int inter_guildcastle_tostr(char *str, struct guild_castle *gc)
// ギルド城データの文字列からの変換
int inter_guildcastle_fromstr(char *str, struct guild_castle *gc)
{
- int tmp_int[26];
+ int castleid, guildid, economy, defense, triggerE, triggerD, nextTime, payTime, createTime, visibleC;
+ int guardian[8];
+ int dummy;
memset(gc, 0, sizeof(struct guild_castle));
- // new structure of guild castle
- if (sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13],
- &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20],
- &tmp_int[21], &tmp_int[22], &tmp_int[23], &tmp_int[24], &tmp_int[25]) == 26) {
- gc->castle_id = tmp_int[0];
- gc->guild_id = tmp_int[1];
- gc->economy = tmp_int[2];
- gc->defense = tmp_int[3];
- gc->triggerE = tmp_int[4];
- gc->triggerD = tmp_int[5];
- gc->nextTime = tmp_int[6];
- gc->payTime = tmp_int[7];
- gc->createTime = tmp_int[8];
- gc->visibleC = tmp_int[9];
- gc->guardian[0].visible = tmp_int[10];
- gc->guardian[1].visible = tmp_int[11];
- gc->guardian[2].visible = tmp_int[12];
- gc->guardian[3].visible = tmp_int[13];
- gc->guardian[4].visible = tmp_int[14];
- gc->guardian[5].visible = tmp_int[15];
- gc->guardian[6].visible = tmp_int[16];
- gc->guardian[7].visible = tmp_int[17];
- gc->guardian[0].hp = tmp_int[18];
- gc->guardian[1].hp = tmp_int[19];
- gc->guardian[2].hp = tmp_int[20];
- gc->guardian[3].hp = tmp_int[21];
- gc->guardian[4].hp = tmp_int[22];
- gc->guardian[5].hp = tmp_int[23];
- gc->guardian[6].hp = tmp_int[24];
- gc->guardian[7].hp = tmp_int[25]; // end additions [Valaris]
- // old structure of guild castle
- } else if (sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13],
- &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17]) == 18) {
- int i;
-
- gc->castle_id = tmp_int[0];
- gc->guild_id = tmp_int[1];
- gc->economy = tmp_int[2];
- gc->defense = tmp_int[3];
- gc->triggerE = tmp_int[4];
- gc->triggerD = tmp_int[5];
- gc->nextTime = tmp_int[6];
- gc->payTime = tmp_int[7];
- gc->createTime = tmp_int[8];
- gc->visibleC = tmp_int[9];
- gc->guardian[0].visible = tmp_int[10];
- gc->guardian[1].visible = tmp_int[11];
- gc->guardian[2].visible = tmp_int[12];
- gc->guardian[3].visible = tmp_int[13];
- gc->guardian[4].visible = tmp_int[14];
- gc->guardian[5].visible = tmp_int[15];
- gc->guardian[6].visible = tmp_int[16];
- gc->guardian[7].visible = tmp_int[17];
-
- for (i = 0; i < MAX_GUARDIANS; i++)
- {
- if (gc->guardian[i].visible)
- gc->guardian[i].hp = 15000 + 2000 * gc->defense;
- else
- gc->guardian[i].hp = 0;
- }
- } else {
+ // structure of guild castle with the guardian hp included
+ if( sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+ &castleid, &guildid, &economy, &defense, &triggerE, &triggerD, &nextTime, &payTime, &createTime, &visibleC,
+ &guardian[0], &guardian[1], &guardian[2], &guardian[3], &guardian[4], &guardian[5], &guardian[6], &guardian[7],
+ &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy) != 26 )
+ // structure of guild castle without the hps (current one)
+ if( sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+ &castleid, &guildid, &economy, &defense, &triggerE, &triggerD, &nextTime, &payTime, &createTime, &visibleC,
+ &guardian[0], &guardian[1], &guardian[2], &guardian[3], &guardian[4], &guardian[5], &guardian[6], &guardian[7]) != 18 )
return 1;
- }
+
+ gc->castle_id = castleid;
+ gc->guild_id = guildid;
+ gc->economy = economy;
+ gc->defense = defense;
+ gc->triggerE = triggerE;
+ gc->triggerD = triggerD;
+ gc->nextTime = nextTime;
+ gc->payTime = payTime;
+ gc->createTime = createTime;
+ gc->visibleC = visibleC;
+ gc->guardian[0].visible = guardian[0];
+ gc->guardian[1].visible = guardian[1];
+ gc->guardian[2].visible = guardian[2];
+ gc->guardian[3].visible = guardian[3];
+ gc->guardian[4].visible = guardian[4];
+ gc->guardian[5].visible = guardian[5];
+ gc->guardian[6].visible = guardian[6];
+ gc->guardian[7].visible = guardian[7];
return 0;
}
@@ -964,15 +925,6 @@ int mapif_guild_castle_datasave(int castle_id, int index, int value)
return 0;
}
-int mapif_guild_castle_alldataload_sub(DBKey key, void *data, va_list ap)
-{
- int fd = va_arg(ap, int);
- int *p = va_arg(ap, int*);
-
-
- return 0;
-}
-
int mapif_guild_castle_alldataload(int fd)
{
DBIterator* iter;
@@ -1498,16 +1450,6 @@ int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index)
case 16:
case 17:
return mapif_guild_castle_dataload(gc->castle_id, index, gc->guardian[index-10].visible);
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- return mapif_guild_castle_dataload(gc->castle_id, index, gc->guardian[index-18].hp); // end additions [Valaris]
-
default:
ShowError("mapif_parse_GuildCastleDataLoad ERROR!! (Not found index=%d)\n", index);
return 0;
@@ -1555,15 +1497,6 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
case 16:
case 17:
gc->guardian[index-10].visible = value; break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- gc->guardian[index-18].hp = value; break; // end additions [Valaris]
default:
ShowError("mapif_parse_GuildCastleDataSave ERROR!! (Not found index=%d)\n", index);
return 0;
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index e148532de..016cf4408 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -564,13 +564,10 @@ ShowDebug("Save guild_castle (%d)\n", gc->castle_id);
// sql_query("DELETE FROM `%s` WHERE `castle_id`='%d'",guild_castle_db, gc->castle_id);
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` "
"(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`,"
- "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`,"
- "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`)"
- "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')",
- guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime,
- gc->createTime, gc->visibleC,
- gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible, gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible,
- gc->guardian[0].hp, gc->guardian[1].hp, gc->guardian[2].hp, gc->guardian[3].hp, gc->guardian[4].hp, gc->guardian[5].hp, gc->guardian[6].hp, gc->guardian[7].hp) )
+ "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`)"
+ "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')",
+ guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC,
+ gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible, gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible) )
Sql_ShowDebug(sql_handle);
#ifndef TXT_SQL_CONVERT
@@ -605,8 +602,7 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc)
memset(gc,0,sizeof(struct guild_castle));
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, "
- "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`,"
- "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`"
+ "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`"
" FROM `%s` WHERE `castle_id`='%d'", guild_castle_db, castle_id) )
{
Sql_ShowDebug(sql_handle);
@@ -637,14 +633,6 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc)
Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data);
Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data);
Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data);
- Sql_GetData(sql_handle, 18, &data, NULL); gc->guardian[0].hp = atoi(data);
- Sql_GetData(sql_handle, 19, &data, NULL); gc->guardian[1].hp = atoi(data);
- Sql_GetData(sql_handle, 20, &data, NULL); gc->guardian[2].hp = atoi(data);
- Sql_GetData(sql_handle, 21, &data, NULL); gc->guardian[3].hp = atoi(data);
- Sql_GetData(sql_handle, 22, &data, NULL); gc->guardian[4].hp = atoi(data);
- Sql_GetData(sql_handle, 23, &data, NULL); gc->guardian[5].hp = atoi(data);
- Sql_GetData(sql_handle, 24, &data, NULL); gc->guardian[6].hp = atoi(data);
- Sql_GetData(sql_handle, 25, &data, NULL); gc->guardian[7].hp = atoi(data);
Sql_FreeResult(sql_handle);
memcpy(&castles[castle_id],gc,sizeof(struct guild_castle));
@@ -1231,14 +1219,6 @@ int mapif_guild_castle_alldataload(int fd)
Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data);
Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data);
Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data);
- Sql_GetData(sql_handle, 18, &data, NULL); gc->guardian[0].hp = atoi(data);
- Sql_GetData(sql_handle, 19, &data, NULL); gc->guardian[1].hp = atoi(data);
- Sql_GetData(sql_handle, 20, &data, NULL); gc->guardian[2].hp = atoi(data);
- Sql_GetData(sql_handle, 21, &data, NULL); gc->guardian[3].hp = atoi(data);
- Sql_GetData(sql_handle, 22, &data, NULL); gc->guardian[4].hp = atoi(data);
- Sql_GetData(sql_handle, 23, &data, NULL); gc->guardian[5].hp = atoi(data);
- Sql_GetData(sql_handle, 24, &data, NULL); gc->guardian[6].hp = atoi(data);
- Sql_GetData(sql_handle, 25, &data, NULL); gc->guardian[7].hp = atoi(data);
memcpy(WFIFOP(fd, len), gc, sizeof(struct guild_castle));
len += sizeof(struct guild_castle);
@@ -1853,15 +1833,6 @@ int mapif_parse_GuildCastleDataLoad(int fd,int castle_id,int index)
case 16:
case 17:
return mapif_guild_castle_dataload(gc.castle_id,index,gc.guardian[index-10].visible); break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- return mapif_guild_castle_dataload(gc.castle_id,index,gc.guardian[index-18].hp); break;
default:
ShowError("mapif_parse_GuildCastleDataLoad ERROR!! (Not found index=%d)\n", index);
return 0;
@@ -1906,15 +1877,6 @@ int mapif_parse_GuildCastleDataSave(int fd,int castle_id,int index,int value)
case 16:
case 17:
gc.guardian[index-10].visible = value; break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- gc.guardian[index-18].hp = value; break; // end additions [Valaris]
default:
ShowError("mapif_parse_GuildCastleDataSave ERROR!! (Not found index=%d)\n", index);
return 0;
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 6bb916299..f87964bf4 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -391,9 +391,8 @@ struct guild_castle {
int visibleC;
struct {
unsigned visible : 1;
- int hp;
- int id;
- } guardian[MAX_GUARDIANS]; //New simplified structure. [Skotlex]
+ int id; // object id
+ } guardian[MAX_GUARDIANS];
};
// for Brandish Spear calculations
diff --git a/src/map/battle.c b/src/map/battle.c
index eeb368feb..759b88f83 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -548,9 +548,7 @@ int battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int dama
break;
default:
if (md && md->guardian_data) {
- damage -= damage
- * (md->guardian_data->castle->defense/100)
- * battle_config.castle_defense_rate/100;
+ damage -= damage * (md->guardian_data->castle->defense/100) * battle_config.castle_defense_rate/100;
}
if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex]
if (flag&BF_WEAPON)
diff --git a/src/map/guild.c b/src/map/guild.c
index 8fe10116d..a6ebd5157 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -1723,15 +1723,6 @@ int guild_castledataloadack(int castle_id,int index,int value)
case 16:
case 17:
gc->guardian[index-10].visible = value; break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- gc->guardian[index-18].hp = value; break;
default:
ShowError("guild_castledataloadack ERROR!! (Not found index=%d)\n", index);
return 0;
@@ -1749,14 +1740,28 @@ int guild_castledataloadack(int castle_id,int index,int value)
// ギルド城データ変更要求
int guild_castledatasave(int castle_id,int index,int value)
{
- if (index == 1)
+ if( index == 1 )
{ //The castle's owner has changed? Update Guardian ownership, too. [Skotlex]
struct guild_castle *gc = guild_castle_search(castle_id);
int m = -1;
if (gc) m = map_mapname2mapid(gc->map_name);
if (m != -1)
- map_foreachinmap(mob_guardian_guildchange, m, BL_MOB);
+ map_foreachinmap(mob_guardian_guildchange, m, BL_MOB); //FIXME: why not iterate over gc->guardian[i].id ?
}
+ else
+ if( index == 3 )
+ { // defense invest change -> recalculate guardian hp
+ struct guild_castle* gc = guild_castle_search(castle_id);
+ if( gc )
+ {
+ int i;
+ struct mob_data* gd;
+ for( i = 0; i < MAX_GUARDIANS; i++ )
+ if( gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != NULL )
+ status_calc_mob(gd,0);
+ }
+ }
+
return intif_guild_castle_datasave(castle_id,index,value);
}
@@ -1786,15 +1791,6 @@ int guild_castledatasaveack(int castle_id,int index,int value)
case 16:
case 17:
gc->guardian[index-10].visible = value; break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- gc->guardian[index-18].hp = value; break;
default:
ShowError("guild_castledatasaveack ERROR!! (Not found index=%d)\n", index);
return 0;
@@ -1864,7 +1860,7 @@ static int Gid[MAX_GUILDCASTLE];
int guild_save_sub(int tid,unsigned int tick,int id,int data)
{
struct guild_castle *gc;
- int i,j;
+ int i;
for(i = 0; i < MAX_GUILDCASTLE; i++) { // [Yor]
gc = guild_castle_search(i);
@@ -1874,11 +1870,6 @@ int guild_save_sub(int tid,unsigned int tick,int id,int data)
guild_castledatasave(gc->castle_id, 1, gc->guild_id);
Gid[i] = gc->guild_id;
}
- for (j = 0; j < MAX_GUARDIANS; j++)
- {
- if (gc->guardian[j].visible && Ghp[i][j] != gc->guardian[j].hp)
- guild_castledatasave(gc->castle_id, 18+j, gc->guardian[j].hp);
- }
}
return 0;
diff --git a/src/map/map.c b/src/map/map.c
index 4383d1cd4..43b17daec 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1763,6 +1763,12 @@ struct map_session_data * map_id2sd(int id)
return (struct map_session_data*)idb_get(pc_db,id);
}
+struct mob_data * map_id2md(int id)
+{// just a id2bl lookup because there's no mob_db
+ if (id <= 0) return NULL;
+ return (struct mob_data*)map_id2bl(id);
+}
+
struct npc_data * map_id2nd(int id)
{// just a id2bl lookup because there's no npc_db
if (id <= 0) return NULL;
diff --git a/src/map/map.h b/src/map/map.h
index 7a3e6ae02..847ca477d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1319,9 +1319,10 @@ void map_reqnickdb(struct map_session_data* sd,int charid);
const char* map_charid2nick(int charid);
struct map_session_data* map_charid2sd(int charid);
-struct map_session_data * map_id2sd(int);
-struct npc_data * map_id2nd(int);
-struct block_list * map_id2bl(int);
+struct map_session_data * map_id2sd(int id);
+struct mob_data * map_id2md(int id);
+struct npc_data * map_id2nd(int id);
+struct block_list * map_id2bl(int id);
#define map_id2index(id) map[(id)].index
int map_mapindex2mapid(unsigned short mapindex);
diff --git a/src/map/mob.c b/src/map/mob.c
index 2d0eb04b9..c58ce5e17 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -439,7 +439,6 @@ static int mob_spawn_guardian_sub(int tid,unsigned int tick,int id,int data)
{ //Safe removal of guardian.
md->guardian_data->castle->guardian[md->guardian_data->number].visible = 0;
guild_castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
- guild_castledatasave(md->guardian_data->castle->castle_id, 18+md->guardian_data->number,0);
}
unit_free(&md->bl,0); //Remove guardian.
}
@@ -1734,9 +1733,6 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
if (src) mob_log_damage(md, src, damage);
}
- if(md->guardian_data && md->guardian_data->number < MAX_GUARDIANS) // guardian hp update [Valaris] (updated by [Skotlex])
- md->guardian_data->castle->guardian[md->guardian_data->number].hp = md->status.hp;
-
if (battle_config.show_mob_info&3)
clif_charnameack (0, &md->bl);
@@ -1779,10 +1775,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
status = &md->status;
if(md->guardian_data && md->guardian_data->number < MAX_GUARDIANS)
- { // guardian hp update [Valaris] (updated by [Skotlex])
guild_castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
- guild_castledatasave(md->guardian_data->castle->castle_id, 18+md->guardian_data->number,0);
- }
md->state.skillstate = MSS_DEAD;
mobskill_use(md,tick,-1); //On Dead skill.
@@ -2291,7 +2284,6 @@ int mob_guardian_guildchange(struct block_list *bl,va_list ap)
{ //Safe removal of guardian.
md->guardian_data->castle->guardian[md->guardian_data->number].visible = 0;
guild_castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
- guild_castledatasave(md->guardian_data->castle->castle_id, 18+md->guardian_data->number,0);
}
unit_free(&md->bl,0); //Remove guardian.
}
@@ -2304,7 +2296,6 @@ int mob_guardian_guildchange(struct block_list *bl,va_list ap)
ShowError("mob_guardian_guildchange: New Guild (id %d) does not exists!\n", md->guardian_data->guild_id);
md->guardian_data->castle->guardian[md->guardian_data->number].visible = 0;
guild_castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
- guild_castledatasave(md->guardian_data->castle->castle_id, 18+md->guardian_data->number,0);
unit_free(&md->bl,0);
return 0;
}
@@ -2412,10 +2403,6 @@ int mob_class_change (struct mob_data *md, int class_)
*------------------------------------------*/
void mob_heal(struct mob_data *md,unsigned int heal)
{
- if(md->guardian_data && md->guardian_data->number < MAX_GUARDIANS)
- // guardian hp update [Valaris] (updated by [Skotlex])
- md->guardian_data->castle->guardian[md->guardian_data->number].hp = md->status.hp;
-
if (battle_config.show_mob_info&3)
clif_charnameack (0, &md->bl);
}
diff --git a/src/map/script.c b/src/map/script.c
index 2575e42ef..b66197bb5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9127,7 +9127,7 @@ BUILDIN_FUNC(getcastledata)
switch(index){
case 0: {
int i;
- for(i=1;i<26;i++) // Initialize[AgitInit]
+ for(i=1;i<18;i++) // Initialize[AgitInit]
guild_castledataload(gc->castle_id,i);
} break;
case 1:
@@ -9157,15 +9157,6 @@ BUILDIN_FUNC(getcastledata)
case 16:
case 17:
script_pushint(st,gc->guardian[index-10].visible); break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- script_pushint(st,gc->guardian[index-18].hp); break;
default:
script_pushint(st,0); break;
}
@@ -9213,30 +9204,6 @@ BUILDIN_FUNC(setcastledata)
case 16:
case 17:
gc->guardian[index-10].visible = value; break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- gc->guardian[index-18].hp = value;
- if (gc->guardian[index-18].id)
- { //Update this mob's HP.
- struct block_list *bl = map_id2bl(gc->guardian[index-18].id);
- if (!bl)
- { //Wrong target?
- gc->guardian[index-18].id = 0;
- break;
- }
- if (value < 1) {
- status_kill(bl);
- break;
- }
- status_set_hp(bl, value, 0);
- }
- break;
default:
return 0;
}
@@ -9742,27 +9709,47 @@ BUILDIN_FUNC(guardian)
return 0;
}
-/*================================================
- * Script for Displaying Guardian Info [Valaris]
- *------------------------------------------------*/
+/// Retrieves various information about the specified guardian.
+///
+/// guardianinfo("<map_name>", <index>, <type>) -> <value>
+/// type: 0 - whether it is deployed or not
+/// 1 - maximum hp
+/// 2 - current hp
+///
BUILDIN_FUNC(guardianinfo)
{
- int guardian=script_getnum(st,2);
- TBL_PC *sd=script_rid2sd(st);
- struct guild_castle *gc=guild_mapname2gc(map[sd->bl.m].name);
+ const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
+ int id = script_getnum(st,3);
+ int type = script_getnum(st,4);
- if (guardian < 0 || guardian >= MAX_GUARDIANS || gc==NULL)
+ struct guild_castle* gc = guild_mapname2gc(mapname);
+ struct mob_data* gd;
+
+ if( gc == NULL || id < 0 || id >= MAX_GUARDIANS )
{
script_pushint(st,-1);
return 0;
}
- if(gc->guardian[guardian].visible)
- script_pushint(st,gc->guardian[guardian].hp);
- else script_pushint(st,-1);
+ if( type == 0 )
+ script_pushint(st, gc->guardian[id].visible);
+ else
+ if( !gc->guardian[id].visible )
+ script_pushint(st,-1);
+ else
+ if( (gd = map_id2md(gc->guardian[id].id)) == NULL )
+ script_pushint(st,-1);
+ else
+ {
+ if ( type == 1 ) script_pushint(st,gd->status.max_hp);
+ else if( type == 2 ) script_pushint(st,gd->status.hp);
+ else
+ script_pushint(st,-1);
+ }
return 0;
}
+
/*==========================================
* IDからItem名
*------------------------------------------*/
@@ -13158,7 +13145,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(soundeffectall,"si*"), // SoundEffectAll [Codemaster]
BUILDIN_DEF(strmobinfo,"ii"), // display mob data [Valaris]
BUILDIN_DEF(guardian,"siisi??"), // summon guardians
- BUILDIN_DEF(guardianinfo,"i"), // display guardian data [Valaris]
+ BUILDIN_DEF(guardianinfo,"sii"), // display guardian data [Valaris]
BUILDIN_DEF(petskillbonus,"iiii"), // [Valaris]
BUILDIN_DEF(petrecovery,"ii"), // [Valaris]
BUILDIN_DEF(petloot,"i"), // [Valaris]
diff --git a/src/map/status.c b/src/map/status.c
index 91ae9eb06..42695e1b4 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -834,11 +834,13 @@ int status_heal(struct block_list *bl,int hp,int sp, int flag)
) //End auto berserk.
status_change_end(bl,SC_PROVOKE,-1);
+ // send hp update to client
switch(bl->type) {
case BL_PC: pc_heal((TBL_PC*)bl,hp,sp,flag&2?1:0); break;
case BL_MOB: mob_heal((TBL_MOB*)bl,hp); break;
case BL_HOM: merc_hom_heal((TBL_HOM*)bl,hp,sp); break;
}
+
return hp+sp;
}
@@ -1446,10 +1448,7 @@ int status_calc_mob(struct mob_data* md, int first)
else {
status->max_hp += 2000 * gc->defense;
status->max_sp += 200 * gc->defense;
- if (md->guardian_data->number < MAX_GUARDIANS) //Spawn with saved HP
- status->hp = gc->guardian[md->guardian_data->number].hp;
- else //Emperium
- status->hp = status->max_hp;
+ status->hp = status->max_hp;
status->sp = status->max_sp;
}
status->batk += status->batk * 10*md->guardian_data->guardup_lv/100;