• 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!

Creaturescript and spell. Help needed.

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
932
Solutions
10
Reaction score
308
Location
Poland
Hello, it's me again. I've got some problem with one-time healing script, it's creaturescript and I'm trying to use globalstorage(dunno if correct) to make it work, but with no success.
Code:
local running = false
function onThink(cid)
local hp = (getCreatureHealth(cid)/getCreatureMaxHealth(cid))*100
    if (hp < 10 and not running) then
    if getGlobalStorageValue(21342) ~= -1 then
    return end
    running = true
    addEvent(removeStorage, 1000, cid)
    end
    end

function removeStorage(cid)
    running = false
    doCreatureAddHealth(cid, 5000)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
      setGlobalStorage(21342, 1)
    return true
end
ERROR
Code:
[04/05/2014 13:33:48] Lua Script Error: [CreatureScript Interface]
[04/05/2014 13:33:48] in a timer event called from:
[04/05/2014 13:33:48] data/creaturescripts/scripts/test heal.lua:onThink
[04/05/2014 13:33:49] data/creaturescripts/scripts/test heal.lua:16: attempt to call global 'setGlobalStorage' (a nil value)
[04/05/2014 13:33:49] stack traceback:
[04/05/2014 13:33:49]    [C]: in function 'setGlobalStorage'
[04/05/2014 13:33:49]    data/creaturescripts/scripts/test heal.lua:16: in function <data/creaturescripts/scripts/test heal.lua:12>
Basically I want monster to heal once when hp drops to 10%(or if possible to 0%, so when it should die - it wont, but heal for 5k hp), if not killed, but healed once for 5k global storage could remove in 30 mins so it can be healed again for 5k when hp drops to 0. Hope you get what I mean. :)
Thanks for any help.

#edit
Is there any way to make spell which grants you/monster permanent invisible unless there's under you/monster a poison field? If yes, could someone make that spell?
Thanks.

#edit2
Code:
function onThink(cid)
   local monster = Monster(cid)
   local hp = (getCreatureHealth(cid)/getCreatureMaxHealth(cid))*100
   if (hp < 99.99) and getCreatureName(cid) == "Zavarash" then
   monster:setHiddenHealth(not monster:isHealthHidden())
   elseif getCreatureCondition(cid, CONDITION_POISON) then
   monster:addCreatureHealth()
   return false
end
end
I've made something like this, but I wonder if there's in theforgottenserver-v0.2.15-win32gui (setHiddenHealth()) available. Ty for help.

or this
Code:
function onThink(cid, param)
    local monster = Monster(cid)
    local isGhost = not monster:isInGhostMode()
    local position = monster:getPosition()
    local hp = (getCreatureHealth(cid)/getCreatureMaxHealth(cid))*100
    if (hp < 99.99) and getCreatureName(cid) == "Zavarash" then
    monster:setGhostMode(isGhost)
    if isGhost then
    position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    elseif getCreatureCondition(cid, CONDITION_POISON) then
end
    return false
end
end
 
Only spell is required. Without anything in creaturescripts, global events and other sh**.
Code:
local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 88888)
setConditionParam(condition, CONDITION_PARAM_TICKS, 30 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_HEALTHGAIN, 0.01)
setConditionParam(condition, CONDITION_PARAM_HEALTHTICKS, 30 * 60 * 1000)

function onCastSpell(cid, var)
    if isCreature(cid) == true then
        if getCreatureHealth(cid) < getCreatureMaxHealth(cid) * 0.1 and getCreatureCondition(cid, CONDITION_REGENERATION, 88888) == false then
            doAddCondition(cid, condition)
            doCreatureAddHealth(cid, 5000)
        else
            return false
        end
    else
        return false
    end
    return true
end

In mosnter's XML file set this spell's execute time to 1 second and with 100% chance.

Simple and easy.
 
Back
Top