whitevo
Feeling good, thats what I do.
This code is default TFS 1.0 mana shield spell in game.cpp
What i want to do with mana shield spell is:
1. All damage taken is reduced by 50% while mana shield active
2. Condition no longer has duration
3. When player looses 100mana while manashield is active, condition will wear off
(i don't mind if doing other spells will also reduce the manashield effect)
(i don't mind if mana shield condition is on, but only would block 10damange and player takes 1000dmg and it halfed by 2)
4. when player takes 210damage total (after the 50% damage reduction) i want it to take mana shield off (100mana) and rest from hp (110hp)
I have slight idea how to change player protection values trough lua script. So only the wear-off should be somehow inserted to source code.
But what would be really the best is: If i could somehow entirely manipulate the mana shield condition inside the .lua code
Attribute1: how much mana can manashield block before condition wears off
Attribute2: how much damage reduction manashield will give
I know this is some next level coding and very hard to do (at least i have no idea where to even start), but perhaps someone has already done something like this and has no problem helping me out with this kind of code.
here is the working script i made with Codinablack and Evan help
barrier.lua
barrier.lua (in spells now)
What i want to do with mana shield spell is:
1. All damage taken is reduced by 50% while mana shield active
2. Condition no longer has duration
3. When player looses 100mana while manashield is active, condition will wear off
(i don't mind if doing other spells will also reduce the manashield effect)
(i don't mind if mana shield condition is on, but only would block 10damange and player takes 1000dmg and it halfed by 2)
4. when player takes 210damage total (after the 50% damage reduction) i want it to take mana shield off (100mana) and rest from hp (110hp)
I have slight idea how to change player protection values trough lua script. So only the wear-off should be somehow inserted to source code.
But what would be really the best is: If i could somehow entirely manipulate the mana shield condition inside the .lua code
Attribute1: how much mana can manashield block before condition wears off
Attribute2: how much damage reduction manashield will give
I know this is some next level coding and very hard to do (at least i have no idea where to even start), but perhaps someone has already done something like this and has no problem helping me out with this kind of code.
here is the working script i made with Codinablack and Evan help
barrier.lua
Code:
local barrierStorage = 10500
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local dam1 = primaryDamage/2
local dam2 = secondaryDamage/2
local manaLoss = math.floor(dam1+dam2)
local barrier = creature:getStorageValue(barrierStorage)
if barrier >= 1 then
if manaLoss <= barrier then
doCreatureSay(creature, manaLoss.. " damage absorbed", TALKTYPE_MONSTER_SAY)
creature:setStorageValue(barrierStorage, barrier-manaLoss)
creature:sendTextMessage(TALKTYPE_MONSTER_SAY, "barrier can absorb "..barrier-manaLoss.." damage more")
return primaryDamage*0, primaryType, secondaryDamage*0, secondaryType
else
if dam1 > barrier then
primaryDamage = primaryDamage - barrier*2
blocked1 = barrier
else
primaryDamage = barrier - dam1
blocked1 = dam1
end
if dam2 > barrier then
secondaryDamage = secondaryDamage - barrier*2
blocked2 = barrier
else
secondaryDamage = barrier - dam2
blocked2 = dam2
end
doCreatureSay(creature, blocked1+blocked2.. " damage absorbed", TALKTYPE_MONSTER_SAY)
creature:setStorageValue(barrierStorage, 0)
creature:sendTextMessage(TALKTYPE_MONSTER_SAY, "BARRIER IS BROKEN")
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Code:
local barrierStorage = 10500
local amount = 110
Combat():setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
function onCastSpell(creature, var)
creature:setStorageValue(barrierStorage, amount)
Combat():execute(creature, var)
creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Mana shield Activated")
creature:sendTextMessage(TALKTYPE_MONSTER_SAY, "barrier can absorb "..amount.." damage")
return true
end
Last edited: