Jump to content

[Help] Script for campfire that vanishes over time


bleakraven

Recommended Posts

Hi Nexus?

 

I'm currently stuck in my mod trying to script a firework which changes states over time from being lit to just a pile of ash. I already have the activator and different models that are supposed to change over time set up in CK, I just need a script for it...

 

 

What I precisely need is:

 

1. Whenever the campfire is activated, it switches model from whatever state it was previously to state1.

2. After 2 hours, switches model to state2. After 2 hours, to state3. After 2 hours, to state4.

3. The campfire can be activated any time during states 2-4. If campfire is activated during state1, a message appears.

 

Of course I want there to be a requirement if the player has enough firewood in their inventory, but I can add that myself.

 

Thanks for the help, I'm really stuck here!

 

_________________________________________________________________________________________________________________________________

 

PS: I tried to code something by myself and while it makes the campfire vanish over time, the function that makes that happen keeps running even if the player re-activates it, leading to double/triple states at time... So unless there is a way to interrupt that function from going on when the player activates it, it won't really work...

 

 

 


Scriptname aBleakCampfireScript extends ObjectReference  
{Script for the custom campfire}

ObjectReference Property stage1 Auto ;Fully Lit
ObjectReference Property stage2 Auto ;Going down
ObjectReference Property stage3 Auto ;Embers
ObjectReference Property stage4 Auto ;Ash

GlobalVariable property NumberOfWood Auto
MiscObject Property ItemToRemove Auto

Message property NotEnoughWoodMessage Auto


Event OnActivate(ObjectReference akActionRef)
		if (Game.GetPlayer().GetItemCount(ItemToRemove) == 2)
			Game.GetPlayer().RemoveItem(ItemToRemove, 2)
			stage2.Disable()
			stage3.Disable()
			stage4.Disable()
			stage1.Enable()
			StartFading()
			float currentStage = 1
			float timeofactivation = Utility.GetCurrentGameTime()
		Else
			NotEnoughWoodMessage.Show()
		EndIf
EndEvent

Function StartFading()
	Utility.WaitGameTime(2)
	stage2.Enable()
	stage3.Disable()
	stage4.Disable()
	stage1.Disable()
	Utility.WaitGameTime(2)
	stage2.Disable()
	stage3.Enable()
	stage4.Disable()
	stage1.Disable()
	Utility.WaitGameTime(2)
	stage2.Disable()
	stage3.Disable()
	stage4.Enable()
	stage1.Disable()
EndFunction 

 

 

 

 

Edited by bleakraven
Link to comment
Share on other sites

  • 4 weeks later...

I would go with something like this:

 

 

 

 

Scriptname aBleakCampfireScript extends ObjectReference  
{Script for the custom campfire}

ObjectReference Property stage1 Auto ;Fully Lit
ObjectReference Property stage2 Auto ;Going down
ObjectReference Property stage3 Auto ;Embers
ObjectReference Property stage4 Auto ;Ash

GlobalVariable property numberOfWood Auto
Int Property gameTimeToWait auto
MiscObject Property itemToRemove Auto

Message property NotEnoughWoodMessage Auto

Actor Property PlayerREF Auto

;Just make sure that in the very beginning the fire is off
Event OnInit()
    stage1.Disable()
    stage2.Disable()
    stage3.Disable()
    stage4.Enable()
EndEvent

Event OnActivate(ObjectReference akActionRef)
    if akActionRef == PlayerREF && PlayerREF.GetItemCount(ItemToRemove) == 2
        PlayerREF.RemoveItem(ItemToRemove, 2)
        GoToState("FullyLit")
    Else
        NotEnoughWoodMessage.Show()
    EndIf
EndEvent

State FullyLit
    Event OnBeginState()
        ;disable the FullyLit stage and enable the GoingDown stage
        stage4.Disable()
        stage1.Enable()
        ;Wait the wanted game time
        Utility.WaitGameTime(gameTimeToWait)
        ;Go to next state
        GoToState("GoingDown")
    EndEvent
EndState

State GoingDown
    Event OnBeginState()
        ;disable the ash stage and enable the fully Lit stage
        stage1.Disable()
        stage2.Enable()
        ;Wait the wanted game time
        Utility.WaitGameTime(gameTimeToWait)
        ;Go to next state
        GoToState("Embers")
    EndEvent
EndState

State Embers
    Event OnBeginState()
        ;disable the ash stage and enable the fully Lit stage
        stage2.Disable()
        stage3.Enable()
        ;Wait the wanted game time
        Utility.WaitGameTime(gameTimeToWait)
        ;Go to next state
        GoToState("Ash")
    EndEvent
EndState

State Ash
    Event OnBeginState()
        ;disable the ash stage and enable the fully Lit stage
        stage4.Disable()
        stage4.Enable()
        ;do not wait now because we can now refill fire
        ;Go back to empty state
        GoToState("")
    EndEvent
EndState

 

 

 

By using states this will make it so the player can only add wood when the fire is completely out.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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