Jump to content

A couple of unrelated scripting questions


smit8420

Recommended Posts

Ok, I've been working on a few miscellaneous mods to do some minor tweaks to gameplay.

 

One is that I want to eliminate the ability of the player to repair weapons and armor with other weapons and armor and totally depend on either repair stations or repair kits. Kits are already in the game and repair stations are easy enough to create, but how do I prevent the player from using either the R key or Y button on the controller? I see the Lutana NVSE functions could be used for something like this, but am a bit at a loss to force the engine to do nothing when these keys/buttons are pressed.

 

 

The other issue is a bit more complex... I want to stop the Powder Gangers around the wasteland from respawning once Eddie is dead. I see that the respawn flag can be accessed using a Bitmask, but I'm at a loss on how to properly manipulate bitmasks in Geckscript.

Link to comment
Share on other sites

I think I made the second bit more complicated than it actually is...

 

How's this sample...

 

scn aaPowderGangerRespawnFix
Begin GameMode
if (NCRCFEddieRef.GetDead == 1) ;Is Eddie a deadie?
SetActorBaseFlagsLow 8, PowderGangerMeleeAAMTEMPLATE ;Set fourth bit which represents the respawn flag
endif
End
Does that have a chance at working? I'm not sure if the SetActorBaseFlagsLow function always sets to "true" or will actually set it to the opposite of what it currently is.
Link to comment
Share on other sites

Two ideas immediately come to mind for the repair question. For the first you could detect when the player is in the inventory menu, then disable the R and Y key and button. You'd need to detect when the player has left the inventory screen (either to game-mode or another menu) and then re-enable the controls so this method would require MenuMode and GameMode blocks with a relatively quick delay. Therefore you need to make sure you doing stuff efficiently or there might be performance concerns.

 

 

 

scn DisableRepairScript

int bControlsDisabled

begin MenuMode

	if (MenuMode == 1002) && (bControlsDisabled == 0)
		DisableKey 19			;disable R key
		
		if (GetController)
			DisableButton 32768	;disable Y button
		endif

		let bControlsDisabled := 1
	elseif (bControlsDisabled)
		EnableKey 19
		EnableButton 32768
		let bControlsDisabled := 0
	endif

end

begin GameMode

	if (GetGameRestarted)
		let bControlsDisabled := 0
	elseif (bControlsDisabled)
		EnableKey 19
		EnableButton 32768
		let bControlsDisabled := 0
	endif

end 

 



The second idea would be to detect when the player is viewing the inventory screen, then use SetUIFloat to set the <visible> trait of the repair button to 0. This'll be preferable to the other method as it removes the button and so the player won't find it strange that the option is there, but they can't use it. Whatever method you choose, I'd also recommend changing the tutorial and help messages to reflect your changes - those kind of inconsistencies drive me up the wall!

 

 

 

 

(I couldn't be bothered to find the repair trait, and I can't remember whether true/false is an integer or sting in xml.)

scn DisableRepairMKIIScript

begin MenuMode 1002

	if (GetUIFloat [repair trait] == 1)
		SetUIFloat [repair trait] 0
	endif

end

 



Bitmasks can be a bit tricky to get your head around: they're a single integer which is the sum of the binary flags (bits). So if the 1st flag (decimal = 1), 3rd flag (dec = 4), and 4th flag (dec = :cool: are set then the total would be 13. Only one combination could ever add up to this values so that's how it works.

Anyway, first you need to retrieve the bitmask using the "Get" function for the flags you're editing, then use SetBit on the retrieved bitmask to set the appropriate flag (bit) to what you want, THEN use the "Set" function for the flags to set them to your edited bitmask them. A word of warning, though - I once tried setting the respawn flag on an actor but I couldn't get it to take effect. The flag was definitely set but I don't know if maybe I was testing it wrong, or the cell wasn't set to reset or something.

 

 

 

 

I've used the example you gave as a template, however scripting each individual powder ganger might not be a good idea as some may already have their own scripts. You could alternatively detect when Eddie is killed in a quest script and call the functions on the powder gangers' base forms. You can easily create a formlist of all powder gangers and then loop through them using ListGetCount and ListGetNthForm or by converting it to an array using GetListForms and then ForEach to quickly move through it.

scn PowederGangerSCRIPT

int bNoRespawn
ref rSelf

begin GameMode

	if (NCRCFEddieRef.GetDead) && (bNoRespawn == 0)

		let rSelf := GetSelf
		let bNoRespawn := rSelf.GetActorBaseFlagsLow	;using bNoSpawn as a temporary variable for the bitmask
		SetBit bNoSpawn 3 0				;remove respawn flag
		rSelf.SetActorBaseFlagsLow bNoRespawn		;set flags to new bitmask

		let rSelf := 0					;no need to store this anymore
		let bNoRespawn := 1

	endif

end

 

 

Edited by PushTheWinButton
Link to comment
Share on other sites

I hadn't looked too closely into it, but I didn't really know much about the Fallout menus. I didn't know that editing the menu actually disables the input from a device whether it be a keyboard or a controller. So, I simply edited the XML document and killed the Repair button that way. Lo and behold, it worked.

 

It still needs further editing to move around the other menu elements so the command looks like it was never there and I am going to create an esp with repair stations... but what a great feature to add to my game. It drove me crazy that you could get fully repaired high value weapons from killing a few hit squads, or that you could clear a dungeon (Shadow Company from NVB2 is a good example) and walk out with 2-3 fully repaired sets of combat armor.

 

 

I'm going to play around with the bitmask thing too... I've used a similar system in other languages where you used an integer to point to a particular bit in a 16 bit word, but the way Geckscript handles them seems a little clunky to me. I'll get it working eventually.

 

In your experiments, were you trying to force a non-respawning NPC/Creature to become respawning? If so, you may be correct and something else was coming into play.

Link to comment
Share on other sites

If you plan on releasing your mod then you might need to find a way around editing the .xml file, because many people use UI mods which have different files.

 

Yep, I was trying to make the Goodsprings Settlers respawn if killed and it wasn't working. It's one of those things that's really hard to test and I ended up drifting into other things so I never worked it out. I'm not sure if the flags are a persistent change or not either. Most NVSE changes are only in the memory so don't save with the game. Very few are permanent - setting a weapon reference's active mods is the only one that comes to mind right now. It may also be the case that setting flags on a base form isn't permanent whereas settings flags on a reference is. Probably needs testing.

 

A sure-fire and pretty unclean method of getting rid of them would be to just Disable the actors instead of editing the respawn flag. Obviously, this would definitely be permanent but it'd be difficult to reverse if you want your mod to be remove-able. Depends what you're going for.

Link to comment
Share on other sites

I just had a cool idea to fix the easy repairing you mentioned. I know it's not what you wanted but I thought it would be good to mention it.

You could remove all items from weapons' repair lists and replace then with Weapon Repair Kits or something. That would mean you couldn't repair a weapon with another weapon - instead you'd need to use the repair interface to fix it with a repair kit or whatever other misc item you wanted the player to use. Fairly quick and easy to do with Lutana NVSE and it utilises the existing game systems so you won't have issues working around it.

 

scn RepairQuestSCRIPT

;makes all weapons only repairable with repair kits in the repair interface
;the Jury Rigging perk will also need to be accounted for somehow

ref rForm
ref rRepairList
array_var aEntry

begin GameMode

	if (GetGameLoaded)

		if (ListGetNthForm Repair10mmPistol 0 != NVRepairKit)	;check if change has been made yet on this save

			foreach (aEntry <- GLTA 40)
				let rForm := *aEntry
				let rRepairList := GetRepairList rForm

				if (IsPlayable rForm)
					ListClear rRepairList
					ListAddForm rRepairList NVRepairKit
				endif

			loop

		endif

	endif

end 

 

 

Edited by PushTheWinButton
Link to comment
Share on other sites

I just had a cool idea to fix the easy repairing you mentioned. I know it's not what you wanted but I thought it would be good to mention it.

 

You could remove all items from weapons' repair lists and replace then with Weapon Repair Kits or something. That would mean you couldn't repair a weapon with another weapon - instead you'd need to use the repair interface to fix it with a repair kit or whatever other misc item you wanted the player to use. Fairly quick and easy to do with Lutana NVSE and it utilises the existing game systems so you won't have issues working around it.

 

 

 

scn RepairQuestSCRIPT

;makes all weapons only repairable with repair kits in the repair interface
;the Jury Rigging perk will also need to be accounted for somehow

ref rForm
ref rRepairList
array_var aEntry

begin GameMode

	if (GetGameLoaded)

		if (ListGetNthForm Repair10mmPistol 0 != NVRepairKit)	;check if change has been made yet on this save

			foreach (aEntry <- GLTA 40)
				let rForm := *aEntry
				let rRepairList := GetRepairList rForm

				if (IsPlayable rForm)
					ListClear rRepairList
					ListAddForm rRepairList NVRepairKit
				endif

			loop

		endif

	endif

end 

 

 

 

This is a thing of beauty. I originally just wanted to do this very thing... get rid of the repair lists altogether and make weapons repairable with repair kits, armors with some sort of armor repair kit and so forth. For the life of me I couldn't get rid of the ability to repair a weapon/armor with a duplicate of the item.

 

I will be testing this out as soon as I get a chance.

 

Some questions on the script... I couldn't find GLTA in the Geck documentation. I know it must have something to do with the repair lists, but I'm a guy that likes to know exactly what the code is that I am using.

 

 

For the "jury rigging" perk... my original thought was to open up recipes that enabled the player to craft a repair kit with a weapon rather than finding all the necessary components, with bigger, heavier weapons yielding more kits, but that's just a brainstorm, not something I had settled on.

Link to comment
Share on other sites

I think you can always repair a weapon or armor with another that's the same type.

 

Yeah, seems you can. Dang, I thought that would be a great idea. Makes you wonder why they bothered making repair lists for every weapon and armour if they were only going to populate them the same item in 99% of cases. Oh well.

 

 

Some questions on the script... I couldn't find GLTA in the Geck documentation. I know it must have something to do with the repair lists, but I'm a guy that likes to know exactly what the code is that I am using.

 

 

Sorry, the GLTA function is a shortened alias for "GetLoadedTypeArray" from the Lutana NVSE Plugin. It returns an array containing all forms of a certain type code, so passing 40 would be weapons. By default it returns forms from all used mods but you can refine it by passing an index.

 

I have a pretty simple script which enforces a repair limit like Fallout 3 which I wrote for JSU. If I can perfect it, I'll post it here so you can reuse it.

Edited by PushTheWinButton
Link to comment
Share on other sites

  • Recently Browsing   0 members

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