Jump to content

Adding activation to static object via script - doable?


SigmondDroid

Recommended Posts

I've been playing around with the CRAFT mod Scrap Metal Crafting adding more objects to turn into large and small spare parts. Then I got to thinking about all the metal junk items all around that I can't pick up or interact with - the static and moveable static objects.

 

Questions:

 

1 - Is there a way to add an activation ("break down this item into spare parts") to static (STAT and MSTT) objects?

 

or

 

2 - Is there a straight-forward way of replacing the static (STAT) and moveable static (MSTT) objects with obtainable items (MISC)?

 

or

 

3 - Does anyone have a suggestion for a better way to go about this?

 

Examples of items I would like to add the activation to are the typewriter (Typewriter01 [sTAT:0003180E]) and bucket (Bucket01 [MSTT:000039DE]) objects.

Link to comment
Share on other sites

Ok, figured there was no easy way to do what I was hoping to do. What I ended up doing was creating override copies of the moveable static objects, adding names to the objects with "[sCRAP]" appended. For instance, the Bucket01 object, when the crosshair is over it, says "Metal bucket [sCRAP]" indicating that this item can be broken down into spare parts. Using the Scrap Metal Crafting mod, these spare parts are then taken back to a workbench and combined into scrap metal.

 

In order to break down the objects I created a quest that would automatically give the player a tool. In actuality it is a weapon that when equipped runs a quest script. This script utilizes the GetCrosshairRef function to find items that are in a form list. Once an item is found and the tool is equipped it then looks for that item within a group of form lists that determines the size of the object and how many spare parts, depending on repair skill, to award, then disables the object and marks it for deletion.

 

This is all working fairly well. One issue I'm having is that the quest script is constantly scanning the GetCrosshairRef while the tool is equipped and causes my game to lose quite a few FPS. Wielding the tool long enough in an outside setting (indoors seems to be ok so far) causes my game to CTD.

 

This is the script for the tool. The messages are simple messages stating that scrapping is enabled or disabled. Also, the tool is marked as a quest item so that the player can't accidentally lose it.

scn fgScrappingEnabledScript

Begin OnEquip
	ShowMessage fgScrappingEnabled
	StartQuest fgBreakdownStatics
End

Begin OnUnequip
	StopQuest fgBreakdownStatics
	ShowMessage fgScrappingDisabled
End

This is the quest script that the tool enables:

scn fgBreakdownStatics

ref tObjectRef
short LG_Lparts
short LG_Sparts
short MD_Lparts
short MD_Sparts
short SM_Sparts
short TN_Sparts
short lparts
short sparts
short HasTool

Begin GameMode
	
	set HasTool to player.GetItemCount WeapScrappingTool
	if  HasTool != 1
		if HasTool < 1
			player.additem WeapScrappingTool 1
		elseif HasTool > 1
			player.removeitem WeapScrappingTool HasTool + 1
			player.additem WeapScrappingTool 1
		endif
	endif

	if ((player.GetEquippedObject 5) == WeapScrappingTool)
		if tObjectRef != GetCrosshairRef
			set tObjectRef to GetCrosshairRef 
			if (tObjectRef.IsInList fgScrappedStaticsALL)
				if (player.GetHasNote fgScrapMetalCrafting1)
					set LG_Lparts to 2
					set LG_Sparts to 1
					set MD_Lparts to 1
					set MD_Sparts to 0
					set SM_Sparts to 1
					set TN_Sparts to 1
				elseif (player.GetHasNote fgScrapMetalCrafting2)
					set LG_Lparts to 3
					set LG_Sparts to 1
					set MD_Lparts to 1
					set MD_Sparts to 1
					set SM_Sparts to 2
					set TN_Sparts to 1
				elseif (player.GetHasNote fgScrapMetalCrafting3)
					set LG_Lparts to 3
					set LG_Sparts to 2
					set MD_Lparts to 2
					set MD_Sparts to 1
					set SM_Sparts to 2
					set TN_Sparts to 1
				elseif (player.GetHasNote fgScrapMetalCrafting4)
					set LG_Lparts to 4
					set LG_Sparts to 1
					set MD_Lparts to 3
					set MD_Sparts to 1
					set SM_Sparts to 2
					set TN_Sparts to 1
				elseif (player.GetHasNote fgScrapMetalCrafting5)
					set LG_Lparts to 4
					set LG_Sparts to 2
					set MD_Lparts to 3
					set MD_Sparts to 2
					set SM_Sparts to 3
					set TN_Sparts to 2
				endif
				if tObjectRef.IsInList fgScrappedStaticsLG
					set lparts to LG_Lparts
					set sparts to LG_Sparts
				elseif tObjectRef.IsInList fgScrappedStaticsMD
					set lparts to MD_Lparts
					set sparts to MD_Sparts
				elseif tObjectRef.IsInList fgScrappedStaticsSM
					set lparts to 0
					set sparts to SM_Sparts
				elseif tObjectRef.IsInList fgScrappedStaticsTN
					set lparts to 0
					set sparts to TN_Sparts
				endif
				tObjectRef.Disable
				tObjectRef.MarkForDelete
				player.AddItem fgLargeScrapParts lparts
				player.AddItem fgSmallScrapParts sparts
				PlaySound UIRepairWeapon
				ShowMessage fgBrokenDown lparts,sparts
			endif
		endif
	else
		StopQuest fgBreakdownStatics
	endif
End


This quest is enabled from start so that the player gets the tool. A check is made to ensure they only get one and if the script is running and the tool is not equipped it is then disabled.

 

I am very much open to suggestions on how to improve the efficiency of this script.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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