Jump to content

Need Scripting help


b3w4r3

Recommended Posts

Hello all,

I'm trying to recreate one of my FO3 mods in FO4 but having a lot of trouble with the changes in the script language. This script is intended to keep track of the players ammo use and increase the value "b10mmShells" accordingly. Previously I used a GameMode block to check the players ammo count, but everything I have tried has failed. As a last resort I tried adding the "while" to force that part of the script to loop, but that doesn't work either. Any help is greatly appreciated!

Scriptname B3AmmoReload:b3ReloadAmmoQuestScript extends Quest


Int added
MiscObject Property b3AmmoBox Auto

Event OnInit()

if added != 1
Game.GetPlayer().Additem(b3AmmoBox, 1)
Debug.MessageBox("Reload Box Added!")
added = 1
Endif

EndEvent

int b10mm
int b38Cal
int b308Cal
int b45Cal
int b44Cal
int ShotShell
int b556Cal
int b5mm

int b10mmShell
int b38CalShell
int b308CalShell
int b45CalShell
int b44CalShell
int ShotShellShell
int b556CalShell
int b5mmShell

Ammo Property Ammo10mm Auto

Function BulletFunction()
While (b10mm != -1)

if (Game.GetPlayer().GetItemCount(Ammo10mm) < b10mm)
  b10mmShell = (b10mmShell + 1)
  Debug.MessageBox("10mm shell added")
  b10mm = Game.GetPlayer().GetItemCount(Ammo10mm)
Else
  b10mm = Game.GetPlayer().GetItemCount(Ammo10mm)

endIf

endWhile
EndFunction

 

 

Link to comment
Share on other sites

OnInit() does not fire for quests scripts, thats OnQuestInit()

 

Best use AddInventoryEventFilter on the player, attach a script using a quest alias https://www.creationkit.com/fallout4/index.php?title=AddInventoryEventFilter_-_ScriptObject

 

Calling Game.GetPlayer() which is super expensive in an unbounded whil loop multiple times is mental. Before the while block assign Actor PlayerRef = Game.GetPlayer() once then use PlayerRef.

 

 

Link to comment
Share on other sites

OnInit() does not fire for quests scripts, thats OnQuestInit()

 

Best use AddInventoryEventFilter on the player, attach a script using a quest alias https://www.creationkit.com/fallout4/index.php?title=AddInventoryEventFilter_-_ScriptObject

 

Calling Game.GetPlayer() which is super expensive in an unbounded whil loop multiple times is mental. Before the while block assign Actor PlayerRef = Game.GetPlayer() once then use PlayerRef.

 

 

Thanks, the OnInit part of the script was actually working, but I changed it as you suggested. I removed the Function block as it just wasn't running, I'm sure due to my improper use. Added the While block to the OnQuestInit() and it's functioning now.

Scriptname B3AmmoReload:b3ReloadAmmoQuestScript extends Quest

int b10mm
int b38Cal
int b308Cal
int b45Cal
int b44Cal
int ShotShell
int b556Cal
int b5mm

int b10mmShell
int b38CalShell
int b308CalShell
int b45CalShell
int b44CalShell
int ShotShellShell
int b556CalShell
int b5mmShell

Ammo Property Ammo10mm Auto

Int added
MiscObject Property b3AmmoBox Auto

Event OnQuestInit()

if added != 1
Game.GetPlayer().Additem(b3AmmoBox, 1)
;Debug.MessageBox("Reload Box Added!")
Actor PlayerRef = Game.GetPlayer()
While (b10mm != -1)

if (PlayerRef.GetItemCount(Ammo10mm) < b10mm)
  b10mmShell = (b10mmShell + 1)
  Debug.MessageBox("10mm shell added")
  b10mm = PlayerRef.GetItemCount(Ammo10mm)
Else
  b10mm =PlayerRef.GetItemCount(Ammo10mm)

endIf

endWhile
added = 1
Endif

EndEvent

 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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