joecalis Posted February 21, 2013 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 64 Reputation: 41 Joined: 03/26/12 Last Seen: March 29 Share Posted February 21, 2013 (edited) Hallo, hallo everyone. This is going to be my very first release here, so I hope it can be useful. So basically I made a script command that checks whether the monster stated exists in the mob_db or spawns naturally (Some monsters doesn't spawn naturally but listed on the mob_db). So here's how it works. if(mobexists(1002)){ // It works with mob name too "mobexists("Poring")" mes "Yes its a Poring, of course exists foo!"; close; } else { mes "No that monster does not exist or maybe it just doesn't spawn."; mes "Meh! What ever floats your boat..."; close; } If the mob stated exists it returns a value of 1 if not it returns -1 or 0. So if you want this script command here's what you do: Step 1 - open src\map\script.c Step 2 - Find this line. BUILDIN_FUNC(checkvending) Step 3 - Right above it, just slap this code right in so it would look like this. Raw Code BUILDIN_FUNC(mobexists) //added code start { struct mob_db *mob, *mob_array[MAX_SEARCH]; const char* mob_id = script_getstr(st,2); int count; int i, j, k; if (!mob_id){ ShowError("buildin_mobexists: No Monster ID set."); return -1; } // If monster identifier/name argument is a name if ((i = mobdb_checkid(atoi(mob_id)))) { mob_array[0] = mob_db(i); count = 1; } else count = mobdb_searchname_array(mob_array, MAX_SEARCH, mob_id); if (!count) { script_pushint(st,-1); } if (count > MAX_SEARCH) { count = MAX_SEARCH; } for (k = 0; k < count; k++) { mob = mob_array[k]; for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++) { j = map_mapindex2mapid(mob->spawn[i].mapindex); if (j < 0) continue; } if (i == 0) { script_pushint(st,-1); } else { script_pushint(st,1); } } return 0; } //added code end BUILDIN_FUNC(checkvending) Step 4 - Find this code. BUILDIN_DEF(getmonsterinfo,"ii"), Step 5 - Right below it slap this code right in too so it would look like this. BUILDIN_DEF(getmonsterinfo,"ii"), BUILDIN_DEF(mobexists,"i"), //added code Step 6 - Save and Recompile and Done. So there you go folks, just a little bit of finding and a little slapping here and there and your good to go. Reply to this thread if you're having any problems/errors. Edited February 22, 2013 by joecalis 1 Quote Link to comment Share on other sites More sharing options...
clydelion Posted February 21, 2013 Group: Members Topic Count: 17 Topics Per Day: 0.00 Content Count: 754 Reputation: 186 Joined: 05/22/12 Last Seen: October 15, 2022 Share Posted February 21, 2013 Cheers mate! Good to see new people releasing stuff. Not to disappoint you or anything but this will do the same thing for checking the existence of the mob. if(strmobinfo(0,1002) != ""){ mes "Yes its a Poring, of course exists foo!"; close; } else { mes "No that monster does not exist or maybe it just doesn't spawn."; mes "Meh! What ever floats your boat..."; close; }Nonetheless, your code looks good. 1 Quote Link to comment Share on other sites More sharing options...
java Posted February 22, 2013 Group: Members Topic Count: 27 Topics Per Day: 0.01 Content Count: 265 Reputation: 35 Joined: 12/22/11 Last Seen: 47 minutes ago Share Posted February 22, 2013 ihihihi can u create diff for ur mod? Quote Link to comment Share on other sites More sharing options...
Dastgir Posted February 22, 2013 Group: Members Topic Count: 26 Topics Per Day: 0.01 Content Count: 331 Reputation: 63 Joined: 11/29/11 Last Seen: Saturday at 10:21 AM Share Posted February 22, 2013 (edited) Its not a custom source(strmobinfo), Its already included in rA Edited February 22, 2013 by Dastgir Pojee Quote Link to comment Share on other sites More sharing options...
joecalis Posted February 22, 2013 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 64 Reputation: 41 Joined: 03/26/12 Last Seen: March 29 Author Share Posted February 22, 2013 (edited) Cheers mate! Good to see new people releasing stuff. Not to disappoint you or anything but this will do the same thing for checking the existence of the mob. if(strmobinfo(0,1002) != ""){ mes "Yes its a Poring, of course exists foo!"; close; } else { mes "No that monster does not exist or maybe it just doesn't spawn."; mes "Meh! What ever floats your boat..."; close; }Nonetheless, your code looks good. Its not a custom source(strmobinfo), Its already included in rA Yeah but (strmobinfo) doesn't track if the mob has natural spawn or not like event monsters and stuff ^^ And no sorry, I don't know how to create a diff. I'm a newbie at this kind of things Edited February 22, 2013 by joecalis Quote Link to comment Share on other sites More sharing options...
mrlongshen Posted February 22, 2013 Group: Members Topic Count: 98 Topics Per Day: 0.02 Content Count: 1302 Reputation: 79 Joined: 12/04/12 Last Seen: September 26, 2019 Share Posted February 22, 2013 (edited) bro, when the patch will be use ? when we use @mi ? or when @whereis ? Edited February 22, 2013 by mrlongshen Quote Link to comment Share on other sites More sharing options...
joecalis Posted February 22, 2013 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 64 Reputation: 41 Joined: 03/26/12 Last Seen: March 29 Author Share Posted February 22, 2013 bro, when the patch will be use ? when we use @mi ? or when @whereis ? Its not an @command, its a script command meaning it will only work for npc scripts like the one shown in the example. Quote Link to comment Share on other sites More sharing options...
mrlongshen Posted February 22, 2013 Group: Members Topic Count: 98 Topics Per Day: 0.02 Content Count: 1302 Reputation: 79 Joined: 12/04/12 Last Seen: September 26, 2019 Share Posted February 22, 2013 i dont get it. sry. i too noobies about src mod, if i implement this, when this will appear ? if(mobexists(1002)){ // It works with mob name too "mobexists("Poring")" mes "Yes its a Poring, of course exists foo!"; close; } else { mes "No that monster does not exist or maybe it just doesn't spawn."; mes "Meh! What ever floats your boat..."; close; } Quote Link to comment Share on other sites More sharing options...
joecalis Posted February 22, 2013 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 64 Reputation: 41 Joined: 03/26/12 Last Seen: March 29 Author Share Posted February 22, 2013 (edited) i dont get it. sry. i too noobies about src mod, if i implement this, when this will appear ? if(mobexists(1002)){ // It works with mob name too "mobexists("Poring")" mes "Yes its a Poring, of course exists foo!"; close; } else { mes "No that monster does not exist or maybe it just doesn't spawn."; mes "Meh! What ever floats your boat..."; close; } That will not appear ever unless you added an npc with a script code like that. So if you implement this, You can make different npc with "mobexists(<Mob ID>)" function. e.g. prontera,150,150,4 script Monster Spawn Check 405,{ set @npcname$,"[^ff0000 Monster Spawn Check ^000000]"; mes @npcname$; mes "Put the monster ID you would like to check."; next; input @mobid; if(@mobid<=0){ mes @npcname$; mes "Please put in a real ID"; close } else if(!mobexists(@mobid)){ mes @npcname$; mes "That monster does not exists or spawn naturally."; close; } else { mes @npcname$; mes "Yes "+getmonsterinfo(@mobinfo,0)+" exists and spawns naturally."; close } } Edited February 22, 2013 by joecalis Quote Link to comment Share on other sites More sharing options...
mrlongshen Posted February 22, 2013 Group: Members Topic Count: 98 Topics Per Day: 0.02 Content Count: 1302 Reputation: 79 Joined: 12/04/12 Last Seen: September 26, 2019 Share Posted February 22, 2013 now i understand. hehe thx mate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.