Jump to content

[LE] How do I have script spawned static items delete themselve OnCellDetatch?


nhguy03276

Recommended Posts

I'm trying to fix a issue I accidentally put into my mod, where when a bunch of items spawn, the only way to remove them is to manually pick up all 60 items...

 

I was hoping it would be as simple as

 

Event OnCellDetach()

self.delete()

endEvent

 

and attach that to the item...

 

Sadly it works for removing the item, but breaks other things...

 

Any ideas on how I should be removing the items?

Link to comment
Share on other sites

Breaking what other things exactly? If the thing(s) being broken is solved, then perhaps you can stick with this method.

Well... After additional testing, it wasn't the cleanup script that's causing the problem... But I have no clue as to what is causing the issue...

 

Anyways, I found a bug with my Serana's Folly Mod. The basics (if you haven't seen it posted) is that when Serana complains about the weather, she Explodes into flames, is struck by lightning, or has a bunch of random junk dropped on her (hence the need for the cleanup). So after some trial and error, the best way for me to get Serana to react to the "Damage" without actually damaging her, was to use a lowgrade unrelenting force effect with a empty projectile. this makes it look like she's being damages, while doing very little actual damage. To get it to work, I place said shout effect on a localized activator, and the visuals on a secondary activator... Works well.... unless I return to Dimhollow Cave. Going in the Front Door and leaving by the front door again causes no issue, but going in the back door after initially leaving the cave,or going in the front door, and leaving the back door again cause what appears to be the activators not to reattach to Serana like they should, and she no longer reacts to the effects being applied. I can go anyplace else, and so far only had the issue after leaving the Back Door of Dimhollow Cave a second time, and so far the only solution I can find is to uninstall the mod, clean save, and reinstall it... Timing made me think it was the ceanup Fragment, but definitely not the case, as I had several test runs where this happened even without having the fragment.

 

 

Anyways: The Fragment to call the code is Serana.PickWho(akSpeaker, X) attached to the dialogue (X is actually the INT I assigned to the conversation)

 

 

 

 

Scriptname SeranasFolly extends Quest  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;             Properties and Variables                                                   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

GlobalVariable Property Conversation1  Auto  
GlobalVariable Property Conversation2  Auto  
GlobalVariable Property Conversation3  Auto  
GlobalVariable Property Conversation4  Auto  
GlobalVariable Property Conversation5  Auto  
GlobalVariable Property Conversation6  Auto  

SPELL Property Knockdown  Auto  
SPELL Property Knockdown2  Auto  
SPELL Property SpellRefforLightning  Auto
SPELL Property SpellRefforFire Auto


MiscObject[] Property ItemsList  Auto  

Explosion Property Fireball  Auto  


Activator Property PlacedActivator  Auto  
Activator Property PlacedActivator2  Auto  

Sound Property SoundFXforLightning  Auto  
Sound Property SoundFXforFire Auto  
   

Float PosY = 0.000000
Float PosZ = 0.000000
Float PosX = 0.000000
Float SPosY = 0.000000
Float SPosZ = 0.000000
Float SPosX = 0.000000


objectReference ActivatorRef
objectReference ActivatorRef2
int counter = 0


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;             Gets MCM Variables and Decides which punishment         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



function PickWho ( objectReference akSpeakerRef, int Conversation)

int Con1_who = Conversation1.Getvalueint()
int Con2_who = Conversation2.Getvalueint()
int Con3_who = Conversation3.Getvalueint()
int Con4_who = Conversation4.Getvalueint()
int Con5_who = Conversation5.Getvalueint()
int Con6_who = Conversation6.Getvalueint()



If (Conversation == 1)
      if (Con1_who ==0)
              FlameBurst(akSpeakerRef)
     elseif (Con1_who ==1)
              LightingStrike(akSpeakerRef)
     elseif (Con1_who ==2)
             TheAbsurd(akSpeakerRef)
     else
         return
    endif
ElseIf (Conversation == 2)
      if (Con2_who ==0)
              FlameBurst(akSpeakerRef)
     elseif (Con2_who ==1)
              LightingStrike(akSpeakerRef)
     elseif (Con2_who ==2)
             TheAbsurd(akSpeakerRef)
     else
         return
    endif
ElseIf (Conversation == 3)
      if (Con3_who ==0)
              FlameBurst(akSpeakerRef)
     elseif (Con3_who ==1)
              LightingStrike(akSpeakerRef)
     elseif (Con3_who ==2)
             TheAbsurd(akSpeakerRef)
     else
         return
    endif
ElseIf (Conversation == 4)
      if (Con4_who ==0)
              FlameBurst(akSpeakerRef)
     elseif (Con4_who ==1)
              LightingStrike(akSpeakerRef)
     elseif (Con4_who ==2)
             TheAbsurd(akSpeakerRef)
     else
         return
    endif
ElseIf (Conversation == 5)
      if (Con5_who ==0)
              FlameBurst(akSpeakerRef)
     elseif (Con5_who ==1)
              LightingStrike(akSpeakerRef)
     elseif (Con5_who ==2)
             TheAbsurd(akSpeakerRef)
     else
         return
    endif
ElseIf (Conversation == 6)
      if (Con6_who ==0)
              FlameBurst(akSpeakerRef)
     elseif (Con6_who ==1)
              LightingStrike(akSpeakerRef)
     elseif (Con6_who ==2)
             TheAbsurd(akSpeakerRef)
     else
         return
    endif

Else
   Return
Endif


endfunction


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                          Bursts into Flames                                               ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


function FlameBurst(objectReference akSpeakerRef)


Actor akSpeaker = akSpeakerRef as Actor

ActivatorRef = akSpeaker.placeAtMe(PlacedActivator as form, 1, false, false)
ActivatorRef2 = akSpeaker.placeAtMe(PlacedActivator2 as form, 1, false, false)


     PosX = ActivatorRef.GetPositionX() + 300.000
     PosY = ActivatorRef.GetPositionY() + 300.000
     PosZ = ActivatorRef.GetPositionZ() + 3000.00
     ActivatorRef.SetPosition(PosX, PosY, PosZ)

       PosX = akSpeaker.GetPositionX()
       PosY = akSpeaker.GetPositionY()
       PosZ = akSpeaker.GetPositionZ() +20.0
       ActivatorRef2.SetPosition(PosX, PosY, PosZ)


akspeaker.placeatme(fireball)

SpellRefforFire.Cast(ActivatorRef,  akSpeaker as objectReference)
SoundFXforFire.play(akSpeaker as objectReference)



Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)
utility.wait(1.0)
Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)
utility.wait(1.0)
Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)
utility.wait(1.0)
Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)
utility.wait(1.0)
Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)
utility.wait(1.0)
Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)



ActivatorRef.disable(false)
ActivatorRef.delete()
ActivatorRef2.disable(false)
ActivatorRef2.delete()
endfunction


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                 Lighting Strike!                                                              ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



function LightingStrike(objectReference akSpeakerRef)

       Actor akSpeaker = akSpeakerRef as Actor
       ActivatorRef = akSpeaker.placeAtMe(PlacedActivator as form, 1, false, false)
       ActivatorRef2 = akSpeaker.placeAtMe(PlacedActivator2 as form, 1, false, false)

       PosX = ActivatorRef.GetPositionX() + 300.000
       PosY = ActivatorRef.GetPositionY() + 300.000
       PosZ = ActivatorRef.GetPositionZ() + 3000.00
       ActivatorRef.SetPosition(PosX, PosY, PosZ)

       PosX = akSpeaker.GetPositionX()
       PosY = akSpeaker.GetPositionY()
       PosZ = akSpeaker.GetPositionZ() +20.0
       ActivatorRef2.SetPosition(PosX, PosY, PosZ)


          SpellRefforLightning.Cast(ActivatorRef,  akSpeaker as objectReference)
          SoundFXforLightning.play(akSpeaker as objectReference)
       

          Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)
          Utility.Wait(1.0)
          Knockdown2.RemoteCast(ActivatorRef2, none, akSpeaker as objectReference)
        


ActivatorRef.disable(false)
ActivatorRef.delete()
ActivatorRef2.disable(false)
ActivatorRef2.delete()

endfunction



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;             The Absurd                                                                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




function TheAbsurd(objectReference akSpeakerRef)


Actor akSpeaker = akSpeakerRef as Actor

ActivatorRef = akSpeaker.placeAtMe(PlacedActivator as form, 1, false, false)

PosX = ActivatorRef.GetPositionX() + 00.000
PosY = ActivatorRef.GetPositionY() + 00.000
PosZ = ActivatorRef.GetPositionZ() + 200.00
ActivatorRef.SetPosition(PosX, PosY, PosZ)

int itemtype = utility.randomint (0,4)

     while (counter <= 20)
          ActivatorRef.placeAtMe(ItemsList[itemtype] as form, 1, false, false).MoveTo(ActivatorRef as ObjectReference, 10 as Float, 10 as Float, 64 as Float, true)
          ActivatorRef.placeAtMe(ItemsList[itemtype] as form, 1, false, false).MoveTo(ActivatorRef as ObjectReference, 0 as Float, 0 as Float, 64 as Float, true)
          ActivatorRef.placeAtMe(ItemsList[itemtype] as form, 1, false, false).MoveTo(ActivatorRef as ObjectReference, -10 as Float, -10 as Float, 64 as Float, true)
          Knockdown.RemoteCast(ActivatorRef, none, akSpeaker as objectReference)
          SPosX = akSpeaker.GetPositionX()
          SPosY = akSpeaker.GetPositionY()
          ActivatorRef.SetPosition(SPosX, SPosY, PosZ)
          counter +=1
    endwhile
    counter = 0




ActivatorRef.disable(false)
ActivatorRef.delete()


endfunction



 

Is my Main Code.

 

Any thoughts as to why this would work everyplace except after coming out Dimhollow cave, or anything you can see in it would be appreciated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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