summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-03 00:46:44 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-03 00:46:44 +0300
commit2b6f23670b3add2cb845b9606d13e6aad6360f11 (patch)
treea10d606892caf62330f657095358d0b0195ed186
parentdeeb2b5b36cbf69bedc5ab5f9fa37881f808b810 (diff)
downloadevol-hercules-2b6f23670b3add2cb845b9606d13e6aad6360f11.tar.gz
evol-hercules-2b6f23670b3add2cb845b9606d13e6aad6360f11.tar.bz2
evol-hercules-2b6f23670b3add2cb845b9606d13e6aad6360f11.tar.xz
evol-hercules-2b6f23670b3add2cb845b9606d13e6aad6360f11.zip
Add basic support for own collision types.
-rw-r--r--src/emap/init.c3
-rw-r--r--src/emap/map.c79
-rw-r--r--src/emap/map.h6
3 files changed, 88 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 09f3c1e..beff644 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -177,6 +177,9 @@ HPExport void plugin_init (void)
addHookPre("unit->can_move", eunit_can_move);
addHookPre("unit->walktoxy", eunit_walktoxy);
addHookPre("mail->invalid_operation", email_invalid_operation);
+ addHookPre("map->cell2gat", emap_cell2gat);
+ addHookPre("map->gat2cell", emap_gat2cell);
+ addHookPre("map->getcellp", emap_getcellp);
addHookPre("script->set_reg_npc_num", eset_reg_npcscope_num);
addHookPre("script->get_val_npc_num", eget_val_npcscope_num);
addHookPre("script->get_val_ref_num", eget_val_npcscope_num);
diff --git a/src/emap/map.c b/src/emap/map.c
index fc5e37d..97aa464 100644
--- a/src/emap/map.c
+++ b/src/emap/map.c
@@ -134,3 +134,82 @@ void emap_online_list(int fd)
send_online_list(fd, buf, ptr - buf);
aFree(buf);
}
+
+int emap_getcellp(struct map_data* m,
+ const struct block_list *bl,
+ int16 *xPtr, int16 *yPtr,
+ cell_chk *cellchkPtr)
+{
+ if (bl)
+ {
+ const cell_chk cellchk = *cellchkPtr;
+ if (cellchk == CELL_CHKWALL ||
+ cellchk == CELL_CHKPASS ||
+ cellchk == CELL_CHKNOPASS ||
+ cellchk == CELL_CHKNOREACH)
+ {
+ if (bl->type == BL_NPC)
+ {
+ }
+ }
+ }
+ return 0;
+}
+
+struct mapcell emap_gat2cell(int *gatPtr)
+{
+ struct mapcell cell;
+ const int gat = *gatPtr;
+
+ memset(&cell, 0, sizeof(struct mapcell));
+
+ switch (gat)
+ {
+ case 0: // walkable ground
+ cell.walkable = 1;
+ cell.shootable = 1;
+ cell.water = 0;
+ break;
+ case 1: // wall
+ cell.walkable = 0;
+ cell.shootable = 0;
+ cell.water = 0;
+ break;
+ case 2: // air allowed
+ cell.walkable = 0;
+ cell.shootable = 0;
+ cell.water = 0;
+ break;
+ case 3: // unwalkable water
+ cell.walkable = 0;
+ cell.shootable = 1;
+ cell.water = 1;
+ break;
+ case 4: // sit, walkable ground
+ cell.walkable = 1;
+ cell.shootable = 1;
+ cell.water = 0;
+ break;
+ default:
+ ShowWarning("map_gat2cell: unrecognized gat type '%d'\n", gat);
+ break;
+ }
+
+ hookStop();
+ return cell;
+}
+
+int emap_cell2gat(struct mapcell *cellPtr)
+{
+ struct mapcell cell = *cellPtr;
+ hookStop();
+ if (cell.walkable == 1 && cell.shootable == 1 && cell.water == 0)
+ return 0;
+ if (cell.walkable == 0 && cell.shootable == 0 && cell.water == 0)
+ return 1;
+ if (cell.walkable == 0 && cell.shootable == 1 && cell.water == 1)
+ return 3;
+
+ ShowWarning("map_cell2gat: cell has no matching gat type\n");
+ return 1;
+}
diff --git a/src/emap/map.h b/src/emap/map.h
index cd8dac8..5c6e899 100644
--- a/src/emap/map.h
+++ b/src/emap/map.h
@@ -16,5 +16,11 @@ int emap_addflooritem_post(int retVal,
int *third_charid,
int *flags);
void emap_online_list(int fd);
+int emap_getcellp(struct map_data* m,
+ const struct block_list *bl,
+ int16 *xPtr, int16 *yPtr,
+ cell_chk *cellchkPtr);
+struct mapcell emap_gat2cell(int *gatPtr);
+int emap_cell2gat(struct mapcell *cellPtr);
#endif // EVOL_MAP_MAP