ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Mon Feb 24, 2020 8:04 am

All times are UTC




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Dec 16, 2016 4:33 pm 
Offline
Sher'Tul

Joined: Sat May 15, 2010 9:17 pm
Posts: 1481
Pretty straightforward, I want to make a small addon that changes beyond the flesh from using wil/cun regardless to only using them if they're higher than strength/dex,* mostly just to increase its ability to slot into adventurer builds. The problem being I have zero bloody idea how to do it, ahaha!

What I've attempted so far is changing the combat.lua bit that covers the ability from its default to this, which I have no clue if is even remotely appropriate for lua coding:
Code:
function _M:combatAttack(weapon, ammo)
   local stats
   if self:attr("use_psi_combat") and ((self:getCun(100, true)) > (self:getDex(100, true))) then stats = (self:getCun(100, true) - 10) * (0.6 + self:callTalent(self.T_RESONANT_FOCUS, "bonus")/100)
   elseif weapon and weapon.wil_attack and ((self:getWil(100, true)) > (self:getStr(100, true))) then stats = self:getWil(100, true) - 10
   else stats = self:getDex(100, true) - 10
   end
   local d = self:combatAttackBase(weapon, ammo) + stats
   if self:attr("dazed") then d = d / 2 end
   if self:attr("scoured") then d = d / 1.2 end
   return self:rescaleCombatStats(d)
end

function _M:combatAttackRanged(weapon, ammo)
   local stats
   if self:attr("use_psi_combat") and ((self:getCun(100, true)) > (self:getDex(100, true))) then stats = (self:getCun(100, true) - 10) * (0.6 + self:callTalent(self.T_RESONANT_FOCUS, "bonus")/100)
   elseif weapon and weapon.wil_attack ((self:getWil(100, true)) > (self:getStr(100, true))) then stats = self:getWil(100, true) - 10
   else stats = self:getDex(100, true) - 10
   end
   local d = self:combatAttackBase(weapon, ammo) + stats + (self.combat_atk_ranged or 0)
   if self:attr("dazed") then d = d / 2 end
   if self:attr("scoured") then d = d / 1.2 end

   return self:rescaleCombatStats(d)
end
Which doesn't seem to break anything!

It also doesn't work. Even made sure it wasn't just a display thing; damage definitely dropped appropriately with BtF up. So... would anyone happen to able to point out whatever it is I'm blatantly doing wrong? Help would be appreciated, heh, 'cause I'm pretty terrible at this stuff.

*Ideally, it'd be will/cun for the psi-wield weapon regardless, and better of for the main/off hand, but... my competence when it comes to coding begins classification with the in- prefix and gets worse from there. Baby steps.

E: Wait, wait, no, it breaks something. Ranged attacks spit out a lua error with that mess. Whoops. At least I can stop being faintly surprised at how little it screwed things up, now.


Top
 Profile  
 
PostPosted: Sat Dec 17, 2016 12:16 am 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 6032
Wouldn't it make more sense to modify the Beyond the Flesh code instead of the combat core?

_________________
My feedback meter decays into coding. Give me feedback and I make mods.


Top
 Profile  
 
PostPosted: Sat Dec 17, 2016 12:53 am 
Offline
Sher'Tul

Joined: Sat May 15, 2010 9:17 pm
Posts: 1481
It'd be nice, but as near as I can tell the weapon modifier stuff isn't in the BtF code. It calls on use_psi_combat, as far as I can parse, which seems to have the stuff specifically related to the wil/cun thing defined in combat.lua (and some other stuff, but m'not trying to tinker with the aura junk).

I'm not even remotely sure about any of that, but the BtF code's in psionic/other.lua and makes no mention of referencing stats that I can find outside of the description and the gem related stat buff, and combat.lua was where find-in-file found reference to both use_psi_combat and the weapon modifier, heh. Unless I'm missing it/badly misunderstanding some of BtF's code, which is entirely possible, ahaha.


Top
 Profile  
 
PostPosted: Sat Dec 17, 2016 1:33 am 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 838
Location: Middle of Nowhere
So, ideally you want this to affect main/off weapons when str/dex is higher than cun/wil, and leave the TK-wielded weapon alone?

The 'use_psi_combat' attribute is set when the tk-wield attack is made, and it is also set when the player activates the talent, making it affect all weapons. Since it is set for the tk attack each time the attack is made, all we need to do is set up a check to decide when to set the attribute for the player. This is done in the 'activate' field of the talent:
Code:
activate = function (self, t)
      local tk = self:getInven("PSIONIC_FOCUS") and self:getInven("PSIONIC_FOCUS")[1]
      if not tk then return false end

      local ret = {name = self.name:capitalize().."'s "..t.name}
      if tk.type == "gem" then
         local power = (tk.material_level or 1) * 3 + math.ceil(self:callTalent(self.T_RESONANT_FOCUS, "bonus") / 5)
         self:talentTemporaryValue(ret, "inc_stats", {
            [self.STAT_STR] = power,
            [self.STAT_DEX] = power,
            [self.STAT_MAG] = power,
            [self.STAT_WIL] = power,
            [self.STAT_CUN] = power,
            [self.STAT_CON] = power,
         })
      elseif tk.subtype == "mindstar" then
         ret.mindstar_grab = {
            chance = (tk.material_level or 1) * 5 + 5 + self:callTalent(self.T_RESONANT_FOCUS, "bonus"),
            range = 2 + (tk.material_level or 1),
         }
      elseif tk.combat then
         self:talentTemporaryValue(ret, "psi_focus_combat", 1) -- enables Psi Focus attacks
      end
      self:talentTemporaryValue(ret, "use_psi_combat", 1) -- Affects all weapons
      game:onTickEnd(function()
         self:actorCheckSustains(true) end -- affects equipment for some talents
      )
      return ret
   end,



Right near the end, " self:talentTemporaryValue(ret, "use_psi_combat", 1) -- Affects all weapons ". You could wrap this inside a check that looks at the actor's weapon(s) and stats and determines if using the normal stats is more ideal. Then, each time the sustain is activated, it would either set the value or not. Even when it is not set, the TK attack will still use the 'psi_combat' modifiers.

I think that's more or less what you are looking for?


Top
 Profile  
 
PostPosted: Sat Dec 17, 2016 3:03 am 
Offline
Sher'Tul

Joined: Sat May 15, 2010 9:17 pm
Posts: 1481
It... sounds like it is, at least. Will just have to figure out how to get it to look at the actor's weapons and stats, eheh.* Or at least get around to remembering what else in the game does something similar, so I can shamelessly plagiari... uh. Find an example. Yes. Example. Of similar coding.

... tomorrow, at least. Too late to give myself a headache now, ha.

*Won't lie, probably better than half the reason I was going at it in the combat.lua bit was it looked like it involved the least among of actual understanding to kludge into something that did what I wanted it to. I have no bloody clue how T4's lua (or any other) coding really works and trying to figure it out consistently gives me a very literal and very intense headache.


Top
 Profile  
 
PostPosted: Sat Dec 17, 2016 9:09 pm 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 838
Location: Middle of Nowhere
I whipped up a quick addon that makes the changes I described. When you activate Beyond the Flesh it will check your main-hand weapon and your stats to determine if it will set the 'use_psi_combat' value. Right now, it will check to see if you have a mindstar in your mainhand. If you do, it sets the value. If you don't, it passes on to another check. If it gets to this step, it will check to see if: 1) your Str is less than 60% of your Wil and 2) your Dex is less than 60% of your Cun. If both are true, then it will set the value, otherwise it will not.

Try it out, feel free to dig into it and change the checks any way that you like. Most of my changes come near the end and I left a couple of notes, but I think you'll be able to figure it out from the code. Feel free to shoot any questions you have my way, I'll do my best to answer. If it does what you're looking for, or you can tweak it so that it does, you're welcome to upload it :)


Attachments:
tome-btf_tweak.zip [3.08 KiB]
Downloaded 49 times
Top
 Profile  
 
PostPosted: Sat Dec 17, 2016 10:29 pm 
Offline
Sher'Tul

Joined: Sat May 15, 2010 9:17 pm
Posts: 1481
It's definitely about what I was thinking of, hohoho. Thanks!

Am going to try tweaking it a little, though. Pretty sure I've got a resonant focus check added in now and maybe one for staves, too. Probably going to try to poke at it a bit more to see if it's possible to get it to check weapon modifiers (incidentally, if you, or anyone, happen to know what bit of coding would do that...) as well, since 2 handers, daggers, and staves all add some extra considerations. As do a couple prodigies, some talents, and several artifacts, now that I think about it. I think something checking modifiers instead of if prodigies are in play or whatev' would be less... cluttered. Assuming it's possible, anyway, heh.

Also might weight it towards the damage component, since the accuracy aspect generally isn't really the issue with sticking BtF into an unusual build. Not sure how much I'll poke at it, though... part of me is already doing odd things like idly trying to figure out if PES would be worth adding a check for, eheh.*

*I could actually see it for something like a wyrmic or cursed base, ferex, that's topped out both str and wil and would have the PES activation tip the mental stats over the edge... and if you've got PES, you've probably built for enough crit it's functionally always on and having BtF check wil/cun instead of str/dex would be better on the net.

E: Though it looks like it doesn't need a check for staves, checking some stuff. Which is disconcerting, 'cause I could have sworn BtF changed the modifier on those things...


Top
 Profile  
 
PostPosted: Sun Dec 18, 2016 12:01 am 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 838
Location: Middle of Nowhere
You could check the modifiers, sure. They are stored inside a field called dammod inside of the combat field of a weapon. In the tweaked BtF, you could check for a particular dammod, after the weapon has been found, with something like:
Code:
if weapon.combat.dammod.str then

Using checks like that, you could effectively check for prodigies like Superpower or Arcane Might by looking for Mag or Wil modifiers, because they actually change the dammod field of all affected items. If you had need to, you could check the actual numbers of the damage modifiers. They are multipliers, so a weapon with a 120% strength dammod would have a value of 1.2 stored in combat.dammod.str, for example.

One thing I hand't thought of before that might be worth note are dwarven adventurers. Right now, there is an addon that lets them choose Stone Warden talents, potentially allowing them to dual-shield. When Possessors displace Stone Wardens in 1.5, this will become part of the base game, as well. If you want to check for a shield, you can use the same check for the subtype that I used for mindstars. Just check to see if the subtype is "shield". If you want to take the dammod route, shields are slightly different. Their dammods are stored under special_combat.dammod, rather than combat.dammod. You would need to check them separately, since they don't have a 'combat' field.

PES would be harder to account for, because the stat change is temporary. If you wanted it to change on the fly when PES triggers, it would involve re-writing the talent so that it checks every time your stats change and re-determines whether or not to set the value. It could be done, but it would be a bit messy. If, however, you're just going to assume that if you know PES you will have it up most of the time and therefore your Wil will be greater than your Str most of the time, that would be pretty simple. You can check if the actor knows a talent by adding a check such as:
Code:
if self:knowTalent(self.T_PAIN_ENHANCEMENT_SYSTEM) then

If you wanted, you could check for PES and then check to see if half of the actor's strength plus their willpower is greater than their strength, and then go from there.

Edit:
Oh, also, ranged weapons. They have a combat field, but the dammod is actually in the ammo's combat field. If you want to check those, you could do a check on the weapon subtype to see if it is a bow or sling, and afterwards get the information for the ammo. Something like:
Code:
if weapon.subtype == "bow" or weapon.subtype == "sling" then
   local ammo = self:getInven("QUIVER") and self:getInven("QUIVER")[1] or false
   if ammo and ammo.combat.dammod.str then
      foo()
   end
end


Top
 Profile  
 
PostPosted: Sun Dec 18, 2016 1:54 am 
Offline
Sher'Tul

Joined: Sat May 15, 2010 9:17 pm
Posts: 1481
Ho, sweet. Pretty sure that's exactly what I was hoping for, ahaha! Be another day due to sleeping before sitting down and mangling up a full check, but I think I might actually be able to, now, which is better than I normally manage with T4 coding :V

Thanks again, eheh. I don't think I had realized how much BtF sometimes being a detriment bothered me until I started looking at fixing it. Smart(er) BtF'll be neat.


Top
 Profile  
 
PostPosted: Sun Dec 18, 2016 4:09 am 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 838
Location: Middle of Nowhere
Glad I could help :)


Top
 Profile  
 
PostPosted: Mon Dec 19, 2016 5:39 am 
Offline
Uruivellas

Joined: Mon Jan 27, 2014 10:40 am
Posts: 703
not gonna lie I'll download this in a heartbeat when it's working.


Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 3:19 am 
Offline
Sher'Tul

Joined: Sat May 15, 2010 9:17 pm
Posts: 1481
What nsrr attached works fine, actually, if you don't want to wait and don't care it's pretty straightforward. I'd... kinda' suggest it, really. I got distracted by life stuff, so only got around to actually making a mess of nsrr's poor, helpless code this afternoon. Starting to test just now, even.

Let it be repeated I'm freaking terrible at this, by the by. Think I'm on the track of something that's going to work, but I'm also fairly sure it's going to spontaneously generate headaches in anyone that can code worth a flip that sees it.

... also it's not going to care about accuracy (save maybe a check for staves, I'unno), or even remotely attempt to include the offhand in its calculations. I don't have near enough moxy to try for that. So there's not really going to be that much additional functionality over what nsrr already put up, either.

E: Speaking of which, an initial pass just covering melee weapons is currently seemingly functioning for 2handers! Going to attach a copy of the modified tweak, because I've managed to balloon the poor blighter's psionic.lua file from 59 lines to 127 (and adding launcher support is probably going to increase it by about the same amount). Also it's formatted well enough (for a given value of well enough that may make anyone with much coding experience scream internally, anyway) in notepad++, but a cursory check in other things is... not. At all. So yeah, warning and all that if you're going to look at it.

It would be really nice if someone else could do some testing, check and see how it handles stuff on their end. Just rename the zip file to teaa and go from there. I think. Or even just look at the code for any obvious mistakes, of which I'm very, very sure there are some. I've currently got a headache from hell and probably won't manage any QA checks until tomorrow at the earliest. Do note the check for launchers isn't in there yet, though. Only handles mainhand melee weapons, and I'm like 80% sure there's some problems with overlap (a str/dex scaling weapon might be getting hit repeatedly, by its check and the checks for strictly str or dex ones, ferex) I'll have to deal with... later. Unless LUA's smarter than me, which is entirely possible with the biology induced INT penalty I'm currently rocking.

Still, it at least appears to now be very sensitive to if you're actually going to get a larger effective stat modifier by the switch from strength to willpower scaling, at the absolute least. Haven't checked anything except the starting mindslayer greatswords, yet, though. Head, etc., etc.

E2:... that feeling when you wake up in the morning, look over a bit of code, and very literally do not know what you were thinking the night before. Other than overthinking, apparently. Pretty sure I made that a lot more complicated than it needed to be. I blame the headache. Give a mo', should have something less bugnuts in a minute or fifteen.


Attachments:
tome-btf_tweaktweak1stpass.zip [3.42 KiB]
Downloaded 54 times
Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 6:03 pm 
Offline
Sher'Tul

Joined: Sat May 15, 2010 9:17 pm
Posts: 1481
Bump instead of edit because I think I've got it, and something like sixty, seventy minutes of fiddling around with edge cases and whatnot is looking like it's working. Also the code is more sane than my first pass, and the math less deranged. No PES check, it doesn't even try to factor in the offhand or accuracy (save for staves), and I can't seem to figure out if it's responsive to on the fly stat changes (PES, heroism, etc.) or not, but... otherwise, it seems to be working. Responds appropriately to melee weapons, mindstars, staves, and launchers (including steamguns, heh).

... well, except it's still flipping the TK weapon's stats in line with the rest instead of always using the BtF values. Not entirely sure how to fix that one. I guess just envision someone with a strength advantage is duct taping the weapon to their head and headbutting anyone that argues about it being psi-wielding.

Areas of improvement, well... it'd be nice to finagle things so it's checking for a shoot talent requirement instead of weapon subtype for the launchers (just to help future proofing/mod compatibility). Also actually factoring in the offhand (and maybe the accuracy component) would be great, and I have no idea how (if) it's dealing with shields. Conceptually something for unarmed, too, would be nice, but there's only so much effort I have to give, heh. Fixing the TK/unarmed interaction in general would be nice... iirc, last time I tried that, having a weapon in the focus slot cuts off your unarmed talents, which doesn't make much sense. Want to say there's something similar going on with cursed gestures, but I don't even know where to start there and probably don't care enough to do something about it regardless :V

Anyway, will leave it here for... let's say a day. If no one can see any particularly serious problems with it, I'll go ahead and upload.


Attachments:
tome-btf_tweak.zip [3.37 KiB]
Downloaded 56 times
Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 9:13 pm 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 838
Location: Middle of Nowhere
I'll give it a look and see if anything pops out at me.

As for the TK weapon, when you look at it in your inventory it will show the normal stats if the 'use_psi_combat' value was not set when you activated BtF. Technically, it is using normal stats at that time, however, the talents that actually make attacks using it always set the 'use_psi_combat' value temporarily before the attack is made and remove it again afterward. This includes the automatic TK hit from BtF, which is handled by another part of the talent which we aren't touching. So, when it attacks, it will always use the 'psi-combat' stats. It would actually take a lot more work and alterations to more talents to get around that, so it's good that you didn't want to, anyway :lol:

That's probably worth noting in the addon description, I suppose :P


Top
 Profile  
 
PostPosted: Thu Dec 22, 2016 11:15 pm 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 838
Location: Middle of Nowhere
Seems to be working as intended, with one bug. If you don't have a weapon in the mainhand, it throws an error. That might be my bad, or maybe it was something that got mixed up in the tweaking. Either way, at the beginning of the changes, after you check for the weapon and ammo, the first check should be ' if weapon and weapon.subtype ~= "mindstar" ' . As it is now, it will pass this check without a weapon and try to index the weapon even if you do not have one equipped.

Aside from that, looks good to go. The code is much cleaner than on the first pass, too :wink: . I hadn't thought to check for Resonant Focus bonuses, either, good call. I'm not that familiar with Mindslayer, honestly.

I tested it with 1h sword, 2h sword, staff, dagger, bow, sling and mindstar, with varying stat values, all seemed to work as intended.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group