Jump to content
  • 0

Help to make a mapflag work again


Clare

Question


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  18
  • Reputation:   7
  • Joined:  07/28/12
  • Last Seen:  

Hi guys, I need help!
 
Would i like to edit this old Mapflag NoItem NoSkill2, but I dont know much about making changes to the Source, someone could help me with this?
 
What I want do?
 
Simply do this back to work, with the changes that occurred in the emulator it has become incompatible
 

MapFlag original topic:
http://rathena.org/board/topic/59578-mapflags-noitem-and-noskill2/

 

Mapflag Source Code:

Index: map.c
===================================================================
--- map.c (revision 15629)
+++ map.c (working copy)
@@ -2877,6 +2877,8 @@
  map[i].bexp      = 100;  // per map base exp multiplicator
  map[i].jexp      = 100;  // per map job exp multiplicator
  memset(map[i].drop_list, 0, sizeof(map[i].drop_list));  // pvp nightmare drop list
+ memset(map[i].noiteml, 0, sizeof(map[i].noiteml));      // noitem item list mapflag [ Wynn ]
+ memset(map[i].noskilll, 0, sizeof(map[i].noskilll));      // noskill2 item list mapflag [ Wynn ]
 
  // adjustments
  if( battle_config.pk_mode )
Index: map.h
===================================================================
--- map.h (revision 15629)
+++ map.h (working copy)
@@ -67,6 +67,9 @@
 #define MAPID_UPPERMASK 0x0fff
 #define MAPID_BASEMASK 0x00ff
 #define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK)
+
+#define MAX_RESTRICTED_LIST 50
+
 //First Jobs
 //Note the oddity of the novice:
 //Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type, too...
@@ -522,6 +525,8 @@
  unsigned guildlock :1;
  unsigned src4instance : 1; // To flag this map when it's used as a src map for instances
  unsigned reset :1; // [Daegaladh]
+ unsigned noitem : 1; // [ Wynn ]
+ unsigned noskill2 : 1;
  } flag;
  struct point save;
  struct npc_data *npc[MAX_NPC_PER_MAP];
@@ -537,6 +542,8 @@
  int jexp; // map experience multiplicator
  int bexp; // map experience multiplicator
  int nocommand; //Blocks @/# commands for non-gms. [Skotlex]
+ int noiteml[MAX_RESTRICTED_LIST]; // [ Wynn ]
+ int noskilll[MAX_RESTRICTED_LIST];
  // Instance Variables
  int instance_id;
  int instance_src_map;
Index: npc.c
===================================================================
--- npc.c (revision 15629)
+++ npc.c (working copy)
@@ -3250,6 +3250,42 @@
  map[m].flag.guildlock=state;
  else if (!strcmpi(w3,"reset"))
  map[m].flag.reset=state;
+ else if (!strcmpi(w3,"noitem")   ||
+  !strcmpi(w3,"noskill2"))
+ {
+ int i = 0, type = 0, id = 0;
+ char *arr = NULL, *list = strdup(w4);
+
+ if ( !strcmpi(w3,"noitem") ) type = 1;
+ else if ( !strcmpi(w3,"noskill2") ) type = 2;
+
+ arr = strtok( list, " ,.+-" );
+ while (arr != NULL) {
+ id = atoi(arr);
+ switch (type) {
+ case 1:
+ if ( id && ( itemdb_exists( id ) || id < 8 ) )
+ map[m].noiteml[i] = id;
+ else
+ ShowWarning("npc_parse_mapflag: Item ID \"%s\" does not exist.\n           Mapflag noitem: At %s (file '%s', line '%d').\n", arr, map[m].name, filepath, strline(buffer,start-buffer));
+ break;
+ case 2:
+ if ( id && skill_get_index( id ) )
+ map[m].noskilll[i] = id;
+ else
+ ShowWarning("npc_parse_mapflag: Skill ID \"%s\" does not exist.\n           Mapflag noitem: At %s (file '%s', line '%d').\n", arr, map[m].name, filepath, strline(buffer,start-buffer));
+ break;
+ default: return strchr(start,'\n');
+ }
+ i++;
+ arr = strtok(NULL," ,.+-");
+ }
+ free(list);
+ switch (type) {
+ case 1: map[m].flag.noitem = state; break;
+ case 2: map[m].flag.noskill2 = state; break;
+ }
+ }
  else
  ShowError("npc_parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').\n", w3, filepath, strline(buffer,start-buffer));
 
Index: pc.c
===================================================================
--- pc.c (revision 15629)
+++ pc.c (working copy)
@@ -837,6 +837,13 @@
  return 0;
  if(map[sd->bl.m].flag.battleground && ((item->flag.no_equip&8) || !pc_isAllowedCardOn(sd,item->slot,n,8)))
  return 0;
+ if(map[sd->bl.m].flag.noitem)
+ {
+ int i;
+ ARR_FIND(0, MAX_RESTRICTED_LIST, i, map[sd->bl.m].noiteml[i] == sd->status.inventory[n].nameid || ( map[sd->bl.m].noiteml[i] < 9 && map[sd->bl.m].noiteml[i] & 2)); // Grupo 2 : Sem equipamentos
+ if ( i < MAX_RESTRICTED_LIST )
+ return 0;
+ }
  if(map[sd->bl.m].flag.restricted)
  {
  int flag =8*map[sd->bl.m].zone;
@@ -3863,7 +3870,14 @@
  return 0;
  break;
  }
-
+ if ( map[sd->bl.m].flag.noitem ) {
+ int i;
+ ARR_FIND(0, MAX_RESTRICTED_LIST, i, map[sd->bl.m].noiteml[i] == nameid || ( map[sd->bl.m].noiteml[i] < 9 && map[sd->bl.m].noiteml[i] & 1)); // Grupo 1 : Sem itens consumíveis
+ if( i < MAX_RESTRICTED_LIST ) {
+ clif_displaymessage( sd->fd, "You cannot use this item." );
+ return 0;
+ }
+ }
  if( nameid >= 12153 && nameid <= 12182 && sd->md != NULL )
  return 0; // Mercenary Scrolls
 
@@ -7515,6 +7529,17 @@
  return 0;
  }
 
+ if ( map[sd->bl.m].flag.noitem ) {
+ int b;
+ ARR_FIND(0, MAX_RESTRICTED_LIST, b, map[sd->bl.m].noiteml[b] == sd->status.inventory[n].nameid ||
+ ( map[sd->bl.m].noiteml[b] < 9 && map[sd->bl.m].noiteml[b] & 2 ) // Grupo 2 : Sem equipamentos
+ );
+ if ( b < MAX_RESTRICTED_LIST ) {
+ clif_equipitemack(sd,n,0,0);
+ return 0;
+ }
+ }
+
  id = sd->inventory_data[n];
  pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
 
@@ -7862,6 +7887,19 @@
  continue;
  }
 
+ if ( map[sd->bl.m].flag.noitem ) {
+ int b;
+ calc_flag = 1;
+ for(b=0;b<MAX_RESTRICTED_LIST;b++)
+ if ( ( map[sd->bl.m].noiteml[b] < 9 && map[sd->bl.m].noiteml[b] & 2 ) || // Grupo 2 : Sem equipamentos
+  ( i >= 0 && map[sd->bl.m].noiteml[b] == sd->status.inventory[i].nameid )
+ ) {
+ clif_displaymessage( sd->fd, "You cannot use this item." );
+ pc_unequipitem(sd, i, 2);
+ continue;
+ }
+ }
+
  if( it )
  { // check for forbiden items.
  int flag =
@@ -7878,7 +7916,7 @@
  }
  }
 
- if( calc_flag && sd->state.active )
+ if( sd->state.active && ( calc_flag || map[sd->state.pmap].flag.noitem ) )
  {
  pc_checkallowskill(sd);
  status_calc_pc(sd,0);
Index: skill.c
===================================================================
--- skill.c (revision 15629)
+++ skill.c (working copy)
@@ -442,7 +442,7 @@
 // [MouseJstr] - skill ok to cast? and when?
 int skillnotok (int skillid, struct map_session_data *sd)
 {
- int i,m;
+ int i,m,j;
  nullpo_retr (1, sd);
  m = sd->bl.m;
  i = skill_get_index(skillid);
@@ -567,11 +567,14 @@
  break;
 
  }
- return (map[m].flag.noskill);
+// return (map[m].flag.noskill);
+ ARR_FIND(1, MAX_RESTRICTED_LIST, j, map[sd->bl.m].noskilll[j] == skillid );
+ return ( map[m].flag.noskill || ( j < MAX_RESTRICTED_LIST && map[m].flag.noskill2 ) );
 }
 
 int skillnotok_hom(int skillid, struct homun_data *hd)
 {
+ int j;
  int i = skill_get_index(skillid);
  nullpo_retr(1,hd);
 
@@ -581,6 +584,12 @@
  if (hd->blockskill[i] > 0)
  return 1;
 
+ if ( map[hd->master->bl.m].flag.noskill2 ) {
+ ARR_FIND(1, MAX_RESTRICTED_LIST, j, map[hd->master->bl.m].noskilll[j] == skillid );
+ if ( j < MAX_RESTRICTED_LIST )
+ return 1;
+ }
+
  //Use master's criteria.
  return skillnotok(skillid, hd->master);
 }
Index: status.c
===================================================================
--- status.c (revision 15629)
+++ status.c (working copy)
@@ -2389,6 +2389,12 @@
  }
  if(!data->script)
  continue;
+ if ( map[sd->bl.m].flag.noitem ) {
+ int b;
+ ARR_FIND(0, MAX_RESTRICTED_LIST, b, c == map[sd->bl.m].noiteml[b] || ( map[sd->bl.m].noiteml[b] < 9 && map[sd->bl.m].noiteml[b] & 4 ) );
+ if ( b < MAX_RESTRICTED_LIST )
+ continue;
+ }
  if(data->flag.no_equip) { //Card restriction checks.
  if(map[sd->bl.m].flag.restricted && data->flag.no_equip&(8*map[sd->bl.m].zone))
  continue;
After many failed attempts managed to solve the problem by myself.
Solved!
Edited by Suzuya
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...