ajs52698 Posted August 28, 2016 Share Posted August 28, 2016 (edited) Im having a hard time figuring out a way to have a script search to see if a object is in a formlist. Need some help \: Ive gotten this far ScriptName Script extends Objectreference Formlist Property List auto Event OnHit(aktarget) Int ListInt == List.GetSize()Int RandomResourceChance If aktarget == List.Getat() Again im having a hard time figuring out how I would go about having the script search a formlist. Got some of the info from this example http://www.creationkit.com/index.php?title=Complete_Example_Scripts#Cycle_Through_a_List_of_Objects_and_Perform_an_Action_on_Each_Object.28FormLists.29 Edited August 28, 2016 by ajs52698 Link to comment Share on other sites More sharing options...
TummaSuklaa Posted August 28, 2016 Share Posted August 28, 2016 (edited) The Event you are using is complicating in Fallout 4 (it's easier in Skyrim, but it's been changed because stack overflow is just too easy..) and I can't wrap my head around doing it. You have to register for a hit event first: http://www.creationkit.com/fallout4/index.php?title=RegisterForHitEvent_-_ScriptObject and also, that event wouldn't run anyway because you don't have all the parameters. All parameters need to be present, or the compiler will complain. http://www.creationkit.com/fallout4/index.php?title=OnHit_-_ScriptObjectI will however right out a basic function for searching through a formlist. I am better with arrays for they are faster, so I might be a little off with this. Formlist property MyRefList auto Int Function GetRefInList(Form akForm) ; Checks the Formlist if this form is in it. if MyRefList.HasForm(akForm) int iIndex = akList.GetSize() ; Counts down until it reaches 0 While iIndex > 0 iIndex -= 1 ; Going through the list, from the last index to the first. ; Comparing each form to the passed in form. if MyRefList.GetAt(iIndex) == akForm ; Return the index for the matching form. return iIndex EndIf EndWhile EndIf ; If not found return this value instead. return -1 EndFunction Edited August 28, 2016 by TummaSuklaa Link to comment Share on other sites More sharing options...
ajs52698 Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) So with this script you have to define the hasform.() no?I was going to use this at first but I didnt because I wanted to avoid typing out all of the forms im trying to search for, theres a lot, very time consuming Edited August 29, 2016 by ajs52698 Link to comment Share on other sites More sharing options...
TummaSuklaa Posted August 29, 2016 Share Posted August 29, 2016 I pulled that from an example off the Skyrim wiki(no examples on the Fallout one) and yeah the HasForm bit confused me as well. Link to comment Share on other sites More sharing options...
LoneRaptor Posted August 29, 2016 Share Posted August 29, 2016 Ty this: ScriptName Script extends Objectreference Formlist Property List Auto Actor Property PlayerREF Auto Event OnInit() RegisterForHiteEvent(PlayerREF) EndEvent Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial) int Index = Find(akTarget) If Index >= 0 ;put here watherver you want to do if it is in the formlist Else ; akTarget does not appear in the formlist EndIf EndEvent I am assuming here that you want to search for what hit the player if not just change PlayerREF to wathever you want to check on.This script will need to be added to a dummy quest to work. Link to comment Share on other sites More sharing options...
ajs52698 Posted August 29, 2016 Author Share Posted August 29, 2016 I think that still involves having to type out all the forms to search for no? Heres what im trying to do, Player hits object, if object is in form list, do something. Link to comment Share on other sites More sharing options...
LoneRaptor Posted August 30, 2016 Share Posted August 30, 2016 (edited) No you make a formlist and the onHit event fills in the akTarget and then the Find function seaches your formlist.But if you want to know if the item that got hit is in a formlist this might not work as the onhit in this case only triggers when the player is hit. You would have to attach this script to everything you want to check on and then replace PlayerREF in the RegisterForHitEvent with Self. RegisterForHitEvent(Self)Which migt not be the best approach. Edited August 30, 2016 by LoneRaptor Link to comment Share on other sites More sharing options...
ajs52698 Posted August 30, 2016 Author Share Posted August 30, 2016 So there really is no way to do this without spending tons of time filling out forms or adding scripts D: Link to comment Share on other sites More sharing options...
Reneer Posted August 30, 2016 Share Posted August 30, 2016 (edited) This is what you want. I haven't checked to see if this exact script compiles, but I've written code like this before:Scriptname RenFormlistHitQuestScript extends Quest Formlist Property List Auto ; formlist filled with objectreferences, not baseids int listsize = 0 Event OnInit() listsize = List.GetSize() int itr = 0 while (itr < listsize) Self.RegisterForHitEvent(List.GetAt(itr)) itr += 1 endWhile Self.RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerLoadGame") endEvent Event Actor.OnPlayerLoadGame(Actor akSender) if (listsize != List.GetSize()) int itr = 0 Self.UnregisterForAllHitEvents(none) while (itr < List.GetSize()) Self.RegisterForHitEvent(List.GetAt(itr)) itr += 1 endWhile endif listsize = List.GetSize() endEvent Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial) ; do whatever you need to do here. endEvent Edited August 30, 2016 by Reneer Link to comment Share on other sites More sharing options...
ajs52698 Posted August 31, 2016 Author Share Posted August 31, 2016 alright ill mess with your code Reneer when I get done playing nuka world :P Link to comment Share on other sites More sharing options...
Recommended Posts