Making Dropped Torch Ignite Oil

Post » Thu Jun 21, 2012 2:31 am

If I drop a lit torch in oil, the oil should burn. It doesn't. I want to fix this. I would like to attach an event script to the torch that basically looks for oil, and damages it, triggering the fire:

ObjectReference closestFireTrap = Game.FindClosestReferenceOfAnyTypeInListFromRef(TossableTorchIgnitesList, dropTorch, 50.0)
if(closestFireTrap )
closestFireTrap.damageObject(5)
endif

This works fine, except that I dont want to modify Torch01. I've heard you can dynamically attach scripts like this using quests somehow?

I have an object reference to a specific torch, taken from akActor.DropObject(Torch001). How do I dynamically attach my script to that dropped item?
User avatar
naana
 
Posts: 3362
Joined: Fri Dec 08, 2006 2:00 pm

Post » Thu Jun 21, 2012 1:37 am

Make a ReferenceAlias filled with the player and another for the dropped torch. Something like...
ScriptName KaboomPlayerAliasScript extends ReferenceAliasLight Property Torch01 AutoReferenceAlias Property KaboomTorchAlias AutoEvent OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)	If akDestContainer	ElseIf akBaseItem != Torch01	ElseIf CriterionMet		KaboomTorchAlias.ForceRefIfEmpty(akItemReference)		; Kaboom		KaboomTorchAlias.Clear()	EndIfEndEvent
...should do it. You might be able to substitute the dropped torch with a single persistent ObjectReference property, then delete the dropped item without ever making it persistent.
User avatar
Laura Cartwright
 
Posts: 3483
Joined: Mon Sep 25, 2006 6:12 pm

Post » Thu Jun 21, 2012 1:36 pm

Ok... it kinda works but I'm still a little fuzy on some parts, and Im unsure how to pass some info into the RefAliases.

1) New Quest "TossableTorchIgnitionQuest"- start Game enabled.

2) Quest aliases tab: New reference alias "TossableTorchPlayerAlias".

a) Set to Unique Actor: Player.

B) Added Script:

Scriptname TossableTorchPlayerAliasScript extends ReferenceAliasLight Property Torch01 AutoReferenceAlias Property TossableTorchTorchAlias AutoEvent OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)  If(( !akDestContainer) && (akBaseItem == Torch01))    Debug.Notification("TossingTorch begin forced ref")    TossableTorchTorchAlias.ForceRefIfEmpty(akItemReference)    ;TossableTorchTorchAlias.Clear()  EndIfEndEvent


3) Quest aliases tab: New reference alias "TossableTorchTorchAlias".

a) Create Reference to Object Torch01, Level:Easy Create In:None

B) Added script:


Scriptname TossableTorchAliasScript extends ReferenceAlias{Checks for/ignites nearby oil/gas when torch is dropped.}FormList Property TossableTorchIgnitesList Autoint Property torchLife = 120 Auto;-----------------------------------------------------------------Event OnLoad ()  Debug.Trace("load torch:" + GetRef() )  registerToSeekTraps()endEventEvent OnInit ()  Debug.Trace("init torch:" + GetRef() )  registerToSeekTraps()endEventEvent OnUpdate()  Debug.Trace("update torch:" + GetRef() )  countdown()  seekTraps()endEvent;-----------------------------------------------------------------Function registerToSeekTraps()  Debug.Trace("register torch:" + GetRef() )  RegisterForUpdate(1)endFunctionFunction countdown()  Debug.Trace("torchLife:"+  GetRef() + ":" + torchLife )  torchLife += -1  if(torchLife <1)    UnRegisterForUpdate()  endifendFunctionFunction seekTraps()  ObjectReference closestFireTrap = Game.FindClosestReferenceOfAnyTypeInListFromRef(TossableTorchIgnitesList, GetRef(), 50.0)  if(closestFireTrap )    ; Base method to ignite gas/oil traps    closestFireTrap.damageObject(5)  endifendFunction

4) Opened up script properties on both and hit AutoApply all. Had to manually bind TossableTorchTorchAlias to "TossableTorchIgnitionQuest:TossableTorchTorchAlias" but everything else took.

First, I'm not 100% sure the TossableTorchAliasScript is being assigned to what the Player is dropping. So I dont think my settigns are right. It seems to find one torch somewhere in the world, because when it starts the torch init goes off - once. But when I toss out 3-5 torches... nothing happens. No log records.

Any suggestions?
User avatar
Nathan Risch
 
Posts: 3313
Joined: Sun Aug 05, 2007 10:15 pm

Post » Thu Jun 21, 2012 8:21 am

Trace:

[05/10/2012 - 01:02:00AM] VM is thawing...[05/10/2012 - 01:02:00AM] init torch:None[05/10/2012 - 01:02:00AM] register torch:None[05/10/2012 - 01:02:01AM] update torch:None[05/10/2012 - 01:02:01AM] torchLife:None:120[05/10/2012 - 01:02:01AM] error: Cannot call X() on a None object, aborting function callstack:.Game.FindClosestReferenceOfAnyTypeInListFromRef() - "Game.psc" Line 65[alias TossableTorchTorchAlias on quest TossableTorchIgnitionQuest (45003878)].TossableTorchAliasScript.seekTraps() - "TossableTorchAliasScript.psc" Line 42[alias TossableTorchTorchAlias on quest TossableTorchIgnitionQuest (45003878)].TossableTorchAliasScript.OnUpdate() - "TossableTorchAliasScript.psc" Line 22[05/10/2012 - 01:02:01AM] warning: Assigning None to a non-object variable named "::temp8"stack:.Game.FindClosestReferenceOfAnyTypeInListFromRef() - "Game.psc" Line 65[alias TossableTorchTorchAlias on quest TossableTorchIgnitionQuest (45003878)].TossableTorchAliasScript.seekTraps() - "TossableTorchAliasScript.psc" Line 42[alias TossableTorchTorchAlias on quest TossableTorchIgnitionQuest (45003878)].TossableTorchAliasScript.OnUpdate() - "TossableTorchAliasScript.psc" Line 22[05/10/2012 - 01:02:01AM] error: Cannot call Y() on a None object, aborting function callstack:.Game.FindClosestReferenceOfAnyTypeInListFromRef() - "Game.psc" Line 65[alias TossableTorchTorchAlias on quest TossableTorchIgnitionQuest (45003878)].TossableTorchAliasScript.seekTraps() - "TossableTorchAliasScript.psc" Line 42[alias TossableTorchTorchAlias on quest TossableTorchIgnitionQuest (45003878)].TossableTorchAliasScript.OnUpdate() - "TossableTorchAliasScript.psc" Line 22

This is BEFORE dropping any torches. Even after dropping the torches, the Debug.Notification("TossingTorch begin forced ref")
never fires off (even when I switch to trace()).

I'm thinking that "a) Create Reference to Object Torch01, Level:Easy Create In:None" is wrong, maybe?

I'm a coder at heart so this "user friendly" GUI crap is killing me =)
User avatar
TRIsha FEnnesse
 
Posts: 3369
Joined: Sun Feb 04, 2007 5:59 am


Return to V - Skyrim