Jump to content

Scripting quickie. How do I add an item to the inventory of every actor in a specific faction?


PsychorGames

Recommended Posts

Depends. Are you wanting to add them real-time, or when the game starts?

 

Real-time is probably the less performance intensive. You'll have to utilise NVSE, but you can also use Lutana and JIP to simplify stuff.

 

Here's a real-time example that just used NVSE (haven't tested):

scn pwbAMRifleAdderQuestSCRIPT

; Adds Anti-Materiel Rifles to NCR faction members as the player explores

array_var aEntry
array_var aNPCs
ref rCell
ref rLastCell
ref rNPC

begin GameMode

	; Check if player has moved cell
	let rCell := PlayerREF.GetParentCell
	if (rCell == rLastCell)
		return
	endif

	; Save current cell
	let rLastCell := rCell

	; Get all nearby NPCs
	let aNPCs := GetRefs 42 -1

	; Check array isn't empty
	if eval (ar_Size aNPCs) < 1
		let aNPCs := ar_Null
		return
	endif

	; Loop through the array of NPCs
	foreach (aEntry <- aNPCs)
		let rNPC := *aEntry
		if (IsFormValid rNPC)
			if (rNPC.GetDead == 0) && (rNPC.GetInFaction NCRFactionNV) && (rNPC.GetItemCount WeapNVAntiMaterielRifle == 0)
				;do the stuff
			endif
		endif
	loop

	let aNPCs := ar_Null

end
Link to comment
Share on other sites

What's the difference between items placed in their inventories on in real time vs game start? The result is the same isn't it? The reason I ask is because I'm trying to put an item into everyone's inventory that I will add a script that will make it so that they are hireable (via a dialogue option)

 

Oh and thanks for replying!

Link to comment
Share on other sites

because I'm trying to put an item into everyone's inventory that I will add a script that will make it so that they are hireable (via a dialogue option)

 

Oh and thanks for replying!

 

WoW ... that is some good thinkin

Link to comment
Share on other sites

If you do it on game start then you'll have to work with base forms, not references, which means you'll have to use BaseAddItem from Lutana NVSE, and either loop through actors' base factions to check if any of them == NCRFactionNV or you'll have to make a form list of such actors in the GECK beforehand. And no, this isn't possible without NVSE. This isn't a case of "NCRFactionNV.AddItemToAll" if that's what you were thinking.

 

Why do you need to add an item to them? Can't you just make a dialogue option with the (GetInFaction NCRFactionNV) condition and have the result script do what you want?

Link to comment
Share on other sites

I will try that when I get home . Forgive me, I'm still pretty new to modding.

 

I figured if the other NPC-recruiting mods didn't require NVSE, this task wouldn't require it either. But the difference is that they put the object into every NPC somehow whereas I'm trying to put the object into NPCs of specific factions.

Edited by PsychorGames
Link to comment
Share on other sites

"Why do you need to add an item to them? Can't you just make a dialogue option with the (GetInFaction NCRFactionNV) condition and have the result script do what you want?"

 

Hmm, maybe that's what the original modders did to make their hiring mod work, and I'm simply misinterpreting what they did thinking that they added an object to all NPCs via script.

Edited by PsychorGames
Link to comment
Share on other sites

  • Recently Browsing   0 members

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