Hi, I am not going to write a full script for you beceaus eI don’t know your setting, I am going to give you pointer:
the 5% chances nothing to say about it
if(!Random(20))
the spawn of the NPC :
Use a marker to mark it has spawned. If it’s intra one module you can use SetLocalInt(GetModule(),…
if it can spawn across different modules in a same campaign use a GlobalInt.
You can also use SetLocalObject or SetGlobalObject and check its existence.
object oNPC;
if(!GetGlobalInt("MyNpcIsOn")){
SetGlobalInt("MyNpcIsOn",TRUE);
oNPC = CreateObject(OBJECT_TYPE_CREATURE,sResRef,lLoc,FALSE,MyNewTag);
}
Now depending on what you want to do if you don’t want the NPC to move one he is in place :
if(GetGlobalInt("MyNpcIsOn")) return;
If you want your NPC to move inside one module you can use the Jump function.
If you want your NPC to move across different module you ll have to destroy it and recreate it.
if(GetGlobalInt("MyNpcIsOn") && !GetIsObjectValid(GetObjectByTag("MyNPC")) {
//here you know your NPC has been spawn once but it s not alive in the module where you are.
//you may want to put a marker for death.
}
For the conversion if it’s inside one module a module conversation will work.
if its cross module you’ll have to use a campaign conversation.
What you want to do is easy but require to be “fluent” with NWN script. It’s a good exercice to becommes more proficient with it.
You need to :
1 check the condition for it to be here.
2 check its existence
3 put a mark for its death
4 if he al rdy exist and has not been slain move it around by despawning him and making him again, or by jumping around.
5 be carefull where you store your indicator, if its inside a single module no much problem, if its cross module you need to be sure to store your value in var that are cross module.
Don’t use campaign var they are not tied to save game.