Need help modding DA abilities

By on July 20, 2011 2:42:36 PM from Demigod Forums Demigod Forums

Bryff

Join Date 09/2009
+4

EDIT2-Now I just need to make it less destructive, add more comments if you wish

EDIT-nm, I was just missing two lines that I missed in the other thread I linked, so it should be working now.  Although if I didn't do something right go ahead and post anyway.

I'm trying to mod the abilities for DA, like changing the energy costs and adding buffs, but I couldn't get it to work.  In game the abilites are grayed out in the bottom of the screen, and in the ability assigning tab none of the tooltips for the skills show up when I hover the mouse over them.  Here's what I've got so far

folders

mods>[TheMod]>hook>units>heroes>HDemon

I have a working mod_info in the mod folder, and in the HDemon folder I copied the HDemon_Abilites from dgdata and put it there.

I changed the energy costs, cooldown, and damage for warp strike 1 through 4 and spine attack 1 through 4, and also put in buffs for them.  For the buffs I went here

http://forums.demigodthegame.com/370997

so it looks like this (EDIT2-changed the code to the working version)

Code: c++
  1. #################################################################################################################
  2. # Warp Strike I
  3. #################################################################################################################
  4. AbilityBlueprint {
  5.  Name = 'HDemonWarpStrike01',
  6.  DisplayName = '<LOC ABILITY_DA_0001>Warp Strike I',
  7.  Description = '<LOC ABILITY_DA_0002>Demon Assassin warps to an enemy and instantly strikes, dealing [GetDamage] damage and permanently increasing weapon damage by [GetDamageBonusBuff]%.',
  8.  AbilityType = 'TargetedUnit',
  9.  TargetAlliance = 'Enemy',
  10.  TargetCategory = 'ALLUNITS - UNTARGETABLE',
  11.  TargetingMethod = 'HOSTILETARGETED',
  12.  EnergyCost = 150,
  13.  RangeMax = 10,
  14.  Cooldown = 6,
  15.  DamageAmt = 50,
  16.  DamageType = 'Spell',
  17.  UISlot = 1,
  18.  HotKey = '1',
  19.  CastAction = 'WarpStrike',
  20.  FollowThroughTime = 0.3,
  21.  GetDamage = function(self) return math.floor( self.DamageAmt ) end,
  22.  GetDamageBonusBuff = function(self) return math.floor( Buffs['HDemonWarpStrikeBuff011'].Affects.DamageBonus.Mult * 100 ) end,
  23.  OnStartAbility = function(self, unit, params)
  24.   -- Set the old target so we attack the target of Warp Strike after warping and continue attacking them if
  25.   -- we decide to use another ability after warping or if they run away.
  26.   local tac = unit:GetAttacker()
  27.   tac:SetOldTarget(params.Targets[1])
  28.   
  29.   ForkThread(WarpStrike, self, unit, params)
  30.   Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff011', unit)
  31.  end,
  32.  Icon = '/DGDemonAssassin/DA_WarpStrike',
  33. }
  34. BuffBlueprint {
  35.  Name = 'HDemonWarpStrikeBuff011',
  36.  Debuff = false,
  37.  DisplayName = 'Warp Strike Weapon Damage Buff',
  38.  Description = '+10% Weapon Damage',
  39.  BuffType = 'HDEMONWARPSTRIKEBUFF',
  40.  Stacks = 'REPLACE',
  41.  Duration = -1,
  42.  Affects = {
  43.   DamageBonus = {Mult = 0.10},
  44.  },
  45.  Icon = '/DGDemonAssassin/DA_WarpStrike',
  46. }

and

Code: c++
  1. #################################################################################################################
  2. # Spine Attack I
  3. #################################################################################################################
  4. AbilityBlueprint {
  5.  Name = 'HDemonSpineAttack01',
  6.  DisplayName = '<LOC ABILITY_DA_0008>Spine Attack I',
  7.  Description = '<LOC ABILITY_DA_0009>Demon Assassin throws a deadly barb from his tail, dealing [GetDamage] damage and permanently increasing attack speed by [GetRateOfFireBuff]%.',
  8.  AbilityType = 'TargetedUnit',
  9.  ReengageTargetAfterUse = true,
  10.  TargetAlliance = 'Enemy',
  11.  TargetCategory = 'ALLUNITS - UNTARGETABLE',
  12.  TargetingMethod = 'HOSTILETARGETED',
  13.  EnergyCost = 150,
  14.  RangeMax = 10,
  15.  Cooldown = 3,
  16.  DamageAmt = 125,
  17.  DamageType = 'Spell',
  18.  UISlot = 2,
  19.  HotKey = '2',
  20.  CastingTime = 0.3,
  21.  CastAction = 'SpineAttack',
  22.  FollowThroughTime = 0.1,
  23.  GetDamage = function(self) return math.floor( self.DamageAmt ) end,
  24.  GetRateOfFireBuff = function(self) return math.floor( Buffs['HDemonSpineAttackBuff011'].Affects.RateOfFire.Mult * 100 ) end,
  25.  OnStartAbility = function(self, unit, params)
  26.   ForkThread(SpineAttack, self, unit, params)
  27.   Buff.ApplyBuff(unit, 'HDemonSpineAttackBuff011', unit)
  28.  end,
  29.  Icon = '/DGDemonAssassin/DA_SpineAttack',
  30. }
  31. BuffBlueprint {
  32.  Name = 'HDemonSpineAttackBuff011',
  33.  Debuff = false,
  34.  DisplayName = 'Spine Attack Attack Speed Buff',
  35.  Description = '+10% Attack Speed',
  36.  BuffType = 'HDEMONWARPSTRIKEBUFF',
  37.  Stacks = 'REPLACE',
  38.  Duration = -1,
  39.  Affects = {
  40.   RateOfFire = {Mult = 0.10},
  41.  },
  42.  Icon = '/DGDemonAssassin/DA_SpineAttack',
  43. }

Can someone please explain what I have to do to make the skills work?

Locked Post 6 Replies
Search this post
Subscription Options


Reason for Karma (Optional)
Successfully updated karma reason!
July 21, 2011 3:06:34 PM from Demigod Forums Demigod Forums

If skills are greyed out, it means there's a syntax error in your file somewhere that's preventing the entire ability system from initializing.  First read this post about enabling and using the error log - it's much more (and unnecessarily) difficult to debug a mod without it: http://forums.demigodthegame.com/399524/page/1/#2812350

Then make sure you're familiar with Lua syntax and are using an editor (like Notepad++) that has syntax highlighting, so you can more easily find errors, and use a non-destructive approach to changing ability parameters when possible, to keep the possible errors to a minimum.

For example, to change the energy cost of Spine Attack I, you only need to reference that one variable within its ability blueprint table, within the global Ability table.  So start with a blank HDemon_Abilities.lua file in your hook path, and add a single line like this:

Code: c++
  1. Ability.HDemonSpineAttack01.EnergyCost = 150
Use one line like that for each ability blueprint to change their energy costs, making sure to change the name of each ability blueprint (HDemonSpineAttack01 in this case) referenced so the correct ability is changed.  How/why you do this is described in much greater detail in several posts following this one: http://forums.demigodthegame.com/376116/page/1/#2635933

 

As for adding buffs, I'm not entirely sure what you're trying to accomplish there?  First of all, that buff isn't being added to the ability in any way.  There are two ways to do that, one 'automatic' and one manual, and usually the manual way (via actual ability function code) is the only way that really works for most abilities.

What do you want the buffs to be applied to?  When do you want them to run out?  You're creating infinite-duration buffs that, if added to the ability's Buffs table, would be applied to the TARGET of the ability, PERMANENTLY.  I'm guessing you don't want either of those things, so you might want to do a bit more research on buff creation and usage by looking at some other abilities.

 

And remember to always start with one change at a time.  Do simple things first, get those working in-game, and then add each further change one at a time (in chunks that seem reasonable to debug should an error pop up), so you know exactly where the problem is whenever you run into an error.

Reason for Karma (Optional)
Successfully updated karma reason!
July 21, 2011 8:34:50 PM from Demigod Forums Demigod Forums

Ty for replying.

As for the skills grayed out, I got that fixed.

I'm not too familiar, but I think I can make do for what I'm trying to do for now.

I'll make it less destructive once I get some more time, maybe tomorrow.

The adding buffs part, I was trying to add the buffs to the DA using the ability.  I did test it and get it to work, so that the DA gets the buff (permanently) right after the first use of the skill (uses warp strike and gets the buff applied), but I'm not sure if my target got affected by it, like you said.  I'll update the post with the new code so you can look at it (maybe offer more advice for destructiveness, or I'll look at the link).

It turns out I was missing some lines

Code: c++
  1.  GetDamageBonusBuff = function(self) return math.floor( Buffs['HDemonWarpStrikeBuff011'].Affects.DamageBonus.Mult * 100 ) end,
Code: c++
  1.   Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff011', unit)

Thanks for the advice!

Reason for Karma (Optional)
Successfully updated karma reason!
July 22, 2011 9:01:04 AM from Demigod Forums Demigod Forums

If you're manually adding the buff using ApplyBuff, then it will only affect the unit you're passing to the ApplyBuff call (in this case, 'unit' represents the casting unit).

If you added the buff blueprint or buff name to a Buffs table in the ability blueprint, then it would applied automatically to only the target because it's a targeted ability.  If it were an instant-cast ability, like Warp Area, any buffs in the ability's Buffs table would be applied to the casting unit.  Buffs on a 'Quiet' type ability (e.g. Forceful Blows) get added to the unit immediately upon receiving the ability.
This is why it's usually preferable to add it via an ApplyBuff call in the ability function, so you can control when and to what it's applied.

 

I'm not quite sure why you'd want a permanent buff to be applied on ability use, though - why not just have the buff apply when DA receives the ability?  Add an OnAbilityAdded function within the ability blueprint that applies it:

Code: c++
  1.     OnAbilityAdded = function(self, unit)
  2.         Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff011', unit)
  3.     end,
or, non-destructively, outside any blueprints or tables:
Code: c++
  1. local WS1OAA = Ability.HDemonWarpStrike01.OnAbilityAdded
  2. Ability.HDemonWarpStrike01.OnAbilityAdded = function(self, unit)
  3.     if WS1OAA then
  4.         WS1OAA(self, unit)
  5.     end
  6.     Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff011', unit)
  7. end
That additionally saves a copy of the ability's existing OnAbilityAdded function (in case another mod adds one) and runs it if it exists.

If you were adding something like this to an item ability, you'd also need a corresponding OnRemoveAbility function with a RemoveBuff call for when the item is sold or dropped, but character abilities can't be un-chosen, so it's not needed in this case.

Reason for Karma (Optional)
Successfully updated karma reason!
July 22, 2011 3:27:35 PM from Demigod Forums Demigod Forums

Ok, so I've made the code like you said in your first post (Wall of text)

Code: c++
  1. Ability.HDemonWarpStrike01.EnergyCost = 150
  2. Ability.HDemonWarpStrike01.RangeMax = 10
  3. Ability.HDemonWarpStrike01.Cooldown = 6
  4. Ability.HDemonWarpStrike01.DamageAmt = 50
  5. local WS1OAA = Ability.HDemonWarpStrike01.OnAbilityAdded
  6. Ability.HDemonWarpStrike01.OnAbilityAdded = function(self, unit)
  7.     if WS1OAA then
  8.         WS1OAA(self, unit)
  9.     end
  10.     Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff011', unit)
  11. end
  12. BuffBlueprint {
  13.  Name = 'HDemonWarpStrikeBuff011',
  14.  Debuff = false,
  15.  DisplayName = 'Warp Strike Weapon Damage Buff',
  16.  Description = '+10% Weapon Damage',
  17.  BuffType = 'HDEMONWARPSTRIKEBUFF',
  18.  Stacks = 'REPLACE',
  19.  Duration = -1,
  20.  Affects = {
  21.   DamageBonus = {Mult = 0.10},
  22.  },
  23.  Icon = '/DGDemonAssassin/DA_WarpStrike',
  24. }
  25. Ability.HDemonWarpStrike02.EnergyCost = 250
  26. Ability.HDemonWarpStrike02.RangeMax = 16
  27. Ability.HDemonWarpStrike02.Cooldown = 5
  28. Ability.HDemonWarpStrike02.DamageAmt = 100
  29. local WS1OAA = Ability.HDemonWarpStrike02.OnAbilityAdded
  30. Ability.HDemonWarpStrike02.OnAbilityAdded = function(self, unit)
  31.     if WS1OAA then
  32.         WS1OAA(self, unit)
  33.     end
  34.     Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff012', unit)
  35. end
  36. BuffBlueprint {
  37.  Name = 'HDemonWarpStrikeBuff012',
  38.  Debuff = false,
  39.  DisplayName = 'Warp Strike Weapon Damage Buff',
  40.  Description = '+20% Weapon Damage',
  41.  BuffType = 'HDEMONWARPSTRIKEBUFF',
  42.  Stacks = 'REPLACE',
  43.  Duration = -1,
  44.  Affects = {
  45.   DamageBonus = {Mult = 0.20},
  46.  },
  47.  Icon = '/DGDemonAssassin/DA_WarpStrike',
  48. }
  49. Ability.HDemonWarpStrike03.EnergyCost = 350
  50. Ability.HDemonWarpStrike03.RangeMax = 23
  51. Ability.HDemonWarpStrike03.Cooldown = 4
  52. Ability.HDemonWarpStrike03.DamageAmt = 150
  53. local WS1OAA = Ability.HDemonWarpStrike03.OnAbilityAdded
  54. Ability.HDemonWarpStrike03.OnAbilityAdded = function(self, unit)
  55.     if WS1OAA then
  56.         WS1OAA(self, unit)
  57.     end
  58.     Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff013', unit)
  59. end
  60. BuffBlueprint {
  61.  Name = 'HDemonWarpStrikeBuff013',
  62.  Debuff = false,
  63.  DisplayName = 'Warp Strike Weapon Damage Buff',
  64.  Description = '+30% Weapon Damage',
  65.  BuffType = 'HDEMONWARPSTRIKEBUFF',
  66.  Stacks = 'REPLACE',
  67.  Duration = -1,
  68.  Affects = {
  69.   DamageBonus = {Mult = 0.30},
  70.  },
  71.  Icon = '/DGDemonAssassin/DA_WarpStrike',
  72. }
  73. Ability.HDemonWarpStrike04.EnergyCost = 450
  74. Ability.HDemonWarpStrike04.RangeMax = 30
  75. Ability.HDemonWarpStrike04.Cooldown = 3
  76. Ability.HDemonWarpStrike04.DamageAmt = 200
  77. local WS1OAA = Ability.HDemonWarpStrike04.OnAbilityAdded
  78. Ability.HDemonWarpStrike04.OnAbilityAdded = function(self, unit)
  79.     if WS1OAA then
  80.         WS1OAA(self, unit)
  81.     end
  82.     Buff.ApplyBuff(unit, 'HDemonWarpStrikeBuff014', unit)
  83. end
  84. BuffBlueprint {
  85.  Name = 'HDemonWarpStrikeBuff014',
  86.  Debuff = false,
  87.  DisplayName = 'Warp Strike Weapon Damage Buff',
  88.  Description = '+40% Weapon Damage',
  89.  BuffType = 'HDEMONWARPSTRIKEBUFF',
  90.  Stacks = 'REPLACE',
  91.  Duration = -1,
  92.  Affects = {
  93.   DamageBonus = {Mult = 0.40},
  94.  },
  95.  Icon = '/DGDemonAssassin/DA_WarpStrike',
  96. }
  97. Ability.HDemonSpineAttack01.EnergyCost = 150
  98. Ability.HDemonSpineAttack01.RangeMax = 10
  99. Ability.HDemonSpineAttack01.Cooldown = 3
  100. Ability.HDemonSpineAttack01.DamageAmt = 125
  101. local WS1OAA = Ability.HDemonSpineAttack01.OnAbilityAdded
  102. Ability.HDemonSpineAttack01.OnAbilityAdded = function(self, unit)
  103.     if WS1OAA then
  104.         WS1OAA(self, unit)
  105.     end
  106.     Buff.ApplyBuff(unit, 'HDemonSpineAttackBuff011', unit)
  107. end
  108. BuffBlueprint {
  109.  Name = 'HDemonSpineAttackBuff011',
  110.  Debuff = false,
  111.  DisplayName = 'Spine Attack Attack Speed Buff',
  112.  Description = '+10% Attack Speed',
  113.  BuffType = 'HDEMONSPINEATTACKBUFF',
  114.  Stacks = 'REPLACE',
  115.  Duration = -1,
  116.  Affects = {
  117.   RateOfFire = {Mult = 0.10},
  118.  },
  119.  Icon = '/DGDemonAssassin/DA_SpineAttack',
  120. }
  121. Ability.HDemonSpineAttack02.EnergyCost = 150
  122. Ability.HDemonSpineAttack02.RangeMax = 21
  123. Ability.HDemonSpineAttack02.Cooldown = 2.67
  124. Ability.HDemonSpineAttack02.DamageAmt = 180
  125. local WS1OAA = Ability.HDemonSpineAttack02.OnAbilityAdded
  126. Ability.HDemonSpineAttack02.OnAbilityAdded = function(self, unit)
  127.     if WS1OAA then
  128.         WS1OAA(self, unit)
  129.     end
  130.     Buff.ApplyBuff(unit, 'HDemonSpineAttackBuff012', unit)
  131. end
  132. BuffBlueprint {
  133.  Name = 'HDemonSpineAttackBuff012',
  134.  Debuff = false,
  135.  DisplayName = 'Spine Attack Attack Speed Buff',
  136.  Description = '+20% Attack Speed',
  137.  BuffType = 'HDEMONSPINEATTACKBUFF',
  138.  Stacks = 'REPLACE',
  139.  Duration = -1,
  140.  Affects = {
  141.   RateOfFire = {Mult = 0.20},
  142.  },
  143.  Icon = '/DGDemonAssassin/DA_SpineAttack',
  144. }
  145. Ability.HDemonSpineAttack03.EnergyCost = 150
  146. Ability.HDemonSpineAttack03.RangeMax = 33
  147. Ability.HDemonSpineAttack03.Cooldown = 2.33
  148. Ability.HDemonSpineAttack03.DamageAmt = 240
  149. local WS1OAA = Ability.HDemonSpineAttack03.OnAbilityAdded
  150. Ability.HDemonSpineAttack03.OnAbilityAdded = function(self, unit)
  151.     if WS1OAA then
  152.         WS1OAA(self, unit)
  153.     end
  154.     Buff.ApplyBuff(unit, 'HDemonSpineAttackBuff013', unit)
  155. end
  156. BuffBlueprint {
  157.  Name = 'HDemonSpineAttackBuff013',
  158.  Debuff = false,
  159.  DisplayName = 'Spine Attack Attack Speed Buff',
  160.  Description = '+30% Attack Speed',
  161.  BuffType = 'HDEMONSPINEATTACKBUFF',
  162.  Stacks = 'REPLACE',
  163.  Duration = -1,
  164.  Affects = {
  165.   RateOfFire = {Mult = 0.30},
  166.  },
  167.  Icon = '/DGDemonAssassin/DA_SpineAttack',
  168. }
  169. Ability.HDemonSpineAttack04.EnergyCost = 150
  170. Ability.HDemonSpineAttack04.RangeMax = 45
  171. Ability.HDemonSpineAttack04.Cooldown = 2
  172. Ability.HDemonSpineAttack04.DamageAmt = 300
  173. local WS1OAA = Ability.HDemonSpineAttack04.OnAbilityAdded
  174. Ability.HDemonSpineAttack04.OnAbilityAdded = function(self, unit)
  175.     if WS1OAA then
  176.         WS1OAA(self, unit)
  177.     end
  178.     Buff.ApplyBuff(unit, 'HDemonSpineAttackBuff014', unit)
  179. end
  180. BuffBlueprint {
  181.  Name = 'HDemonSpineAttackBuff014',
  182.  Debuff = false,
  183.  DisplayName = 'Spine Attack Attack Speed Buff',
  184.  Description = '+40% Attack Speed',
  185.  BuffType = 'HDEMONSPINEATTACKBUFF',
  186.  Stacks = 'REPLACE',
  187.  Duration = -1,
  188.  Affects = {
  189.   RateOfFire = {Mult = 0.40},
  190.  },
  191.  Icon = '/DGDemonAssassin/DA_SpineAttack',
  192. }

So for the buff, yes I wanted it to apply the buff when you chose the ability but I didn't know how. 

Now, I've tested this code in game.  The abilities work themselves (EnergyCost, etc.) but the buffs for WarpStrike and Spine Attack replace each other on gaining the skill.  So if I get Warp Strike 1, I get the +10% weapon damage, but when I get Spine Attack 1, the new buff replaces the Warp Strike buff, so I now have +10% attack speed.  What do I do to fix this?

EDIT-I corrected the code in this reply.

Reason for Karma (Optional)
Successfully updated karma reason!
July 22, 2011 5:21:46 PM from Demigod Forums Demigod Forums

That's determined by two elements of the BuffBlueprints themselves - Stacks and BuffType.  If Stacks is set to 'REPLACE', which you normally want for a permanent buff that increases in power with level (so the newer versions replace the older ones automatically), any existing buffs with the same BuffType will be replaced by the incoming buff.  So, your Spine Attack buffs need their own BuffType.

Reason for Karma (Optional)
Successfully updated karma reason!
July 22, 2011 6:00:24 PM from Demigod Forums Demigod Forums

Oops, now I realize that the Spine Attack buffs have " 'HDEMONWARPSTRIKEBUFF' " on them, once I fix that I think it'll work.

EDIT-yes it works, if there's anything else I should do I'll do it, otherwise I don't have anymore questions for now.

Reason for Karma (Optional)
Successfully updated karma reason!
Stardock Forums v1.0.0.0    #108432  walnut2   Server Load Time: 00:00:00.0000218   Page Render Time:

Stardock Magazine | Register | Online Privacy Policy | Terms of Use

Copyright © 2016 Stardock Entertainment and Gas Powered Games. Demigod is a trademark of Gas Powered Games. All rights reserved. All other trademarks and copyrights are the properties of their respective owners. Windows, the Windows Vista Start button and Xbox 360 are trademarks of the Microsoft group of companies, and 'Games for Windows' and the Windows Vista Start button logo are used under license from Microsoft. © 2012 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo and combinations thereof are trademarks of Advanced Micro Devices, Inc.