Jump to content
  • 0

How to create a new Mapflag?


Neutral

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  11/03/16
  • Last Seen:  

Hello all, right now I'm in the process of learning how things work in rAthena and I came across mapflags and noticed all my available options and what they offer me and thought it was a really cool feature. However I also wanted to know something in particular. How does one go about adding their own custom/new mapflag if they so desire it?

My first instinct was to look on the wiki. I went there and noticed there was a mapflag section under scripting but unfortunately that just directs me to a 404 page so I can't view anything. I also tried googling and searching on the forums but couldn't find an existing topic that already talks about this in particular. I also found the process of adding a new mapflag but it was for hercules on their wiki, I wanted to play it safe though by not following those instructions since I know hercules and rAthena are not one of the same. Therefore I decided to make this thread here since I'm pretty certain making a new mapflag would count as a source edit. Thank you all for your support. 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

To make the mapflag usable with @mapflag, open atcommand.c, ACMD_FUNC(mapflag) and add it to the list of existing flags:

		checkflag(nousecart);			checkflag(noitemconsumption);	checkflag(nosumstarmiracle);	checkflag(nomineeffect);
		checkflag(nolockon);			checkflag(notomb);				checkflag(nocostume);			checkflag(gvg_te);
		checkflag(gvg_te_castle);		checkflag(newmapflag);			checkflag(newmapflag2);
...
	setflag(nousecart);			setflag(noitemconsumption);	setflag(nosumstarmiracle);		setflag(nomineeffect);
	setflag(nolockon);			setflag(notomb);			setflag(nocostume);				setflag(gvg_te);
	setflag(gvg_te_castle);		setflag(newmapflag);		setflag(newmapflag2);

To make the mapflag readable from a script, you'll have to add the flag as a constant first:
Go in script.c, search for "MF_NOTOMB" and add your flag at the end of the list, such as:

	MF_NOTOMB,
	MF_SKILL_DAMAGE,	//60
	MF_NOCOSTUME,
	MF_GVG_TE_CASTLE,
	MF_GVG_TE,
	MF_NEWMAPFLAG = 100,	// Custom flags
	MF_NEWMAPFLAG2,	// Custom flags
};

and then add it as a script constant. Open script_constants.h and add

	export_constant(MF_NOTOMB);
	export_constant(MF_SKILL_DAMAGE);
	export_constant(MF_NOCOSTUME);
	export_constant(MF_GVG_TE_CASTLE);
	export_constant(MF_GVG_TE);
	export_constant(MF_NEWMAPFLAG); // Custom flags
	export_constant(MF_NEWMAPFLAG2);

Now you'll have to add the mapflag to the map structure, so go in map.h:

		unsigned nocostume : 1; // Disable costume sprites [Cydh]
		unsigned newmapflag : 1; // Custom flag
		unsigned newmapflag2 : 1; // Custom flag2
		unsigned gvg_te : 1; // GVG WOE:TE. This was added as purpose to change 'gvg' for GVG TE, so item_noequp, skill_nocast exlude GVG TE maps from 'gvg' (flag &4)
		unsigned gvg_te_castle : 1; // GVG WOE:TE Castle
#ifdef ADJUST_SKILL_DAMAGE
		unsigned skill_damage : 1;
#endif
	} flag;

You have to make it so that the script engine can read your flag, so go in npc.c and ctrl-f "nowarp":

	else if (!strcmpi(w3,"noteleport"))
		map[m].flag.noteleport=state;
	else if (!strcmpi(w3,"nowarp"))
		map[m].flag.nowarp=state;
	else if (!strcmpi(w3,"newmapflag"))
		map[m].flag.newmapflag=state;
	else if (!strcmpi(w3,"newmapflag2"))
		map[m].flag.newmapflag2=state;
	else if (!strcmpi(w3,"nowarpto"))
		map[m].flag.nowarpto=state;

You should now be done, but if you want to make your flag work with the getmapflag/setmapflag/removemapflag script commands, you'll have to edit script.c:

//BUILDIN_FUNC(getmapflag)
			case MF_NEWMAPFLAG:			script_pushint(st,map[m].flag.newmapflag); break;

//BUILDIN_FUNC(setmapflag)
			case MF_NEWMAPFLAG:			map[m].flag.newmapflag = 1; break;

//BUILDIN_FUNC(removemapflag)
			case MF_NEWMAPFLAG:				map[m].flag.newmapflag = 0; break;

Now you can use your mapflag in the source with (map[m].flag.newmapflag) { ... }

Good luck ;O!

  • Upvote 3
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  281
  • Reputation:   14
  • Joined:  10/14/13
  • Last Seen:  

33 minutes ago, Neutral said:

Hello all, right now I'm in the process of learning how things work in rAthena and I came across mapflags and noticed all my available options and what they offer me and thought it was a really cool feature. However I also wanted to know something in particular. How does one go about adding their own custom/new mapflag if they so desire it?

My first instinct was to look on the wiki. I went there and noticed there was a mapflag section under scripting but unfortunately that just directs me to a 404 page so I can't view anything. I also tried googling and searching on the forums but couldn't find an existing topic that already talks about this in particular. I also found the process of adding a new mapflag but it was for hercules on their wiki, I wanted to play it safe though by not following those instructions since I know hercules and rAthena are not one of the same. Therefore I decided to make this thread here since I'm pretty certain making a new mapflag would count as a source edit. Thank you all for your support. 

You can use this for your referrence https://github.com/rathena/rathena/wiki/Mapflag

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  11/03/16
  • Last Seen:  

Thank you that guides me in a better direction.

 

Thank you very much Tokei that's very useful information! I'll make sure to put it to great use. :)

Link to comment
Share on other sites

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...