Jump to content

[scripting] 2 big "is it possible questions"


Korodic

Recommended Posts

1) Is it possible to get the item currently equipped to a certain slot. Such as what is currently equipped in the right hand by ID?

 

I need it because when you go to my jail-like scenario you should get released wearing your normal clothes you went in with (so I can store them into variables and then reference them again with an equipitem function), not jail rags (I havent been arrested and I got class so I can't confirm if that is true) either way I still need the code if it is possible.

 

2) Is it possible to intercept the variable you set wait/sleep hours to?

 

For example, when you sleep in a bed, or wait in-game, it asks you how long you want to sleep/wait for, so let's say you choose 1 hour? Does this hour-chosen variable have a name I can use/reference?

 

Even if I didn't have class in a few minutes I'd probably be searching a while just to get this info, I'm really hoping someone out here knows or can point me in the right direction. Thanks! :dance:

Link to comment
Share on other sites

after much searching all I found was this

 

http://www.creationkit.com/IsEquipped_-_Actor

 

http://www.creationkit.com/GetEquippedWeapon_-_Actor

EquipRightHand=Game.GetPlayer().GetEquippedWeapon()

EquipLeftHand=Game.GetPlayer().GetEquippedWeapon(true)

 

http://www.creationkit.com/GetEquippedSpell_-_Actor

EquipSpellLeftHand=Game.GetPlayer().GetEquippedSpell(0)

EquipSpellRightHand=Game.GetPlayer().GetEquippedSpell(1)

 

http://www.creationkit.com/GetEquippedShout_-_Actor

Game.GetPlayer().GetEquippedShout()

 

if (Bob.GetEquippedItemType(0) == 7) ; 7 is a bow

Debug.Trace("Bob has a bow in his left hand")

endIf

 

and I could probably use this for weapons... but I cannot figure out how I would possibly get the armor, I would have gotten it if I could use a wildcard, but the Creation kit wants specifics. There is just no way to figure that out. The only thing I *THINK* I could do is assign a variable for each equipped item. I think the werewolf effect unequips everything that is equipped, probably because ti takes up all the slots, but even then nothing would be stored of what was equipped, and no command lets me equip everything in the inventory, or at least if I had a wildcard it would >.> assuming I could remove everything from the inventory first. *sigh* guess I'm going to have to settle for just weapons.

Link to comment
Share on other sites

For wait/sleep, I used this for my Basic Needs mod:

 

hoursWaiting = Game.queryStat("Hours Waiting")
if (logHoursWaiting != hoursWaiting)
hoursWaiting -=logHoursWaiting
;player waited for hoursWaiting
;do stuff
...
logHoursWaiting = hoursWaiting
endIf

 

Basically you have a background tick script that checks this regularly (because there is no event that fires for wait event, only sleep) and as soon as the tracked game statistic "Hours Waiting" differs from the logged value, it calculates the delta and does whatever you need it to, then updates the logged value so that it can detect the next change.

 

Just make sure that the init function for the background tick quest includes initial recording of the game statistic, or you may end up with some weird behaviour the first time the code runs (on older games it would return that the player waited for hundreds of hours the first time it runs).

 

Anyway, the same can be done with sleep hours using tracked game statistic "Hours Slept".

Link to comment
Share on other sites

what I am using is the OnSleep event, so it gets interrupted almost immediately, so I really just need to get whatever the initial hour the player had selected which *i think* is your "hoursWaiting = Game.queryStat("Hours Waiting")" as soon as it is declared (assuming you are using the OnSleep Event). Am I right?

 

EDIT: and here I am thinking I hit a breakthrough when this compiled OK...

Game.GetPlayer().IsEquipped(Game.GetPlayer().RemoveAllItems(NTPlayerEquipsHolderREF, abRemoveQuestItems = true))

 

It just removes my ALL of my equips without putting them into the container :'(

 

I think if I can single out the equipped stuff to be put into a seperate chest then I can add them back and use the OnIttemAdded to equip the incoming items... I give up on the re-equip stuff, I dont think even bethesda reequiped anything they took off of you that is clothing or armor. When you get out of jail they throw you in jail rags...

Link to comment
Share on other sites

You can use the OnSleep() event but it works only for sleeping. It will not work for waiting. Hence I opted to use the tick script for both. Other than that, yeah, you can use that, although I think the game stat is updated only when sleep ends (which makes sense since you can interrupt sleeping), so you need to use the OnSleepStop() to catch the proper value of the game stat.
Link to comment
Share on other sites

You can use the OnSleep() event but it works only for sleeping. It will not work for waiting. Hence I opted to use the tick script for both. Other than that, yeah, you can use that, although I think the game stat is updated only when sleep ends (which makes sense since you can interrupt sleeping), so you need to use the OnSleepStop() to catch the proper value of the game stat.

So that variable gets the hours slept as you sleep... I think I understand what you're saying. I really just need to know what the intended hours to sleep is, since I will certainly be interrupting the player's normal sleep.

 

 

EDIT: I don't really need waiting, that was just for an example in my OP :) so I'm really just focused on getting that value for sleeping. I will look into it in just a lil bit. :thumbsup:

Link to comment
Share on other sites

A little off of what I said earlier, I think I might have hit a possible breakthrough with keeping track of armor after removing theme earlier...

 

the code would go something like this...

 

unequipall function...

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
 if akBaseObject as Armor
 Form myVar = akBaseObject.GetFormID()
 endIf
endEvent

 

maybe store the armor in an array then equip the array? *sigh* I dunno.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...