Aller au contenu

Photo

tTalents


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
kevL

kevL
  • Members
  • 4 070 messages
woohoo!
I just got an Ogre Magi to use an item's ability on itself. Gave him a Runescarred Greatsword, which has Heroism. That falls into TALENT_CATEGORY_BENEFICIAL_ENHANCEMENT_SINGLE

he also had Invisibility mem'd as a regular spell, which is in the same category. Then with this code:


talent tBeneEnhSingl_rand = GetCreatureTalentRandom(TALENT_CATEGORY_BENEFICIAL_ENHANCEMENT_SINGLE);
if (GetIsTalentValid(tBeneEnhSingl_rand))
{
ClearAllActions(TRUE);
DelayCommand(0.2f, ActionUseTalentOnObject(tBeneEnhSingl_rand, OBJECT_SELF));
}


( called in this case from X2_Special_ai ) the Ogre first cast Invisibility on itself, and the next round Heroism went off!!!


next ... *potions*

#2
ColorsFade

ColorsFade
  • Members
  • 1 270 messages
Whoa. That *is* awesome... I've been wanting to do that for a while.

You made my day kevL.

#3
kevL

kevL
  • Members
  • 4 070 messages
if/when you start playing with Talents, beware breakage.

To find *exactly* what category a spell fits, look in Spells.2da at the Category column. Same for Feat.2da (and Skills.2da). Or do what i did: load up yur monster and write a script that cycles through all categories on it, using GetCreatureTalentBest() and decrement MaxCR each loop for each category. (Less powerful abilities or 'talents' seem to correspond to lower MaxCR..) Output the type and ID on each loop, then look em up in the .2da's

I think "indiscriminant" is supposed to mean "ok to hit allies" -- although Cone of Cold shows up there .....

"obtain allies" is summons, etc. Note there's also a Categories.2da but even the guy who wrote nwn2_Spells.txt (in the .2da zip) isn't sure if it does anything; i fixed mine up with a placeholder on line#0 and put in the true nwscript constants anyway. See what happens,


( edit, i started w/ MaxCR 20 )

Modifié par kevL, 22 mars 2013 - 08:10 .


#4
kevL

kevL
  • Members
  • 4 070 messages
tl;dr : in Feat.2da, CATEGORY & MAXCR columns work.. sorta. But don't know where spells are getting their CR from. In Spells.2da the Category column works.



As a test, I changed Spell.2da Category for Cone of Cold ( SpellID #25 ) from "11" TALENT_CATEGORY_HARMFUL_AREAEFFECT_INDISCRIMINANT, to "1" TALENT_CATEGORY_HARMFUL_AREAEFFECT_DISCRIMINANT

and my debug script appropriately regarded my OgreMagi's mem'd Cone of Cold under the new category.

( i was concerned that the category might be defined in Henchspells.2da -- and it probably is for the scripted AI, but apparently not for these native functions )


Of interest:
GetCreatureTalentBest found Cone of Cold ((with the above change)) between 20 and 10 MaxCR, then switched to Sleep under 10 CR, and came up empty at 0 CR. However, there are talents that come up valid at 0 CR in other categories ...

Charm Person under harmful_ranged didn't, but healing_potion did and so does harmful_melee. ( maybe spells won't get chosen at only 0 MaxCR.. )

The oddest thing was harmful_melee: the chosen talent keeps switching back and forth between Disarm and Combat Expertise, don't know why. And it never chooses Knockdown -- all 3 feats are available to the Magi. Ahh, Knockdown isn't assigned a CATEGORY in Feat.2da. It *is* assigned a MAXCR right beside this tho. Improved Knockdown has neither. Disarm has both set; Improved Disarm has neither. Power Attack has both set; so does Improved Power Attack

Yep as soon as I assign Knockdown harmful_melee ( "22" ) in Feat.2da it shows up as an available talent in debug. I tend to believe, atm, that the scripted AI uses values from Hench*.2da rather than from these standard .2da's ...... anyway, i'm putting in some numbers here. See what happens ;)

I have no clue where MaxCR is defined for spells yet, because so far i see no reason that these native functions are accessing Henchspells.2da.


Also, GetCreatureTalentRandom doesn't seem very random: the ogre has always gone Invis first, then Heroic 2nd. (on a half dozen runs). probly the pRNG seed ....


- am looking at the CATEGORY & MAXCR columns in Feat.2da; hard to make sense and easy to think "unfinished". Things like Bardsongs seem well set up with entries like 8 enhancement_areaeffect & 20 CR. Others like Epic Shapes & Epic Spells have Shape_Undead, 10 & 1 but then right under it is Shape_Dragon with nothing. Even Hellball has ... nothing. Is hellball even implemented in NwN2? .. the spellscript is here. Others have one column and not the other and vice versa.

As a test I pumped Disarm's MaxCR column up to 10 and sure enough, it filled my debug under harmful_melee as the talent to choose, from 0..20 MaxCR in GetCreatureTalentBest(). This is evidence that both CATEGORY & MAXCR actually work, in Feat.2da

ps. the "CRValue" column in Feat.2da is used for something entirely different, i thinkzor.



Unfortunately, increasing MAXCR even modestly seems to knock lesser Feats off the bottom of the graph,

ie. w/ Improved Disarm @ 3
and Improved Knockdown @ 3

Combat Expertise @ 1 never shows up even at MaxCR = 0. The debug just fluctuates between the two Improved feats. When i increase CE to 4, everything else gets knocked out (from MaxCR 20 down to MaxCR 0 in the debug-loop)


i Wish to stress that all this may have nothing to do with the scripted AI (eg. TonyK's ) which likely uses Hench*.2da files exclusively.


final test: setting the Feats' MAXCR at "1" makes the selection process jump around at various MaxCRs, apparently giving a decent spectrum of harmful_melee Talents.

#5
ColorsFade

ColorsFade
  • Members
  • 1 270 messages

kevL wrote...


and my debug script appropriately regarded my OgreMagi's mem'd Cone of Cold under the new category.


I'm confused. If the Ogre Mage has the spell memorized, why do you need to go through all of this to cast it? I thought we were talking about spells as Item Properties here? 

#6
kevL

kevL
  • Members
  • 4 070 messages
subject of thread is, tTalents

that's a lot more than itemproperties. I'm interested in Talents generally, not just because it seems to be the only means of forcing item usage, but because it helps me understand the scripted AI. My goal is to eventually tweak that; and since a search at Google for "nwn2 talents" turned up only the nwscript entries at nwn2.wikia, well, if anyone else is interested at least they get something to chew on ....


But if you want to know more about item use, it looks like you have to isolate the item's talent into a Talent_Category and spellID (or FeatID, if those are usable on items, i can't think of any and they might run as a spellscript anyway). Here's the script i'm using to determine what a mob is capable of, and what Talent_Categories its abilities fall into: Pastebin

i've been running it from X2_Special but it could be set up to run from console.


The troublesome thing is, not just casting a spell that's mem'd, but segregating a usable itemproperty when the NPC has other talents in that same category. Or likely just let the entries in a particular category fire off randomly, unless one can pin down the near-exact MaxCR that an item's property gets called at

#7
ColorsFade

ColorsFade
  • Members
  • 1 270 messages

kevL wrote...



The troublesome thing is, not just casting a spell that's mem'd...


Well, and that was why I was asking. Because if you just want to cast a memorized spell, there's a much easier way. 

kevL wrote...
...but segregating a usable itemproperty when the NPC has other talents in that same category. Or likely just let the entries in a particular category fire off randomly, unless one can pin down the near-exact MaxCR that an item's property gets called at


Yes, and that's a problem. When I wanted my necro to cast a specific spell on a dagger, I had a helluva a time trying to figure out how to do it. I eventually gave up and "faked" it. 

Have you taken a look at the GetCreatureTalentBest and GetCreatureTalentRandom functions to see what else they might be calling internally? That's been the only way I've been able to figure a lot of stuff out. Unfortunately, tracking down those function calls can be a headache when a script references 5 other libraries, or the authors don't use an #include for the function call (it's unfortunate that the script compiler allows that to happen at all)

#8
kevL

kevL
  • Members
  • 4 070 messages

ColorsFade wrote...

Have you taken a look at the GetCreatureTalentBest and GetCreatureTalentRandom functions to see what else they might be calling internally? That's been the only way I've been able to figure a lot of stuff out. Unfortunately, tracking down those function calls can be a headache when a script references 5 other libraries, or the authors don't use an #include for the function call (it's unfortunate that the script compiler allows that to happen at all)

if i understand correctly, Those are internal functions; I have no way of knowing what they're doing except by running them IG. And you mention why i finally broke all the scripts out of \\Data and put them in Override: not only can I edit them freely, i pull up AgentRansack for internal textsearches. Can usually pull up the subfunctions pretty fast,

The thing is, what you're going to have to do is set up your monster, then run that script i Pasted there. The itemproperty-ability ought show up in one of the Talent_Categories. If that is all that's in the category, gtg.

But if it's competing with another spell or feat in that category, then a guy has to look more closely at what the "MaxCR" value is when (if ?) it switches from the spell/feat to the itemprop or vice versa. And specify


GetCreatureTalentBest(_category_, top_CR_that_IP_is_found) ... i figure something like that should work

#9
ColorsFade

ColorsFade
  • Members
  • 1 270 messages

kevL wrote...
if i understand correctly, Those are internal functions; I have no way of knowing what they're doing except by running them IG. 


Ah, okay. I didn't know if they were internal or not. I've ran into very few of those...

kevL wrote...
And you mention why i finally broke all the scripts out of Data and put them in Override: not only can I edit them freely, i pull up AgentRansack for internal textsearches. Can usually pull up the subfunctions pretty fast,


That's a better way than what I was doing (AgentRansack).

I look at the include headers on a script, and start hunting through the includes using Find to try and find the function call. I haven't found many internal/inaccessible functions though. Almost everything seems to be in a script somewhere. That's why I was asking. 

I have a directory in my "NWN Development" directory called "ForEditing". I dump 2da's and other files in there just so I can look at stuff without fear of messing up my game. I'll dump the scripts next so I can Ransack them for function names. That will be faster than what I was doing. 

The collection of known/available functions for dealing with Talents sure is limited. I mean, GetCreatureTalentRandom()? Really? LOL... .my goodness. 

The whole system seems really imprecise. 

As far as casting spells from items: the path I was going down was using the inventory functions to attempt to get a specific item in the characters inventory (or hand) and then I was going to try and use the UseMagicDevice skill on it. I never got very far into that before I decided that faking it in a cut-scene conversation would be easier (and it was, at the time). 

#10
kevL

kevL
  • Members
  • 4 070 messages

ColorsFade wrote...

Ah, okay. I didn't know if they were internal or not. I've ran into very few of those...

what happens to me now is, occasionally I'm searching and searching thinking "this doesn't exist!" Then ... ah!!! nwscript.nss

Another thing is, so many of the #includes have functions that well, just aren't quite right. I like to use as few of those functions as possible, and if i compile a script with no includes it's a little bonus. Now of course i've been through the includes so many times tinkering that i take a glance at them first to jog my memory.

I look at the include headers on a script,

oh heck no. Open EC's superinclude and switch to it to find functions via ScriptAssist

... I have a directory in my "NWN Development" directory called "ForEditing". I dump 2da's and other files in there just so I can look at stuff without fear of messing up my game.

... it takes a while to get comfortable, but there's always the backups in \\Data

The collection of known/available functions for dealing with Talents sure is limited. I mean, GetCreatureTalentRandom()? Really? LOL... .my goodness.

The whole system seems really imprecise.

I started out by trying to use TalentSpell() ... clunk. Finally i traced it down in the NwNLexicon ... didn't work even in NwN1. Then GetCreatureHasTalent() crashed the game .... Lol

but yeah, the method described above is going to be cludgy but it might be all there is for some things.

As far as casting spells from items: the path I was going down was using the inventory functions to attempt to get a specific item in the characters inventory (or hand) and then I was going to try and use the UseMagicDevice skill on it. I never got very far into that before I decided that faking it in a cut-scene conversation would be easier (and it was, at the time).

wise move. ( i doubt doing a skill check could trigger it.. )

#11
ColorsFade

ColorsFade
  • Members
  • 1 270 messages

kevL wrote...

oh heck no. Open EC's superinclude and switch to it to find functions via ScriptAssist


I had that downloaded, but never got it working correctly (failed to read instructions fully). Decided to give it another go after reading this, and got it working. 

It's great for finding more functions, as you say. But the reason I was hunting through #include files wasn't to look for functions, but to look for the code and see what they were actually doing within the function. And also, to lookup (in many cases) constants. 

Like, I have NWN2 Script Constants bookmarked for fast access. But even there, they are missing some constants. and they only way to find them for sure is to dig through scripts (or 2da files).

Mostly though, I just want to see their code.

Thanks for the tip on EC's though. That is useful... Scanning now. Fun. More functions to explore!

#12
kevL

kevL
  • Members
  • 4 070 messages
ScriptAssist should have some tabs: functions/constants/templates me think

- to see the code for a function, right-click & go to def'n.