-
Posts
15 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by alliluyaforgood
-
-
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?
-
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?
-
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!
-
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 -
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!
-
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: )
-
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
-
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.
-
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.
-
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
-
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
-
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.
-
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 happenedWhat 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!
Simple Quest with Script(ATTENTION! Author is novice)
in Creation Kit and Modders
Posted
So, using of While is must-have in this situation?
After all Cycle "While" will be launched only at 1000+RAD, in other time script not even touch that piece of code.