noitem plugin

AnnieRuru

~~Cute~Cute~Scripter~~
Messages
1,677
Points
0
Location
your next door ~
Discord
AnnieRuru#1609
Github
AnnieRuru
Emulator
Client Version
2019-05-30aRagexeRE
Download: 1.9
plugin

tested with

prontera mapflag noitem 0,4,5

Code:
prontera	mapflag	noitem	IT_HEALING, IT_WEAPON, IT_ARMOR

disable player from using healing items, and preventing equip weapon and armor.

.

prontera mapflag noitem Poring_Card

Code:
prontera	mapflag	noitem	4001

disable player from using Poring Card

1.0
noitem_20140310

1.1
-- fix a bug which messed up counter, should be [k] in npc.c
----- counter is for string size (w4), [k] counter is the index of the array map->list[m].noitemlist
noitem_20140828.
noitem_20140908

1.2
-- forgot to add aFree(temp), which cause memory leak
noitem_20140911.
noitem_20151030

1.3
plugin
-- remove MAX_RESTRICTED_LIST and hardcoded it as 50
-- and change noitem from state, into number of items restricted, to make it loop lesser

1.4
plugin
-- fix a rare bug if the user put multiple noitem on the same map, it spam non-sensible error
---- although this will overwrite the previous one without warning this time

1.5
plugin
--- remove the 50 items restriction limit by utilizing vector

1.6
plugin
--- fix server crash on certain compiler

1.7 - plugin
- fix memory leak cause by aStrdup and VECTOR_ENSURE

1.8 - plugin
- fix duplicate entry by ShowWarning
- add missing IT_AMMO item type deny

1.9 - plugin

- fix memory leak from doing multiple `@loadnpc`
 

Credit to original author -> https://rathena.org/board/topic/59578-mapflags-noitem-and-noskill2/
Wynn_

 
Last edited by a moderator:
Hope this mapflag will be implemented fully on Hercules since its very very useful specially on events and a lot more... and also, to fix known issues. 

Good job @AnnieRuru !! /no1

Reputation +1

 
Last edited by a moderator:
Wow,
default_smile.png
nice addition..
default_biggrin.png
but hopefully, in the future there could be a possibility that we could use plugin system to add mapflags, OnCustomEvents, and edit some complicated things in skill.c and status.c
default_biggrin.png


 
hahaha .... that known issue is a false alarm

I was having another plugin that crash the server ... thanks to the core dump

there was nothing wrong with the patch at all

@Jezu

actually I rather have the map_zone_db.conf have a config to unequip the equipments

so this one stay custom, that one should get a pull request

@Samuel

the current mapflag implementation sucks

there should be just a function to add a mapflag, then from that global function handle the rest

 
annie you are the best :3 but I'm really waiting for your push commit :#

 
Hello Annie
default_smile.png


this script looks very very interessting.

But I have two questions:

- Can it be enabled / disabled by using setmapflag / removemapflag script commands ?

- If YES, how ? ( Can I add mf_noitem to const.txt ?, cause setmapflag / removemapflag use that. )

MfG

Snowflake

 
Last edited by a moderator:
this should be added officially on Hercules.

anyone can apply this as Plugin?

 
Last edited by a moderator:
But I have two questions:

- Can it be enabled / disabled by using setmapflag / removemapflag script commands ?
no ... setmapflag in script.c isBUILDIN_DEF(setmapflag,"si?"),which only allow 2 parametersits better to leave it as mapflags as mine can support up to 50 items

.

.

.

this should be added officially on Hercules.
no, custom mod should stay custom ... this is not an official feature.

.

.

anyone can apply this as Plugin?
probably no ... there is currently no known way to add mapflags through plugin.

.

.

and ... update the patch

 
Last edited by a moderator:
GLAD your back IDOL!
default_smile.png


 
i finally got it. wonderful!!!!!  will it support multiple items to disable? because i tried, map server wont load "stuck in loading mapflag file"
 
 
guild_vs1 mapflag noitem 4047, 4134, 4135, 4137, 4138, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4168, 4276, 4305, 4302, 4318, 4324
 
Last edited by a moderator:
MUAHAHAHAHAHA !!

for so many months nobody noticed this bug

I messed up the , it should be [k]

 

everyone should download the new one

 

fix in noitem_20140828

 
Last edited by a moderator:
on the recent map_zone_db update are this already added can we now globally add Item Type like: IT_HEALING, IT_WEAPON, IT_ARMOR to restrict them for using

 
Hope they would add it this will be a perfect addition to map_zone_db
default_smile.png


 
i have warning memory leak on map server console for npc.c, have i messed up ?

Code:
Index: plugins/Makefile.in===================================================================--- plugins/Makefile.in	(revision 14604)+++ plugins/Makefile.in	(working copy)@@ -18,7 +18,7 @@ #                                                                    # # Note: DO NOT include the .c extension!!!                           # -MYPLUGINS = +MYPLUGINS = getmemberaid  #                                                                    # #########  DO NOT EDIT ANYTHING BELOW THIS LINE!!!  ##################Index: config/renewal.h===================================================================--- config/renewal.h	(revision 14604)+++ config/renewal.h	(working copy)@@ -21,7 +21,7 @@  * line, by passing --disable-renewal to the configure script:  * ./configure --disable-renewal  */-//#define DISABLE_RENEWAL+#define DISABLE_RENEWAL   #ifndef DISABLE_RENEWAL // Do not change this lineIndex: common/mmo.h===================================================================--- common/mmo.h	(revision 14604)+++ common/mmo.h	(working copy)@@ -80,7 +80,7 @@         #define MAX_HOTKEYS 36 #else // >= 20090617         // (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268)-        #define MAX_HOTKEYS 38+        #define MAX_HOTKEYS 36 #endif // 20090603 #endif // 20070227 @@ -94,18 +94,18 @@  #define MAX_INVENTORY 100 //Max number of characters per account. Note that changing this setting alone is not enough if the client is not hexed to support more characters as well.-#define MAX_CHARS 9+#define MAX_CHARS 12 //Number of slots carded equipment can have. Never set to less than 4 as they are also used to keep the data of forged items/equipment. [Skotlex] //Note: The client seems unable to receive data for more than 4 slots due to all related packets having a fixed size. #define MAX_SLOTS 4 //Max amount of a single stacked item #define MAX_AMOUNT 30000-#define MAX_ZENY 1000000000+#define MAX_ZENY 2000000000  //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY 2100000000 -#define MAX_LEVEL 175+#define MAX_LEVEL 255 #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478Index: char/char.c===================================================================--- char/char.c	(revision 14604)+++ char/char.c	(working copy)@@ -4749,8 +4749,7 @@ 				 			// checks the entered pin 			case 0x8b8:-				if( RFIFOREST(fd) < 10 )-					return 0;+				FIFOSD_CHECK(10); 				 				if( RFIFOL(fd,2) == sd->account_id ) 					pincode->check( fd, sd );@@ -4760,8 +4759,8 @@ 				 			// request for PIN window 			case 0x8c5:-				if( RFIFOREST(fd) < 6 )-					return 0;+				FIFOSD_CHECK(6);+				 				if( RFIFOL(fd,2) == sd->account_id ) 					pincode->sendstate( fd, sd, PINCODE_NOTSET ); 							@@ -4770,8 +4769,8 @@ 				 			// pincode change request 			case 0x8be:-				if( RFIFOREST(fd) < 14 )-					return 0;+				FIFOSD_CHECK(14);+				 				if( RFIFOL(fd,2) == sd->account_id ) 					pincode->change( fd, sd ); 				@@ -4780,8 +4779,8 @@ 				 			// activate PIN system and set first PIN 			case 0x8ba:-				if( RFIFOREST(fd) < 10 )-					return 0;+				FIFOSD_CHECK(10);+				 				if( RFIFOL(fd,2) == sd->account_id ) 					pincode->setnew( fd, sd ); 				RFIFOSKIP(fd,10);@@ -4789,9 +4788,8 @@ 			 			/* 0x8d4 <from>.W <to>.W <unused>.W (2+2+2+2) */ 			case 0x8d4:-				if( RFIFOREST(fd) < 8 )-					return 0;-				else {+				FIFOSD_CHECK(8);+				{ 					bool ret; 					ret = char_slotchange(sd, fd, RFIFOW(fd, 2), RFIFOW(fd, 4)); 					WFIFOHEAD(fd, 8);Index: map/skill.c===================================================================--- map/skill.c	(revision 14604)+++ map/skill.c	(working copy)@@ -6360,7 +6360,7 @@  				if (tsc->data[SC_STONE]) { 					status_change_end(bl, SC_STONE, INVALID_TIMER);-					if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);+					clif->skill_nodamage(src,bl,skill_id,skill_lv,1); 					break; 				} 				if (sc_start4(src,bl,SC_STONE,(skill_lv*4+20)+brate,@@ -11020,7 +11020,13 @@ 		case BA_ASSASSINCROSS: 			val1 = 10 + skill_lv + (st->agi/10); // ASPD increase 			if(sd)+#ifdef RENEWAL+				val1 += 4 * pc->checkskill(sd,BA_MUSICALLESSON);+#else 				val1 += (pc->checkskill(sd,BA_MUSICALLESSON) + 1) / 2;++			val1 *= 10; // ASPD works with 1000 as 100%+#endif 			break; 		case DC_FORTUNEKISS: 			val1 = 10+skill_lv+(st->luk/10); // Critical increaseIndex: map/unit.c===================================================================--- map/unit.c	(revision 14604)+++ map/unit.c	(working copy)@@ -1241,6 +1241,17 @@ 			casttime = -1; 		temp = 1; 	break;+	case CR_DEVOTION:+		if (sd)	{+			int i = 0, count = min(skill_lv, 5);+			ARR_FIND(0, count, i, sd->devotion[i] == target_id);+			if (i == count) {+				ARR_FIND(0, count, i, sd->devotion[i] == 0);+					if(i == count)+						return 0; // Can't cast on other characters when limit is reached+			}+		}+	break; 	case SR_GATEOFHELL: 	case SR_TIGERCANNON: 		if (sc && sc->data[SC_COMBOATTACK] &&Index: map/npc.c===================================================================--- map/npc.c	(revision 14604)+++ map/npc.c	(working copy)@@ -4003,6 +4003,58 @@ 		map->list[m].flag.src4instance = (state) ? 1 : 0; 	} else if ( !strcmpi(w3,"nocashshop") ) { 		map->list[m].flag.nocashshop = (state) ? 1 : 0;+	} else if (!strcmpi(w3,"noitem")) {+		int id = 0, i = 0, j = 0, k = 0, l = strlen(w4);+		char *temp = (char*)aMalloc( strlen(w4) +1 );+		struct item_data *i_data;+		if ( l ) {+			while ( i <= l && k < MAX_RESTRICTED_LIST ) {+				if ( w4[i] != ' ' && w4[i] != '	' && w4[i] != ',' && w4[i] != '0' ) {+					temp[j++] = w4[i];+				}+				else if ( w4[i-1] != ' ' && w4[i-1] != '	' && w4[i-1] != ',' ) {+					temp[j] = '0';+					if ( !strcmp( temp, "IT_HEALING" ) || !strcmp( temp, "0" ) )+						map->list[m].noitemlist[k] = 0;+					else if ( !strcmp( temp, "IT_USABLE" ) || !strcmp( temp, "2" ) )+						map->list[m].noitemlist[k] = 2;+					else if ( !strcmp( temp, "IT_WEAPON" ) || !strcmp( temp, "4" ) )+						map->list[m].noitemlist[k] = 4;+					else if ( !strcmp( temp, "IT_ARMOR" ) || !strcmp( temp, "5" ) )+						map->list[m].noitemlist[k] = 5;+					else if ( !strcmp( temp, "IT_CARD" ) || !strcmp( temp, "6" ) )+						map->list[m].noitemlist[k] = 6;+					else if ( !strcmp( temp, "IT_DELAYCONSUME" ) || !strcmp( temp, "11" ) )+						map->list[m].noitemlist[k] = 11;+					else if ( !strcmp( temp, "IT_CASH" ) || !strcmp( temp, "18" ) )+						map->list[m].noitemlist[k] = 18;+					else if ( atoi(temp) == 0 ) {+						i_data = itemdb->search_name( temp );+						if ( i_data )+							map->list[m].noitemlist[k] = i_data->nameid;+						else {+							ShowWarning("npc_parse_mapflag: Item name "%s" does not exist.n    Mapflag noitem: At %s (file '%s', line '%d').n", temp, map->list[m].name, filepath, strline(buffer,start-buffer) );+							map->list[m].noitemlist[k] = -1;+						}+					}+					else {+						id = atoi(temp);+						if ( itemdb->exists(id) )+							map->list[m].noitemlist[k] = id;+						else {+							ShowWarning("npc_parse_mapflag: Item ID "%s" does not exist.n    Mapflag noitem: At %s (file '%s', line '%d').n", temp, map->list[m].name, filepath, strline(buffer,start-buffer) );+							map->list[m].noitemlist[k] = -1;+						}+					}+					k++;+					j = 0;+				}+				i++;+			}+			map->list[m].flag.noitem = state;+		}+		else+			ShowWarning("npc_parse_mapflag: no Item ID/type input.n           Mapflag noitem: At %s (file '%s', line '%d').n", map->list[m].name, filepath, strline(buffer,start-buffer)); 	} else { 		ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.n", w3, filepath, strline(buffer,start-buffer)); 		if (retval) *retval = EXIT_FAILURE;Index: map/status.c===================================================================--- map/status.c	(revision 14604)+++ map/status.c	(working copy)@@ -1790,16 +1790,8 @@ 	hide_flag = flag?OPTION_HIDE:(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK);  	//You cannot hide from ground skills.-	if( skill->get_ele(skill_id,1) == ELE_EARTH ) //TODO: Need Skill Lv here :/+	if( skill->get_ele(skill_id,1) == ELE_EARTH && skill_id != MG_STONECURSE) 		hide_flag &= ~OPTION_HIDE;-	else {-		switch ( skill_id ) {-			case MO_ABSORBSPIRITS: // it works when already casted and target suddenly hides.-			case SA_DISPELL:-				hide_flag &= ~OPTION_HIDE;-				break;-		}-	}  	switch( target->type ) { 		case BL_PC: {@@ -1810,6 +1802,7 @@ 					return 0; 				if( tsc ) { 					if (tsc->option&hide_flag && !is_boss &&+						!(flag&1 && skill->get_nk(skill_id)&NK_NO_DAMAGE) && // Buff/debuff skills that started casting before hiding still applies 						((sd->special_state.perfect_hiding || !is_detect) || 						(tsc->data[SC_CLOAKINGEXCEED] && is_detect))) 						return 0;@@ -5569,7 +5562,7 @@ 					max = sc->data[SC_ASSNCROS]->val2; 			} 		}-		aspd_rate -= 10 * max; // let's multiply here for consistency+		aspd_rate -= max;  		if(sc->data[SC_BERSERK]) 			aspd_rate -= 300;Index: map/pc.c===================================================================--- map/pc.c	(revision 14604)+++ map/pc.c	(working copy)@@ -961,6 +961,23 @@ 		} 	} +	if ( map->list[sd->bl.m].flag.noitem ) {+		int i, slot;+		ARR_FIND( 0, MAX_RESTRICTED_LIST, i, item->nameid == map->list[sd->bl.m].noitemlist[i] || item->type == map->list[sd->bl.m].noitemlist[i] );+		if ( i < MAX_RESTRICTED_LIST )+			return 0;+		if ( !itemdb_isspecial( sd->status.inventory[n].card[0] ) ) {+			for ( slot = 0; slot < MAX_SLOTS; slot++ ) {+				if ( sd->status.inventory[n].card[slot] ) {+					struct item_data *i_data = itemdb->exists( sd->status.inventory[n].card[slot] );+					ARR_FIND( 0, MAX_RESTRICTED_LIST, i, i_data->nameid == map->list[sd->bl.m].noitemlist[i] || i_data->type == map->list[sd->bl.m].noitemlist[i] );+					if ( i < MAX_RESTRICTED_LIST )+						return 0;+				}+			}+		}+	}+ 	return 1; } @@ -4385,6 +4402,13 @@ 		if( item->class_upper&ITEMUPPER_THIRDBABY && sd->class_&JOBL_THIRD && sd->class_&JOBL_BABY ) break; 		return 0; 	}+	+	if ( map->list[sd->bl.m].flag.noitem ) {+		int i;+		ARR_FIND( 0, MAX_RESTRICTED_LIST, i, map->list[sd->bl.m].noitemlist[i] == nameid || item->type == map->list[sd->bl.m].noitemlist[i] );+		if( i < MAX_RESTRICTED_LIST )+			return 0;+	}  	return 1; }@@ -9236,6 +9260,30 @@ 			calc_flag = 1; 			continue; 		}+		+		if ( map->list[sd->bl.m].flag.noitem ) {+			int j, slot;+			struct item_data *i_data = itemdb->exists( sd->status.inventory[i].nameid );+			ARR_FIND( 0, MAX_RESTRICTED_LIST, j, map->list[sd->bl.m].noitemlist[j] == i_data->type || map->list[sd->bl.m].noitemlist[j] == sd->status.inventory[i].nameid );+			if ( j < MAX_RESTRICTED_LIST ) {+				pc_unequipitem(sd, i, 2);+				calc_flag = 1;+				continue;+			}+			if ( !itemdb_isspecial( sd->status.inventory[i].card[0] ) ) {+				for ( slot = 0; slot < MAX_SLOTS; slot++ ) {+					if ( sd->status.inventory[i].card[slot] ) {+						struct item_data *i_datac = itemdb->exists( sd->status.inventory[i].card[slot] );+						ARR_FIND( 0, MAX_RESTRICTED_LIST, j, map->list[sd->bl.m].noitemlist[j] == i_datac->type || map->list[sd->bl.m].noitemlist[j] == sd->status.inventory[i].card[slot] );+						if ( j < MAX_RESTRICTED_LIST ) {+							pc_unequipitem(sd, i, 2);+							calc_flag = 1;+							break;+						}+					}+				}+			}+		}  		if ( battle_config.unequip_restricted_equipment & 1 ) { 			int j;Index: map/map.c===================================================================--- map/map.c	(revision 14604)+++ map/map.c	(working copy)@@ -3176,6 +3176,8 @@ 		map->list[i].nocommand = 0;   // nocommand mapflag level 		map->list[i].bexp      = 100; // per map base exp multiplicator 		map->list[i].jexp      = 100; // per map job exp multiplicator+		for ( v = 0; v < MAX_RESTRICTED_LIST; v++ )+			 map->list[i].noitemlist[v] = -1; 		if( map->list[i].drop_list != NULL ) 			aFree(map->list[i].drop_list); 		map->list[i].drop_list = NULL;Index: map/map.h===================================================================--- map/map.h	(revision 14604)+++ map/map.h	(working copy)@@ -31,7 +31,7 @@ #define LOOTITEM_SIZE 10 #define MAX_MOBSKILL 50 #define MAX_MOB_LIST_PER_MAP 100-#define MAX_EVENTQUEUE 2+#define MAX_EVENTQUEUE 20 #define MAX_EVENTTIMER 32 #define NATURAL_HEAL_INTERVAL 500 #define MIN_FLOORITEM 2@@ -39,6 +39,7 @@ #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 #define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo]+#define MAX_RESTRICTED_LIST 50  #define BLOCK_SIZE 8 #define block_free_max 1048576@@ -647,6 +648,7 @@ 		unsigned noknockback : 1; 		unsigned notomb : 1; 		unsigned nocashshop : 1;+		unsigned noitem	: 1; 	} flag; 	struct point save; 	struct npc_data *npc[MAX_NPC_PER_MAP];@@ -658,6 +660,7 @@ 	int jexp;	// map experience multiplicator 	int bexp;	// map experience multiplicator 	int nocommand; //Blocks @/# commands for non-gms. [Skotlex]+	int noitemlist[MAX_RESTRICTED_LIST]; 	/** 	* Ice wall reference counter for bugreport:3574 	* - since there are a thousand mobs out there in a lot of maps checking on,
 
Last edited by a moderator:
Back
Top