How do I "blow out the players torch" if the player

Post » Thu Feb 17, 2011 12:47 am

AS slot 14 is not working (per the obse docs and wiki) this of course will not work:

Ref Object
Set Object to Player.GetEquippedObject 14
Player.UnequipItem Object


So how do I get this done?
How do I "blow out the players torch" if the player has a custom torch?
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Thu Feb 17, 2011 6:38 am

Could you equip your own torch, and then unequip it? Seems like that would work.
User avatar
Victoria Vasileva
 
Posts: 3340
Joined: Sat Jul 29, 2006 5:42 pm

Post » Thu Feb 17, 2011 10:31 am

Ref Object
Set Object to Player.GetEquippedObject 14
Player.UnequipItem Object

This does work, as I've used this script structure for a script that "blows out the player's torch" (and light spell/night eye spell if applicable) exactly as you described. (and I've tested it in game several times) If you like, I'll PM you that script, but as it has other sections relevant to the cave that I use it in, I'll only post part of it here:

		PlaySound RPSBlowoutNoise		if Player.GetEquippedObject 14 != 0			set Torch to Player.GetEquippedObject 14			Player.UnequipItemNS Torch		endif


Hope this helps.
User avatar
Kira! :)))
 
Posts: 3496
Joined: Fri Mar 02, 2007 1:07 pm

Post » Thu Feb 17, 2011 5:39 am

An (untested) alternative, would be to do something like this:
ForEach item <- player	if item.IsEquipped		if item.GetObjectType == 26			item.SetTimeLeft 0 			Break;		endif	endifLoop

It iterates the player's inventory until it finds an equipped light, and sets its time left to 0, thus really blowing it out instead of merely unequipping it (though the effect is more or less the same).
User avatar
RUby DIaz
 
Posts: 3383
Joined: Wed Nov 29, 2006 8:18 am

Post » Thu Feb 17, 2011 10:20 am

That looks good. It could be annoying if the player has a unique infinite torch equipped though. Doesn't setting it's time to 0 remove it from the inventory?
User avatar
flora
 
Posts: 3479
Joined: Fri Jun 23, 2006 1:48 am

Post » Thu Feb 17, 2011 12:55 am

But of course, if the player has a super special awesome torch from a mod, and you ruin it, they will not be pleased. :lmao:
User avatar
Alina loves Alexandra
 
Posts: 3456
Joined: Mon Jan 01, 2007 7:55 pm

Post » Thu Feb 17, 2011 12:30 pm

Well if you do destroy the torch with the script couldn't you also add one to their inventory in the conditional?
User avatar
Alberto Aguilera
 
Posts: 3472
Joined: Wed Aug 29, 2007 12:42 am

Post » Thu Feb 17, 2011 4:54 am

Well if you do destroy the torch with the script couldn't you also add one to their inventory in the conditional?


As long as you're absolutely sure that it's completely safe to reset all the torch's script variables to 0 and re-run the torch's onAdd block, then sure, that's a great way to do it.
User avatar
Tinkerbells
 
Posts: 3432
Joined: Sat Jun 24, 2006 10:22 pm

Post » Thu Feb 17, 2011 1:10 pm

um... guys this is a moot point as


item.GetObjectType == 26; object type light


does not work to get the torch anyway.

Now I will try:

set Torch to Player.GetEquippedObject 14

as I originally wanted to try but per the wiki I thought that filter 14 would not work. If this DOES works as Mr. Spaniard says it will I will update the wiki article myself.

@ TheNiceOne

Thanks for the little script you wrote anyway as you just enlightened me one very important command that is not well described (not in an obvious way) in the OBSE docs.

ForEach item <- player

The only thing that comes close to a description of this command (that I could find) is buried in text about the FOREACH command. This (<-) is a GREAT command and I wish it had been featured as the other commands more prominently, could have used this dozens of time in my past scripts and I will be using this a HECK of a lot from now on.

I have a sneaky feeling this <- tidbit is another of the little "programmer class" things that a programmer would already have known about and thus slips by the pros like you and the other guys that write OBSE but that the rest of us "uninitiated" would need to be told about...
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Thu Feb 17, 2011 1:41 pm

That's why I suggested you have a look at foreach loops in other programming languages when you were asking about arrays in one of the other threads. :) This is a standard syntax and once you start getting into arrays and some of the advanced structures of OBSE, knowing a programming language really helps. Basically Scruggsy and company are too busy just keeping up with requests, so the documentation is a little sparse. The syntax uses standard C++ documentation conventions though, which is what OBSE is coded in...
User avatar
Holli Dillon
 
Posts: 3397
Joined: Wed Jun 21, 2006 4:54 am

Post » Thu Feb 17, 2011 7:57 am

as I originally wanted to try but per the wiki I thought that filter 14 would not work. If this DOES works as Mr. Spaniard says it will I will update the wiki article myself.
This was asked in the OBSE thread just a week or two ago, and scruggsy said it worked fine and even tested it (he had no idea why the wiki said what it does).


Thanks for the little script you wrote anyway as you just enlightened me one very important command that is not well described (not in an obvious way) in the OBSE docs.

ForEach item <- player

The only thing that comes close to a description of this command (that I could find) is buried in text about the FOREACH command. This (<-) is a GREAT command and I wish it had been featured as the other commands more prominently, could have used this dozens of time in my past scripts and I will be using this a HECK of a lot from now on.

Just note that the "ForEach item <- player" loop does something else than the GetNumItems/GetInventoryObject loop you may have used before.

E.g. look at those to script snippets:

let i := 0 While i < player.GetNumItems	let item := player.GetInventoryObject i		; item is now a base object		let i += 1Loop


ForEach item <- player	; item is now a reference	Loop


As indicated in the comment, the first gives you a base object while the second gives you a reference. Since the second gives you a reference, it will not necessarily give you all items of a base object at the same time. E.g. assume the player has nothing but three identical swords in his inventory, but one of them has been damaged:

The first loop will iterate only once, giving you the base sword object, and "player.GetItemCount item" will return 3.

The second loop will iterate twice, once giving you the reference to the damaged weapon and once giving you the reference to the two other weapons. "item.GetRefCount" will return "1" and "2" within those two loops. I'm not sure if "player.GetItemCount item", will work at all since item is a reference, but if it works, I am pretty sure it will return 3 in both iterations of the loop.


Anyway, the difference is quite important, and I recommend that you use the right loop for the job you need. For example, in your Archery mod where you adjust base health, damage and gold for arrows and bows, you are doing so on the base objects, so the first loop is best. On the other hand, if you want to adjust the current health of specific bows in the inventory, to ensure their health percentage stays correct after the base health adjustment, you need to use the second loop to access the reference to one specific bow in order to adjust that bow's current health.
User avatar
Ymani Hood
 
Posts: 3514
Joined: Fri Oct 26, 2007 3:22 am

Post » Thu Feb 17, 2011 5:57 am

If it will make your life easier I can add SetEquippedTorchTimeLeft, which will extinguish the torch if passed a value of zero.
User avatar
lucy chadwick
 
Posts: 3412
Joined: Mon Jul 10, 2006 2:43 am

Post » Thu Feb 17, 2011 9:22 am

Oh , no

I mean wow ..thank you for that very generous offer but I do not feel it is nesccery.
You are very busy (I am chopping at the bit for obse 20 release) and I mean you can do the same thing with a small script right?
I.E check to see if the torch has a time value and then if so set to 0. Personally I prefer equipping the torch because the player cannot "light" the torch again after it is out without additional mods.

And I would REALLY rather pester you more about sound manipulation commands!

(stuff similar to model path commands) :whistling:

such as:

SetSoundVolume
Get/SetSoundFilePath
CompareSoundName (with wild cards)
GetSoundName

GetSoundModulation (like a VOX) where when the sound level in the wave file goes up and down you can get numeric anolog return with zero being silence and 10 being very loud. I know a ton of tricks doing this in real life for animated props and theater "floor" effects that would apply to modding the game as well. I also know this is a pipe dream but I thought I would ask anyway.

SetSoundVolume being the most important as it cannot be duplicated (practically) with sound object disable tricks.

BTW ...I changed the Wiki reading erroneously about filter 14 not working.



If it will make your life easier I can add SetEquippedTorchTimeLeft, which will extinguish the torch if passed a value of zero.

User avatar
Rusty Billiot
 
Posts: 3431
Joined: Sat Sep 22, 2007 10:22 pm


Return to IV - Oblivion