Jump to content

Simple Quest with Script(ATTENTION! Author is novice)


Recommended Posts

 

Much better

 

 

Event OnInit()
Actor PlayerRef = GetPlayer()
While (PlayerRef.IsDead() == 0)
...
EndWhile
EndEvent

 

I'd say that running an endless loop until the player dies is pretty much the worst thing you could do in scripting ;-)

 

I would try something like that:

 

1. RegisterForRadiationDamageEvent at start

2. check radiation level when you recieve the Radiation event.

3. If player does not die in the process of your radLevel check, then registerForSingleUpdate in xx seconds

4. when you recieve the updateEvent, then check radiation again -> if player still didnt die, RegisterForRadiationDamageEvent again

 

=> this way your script should do nothing at all except waiting for the registered event(s) until you take rad damage and some seconds after you take rad damage it should go into waiting mode again till you take rad dmg again...

Edited by azraelb
Link to comment
Share on other sites

 

 

I'd say that running an endless loop until the player dies is pretty much the worst thing you could do in scripting ;-)

 

Well, as i say - I just another rookie

I didnt even know about this event :smile:

 

I will try.

Already disable raddamage, which influence maxHP, fix HUDMenu file to show RAD in right direction with .75 alpha(now can see RAD and HP bar at one time), and create esp

Script is the last.

(i wish to able construct HUDWidget, but... :smile: )

Edited by alliluyaforgood
Link to comment
Share on other sites

  • 2 weeks later...

 

1. RegisterForRadiationDamageEvent at start

2. check radiation level when you recieve the Radiation event.

3. If player does not die in the process of your radLevel check, then registerForSingleUpdate in xx seconds

4. when you recieve the updateEvent, then check radiation again -> if player still didnt die, RegisterForRadiationDamageEvent again

OK, Im back

All of these sounds nice, but I can't do that without wide knowledge of Papyrus'scripting.

It would be nice if you show me how to do it a bit more clear.

Some sort of script-like algorithm..

 

 

Scriptname AAAA extends Quest

--PROPERTIES--

--VARS--CONSTS--

Event OnXxx()
;some do
EndEvent

Event OnInit()
;somedo
RegisterForXxx()
EndEvent

etc

Can you introduce some examples of code using? How you see that?

 

Thanks in advance!

Edited by alliluyaforgood
Link to comment
Share on other sites

something like:

Actorvalue property Rads auto const
Actor property Player auto const

Event OnInit ()
     RegisterForRadiationDamage (Player)
EndEvent

Event OnRadiationDamage (ObjectReference akTarget, bool abIngested)
     if !Player.isDead ()
          float current_rads = Player.GetValue (Rads)
          if current_rads <= 1000
          ;;   do script stuff
          endif
          startTimer (1.0)
     endif     
EndEvent
Event OnTimer(int aiTimerID)
     RegisterForRadiationDamage (Player)
EndEvent
Edited by jdrfox
Link to comment
Share on other sites

 

something like:

I port my code into your example, like this

 

Scriptname RadiationPlayerDeathNew extends Quest

import utility
import debug
import game

ActorValue property Rads auto const
ActorValue property HPs auto const
Actor property PlayerRef auto const
Perk property SurvivedMutant auto

int TimerID = 10
float fRad = 0.0
int i = 1
int check = 0


Event OnInit()
    RegisterForRadiationDamage(PlayerRef)
EndEvent

Event OnRadiationDamage(ObjectReference akTarget, bool abIngested)
    if !PlayerRef.isDead()
		float fHP = (PlayerRef.GetValue(HPs) as float) / 10
        fRad = PlayerRef.GetValue(Rads)
        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)	
				PlayerRef.DamageValue(HPS, fHP)
				check = 1
			ElseIf (i == 4)&&(fRad >= 1000)&&(check == 1)	
				Notification(" I am feeling really bad, should do something. ")
				i += 1
				PlayerRef.DamageValue(HPS, fHP)
				Wait(10.0)	
			ElseIf (i == 4)&&(fRad >= 1000)&&(check == 0)
				Notification(" I am feeling really bad, should do something. ")
				i += 1
				PlayerRef.DamageValue(HPS, fHP)
				Wait(10.0)		
			ElseIf (i == 5)&&(fRad >= 1000)	
				Notification(" I am dying... ")	
				i += 1
				PlayerRef.DamageValue(HPS, fHP)
				Wait(3.0)
			ElseIf (i == 6)&&(fRad >= 1000)&&(PlayerRef.IsDead() == 0)		
				PlayerRef.DamageValue(HPS, fHP)
				Wait(0.1)
				;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
		
        startTimer (1.0)
		
    EndIf     
EndEvent

Event OnTimer(int aiTimerID)
     RegisterForRadiationDamage(PlayerRef)
EndEvent

Compiler says

 

 

Compiling "RadiationPlayerDeathNew.psc"...

E:\Games\Fallout 4 Association\Data\Scripts\Source\User\RadiationPlayerDeathNew.psc(19,4): RegisterForRadiationDamage is not a function or does not exist
E:\Games\Fallout 4 Association\Data\Scripts\Source\User\RadiationPlayerDeathNew.psc(88,5): RegisterForRadiationDamage is not a function or does not exist
No output generated for RadiationPlayerDeathNew.psc, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on RadiationPlayerDeathNew.psc
Link to comment
Share on other sites

OK
I recreate the script
Now it looks like this

Scriptname RadiationPlayerDeath extends Quest

import utility
import debug
import game

ActorValue property Rads auto const
ActorValue property HPs auto const
Actor property PlayerRef auto const
Perk property SurvivedMutant auto

int TimerID = 10
float fRad = 0.0
int i = 1
int Survive = 0


Event OnInit()
    RegisterForRadiationDamageEvent(PlayerRef)
EndEvent


function Survival()	
If (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
		Survive = 0
		Notification(" I am survived... ")
	Else
		Notification(" I was so close to death... ")
		i = 1
		Survive = 0
	EndIf
EndIf	
endfunction

function PrepareToDie()
float fHP = (PlayerRef.GetValue(HPs) as float) / 10
fRad = PlayerRef.GetValue(Rads) as float
While (PlayerRef.IsDead() == 0)&&(fRad >= 1000)
fRad = PlayerRef.GetValue(Rads) as float
	If (i == 1)
		Notification(" PIP-BOY BLINKING ")
		i += 1
		Wait(2.0)
	ElseIf (i == 2)
		Notification(" DEADLY RAD-LEVEL! ")
		i += 1
		Wait(2.0)
	ElseIf (i == 3)
		Notification(" PERFORM MEDICAL TREATMENT IMMEDIATELY! ")
		i += 1		
		Wait(5.0)	
	ElseIf (i == 4)&&(PlayerRef.HasPerk(SurvivedMutant) == 1)
		Notification(" I am resisting to crawling radiation death... ")
		Wait(10.0)	
		PlayerRef.DamageValue(HPS, fHP)
		Notification(" I am feeling really bad, should do something. ")
		i += 1
		PlayerRef.DamageValue(HPS, fHP)
		Wait(10.0)	
	ElseIf (i == 4)
		Notification(" I am feeling really bad, should do something. ")
		i += 1
		PlayerRef.DamageValue(HPS, fHP)
		Wait(10.0)		
	ElseIf (i == 5)
		Notification(" I am dying... ")	
		i += 1
		PlayerRef.DamageValue(HPS, fHP)
		Wait(3.0)
	ElseIf (i == 6)		
		PlayerRef.DamageValue(HPS, fHP)
		Wait(0.1)
		Survive = 1
		;PlayerRef.Kill()
	Else
		i = 1
		Survive = 0
	EndIf	
EndWhile
endfunction

Event OnRadiationDamage(ObjectReference akTarget, bool abIngested)
    if !PlayerRef.isDead()
        fRad = PlayerRef.GetValue(Rads)
		If fRad >= 1000
			PrepareToDie()
		EndIf		
        startTimer (1.0)
		
    EndIf     
EndEvent



Event OnTimer(int aiTimerID)
    RegisterForRadiationDamageEvent(PlayerRef)
	If Survive == 1
		Survival()
	EndIf
EndEvent

Any ideas how I can optimize the code, or even - maybe I forgot something?

Edited by alliluyaforgood
Link to comment
Share on other sites

Try to avoid using "while" like that, here's how I'd script it:

Scriptname RadiationPlayerDeath extends Quest

import utility
import debug
import game

ActorValue property Rads auto const
ActorValue property HPs auto const
Actor property PlayerRef auto const
Perk property SurvivedMutant auto

int TimerID = 10
float fRad = 0.0
int i = 1
int Survive = 0
bool warned = false

Event OnInit()
    RegisterForRadiationDamageEvent(PlayerRef)
EndEvent

Event OnRadiationDamage(ObjectReference akTarget, bool abIngested)
	if !PlayerRef.IsDead()
		fRad = PlayerRef.GetValue(Rads) as float
		if fRad >= 1000
			if (i == 2)
				i += 1
				Notification(" DEADLY RAD-LEVEL! ")
				startTimer (2.0)
			elseif (i == 3)
				i += 1
				Notification(" PERFORM MEDICAL TREATMENT IMMEDIATELY! ")
				startTimer (5.0)
			elseif (i == 4)
				if PlayerRef.HasPerk(SurvivedMutant)
					Notification(" I am resisting to crawling radiation death... ")
					if !warned
						warned = true
						startTimer (10.0)
					else
						warned = false
						float fHP = (PlayerRef.GetValue(HPs) as float) * 0.1
						PlayerRef.DamageValue(HPS, fHP)
						Notification(" I am feeling really bad, should do something. ")
						i += 1
						PlayerRef.DamageValue(HPS, fHP)
						startTimer (10.0)
					endif
				else
					Notification(" I am feeling really bad, should do something. ")
					i += 1
					float fHP = (PlayerRef.GetValue(HPs) as float) * 0.1
					PlayerRef.DamageValue(HPS, fHP)
					startTimer (10.0)
				endif
			elseif (i == 5)
				Notification(" I am dying... ")	
				i += 1
				float fHP = (PlayerRef.GetValue(HPs) as float) * 0.1
				PlayerRef.DamageValue(HPS, fHP)
				startTimer (3.0)
			elseif (i == 6)
				float fHP = (PlayerRef.GetValue(HPs) as float) * 0.1
				PlayerRef.DamageValue(HPS, fHP)
				startTimer (0.1)
				Survive = 1
			else
				i += 1
				Notification(" PIP-BOY BLINKING ")
				startTimer (2.0)
			endif
		else
			if Survive == 1
				if PlayerRef.HasPerk(SurvivedMutant)
					Notification(" I was so close to death... ")
				else
					PlayerRef.AddPerk(SurvivedMutant)
					MessageBox(" I was close to nuclear death, and now I able to survive under radiation pressure a little bit longer. ")
					Notification(" I am survived... ")
				endif
			endif
			i = 1
			Survive = 0
                        warned = false
			RegisterForRadiationDamageEvent(PlayerRef)			
		endif
	endif
EndEvent

Event OnTimer(int aiTimerID)
    RegisterForRadiationDamageEvent(PlayerRef)
EndEvent
Edited by jdrfox
Link to comment
Share on other sites

 

Try to avoid using "while" like that, here's how I'd script it:

I wish to, but what about situation, when you collect more than 1000 RAD !AND! PC is out of radiation damage zone?

For example, when PC in state after taking some Gamma gun shots. There will be no RadiationDamage event, I suppose.

Will it work?

Edited by alliluyaforgood
Link to comment
Share on other sites

  • Recently Browsing   0 members

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