summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--db/const.txt22
-rw-r--r--npc/sample/getmonsterinfo.txt18
-rw-r--r--src/map/script.c92
4 files changed, 134 insertions, 0 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 748b30756..40844982d 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -5,6 +5,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV
GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
2006/03/18
+ * Added 'GetMonsterInfo(MobID,Idx)' script function. [Lupus]
+ You can get monsters name,level,race, etc by its Id. Check npc\sample\getmonsterinfo.txt
* Fixed warnings on compilers again. [Lance]
2006/03/17
diff --git a/db/const.txt b/db/const.txt
index e2802b2f0..2e1aba0d7 100644
--- a/db/const.txt
+++ b/db/const.txt
@@ -629,3 +629,25 @@ PET_LEVEL 3
PET_HUNGRY 4
PET_INTIMATE 5
+MOB_NAME 0
+MOB_LV 1
+MOB_MAXHP 2
+MOB_BASEEXP 3
+MOB_JOBEXP 4
+MOB_ATK1 5
+MOB_ATK2 6
+MOB_DEF 7
+MOB_MDEF 8
+MOB_STR 9
+MOB_AGI 10
+MOB_VIT 11
+MOB_INT 12
+MOB_DEX 13
+MOB_LUK 14
+MOB_RANGE 15
+MOB_RANGE2 16
+MOB_RANGE3 17
+MOB_SIZE 18
+MOB_RACE 19
+MOB_ELEMENT 20
+MOB_MODE 21
diff --git a/npc/sample/getmonsterinfo.txt b/npc/sample/getmonsterinfo.txt
new file mode 100644
index 000000000..a935771c7
--- /dev/null
+++ b/npc/sample/getmonsterinfo.txt
@@ -0,0 +1,18 @@
+//by Lupus
+
+prontera.gat,156,179,6 script test_getmonsterinfo 117,{
+ mes "Please enter a monster ID (1001 ... 2000)";
+ input @value;
+ if(getmonsterinfo(@value,MOB_LV)<0 || getmonsterinfo(@value,MOB_NAME)=="Dummy") {
+ mes "Wrong MOB ID.";
+ close;
+ }
+ mes "Monster ID: "+@value+" '"+getmonsterinfo(@value,MOB_NAME)+"'";
+ mes "Current Monster info:";
+ set @id,0;
+L_LOOP:
+ mes " getmonsterinfo("+@value+","+@id+") = "+getmonsterinfo(@value,@id);
+ set @id,@id+1;
+ if(@id<22) goto L_LOOP;
+ close;
+} \ No newline at end of file
diff --git a/src/map/script.c b/src/map/script.c
index b39eba0fa..b7322164c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -434,6 +434,7 @@ int mapreg_setregstr(int num,const char *str);
int buildin_setitemscript(struct script_state *st);
int buildin_disguise(struct script_state *st);
int buildin_undisguise(struct script_state *st);
+int buildin_getmonsterinfo(struct script_state *st); // [Lupus]
#ifdef PCRE_SUPPORT
int buildin_defpattern(struct script_state *st); // MouseJstr
@@ -732,6 +733,7 @@ struct {
{buildin_setitemscript,"setitemscript","is"}, //Set NEW item bonus script. Lupus
{buildin_disguise,"disguise","i"}, //disguise player. Lupus
{buildin_undisguise,"undisguise","i"}, //undisguise player. Lupus
+ {buildin_getmonsterinfo,"getmonsterinfo","ii"}, //Lupus
// [zBuffer] List of player cont commands --->
{buildin_pcwalkxy,"pcwalkxy","iii"},
{buildin_pctalk,"pctalk","is"},
@@ -9829,6 +9831,96 @@ int buildin_delmonsterdrop(struct script_state *st)
}
}
*/
+/*==========================================
+ * Returns some values of a monster [Lupus]
+ * Name, Level, race, size, etc...
+ getmonsterinfo(monsterID,queryIndex);
+ *------------------------------------------
+ */
+int buildin_getmonsterinfo(struct script_state *st)
+{
+ struct mob_db *mob;
+ int mob_id;
+
+ mob_id = conv_num(st,& (st->stack->stack_data[st->start+2]));
+ if (mob_id <= 1000 || (mob = mob_db(mob_id))==NULL) {
+ ShowError("buildin_getmonsterinfo: Wrong Monster ID: %i", mob_id);
+ push_val(st->stack, C_INT, -1);
+ return -1;
+ }
+
+ switch ( conv_num(st,& (st->stack->stack_data[st->start+3])) ) {
+ case 0: //Name
+ push_str(st->stack,C_CONSTSTR, (unsigned char *) mob->jname);
+ break;
+ case 1: //Lvl
+ push_val(st->stack,C_INT, mob->lv);
+ break;
+ case 2: //MaxHP
+ push_val(st->stack,C_INT, mob->max_hp);
+ break;
+ case 3: //Base EXP
+ push_val(st->stack,C_INT, mob->base_exp);
+ break;
+ case 4: //Job EXP
+ push_val(st->stack,C_INT, mob->job_exp);
+ break;
+ case 5: //Atk1
+ push_val(st->stack,C_INT, mob->atk1);
+ break;
+ case 6: //Atk2
+ push_val(st->stack,C_INT, mob->atk2);
+ break;
+ case 7: //Def
+ push_val(st->stack,C_INT, mob->def);
+ break;
+ case 8: //Mdef
+ push_val(st->stack,C_INT, mob->mdef);
+ break;
+ case 9: //Str
+ push_val(st->stack,C_INT, mob->str);
+ break;
+ case 10: //Agi
+ push_val(st->stack,C_INT, mob->agi);
+ break;
+ case 11: //Vit
+ push_val(st->stack,C_INT, mob->vit);
+ break;
+ case 12: //Int
+ push_val(st->stack,C_INT, mob->int_);
+ break;
+ case 13: //Dex
+ push_val(st->stack,C_INT, mob->dex);
+ break;
+ case 14: //Luk
+ push_val(st->stack,C_INT, mob->luk);
+ break;
+ case 15: //Range
+ push_val(st->stack,C_INT, mob->range);
+ break;
+ case 16: //Range2
+ push_val(st->stack,C_INT, mob->range2);
+ break;
+ case 17: //Range3
+ push_val(st->stack,C_INT, mob->range3);
+ break;
+ case 18: //Size
+ push_val(st->stack,C_INT, mob->size);
+ break;
+ case 19: //Race
+ push_val(st->stack,C_INT, mob->race);
+ break;
+ case 20: //Element
+ push_val(st->stack,C_INT, mob->element);
+ break;
+ case 21: //Mode
+ push_val(st->stack,C_INT, mob->mode);
+ break;
+ default: //wrong Index
+ push_val(st->stack,C_INT,-1);
+ }
+ return 0;
+}
// [zBuffer] List of player cont commands --->
int buildin_pcwalkxy(struct script_state *st){