SeraphimKensai Posted October 27, 2018 Share Posted October 27, 2018 Hello,So I have adapted the creation kit.com tutorial script to make an object cast a spell. The way it works is that it will target the closest vivable target within it's range. I'm looking for a means to make target acquisition more random so that on update, it randomly selects a target within it's range so that way the effect has the ability to distribute potentially more evenly then just continuously blast the closest target. Does anyone have an idea how best to make that work? And a follow up question regarding the associated FormList for establishing vivable targets, as is I have it loaded with all the actors in the game, which works for those actors but neglects any actors added via mods. Does anyone have a better idea for creating my potential Target list to be inclusive of actors added by mods down the road to enhance compatibility? Currently I use an IsHostile condition to rule out whether an actor is targeted by a beneficial or hostile spell. Any help as always is appreciated. Thanks. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 27, 2018 Share Posted October 27, 2018 Do not know about the targeting thing. Regarding using NPCs from other mods. You could make each one compatible as you find out about them and do something as follows (uses SKSE): If Game.GetModByName("SomeMod.esp") != 255 ; is the SomeMod.esp plugin present and loaded into the game myTargetList.AddForm(Game.GetFormFromFile(0x00123456,"SomeMod.esp") as ActorBase) ;may not even need to cast since formlists store as form anyway.EndIf You can avoid SKSE and skip the condition check, but then you'll have to let users know to ignore any papyrus log errors about not finding plugins that they are not using which your mod accounts for. GetFormFromFile spits out a harmless message when it cannot find the target plugin. Link to comment Share on other sites More sharing options...
SeraphimKensai Posted October 27, 2018 Author Share Posted October 27, 2018 (edited) Hmmm interesting. I'll have to check that out when I get home today, or as time allows. Thanks for some insight. Edited October 27, 2018 by SeraphimKensai Link to comment Share on other sites More sharing options...
Evangela Posted October 28, 2018 Share Posted October 28, 2018 Maybe this for the random target thing? https://www.creationkit.com/index.php?title=FindRandomReferenceOfAnyTypeInListFromRef_-_Game Link to comment Share on other sites More sharing options...
SeraphimKensai Posted October 28, 2018 Author Share Posted October 28, 2018 That looks promising. I'm going to check on it hopefully this Sunday afternoon trying to find time between work, the Vikings and Red Dead Redemption 2. Thanks again. Link to comment Share on other sites More sharing options...
SeraphimKensai Posted November 2, 2018 Author Share Posted November 2, 2018 Following up, Rasikko, using the random type instead worked great from my initial testing. Then I realized my script was firing the effects even after the object despawned, so I made a state to bump to from OnUpdate once a count is full to avoid that (so that works well). Otherwise, I'm still trying to figure out perhaps a more effective method of targeting any actor, that would somehow be compatible with any mod added actor. Ishara's method works, but trying to guess exactly what mods someone might be using or might not be is kind of less efficient than I hope to find. I wonder if adjusting the target type from a list of actors, to looking for races, such might work better or at all? As always thanks for the help, I might not have the most time to work on this stuff, or any particular talent, but it's definitely a learning experience. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 2, 2018 Share Posted November 2, 2018 I'm wondering if you couldn't do one of those "cloaking abilities" that can reach out and do something to all nearby actors. Each actor can be checked for whatever required things you need and they then added to your formlist for use with the object casting a spell at "random" targets. The following touches on it a bit (its the only place I know of that explains how to do any of it, there could be other more specific tutorials somewhere): https://www.creationkit.com/index.php?title=Dynamically_Attaching_Scripts Link to comment Share on other sites More sharing options...
SeraphimKensai Posted November 2, 2018 Author Share Posted November 2, 2018 I'll check that out, because even if it didn't work with mod added actors it sounds like it has the opportunity to reduce bloat of having essentially every vanilla actor loaded into a FormList. Thanks Ishara. Link to comment Share on other sites More sharing options...
SeraphimKensai Posted November 2, 2018 Author Share Posted November 2, 2018 I'm sitting on a lunch break at work, but I was thinking about this dilemma regarding allowing targeting from mod added actors using the FindRandomReferenceofAnyTypeinListFromRef, and stumbled on FindRandomActorFromRef. Now since I'm at work, I haven't had a chance to test this, but I'm thinking that this might cover both the random targeting that I want, but also allow any actor to be a potential target, thus fulfilling my desire for maximum compatibility.Once I get off work, I will test this and verify, posting whether or not it works, so as to document this for anyone down the road trying to do something similar. https://www.creationkit.com/index.php?title=FindRandomActorFromRef_-_Game Link to comment Share on other sites More sharing options...
SeraphimKensai Posted November 4, 2018 Author Share Posted November 4, 2018 (edited) So for those interested, the FindRandomActorFromRef worked great for randomly targeting npcs from both vanilla and those added by mods, so that way it's possible to do this without having to manually account for any potential mods that introduce NPC's. I'll be uploading the next version of my spell pack pretty soonish (looking to have it out probably by November 15th), which will have the fully functional floating turrets I've been working on along with a whole slew of other things. As always, thanks. Edited November 4, 2018 by SeraphimKensai Link to comment Share on other sites More sharing options...
Recommended Posts