Jump to content

Not sure if this is possible with scripting - Spawning NPCs near statics ingame. (critter MOD wip)


dirtfoot84

Recommended Posts

So, my dilemma here is that I have working snail NPC actors that I have singled out from the Beasts of Tamriel mod with permission from the mod creators (SpikeDragonLord and Jboyd4). I would like to place them into the game using scripts rather than just hand place them, which would take quite some time, but still is a possibility if this scripting isnt possible.

 

I would attach my script to something such as Cabbage, or mushrooms within the game, but Id rather not interfere with that item itself as it can negatively effect other mods.

 

My question is, is it possible to create a script that will Spawn the snail NPC near mushrooms and cabbages, without me having to attach a script to those mushrooms and cabbages?

 

To clarify, let's say I enter Riverwood. In Riverwood there is a small farm behind the Sleeping Giant Inn that has several cabbages.

 

My first idea was to create a script attached to those cabbages which would, when the cabbages are loaded using the OnLoad event, then the script would spawn a snail near that cabbage. I'm not familiar enough with scripting beyond the PlaceAtMe function, I have no idea to tell the script where the said cabbage is and that there is where I would like to spawn the snail.

 

Not only that, I realized that cabbages are a type of TREE and I was unable to attach a script to them.

 

Foremost, I would rather not attach scripts to base items, as I have done with my Firefly mod (attached script to all mushroom flora). This can conflict with other mods. I would much rather prefer some way of spawning in the snails to cabbages/mushrooms in a safer manner. Besides using trigger boxes, onload events, Im at a loss of understanding.

 

 

HOWEVER - I have seen an example of what I want to happen in the mod SkyBirds, where nests are spawned dynamically near trees. I have no idea how to do such a thing, nor how that script becomes active in the first place.

 

Hope to hear any kind of help on this issue, as it is I will continue to scan through script examples and native scripts for some kind of example to use. Thanks!

 

Link to comment
Share on other sites

UPDATE

 

I found a very simple script to spawn an NPC near an object, however it is still a script attached to the mushroom flora.

Script is exactly as follows:

 

Scriptname _bdgray02_snailspawner extends ObjectReference
actorbase property SnailNPC auto
Event OnLoad()
self.placeatme(SnailNPC)
EndEvent
--------------
What it does is basically, when the object (mushrooms) load, they spawn the snail at their location.
Huge milestone for me at the moment, will still be looking for ways to spawn them in without the need of attaching a script directly to the object.
Link to comment
Share on other sites

If you don't want to pre-place the snails, you'll need to pre-place an xMarker wherever you want the snails to appear.

If you duplicate the existing xMarker base object and name it so others will know it is part of your mod, you can simply apply your script in the post above to the base record rather than applying it to every placed instance.

 

EDIT: One thing to be concerned about, is your script above will always load a new snail whenever the cell is loaded. In a long game, this might yield a lot of snails crawling around which may tax one's system. You may wish to limit the amount of snails it spawns or have some means of causing the snail to be removed when the cell is unloaded.

Edited by IsharaMeradin
Link to comment
Share on other sites

Thank you for the reply Ishara.

 

I added a simple script directly to the snailNPC that uses OnUnload and the an event to disable and delete.

 

It is as follows:

 

Scriptname _bdg_snail_script extends ObjectReference
Event OnUnload()
Disable()
Delete()
EndEvent
---------------------------
It works as far as I can tell and allows the spawner (mushrooms) to have a snail around at all times, and deletes the previous NPC on unloading.
For what it is, it works. I just dont like having attached a script to a base object. Also, I understand the xmarker advice but that would still require me to hand place an Xmarker at each location, correct?
Im also looking for a way to "bump" the snails up out of the ground after they spawn. Apparently there is a ModPos command you can use to move something on its axis by increments, but it is new to FallOut4 and doesnt work with Skyrim creation kit. So as it is, my snails sometimes appear underground.
Thanks for your help I will post any updates.
Link to comment
Share on other sites

Another update, I had released my Snails mod to Nexus, then a few hours later I noticed I was having CTD issues when fast traveling to Riverwood. I disabled my snails mod and the CTD issue went away. I am guessing something to do with the script was causing some huge issues, so for now I will just settle with hand placing snails as to avoid the scripting issues until I have more knowledge.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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