Jump to content

How do I add rising water behaviour?


Lunket

Recommended Posts

Hi

 

I've tried to figure this out myself, have gone into the WestonWaterTreatment01-level and tried to copy and paste the functionality of that rising water plane into my own level, but haven't gotten it to work at all.

 

Is there some easy script to just slap onto my own water plane, in order to make it rise X units per second or such?

The script should be automatically turned on when entering the level. (I'm trying to simulate a cave being flooded)

 

Thanks

Edited by Lunket
Link to comment
Share on other sites

Yes, that would be very simple. You'll need to create an activator that will trigger the script using this function: https://www.creationkit.com/fallout4/index.php?title=OnTriggerEnter_-_ObjectReference

 

After that it's just a simple matter of using these functions:

https://www.creationkit.com/fallout4/index.php?title=GetPositionZ_-_ObjectReference

https://www.creationkit.com/fallout4/index.php?title=SetPosition_-_ObjectReference

https://www.creationkit.com/fallout4/index.php?title=StartTimer_-_ScriptObject

https://www.creationkit.com/fallout4/index.php?title=OnTimer_-_ScriptObject

 

You'll probably end up with something that looks like this:

 

 

scriptname MyScript extends objecctReference

float fMyZ
objectReference Property MyWater Auto Const; You'll need to point this at your water in the CK.

event onTriggerEnter(ObjectReference rActionRef)
	if rActionRef == game.getPlayer()
		startTimer(X); replace "X" with how frequently you want the water to rise, for a slow rise, maybe try something like 0.05?
		fMyZ = MyWater.getPositionZ()
	endif
endEvent

event onTimer(Int iTimerID)
	fMyZ += 1
	MyWater.setPosition((MyWater.getPositionX()), (MyWater.getPositionY()), fMyZ)
	startTimer(X)
	if fMyZ == Y; Replace Y with the maximum height you want the water to go to. This will allow you to cancel the timer. It's a bad idea to leave a timer to go off indefinitely.
		cancelTimer()
	endif
endEvent 

 

 

 

So you'd attach that script to an activator that the player would walk through to trigger the rising water.

Edited by Jojash
Link to comment
Share on other sites

I would use "TranslateToRef()" function. It has one iteration, so less work goes to your system and it gets the job done in one line, that saves you from writing a longer code.

 

That's actually a much better idea than what I suggested, you should do that instead.

Link to comment
Share on other sites

  • 2 weeks later...

So I've written the following code, but the water plane doesn't move still..

 

-------------------------

scriptname Watermoving2
ObjectReference Property arTarget Auto Const
Float Property afSpeed Auto Const
Function TranslateToRef(ObjectReference arTarget, float afSpeed, float afMaxRotationSpeed = 0.0)
endFunction

---------------------

 

I have set the arTarget (to a door in my scene), and the speed to 1000, as seen in the following screenshot.

 

But the water plane still doesn't move.

Does the script need to be activated somehow?

Shouldnt it be active by default?

http://oi68.tinypic.com/31666iq.jpg

Edited by Lunket
Link to comment
Share on other sites

Well if this is the actual code it is not gonna work.

 

-------------------------

scriptname Watermoving2
ObjectReference Property arTarget Auto Const
Float Property afSpeed Auto Const
Function TranslateToRef(ObjectReference arTarget, float afSpeed, float afMaxRotationSpeed = 0.0)
endFunction

---------------------

 

 

As kitcat81 said you should have something that recieves the event. Such as triggerbox for instance. And in that case you should rise the water within the event.

 

Moreover I don't understand why do you need Const properties here? People tend to clump all together making their scripts havier while loosing the main idea of it or not truly understanding how the game system works in the first place. No need for Const in your script.

 

Moving on, why your script doesn't extend any existing class (script) such as ObjectReference or Actor or whatever? There is no TranslateToRef() in Watermoving2 class, it exists in ObjectReference class (script). It is a native function there and you don't need to declare it once more, it's already in there.

 

In your current script the fuction is declared, but never called.

 

****

Here is what i would write if activation by entering the trigger is what suits you.

 

 

scriptname Watermoving2 extends ObjectReference

ObjectReference property StartPlane01 Auto    ;plane which you want to translate
ObjectReference property StartPlane02 Auto    ;plane 2 which you want to translate (if many)
ObjectReference property StartPlane03 Auto    ;plane 3 which you want to translate (if many)

ObjectReference property DestinationPlane01 Auto    ;plane to traslate to
ObjectReference property DestinationPlane02 Auto    ;plane 2 to traslate to (if many)
ObjectReference property DestinationPlane03 Auto    ;plane 3 to traslate to (if many)

Actor property PlayerREF auto
Float property TrSpeed = 60.0 auto        ;speed of traslation. Default is 60.0 a.u.
Bool property DoOnce = true

    Event OnTriggerEnter(ObjectReference akTriggerRef)
        if akTriggerRef == PlayerREF
            WaterMoveFunction(StartPlane01, DestinationPlane01, TrSpeed)
            WaterMoveFunction(StartPlane02, DestinationPlane02, TrSpeed)
            WaterMoveFunction(StartPlane03, DestinationPlane03, TrSpeed)
            ;other silly suff
            if DoOnce    ;if is flagged TRUE
                Self.Disable()
                Self.Delete()
            endif
        endif
    EndEvent
    
    Function WaterMoveFunction(ObjectReference StartREF, ObjectReference DestREF, Float fSpeed)
        StartREF.TranslateToRef(DestREF, fSpeed, 0.0)
        ;extra stuff if needed
    EndFunction

 

As an alternative you might extend quest (add script to your quest). It is very handy. Thus you can store lots of functions in there without even calling them from that script (without events). And when you need to call it after player made some progress through quest, you can call it from a stage papyrus fragment field as you would any native function such as setstage(). Just cast that quest script as your stage papyrus fragment and voila!

Link to comment
Share on other sites

Thanks for the help and suggestions.

 

I tried the code above, put the script (from above) onto a trigger volume, chose what item should be moving and where it should be moving toward, but still, nothing is moving when I walk through the trigger in my level.

 

Do I need to connect the trigger and the object that should move in some *other* way?

Like under "Linked ref" or something?

 

This is how I filled it the info in:

 

And yes I'm pretty much a complete beginner, so I've been sitting here for like 4 straight days with all kind of scripts and tutorials trying to figure out how to get a darn plane to move.

Since the water planes I was originally trying to move where "Activators", I wanted to switch to "movable static" objects and see if that helped (which is why the start and end point are now cars instead).

But seems it didn't help.

http://oi67.tinypic.com/v7f7fr.jpg

Edited by Lunket
Link to comment
Share on other sites

If you added the script on the trigger to a save that already had the trigger spawned that's likely your problem. The save would have the reference baked without the script so it would never fire. You'd need to use a save where the trigger was never spawned yet.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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