RowanSkie Posted September 7, 2019 Share Posted September 7, 2019 (edited) How do I do that? I'm getting too advanced on stuff anyway, but I made a Quest, Magic Effect, a Perk, and a Spell. The quest runs the script which makes the Perk activate the Spell which activates the Magic Effect, or wrong? And also, this is the script to check if the player has the item, but when it's in the game world, it doesn't work. Scriptname DarkOneScript extends Quest Actor Player Weapon Property DarkOneDagger2 Auto Perk Property DarkOneEffect Auto Event OnInit() Player = Game.GetPlayer() SetupPerks(true) EndEvent Function SetupPerks(bool abActivate) If(abActivate && GetState() != "ACTIVESTATE") && (Game.GetPlayer().GetItemCount(DarkOneDagger2) == 1) GoToState("ACTIVESTATE") Else GoToState("") EndIf EndFunction State ACTIVESTATE Event OnBeginState() Game.GetPlayer().AddPerk(DarkOneEffect) EndEvent Event OnEndState() EndEvent EndState Edited September 7, 2019 by RowanSkie Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 7, 2019 Share Posted September 7, 2019 Scrap your quest script (or at least the portions related to adding the perk). If the quest is start game enabled or will be triggered to start prior to the dagger being available, add an alias that points to the player. On the alias add a script that checks when the player obtains the dagger and then apply the perk. Otherwise, create a secondary quest that is start game enabled with a player alias and add the script there. With this method the perk will be added the first time the dagger is added to the player inventory. Here is an example that may or may not work out of the box (not tested for compilation for function) Scriptname DarkOnePlayerAliasScript Extends ReferenceAlias Weapon Property DarkOneDagger2 Auto Perk Property DarkOneEffect Auto Actor PlayerRef Event OnInit() AddInventoryEventFilter(DarkOneDager2) ; allows only the passed in item or formlist to trigger inventory functions PlayerRef = Self.GetReference() as Actor ; only do it this way for player alias scripts EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If PlayerRef ; sanity check to make sure we got a valid reference before attempting to use it If akBaseItem as weapon ; sanity check to make sure a weapon was added If akBaseItem as weapon == DarkOneDagger2 ; was the item the one we want If PlayerRef.HasPerk(DarkOneEffect) ; sanity check to see if player already has the perk ;do nothing Else PlayerRef.AddPerk(DarkOneEffect) ; add the perk EndIf EndIf EndIf EndIf EndEvent You could skip the perk and run the spell directly. But the perk may be easier to track. Why do I suggest this? In your quest script, you are using OnInit to trigger everything. This block only runs once when the quest is first started. Unless the quest is on some kind of loop to start and stop every so often, the perk will most likely fail to be added if the dagger is not in the player inventory at that exact moment. Link to comment Share on other sites More sharing options...
RowanSkie Posted September 7, 2019 Author Share Posted September 7, 2019 (edited) Scrap your quest script (or at least the portions related to adding the perk). If the quest is start game enabled or will be triggered to start prior to the dagger being available, add an alias that points to the player. On the alias add a script that checks when the player obtains the dagger and then apply the perk. Otherwise, create a secondary quest that is start game enabled with a player alias and add the script there. With this method the perk will be added the first time the dagger is added to the player inventory. Here is an example that may or may not work out of the box (not tested for compilation for function) Scriptname DarkOnePlayerAliasScript Extends ReferenceAlias Weapon Property DarkOneDagger2 Auto Perk Property DarkOneEffect Auto Actor PlayerRef Event OnInit() AddInventoryEventFilter(DarkOneDager2) ; allows only the passed in item or formlist to trigger inventory functions PlayerRef = Self.GetReference() as Actor ; only do it this way for player alias scripts EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If PlayerRef ; sanity check to make sure we got a valid reference before attempting to use it If akBaseItem as weapon ; sanity check to make sure a weapon was added If akBaseItem as weapon == DarkOneDagger2 ; was the item the one we want If PlayerRef.HasPerk(DarkOneEffect) ; sanity check to see if player already has the perk ;do nothing Else PlayerRef.AddPerk(DarkOneEffect) ; add the perk EndIf EndIf EndIf EndIf EndEvent You could skip the perk and run the spell directly. But the perk may be easier to track. Why do I suggest this? In your quest script, you are using OnInit to trigger everything. This block only runs once when the quest is first started. Unless the quest is on some kind of loop to start and stop every so often, the perk will most likely fail to be added if the dagger is not in the player inventory at that exact moment.So where do this go then? In the item itself? Edited September 7, 2019 by RowanSkie Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 7, 2019 Share Posted September 7, 2019 No. On an quest alias that targets the player. Thought I explained as much... Link to comment Share on other sites More sharing options...
RowanSkie Posted September 8, 2019 Author Share Posted September 8, 2019 (edited) No. On an quest alias that targets the player. Thought I explained as much...Sorry, I'm still new to making quest-related mods, all my experience are from the xEdits and minor location changes from Creation Kit, plus an attempt to fix an old broken script from a Fallout 4 mod. I used this script directly to the item: Scriptname DarkOneScript extends Quest Actor Player Weapon Property DarkOneDagger2 Auto Perk Property DarkOneEffect Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akNewContainer == Game.GetPlayer() SetupPerks(true) endIf endEvent Function SetupPerks(bool abActivate) If(abActivate && GetState() != "ACTIVESTATE") GoToState("ACTIVESTATE") Else GoToState("") EndIf EndFunction State ACTIVESTATE Event OnBeginState() Game.GetPlayer().AddPerk(DarkOneEffect) EndEvent EndState Edited September 8, 2019 by RowanSkie Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 8, 2019 Share Posted September 8, 2019 I think that would work except if it is on the weapon itself the script should extend Weapon instead of quest. I am confused on what would happen if the player places the dagger in a container and then picks it up later. Will it try to re-apply the perk? Does the perk get removed when the dagger is removed from the player? Also, you have a local variable for the player but are not using it. You can compare akNewContainer to Game.GetPlayer() and then assign akNewContainer to the Player variable for use later in the script (i.e. when adding the perk). Or just remove the local variable. Along those lines you have a property for the weapon, but if the script is on the weapon itself you usually do not need a property pointing at the base object. Link to comment Share on other sites More sharing options...
RowanSkie Posted September 8, 2019 Author Share Posted September 8, 2019 I think that would work except if it is on the weapon itself the script should extend Weapon instead of quest. I am confused on what would happen if the player places the dagger in a container and then picks it up later. Will it try to re-apply the perk? Does the perk get removed when the dagger is removed from the player? Also, you have a local variable for the player but are not using it. You can compare akNewContainer to Game.GetPlayer() and then assign akNewContainer to the Player variable for use later in the script (i.e. when adding the perk). Or just remove the local variable. Along those lines you have a property for the weapon, but if the script is on the weapon itself you usually do not need a property pointing at the base object.I used your script and it was better. I'm now getting some cool Magic Effects. Link to comment Share on other sites More sharing options...
Recommended Posts