azraelb Posted November 12, 2018 Share Posted November 12, 2018 (edited) 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 start2. 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 seconds4. 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 November 12, 2018 by azraelb Link to comment Share on other sites More sharing options...
alliluyaforgood Posted November 12, 2018 Author Share Posted November 12, 2018 (edited) 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 rookieI 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 espScript is the last.(i wish to able construct HUDWidget, but... :smile: ) Edited November 12, 2018 by alliluyaforgood Link to comment Share on other sites More sharing options...
alliluyaforgood Posted November 22, 2018 Author Share Posted November 22, 2018 (edited) 1. RegisterForRadiationDamageEvent at start2. 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 seconds4. when you recieve the updateEvent, then check radiation again -> if player still didnt die, RegisterForRadiationDamageEvent againOK, Im backAll 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 November 22, 2018 by alliluyaforgood Link to comment Share on other sites More sharing options...
jdrfox Posted November 22, 2018 Share Posted November 22, 2018 (edited) 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 November 22, 2018 by jdrfox Link to comment Share on other sites More sharing options...
alliluyaforgood Posted November 22, 2018 Author Share Posted November 22, 2018 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 existE:\Games\Fallout 4 Association\Data\Scripts\Source\User\RadiationPlayerDeathNew.psc(88,5): RegisterForRadiationDamage is not a function or does not existNo 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 More sharing options...
jdrfox Posted November 22, 2018 Share Posted November 22, 2018 (edited) oh, typo, sorry.. it's RegisterForRadiationDamageEvent (Player) Edited November 22, 2018 by jdrfox Link to comment Share on other sites More sharing options...
alliluyaforgood Posted November 22, 2018 Author Share Posted November 22, 2018 oh, typo, sorry.. it's RegisterForRadiationDamageEvent (Player)May the Force and Atom light bless you, good human!It compiled, but night is deep around me, so I will test script later. Thank you! Link to comment Share on other sites More sharing options...
alliluyaforgood Posted November 25, 2018 Author Share Posted November 25, 2018 (edited) OKI recreate the scriptNow 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 November 25, 2018 by alliluyaforgood Link to comment Share on other sites More sharing options...
jdrfox Posted November 26, 2018 Share Posted November 26, 2018 (edited) 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 November 26, 2018 by jdrfox Link to comment Share on other sites More sharing options...
alliluyaforgood Posted November 26, 2018 Author Share Posted November 26, 2018 (edited) 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 November 26, 2018 by alliluyaforgood Link to comment Share on other sites More sharing options...
Recommended Posts