The Forums Are Now Closed!

The content will remain as a historical reference, thank you.

Help: Changing ability on 1 item when equipping a different item

By on July 24, 2010 12:21:50 AM from Demigod Forums Demigod Forums

LORD-ORION

Join Date 04/2009
+51

I've been trying to adjust the WeaponProcChanceRanged abilities of some items when equipping a new item.

Specifically, if someone equips goggles, I want to set the WeaponProcChanceRanged to be the same amount as the
WeaponProcChance when the ranged value is lower. 

The task list for items that require changes.

Gauntlets of Despair
WeaponProcChance = 15,
WeaponProcChanceRanged = 10,

Wyrmskin handguards
WeaponProcChance = 15,
WeaponProcChanceRanged = 8,

Doomsprite
GripsWeaponProcChance = 25,
WeaponProcChanceRanged = 16,

Gloves of Fell-Darkur
WeaponProcChance = 20,
WeaponProcChanceRanged = 13,

Nature's Reckoning
WeaponProcChance = 15,
WeaponProcChanceRanged = 10,

Unmaker
WeaponProcChance = 20,
WeaponProcChanceRanged = 13,

What I tried

I tried the approach of adding to the original effect when equipping the other item, but that doesn't seem to work. So I am thinking I am doing it wrong or you can only add values to buffs, not abilities.

eg: In the goggle abilities (add to nature's rec when it is equipped)
AbilityBlueprint {
Name = 'Item_Ring_030_WeaponProc',
AbilityType = 'WeaponProc',
Icon = 'NewIcons/Ring/Ring2',
FromItem = 'Item_Ring_030' ,
WeaponProcChanceRanged = {add = 5}, 

What I learned

-Crits have the same chance on ranged as melee... it is certain proc effects that are lower (see above list)
-If WeaponProcChanceRanged is ommitted, then WeaponProcChance is used for ranged attacks. (as seen on Stormbringer, Theurgist's Cap, and Forest Band). Yet Girdle of Giants has set both values to 100.

Any ideas or help would be appreciated.

Locked Post 11 Replies +1
Search this post
Subscription Options


Reason for Karma (Optional)
Successfully updated karma reason!
July 24, 2010 12:54:10 AM from Demigod Forums Demigod Forums

Can't really help you, orion - but I'm pleased that you are checking into this.  Happy to test with you once you have the finished product (I'm sure I'll assist on other items though).  +1 for you

Reason for Karma (Optional)
Successfully updated karma reason!
July 24, 2010 1:04:22 AM from Demigod Forums Demigod Forums

You are going to have to add checks in the items to check for wearing the goggles. You are also going to have to do the same in the goggles. Fortunately because the goggles are favor items you don't have to worry about removing the buff when you remove the items. I think the Poisoned Blood Potion code in the Uberfix has the basics of what you are looking for (combine with COmposts effect on Mulch).

Reason for Karma (Optional)
Successfully updated karma reason!
July 24, 2010 3:34:21 AM from Demigod Forums Demigod Forums

Ability tables are sim global, which means you cannot directly change WeaponProcChanceRanged for any one player, as that would also change it for all other players.

 

There's actually a super-easy way to accomplish what you're trying to do:

1) Add an OnAbilityAdded function to the goggles that sets unit.HasGoggles to true.  No need to do an OnRemoveAbility, as it's a favor item.  This can be done non-destructively with one line of code:

Code: c++
  1. Ability.AchievementVision.OnAbilityAdded = function(self, unit) unit.HasGoggles = true end

2) Override the WeaponProc function in lua/sim/Ability.lua (line 446), and add a third condition to the WeaponProcChanceRanged/IsMelee check (line 459) that also looks for unit.HasGoggles.  e.g.:

Code: c++
  1. if not def.WeaponProcChanceRanged or unit.IsMelee then

becomes

Code: c++
  1. if not def.WeaponProcChanceRanged or unit.IsMelee or unit.HasGoggles then

I don't see a way to hook this non-destructively and still use the same random chance.  All you need in your hook of this file is this one overridden function - just copy-paste it and add the extra condition to that if statement.

 

Now any unit with the goggles will use the melee proc chance instead of the ranged proc chance.

 

 

Edit: I did a full search of the 1.3 lua, and IsMelee is only used for crits and procs.  I think it's safe to have the goggles set IsMelee = true, and then you can skip the Ability.lua override.  Typically I wouldn't recommend something like this as it could have unintended consequences, but I really don't see anywhere else this flag is used.  Other mods could be using it, I suppose.

Reason for Karma (Optional)
Successfully updated karma reason!
July 24, 2010 9:51:31 AM from Demigod Forums Demigod Forums

No luck with the ability.lua... all the favors are broken at the selection screen. (I used the full files with the small changes to make sure I didn't make any simple mistakes)

http://www.box.net/shared/pp98hmp3bx

Reason for Karma (Optional)
Successfully updated karma reason!
July 24, 2010 12:10:20 PM from Demigod Forums Demigod Forums

downloaded - I'll check this out later today. 

Reason for Karma (Optional)
Successfully updated karma reason!
July 24, 2010 4:41:27 PM from Demigod Forums Demigod Forums

I haven't looked at it, but if the favor items are all greyed out, that means there is a syntax error in the code you added.

Reason for Karma (Optional)
Successfully updated karma reason!
July 24, 2010 8:27:23 PM from Demigod Forums Demigod Forums

IsMelee = true

I didn't try this one yet, can anyone give me a line of code I put in goggles to make this?

Reason for Karma (Optional)
Successfully updated karma reason!
July 25, 2010 1:18:40 AM from Demigod Forums Demigod Forums
Code: c++
  1. Ability.AchievementVision.OnAbilityAdded = function(self, unit) unit.IsMelee = true end

in an empty AchievementItems.lua.

Could you really not have figured that out from the HasGoggles hook I gave you above?  Oh well.  And yeah, there's obv. a parse error somewhere in one of those files, which is why you should have a logging shortcut if you're going to try to mod anything, no matter how simple it may seem.

 

Edit: I just looked at your Achievement_Items.lua, where you copy-pasted the entire file and shoehorned that line into the ability table, when all you needed is that one line in an empty file.  You can't stick a table-indexing line inside a table, that's just all kinds of wrong.  You guys need to get out of the habit of copy-pasting everything, it's the absolute worst way to mod / fix anything, and the best way to guarantee that nobody who uses any other mods that change the same files can or will use yours.

Reason for Karma (Optional)
Successfully updated karma reason!
July 25, 2010 2:23:24 AM from Demigod Forums Demigod Forums

I went ahead and spent the 15 minutes or so needed to get this working according to your description, and non-destructively.

http://code.google.com/p/nubletsupreme/downloads/detail?name=Goggles.zip&can=2&q=

 

Everything is added procedurally and fully hooked, including the crit ability, the two new description entries, and even the OnAbilityAdded function, which I tested as working and fully compatible with my own mod that also does an OnAbilityAdded on the same item.

Reason for Karma (Optional)
Successfully updated karma reason!
July 25, 2010 9:32:34 AM from Demigod Forums Demigod Forums

Awesome and thanks for doing that...

Now...

You also remind my off my boss when he's dealing with the tech support people. He's a software architect with 30 years of experience. They're new guys fresh out of college with limited knowledge of C# and Visual Studio.

There is a large jump from what you said and showed as example code, to what needed to be done if someone has no clue of how LUA works and is using some crappy LUA IDE (if you can call it that).

You're better off pointing to full working code and then saying, figure out how to adapt that to your needs. Like what Ptarth did.

I'm not trying to be belligerent, but that is honest good advice when teaching anyone anything. Thinking back to my boss, I can't understand why he insists on doing the same thing. The support guys don't learn anything, and piss off our paying customers in the process. (which is fortunately not the case here. )

Cheers...

Reason for Karma (Optional)
Successfully updated karma reason!
July 26, 2010 3:13:58 PM from Demigod Forums Demigod Forums

Honestly, there is no working code in the game that's even remotely similar to the 'correct' way to modify already existing item, ability, and buff blueprints.  None in mods either, other than the in-progress Uberfix 1.03.  I should probably make a standalone how-to thread for modding these things, because unless you know everything about how the game stores its blueprints, modding them non-destructively is completely unintuitive.  I did make a post detailing most of this in one of the existing mod-help threads, but I guess that's not exactly high-profile.

That's part of the reason I did this particular mod top-to-bottom and commented everything.  It's a pretty thorough item mod tutorial on its own, including 'advanced' stuff like hooking add/remove event callbacks non-destructively, adding an ability without overwriting another, and appending/prepending description text.

 

The other reason is that I had made my own little mod that added a +2 weapon range increase to the goggles that only affected ranged characters, and I was using IsMelee to determine whether or not the character was ranged, which this method would appear to conflict with at first glance.  So I wanted to see if I could make them work together-- which they do, as long as this mod executes the existing OnAddAbility before its own.

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: