summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c85
1 files changed, 64 insertions, 21 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 0e021f2c8..73bfca5b9 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -16586,7 +16586,7 @@ static BUILDIN(npcwalkto)
} else {
status_calc_npc(nd, SCO_NONE);
}
- unit->walktoxy(&nd->bl, x, y, 0);
+ unit->walk_toxy(&nd->bl, x, y, 0);
}
return true;
@@ -19708,7 +19708,7 @@ static BUILDIN(setunitdata)
unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT);
break;
case UDT_WALKTOXY:
- if (!unit->walktoxy(bl, (short) val, (short) val2, 2))
+ if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0)
unit->movepos(bl, (short) val, (short) val2, 0, 0);
break;
case UDT_SPEED:
@@ -19755,7 +19755,7 @@ static BUILDIN(setunitdata)
clif->changelook(bl, LOOK_WEAPON, val);
break;
case UDT_LOOKDIR:
- unit->setdir(bl, (uint8) val);
+ unit->set_dir(bl, (enum unit_dir)val);
break;
case UDT_CANMOVETICK:
md->ud.canmove_tick = val;
@@ -19879,7 +19879,7 @@ static BUILDIN(setunitdata)
unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT);
break;
case UDT_WALKTOXY:
- if (!unit->walktoxy(bl, (short) val, (short) val2, 2))
+ if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0)
unit->movepos(bl, (short) val, (short) val2, 0, 0);
break;
case UDT_SPEED:
@@ -19887,7 +19887,7 @@ static BUILDIN(setunitdata)
status->calc_misc(bl, &hd->base_status, hd->homunculus.level);
break;
case UDT_LOOKDIR:
- unit->setdir(bl, (unsigned char) val);
+ unit->set_dir(bl, (enum unit_dir)val);
break;
case UDT_CANMOVETICK:
hd->ud.canmove_tick = val;
@@ -20018,7 +20018,7 @@ static BUILDIN(setunitdata)
unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT);
break;
case UDT_WALKTOXY:
- if (!unit->walktoxy(bl, (short) val, (short) val2, 2))
+ if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0)
unit->movepos(bl, (short) val, (short) val2, 0, 0);
break;
case UDT_SPEED:
@@ -20026,7 +20026,7 @@ static BUILDIN(setunitdata)
status->calc_misc(bl, &pd->status, pd->pet.level);
break;
case UDT_LOOKDIR:
- unit->setdir(bl, (unsigned char) val);
+ unit->set_dir(bl, (enum unit_dir)val);
break;
case UDT_CANMOVETICK:
pd->ud.canmove_tick = val;
@@ -20151,7 +20151,7 @@ static BUILDIN(setunitdata)
unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT);
break;
case UDT_WALKTOXY:
- if (!unit->walktoxy(bl, (short) val, (short) val2, 2))
+ if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0)
unit->movepos(bl, (short) val, (short) val2, 0, 0);
break;
case UDT_SPEED:
@@ -20159,7 +20159,7 @@ static BUILDIN(setunitdata)
status->calc_misc(bl, &mc->base_status, mc->db->lv);
break;
case UDT_LOOKDIR:
- unit->setdir(bl, (unsigned char) val);
+ unit->set_dir(bl, (enum unit_dir)val);
break;
case UDT_CANMOVETICK:
mc->ud.canmove_tick = val;
@@ -20285,7 +20285,7 @@ static BUILDIN(setunitdata)
unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT);
break;
case UDT_WALKTOXY:
- if (!unit->walktoxy(bl, (short) val, (short) val2, 2))
+ if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0)
unit->movepos(bl, (short) val, (short) val2, 0, 0);
break;
case UDT_SPEED:
@@ -20293,7 +20293,7 @@ static BUILDIN(setunitdata)
status->calc_misc(bl, &ed->base_status, ed->db->lv);
break;
case UDT_LOOKDIR:
- unit->setdir(bl, (unsigned char) val);
+ unit->set_dir(bl, (enum unit_dir)val);
break;
case UDT_CANMOVETICK:
ed->ud.canmove_tick = val;
@@ -20414,7 +20414,7 @@ static BUILDIN(setunitdata)
unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT);
break;
case UDT_WALKTOXY:
- if (!unit->walktoxy(bl, (short) val, (short) val2, 2))
+ if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0)
unit->movepos(bl, (short) val, (short) val2, 0, 0);
break;
case UDT_CLASS:
@@ -20425,7 +20425,7 @@ static BUILDIN(setunitdata)
status->calc_misc(bl, &nd->status, nd->level);
break;
case UDT_LOOKDIR:
- unit->setdir(bl, (unsigned char) val);
+ unit->set_dir(bl, (enum unit_dir)val);
break;
case UDT_STR:
nd->status.str = (unsigned short) val;
@@ -21149,7 +21149,10 @@ static BUILDIN(unitwalk)
if (script_hasdata(st, 4)) {
int x = script_getnum(st, 3);
int y = script_getnum(st, 4);
- script_pushint(st, unit->walktoxy(bl, x, y, 0));// We'll use harder calculations.
+ if (unit->walk_toxy(bl, x, y, 0) == 0) // We'll use harder calculations.
+ script_pushint(st, 1);
+ else
+ script_pushint(st, 0);
}
else {
int target_id = script_getnum(st, 3);
@@ -21159,6 +21162,38 @@ static BUILDIN(unitwalk)
return true;
}
+/**
+ * Checks if a unit is walking.
+ *
+ * Returns 1 if unit is walking, 0 if unit is not walking and -1 on error.
+ *
+ * @code{.herc}
+ * unitiswalking({<GID>});
+ * @endcode
+ *
+ **/
+static BUILDIN(unitiswalking)
+{
+ int gid = script_hasdata(st, 2) ? script_getnum(st, 2) : st->rid;
+ struct block_list *bl = map->id2bl(gid);
+
+ if (bl == NULL) {
+ ShowWarning("buildin_unitiswalking: Error in finding object for GID %d!\n", gid);
+ script_pushint(st, -1);
+ return false;
+ }
+
+ if (unit->bl2ud(bl) == NULL) {
+ ShowWarning("buildin_unitiswalking: Error in finding unit_data for GID %d!\n", gid);
+ script_pushint(st, -1);
+ return false;
+ }
+
+ script_pushint(st, unit->is_walking(bl));
+
+ return true;
+}
+
/// Kills the unit
///
/// unitkill <unit_id>;
@@ -23278,7 +23313,6 @@ static BUILDIN(progressbar_unit)
}
static BUILDIN(pushpc)
{
- uint8 dir;
int cells, dx, dy;
struct map_session_data* sd;
@@ -23287,14 +23321,14 @@ static BUILDIN(pushpc)
return true;
}
- dir = script_getnum(st,2);
- cells = script_getnum(st,3);
+ enum unit_dir dir = script_getnum(st, 2);
+ cells = script_getnum(st,3);
- if (dir > 7) {
+ if (dir >= UNIT_DIR_MAX) {
ShowWarning("buildin_pushpc: Invalid direction %d specified.\n", dir);
script->reportsrc(st);
- dir%= 8; // trim spin-over
+ dir %= UNIT_DIR_MAX; // trim spin-over
}
if(!cells)
@@ -23303,10 +23337,11 @@ static BUILDIN(pushpc)
}
else if(cells<0)
{// pushing backwards
- dir = (dir+4)%8; // turn around
- cells = -cells;
+ dir = unit_get_opposite_dir(dir);
+ cells = -cells;
}
+ Assert_retr(false, dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX);
dx = dirx[dir];
dy = diry[dir];
@@ -27061,6 +27096,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(getunittitle,"i"),
BUILDIN_DEF(setunittitle,"is"),
BUILDIN_DEF(unitwalk,"ii?"),
+ BUILDIN_DEF(unitiswalking, "?"),
BUILDIN_DEF(unitkill,"i"),
BUILDIN_DEF(unitwarp,"isii"),
BUILDIN_DEF(unitattack,"iv?"),
@@ -27893,6 +27929,13 @@ static void script_hardcoded_constants(void)
script->set_constant("ISF_INSTANTCAST", ISF_INSTANTCAST, false, false);
script->set_constant("ISF_CASTONSELF", ISF_CASTONSELF, false, false);
+ script->constdb_comment("Item Bound Types");
+ script->set_constant("IBT_ANY", IBT_NONE, false, false); // for *checkbound()
+ script->set_constant("IBT_ACCOUNT", IBT_ACCOUNT, false, false);
+ script->set_constant("IBT_GUILD", IBT_GUILD, false, false);
+ script->set_constant("IBT_PARTY", IBT_PARTY, false, false);
+ script->set_constant("IBT_CHARACTER", IBT_CHARACTER, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);