Jump to content

[FO4 CK] General Help Thread


Recommended Posts

37 minutes ago, Elsidia said:

I can't use CK because i modify existing mod and i have no originals. I have only mod and source files. At this moment i can't made it only in FO4edit. All works but condition ignores quest variable - in ck it shows as illegal.

 

Hmmm, OK.

 

To access a quest variable from a condition, both the quest and variable need to be flagged as conditional. Do you know if they are?

 

Also, if you don't have the source, there's a decent decompiler on Nexus. Might make life easier.

Link to comment
56 minutes ago, DocClox said:

Do you know if they are?

Yes it is. And when i load mod into CK i can select quest in condition and variable for quest too. But if it made in fo4edit when i load it ck in condition variable is wrote but quest name is put illegal... I don't want to save mod after that in CK because i fear i may something damage after that. And i have source files psc. I fix there some error what original mod have and after that i compile in papyrus script manager in ck. After that all works. But i still fear save esp file in ck - maybe it's can damage something serious in mod.

Link to comment

Well, you could always take a bcakup, then save and test it anyway.

 

Failing that, is there a place in the mod that uses the same condition? I assume there must be if the variable has been marked as conditional. Can you cut and paste the condition?

 

Also, if not the papyrus source, what are you missing that stops you from using the CK for this?

 

Link to comment
7 hours ago, Elsidia said:

Yes it is. And when i load mod into CK i can select quest in condition and variable for quest too. But if it made in fo4edit when i load it ck in condition variable is wrote but quest name is put illegal... I don't want to save mod after that in CK because i fear i may something damage after that. And i have source files psc. I fix there some error what original mod have and after that i compile in papyrus script manager in ck. After that all works. But i still fear save esp file in ck - maybe it's can damage something serious in mod.

 

If you're only editing and compiling a script. And not making any changes in the script property manager. There is no need to save the esp.

Link to comment
1 hour ago, Carabosse said:

 

If you're only editing and compiling a script. And not making any changes in the script property manager. There is no need to save the esp.

 

I think they're trying to add in a new condition using xEdit rather than editing the script.

Link to comment
On 3/9/2020 at 1:22 PM, DocClox said:

Failing that, is there a place in the mod that uses the same condition?

In that mod no. I take a example from another mod. Mod is files archive and there not ba2 archive. Only 7zip) In mod are esp, textures, meshes, materials, scripts,  source scripts and etc. Mod have many properties and different quests (3 or 4) I fear use CK because i hear it can delete some scripts and recompile. Mod is as in my sight complicated and i fear that something can't work after save it in CK. I start my modding experience by making new textures, modify nif, material files etc. Using Bodyslide and outfit studio, then i found blender, gimp, nifscope, online photopea. Then i start learning fo4edit by explore different mods. Then new level : i found txt script files and starting learning script language. CK i install no so far ago and still using only to recompile source files by papyrus manager. I know fo4edit must better than CK, that's a problem) I make new variable in source file like:

extends quest conditional

bool property suit auto conditional

Then i recompile the source using papyrus script manager from ck and open fo4edit - add condition, fill the field for quest and in string field write that: ::suit_var After that i save changes in fo4edit.

Something like that.

Link to comment
19 hours ago, Carabosse said:

If you're only editing and compiling a script. And not making any changes in the script property manager. There is no need to save the esp.

I use both methods: use xedit to add new dialogue, add to this dialogue conditions (all works excellent but not getvmquestvariable) Then i change source scripts or made new scripts by writing in notepad+ and then recompile it in ck using menu: papyrus script manager. As i say before i fear modify esp file in ck because i fear, that ck can change something what i don't know and not modify and it can lead to wrong mod work. Then i check if my new script activates and work. If not then check where i put wrong variable or extend type. I know probably it's looks like hit nails using microscope and not hammer what's designed for nails)

Link to comment
10 hours ago, Elsidia said:

I fear use CK because i hear it can delete some scripts and recompile.

 

Keep a backup of the original mod archive and you'll be fine. Recompile the scripts by hand and don't mess with anything you don't have to, so you keep the test area small. Then test what you changed. You might save yourself a lot of time.

Link to comment

@Elsidia I only use FO4Edit for stuff like cleaning, conflict checking.

 

I use conditional properties a lot. Probably won't help but this is what some conditional property references look like for my mod in FO4edit. Note that they aren't displayed as properties in the script fields for the relevant quest for some reason, I checked (I guess FO4edit doesn't consider that a worthwhile feature). I only see them referenced in the dialogue conditions which call them.


 

Spoiler

 

These are conditions on a line of dialogue where I'm trying to convince the speaker target to use a condom (:|).

 

x01.jpg.b2eb6c79c52341f75fe4a043b9fd52e0.jpg

 

And collapsed.

 

x02.jpg.7021827e58399821311d591a71edf568.jpg

 


 

 

The script that holds conditionals must be flagged conditional and only one conditional flagged script is allowed per object (quest etc). The relevant properties must be flagged conditional also etc, etc.

 

So for the above examples this is how the script and properties are declared.

 

Scriptname hh123:hh123_Questhelper_SCR extends Quest Conditional


int Property iCondomCount = 0 Auto Conditional
bool Property bCondomGiven = false Auto Conditional
bool Property bRefusedCondom = false Auto Conditional

 

I do remember having a problem with conditionals before where it seemed like I needed to give them a kick up the bum before they would work. What I mean is that when the quest began that would later use them (it was for tracking attitude of a npc during a conversation). I had to assign them a value prior to the check being called. But that issue no longer seems to crop up. Maybe because I always give them default values now. Maybe I was doing something stupid and accidentally stopped doing it (likely this).

 

Link to comment
  • 3 weeks later...

I'm trying to make a little mod that prevents the player from carrying more than one weapon at a time (without a backpack) At first I tried a OnItemAdded event where when you pick up a weapon I had it check PlayerRef.GetEquippedWeapon() dropped that old one, and equipped the new one and that worked great EXCEPT as you probably know when you do placeatme on a modified object it always places the generic version on the ground.

 

So to avoid that I need a way to prevent the player from ever picking up another weapon if they already have one (giving a messagebox)

 

Or Alternatively a way to drop a modded/renamed weapon from your inventory without losing all the changes.

 

Any ideas?

Link to comment
7 hours ago, Tentacus said:

I'm trying to make a little mod that prevents the player from carrying more than one weapon at a time (without a backpack) At first I tried a OnItemAdded event where when you pick up a weapon I had it check PlayerRef.GetEquippedWeapon() dropped that old one, and equipped the new one and that worked great EXCEPT as you probably know when you do placeatme on a modified object it always places the generic version on the ground.

 

So to avoid that I need a way to prevent the player from ever picking up another weapon if they already have one (giving a messagebox)

 

Or Alternatively a way to drop a modded/renamed weapon from your inventory without losing all the changes.

 

Any ideas?

 

How are you handling tracking of weapons? I assume with aliases. I'd have a referencealias that always tracked the currently used weapon of the player (whether its equipped or not). And maybe have a refcollection that could sweep for all other weapons that might be acquired or given to the player. Because weird things are bound to happen.

 

The wiki says drop() will 'drop' a reference with whatever omod configuration it currently has. Whereas PlaceAtMe, DropObject etc are going to give you a base object reference.

 

https://www.creationkit.com/fallout4/index.php?title=Drop_-_ObjectReference

 

Something else that may be useful is GetAllMods() (F4SE)

 

https://www.creationkit.com/fallout4/index.php?title=GetAllMods_-_ObjectReference


Which will return an array of omods for a reference (I haven't looked at how you would use that information to apply the mods back to a weapon though).

Link to comment
51 minutes ago, Carabosse said:

 

How are you handling tracking of weapons? I assume with aliases. I'd have a referencealias that always tracked the currently used weapon of the player (whether its equipped or not). And maybe have a refcollection that could sweep for all other weapons that might be acquired or given to the player. Because weird things are bound to happen.

 

The wiki says drop() will 'drop' a reference with whatever omod configuration it currently has. Whereas PlaceAtMe, DropObject etc are going to give you a base object reference.

 

https://www.creationkit.com/fallout4/index.php?title=Drop_-_ObjectReference

 

Something else that may be useful is GetAllMods() (F4SE)

 

https://www.creationkit.com/fallout4/index.php?title=GetAllMods_-_ObjectReference


Which will return an array of omods for a reference (I haven't looked at how you would use that information to apply the mods back to a weapon though).

I had considered using a reference alias but wasn't sure if you could fill one for an object in the inventory. For drop() you need the object reference... and objects in the inventory don't have an object reference Unless I'm mistaken. Anyway thanks for getting back to me. I've pretty much given up on this though.

Link to comment
18 minutes ago, Tentacus said:

I had considered using a reference alias but wasn't sure if you could fill one for an object in the inventory. For drop() you need the object reference... and objects in the inventory don't have an object reference Unless I'm mistaken. Anyway thanks for getting back to me. I've pretty much given up on this though.

Drop() is an inventory safe function. It can be called on a reference inside of a container (they don't just spontaneously diffuse as soon as they hit your inventory, how else would your modded weapons retain their stats).

 

Aside from that. For what you are trying to do, I'd advise to use aliases to track your designated weapon at least (designated does not necessarily mean equipped in this context).

 

 

Link to comment
13 hours ago, Carabosse said:

Drop() is an inventory safe function. It can be called on a reference inside of a container (they don't just spontaneously diffuse as soon as they hit your inventory, how else would your modded weapons retain their stats).

 

Aside from that. For what you are trying to do, I'd advise to use aliases to track your designated weapon at least (designated does not necessarily mean equipped in this context).

 

 

I think this is a dead end. It seems no weapon has a persistent reference even the unique ones like Gognaks axe, Righteous Authority etc... Therefore I can't get the object reference in the OnItemAdded event. So even using aliases all I can add to the alias is the base object. Drop() simply isn't an option without a persistent reference.

 

Oh well. This was just a side mod without much mass appeal.

Link to comment
  • 4 weeks later...
On 3/29/2020 at 5:52 PM, Tentacus said:

I think this is a dead end. It seems no weapon has a persistent reference even the unique ones like Gognaks axe, Righteous Authority etc... Therefore I can't get the object reference in the OnItemAdded event. So even using aliases all I can add to the alias is the base object. Drop() simply isn't an option without a persistent reference.

 

Oh well. This was just a side mod without much mass appeal.

 

Self.Drop()

 

...is the key. But it will require to attach a script to every weapon.

 

Self does in this case point at the attached script that already defines itself as object reference. It works on any item it is attached to and will drop it sucessfully out of any container, even when it is equipped. There is no way to externally define an item as object reference when it is inside of a container, it only becomes a persistant object reference for as long as that item is in the world.

 

Link to comment
8 hours ago, Nordir said:

 

Self.Drop()

 

...is the key. But it will require to attach a script to every weapon.

 

Self does in this case point at the attached script that already defines itself as object reference. It works on any item it is attached to and will drop it sucessfully out of any container, even when it is equipped. There is no way to externally define an item as object reference when it is inside of a container, it only becomes a persistant object reference for as long as that item is in the world.

 

Hmmm... attaching a script to every weapon in the game seems a bit overreaching, but if I was going to attempt that how would I do it. I mean what function could I use in say an OnInit() event. Normally if I was going to attach a script to an object I'd use reference aliases. That's not feasable here.

 

7 hours ago, DocClox said:

Did you try DropObject? That just needs a form. Admittedly, there's a risk of dropping the modded weapon in favour of the new one, but you could argue that was a feature rather than a bug.

Not sure if I tried that. One thing I did try was getting the form AS an object reference and that just dropped the default item. and the modded/legendary/renamed etc... item is what I need. 

 

Anyway I am very busy with Scavvers Closet and then Hardship, but am gonna revisit weapons with a counterpart to Svavvers closet after so I may persue these ideas down the line. 

Link to comment
7 hours ago, Tentacus said:

Hmmm... attaching a script to every weapon in the game seems a bit overreaching, but if I was going to attempt that how would I do it. I mean what function could I use in say an OnInit() event. Normally if I was going to attach a script to an object I'd use reference aliases. That's not feasable here.

 

Not sure if I tried that. One thing I did try was getting the form AS an object reference and that just dropped the default item. and the modded/legendary/renamed etc... item is what I need. 

 

Anyway I am very busy with Scavvers Closet and then Hardship, but am gonna revisit weapons with a counterpart to Svavvers closet after so I may persue these ideas down the line. 

 

You don't even need OnInit, just a global Var that defines if the player already has a weapon and a container event attached to every weapon script.

 

GlobalVariable Property PlayerHasWeapon Auto Const

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If (akNewContainer as Actor)
		If (akNewContainer == PlayerRef)
			bVal = PlayerHasWeapon.GetValue() as int
			If (bVal == 1)
				Self.Drop()
			EndIf
		EndIf
	EndIf
EndEvent

 

Link to comment
1 hour ago, Nordir said:

 

You don't even need OnInit, just a global Var that defines if the player already has a weapon and a container event attached to every weapon script.

 


GlobalVariable Property PlayerHasWeapon Auto Const

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If (akNewContainer as Actor)
		If (akNewContainer == PlayerRef)
			bVal = PlayerHasWeapon.GetValue() as int
			If (bVal == 1)
				Self.Drop()
			EndIf
		EndIf
	EndIf
EndEvent

 

Oh sorry I thought it was a very bad idea to add scripts to vanilla items in the CK, so I was concerned with attaching the scripts at mod initialization, for instance if you add an NPC to a faction in the CK it causes the black face bug, but if you do it with a script at init it's fine etc... Maybe it's less destructive to edit weapon forms directly?

Link to comment

I would suggest just dropping the new weapon if the player already has a weapon in inventory.  This is simpler and only requires putting the player in a quest alias with the following script attached:

Keyword Property ObjectTypeWeapon Auto Const

Event OnAliasInit()
    Self.AddInventoryFilter(ObjectTypeWeapon)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If (PlayerRef.GetItemCount(ObjectTypeWeapon) > 1)
        If (akSourceContainer != None)
            PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer)
        Else
            PlayerRef.DropObject(akBaseItem, aiItemCount)
        Endif
        Debug.Notification("You can't take the " + akBaseItem.GetName() + " right now.")
    EndIf
EndEvent

When the player is in this alias and has a weapon in their inventory, they will drop any weapon they try to pick up, and put back any weapon they take out of a container. 

 

The downside is that OnItemAdded doesn't actually give you the ObjectReference for the item you picked up (it's always None), so you can't call Drop() on it.  You have to call DropItem() instead.  In most cases this isn't a problem, but if the player tries to pick up the same type of weapon they already had, they will randomly drop either the new one or the old one.

Link to comment

You should look at the vanilla script for the weapons racks in DLC05.  They use the drop command to spawn the weapon in world so it will regenerate it's RefID.  The RefID is destroyed once you pick up an item, and the items in your inventory are a list of Form IDs with a generated node ID that is used to reconstitute the configuration and generate a new Ref ID.  The weapon rack uses the following bit of code to generate a new ref ID from the player's inventory and then put onto the weapon rack

 

if WeaponToPlace is ObjectReference
			; have to use base object - PlacedWeaponRef.Drop() causes issues (OnItemRemoved triggered when we don't want it to be)
			PlacedWeaponRef = DropObject((WeaponToPlace as ObjectReference).GetBaseObject())
		else
			PlacedWeaponRef = DropObject(WeaponToPlace)
		endif
		AttachWeapon(PlacedWeaponRef)

If you don't attempt to get a refID, you will get a randomly generated item off the loot table if you use just the weapon base.

Link to comment
20 hours ago, EgoBallistic said:

I would suggest just dropping the new weapon if the player already has a weapon in inventory.  This is simpler and only requires putting the player in a quest alias with the following script attached:


Keyword Property ObjectTypeWeapon Auto Const

Event OnAliasInit()
    Self.AddInventoryFilter(ObjectTypeWeapon)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If (PlayerRef.GetItemCount(ObjectTypeWeapon) > 1)
        If (akSourceContainer != None)
            PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer)
        Else
            PlayerRef.DropObject(akBaseItem, aiItemCount)
        Endif
        Debug.Notification("You can't take the " + akBaseItem.GetName() + " right now.")
    EndIf
EndEvent

When the player is in this alias and has a weapon in their inventory, they will drop any weapon they try to pick up, and put back any weapon they take out of a container. 

 

The downside is that OnItemAdded doesn't actually give you the ObjectReference for the item you picked up (it's always None), so you can't call Drop() on it.  You have to call DropItem() instead.  In most cases this isn't a problem, but if the player tries to pick up the same type of weapon they already had, they will randomly drop either the new one or the old one.

This works perfectly @EgoBallistic. The example code helped especially the container check.

 

The gun stuff is now gonna be a seperate mod from Scavver's Closet, and I won't get to it for quite a while but I might just add an (annoying immersion for maniacs) mode to SC using this that only lets you carry a few clothing items at a time (Optional in MCM of course)

 

Thanks to everybody who revived this question after I gave up :)

Link to comment

I was wondering what the event would be for persistently checking to see if an item was in a container (notably, the player, since it is my understanding that the game regards the player as a container). I have a few ideas for scripted events (as an example, a radioactive item that would naturally give you radiation over X period of time). I have been trying to find an example of constantly checking the player's inventory for a particular item but I have yet to find it. Any assistance would be greatly appreciated. Thank you.

Link to comment
1 hour ago, Victor14 said:

I was wondering what the event would be for persistently checking to see if an item was in a container (notably, the player, since it is my understanding that the game regards the player as a container). I have a few ideas for scripted events (as an example, a radioactive item that would naturally give you radiation over X period of time). I have been trying to find an example of constantly checking the player's inventory for a particular item but I have yet to find it. Any assistance would be greatly appreciated. Thank you.

You won't find many examples of that, because constantly checking the player's inventory is not efficient.  Most mods have scripts that check when an item is added to the player's inventory.  That way the script only runs when it needs to.

 

The code I posted above is an example of this.  You need one routine to call AddInventoryFilter(FormToListenFor) to start listening for items added or removed to/from the inventory.  The form to listen for can be a keyword, a base object type, a crafting component, or a form list of these.

 

Then you need an OnItemAdded() event handler which the game will call when the objects specified by the AddInventoryFilter() call are added or removed.

 

You could also take the object-centered approach.  You can attach a script to the object itself so that it will do something when it is transferred to or from the player's inventory.  This example will add a spell to the player when it is added to the player's inventory, and remove the spell when it leaves the player's inventory:

Scriptname RadioactiveItemScript extends ObjectReference

Spell Property MyRadiationSpell Auto Const

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
    Debug.Trace("RadioactiveItem: container changed to " + akNewContainer)
    If akNewContainer == Game.GetPlayer() as ObjectReference
        Game.GetPlayer().AddSpell(MyRadiationSpell, false)
    Else
        If akOldContainer == Game.GetPlayer() as ObjectReference
            Game.GetPlayer().RemoveSpell(MyRadiationSpell)
        EndIf
    EndIf
EndEvent

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use