Jump to content

Disable Trigger Box on Destruction of an Object


Laerithryn

Recommended Posts

Ok, I've sorta got it working one way, but not really the desirable end result I'm looking for.

 

This is my current script:

Scriptname _LocNarActivatorScript extends ObjectReference  

import debug

ObjectReference Property LocNarDmgTriggerBox Auto

Int Property OldStage = 3 Auto

Int Property NewStage = 4 Auto

Sound Property OBJCWBarricadeDamage Auto
Sound Property OBJCWBarricadeDestroyed Auto

ObjectReference CollisionLink 

Event OnDestructionStageChanged(int aiOldStage, int aiCurrentStage)

     int DamageID = OBJCWBarricadeDamage.Play(self)

     if (aiOldStage == OldStage) && (aiCurrentStage == NewStage)
     int DestroyedID = OBJCWBarricadeDestroyed.Play(self)
          CollisionLink.Disable()
          LocNarDmgTriggerBox.Disable()
     endif
EndEvent

 

This successfully disables the damage trigger box when the object is destroyed*.

 

But something odd is going on that I do not understand. When editing my object's Destructible Object Data, on Damage Stage 4 when the object is dropped to 0 hit points being defeated I have a replacement model to reflect it's disabled state, so I ticked the box to "Disable" as I want the object to remain as a miscellaneous object trophy for the player to pickup. But in game it's actually being destroyed (as in disappears completely) regardless of this setting, which I believe the script is doing though I'm not sure. But the trigger is disabled this way.

 

So for a test I simply changed the tick box to "Destroyed" from previously being set to "Disable", and in game when the object is reduced to 0 hit points defeated it is instead disabled now as I want it to be showing the replacement model, but the damage trigger box is "still active" and why I don't know? Weird to me, like the check boxes are working in reverse for those two options.

 

Third test, I ticked both "Disable & Destroyed" and the results were the same as just ticking the Destroyed box.

 

Fourth test, uncheck all options and the results are the same as the last two tests.

 

Last, and least of my worries I don't know how to get the activator to be replaced by a retrievable miscellaneous object to be placed into the player's inventory? I know I could bypass the process by simply adding the miscellaneous object to the player's inventory automatically but would prefer the more immersive approach of having the player pick it up.

Link to comment
Share on other sites

Your issue is that you still haven't fully understand how to set up / to place in the world a "Destructible Object".

I suggest that you read all this and especially the "Degrading" (Changing the Model) part, and especially the penultimate paragraph.



Your script has an error, the 'Collision' is not getting disabled.

You either:

A) Set a Property on your script and then select the collision from your script's property.

ObjectReference Property Collision Auto

then inside the Event

Collision.Disable()


B) Modify in your script this line.

CollisionLink.Disable()

to

CollisionLink = GetLinkedRef()

CollisionLink.Disable()


C) Use the vanilla script and do what i've explained you in one of the previous posts.

Link to comment
Share on other sites

Ok it official, I'm an idiot. Through all my frustration and re-reading all of your replies Max, as well as your suggestions on reading up on the Destructible Object info in the CK Tutorial, I discovered I had totally misunderstood the part of manually setting the properties to the correct stages and clicking the render window object to create the link ref. So it's working now finally after a week of aggravation I could have saved myself by slowing down and reading thoroughly step-by-step on the Destructible Object info in the CK Tutorial. What's even worse, you told me the very same thing in one of your previous posts. Lesson learned, don't rely on CK's autofill button and read slowly.

 

Many thanks Max for pointing me in the right direction, I couldn't have done it without you man!

 

So now I'm on to the next issue of trying to get this the way I would prefer. Is there a way to replace the last stage model of the activator with one that is interactive for the player to pickup and place in inventory. I'm know I could bypass the process automatically by adding a replica miscellaneous object to the player's inventory through a script, but that would feel cheap and I would greatly prefer the more immersive approach of having the player pick it up like a trophy. This might be tricky as I have included the don't settle havok checkbox on the activator as well as adding the vanilla defaultDisableHavokOnLoad script to keep the object from moving around while being attacked. Like I said, it all works great now except that the object just sits there in it's disabled state non-interactive.

Link to comment
Share on other sites

Nope... you can't pick up - add to your inventory an "Activator", this can only be done through scripting and by making the whole set up 'Custom Made' from scratch.


If you want to pick up the barricade > place it in your inventory > then be able to place it again, you will need at least 3 custom made scripts and a set up in CK with Activator + Misc Item + and maybe Some xMarker Static helper for placing, always according to what you are trying to do of course.


And yes... it's a little complicated to make it, but once you have done it once then afterwards is a play on the park.


Have a happy modding.

Link to comment
Share on other sites

Ok, second issue solved!!! Appreciate the replies folks. Hey Max it was easier than I thought it would be. To replace the activator object with a miscellaneous object. Thanks in part to Dybill's comment about "disabling" the activator and some chap named Antony Bellingham and his video on Enable/Disable Multiple Objects, Trigger Boxes, Xmarkers & Script. It was the script part that caught my eye and after watching the vid got me wondering if I could use his script altering it a bit and it worked!!!

 

I thought I'd copy my scripts here for anyone else looking to do something similar.

 

This first script is on my destructible object:

 

 

 

Scriptname _LocNarActivatorScript extends ObjectReference  

import debug

ObjectReference Property MyDmgTrigger Auto

Int Property OldStage = 3 Auto
Int Property NewStage = 4 Auto

Sound Property OBJCWBarricadeDamage Auto
Sound Property OBJCWBarricadeDestroyed Auto

ObjectReference Property Collision Auto
ObjectReference CollisionLink 

Event OnDestructionStageChanged(int aiOldStage, int aiCurrentStage)

     int DamageID = OBJCWBarricadeDamage.Play(self)
     if (aiOldStage == OldStage) && (aiCurrentStage == NewStage)
          int DestroyedID = OBJCWBarricadeDestroyed.Play(self)
          CollisionLink.Disable()
          MyDmgTrigger.Disable()
     endif

EndEvent

 

 

 

This script swaps out the non-interactive mesh used in stage 4 of the Destructible Object with an interactive Miscellaneous Object representing the same thing in a disabled state for the player to pick up and add to inventory, take home as a Trophy, or if they wish simply play kickball with it:

 

 

 

Scriptname LocNarOnOff extends ObjectReference

ObjectReference Property LocNarOn Auto
ObjectReference Property LocNarOff Auto

Event OnTriggerEnter(ObjectReference akActionRef)
     if akActionRef == Game.GetPlayer()
          LocNarOff.Disable()
          LocNarOn.Enable()
     Endif
Endevent[/spoiler]

 

 

 

I'm soooo happy it finally works. Thanks Max and Dybill for your valuable support that got me thinking to push forward and work this out. You guys are awesome!!!

 

 

Link to comment
Share on other sites

I had the impression that you want to pick up the Barricade > place it in your inventory > then be able to place again the "Destructible Barricade".

This is a little more complicated to do than just add a misc item that will do nothing.


Your script still has an error, take a look at this 2 version of the same script:




ObjectReference Property MyDmgTrigger Auto

Int Property OldStage = 3 Auto
Int Property NewStage = 4 Auto

Sound Property OBJCWBarricadeDamage Auto
Sound Property OBJCWBarricadeDestroyed Auto

ObjectReference Property Collision Auto ; Collison Assigned in script's property


Event OnDestructionStageChanged(int aiOldStage, int aiCurrentStage)

int DamageID = OBJCWBarricadeDamage.Play(self)
if (aiOldStage == OldStage) && (aiCurrentStage == NewStage)
int DestroyedID = OBJCWBarricadeDestroyed.Play(self)
Collision.Disable() ; Disable Collision
MyDmgTrigger.Disable()
endif

EndEvent


OR


ObjectReference Property MyDmgTrigger Auto

Int Property OldStage = 3 Auto
Int Property NewStage = 4 Auto

Sound Property OBJCWBarricadeDamage Auto
Sound Property OBJCWBarricadeDestroyed Auto

ObjectReference CollisionLink

Event OnDestructionStageChanged(int aiOldStage, int aiCurrentStage)

int DamageID = OBJCWBarricadeDamage.Play(self)
if (aiOldStage == OldStage) && (aiCurrentStage == NewStage)
int DestroyedID = OBJCWBarricadeDestroyed.Play(self)
CollisionLink = GetLinkedRef() ; Get the "Linked Ref" of this object which is the "Collision Box"
CollisionLink.Disable() ; Now thar we have obtain the "Linked Ref" we can disable the "Collison Box"
MyDmgTrigger.Disable()
endif

EndEvent



* Read the descriptions that are after the ; so you can understand what does what, there is no need to add those descriptions to your script.


* This as it is in your script:

ObjectReference Property Collision Auto

ObjectReference CollisionLink


CollisionLink.Disable()


Is doing nothing !!, your collision is not getting disabled !!, and you have a property targeting / doing nothing !.


* There is no need to add "import debug" since the script doesn't have a single 'debug' function.

Link to comment
Share on other sites

Hey Max thanks for the feedback. Ok I need some clarity as I'm still confused about the Collision Box thing I think.

 

The Destructible Object in and of it's self is a .nif file of a sphere, which in turn has been made into an activator and to my knowledge has no collision box that I can tell, correct me if I'm wrong.

 

The only Box per se that I've made is the Trigger Box surrounding the Destructible Object which has it's own separate script for doing damage to the player upon entering. Unless this is the Collision Box you are referring to? If that is the case you bring to light a valid point, as I never went back in to clean up the script after my epiphany with having to manually set the properties to the stages sequence and clicking the render window to create the much needed link ref. After another look this is what I have. This is where I'm confusion as I don't know why I've got two instances of MyDmgTrigger but by the look of it, it answers my previous query about the Collision Box thing.

 

[Properties of my Activator Script]
Name:....................................Reference:
Collision..................................MyDmgTrigger 041D314E
MyDmgTrigger.........................MyDmgTrigger 041D314E
NewStage.................................4
OBJCWBarricadeDamage..........OBJCWBarricadeDamage
OBJCWBarricadeDestroyed.......OBJCWBarricadeDestroyed
OldStage.................................3
I went back in CK and removed the ObjectReference CollisionLink and went with ObjectReference Property Collision Auto, removed the import debug which I think was a remnant carried over from an older script test. Everything is still working fine. Thanks again Max!
Hey out of curiosity, would it be possible to add to this script in the future to disable some ambient lighting upon reaching stage 4 of the Destructible Object?
Link to comment
Share on other sites

You need to create a "NavCut Collision Box" around the barricade.

1) Select ONLY the 'Destructible Barricade'.


2) Press the 'Create Collision Cube' button in the upper side of CK.

* A 'Collision Box' will be created around the barricade.


3) Scale the 'Collision Box' in a Z axe (downwards), so that it has the same high as the upper side (from the ground up).


4) Double click the 'Collision Box' and go to the "Primitives" tab and select from the drop down menu:

- Collision Layer = L_NAVCUT


5) Use the first script's version i posted and from the script's property "Collision", click 'Select Reference From render window', and select the "NavCut Collision Box" you created.

You are done....


"NavCut Collision Box" are used to cut the NavMesh so that npcs won't bump into the 'Barricade' and instead go around it, otherwise without it, all actors will bump / get stuck in the 'Barricade', because npcs / actors don't have vision !!, they can't see !!.


After the "NavCut Collision Box" is disabled all actors can use that part of the ground again that was previously cut by the "NavCut Collision Box".


"Hey out of curiosity, would it be possible to add to this script in the future to disable some ambient lighting upon reaching stage 4 of the Destructible Object?"

Yes, you just need to select in the 'Collision Property' the light instead of a collision.

If you want to disable multiple lights, then place an xMarker, "Enable Parent" all your lights to the xMarker and in your script instead of a collision select the xMarker that is handeling the lights.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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