Jump to content

tell me why this isn't working


Recommended Posts

I created a quest, went to edit script, and input this

 

Scriptname BoringPerksScript01 extends Quest
Event Increase Level
if IfGame.GetPlayer().GetLevel() >=2
Player.addperk 0004b254
Player.addperk 00065df9
Player.addperk 0004a0b5
Player.addperk 0004b253
Player.addperk 0004a0c5
Player.addperk 0004c923
Player.addperk 0004a0da
Player.addperk 0004a09f
Player.addperk 0004a0d6
Player.addperk 0001dafe
Player.addperk 0004d88d
Player.addperk 0004a0b6
Player.addperk 000264d9
endif
EndEvent
By everything I"ve learned about this goofy-ass system, that should run all those addperk commands if the player level is above 2 when they level up. However it refuses to compile, gives me an error about "not bound to object" and... that's all I can do.
Link to comment
Share on other sites

So what is sending this custom event? An event doesn't just fire automatically, you have to send for it in a function call or something. Edit - Unless it is something like OnInit() or OnLoad() or even OnCellAttach() etc, but you must use them properly.

 

I think it best to learn yourself, so have a look at my StartupQuestScript for my mod, which starts another quest (the main one) when an input event is selected from a message box.

 

 

 

Scriptname ASC_StartupQuestScript extends Quest

Message property ASC_StartUpMenu Auto Const
Message property ASC_StartConfirmOnDefer Auto Const
Quest Property ASC_MasterQuest Auto Const
Quest Property Min01 Auto Const
Quest Property MinRecruit00 Auto Const
Quest Property ASC_StartupQuest Auto
Form Property ASC_MasterMenuItem Auto Const


Event OnInit()
	StartUpMenu()
EndEvent

Event OnStageSet(int auiStageID, int auiItemID)
	if (auiStageID == 50)
	Utility.Wait(5.0)
	Debug.Notification("Stage set to 20")
		if MinRecruit00.GetStage() < 500
			while MinRecruit00.GetStage() < 500
				Utility.Wait(30.0)
			endwhile
		endif
		if MinRecruit00.GetStage() == 500
			Confirm()
		endif
	elseif (auiStageID == 100)
		ASC_StartupQuest.Stop()
	endif
EndEvent

Function StartUpMenu()
	int iMenu = -1
	While (iMenu != 4)
		iMenu = -1
		iMenu = ASC_StartUpMenu.Show()
		If (iMenu == 0)
			Game.GetPlayer().Additem(ASC_MasterMenuItem, 1, true)
			Debug.Notification("SOTC Main Menu Item Added")
			ASC_MasterQuest.SetStage(99)
			ASC_StartupQuest.SetStage(100)
			iMenu = 4
		elseIf (iMenu == 1)
			ASC_MasterQuest.SetStage(1)
			ASC_StartupQuest.SetStage(100)
			iMenu = 4
		elseIf (iMenu == 2)
			ASC_StartupQuest.SetStage(50)
			iMenu = 4
		elseif (iMenu == 4)
		EndIf
	EndWhile
EndFunction

Function Confirm()
	int iMenu = -1
	While (iMenu != 2)
		iMenu = -1
		iMenu = ASC_StartConfirmOnDefer.Show()
		If (iMenu == 0)
			ASC_MasterQuest.SetStage(99)
			ASC_StartupQuest.SetStage(100)
			Game.GetPlayer().Additem(ASC_MasterMenuItem, 1, true)
			iMenu = 2
		elseif (iMenu == 1)
			ASC_MasterQuest.SetStage(1)
			ASC_StartupQuest.SetStage(100)
			iMenu = 2
		endif
	EndWhile
EndFunction

 

 

 

Edit - You can also use fragment code for the functions if you desire, on your stages (for me it didn't matter for this particular script, whereas my master uses lots of fragments). Take note of the Event OnInit and the function it calls, this is what applies to you.

Link to comment
Share on other sites

Well I have no idea how that script works, but clearly I'm never going to get it because I've spent the past seven hours of today trying to get it.

 

Telling me it's better that I "learn it for myself" is a big "f*#@ you" because I've spent seven hours trying to "learn it for myself" from the various tutorials, and NONE OF THEM WORK.

Link to comment
Share on other sites

So... looking at your code, here's the best I can come up with

 

Event Increase Level
LevelCheck()
End Event
Function LevelCheck()
if IfGame.GetPlayer().GetLevel() >=2
Player.addperk 0004b254
Player.addperk 00065df9
Player.addperk 0004a0b5
Player.addperk 0004b253
Player.addperk 0004a0c5
Player.addperk 0004c923
Player.addperk 0004a0da
Player.addperk 0004a09f
Player.addperk 0004a0d6
Player.addperk 0001dafe
Player.addperk 0004d88d
Player.addperk 0004a0b6
Player.addperk 000264d9
endif
EndFunction
As best I can tell, that should work. On the level up event (https://www.creationkit.com/index.php?title=Increase_Level) , it runs function LevelCheck(), and that checks if player level is greater than or equal to 2, if so then it runs all the addperk commands.
So why won't it compile?
Link to comment
Share on other sites

Well I have no idea how that script works, but clearly I'm never going to get it because I've spent the past seven hours of today trying to get it.

 

Telling me it's better that I "learn it for myself" is a big "f*** you" because I've spent seven hours trying to "learn it for myself" from the various tutorials, and NONE OF THEM WORK.

Calm down bud. 2 months ago I couldn't really code either, now I am building a mod that currently has around 18,000 lines of code.

 

What you need to do is instead of Event Increase Level is have:

 

Event Oninit()

Your perk codes here

YOURQUEST.Stop()

Endevent

 

Make sure your quest is "Run Once" in main tab, EDIT - Sorry, TICK "Start Game ENabled", not untick

Link to comment
Share on other sites

What you are doing wrong is, your "Event" does not exist. Creating a custom event like what you have there requires a bit more advanced coding, for which we won't go into right now. You need to use Events that exist for now. OnInit() for a quest is an event sent the first time the quest loads. OnLoad() is for when an object loads, but not so good for quests. OnCellAttach() is when you say, walk into an area and the object loads up. These are the kind of default events you are looking for.

Link to comment
Share on other sites

What you are doing wrong is, your "Event" does not exist. Creating a custom event like what you have there requires a bit more advanced coding, for which we won't go into right now. You need to use Events that exist for now. OnInit() for a quest is an event sent the first time the quest loads. OnLoad() is for when an object loads, but not so good for quests. OnCellAttach() is when you say, walk into an area and the object loads up. These are the kind of default events you are looking for.

But https://www.creationkit.com/index.php?title=Increase_Level says that Increase Level is an event.

 

I also tried it with OnLocationChange, did not work.

 

Scriptname BoringPerksScript extends Quest
Event OnLocationChange
LevelCheck()
End Event
Function LevelCheck()
if IfGame.GetPlayer().GetLevel() >=2
Player.addperk 0004b254
Player.addperk 00065df9
Player.addperk 0004a0b5
Player.addperk 0004b253
Player.addperk 0004a0c5
Player.addperk 0004c923
Player.addperk 0004a0da
Player.addperk 0004a09f
Player.addperk 0004a0d6
Player.addperk 0001dafe
Player.addperk 0004d88d
Player.addperk 0004a0b6
Player.addperk 000264d9
endif
EndFunction
Error is
Papyrus Compiler Version 2.8.0.4 for Fallout 4
Copyright © ZeniMax Media. All rights reserved.
Starting 1 compile threads for 1 files...
Compiling "BoringPerksScript"...
C:\Users\Robert\AppData\Local\Temp\PapyrusTemp\BoringPerksScript.psc(2,22): no viable alternative at input '\\r\\n'
C:\Users\Robert\AppData\Local\Temp\PapyrusTemp\BoringPerksScript.psc(0,0): error while attempting to read script BoringPerksScript: Object reference not set to an instance of an object.
No output generated for BoringPerksScript, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on BoringPerksScript
Link to comment
Share on other sites

Okay, at this point I'm wondering if you can even use addperk commands in a script. I created the sample script from

, which is as follows

 

Scriptname BoringPerksScript extends Quest
Function Startup()
if StartupCheck() == False
RegisterForRemoteEvent(game.GetPlayer(), "OnLocationChange")
EndIf
EndFunction
bool Function StartupCheck()
If Game.GetPlayer().GetLevel() >=3
SetStage(10)
Return True
Else
Return False
EndIf
EndFunction
Event Actor.OnLocationChange(Actor akSender, Location AkOldLoc, Location akNewLoc)
StartupCheck()
EndEvent
I understand about half of that. However if I try to put in a command like Player.addperk 0004b254 anywhere in it, it refuses to compile. So... what am I doing wrong?
Link to comment
Share on other sites

With the example you provided above, RegisterForRemoteEvent is how you would receive custom events, yes. Eventually you will get the hang of it.

 

For now however, this is what you want:

Scriptname BoringPerksScript extends Quest

Actor Property PlayerRef Auto Const  ;Make the player a property because we will reference him more than once
Quest Property BoringPerkQuest Auto Const   ;Reference to the quest itself

Event OnInit()
 LevelCheck()
EndEvent
 
Function LevelCheck()
while PlayerRef.GetLevel() <= 2 ;Start a loop to wait for when the player exceeds level 2
	Utility.Wait(3)  ;This is so the loop doesnt run at a million miles an hour
endwhile
AddPlayerPerks()
EndFunction


Function AddPlayerPerks()
	PlayerRef.addperk 0004b254 ;NOTE: If you didnt want the player to be a property, you could do Game.GetPlayer().AddPerk() however this is slower. 
	PlayerRef.addperk 00065df9
	PlayerRef.addperk 0004a0b5
	PlayerRef.addperk 0004b253
	PlayerRef.addperk 0004a0c5
	PlayerRef.addperk 0004c923
	PlayerRef.addperk 0004a0da
	PlayerRef.addperk 0004a09f
	PlayerRef.addperk 0004a0d6
	PlayerRef.addperk 0001dafe
	PlayerRef.addperk 0004d88d
	PlayerRef.addperk 0004a0b6
	PlayerRef.addperk 000264d9

	BoringPerksQuest.Stop()
EndFunction

Link to comment
Share on other sites

I think I'm understanding more of the scripting, particularly the first two lines make sense. My thinking was stuck in the 'console command' mentality. However I get a compile error when I try to add that script to the BoringPerks quest.

 

Papyrus Compiler Version 2.8.0.4 for Fallout 4
Copyright © ZeniMax Media. All rights reserved.
Starting 1 compile threads for 1 files...
Compiling "BoringPerksScript"...
C:\Users\Robert\AppData\Local\Temp\PapyrusTemp\BoringPerksScript.psc(6,12): no viable alternative at input '\\r\\n'
C:\Users\Robert\AppData\Local\Temp\PapyrusTemp\BoringPerksScript.psc(0,0): error while attempting to read script BoringPerksScript: Object reference not set to an instance of an object.
No output generated for BoringPerksScript, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on BoringPerksScript
Link to comment
Share on other sites

  • Recently Browsing   0 members

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