summaryrefslogtreecommitdiff
path: root/src/map/skill.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-04 12:41:49 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-04 12:41:49 +0000
commitff2dd3a0c696cbcd659837ff736f927fab8937e3 (patch)
tree03aec2e46cbd950af34cfcb4995580e6a1deeae4 /src/map/skill.c
parent1903717ee1d6f3d7834b8ed807cf40f52364129b (diff)
downloadhercules-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/skill.c')
-rw-r--r--src/map/skill.c73
1 files changed, 30 insertions, 43 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 692a94e23..3e8ca67fa 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -1996,24 +1996,27 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, int
int skill_count_water (struct block_list *src, int range)
{
- int i,x,y,cnt = 0,size = range*2+1;
+ int x,y,cnt = 0;
struct skill_unit *unit;
- for (i=0;i<size*size;i++) {
- x = src->x+(i%size-range);
- y = src->y+(i/size-range);
- if (map_getcell(src->m,x,y,CELL_CHKWATER)) {
- cnt++;
- continue;
- }
- unit = map_find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL);
- if (!unit)
- unit = map_find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL);
- if (unit) {
- cnt++;
- skill_delunit(unit);
+ for( y = src->y - range; y <= src->y + range; ++y )
+ {
+ for( x = src->x - range; x <= src->x + range; ++x )
+ {
+ if (map_getcell(src->m,x,y,CELL_CHKWATER)) {
+ cnt++;
+ continue;
+ }
+ unit = map_find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL);
+ if (!unit)
+ unit = map_find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL);
+ if (unit) {
+ cnt++;
+ skill_delunit(unit);
+ }
}
}
+
return cnt;
}
@@ -7066,6 +7069,7 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in
if (sce)
status_change_end(bl,type,-1);
break;
+
case UNT_HERMODE: //Clear Hermode if the owner moved.
if (sce && sce->val3 == BCT_SELF && sce->val4 == sg->group_id)
status_change_end(bl,type,-1);
@@ -8758,34 +8762,17 @@ int skill_frostjoke_scream (struct block_list *bl, va_list ap)
/*==========================================
*
*------------------------------------------*/
-void skill_unitsetmapcell (struct skill_unit *src, int skill_num, int skill_lv, int flag)
+static void skill_unitsetmapcell (struct skill_unit *src, int skill_num, int skill_lv, cell_t cell, bool flag)
{
- int i,x,y,range = skill_get_unit_range(skill_num,skill_lv);
- int size = range*2+1;
+ int range = skill_get_unit_range(skill_num,skill_lv);
+ int x,y;
- for (i=0;i<size*size;i++) {
- x = src->bl.x+(i%size-range);
- y = src->bl.y+(i/size-range);
- map_setcell(src->bl.m,x,y,flag);
- }
+ for( y = src->bl.y - range; y <= src->bl.y + range; ++y )
+ for( x = src->bl.x - range; x <= src->bl.x + range; ++x )
+ map_setcell(src->bl.m, x, y, cell, flag);
}
/*==========================================
- * Sets a map cell around the caster, according to the skill's splash range.
- *------------------------------------------*/
-void skill_setmapcell (struct block_list *src, int skill_num, int skill_lv, int flag)
-{
- int i,x,y,range = skill_get_splash(skill_num, skill_lv);
- int size = range*2+1;
-
- for (i=0;i<size*size;i++) {
- x = src->x+(i%size-range);
- y = src->y+(i/size-range);
- map_setcell(src->m,x,y,flag);
- }
-}
-
-/*==========================================
*
*------------------------------------------*/
int skill_attack_area (struct block_list *bl, va_list ap)
@@ -9241,13 +9228,13 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int
switch (group->skill_id) {
case SA_LANDPROTECTOR:
- skill_unitsetmapcell(unit,SA_LANDPROTECTOR,group->skill_lv,CELL_SETLANDPROTECTOR);
+ skill_unitsetmapcell(unit,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true);
break;
case HP_BASILICA:
- skill_unitsetmapcell(unit,HP_BASILICA,group->skill_lv,CELL_SETBASILICA);
+ skill_unitsetmapcell(unit,HP_BASILICA,group->skill_lv,CELL_BASILICA,true);
break;
case WZ_ICEWALL:
- skill_unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_SETICEWALL);
+ skill_unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true);
break;
default:
if (group->state.song_dance&0x1) //Check for dissonance.
@@ -9282,13 +9269,13 @@ int skill_delunit (struct skill_unit* unit)
switch (group->skill_id) {
case SA_LANDPROTECTOR:
- skill_unitsetmapcell(unit,SA_LANDPROTECTOR,group->skill_lv,CELL_CLRLANDPROTECTOR);
+ skill_unitsetmapcell(unit,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,false);
break;
case HP_BASILICA:
- skill_unitsetmapcell(unit,HP_BASILICA,group->skill_lv,CELL_CLRBASILICA);
+ skill_unitsetmapcell(unit,HP_BASILICA,group->skill_lv,CELL_BASILICA,false);
break;
case WZ_ICEWALL:
- skill_unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_CLRICEWALL);
+ skill_unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false);
break;
}