• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Random Damage math.random SPELL

mackerel

Well-Known Member
Joined
Apr 26, 2017
Messages
398
Solutions
18
Reaction score
74
The following code sets random value but it does it only once, I have to type /reload spells in order for new value to be generated

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 29)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -8.2, 1, -12.2, 1)

local condition = createConditionObject(CONDITION_FIRE)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 10, 2000, -hit)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    local position1 = {x=getCreaturePosition(getCreatureTarget(cid)).x+2, y=getCreaturePosition(getCreatureTarget(cid)).y, z=getCreaturePosition(getCreatureTarget(cid)).z}
    doSendMagicEffect(position1, 5)
    player = Player(cid)
    level = player:getLevel()
    maglevel = player:getMagicLevel()
    hit = math.random(maglevel * 2, level * 2)
    return doCombat(cid, combat, var)
end
 
Use this before to set a new seed.

Code:
math.randomseed(os.time())

same thing

cJHn8eU.png


LUA:
function onCastSpell(cid, var)
    local position1 = {x=getCreaturePosition(getCreatureTarget(cid)).x+2, y=getCreaturePosition(getCreatureTarget(cid)).y, z=getCreaturePosition(getCreatureTarget(cid)).z}
    doSendMagicEffect(position1, 5)
    player = Player(cid)
    level = player:getLevel()
    maglevel = player:getMagicLevel()
    math.randomseed(os.time())
    hit = math.random(maglevel * 2, level * 2)
    return doCombat(cid, combat, var)
end
 
Back
Top