I don’t even know where to start - it seems the more I learn the more questions I have.
I want to use CR as a determining factor when it comes to the quantity and quality of loot drops. Is it possible to GetChallengeRating from a creature in its own OnDeath script? Or do I need to generate loot OnSpawn?
I need a way to return to a previous point in the script by line number. I kinda just assumed this was possible, but I can’t find which command it is.
Which command(s) to use to generate items? Non-stackables, stackables, gold, etc. NWN lexicon refers to CreateObjectVoid as well as CreateObject, for gp there is GiveGoldToCreature and I think there are also some commands for placing things in a given objects inventory, etc. I have too many choices and too little experience, so again, which command(s) to use to generate items?
As a general rule of thumb, OnDeath is best avoided when there is a better alternative such as OnSpawn. Many commands still work, but some, such as Actions, fail because the creature is dead.
You can use “while” for everything if you like, “for” and “do” are just alternative syntax for convenience.
CreateItemOnObject is the most general function for giving inventory to creatures or containers.
You use CreateObject for an item when you want to spawn it on the ground.
Gold is a special case because there are a few glitches in the object handling functions. Rather than trying to remember what they are, it’s probably safer to use GiveGoldToCreature etc.
Looping seems like it will do what I wanted to do with a goto. What happens if a return; command is encountered inside the loop? Will it end script like normal or start loop over?
In the main body of a script, return stops the script.
In a function, return stops the current function, breaking out of any loops in that function. It immediately returns control to the code that called the function… Any loops in the calling code continue.