[BETA] Oblivion Script Extender (OBSE) 0020

Post » Mon May 02, 2011 8:00 pm

GetBoundingBox should help with that.


GetBoundingBox only works on actors and projectiles... GetDimension would open up more possibilities. We at MERP have been thinking about interactive environments and are also implementing climbing. GetDimension would give a lot of flexibility in detection what the shape of a static object is, and hence what kind of actions are possible. A script could detect the difference between a fence over which your character can hop, or a boulder on which your character can climb.
User avatar
Claire Vaux
 
Posts: 3485
Joined: Sun Aug 06, 2006 6:56 am

Post » Mon May 02, 2011 10:58 pm

What the heck is going on? Am I still confused as to what exactly these functions are suppose to be doing?

GetPlayerSkillUse takes an integer actor value. http://cs.elderscrolls.com/constwiki/index.php/Category:Actor_Values. I believe if you use a _GameMode block (OBSE compiler override), you can use the text name. Probably a good idea to bookmark that chart, tho.

What you really want is an OnSkillUse trigger, which I've already requested but it's not going to show up for 0020 because of the sheer number of code hooks required. For now, use the
User avatar
Charlotte Henderson
 
Posts: 3337
Joined: Wed Oct 11, 2006 12:37 pm

Post » Tue May 03, 2011 6:12 am

GetPlayerSkillUse takes an integer actor value. http://cs.elderscrolls.com/constwiki/index.php/Category:Actor_Values. I believe if you use a _GameMode block (OBSE compiler override), you can use the text name. Probably a good idea to bookmark that chart, tho.

What you really want is an OnSkillUse trigger, which I've already requested but it's not going to show up for 0020 because of the sheer number of code hooks required. For now, use the



ummm... CS is giving me an error (invaild actor value ) when I try to use GetPlayerSkillUse 28

It will accept GetPlayerSkillUse marksman

I am very confused.
User avatar
lacy lake
 
Posts: 3450
Joined: Sun Dec 31, 2006 12:13 am

Post » Tue May 03, 2011 10:56 am

Hmm, me too now. Docs say int, but there's a *C version of that command which implies you should be able to use the text name with the normal version...
User avatar
Shiarra Curtis
 
Posts: 3393
Joined: Thu Jan 04, 2007 3:22 pm

Post » Mon May 02, 2011 10:02 pm

Hmm, me too now. Docs say int, but there's a *C version of that command which implies you should be able to use the text name with the normal version...



And when I change the line to "set OldSkillLevel to GetPlayerSkillUse marksman" and "If (GetPlayerSkillUse marksman) > OldSkillLevel" the script no longer worked! But when I changed it back to "IncrementPlayerSkillUse" and it works. Somehow IncrementPlayerSkillUse increased (?) when the player's arrow hits the NPC.

If the arrow missed the NPC my message-box did not pop up, it only popped up if the arrow hits the NPC.
User avatar
Arrogant SId
 
Posts: 3366
Joined: Sat May 19, 2007 11:39 am

Post » Tue May 03, 2011 10:47 am

Somehow IncrementPlayerSkillUse increased (?) when the player's arrow hits the NPC.

This actually matches the docs. IncrementPlayerSkillUse returns the new total experience for that skill.

But of course, it has the side effect of also increasing the skill, which you probably don't want. GetPlayerSkillUse definitely should work, and I'm not sure why it doesn't.

Maybe try using the *C version: GetPlayerSkillUseC 28
User avatar
Dan Scott
 
Posts: 3373
Joined: Sun Nov 11, 2007 3:45 am

Post » Tue May 03, 2011 12:41 am

This actually matches the docs. IncrementPlayerSkillUse returns the new total experience for that skill.

But of course, it has the side effect of also increasing the skill, which you probably don't want. GetPlayerSkillUse definitely should work, and I'm not sure why it doesn't.

Maybe try using the *C version: GetPlayerSkillUseC 28


I suspect there's a typo in the documentation. I think it's supposed to be as you suggest, using GetPlayerSkillUseC with an int will work, where the other form is meant to be the skill form. Recently I was using GetDescription and that had a really strange syntax, imo. It took an object reference, so all the skills had to be passed as SkillArmorer, SkillAthletics etc. I got help from Kyoma on that and it made me wonder where the heck these magic codes for skills came from. Might be something similar here.

I would try tejon's suggestion and see if that works.
User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Tue May 03, 2011 11:01 am

I'm planning to add a balance option to my mod, the option will make learning spells from scrolls skill based(possibly). (Not 100% decided on how I'm going to balance it yet, just looking at options..)

I possibly, want to do what the spell menu does, when you create a spell, whatever effect type is more dominant becomes the school of the created spell.

I see this.. GetSpellSchool - Would this work with a scroll, is that a spell according to the game, or would I need to swap it over to a spell first, then check it, or is there a better way to go about this? I also need to be able to compare the level of the scroll\spell, against the players skill level in that school, ie, if the scroll were a spell, what level in the school would it require to cast, and does the player meet this requirement, if no, learning the spell will fail.. (Might factor in a bit of luck, etc, to make this less strict, I'm mainly trying to figure what functions I need to be looking into, rather than detailing exact designs, etc,...)

So, am I on the right track here, or is there a better way to go about doing this? (Basically, this is a yes\no kinda deal, if I'm on the right track, I should be able to use the docs to figure out the necessary related commands, I just don't want to do things the hard way, or in a way that's going to have issues somewhere along the line..)

I also wanted to ask about that function we talked about awhile back, I wanted to be able to apply an enchantment, and have it adjust itself, just like sigil stones do..

Ie, if I add an effect directly to a weapon, it gives completely different results when compared to placing the same effects on a Sigil and creating the weapon from that instead.. I'll admit, I haven't created a weapon under the new OBSE though, so you could have implemented this directly into setenchantment without my noticing, if so ignore this.. I'm just to the point in my mod where I'm needing all these things I was wanting\requesting over the last while..
User avatar
jasminε
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am

Post » Tue May 03, 2011 9:59 am

@Claviticus, a Scroll is an enchanted book item, so what you need to do is call GetEnchantment on the Scroll first, which gives you the Enchantment ID. GetSchool won't work on Enchantments. To get the School of an enchantment, you should iterate over the Effects in the Enchantment and determine which one has the highest magicka cost (***). That effect will determine the School of the Enchantment. Enchantments do have auto-calc costs, so you can compare them with the game settings fMagicSpellLevelApprenticeMin, fMagicSpellLevelJourneymanMin etc to detect if the player is eligible to learn that spell.

You're going to need to create dynamic base objects on the fly if you want the created Spells to survive reloads/restarts of the game. I advise to use CloneForm on a Spell, then strip all the magic effects from this clone with RemoveAllEffectItems, and then use CopyAllEffectItems on the Enchantment with the empty cloned Spell base object as the target. Then use Player.AddSpellNS on the clone to add it to the player spells list.


(***) Actually, it might be easier to first create the Spell clone, and then use GetSchool on the clone instead of iterating over the Effects of the Enchantment. If the player isn't eligible, you just don't add the cloned spell to the player, and re-use it on the next attempt.
User avatar
Gisela Amaya
 
Posts: 3424
Joined: Tue Oct 23, 2007 4:29 pm

Post » Tue May 03, 2011 7:29 am

(***) Actually, it might be easier to first create the Spell clone, and then use GetSchool on the clone instead of iterating over the Effects of the Enchantment. If the player isn't eligible, you just don't add the cloned spell to the player, and re-use it on the next attempt.


That's exactly what I said I was going to do.(ie, Self Quote=>or would I need to swap it over to a spell first<) Perhaps I just wasn't clear enough..

I was just curious if a better method existed..(ie, a way to do it directly from the scroll, and avoid needless creation of bloat..)

Anyways, thanks for taking the time to answer me, I appreciate it. :)

---

Edit: I would still prefer a cleaner solution, I either have to create some method for managing the clones for reuse later, as you suggested, or just deal with the fact that I'm creating cloneforms that may not be used...

That's also why I was worried about issues down the road with this method, for instance, using an array to store them, don't arrays(in particular, a StringMap seems best, ie, storing them by scroll\spell name(key) ref(value)..) have upper limits, etc,.? What if they change their mind, and I've stored it, eventually, it's going to get full, etc,..

I'm going to have to think about it some more, perhaps just create my own spell learning skill that governs it.. Or sum total of all their skills + luck vs. some formula... Is there a value in the scrolls(perhaps,auto-calc) stuff, I could use to weight the scrolls power in my formula? (I guess I could use the gold value of scroll as measurement of it's power? After a quick look in the CS, I saw an Enchantment value in the auto-calc, but I'm not quite sure how to get at that value, it may be of use as well..)
User avatar
stevie trent
 
Posts: 3460
Joined: Thu Oct 11, 2007 3:33 pm

Post » Tue May 03, 2011 5:05 am

And when I change the line to "set OldSkillLevel to GetPlayerSkillUse marksman" and "If (GetPlayerSkillUse marksman) > OldSkillLevel" the script no longer worked! But when I changed it back to "IncrementPlayerSkillUse" and it works. Somehow IncrementPlayerSkillUse increased (?) when the player's arrow hits the NPC.

If the arrow missed the NPC my message-box did not pop up, it only popped up if the arrow hits the NPC.

Why not use the OnHitWith event? You can indeed track arrow hits, I've already done that, it works fine. And you don't have to care about misses.

GuruSR.
User avatar
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Mon May 02, 2011 8:00 pm

A quick request: GetCellNorthMarker(Angle). The related ExtraData was already decoded so I'm guessing it is (relatively) easy to add.
User avatar
Colton Idonthavealastna
 
Posts: 3337
Joined: Sun Sep 30, 2007 2:13 am

Post » Mon May 02, 2011 10:29 pm

Edit: I would still prefer a cleaner solution, I either have to create some method for managing the clones for reuse later, as you suggested, or just deal with the fact that I'm creating cloneforms that may not be used...

That's also why I was worried about issues down the road with this method, for instance, using an array to store them, don't arrays(in particular, a StringMap seems best, ie, storing them by scroll\spell name(key) ref(value)..) have upper limits, etc,.? What if they change their mind, and I've stored it, eventually, it's going to get full, etc,..

I'm going to have to think about it some more, perhaps just create my own spell learning skill that governs it.. Or sum total of all their skills + luck vs. some formula... Is there a value in the scrolls(perhaps,auto-calc) stuff, I could use to weight the scrolls power in my formula? (I guess I could use the gold value of scroll as measurement of it's power? After a quick look in the CS, I saw an Enchantment value in the auto-calc, but I'm not quite sure how to get at that value, it may be of use as well..)


Concerning the last question, just use GetEnchantmentCost for that.

If you are worried about bloating, do it this way: Just create a regular Array to which you append the FormID of any new clone you create. Before making a new clone however, iterate over all clone FormID's that are already in the Array and do a Player.HasSpell check on all of them. If one returns false, that particular cloned form has been deleted from (or never been added to) the player's spell list and can thus be re-used. If all current clones are actually in the player's list, you create the new clone and append it to the Array.

As far as I know, Array's don't have a maximum size. At least not one you'll reach in practice.
User avatar
Anne marie
 
Posts: 3454
Joined: Tue Jul 11, 2006 1:05 pm

Post » Tue May 03, 2011 5:45 am

Concerning the last question, just use GetEnchantmentCost for that.


Alright thanks, I'll check it out, see what kind of values it returns, and if I can do anything with em'..

If you are worried about bloating, do it this way: Just create a regular Array to which you append the FormID of any new clone you create. Before making a new clone however, iterate over all clone FormID's that are already in the Array and do a Player.HasSpell check on all of them. If one returns false, that particular cloned form has been deleted from (or never been added to) the player's spell list and can thus be re-used. If all current clones are actually in the player's list, you create the new clone and append it to the Array.

As far as I know, Array's don't have a maximum size. At least not one you'll reach in practice.


Yeah, I kinda have to worry about bloat, if you check out my mod Advanced Magecraft, you will see it creates a bit of bloat already, but I do so only when the player is wanting to do something that requires cloneforming to avoid issues.. (Like if they enchant a ring, I have too, or else it effects all the rings of that type..)

So adding in a function that creates more, just to throw it away wasn't sitting well with me.. Especially given how much work I've done lately to clean up my mods code.

Regardless, thanks again for your time, and advice on this, I'll definitely give this a try, it sounds like it should do what I need. :)

--

Edit: Can anyone comment on array iteration speed, one concern, is my mods UI, you can enter into it, do something, then immediately get right back in there, and in fact, that's more often than not how it gets used. So any function that's too heavy can cause the UI to feel jerky.. (I wouldn't imagine the array would ever have over 100 items at worse..)

Is there any cause for concern here? I just haven't used OBSE arrays to that extent, and have no idea what their actual performance is under heavier loads, nor do I know what is considered a heavy load by them.. (Ie, in C#, a List starts breaking down at around 20,000 items, anything less has great speed, anything more runs like a turd, this number may be specific to my machine, your mileage may vary..)
User avatar
Sophh
 
Posts: 3381
Joined: Tue Aug 08, 2006 11:58 pm

Post » Tue May 03, 2011 2:42 am

In this case, the array iteration will only happen once for every scroll-learning action, and it will happen in the same frame. The worst that can happen is that the menu freezes for a very short while, like a split second. I wouldn't worry about it, especially since it'll be in menumode. I use loops quite often, and have never run into serious performance problems.
User avatar
Alisia Lisha
 
Posts: 3480
Joined: Tue Dec 05, 2006 8:52 pm

Post » Mon May 02, 2011 11:13 pm

In this case, the array iteration will only happen once for every scroll-learning action, and it will happen in the same frame. The worst that can happen is that the menu freezes for a very short while, like a split second. I wouldn't worry about it, especially since it'll be in menumode. I use loops quite often, and have never run into serious performance problems.


Alright, sounds good, well thanks again for your help. :)
User avatar
mimi_lys
 
Posts: 3514
Joined: Mon Apr 09, 2007 11:17 am

Post » Mon May 02, 2011 8:53 pm

This works! Thank you for that.

But also thank you (and andalaybay ) for answering my actual question. Often I get "solutions" I did not ask for from good intentioned people because they do not understand I am asking for the "whys" and not the "hows".

Sometimes I do ask for the hows, but more often I desire my specific questions answered (or at lease addressed)
because I very much dislike not understanding what I am doing in my mods.


Maybe try using the *C version: GetPlayerSkillUseC 28

User avatar
lexy
 
Posts: 3439
Joined: Tue Jul 11, 2006 6:37 pm

Post » Tue May 03, 2011 5:35 am

Oh, has there been an article written yet on OBSE Arrays usage? Someone here had said once they might write one for the wiki.
User avatar
Robert DeLarosa
 
Posts: 3415
Joined: Tue Sep 04, 2007 3:43 pm

Post » Tue May 03, 2011 10:12 am

So if I use mods that Require OBSE I need to run Oblivion with the OBSE loader instead of the normal Oblivion launcher?
User avatar
Amy Masters
 
Posts: 3277
Joined: Thu Jun 22, 2006 10:26 am

Post » Tue May 03, 2011 4:00 am

Edit: Can anyone comment on array iteration speed, one concern, is my mods UI, you can enter into it, do something, then immediately get right back in there, and in fact, that's more often than not how it gets used. So any function that's too heavy can cause the UI to feel jerky.. (I wouldn't imagine the array would ever have over 100 items at worse..)

Is there any cause for concern here? I just haven't used OBSE arrays to that extent, and have no idea what their actual performance is under heavier loads, nor do I know what is considered a heavy load by them.. (Ie, in C#, a List starts breaking down at around 20,000 items, anything less has great speed, anything more runs like a turd, this number may be specific to my machine, your mileage may vary..)
I recall reading that setting up the iteration/loop would be more 'demanding' than iterating through the array itself. Or atleast the potential hit on iterating a large array is almost nothing compared to what code you might be using within the loop.


So if I use mods that Require OBSE I need to run Oblivion with the OBSE loader instead of the normal Oblivion launcher?
Yes.
User avatar
Donatus Uwasomba
 
Posts: 3361
Joined: Sun May 27, 2007 7:22 pm

Post » Tue May 03, 2011 5:10 am

Hey Scruggsy..

WARNING: substantial numbers of string variables exist for the following files (may indicate savegame bloat):
Advanced Magecraft.esp (633 strings)

I just checked my mod, and I call sv_Destruct on every single string I use.. Perhaps it's left overs from an earlier version of my mod, I'm not sure..

What I want to know, is there any way I can flush those? Would simply clean saving without my mod do it, or what? (Wrye Bash said my save was fine..)

I basically want a clean slate, so I can figure out what's going here..
User avatar
Darlene DIllow
 
Posts: 3403
Joined: Fri Oct 26, 2007 5:34 am

Post » Tue May 03, 2011 6:58 am

A clean save should get rid of the strings.
User avatar
Nick Tyler
 
Posts: 3437
Joined: Thu Aug 30, 2007 8:57 am

Post » Tue May 03, 2011 10:57 am

A clean save should get rid of the strings.


Alright, thanks.. :)

I'll report back if they return, we'll go from there.. (Mainly talking to scruggs on this one, to be clear.)
User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Tue May 03, 2011 10:20 am

I just discovered PurgeCellBuffers, and this has become a vital function for me to prevent a CTD in my scripting. Are there any other functions with the purpose of improving game performance? After searching, this is the only one I've found.
User avatar
RaeAnne
 
Posts: 3427
Joined: Sat Jun 24, 2006 6:40 pm

Post » Tue May 03, 2011 6:42 am

Alright, I had an issue the other day, and it went away, so I figured it was just Oblivion being weird, or something..

Now it's occurring again, basically, my inventory is acting wonky. An example, I killed two bandits, and stripped their gear, each had a set of glass armor, and daedric daggers.

The problem, is that they(none of the items) were stacking in my inventory, I ran my mods function to recycle items on them, and my mod said it was deleting them, however, checking the inventory, they remained.. (I know this function works correctly, I used it a lot, with 0 issues.) A bit later, they vanished, but my mod had already returned a message that could only occur after deletion, beforehand..(This bit probably just skews the issue, but I thought I should mention the behavior I"m experiencing.. It also kind of alludes to a few possibilities, such as, something actively scanning my inventory, and changing formid's, causing my mod to be unable to remove the item, or similar..)

(Also, I can't be sure, but I swear I had only two daedric daggers(the ones I just grabbed), yet it showed three in my inventory, I think the counts were off for the bandit gear as well..)

Here is my recycle code, just to be sure there is nothing wrong here.. (Though it couldn't cause the inventory stacking issue, seeing as it happened b4 I used this..)

Spoiler

scn aaaRecycle; A function for deleting game items.ref Itemlong ItemValuelong FinalValuelong Amountlong PlayerHaslong PayOutBegin Function { Item, Amount }	; Get Item Value	Set ItemValue to ( GetFullGoldValue Item )	Set FinalValue to (ItemValue * aaaAdvancedMagecraftQST.RecycleGoldCost)	; Give 1 Gold For Items Of Value (If Balance Options Reduce Them To 0)		if (ItemValue > 0 && FinalValue =http://forums.bethsoft.com/index.php?/topic/1170916-beta-oblivion-script-extender-obse-0020/= 0 && aaaAdvancedMagecraftQST.RecycleGoldCost != 0)		Set FinalValue to 1	endif	Set PlayerHas to (Player.GetItemCount Item)	if (Amount> PlayerHas)		Set Amount to (PlayerHas)	endif	MessageEx "Recycling: %n - Amount: %0.f" Item Amount	; Remove Items	(It's impossible for no item to reach this function, no if block necessary, there is at least one..)	Player.RemoveItemNS Item Amount	; Give Gold (If applicable)  ; I should probably wrap this in an if block...	Set PayOut to (FinalValue * Amount)	Player.AddItem Gold001 PayOut <--- This is the message I refer to above, the gold added message.. I got this, it must have ran to have gotten here..End



Here is my mod list..

Spoiler
Active Mod Files:00  Oblivion.esm01  Cobl Main.esm  [Version 1.72]02  Unofficial Oblivion Patch.esp  [Version 3.3.3]03  DLCShiveringIsles.esp04  Unofficial Shivering Isles Patch.esp  [Version 1.4.0]05  Enhanced Water v2.0 HD.esp06  BEER_Inebriation.esp  [Version 1.21]07  CLS-Object Renamer-COBL.esp08  Map Marker Overhaul.esp  [Version 3.8]09  Map Marker Overhaul - SI additions.esp  [Version 3.5]0A  Enhanced Hotkeys.esp  [Version 2.1.1]0B  Cobl Glue.esp  [Version 1.72]0C  Cobl Si.esp  [Version 1.63]++  Cobl Tweaks.esp  [Version 1.44]0D  Imperial Furniture Renovated.esp0E  StarX Vampire Deaths.esp0F  Toggleable Quantity Prompt.esp  [Version 3.2.0]10  Advanced Magecraft.esp11  SupremeMagicka.esp  [Version 0.90b]12  SM_ShiveringIsles.esp  [Version 0.90]++  SM_COBL.esp  [Version 0.90]13  SM_EnchantStaff.esp  [Version 0.90]++  SM_Scrolls.esp  [Version 0.90]++  SM_SigilStone.esp  [Version 0.90]14  Cobl Races.esp  [Version 1.52]15  Decoration Wizard.esp (My mod, unreleased, does nothing even remotely close to being able to cause this..)16  FO3Keys.esp (My mod, also unreleased, simply sets "A" key to take all in containers.. Which makes it suspect.. It touches what is malfunctioning.. It's also recently added.. But I can't see how what it's doing could cause this..)17  Bashed Patch, 0.esp


OBSE Plugins

CSE v4.0Elys Uncapper (version ?)Elys Silent Voice (version ?)OBGE v2MenuQue v7Oblivion Stutter RemoverWEOCPS (Crash Prevention System)


Edit: This is issue is very hard to track down.. I wish it were a constant issue, rather than sporadic, I can't tell if removing mods fixed it, or it's just not occurring at the moment, etc,.

----

Edit2:

WARNING: substantial numbers of string variables exist for the following files (may indicate savegame bloat):
Advanced Magecraft.esp (141 strings)

I've saved once, maybe twice since the creation of a clean save.. Something is not right.
User avatar
Nomee
 
Posts: 3382
Joined: Thu May 24, 2007 5:18 pm

PreviousNext

Return to IV - Oblivion