There is no direct way to do what you're trying to do, as the ability blueprints are not meant to be modified mid-game (as that would affect every demigod using that ability regardless of which team they're on, and would not be reflected in the UI).
There are several workarounds you can use, from directly overriding the function that the ability calls in OnStartAbility, or non-destructively by hooking OnStartAbility and passing the original call a copy of the ability blueprint with a modified damage value, e.g.:
Code: c++
- --Non-destructive ability damage hook--Save a copy of the existing OnStartAbility
- local prevOnStartAbility = Ability.HDemonSpineAttack01.OnStartAbility
- Ability.HDemonSpineAttack01.OnStartAbility = function(self, unit, params)
- --Make a copy of the ability blueprint table that's passed to the function when the ability is used
- local bpCopy = table.copy(self)
- --Modify damage amount in this blueprint copy, for example, adding the unit's DamageRating
- bpCopy.DamageAmt = bpCopy.DamageAmt + unit.Sync.DamageRating
- --Call the original OnStartAbility with the copied blueprint instead of the original ability blueprint
- prevOnStartAbility(bpCopy, unit, params)
- end
Note that this will add a tiny bit of overhead due to the table copy operation - this is completely negligible in this case, since this will only happen any time an ability is called (not that often in sim terms), and there are already dozens of table copies happening per tick, but it's worth mentioning that you'd want to use a more efficient method for something other than an ability hook.
This also won't be reflected in the UI, since it does nothing to the original blueprint table (nevermind each player's UI copy, which is separate and untouchable by the sim code). There is a hack that you can use to change the UI display, but you need to make sure whatever value you're adding/multiplying the damage by is available in the unit's Sync on the sim side:
Code: c++
- --Modify the GetDamage function on the UI side to snag updated damage info from Synclocal Spine01DamageAdd = 0
- Ability.HDemonSpineAttack01.GetDamage = function(self)
- --Try to fetch damage bonus from sync
- local focusHero, syncData = import('/lua/ui/game/ingameui.lua').GetFocusArmyHero()
- if focusHero and not focusHero:IsDead() then
- syncData = import('/lua/common/commonutils.lua').GetSyncData(focusHero)
- end
- --Add the value from the sync (or a cached value, if the demigod is currently dead)
- if syncData and syncData.DamageRating then
- Spine01DamageAdd = syncData.DamageRating
- end
- return math.floor(self.DamageAmt + Spine01DamageAdd)
- end
This creates a cached upvalue (Spine01DamageAdd) that the UI can add to the original ability damage even if the sync data is unavailable (e.g. currently dead).
If it isn't clear, you'd need to do both of these things for every single ability you want to affect - there is no catch-all method for applying something like this to every ability, although if you'd like I can show you how to use a loop to quickly apply it to a series of abilities (e.g. spine attack I through IV).
Also, for the record, I would highly question the balance impact of adding DamageRating to ability damage, and would suggest you find a better way to increase damage (making sure you set that amount as a Sync value on the unit, so both UI and sim can access it).
If you want to use these code snippets, make sure you quote the post and copy the contents of the [ code ][ /code ] tags, otherwise you'll get a bunch of extra junk in it and it won't work (this forum's code tags are terrible).