Commit ba75473a authored by Aephiex's avatar Aephiex Committed by nanahira

add Effect.UseCountLimit and Effect.CheckCountLimit (#151)

parent c500b776
......@@ -316,6 +316,8 @@ static const struct luaL_Reg effectlib[] = {
{ "IsActivated", scriptlib::effect_is_activated },
{ "GetActivateLocation", scriptlib::effect_get_activate_location },
{ "GetActivateSequence", scriptlib::effect_get_activate_sequence },
{ "CheckCountLimit", scriptlib::effect_check_count_limit },
{ "UseCountLimit", scriptlib::effect_use_count_limit },
{ NULL, NULL }
};
......
......@@ -530,3 +530,31 @@ int32 scriptlib::effect_get_activate_sequence(lua_State *L) {
lua_pushinteger(L, peffect->active_sequence);
return 1;
}
int32 scriptlib::effect_check_count_limit(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 p = lua_tointeger(L, 2);
lua_pushboolean(L, peffect->check_count_limit(p));
return 1;
}
int32 scriptlib::effect_use_count_limit(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 p = lua_tointeger(L, 2);
uint32 count = 1;
uint32 oath_only = 0;
uint32 code = peffect->count_code;
if(lua_gettop(L) > 2) {
count = lua_tointeger(L, 3);
if (lua_gettop(L) > 3)
oath_only = lua_toboolean(L, 4);
}
if (!oath_only || code & EFFECT_COUNT_CODE_OATH)
while(count) {
peffect->dec_count(p);
count--;
}
return 0;
}
......@@ -316,6 +316,8 @@ public:
static int32 effect_is_activated(lua_State *L);
static int32 effect_get_activate_location(lua_State *L);
static int32 effect_get_activate_sequence(lua_State *L);
static int32 effect_check_count_limit(lua_State *L);
static int32 effect_use_count_limit(lua_State *L);
//Group functions
static int32 group_new(lua_State *L);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment