diff options
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r-- | src/map/script-fun.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 1efa006..91beb96 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -3920,6 +3920,7 @@ void builtin_sc_start(ScriptState *st) // all those use ms so this checks for < 1s are not needed on those // and it would break the cooldown symbol since many spells have cooldowns less than 1s case StatusChange::SC_PHYS_SHIELD: + case StatusChange::SC_PHYS_SHIELD_ITEM: case StatusChange::SC_MBARRIER: case StatusChange::SC_COOLDOWN: case StatusChange::SC_COOLDOWN_MG: @@ -3929,7 +3930,10 @@ void builtin_sc_start(ScriptState *st) case StatusChange::SC_COOLDOWN_ENCH: case StatusChange::SC_COOLDOWN_KOY: case StatusChange::SC_COOLDOWN_UPMARMU: - break; + case StatusChange::SC_COOLDOWN_SG: + case StatusChange::SC_SLOWMOVE: + case StatusChange::SC_CANTMOVE: + break; default: // work around old behaviour of: @@ -4362,9 +4366,14 @@ void builtin_getitemlink(ScriptState *st) struct script_data *data; AString buf; data = &AARG(0); - ZString name = conv_str(st, data); + Option<P<struct item_data>> item_data_ = None; + + get_val(st, data); + if (data->is<ScriptDataStr>()) + item_data_ = itemdb_searchname(conv_str(st, data)); + else + item_data_ = itemdb_exists(wrap<ItemNameId>(conv_num(st, data))); - Option<P<struct item_data>> item_data_ = itemdb_searchname(name); OMATCH_BEGIN (item_data_) { OMATCH_CASE_SOME (item_data) @@ -5524,6 +5533,39 @@ void builtin_getmapmaxy(ScriptState *st) } /*========================================== + * Get the hash of a map + *------------------------------------------ + */ +static +void builtin_getmaphash(ScriptState *st) +{ + MapName mapname = stringish<MapName>(ZString(conv_str(st, &AARG(0)))); + P<map_local> m = TRY_UNWRAP(map_mapname2mapid(mapname), return); + push_int<ScriptDataInt>(st->stack, m->hash); +} + +/*========================================== + * Get the map name from a hash + *------------------------------------------ + */ +static +void builtin_getmapnamefromhash(ScriptState *st) +{ + int hash = conv_num(st, &AARG(0)); + MapName mapname; + for (auto& mit : maps_db) + { + map_local *ml = static_cast<map_local *>(mit.second.get()); + if (ml->hash == hash) + { + mapname = ml->name_; + break; + } + } + push_str<ScriptDataStr>(st->stack, mapname); +} + +/*========================================== * Get the NPC's info *------------------------------------------ */ @@ -5787,6 +5829,8 @@ BuiltinFunction builtin_functions[] = BUILTIN(getmap, "?"_s, 's'), BUILTIN(getmapmaxx, "M"_s, 'i'), BUILTIN(getmapmaxy, "M"_s, 'i'), + BUILTIN(getmaphash, "M"_s, 'i'), + BUILTIN(getmapnamefromhash, "i"_s, 's'), BUILTIN(mapexit, ""_s, '\0'), BUILTIN(freeloop, "i"_s, '\0'), BUILTIN(if_then_else, "iii"_s, 'v'), |