Jump to content

Need Some help spawning npcs.


Gruffys

Recommended Posts

The examples i used were based on making the 'Spawn Child' to have a 3% chance, so your suggestion/observation:

Int RWolf = Utility.RandomInt(0, 1)

Will make it to have a 50% chance, so in a few words, yes.


For this you can use the last example and just change the "Int Value" from the script's property, from its default 2 to 1, this way you have one script that can be used with multiple creatures and multiple creatures having different "Int Values", meaning = different Chances to spawn a child using the same script.


* As for performance, this is 1000 times faster and safer than having a 'While Loop'.


* Always have one thing in mind when creating scripts, big or complex scripts does not mean better, better is to safely do something using the less amount of system resources as possible, when of course this is doable.

Edited by maxarturo
Link to comment
Share on other sites

I made a stupid 'Typo' mistake in my previous post.

"from its default 2 to 1"


I actually meant:

from its default 2 to 50


Sorry about that...





"Does If ( RWolf <= SpawnMaximum ) get the script to run however many time is defined in the SpawnMaximum Int in order to spawn a wolf or does the script just take the Int and calculate the result once?"



The script runs only one time whenever the "Scripted Ability" is executed, this means that when the wolf get loaded the ability will calculate the chance to spawn the 'Child' based on the "SpawnMaximum".


The "RandomInt()" generates a random number and if that number is equal or less than the "SpawnMaximum" it will place a 'Child', otherwise it will do nothing.


NOTE 1: If the wolf isn't killed and you leave the cell and then return again ( the wolf gets unloaded / loaded ), the 'Scripted Ability' will execute once again and so on...


NOTE 2: The script fires only when the 'Scripted Ability' executes and no more after the wolf gets loaded, if we count in seconds for how much time the script is running the time is LITERALLY MILISECONDS, as for using a 'While Loop" that it will run continuously until the condition is meat, this means tension on the system, which is unnecessary if it can be done in a more fast and safest way.



I hope it helps.

Edited by maxarturo
Link to comment
Share on other sites

Thanks for the update max, I presumed you meant 50 and not 2 so its no problem. Your way is a much better and more flexible way to alter the spawn rate than changing Int RWolf = Utility.RandomInt(0, 1) as my way would only allow you a max 50% spawn rate before it becomes 100%.

 

I added the script to the base wolf Npc and set the spawn rate at 100 to see what it would be like at max and having spent the last couple of days running around the plains while I tested and textured my deer has given me a good idea of overall performance. Its running really great even at 100% and because I've setup a package for them to follow the wolf that spawned them you always see them where you would expect.

 

Having done a bit of testing with it now I think a spawn rate of 10 might be the best value to set the script too. Thank you so much again for doing all the heavy lifting and teaching me a little about how scripting works :)

Link to comment
Share on other sites

Alright my friend, good to see you testing your mod heavily, which is something you should always do, after all we are only humans and we do mistakes, and sometimes... stupid ones !!.


* Send me a link whenever you are done with it.


Have a happy modding.

Edited by maxarturo
Link to comment
Share on other sites

Thanks max, I will. I've also discovered a little workaround for our original script, while I can not add scripts to actors in level lists within the CK there's nothing stopping me from adding it them to actors in Xedit.

 

I've tried this out and the scripts run fine. Would you say that the first script you made was more safe to use if I wanted to use it on a lot of actors?

 

I'm going to try my hand at creating another little script just for the baby animals in order to have them grow up into adults once a certain number of hours has passed. I can imagine few people will want to kill the babies as they are pretty cute and pose no threat to the character so eventually there needs to be a way to have the player kill them off.

 

I presume it is possible to script something that will basically spawn an actor and then remove the one that spawned it immediately?

Link to comment
Share on other sites

Although theoretically is safe using multiple times by multiple actors any of the register function:

RegisterForSingleUpdateGameTime()

RegisterForSingleUpdate()

RegisterForUpdate()

RegisterForAnimationEvent()

RegisterForLOS()

RegisterForSingleLOSGain()

RegisterForSingleLOSLost()

RegisterForSleep()

RegisterForTrackedStatsEvent()


There is one big drawback, and that is the high possibility of corruption of the save file when the mod is uninstalled, especially if those functions have a lot of registers inside the save file.


The Skyrim game engine does not support the uninstallation of a mod and although there are tools to clean the save file, things like 'Register' function are not cleaned by those tools.


Unfortunately 99% of players are completely uneducated in the way of how this game engine works and your mods must be done in such a way to avoid as much as possible causing the player issues that they don't know and understand.


But "As Much As Possible", if we were to completely protect the player then no mods would ever be possible to be created !, in the end its in the player's hand and responsibility to educate himself.



That being said, i personally would avoid using the "Chicken" script in a lot of animals and i would place it in a few and targeted one, in those that the player is more likely to encounter / see / interact with, just for 'Fail Safe' and optimization.


But that's just me, this decision and responsibility is entirely up to you.


"I presume it is possible to script something that will basically spawn an actor and then remove the one that spawned it immediately?"

Yes it's possible, you can even make the initial baby animal to grow a little (in size) before it actually spawns its replacer, and so on...

Give it a try and if you need help, ask for it !, except me there are other too that can give a hand.



NOTE: Don't EVER add to your mod's description page this kind of info and how the mod or the game engine works or how to safely uninstall it, player will think that is a too demanding and unsafe mod !.


I did the mistake to try to educate players by posting detailed info on how to "Safely Install and Uninstall a Mod" and how the game works and the result was that:

- Until now i've received more than 200+ messages (basically i've lost count...), asking me why is this mod so demanding and dangerous !, while all of them had completely missed (intentional or unintentional, i don't know...) the part that says: "This applies to All Mods and not just to this one".

The end result is that the mod has being marked as "Dangerous" in the mind of the players.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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