summaryrefslogtreecommitdiff
path: root/src/map/script.c
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/map/script.c
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/map/script.c')
-rw-r--r--src/map/script.c77
1 files changed, 32 insertions, 45 deletions
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]