Advertisement
dalvorsn

Untitled

Feb 9th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. int32_t LuaScriptInterface::luaSetCombatFormula(lua_State* L)
  2. {
  3.     //setCombatFormula(combat, type, mina, minb, maxa, maxb[, minl, maxl[, minm, maxm[, minc[, maxc]]]])
  4.     ScriptEnviroment* env = getEnv();
  5.     if(env->getScriptId() != EVENT_ID_LOADING)
  6.     {
  7.         errorEx("This function can only be used while loading the script.");
  8.         lua_pushboolean(L, false);
  9.         return 1;
  10.     }
  11.  
  12.     int32_t params = lua_gettop(L), minc = 0, maxc = 0;
  13.     if(params > 11)
  14.         maxc = popNumber(L);
  15.  
  16.     if(params > 10)
  17.         minc = popNumber(L);
  18.  
  19.     double minm = g_config.getDouble(ConfigManager::FORMULA_MAGIC), maxm = minm,
  20.         minl = g_config.getDouble(ConfigManager::FORMULA_LEVEL), maxl = minl;
  21.     if(params > 8)
  22.     {
  23.         maxm = popFloatNumber(L);
  24.         minm = popFloatNumber(L);
  25.     }
  26.  
  27.     if(params > 6)
  28.     {
  29.         maxl = popFloatNumber(L);
  30.         minl = popFloatNumber(L);
  31.     }
  32.  
  33.     double maxb = popFloatNumber(L), maxa = popFloatNumber(L),
  34.         minb = popFloatNumber(L), mina = popFloatNumber(L);
  35.     formulaType_t type = (formulaType_t)popNumber(L);
  36.     if(Combat* combat = env->getCombatObject(popNumber(L)))
  37.     {
  38.         combat->setPlayerCombatValues(type, mina, minb, maxa, maxb, minl, maxl, minm, maxm, minc, maxc);
  39.         lua_pushboolean(L, true);
  40.     }
  41.     else
  42.     {
  43.         errorEx(getError(LUA_ERROR_COMBAT_NOT_FOUND));
  44.         lua_pushboolean(L, false);
  45.     }
  46.  
  47.     return 1;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement