I started this thread on the nexus forums...
http://forums.nexusmods.com/index.php?/topic/3184014-adding-activation-to-static-object-via-script-doable/
Basically, I'm adding onto http://ww.nexusmods.com/fallout3/mods/12688/? mod by FGRaptor. I started out by just adding more items that could be collected and then broken down into large and small spare parts to be crafted into scrap metal. I went through the scripts and optimized them a little and eliminated several of the kind of redundant messages. I then wanted to add on to that to use many unused static objects cluttering up the world. At first I wanted to be able to add an activation to these items so that the player could click on them for an option to break them down into spare parts. That idea didn't work out so I went another route. I ended up creating a quest and a weapon used as a tool. This method works well with the exception of how the quest script runs. While the tool is equipped the quest script is enabled and scans the object under the cross hair using the FOSE function GetCrosshairRef. While this is happening, I notice a large drop in FPS. While in outdoors areas this can lead to a CTD if I'm running around too long with the tool equipped. While in indoor areas, this doesn't seem to happen or at least not to a degree where it causes a crash.
Here is the relevant script that runs while the tool is equipped. I would like know if there is a better way to do this so that it doesn't eat up so many resources that my game crashes.
scn fgBreakdownStaticsref tObjectRefshort LG_Lpartsshort LG_Spartsshort MD_Lpartsshort MD_Spartsshort SM_Spartsshort TN_Spartsshort lpartsshort spartsshort HasToolBegin 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 endifEnd
Any help or pointers to improve this would be appreciated.