-
Notifications
You must be signed in to change notification settings - Fork 0
/
FPFP_PlayerPregData.psc
889 lines (644 loc) · 26.1 KB
/
FPFP_PlayerPregData.psc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
Scriptname FPFP_PlayerPregData Extends FPFP_BasePregData
Group PlayerDataTechnicalProperties
Potion Property Stimpak Auto Const Mandatory
Potion Property RadAway Auto Const Mandatory
MagicEffect Property FortifyResistRadsRadX Auto Const Mandatory
Keyword Property ObjectTypeAlcohol Auto Const Mandatory
Keyword Property CA_ObjType_ChemBad Auto Const Mandatory
GlobalVariable Property FPFP_Global_BabyHealth Auto Const Mandatory
Perk Property Cannibal01 Auto Const Mandatory
Perk Property Cannibal02 Auto Const Mandatory
Perk Property Cannibal03 Auto Const Mandatory
Perk Property Ghoulish01 Auto Const Mandatory
Perk Property Ghoulish02 Auto Const Mandatory
Perk Property Ghoulish03 Auto Const Mandatory
Perk Property RadResistant01 Auto Const Mandatory
Perk Property RadResistant02 Auto Const Mandatory
Perk Property RadResistant03 Auto Const Mandatory
Perk Property Toughness01 Auto Const Mandatory
Perk Property Toughness02 Auto Const Mandatory
Perk Property Toughness03 Auto Const Mandatory
Perk Property Toughness04 Auto Const Mandatory
Perk Property Toughness05 Auto Const Mandatory
Perk Property LeadBelly01 Auto Const Mandatory
EndGroup
Group PlayerDataVariableProperties
Float Property BabyHealth Auto
Float Property RadiationDamage Auto
Float Property LastBabyHealthUpdate Auto
Bool Property IsGivingBirth Auto
Bool Property MorningAfterPill Auto
EndGroup
;Perk[] Property WLD_Perk_Month Auto
Perk Property WLD_Perk_Impregnated_Special Auto
;Startup handling
Float Creature_Cycle
bool Creature_Cycle_Multi
Perk Creature_Perk
Faction Creature_Faction
int Breeder_mod
GlobalVariable property INVB_Global_ForceLabourQuest Auto Const Mandatory
Event OnInit() ; just tell us to initialize
Initialize(PlayerREF)
EndEvent
Function Initialize(Actor akTarget)
RegisterForCustomEvent(FPE, "DoUpdate")
RegisterForCustomEvent(FPE, "DoCleaning")
RegisterForCustomEvent(FPE, "DoReset")
RegisterForPlayerSleep()
LoadFP()
EndFunction
Function LoadFP()
;Quest Main = Game.GetFormFromFile(0x02679, "four_play.esp") as quest
Trace("LoadFP")
Quest Main = Game.GetFormFromFile(0x01000F99, "AAF.esm") as quest
If Main
;four_play_event = Main as four_play:Main
;RegisterForCustomEvent(four_play_event, "animation_over")
AAF_Events = Main as AAF:AAF_API
RegisterForCustomEvent(AAF_Events, "OnAnimationStart")
RegisterForCustomEvent(AAF_Events, "OnAnimationStop")
RegisterForCustomEvent(AAF_Events, "OnAnimationChange")
Else
utility.wait(0.1)
Endif
EndFunction
;Gameplay handling - If it isn't listed here, it is assumed to be the same as the base spell
Event OnPlayerSleepStop(bool abInterrupted, ObjectReference akBed)
If !abInterrupted
TryForFertility()
EndIf
EndEvent
Function TryForFertility()
If Utility.RandomInt(0,99) < FPFP_Global_Fertile.getValueInt() && !PlayerREF.HasMagicEffect(FPFP_ME_Fertile) && !PlayerREF.IsInFaction(FPFP_Preggo)
MakeFertile()
If FPFP_Global_FNotif.getValue() == 1
If PlayerREF.GetLeveledActorBase().GetSex() == 1 && FPFP_Global_FemaleToFemaleCum.GetValue() == 0.0
debug.notification("I'm feeling fertile today.")
ElseIf PlayerREF.GetLeveledActorBase().GetSex() == 0 && FPFP_Global_MPreg.GetValue() == 0.0
debug.notification("I'm feeling virile today.")
Else
debug.notification("I'm feeling fertile and virile today.")
EndIf
Endif
Endif
EndFunction
Bool Function IsValidWoman(Actor akActor) ; Removes player only checks, as if this function should only be called on the player
Bool akReturn = False
If akActor
If akActor.GetLeveledActorBase().GetSex() == 1.0 ; If the player is female
akReturn = True
ElseIf FPFP_Global_MPreg.GetValue() == 1.0 ; or if MPreg is allowed
akReturn = True
EndIf
EndIf
Return akReturn
EndFunction
Bool Function TrySpermFrom(Actor akMan) ; takes the impregnation result and uses that to either record a partner or set the dad
bool wasImpregnated = parent.TrySpermFrom(akMan)
If !wasImpregnated
FPE.RecordPartner(akMan)
EndIf
return wasImpregnated
EndFunction
Function Impregnate(Actor akMan) ; When called, akWoman is PlayerREF. animation_over event handler in the base script handles player pregnancy
if PlayerREF.HasPerk(WLD_Perk_Pregnancy_Freezing)
PlayerREF.RemovePerk(WLD_Perk_Pregnancy_Freezing)
Debug.Notification("FP: Freezing Perk Removed...")
endIf
bool impregnated = false
FPE.SetDaddy(akMan) ; Moved setdaddy over to impregnate, as it makes the most sense to record the dad in the incep process then the testing sperm process
if akMan.GetLeveledActorBase().GetRace() == HumanRace
Creature_Cycle = FPFP_Global_Length_Human.GetValue()
Creature_Perk = WLD_Perk_Impregnated_Special
else
bool FoundFather_Player = false
FoundFather_Player = FPFP_BabyHandler.FoundtheFather(akMan.GetLeveledActorBase().GetRace())
if FoundFather_Player
Creature_Perk = FPFP_BabyHandler.WhatsmyPerk(akMan.GetLeveledActorBase().GetRace())
Creature_Cycle = FPFP_BabyHandler.Howlongismypregnancy(akMan.GetLeveledActorBase().GetRace())
Creature_Cycle_Multi = FPFP_BabyHandler.WhatTwins(akMan.GetLeveledActorBase().GetRace())
if FPFP_Global_Creature_Faction.GetValue() == 1 || FPFP_Global_Creature_Faction.GetValue() == 3
Creature_Faction = FPFP_BabyHandler.WhatFaction(akMan.GetLeveledActorBase().GetRace())
elseif FPFP_Global_Creature_Faction.GetValue() == 2 || FPFP_Global_Creature_Faction.GetValue() == 4
Creature_Faction = FPFP_BabyHandler.WhatFaction_Friendly(akMan.GetLeveledActorBase().GetRace())
endIf
elseIf FoundFather_Player == false
Creature_Perk = WLD_Perk_Impregnated_Special
Creature_Cycle = FPFP_Global_Length_Human.GetValue()
EndIf
EndIf
if FPFP_Global_Current_Births_Player.GetValue() <= FPFP_Global_Total_Births_Player.GetValue() && FPFP_Global_BirthLimit.GetValue() == 1
impregnated = true
elseIf (FPFP_Global_Current_Births_Player.GetValue() >= FPFP_Global_Total_Births_Player.GetValue()) && FPFP_Global_BirthLimit.GetValue() == 1 && FPFP_Global_Total_Freeze.GetValue() > 1
impregnated = false
Debug.notification("Birth Limit has been reached, Will not Impregnate")
elseif FPFP_Global_BirthLimit.GetValue() == 0
impregnated = true
else
impregnated = false
endif
If PlayerREF.IsInFaction(FPFP_Preggo)
impregnated = false
endif
If impregnated && !PlayerREF.IsInFaction(FPFP_Preggo)
if FPFP_Global_Perks_Father.GetValue() == 1
PlayerREF.AddPerk(Creature_Perk)
Creature_Perk = NONE
endif
if FPFP_Global_Creature_Faction.GetValue() >= 1
if Creature_Faction != None
PlayerREF.setFactionRank(Creature_Faction, 0)
if PlayerREF.IsInFaction(Creature_Faction)
PlayerREF.AddPerk(WLD_Perk_Pheromones)
endIf
endIf
endif
parent.Impregnate(akMan) ; Do everything that is done by default
;Register for radiation damages and attack damage
RegisterPlayerPregnancyEvents()
;Now make sure everything is set to max at first
BabyHealth = 100
RadiationDamage = 0
endif
EndFunction
Function RegisterPlayerPregnancyEvents()
RegisterForRadiationDamageEvent(PlayerREF)
RegisterForHitEvent(PlayerREF)
RegisterForRemoteEvent(Ourself, "OnItemEquipped")
RegisterForRemoteEvent(Cannibal01, "OnEntryRun")
RegisterForRemoteEvent(Cannibal02, "OnEntryRun")
RegisterForRemoteEvent(Cannibal03, "OnEntryRun")
EndFunction
Function UnregisterPlayerPregnancyEvents()
UnregisterForAllRadiationDamageEvents()
UnregisterForAllHitEvents()
UnregisterForRemoteEvent(Ourself, "OnItemEquipped")
UnregisterForRemoteEvent(Cannibal01, "OnEntryRun")
UnregisterForRemoteEvent(Cannibal02, "OnEntryRun")
UnregisterForRemoteEvent(Cannibal03, "OnEntryRun")
EndFunction
Event OnTimerGameTime(int aiTID)
If !PlayerREF.HasPerk(WLD_Perk_Pregnancy_Freezing)
If !IsPregnant || IsGivingBirth
return ; Don't do any of this stuff while we are not pregnant, or in labor
EndIf
If MorningAfterPill ; the player has taken the pill during the first month
GiveBirth(False)
INVB_Global_Preggo_Count_Player_Babies.SetValue(INVB_Global_Preggo_Count_Player_Babies.getValue() - 1)
Debug.MessageBox("The contraceptive you took forced a period.")
Return
EndIf
float currentMonth
if Ourself.HasPerk(WLD_Perk_Breeder)
currentMonth = GetCurrentMonth() + Breeder_mod
else
currentMonth = GetCurrentMonth()
endif
If currentMonth < Creature_Cycle
UpdateBody(currentMonth)
if (FPFP_Global_Perks_Monthly.GetValue() == 1)
PlayerREF.RemovePerk(WLD_Perk_Month[0])
PlayerREF.RemovePerk(WLD_Perk_Month[1])
PlayerREF.RemovePerk(WLD_Perk_Month[2])
PlayerREF.RemovePerk(WLD_Perk_Month[3])
PlayerREF.RemovePerk(WLD_Perk_Month[4])
PlayerREF.RemovePerk(WLD_Perk_Month[5])
PlayerREF.RemovePerk(WLD_Perk_Month[6])
PlayerREF.RemovePerk(WLD_Perk_Month[7])
PlayerREF.RemovePerk(WLD_Perk_Month[8])
PlayerREF.RemovePerk(WLD_Perk_Month[9])
PlayerREF.AddPerk(WLD_Perk_Month[currentMonth as int])
endif
else
UpdateBody(Creature_Cycle)
if (FPFP_Global_Perks_Monthly.GetValue() == 1)
PlayerREF.RemovePerk(WLD_Perk_Month[0])
PlayerREF.RemovePerk(WLD_Perk_Month[1])
PlayerREF.RemovePerk(WLD_Perk_Month[2])
PlayerREF.RemovePerk(WLD_Perk_Month[3])
PlayerREF.RemovePerk(WLD_Perk_Month[4])
PlayerREF.RemovePerk(WLD_Perk_Month[5])
PlayerREF.RemovePerk(WLD_Perk_Month[6])
PlayerREF.RemovePerk(WLD_Perk_Month[7])
PlayerREF.RemovePerk(WLD_Perk_Month[8])
PlayerREF.RemovePerk(WLD_Perk_Month[9])
if currentMonth == Creature_Cycle
PlayerREF.AddPerk(WLD_Perk_Month[Creature_Cycle as int])
else
if Creature_Cycle > 9
PlayerREF.AddPerk(WLD_Perk_Month[9])
else
PlayerREF.AddPerk(WLD_Perk_Month[currentMonth as int])
endIf
endif
endif
EndIf
If currentMonth > 0 && currentMonth < Creature_Cycle
If FirstCheck
debug.notification("There's no mistake about it: I'm pregnant!")
StartFPEPlayerQuests()
FirstCheck = False
EndIf
if PlayerREF.HasPerk(WLD_Perk_Breeder)
if FPFP_Global_Monthly_MessageType.GetValue() == 1
debug.notification("It now looks like I am in the "+ GetMonthString(currentMonth) +" month of my pregnancy because of the Breeder Virus [The pregnancy is expected to be "+ Creature_Cycle as int +" Months Long].")
elseif FPFP_Global_Monthly_MessageType.GetValue() == 2
debug.MessageBox("It now looks like I am in the "+ GetMonthString(currentMonth) +" month of my pregnancy because of the Breeder Virus [The pregnancy is expected to be "+ Creature_Cycle as int +" Months Long].")
endIf
else
if FPFP_Global_Monthly_MessageType.GetValue() == 1
debug.notification("It's the "+ GetMonthString(currentMonth) +" month of my pregnancy [The pregnancy is expected to be "+ Creature_Cycle as int +" Months Long].")
elseif FPFP_Global_Monthly_MessageType.GetValue() == 2
debug.MessageBox("It's the "+ GetMonthString(currentMonth) +" month of my pregnancy [The pregnancy is expected to be "+ Creature_Cycle as int +" Months Long].")
endIf
endIf
If currentMonth >= (Creature_Cycle / 3)
FPE.TooLateToAbort()
EndIf
UpdateBabyHealth()
ElseIf currentMonth >= Creature_Cycle && FPFP_Global_Current_Births_Player.GetValue() < FPFP_Global_Total_Births_Player.GetValue() && FPFP_Global_BirthLimit.GetValue() == 1
FPFP_Global_Current_Births_Player.setValue(FPFP_Global_Current_Births_Player.GetValue() + 1)
Breeder_mod = 0
DoLabour()
;Sthan: I am adding these parentheses
elseIf currentMonth >= Creature_Cycle && FPFP_Global_Current_Births_Player.GetValue() >= FPFP_Global_Total_Births_Player.GetValue() && FPFP_Global_BirthLimit.GetValue() == 1 && (FPFP_Global_Total_Freeze.GetValue() == 0 || FPFP_Global_Total_Freeze.GetValue() == 2)
PlayerREF.AddPerk(WLD_Perk_Pregnancy_Freezing)
Breeder_mod = 0
Debug.notification("Birth Limit has been reached, Applying Frozen Pregnancy Perk")
elseIf currentMonth >= Creature_Cycle && FPFP_Global_Current_Births_Player.GetValue() >= FPFP_Global_Total_Births_Player.GetValue() && FPFP_Global_BirthLimit.GetValue() == 1 && FPFP_Global_Total_Freeze.GetValue() == 3
Breeder_mod = 0
FPFP_Surrogate.Surrogate(false, PlayerREF, FatherRace, NumChildren)
ElseIf currentMonth >= Creature_Cycle && FPFP_Global_BirthLimit.GetValue() == 0
Breeder_mod = 0
DoLabour()
EndIf
if !PlayerREF.HasPerk(WLD_Perk_Pregnancy_Freezing) && FPFP_Global_MultiBirth.GetValue() == 1
if Creature_Cycle_Multi == true && FPFP_Global_Current_Births_Player.GetValue() < FPFP_Global_Total_Births_Player.GetValue() && FPFP_Global_BirthLimit.GetValue() == 1
if currentMonth > (Creature_Cycle - FPFP_Global_MultiBirth_Modifier.GetValue())
FPFP_Global_Current_Births_Player.setValue(FPFP_Global_Current_Births_Player.GetValue() + 1)
GiveBirth_Multi()
endif
elseIf Creature_Cycle_Multi == true && currentMonth >= Creature_Cycle && FPFP_Global_Current_Births_Player.GetValue() >= FPFP_Global_Total_Births_Player.GetValue() && FPFP_Global_BirthLimit.GetValue() == 1 && (FPFP_Global_Total_Freeze.GetValue() == 0 || FPFP_Global_Total_Freeze.GetValue() == 2)
PlayerREF.AddPerk(WLD_Perk_Pregnancy_Freezing)
debug.Notification("Added Freezing Perk:" + "Creature Cycle: ")
elseif Creature_Cycle_Multi == true && FPFP_Global_BirthLimit.GetValue() == 0
if currentMonth > (Creature_Cycle - FPFP_Global_MultiBirth_Modifier.GetValue())
GiveBirth_Multi()
endif
endif
endif
If IsPregnant && !IsGivingBirth
if PlayerREF.HasPerk(WLD_Perk_Breeder)
Breeder_mod += 1
StartTimerGameTime(FPE.GetUpdateTime_Breeder())
else
StartTimerGameTime(FPE.GetUpdateTime())
endif
EndIf
EndIf
EndEvent
String Function GetMonthString(float theCurrentProgress)
String theReturn = Math.Ceiling(theCurrentProgress)
If theReturn == "1"
theReturn += "st"
ElseIf theReturn == "2"
theReturn += "nd"
ElseIf theReturn == "3"
theReturn += "rd"
Else
theReturn += "th"
EndIf
Return theReturn
EndFunction
Bool Function GiveBirth_Multi()
Game.FadeOutGame(true, true, 0, 1, true)
Utility.Wait(1)
Debug.notification("I am giving birth to the first of many.")
if FPFP_Global_BloodyBirth.GetValue() == 1
SP_BloodyBirth.Cast(PlayerREF, PlayerREF)
endif
if FPFP_Surrogate.CheckPerk(Ourself)
FPFP_Surrogate.Surrogate(false, PlayerREF, FatherRace, NumChildren)
else
FPFP_BabyHandler.AddBaby(PlayerREF, FatherRace, NumChildren, RadiationDamage)
Endif
Game.FadeOutGame(false, true, 0, 1)
EndFunction
Function RemovePerks(Race akDadRace)
if PlayerREF.HasPerk(WLD_Perk_Pregnancy_Freezing)
PlayerREF.RemovePerk(WLD_Perk_Pregnancy_Freezing)
endIf
if FPFP_BabyHandler.FoundtheFather(akDadRace)
Creature_Perk = FPFP_BabyHandler.WhatsmyPerk(akDadRace)
if FPFP_Global_Creature_Faction.GetValue() == 1
Creature_Faction = FPFP_BabyHandler.WhatFaction(akDadRace)
if PlayerREF.IsInFaction(Creature_Faction)
PlayerREF.removeFromFaction(Creature_Faction)
endIf
if PlayerREF.HasPerk(WLD_Perk_Pheromones)
PlayerREF.RemovePerk(WLD_Perk_Pheromones)
endif
elseif FPFP_Global_Creature_Faction.GetValue() == 2
Creature_Faction = FPFP_BabyHandler.WhatFaction_Friendly(akDadRace)
if PlayerREF.IsInFaction(Creature_Faction)
PlayerREF.removeFromFaction(Creature_Faction)
endIf
if PlayerREF.HasPerk(WLD_Perk_Pheromones)
PlayerREF.RemovePerk(WLD_Perk_Pheromones)
endif
endIf
if PlayerREF.HasPerk(Creature_Perk)
PlayerREF.RemovePerk(Creature_Perk)
endif
endif
if PlayerREF.HasPerk(WLD_Perk_Impregnated_Special)
PlayerREF.RemovePerk(WLD_Perk_Impregnated_Special)
endif
if FPFP_Global_Perks_Monthly.GetValue() == 1
PlayerREF.RemovePerk(WLD_Perk_Month[0])
PlayerREF.RemovePerk(WLD_Perk_Month[1])
PlayerREF.RemovePerk(WLD_Perk_Month[2])
PlayerREF.RemovePerk(WLD_Perk_Month[3])
PlayerREF.RemovePerk(WLD_Perk_Month[4])
PlayerREF.RemovePerk(WLD_Perk_Month[5])
PlayerREF.RemovePerk(WLD_Perk_Month[6])
PlayerREF.RemovePerk(WLD_Perk_Month[7])
PlayerREF.RemovePerk(WLD_Perk_Month[8])
PlayerREF.RemovePerk(WLD_Perk_Month[9])
endif
EndFunction
Bool Function GiveBirth(bool akBirth = True) ; returns whether or not a birth happened so that miscarriage can still happen during labor and dialogue can be written for it
UnBecomePreggo()
RemovePerks(FatherRace)
GlobalVariable Enable_Lactation = Game.GetFormFromFile(0x005A3F, "INVB_WastelandDairy.esp") as GlobalVariable
Perk Perk_Lactation = Game.GetFormFromFile(0x005A3E, "INVB_WastelandDairy.esp") as Perk
if Enable_Lactation.getValue() == 1 && akBirth && !PlayerREF.HasPerk(Perk_Lactation)
PlayerREF.AddPerk(Perk_Lactation)
endif
UnregisterPlayerPregnancyEvents()
FPE.StopBabyGeneral()
FPE.StopDNAQuest()
FPE.StopDaddyQuest()
FPE.StopAbortQuest()
If BabyHealth <= 0 || RadiationDamage >= 500
akBirth = False
EndIf
Game.FadeOutGame(true, true, 0, 1, true)
Utility.Wait(1)
if FPFP_Global_BloodyBirth.GetValue() == 1
SP_BloodyBirth.Cast(PlayerREF, PlayerREF)
endif
if FPFP_Surrogate.CheckPerk(PlayerREF)
FPFP_Surrogate.Surrogate(true, PlayerREF, FatherRace, NumChildren)
elseIf akBirth
FPFP_BabyHandler.AddBaby(PlayerREF, FatherRace, NumChildren, RadiationDamage); TODO Need to figure out algo for birthing
Endif
Game.FadeOutGame(false, true, 0, 1)
DetermineBodyAfterBirth()
ResetVarProps()
FPE.SendBirthEvent(Ourself, akBirth)
Return akBirth
EndFunction
Function ResetVarProps()
NumChildren = 0 ; All children evac'd
IncepDate = -1.0
LastBabyHealthUpdate = 0 ; make sure that we don't have an update date
IsGivingBirth = False
MorningAfterPill = False
FatherRace = NONE
EndFunction
; Player-Only Baby Health functions
Function UpdateBabyHealth()
If FPFP_Global_BabyHealth.GetValue() == 1.0 ; if the baby health option is enabled
If BabyHealth <= 0 || RadiationDamage >= 500
DoMiscarriage()
EndIf
float currentTime = Utility.GetCurrentGameTime()
If LastBabyHealthUpdate == 0.0 ; if this is our first check for baby health
LastBabyHealthUpdate = currentTime
EndIf
float healAmount = 10 * (currentTime - LastBabyHealthUpdate) / FPFP_Global_Day.GetValue(); how many months have passed since the last check multiplied by 10
ModBabyHealth(healAmount)
LastBabyHealthUpdate = Utility.GetCurrentGameTime()
EndIf
EndFunction
Event Perk.OnEntryRun(Perk akSender, int auiEntryID, ObjectReference akTarget, Actor akOwner)
Trace("Perk handler is a go")
If akOwner == PlayerREF ; if the perk is sending the event from our player...
If FPFP_Global_BabyHealth.GetValue() == 1.0 ; if baby health is on
If akSender == Cannibal01 || akSender == Cannibal02 || akSender == Cannibal03
Trace("Cannibal handler is a go")
int multiplier = 1
If akSender == Cannibal02
multiplier = 2
ElseIf akSender == Cannibal03
multiplier = 3
EndIf
Utility.Wait(0.6) ; wait as long as the cannibal perk takes
ModBabyHealth(10 * multiplier)
EndIf
EndIf
EndIf
EndEvent
Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference)
;check if baby health option is on, then do alcohol damage or chem damage as needed
If akBaseObject == FPFP_Pill && GetCurrentMonth() < 1.0
MorningAfterPill = True
return
EndIf
If FPFP_Global_BabyHealth.GetValue() == 1.0 ; if baby health option is enabled
If akBaseObject == Stimpak
ModBabyHealth(10)
ElseIf akBaseObject == RadAway
ModRadDamage(-100)
EndIf
int itemDanger = ItemLevelOfDanger(akBaseObject)
If itemDanger > 0
float theDamage = Utility.RandomFloat(1.0,3.0) * itemDanger
ModBabyHealth(-theDamage)
EndIf
EndIf
endEvent
Int Function ItemLevelOfDanger(Form akItem)
If akItem.HasKeyword(ObjectTypeAlcohol)
Return 1
ElseIf akItem.HasKeyword(CA_ObjType_ChemBad) || akItem == FPFP_Pill
Return 2
EndIf
Return 0
EndFunction
Event OnRadiationDamage(ObjectReference akPlayerRef, bool abIngested)
If FPFP_Global_BabyHealth.GetValue() == 1.0 ; if the baby health option is enabled
Debug.Trace("FPE Player Pregnancy Data has detected radiation.")
; first, do total rad damage calc
float theDamage = 1
If abIngested && !PlayerREF.HasPerk(LeadBelly01)
theDamage *= Utility.RandomFloat(1.0,5.0)
EndIf
If PlayerREF.HasMagicEffect(FortifyResistRadsRadX)
theDamage /= 2
EndIf
; then, do the ghoulish health healing bits
int playerGhoulishMult = 1
If PlayerREF.HasPerk(Ghoulish01)
If PlayerREF.HasPerk(Ghoulish02)
playerGhoulishMult += 1
If PlayerREF.HasPerk(Ghoulish03)
playerGhoulishMult += 1
EndIf
EndIf
ModBabyHealth(theDamage/3 * playerGhoulishMult)
EndIf
; then, do the actual reductions based off rad resistance perks
int playerResistMult = 1
If PlayerREF.HasPerk(RadResistant01)
If PlayerREF.HasPerk(RadResistant02)
playerResistMult += 1
If PlayerREF.HasPerk(RadResistant03)
playerResistMult += 1
EndIf
EndIf
theDamage *= (3 - playerResistMult) / 3 ; reduce the rad damage done to the baby
EndIf
; then, do the rad damage in the end
ModRadDamage(theDamage)
EndIf
If !abIngested
Utility.Wait(1)
EndIf
If IsPregnant
RegisterForRadiationDamageEvent(PlayerREF)
EndIf
EndEvent
Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \
bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial) ; This still needs work TODO
Trace("The Player was registered as being hit by the object "+akSource)
If FPFP_Global_BabyHealth.GetValue() == 1.0 && akSource && akSource as Weapon; if the baby health option is enabled and we were hit with a weapon
If !abHitBlocked
; do random amount of damage
float theDamage = Utility.RandomFloat(0.0,1.0)
int playerToughness = 1
If PlayerREF.HasPerk(Toughness01)
If PlayerREF.HasPerk(Toughness02)
playerToughness += 1
If PlayerREF.HasPerk(Toughness03)
playerToughness += 1
If PlayerREF.HasPerk(Toughness04)
playerToughness += 1
If PlayerREF.HasPerk(Toughness05)
playerToughness += 1
EndIf
EndIf
EndIf
EndIf
theDamage *= (5 - playerToughness) / 5
EndIf
ModBabyHealth(-theDamage)
EndIf
EndIf
Utility.Wait(3.0)
If IsPregnant
RegisterForHitEvent(PlayerREF)
EndIf
EndEvent
Function ModBabyHealth(Float afAmount)
float newHealth = BabyHealth + afAmount
If newHealth > 100
BabyHealth = 100
Else
BabyHealth = newHealth
EndIf
EndFunction
Function ModRadDamage(Float afAmount)
float newDamage = RadiationDamage + afAmount
If newDamage < 0
RadiationDamage = 0
Else
RadiationDamage = newDamage
EndIf
EndFunction
; Quest functions
Function StartFPEPlayerQuests()
FPE.StartBabyGeneral()
FPE.StartAbort()
FPE.TryToStartDaddy()
EndFunction
Function DoLabour()
If !IsPregnant || IsGivingBirth
Debug.Trace("FPE Player Pregnancy Info Script: Cannot trigger labor right now! We could either not be pregnant, labor is happening, or miscarriage is happening!")
return ; Don't do any of this stuff while we are not pregnant
EndIf
IsGivingBirth = True
if INVB_Global_ForceLabourQuest.GetValue() == 0
FPE.DoLabourQuest()
elseif INVB_Global_ForceLabourQuest.GetValue() == 1
GiveBirth()
else
debug.notification("Strange, I should be giving birth around now")
endif
EndFunction
Function DoMiscarriage()
If !IsPregnant
Debug.Trace("FPE Player Pregnancy Info Script: Cannot trigger miscarriage right now! We could either not be pregnant, labor is happening, or miscarriage is happening!")
return ; Don't do any of this stuff while we are not pregnant, or in labor
EndIf
If !IsGivingBirth ; if labor isn't running, kill the child and start the miscarriage quest
UnBecomePreggo()
INVB_Global_Preggo_Count_Player_Babies.SetValue(INVB_Global_Preggo_Count_Player_Babies.getValue() - 1)
UnregisterPlayerPregnancyEvents()
FPE.StopBabyGeneral()
FPE.StopDNAQuest()
FPE.StopDaddyQuest()
FPE.StopAbortQuest()
FPE.StartLOSSQuest()
Else ; otherwise kill the baby by setting its health to 0 so when the labor quest does its birth, it returns as an abort
BabyHealth = 0.0
EndIf
EndFunction
Function FullyHealBaby()
BabyHealth = 100
RadiationDamage = 0
Debug.Notification("The baby has been healed.")
EndFunction
; Technical Handling
Event FPFP_Player_Script.DoUpdate(FPFP_Player_Script akSender, Var[] akVars)
;Update code goes here...
Trace("Doing Update")
int lastVer = akVars[0] as Int
LoadFP()
if lastVer < 2100
RegisterForCustomEvent(FPE,"DoCleaning")
EndIf
EndEvent
Event FPFP_Player_Script.DoCleaning(FPFP_Player_Script akSender, Var[] akVars)
Trace("Doing clean on player data")
EndEvent
Event FPFP_Player_Script.DoReset(FPFP_Player_Script akSender, Var[] akVars)
Trace("Doing reset on player data")
Uninitialize(TRUE)
EndEvent
Function Uninitialize(Bool abFPEReset = FALSE) ; This version in the player script should only be called when FPE is reset, as we don't delete this reference
If abFPEReset
;prevent any timers and events
CancelTimerGameTime()
UnregisterForAllRadiationDamageEvents()
UnregisterForAllHitEvents()
;completely wipe everything
UnBecomePreggo()
IncepDate = -1.0
NumChildren = 0
FatherRace = NONE
LastBabyHealthUpdate = 0.0
FirstCheck = false
If AffectedByMorphs
ResetBody()
EndIf
OriginalThin = 0.0
OriginalThicc = 0.0
OriginalMuscular = 0.0
EndIf
EndFunction
Function Trace(String theText, Bool forceLog = FALSE)
Debug.TraceConditional("FPE "+self+" holding actor "+Ourself+" | "+theText, forceLog || FPFP_Global_Verbose.GetValue() )
EndFunction