Jump to content

[LE] Is Object in Container?


Kapteyn

Recommended Posts

This is the sort of thing you should be using a quest to do. As the player is changing locations stop and restart the quest so that it fills its aliases with on common things like animals, clutter, flora, etc. Put your script on the quest itself and let it pick one of the filled aliases as the base location for whatever you want to do. You can trigger the quest with the story manager, another quest, or even an alias on the player. (It's possible for a quest to stop and restart itself.)

Link to comment
Share on other sites

I don't know anything about making quests, which is why I'm going the long way about it, it's the only way I know at the moment. I guess that's the next thing I need to look at.

 

I think the wildlife is going to work just fine so far as the outside world is concerned, and including a few things which show up in dungeons. I've condensed everything into one script now based on a magic effect, so once it has dispelled the only single form list used wouldn't be attached to anything (at least I hope not). So what I'm interested in now is placing ambushes in forts and caves.

 

I'm wondering now about the moths and butterflies. They already have scripts attached to them, I suppose I could modify the critter script itself to do what I want them to do. It already has a form list on it so I wouldn't exactly be adding anything to the save file. I dunno if other mods screw around with the critter script or what.

Edited by Kapteyn
Link to comment
Share on other sites

Okay, I get it now.

 


ObjectReference Something = Game.FindClosestReferenceOfTypeFromRef(Game.GetForm(0x7), akCaster, 500)

If Something
Something.AddItem(Game.GetForm(0xF),1)
EndIf

 

So every time I walk past a deer, it gives me money. :smile:

 

All I need to do now is trash this thing about putting scripts on animals and run a quest for it.

Link to comment
Share on other sites

No, don't use FindClosestReferenceOfTypeFromRef use the more powerful and faster feature of quest aliases. You're thinking too much like a programmer.

 

Using the quest is extremely easy. First you create a quest. Then you create one or more aliases, tag those as optional, choose to have them fill by things near the player (or in the loaded cells), and add whatever conditions you want. In the quest script's OnInit block you can test to see if the aliases have a reference filling them and do whatever you want with what they find.

 

The trick for your purpose is finding some event which will stop and restart the quest. You could use the story manager (one more thing to learn), use the events like OnLocationChanged, or even just use OnUpdate to stop and restart the quest every few minutes (using a random number for the registration if you really want it to be unpredictable).

 

The key is that when a quest starts it tries to fill its aliases and that's the most powerful, flexible, and easiest way to find things that happen to be near the player at any arbitrary time.

Link to comment
Share on other sites

What I did above is exactly what Genesis does. In that function it uses a form list, in fact it has form lists for hundreds upon hundreds of objects which it uses as objects to place spawns at. Of course, it's very well using similar methods but what I don't want is for my mod to be almost identical, so I have to be careful with this.

 

So as the quest alias, I could use a form list - or am I having to define every object I want to test against? I guess testing stuff would be a good way to start figuring that out.

Link to comment
Share on other sites

What I did above is exactly what Genesis does. In that function it uses a form list, in fact it has form lists for hundreds upon hundreds of objects which it uses as objects to place spawns at. Of course, it's very well using similar methods but what I don't want is for my mod to be almost identical, so I have to be careful with this.

 

So as the quest alias, I could use a form list - or am I having to define every object I want to test against? I guess testing stuff would be a good way to start figuring that out.

 

You can conditionally fill aliases, and you have access to a number of conditions to do it (listed here: https://www.creationkit.com/index.php?title=Category:Condition_Functions). Some of those conditions are unique tests you cannot execute easily (if at all) in Papyrus. There's also some stuff on the Alias tab that can be used to further refine things, such as limiting the search to stuff in the loaded area and/or finding the thing closest to the player. You can also search as a batch, so this is the ideal way to find all items closest to the player and matching a certain set of conditions.

Link to comment
Share on other sites

Alright, well it's a good thing that I've got rid of a lot of properties being stored in the save file... but next I need to start looking into building it all around a hidden quest (as for a proper lore-based quest, that's something to consider later on). It'll probably involve overhauling everything I've done so it's gonna take some time.

 

I really appreciate the help I've had with this, I guess some are just nice like that but it also goes to show that people feel it is important for mods to be stable and cross-compatible.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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