• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

For people who learned C# before C++. Am i right with this LUA code?

rockseller

Lua & .NET Programmer
Joined
May 10, 2008
Messages
159
Reaction score
9
Location
México
Original:
Code:
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN) 
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) 
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.4, -MIN, -0.4, -MAX)

Explained:

Code:
-- setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN) 
-- its equal to
-- combat.Type = COMBAT_MANADRAIN
-- COMBAT_MANADRAIN = Defined on C++ source code

-- setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) 
-- its equal to
-- combat.Effect = CONST_ME_MAGIC_RED
-- CONST_ME_MAGIC_RED = Defined on C++ source code

-- setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.4, -MIN, -0.4, -MAX) 
-- its equal to
-- combat.Formula = COMBAT_FORMULA_LEVELMAGIC(-0.4, -200, -0.4, -300)
-- COMBAT_FORMULA_LEVELMAGIC(Recieve_1, Recieve_2, Recieve_3, Recieve_4)
-- Formula property, what it does: its just a function that recieves parameters to return a final damage value, which will be 
-- used once the object gets called inside doCombat()

Am i right?
 
constats/variables are defined in /data/lib/000-constant.lua :|
Otherwise they would be nil values in Lua.

Also this code:
LUA:
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.4, -MIN, -0.4, -MAX)
Would only be valid for TFS 0.3.5 and older.

It's been changed in 0.3.6:
[cpp] switch(formulaType)
{
case FORMULA_LEVELMAGIC:
{
min = (int32_t)((player->getLevel() / minl + player->getMagicLevel() * minm) * 1. * mina + minb);
max = (int32_t)((player->getLevel() / maxl + player->getMagicLevel() * maxm) * 1. * maxa + maxb);
if(minc && std::abs(min) < std::abs(minc))
min = minc;

if(maxc && std::abs(max) < std::abs(maxc))
max = maxc;

player->increaseCombatValues(min, max, params.useCharges, true);
return true;
}[/cpp]
:p
 
Last edited:
Back
Top