Hi Mithy
I have a conflict with the latest version of uberfix.
I know that you have updated the buffAffect.lua file in uberfix to provide more options to sync with the ui, however, due to constraints of my mod i have had to alter this file as well
.
Anyway here is the code i am using: (buffAffects.lua)
[code]
local Buff = import('/lua/sim/buff.lua')
######## BEGIN BUFF TYPE FUNCTION DEFINITIONS ############
function Health( unit, buffName, buffDef, buffAffects, instigator, instigatorArmy, bAfterRemove )
#Note: With health we don't actually look at the unit's table because it's an instant happening. We don't want to overcalculate something as pliable as health.
if bAfterRemove then return end
local health = unit:GetHealth()
local val = ((buffAffects.Health.Add or 0) + health) * (buffAffects.Health.Mult or 1) if instigator and not instigator:IsDead() and buffAffects.Health.DamageRatingMult then
val = val + buffAffects.Health.DamageRatingMult * CalculateDamageFromRating(instigator.Sync.DamageRating)
end
if buffAffects.Health.MaxHealthPercent then
val = val + unit:GetMaxHealth() * buffAffects.Health.MaxHealthPercent
end
#######################CHANGE BY EXXCENTRIC FOR FAVORMOD
if buffAffects.Health.MaxHealthPercentlvl then
local playerlevel = unit:GetLevel()
val = val - 100 - 19*playerlevel * buffAffects.Health.MaxHealthPercentlvl # Code For Priest Change
end
#######################END CHANGE BY EXXCENTRIC FOR FAVORMOD
local healthadj = val - health
local data = {
Instigator = instigator,
InstigatorBp = false,
InstigatorArmy = instigatorArmy,
Amount = -healthadj,
Type = buffDef.Type or 'Spell',
DamageAction = buffName or 'Unknown',
Radius = buffDef.DamageRadius or 0,
DamageSelf = buffDef.DamageSelf or false,
DamageFriendly = true,
ArmorImmune = true,
CanBackfire = true,
CanCrit = true,
CanDamageReturn = false,
CanBeEvaded = true,
CanOverKill = true,
Vector = VDiff(instigator:GetPosition(), unit:GetPosition()),
Group = "UNITS", }
if instigator and not instigator:IsDead() then
data.InstigatorBp = instigator:GetBlueprint()
end
data.CanMagicResist = buffDef.CanMagicResist
if buffDef.CanMagicResist == nil and data.Amount < 0 then
data.CanMagicResist = false
elseif buffDef.CanMagicResist == nil and data.Amount > 0 then
data.CanMagicResist = true end
if buffDef.DamageFriendly == false then
data.DamageFriendly = false
end
if buffDef.ArmorImmune == false then
data.ArmorImmune = false
end
if buffDef.CanCrit == false then
data.CanCrit = false
end
if buffDef.CanDamageReturn then
data.CanDamageReturn = buffDef.CanDamageReturn
end if buffDef.CanBackfire == false then
data.CanBackfire = false
end
if buffDef.CanBeEvaded == false then
data.CanBeEvaded = false
end
if buffDef.CanOverKill == false then
data.CanOverKill = false
end
if buffDef.IgnoreDamageRangePercent then
data.IgnoreDamageRangePercent = buffDef.IgnoreDamageRangePercent
end
data.NoFloatText = buffDef.NoFloatText
DealDamage(data,unit) #LOG('*BUFF: Unit ', repr(unit:GetEntityId()), ' Health adjusted to ', repr(val))
end
function MaxHealth( unit, buffName )
local oldMaxHealth = unit:GetMaxHealth()
local unitbphealth = unit:GetBlueprint().Defense.MaxHealth or 1
local newMaxHealth = BuffCalculate(unit, buffName, 'MaxHealth', unitbphealth)
###############################EXXCENTRIC - ADDED TO RESYNC MINION HEALTH AFTER BUYING AN UPGRADE#############
if Buff.HasBuff(unit, 'MinionHealthandDamageBOOSTA') then
local aiBrain = unit:GetAIBrain() local hero = aiBrain:GetHero()
local herolvl = hero:GetLevel() newMaxHealth = newMaxHealth + 50 * herolvl
end
if Buff.HasBuff(unit, 'MinionHealthandDamageBOOSTB') then
local aiBrain = unit:GetAIBrain()
local hero = aiBrain:GetHero()
local herolvl = hero:GetLevel()
newMaxHealth = newMaxHealth + 95 * herolvl
end
#################################################
unit:SetMaxHealth(newMaxHealth)
unit.Sync.MaxHealth = newMaxHealth
# Adjusts current health by the amount of the MaxHealth buff
local maxHealthAdjustment = newMaxHealth - oldMaxHealth
local currentHealth = unit:GetHealth()
# If we are decreasing max health, then apply the descrease
if maxHealthAdjustment < 0 then
if(currentHealth + maxHealthAdjustment <= 0) then
unit:AdjustHealth(-currentHealth + 1)
else
unit:AdjustHealth(maxHealthAdjustment)
end
# Otherwise we are increasing max health. The bp tells us whether or not to adjust the current health
else
if(Buffs[buffName].Affects.MaxHealth.AdjustHealth == true) then
if(currentHealth + maxHealthAdjustment <= 0) then
unit:AdjustHealth(-currentHealth + 1)
else
unit:AdjustHealth(maxHealthAdjustment)
end
end
end
#LOG('*BUFF: Unit ', repr(unit:GetEntityId()), ' buffed max health to ', repr(val))
end
function DamageRating( unit, buffName )
local val = BuffCalculate(unit, buffName, 'DamageRating', 0, 0)
#######################CHANGE BY EXXCENTRIC FOR FAVORMOD - Resync minion damage after buying and upgrade
if Buff.HasBuff(unit, 'MinionHealthandDamageBOOSTA') then
local aiBrain = unit:GetAIBrain() local hero = aiBrain:GetHero()
local herolvl = hero:GetLevel() val = val + 2 * herolvl
end
if Buff.HasBuff(unit, 'MinionHealthandDamageBOOSTB') then
local aiBrain = unit:GetAIBrain()
local hero = aiBrain:GetHero()
local herolvl = hero:GetLevel() val = val + 3 * herolvl
end
#######################END OF CHANGE BY EXXCENTRIC FOR FAVORMOD
unit.Sync.DamageRating = val
local basedamagerating = unit:GetBlueprint().Stats.DamageRating
if unit.Sync.PrimaryWeaponDamage and not unit:IsDead() then
local wep = unit:GetWeapon(1)
if wep then
local damage = wep:GetBaseDamage()
unit.Sync.PrimaryWeaponDamage = damage
unit.Sync.DamageRatingIncrease = damage - basedamagerating
end
end
end
[/code]
Can you suggest a less destructive way that i can import these altered function back into the game?
Any Help would be Appreciated
Exx