diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-01-04 12:41:49 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-01-04 12:41:49 +0000 |
commit | ff2dd3a0c696cbcd659837ff736f927fab8937e3 (patch) | |
tree | 03aec2e46cbd950af34cfcb4995580e6a1deeae4 /src/map/script.c | |
parent | 1903717ee1d6f3d7834b8ed807cf40f52364129b (diff) | |
download | hercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.tar.gz hercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.tar.bz2 hercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.tar.xz hercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.zip |
Modified the map_setcell() code to to use a boolean flag instead of needing SET_ / CLR_ pairs of defines (topic:174323).
Also removed script object 'setcell', added script function 'setcell'.
- Now you can manipulate cell information without needing @loadnpc
- You can also manipulate the terrain ('gat') type itself, using the new cell_walkable, cell_shootable and cell_water constants
(currently the implementation uses bit flags too, so to get the type you want, you need to adjust the flags one by one)
- This breaks current scripts, so please adjust places that use setcell
(also be sure to _only_ use predefined constants, not direct numbers)
- Details can be found in the script reference.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12009 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index a52bf0323..e5bed56a6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12943,6 +12943,33 @@ BUILDIN_FUNC(openmail) return 0; } +/// Modifies flags of cells in the specified area. +/// +/// setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>; +/// +/// @see cell_* constants in const.txt for the types +BUILDIN_FUNC(setcell) +{ + int m = map_mapname2mapid(script_getstr(st,2)); + int x1 = script_getnum(st,3); + int y1 = script_getnum(st,4); + int x2 = script_getnum(st,5); + int y2 = script_getnum(st,6); + cell_t type = (cell_t)script_getnum(st,7); + bool flag = (bool)script_getnum(st,8); + + int x,y; + + if( x1 > x2 ) swap(x1,x2); + if( y1 > y2 ) swap(y1,y2); + + for( y = y1; y <= y2; ++y ) + for( x = x1; x <= x2; ++x ) + map_setcell(m, x, y, type, flag); + + return 0; +} + // declarations that were supposed to be exported from npc_chat.c #ifdef PCRE_SUPPORT @@ -13285,5 +13312,6 @@ struct script_function buildin_func[] = { BUILDIN_DEF(checkvending,"*"), BUILDIN_DEF(checkchatting,"*"), BUILDIN_DEF(openmail,""), + BUILDIN_DEF(setcell,"siiiiii"), {NULL,NULL,NULL}, }; |