Quick Questions, Quick Answers Thread #6

Post » Sun Nov 18, 2012 4:51 pm

Hello, I am trying to add a sound into the CK to add for my spell. I downloaded a sound file and converted it to .wav, and made a fodler for it in my directory and all. But when I click to make a new sound in the "sound descriptor" is says "Invalid directory"...Any tips?

EDIT: After some looking, it seems that the sounds in the vanilla Sound Descriptors start in the Data Folder, and don't have the root stuff before it. For compatibility, of course. But can someone explain how to do this? I don't see any option for it.
User avatar
Ricky Meehan
 
Posts: 3364
Joined: Wed Jun 27, 2007 5:42 pm

Post » Sun Nov 18, 2012 9:48 am

You only need one state. Send the script to Busy state before you do anything and send it back to the original State when you are done.
User avatar
Sarah Kim
 
Posts: 3407
Joined: Tue Aug 29, 2006 2:24 pm

Post » Sun Nov 18, 2012 9:32 am

Spells generally have keywords associated with them that determine things like whether or not they should be considered a fire spell. For school, there's the http://www.creationkit.com/GetAssociatedSkill_-_MagicEffect (I expect you'll also need SKSE's http://www.creationkit.com/GetNumEffects and http://www.creationkit.com/GetNthEffectMagicEffect).

Cipscis

So basically I can check the source is GetAssociatedSkill..... Pretty cool I'll try it out :)
User avatar
Tom Flanagan
 
Posts: 3522
Joined: Sat Jul 21, 2007 1:51 am

Post » Mon Nov 19, 2012 1:51 am

Does anyone know how fast FindRandomRefOfAnyTypeInList iterates through the list (or if it iterates, or just somehow already "knows" whats in it)? I want to make a gravity gun spell, so to do it I need to add darn near every non-static non-actor baseobject in the game to a FormList to make it work to my satisfaction, and I will need something (a spawned object from the projectile's explosion) to do a FindRando for me. Wondering if it is going to take too long to be feasible or not.

EDIT: It appears to work fast, meaning it probably has an intelligently designed search function.
User avatar
Lily Evans
 
Posts: 3401
Joined: Thu Aug 31, 2006 11:10 am

Post » Sun Nov 18, 2012 3:48 pm

Ok so GetAssociatedSkill doesn't work for me inside an OnHit event. Do I need OnEffectStart? Just want to register to do something when the player hits an object with a destruction spell :smile:

EDIT:

Nvm, I'm using keywords... destruction isn't used much by the looks of it, but each damage type (FireDamage) is so :)
User avatar
Tammie Flint
 
Posts: 3336
Joined: Mon Aug 14, 2006 12:12 am

Post » Sun Nov 18, 2012 12:58 pm

How do you set ignore flags for unwanted changes in a mod? I'm guessing that's a "Create Archive" thing?
User avatar
Nathan Maughan
 
Posts: 3405
Joined: Sun Jun 10, 2007 11:24 pm

Post » Sun Nov 18, 2012 2:21 pm

How do you set ignore flags for unwanted changes in a mod? I'm guessing that's a "Create Archive" thing?

Nope, open up the data files menu in the CK, click "details" on your .esp, select the form you want to ignore, and press delete. Load the plugin and save it.
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Sun Nov 18, 2012 7:08 pm

Nope, open up the data files menu in the CK, click "details" on your .esp, select the form you want to ignore, and press delete. Load the plugin and save it.
I knew it was in data, but I didn't think of pressing delete.
User avatar
Sarah Knight
 
Posts: 3416
Joined: Mon Jun 19, 2006 5:02 am

Post » Sun Nov 18, 2012 6:52 pm

Quick question :smile:

I want remove the number of items from the player in twos. So instead of - Player.RemoveItem(Item, (number here)) - I want - Player.RemoveItem(Item, (only remove 2, or 4, or 6, or 8 etc)).

Is that possible?
User avatar
Nick Swan
 
Posts: 3511
Joined: Sat Dec 01, 2007 1:34 pm

Post » Mon Nov 19, 2012 12:56 am

I want remove the number of items from the player in twos. So instead of - Player.RemoveItem(Item, (number here)) - I want - Player.RemoveItem(Item, (only remove 2, or 4, or 6, or 8 etc)).

Is that possible?
Just multiply by 2?? :)

You didn't really give much of a use case, but just put aiCount * 2 there?
User avatar
Lynette Wilson
 
Posts: 3424
Joined: Fri Jul 14, 2006 4:20 pm

Post » Sun Nov 18, 2012 8:08 pm

Just multiply by 2?? :smile:

You didn't really give much of a use case, but just put aiCount * 2 there?

Ok here's my script which will probably help explain it lol.

Spoiler

[code

Scriptname BBDFlourScript extends ObjectReference

Ingredient Property Wheat Auto
Ingredient Property Flour Auto
Actor Property Player Auto

int WheatCount


Event OnActivate(ObjectReference akActionRef)


WheatCount = Player.GetItemCount(Wheat)

if WheatCount < 1
Debug.MessageBox("You need Wheat to use this Grain Mill.")

elseif WheatCount >= 1
Game.FadeOutGame(false, true, 2.0, 1.0)
Utility.Wait(2)
Player.RemoveItem(Wheat, WheatCount)
Player.AddItem(Flour, WheatCount)
Debug.MessageBox("You have ground Wheat into Flour.")
endif

EndEvent

[/code]

Basically I want to remove wheat in 2's, and add flour in 1s for every 2 wheat removed :smile:

Currently the script removes all your wheat and adds flour x however many wheat you had.

EDIT:

Changing the line
Player.AddItem(Flour, WheatCount)

to this:
Player.AddItem(Flour, WheatCount / 2)

Adds to the player the right amount of flour. So if the player had 3 wheat, they would only get 1 flour. But to only remove a number of wheats that's divisible by 2 is still my question mate :smile:
User avatar
Lily Something
 
Posts: 3327
Joined: Thu Jun 15, 2006 12:21 pm

Post » Sun Nov 18, 2012 11:50 pm

WheatCount = 2 * ((player.getItemCount(wheat) / 2) as int)

I'm sure there's a simpler way to round down to the nearest even integer, but I am literally in bed with no PC, so that's all I've got off the top of my head.
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Sun Nov 18, 2012 7:42 pm

Why not just make the mill a Crafting station? The game has an animation for the wheat mill, after all. Then you could do everything you want with Constructible Object records.

If it's a question of compatibility, you can always make your own wheat mill, as well. But I have no context to work with here, so I'm not really sure what your goals are.
User avatar
maya papps
 
Posts: 3468
Joined: Mon Aug 07, 2006 3:44 pm

Post » Sun Nov 18, 2012 11:28 pm

Thanks for the input guys. I figured it out, basic maths really lol feel a bit silly :tongue:


Player.RemoveItem(Wheat, WheatCount / 2 * 2)
Player.AddItem(Flour, WheatCount / 2)

If you have 7 Wheat, the game will think you have 6 (7 divided by 2 is 3, 3 times 2 equals 6), remove them, and add 3 Flour. Done :smile:
User avatar
Barbequtie
 
Posts: 3410
Joined: Mon Jun 19, 2006 11:34 pm

Post » Sun Nov 18, 2012 9:56 am

Thanks for the input guys. I figured it out, basic maths really lol feel a bit silly :tongue:
Haha. Well, it happens. Though if you only ever use (WheatCount / 2) you should just divide by two when you declare WheatCount. Anyway, glad you figured out what I meant, though not sure I actually helped matters. :)
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm

Post » Sun Nov 18, 2012 9:17 pm

Why are some Animations not available to add to IdleMarkers (newly created IdleMarkers)??

(and is there a way to make them available?)

This: http://www.creationkit.com/Idle_Animations looks interesting ... but where do I find that form??!




If I go to the Actor Action branch (under Character in the CK) I can open one and see a list of IDLES - But when I double click on one to edit/find it ... I get an Error saying IDLE is not a known type and so nothing opens up ...

... what am I not understanding (please don't list everything, that's a MASSIVE list, just concerning this issue will be fine ;))


Thanks if anyone can help
User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Sun Nov 18, 2012 10:15 am

Quick question:

does calling GetBaseObject() without specifying any particular reference return the object the script is attached to?

If not, how would I get the object the script is attached to without specifying it as a property?

[EDIT] Would, say, self.GetBaseObject() be appropriate?
User avatar
Justin
 
Posts: 3409
Joined: Sun Sep 23, 2007 12:32 am

Post » Sun Nov 18, 2012 10:50 am

In non-global functions that you define (which are called on objects, whereas global functions are called on types), when other non-global functions like http://www.creationkit.com/GetBaseObject_-_ObjectReference are called without explicitly specifying which object they should be called on, they are called on the object to which the script is attached.

To put it more simply, the following two lines are exactly the same:
foo = GetBaseObject()
foo = Self.GetBaseObject()

Cipscis
User avatar
Melung Chan
 
Posts: 3340
Joined: Sun Jun 24, 2007 4:15 am

Post » Sun Nov 18, 2012 9:41 am

Hm, alright, so this script, attached to a book:

event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)        Actor player = Game.GetPlayer()        if (akNewContainer == player)                player.AddPerk(TestPerk)        elseif (akOldContainer == player)                if (player.GetItemCount(GetBaseObject()) == 0)                        player.RemovePerk(TestPerk)                endif        endifendevent

should only remove the perk if the book you dropped is the last instance of that book in your inventory?

Because it does not seem to be 100% reliable.
User avatar
Shianne Donato
 
Posts: 3422
Joined: Sat Aug 11, 2007 5:55 am

Post » Sun Nov 18, 2012 11:41 am

It's possible that the problem is due to the awkward behaviour exhibited by http://www.creationkit.com/OnContainerChanged_-_ObjectReference. Take a look at its http://www.creationkit.com/Talk:OnContainerChanged_-_ObjectReference on the wiki for a bit more detail and a link to the thread in which it was first investigated.

Also, on a side note, it would be better to either use an auto-filled Actor PlayerRef auto property or to assign the value of the "player" variable in an OnInit event instead of re-assigning it every time OnContainerChanged is called. The same is true for the return value of GetBaseObject, which would best be called once and only once in an OnInit block and have its return value stored in a variable for later use.

Cipscis

EDIT:

Thought I'd mark the occasion: this is my 6,000th post.

Cipscis
User avatar
Charles Mckinna
 
Posts: 3511
Joined: Mon Nov 12, 2007 6:51 am

Post » Sun Nov 18, 2012 11:58 am

It's possible that the problem is due to the awkward behaviour exhibited by http://www.creationkit.com/OnContainerChanged_-_ObjectReference. Take a look at its http://www.creationkit.com/Talk:OnContainerChanged_-_ObjectReference on the wiki for a bit more detail and a link to the thread in which it was first investigated.

Also, on a side note, it would be better to either use an auto-filled Actor PlayerRef auto property or to assign the value of the "player" variable in an OnInit event instead of re-assigning it every time OnContainerChanged is called. The same is true for the return value of GetBaseObject, which would best be called once and only once in an OnInit block and have its return value stored in a variable for later use.

Cipscis

EDIT:

Thought I'd mark the occasion: this is my 6,000th post.

Cipscis

I'm aware of the PlayerRef property thing, but I inherited this script, it isn't my own XD Easy enough to change though, there aren't too many books I'd need to autofill the property on.

As for the GetBaseObject... would the onInit block run just once and then work for every instance of that base object (every reference of it)? Or would it run once for each reference? All the books with this script are in leveled lists and get generated as loot and vendor goods.

And I'm so glad to have contributed to your posting milestone :D
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Sun Nov 18, 2012 11:39 am

No problem, I just wanted to make sure you were aware of it :)

The http://www.creationkit.com/OnInit event is called on an object right after all of its properties have been initialised - both when the script is first attached to it (often when the object is created) or whenever it is reset, if appropriate. Assuming none of the objects are ever reset, it would run once for each of them.

Cipscis
User avatar
saxon
 
Posts: 3376
Joined: Wed Sep 19, 2007 2:45 am

Post » Sun Nov 18, 2012 2:34 pm

Thanks so much for your help! What if the books are already initialized (e.g. on a game-in-progress)?
User avatar
Rachel Cafferty
 
Posts: 3442
Joined: Thu Jun 22, 2006 1:48 am

Post » Sun Nov 18, 2012 3:11 pm

That depends on the state of the script - if the books already exist and the script is already attached to them, then the OnInit event won't be called. However, if the books already exist but this script wasn't attached to them prior to your mod being added, then the script's OnInit event will be called when the script is attached to the object.

Cipscis
User avatar
asako
 
Posts: 3296
Joined: Wed Oct 04, 2006 7:16 am

Post » Sun Nov 18, 2012 2:11 pm

Okay, thanks. Got around to reading Chesko's thread again, about odd behavior with that event with stacks of items. I'm thinking it may be better to have recipes require the player have the book, instead of having the perk that the books are scripted to add. Just a lot cleaner that way.
User avatar
Liv Brown
 
Posts: 3358
Joined: Wed Jan 31, 2007 11:44 pm

PreviousNext

Return to V - Skyrim