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

Post » Tue Dec 06, 2011 4:41 pm

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
suniti
 
Posts: 3176
Joined: Mon Sep 25, 2006 4:22 pm

Post » Tue Dec 06, 2011 5:02 pm

Could you equip your own torch, and then unequip it? Seems like that would work.
User avatar
El Goose
 
Posts: 3368
Joined: Sun Dec 02, 2007 12:02 am

Post » Tue Dec 06, 2011 6:46 pm

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
gandalf
 
Posts: 3400
Joined: Wed Feb 21, 2007 6:57 pm

Post » Wed Dec 07, 2011 7:42 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
Rhiannon Jones
 
Posts: 3423
Joined: Thu Sep 21, 2006 3:18 pm

Post » Wed Dec 07, 2011 5:13 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
Lucy
 
Posts: 3362
Joined: Sun Sep 10, 2006 4:55 am

Post » Wed Dec 07, 2011 6:20 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
Vickytoria Vasquez
 
Posts: 3456
Joined: Thu Aug 31, 2006 7:06 pm

Post » Wed Dec 07, 2011 12:39 am

Well if you do destroy the torch with the script couldn't you also add one to their inventory in the conditional?
User avatar
Kortknee Bell
 
Posts: 3345
Joined: Tue Jan 30, 2007 5:05 pm

Post » Tue Dec 06, 2011 10:10 pm

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
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm

Post » Wed Dec 07, 2011 5:07 am

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
Lloyd Muldowney
 
Posts: 3497
Joined: Wed May 23, 2007 2:08 pm

Post » Tue Dec 06, 2011 7:57 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
Kelly Upshall
 
Posts: 3475
Joined: Sat Oct 28, 2006 6:26 pm

Post » Wed Dec 07, 2011 1:19 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
Britta Gronkowski
 
Posts: 3475
Joined: Mon Apr 09, 2007 3:14 pm

Post » Wed Dec 07, 2011 12:13 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
Vera Maslar
 
Posts: 3468
Joined: Wed Sep 27, 2006 2:32 pm

Post » Wed Dec 07, 2011 8:41 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
Kirsty Collins
 
Posts: 3441
Joined: Tue Sep 19, 2006 11:54 pm


Return to IV - Oblivion