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

CreatureEvent Auto Health Mana Regeneration

Jeffro

Alpha
Joined
Jan 17, 2015
Messages
235
Reaction score
262
Location
New York
[EDIT] Oops I forgot to add, this is TFS 1.2. If someone could edit the topic title.

This was requested in the support section. It could definitely be approved upon, but I'd like to release just for archive reasons.

Here is a simple auto regeneration code. I quickly made it tonight, not sure if it works. I used the food script as reference.

creaturtescripts/login.lua
Code:
--auto health mana regeneration
   local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
   if condition == nil then
     player:constregen()
   end

lib/core/player.lua
Code:
local pahealCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

function Player.constregen(self)
   local condition = self:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
   local vocation = self:getVocation()

   pahealCondition:setTicks(-1)
   pahealCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, vocation:getHealthGainAmount())
   pahealCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, vocation:getHealthGainTicks() * 1000)
   pahealCondition:setParameter(CONDITION_PARAM_MANAGAIN, vocation:getManaGainAmount())
   pahealCondition:setParameter(CONDITION_PARAM_MANATICKS, vocation:getManaGainTicks() * 1000)

   self:addCondition(pahealCondition)
end
 
Back
Top