Extenguishing Torches in Sconces....1 minor difficulty other

Post » Wed Jun 20, 2012 3:58 pm

So I've been working on a proof of concept spell for my Vampire mod called Light Sap which allows vampires to extenguish light sources from a distance. I have a very basic proof of concept up and running now and running into one very small challenge. The way I've approached it is to disable the torch that is in the sconce and replace it with a torch that is unlit. I have that working, but the torch I replace it with get's inserted at a horizontal angle resting on the sconce, as opposed to inserted into the sconce. The interesting thing is that RemovableTorch01 is added in the same way but always inserted properly.

I'm not sure if this is related to linkedchains or not, but the RemovableTorchSconce script does disablelinkchain and enablelinkchain when the original RemovableTorch is added or disabled. How is this linked chain established? I'm having a hard time getting my head around how the link chain is established when the apparent RemovableTorch and Sconce are ... seperate instances as far as the script itself is concerned.

Thanks for any help you can provide.

-MM
User avatar
Suzy Santana
 
Posts: 3572
Joined: Fri Aug 10, 2007 12:02 am

Post » Thu Jun 21, 2012 3:40 am

I'm having trouble understanding what you're doing. Searching the CK for "Torch", only 5 items come with models (not including the handheld torch):
  • RemovableTorch01
  • RemovableTorchSconce01
  • TorchPermanantOn
  • TorchPermanant01
  • TorchPermanantOff
I don't know how #1 is used... Use info just lists it with #2 but checking the items in the same cells as #2, I can't find any of #1. If you are using the spell on #2, then you should be able to just use the Activate() function to turn them on and off.

#3 and #4 have the same model of a lighted torch in a wall sconce. #3 is a movable static (I tried hitting them in the game, but they don't actually move) while #4 is an actual static. They don't actually emit light. #5 is a static of an unlighted torch in a wall sconce. So if you were to "put out" #3 and #4, you would be disabling them and using PlaceAtMe with #5, no torches involved.

Where exactly is placing an unlit torch needed?
User avatar
P PoLlo
 
Posts: 3408
Joined: Wed Oct 31, 2007 10:05 am

Post » Thu Jun 21, 2012 2:19 am

I think it could be one of two things: either the NIF you assign to appear in the sconce (which shows up sideways) has a different default alignment than the model that is NORMALLY used in sconces or the script needs to rotate it around the X and/or Y axis. I think it may be the former... especially if you're trying to use a havok item (which may be 'aligned' to lay flat on its side) vs a true static (as vanilla wall-sconce torches ARE I think... then scripted to do whatever when activated).

The vanilla sconce system is actually more complex than one would expect.. I've been looking into it lately for one of my mods.

But I think the point of replacing a lit sconce torch with an unlit one is for immersion... rather than having a lit torch up and disappear completely, only the light would go out while the static remains. Am I right in this assumption? I'd be curious to know how you get that script to work... does it poll the area for certain objects during an onUpdate loop? ..then 'dimming' them when found, undimming them after a time expires, or radius exceeded?
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Wed Jun 20, 2012 1:19 pm

Hi guys,

Yeh the models tricked me out for a bit. So the current script is still very much proof of concept and only works against 1 sconce at a time. Eventually I'll either make this a point and shoot target script for a spell called "LightSap" or I'll make it loop through a "for loop" multiple times to try and get all the surrounding torches in a small area. There really aren't ever that many Torch Sconces around your character at a single time. Here are the two scripts. One is a modifification of a beth script, and one is the Light Sap spell itself.

Scriptname mm_BeluaLightSapScript extends activemagiceffect Import DebugFormList Property mm_BeluaTorchList AutoEvent OnEffectStart(Actor akTarget, Actor akCaster);ObjectReference Function FindRandomReferenceOfAnyTypeInListFromRef(FormList arBaseObjectsA, ObjectReference arCenter, \  float afRadius) globalObjectReference torch = Game.FindRandomReferenceOfAnyTypeInListFromRef(mm_BeluaTorchList, akCaster, 200)Trace("Torch is " + torch)if torch != None  Trace("Disabling torch")  torch.DamageObject(1000.0)  torch.DisableLinkChain()  (torch as RemovableTorchSconce01SCRIPT).ExtinguishTorch()EndIfEndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)EndEvent

Here's the spell. I'm using a formlist to search for RemovableTorchSconces.

Here's the modified Beth script:

Scriptname RemovableTorchSconce01SCRIPT extends ObjectReference Hiddenimport debugLight Property Torch01 Auto{The Torch01 we look for in the players inventory}Activator Property RemovableTorch01 Auto{Base object for torch activator that gets placed}Light Property TorchOff AutoBool Property StartsEmpty Auto{If this is TRUE the sconce will start empty.  Default = FALSE}Bool Property TorchInSconce = TRUE Auto Hidden{TRUE when there is a torch in the sonce, FALSE when there isn't.  Default = TRUE}ObjectReference Property PlacedTorch Auto Hidden{A way to refer to the torch after it's been placed at the sconce}ObjectReference Property UnlitTorch Auto HiddenSound Property ITMGenericUp AutoSound Property ITMGenericDown AutoEVENT OnCellLoad();Trace("DARYL - " + self + "Cell Loaded")UnlitTorch.Disable()UnlitTorch.Delete()if (StartsEmpty == FALSE && !IsDisabled())  ;Trace("DARYL - " + self + "Should start with a torch in it")  ; If this sconce is marked to start with a torch then place one in it  if (PlacedTorch)   ;Trace("DARYL - " + self + "A torch has been placed here before, lets simply enable it")   PlacedTorch.Enable()  else   PlacedTorch = Self.PlaceAtMe(RemovableTorch01)   ;Trace("DARYL - " + self + "A torch has never been placed here, lets place one as " + PlacedTorch)  endif  EnableLinkChain()   GoToState("HasTorch")elseif (StartsEmpty == FALSE && IsDisabled())  ;STEVE - Special Case - Add a torch when this gets enabled and activated.  ;Remove the old torch (if we had one)  PlacedTorch.Disable()  DisableLinkChain()  ;Trace("STEVE - " + self + "Sconce is starting disabled, going to Awaiting Activation.")  goToState("AwaitingActivation")else  DisableLinkChain()  ;Trace("DARYL - " + self + "Sconce is starting empty, going to NoTorch State")  GoToState("NoTorch")endifEndEVENTFunction RemoveTorch()PlacedTorch.Disable()DisableLinkChain()GoToState("NoTorch")EndFunctionFunction ExtinguishTorch()if self.GetState() == "HasTorch"  PlacedTorch.Disable()  DisableLinkChain()  Self.PlaceAtMe(TorchOff)  GoToState("TorchExtinguished")EndIfEndFunctionState TorchExtinguishedEVENT onActivate(ObjectReference TriggerRef)  GoToState("Busy")  ;;Trace("DARYL - " + self + "Player has activated this sconce in the HasTorch State")  PlacedTorch.Disable()  DisableLinkChain()  UnlitTorch = TriggerRef.AddItem(Torch01)  int TorchTaken = ITMGenericUp.Play(self)  ;;Trace("DARYL - " + self + "Disabling the torch, giving one to the player, and going into the Busy State")  GoToState("NoTorch")EndEVENTEndStateSTATE HasTorchEVENT onActivate(ObjectReference TriggerRef)  GoToState("Busy")  ;;Trace("DARYL - " + self + "Player has activated this sconce in the HasTorch State")  PlacedTorch.Disable()  DisableLinkChain()  TriggerRef.AddItem(Torch01)  int TorchTaken = ITMGenericUp.Play(self)  ;;Trace("DARYL - " + self + "Disabling the torch, giving one to the player, and going into the Busy State")  GoToState("NoTorch")EndEVENTEndStateSTATE NoTorchEVENT onActivate(ObjectReference TriggerRef)  ;;Trace("DARYL - " + self + "Player has activated the sconce in the NoTorch State")  if TriggerRef.GetItemCount(Torch01) > 0   GoToState("Busy")   ;;Trace("DARYL - " + self + "The player has " + (Game.GetPlayer()).GetItemCount(Torch01) + " torches, so lets place one")   if (PlacedTorch)    ;;Trace("DARYL - " + self + "A torch has been placed here before, lets simply enable it")    PlacedTorch.Enable()   else    PlacedTorch = Self.PlaceAtMe(RemovableTorch01)    ;;Trace("DARYL - " + self + "A torch has never been placed here, lets place one as " + PlacedTorch)   endif     TriggerRef.RemoveItem(Torch01)   EnableLinkChain()   int TorchPlaced = ITMGenericDown.Play(self)   ;;Trace("DARYL - " + self + "The player now has" + (Game.GetPlayer()).GetItemCount(Torch01) + " torches after removing one")   GoToState("HasTorch")  endif EndEVENTEndStateSTATE Busy;Do NothingEndStateSTATE AwaitingActivationEvent OnActivate(ObjectReference obj)  Self.Enable()  OnCellLoad()EndEventEndState

TorchOff currently references a modified Light object, mm_BeluaTorch01. This object is a copy of Torch01 but the NIF points to Weapons\Torch\torch.nif and it's set to "Off by default". It's the only way I could get the off torch look with no light.

Hope that clarifies things a bit. I think you're right http://www.gamesas.com/user/764276-sluckyd/. I think I likely need to figure out the correct angle and rotation of the new torch dependent on the sconce's rotation. Ugh...maths.

-MM
User avatar
Rachel Briere
 
Posts: 3438
Joined: Thu Dec 28, 2006 9:09 am

Post » Thu Jun 21, 2012 12:10 am

Ohhh I see why the torches get placed horizontally. Just take a look (preview) at the light Torch01 and the activator RemovableTorch01. The default orientation of the activator is at an angle that fits in perfectly with the sconce, while the Torch01 is on its side by default.

So if you know somebody who knows something about nifs, maybe you can ask them to make a copy of the RemovableTorch01.nif with the fire effect removed.

Otherwise, yes you're going to have to do some math to mess around with angles.
User avatar
alicia hillier
 
Posts: 3387
Joined: Tue Feb 06, 2007 2:57 am

Post » Wed Jun 20, 2012 1:45 pm

Yea... you're trying to place a havok-enabled object where a simple static should be. While you CAN do this, and I see little reason not too, I think the Vanilla way is better. If you place the havok torch in the sconce, Player may accidentally activate the sconce instead of picking up the torch... causing a slight immersion breakage. If you use the static torch as Vanilla does, Player will always activate the sconce - which is scripted to disable the static and add a new instance of the havok-torch directly to Player's Inventory.

If you DO want to use the havok-torch anyways... you don't need math. Simply select your torch, drag the right mouse button to rotate the object... hold down the keys X, Y, or Z to control which axis to rotate across. Dragging the object with the LMB while holding down Z moves it up and down. Don't forget to d-click the torch and set it to 'initially ignore havok' (or whatever it actually says there).

As for the script: I think it may be less system-intensive if you changed the spell-effect from constantly checking a list and all objects in the area (I can't imagine that being very fast). Maybe having the spell effect emit a 'silent sound' or an 'invisible light' which is sensed individually by each sconce (in the sconce script, onCellAttach event), that way your spell is a constant effect simply looping a sound (or something resource-simple like that). I'd also suggest changing the onCellLoad event to onCellAttach or strange behavior may occur after leaving an area then immediately returning (without fast-travel, etc). I'd test all this out myself, but I'm working on other things right now... sorry.

[EDIT: in the onCellAttach event you'd have a registerForSingleUpdate, then the onUpdate event would actually do the checking for the sound/light's presence.. with conditionals based on the state of the sconce (extinguished, empty, etc). You'd have another 'registerSingle' at the end of the check to keep it looping while the cell is attached. In the onCellDetach, you'd break the onUpdate loop to stop the script from being perpetual. You could also use a While/wait loop (instead of onUpdate) to achieve the same affect I think.]
User avatar
Christie Mitchell
 
Posts: 3389
Joined: Mon Nov 27, 2006 10:44 pm

Post » Wed Jun 20, 2012 2:20 pm

Oh the script is just a fire and forget. It's not constantly checking. What I figured I'd do for mutliple lights is put it into a short for loop to iterate through, say...six times and I can keep track of the sconces it's already done by putting them in an array so they get ignored with each iteration. I think a quick 5-6 loop iteration would probably get most torches in a 100 foot area since there are rarely that many torches that close together.

So I took the route of the havoc enabled torch because it was the only way I knew how to use an existing torch without having it lit. As RandomNoob suggests, I think I could copy the removable torch (the one the sconce uses by default), modify the existing .nif and remove the flames and glow, etc,. and save it as a new one for my replacement "touch out" look. Thanks for the suggestions from both of you!!! I'll report back how that works!

-MM
User avatar
josh evans
 
Posts: 3471
Joined: Mon Jun 04, 2007 1:37 am

Post » Wed Jun 20, 2012 6:38 pm

There is a possible race-condition in the vanilla script. DisableLinkChain (a latent function) is called before GoToState this could potentially cause trouble. Although, I doubt that it would in this case, nevertheless why leave a possible error when the script already defines a Busy state, perfectly suitable to prevent any race-conditions.
Spoiler
event OnCellLoad()	if (StartsEmpty == FALSE && !IsDisabled())		if (PlacedTorch)			PlacedTorch.Enable()		else			PlacedTorch = Self.PlaceAtMe(RemovableTorch01)		endif			EnableLinkChain()				GoToState("HasTorch")	elseif (StartsEmpty == FALSE && IsDisabled())		GoToState("Busy")		PlacedTorch.Disable() ;latent		DisableLinkChain() ;latent		goToState("AwaitingActivation")	else		GoToState("Busy")		DisableLinkChain() ;latent		GoToState("NoTorch")	endifendeventfunction RemoveTorch()	GoToState("Busy")	PlacedTorch.Disable()	DisableLinkChain()	GoToState("NoTorch")endfunction
Hmm, interesting that HasTorch and NoTorch account for that issue.
User avatar
Josh Dagreat
 
Posts: 3438
Joined: Fri Oct 19, 2007 3:07 am

Post » Wed Jun 20, 2012 7:41 pm

Thanks guys. So I have it working now with your suggestions! I went ahead and duplicated the RemovableTorch01 activator along with creating a copy of it's .NIF, and removing the flames and glow from it. Now I just need to clean it up for my Vampire mod....I'm also going to go ahead and make a mod today for "Water Arrows" to extenguish sconces from a distance. This should be fun!!!

You guys will, of course, get nods for the help in the credit. Actually, RandomNoob, you're name's in my credits on my Vampire mod already for your other help...it's just still in private beta testing!

Thanks so much!

-MM
User avatar
Marquis T
 
Posts: 3425
Joined: Fri Aug 31, 2007 4:39 pm

Post » Thu Jun 21, 2012 3:15 am

That's cool you got it working. If it's fire&forget, then sure - why NOT have it all from the spell? I thought you meant you wanted to add that as a feature of being a vampire, or something to that affect (which would 'follow' you around without having to re-cast). I also thought there was a static torch without flames... but I never really checked - I'm sure you would have found one. All things considered, I'd do it the way you did - hack the nilla-torch, rename it, and upload it with your mod.. or use the havok one.

I don't play with vampires.. but I will DEFINITELY be interested in your Water Arrow mod; which sounds to be essentially the same thing - only coded into an onHit event for the sconce (checking for being hit by the special arrow).
User avatar
Monika Fiolek
 
Posts: 3472
Joined: Tue Jun 20, 2006 6:57 pm

Post » Thu Jun 21, 2012 2:25 am

SLuckyD. Ok, got it all worked out and beautified. Yeah, I ended up dropping ALL of the modifications to the sconce script and doing all the work in the spell and in the torch that I replace in the sconce. And just using the states of the sconce to control the behavior and know when to replace the torches and when not to.

Now on to the water arrows!

-MM

Oh...and I'm not sure how I'll approach the arrows.... I don't think there's an onhit event exposed to the sconce since it's an Activator and they inherit directly from Form. There's methods to get object references from forms but it reguires calling placeatme to get them and effectively duplicating the previous object. It won't be pretty.

Edit: Well, maybe it will work. I just added an OnHit to the sconce script and it compiled without error. I didn't think about the fact that the script itself was extending ObjectReference. Joy!

Edit2: Ok....by default the sconces can't actually be hit....at least not by projectiles. They seem to fly right through them. But I can work around that...

Edit3: And it's DONE!!! Going to release shortly.
User avatar
neen
 
Posts: 3517
Joined: Sun Nov 26, 2006 1:19 pm

Post » Thu Jun 21, 2012 12:37 am

Here you go guys. Thanks RandomNoob and SLuckyD for your help!

http://skyrim.nexusmods.com/downloads/file.php?id=15267

-MM
User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am

Post » Wed Jun 20, 2012 11:12 pm

And the 1.1 update is up, "extinguishing" torches that are carried by nearby actors when the arrow strikes!

Thanks again guys.

-MM
User avatar
Kill Bill
 
Posts: 3355
Joined: Wed Aug 30, 2006 2:22 am


Return to V - Skyrim