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

[TFS 1.4] Add conditions while on a "training" tile

Goo Goo

Member
Joined
Apr 20, 2010
Messages
42
Reaction score
10
Whilst trying to figure out the RevScripts I did a thing, useless but a thing. :D
Adds conditions onStepIn and remove conditions onStepOut. using aid or item id if prefer, I left the code in for it.
data/scripts/movements
Lua:
local critHitConfig = {
  CRIT_HIT_CHANCE = 50,
  CRIT_HIT_AMOUNT = 500
  }
local lifeLeechConfig = {
  LIFE_LEECH_CHANCE = 50,
  LIFE_LEECH_AMOUNT = 100
}
local manaLeechConfig = {
  MANA_LEECH_CHANCE = 50,
  MANA_LEECH_AMOUNT = 100
}
local condition = Condition(CONDITION_ATTRIBUTES)
  condition:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE, critHitConfig.CRIT_HIT_CHANCE)
  condition:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT, critHitConfig.CRIT_HIT_AMOUNT)
  condition:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE, lifeLeechConfig.LIFE_LEECH_CHANCE)
  condition:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT, lifeLeechConfig.LIFE_LEECH_AMOUNT)
  condition:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE, manaLeechConfig.MANA_LEECH_CHANCE)
  condition:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT, manaLeechConfig.MANA_LEECH_AMOUNT)

local trainingTileIn = MoveEvent()
trainingTileIn:type("stepin")
trainingTileIn:aid(11003)
--NOTE:trainingTileIn:id(7351) --if you want to use an item id instead
function trainingTileIn.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    condition:setTicks(-1)
    player:addCondition(condition)
    return true
end

local trainingTileOut = MoveEvent()
trainingTileOut:type("stepout")
trainingTileOut:aid(11003)
--NOTE:trainingTileOut:id(7351) --if you want to use an item id instead
function trainingTileOut.onStepOut(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    player:removeCondition(CONDITION_ATTRIBUTES, condition)
    --NOTE:even though addCondition(condition) will add CONDITION_ATTRIBUTES
    --NOTE:removeCondition(condition) doesn't remove them, why?
    return true
end

trainingTileIn:register()
trainingTileOut:register()

P.S. removeCondition almost broke my will to live.
 
It doesnt work?
The script works. I was just making a note to myself that removeCondition(condition) will not remove a condition.
removeCondition(CONDITION_ATTRIBUTES, condition) was the only way I could remove the conditions.
 
Back
Top