Jump to content

Simple Quest with Script(ATTENTION! Author is novice)


Recommended Posts

I create little mode for FO4
The main idea was killing player after reaching rad-level and delay with message
As result


Rad is overflowing MC veins
But nothing happened

 

What I did wrong?(lemme guess - everything)
(Im reaaaaly novice and english not my native, hope you will be kind to me :laugh: )

Scriptname RadiationPlayerDeath extends Quest

ActorValue property RADS auto
int TimerID = 10

Function UpDate()                
	StartTimer(10, TimerID) 
EndFunction

Event OnTimer(int Timer2ID)
If TimerID == TimerID
	Actor PlayerRef = Game.GetPlayer()
	float fRad = PlayerRef.GetValue(RADS) as float
	if fRad >= 1000
		Debug.Notification("CRITICAL RADLEVEL! FIXIT!")
		Utility.Wait(10.0)
		if fRad >= 1000
			PlayerRef.Kill()
			CancelTimer(TimerID)
		else
			Self.UpDate()
		EndIf
	EndIf
EndIf
EndEvent

Maybe there is optimal solution than mine.

Thanks in advance!

Edited by alliluyaforgood
Link to comment
Share on other sites

You typo'd the name of the parameter in the event.

That wont work

\Source\User\RadiationPlayerDeath.psc(10,6): function variable timerid already defined in the containing script

 

I fixed equation(missed "2" in first var) in next line, but still not working on clean save.

Even message wont show. So i think script didnt work from the beginning.

Edited by alliluyaforgood
Link to comment
Share on other sites

You need to change the name of your variable - it can't match the one in the event.

Of course i did

 

 

Scriptname RadiationPlayerDeath extends Quest

ActorValue property RADS auto
int TimerID = 10

Function UpDate()                
	StartTimer(10, TimerID) 
EndFunction

Event OnTimer(int Timer2ID)
If Timer2ID == TimerID
	Actor PlayerRef = Game.GetPlayer()
	float fRad = PlayerRef.GetValue(RADS) as float
	if fRad >= 1000
		Debug.Notification("Смертельная доза радиации! Необходимо скорее понизить уровень заражения!")
		Utility.Wait(10.0)
		if fRad >= 1000
			PlayerRef.Kill()
			CancelTimer(TimerID)
		else
			Self.UpDate()
		EndIf
	EndIf
EndIf
EndEvent

Edited by alliluyaforgood
Link to comment
Share on other sites

Wrote a big reply but firefox decided to eat the whole thing..

 

Script looks syntactically ok from my end. Your issue might be with the Kill() function. You wouldn't be the first to experience that here. Maybe it doesn't work in the player anymore, I don't know.

Link to comment
Share on other sites

issue might be with the Kill() function.

Well, console analog "player.kill" is working

Maybe there is some wrongs with quest implementation

I just create empty one, choose "Start Game Enabled" and "Run once" - and attach script with RADS property

After launching quest should scan player AV for until PC death

 

Link to comment
Share on other sites

Scriptname RadiationPlayerDeath extends Quest

ActorValue property RADS auto
int TimerID = 10

Function UpDate()                
	StartTimer(3, TimerID) 
EndFunction

Event OnTimer(int Timer2ID)
If Timer2ID == TimerID
	Actor PlayerRef = Game.GetPlayer()
	float fRad = PlayerRef.GetValue(RADS) as float
	if fRad >= 1000
		Debug.Notification("Смертельная доза радиации! Необходимо скорее понизить уровень заражения!")
		Utility.Wait(10.0)
		fRad = PlayerRef.GetValue(RADS) as float
		if fRad >= 1000
			PlayerRef.Kill()
			CancelTimer(TimerID)
		else
			Self.UpDate()
		EndIf
	EndIf
EndIf
EndEvent

Just lil fix.

I forgot to second RADS check.

But still wont work.

Even message wont show.

Link to comment
Share on other sites

Scriptname RadiationPlayerDeath extends Quest

ActorValue property RADS auto
int TimerID = 10
float fRad = 0.0

Event OnTimer(int Timer2ID)
If Timer2ID == TimerID
	Actor PlayerRef = Game.GetPlayer()
	fRad = PlayerRef.GetValue(RADS) as float
	if fRad >= 1000
		CancelTimer(TimerID)
		CancelTimer(Timer2ID)
		Debug.Notification(" DEADLY RAD-LEVEL! ")
		Utility.Wait(1.0)
		Debug.Notification(" PERFORM MEDICAL TREATMENT IMMEDIATELY! ")
		Utility.Wait(10.0)
		fRad = PlayerRef.GetValue(RADS) as float
		if fRad >= 1000
			PlayerRef.Kill()
		else
			StartTimer(3, TimerID)
		EndIf
	EndIf
EndIf
EndEvent

Event OnInit()
	StartTimer(3, TimerID)
EndEvent

Now is working! Well, partly, after 3 second still didnt work. Looks like event OnTimer not working twice.

Also, any ideas to optimize the script? Cause it will follow player until death and eat some performance.

Edited by alliluyaforgood
Link to comment
Share on other sites

Much better

Scriptname RadiationPlayerDeath extends Quest

import utility
import debug
import game

ActorValue property RADS auto
Perk property SurvivedMutant auto
int TimerID = 10
float fRad = 0.0
int i = 1
int check = 0

Event OnInit()
Actor PlayerRef = GetPlayer()
While (PlayerRef.IsDead() == 0)
fRad = PlayerRef.GetValue(RADS) as float
if fRad >= 1000
	fRad = PlayerRef.GetValue(RADS) as float
	If (i == 1)&&(fRad >= 1000)
		Notification(" PIP-BOY BLINKING ")
		i += 1
		Wait(2.0)
	ElseIf (i == 2)&&(fRad >= 1000)
		Notification(" DEADLY RAD-LEVEL! ")
		i += 1
		Wait(2.0)
	ElseIf (i == 3)&&(fRad >= 1000)
		Notification(" PERFORM MEDICAL TREATMENT IMMEDIATELY! ")
		i += 1		
		Wait(5.0)	
	ElseIf (i == 4)&&(PlayerRef.HasPerk(SurvivedMutant) == 1)&&(fRad >= 1000)&&(check == 0)
		Notification(" I am resisting to crawling radiation death... ")
		Wait(10.0)	
		check = 1
	ElseIf (i == 4)&&(fRad >= 1000)&&(check == 1)	
		Notification(" I am feeling really bad, should do something. ")
		i += 1
		Wait(10.0)	
	ElseIf (i == 4)&&(fRad >= 1000)&&(check == 0)
		Notification(" I am feeling really bad, should do something. ")
		i += 1
		Wait(10.0)		
	ElseIf (i == 5)&&(fRad >= 1000)	
		Notification(" I am dying... ")	
		i += 1
		Wait(3.0)
	ElseIf (i == 6)&&(fRad >= 1000)&&(PlayerRef.IsDead() == 0)
		PlayerRef.Kill()
	EndIf		
ElseIf (i == 6)&&(fRad < 1000)&&(PlayerRef.IsDead() == 0)	
	If (PlayerRef.HasPerk(SurvivedMutant) == 0)
		PlayerRef.AddPerk(SurvivedMutant)
		MessageBox(" I was close to nuclear death, and now I able to survive under radiation pressure a little bit longer. ")
		i = 1
		check = 0
		Notification(" I am survived... ")
	Else
		Notification(" I was so close to death... ")
		i = 1
		check = 0
	EndIf
Else
	i = 1
	check = 0
EndIf
EndWhile
EndEvent

Edited by alliluyaforgood
Link to comment
Share on other sites

  • Recently Browsing   0 members

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