Initial upload
Initial upload
This commit is contained in:
135
_module/nss/spawn_scribe_onc.nss
Normal file
135
_module/nss/spawn_scribe_onc.nss
Normal file
@@ -0,0 +1,135 @@
|
||||
void ReturnAll(object oTarget);
|
||||
|
||||
void main()
|
||||
{
|
||||
object o = OBJECT_SELF;
|
||||
object oPC = GetLastClosedBy();
|
||||
object oS = GetNearestObjectByTag("d_scribe", o);
|
||||
object oTarget, oSpawn;
|
||||
location lTarget;
|
||||
int nUse = GetLocalInt(o, "IN_USE");
|
||||
int c = GetLocalInt(oPC, "DESC_USER");
|
||||
int i;
|
||||
|
||||
object oItem = GetFirstItemInInventory(o);
|
||||
while(GetIsObjectValid(oItem))
|
||||
{
|
||||
if(GetIsObjectValid(oItem))
|
||||
{
|
||||
i +=1;
|
||||
}
|
||||
oItem = GetNextItemInInventory(o);
|
||||
}
|
||||
|
||||
//If there are 1 ore more items in the container
|
||||
if(i>=1)
|
||||
{
|
||||
if(nUse!=1)
|
||||
{
|
||||
if(oS==OBJECT_INVALID)
|
||||
{
|
||||
|
||||
//Set that the PC who used it last is the person spawning in the scribe!
|
||||
SetLocalInt(oPC, "DESC_USER", 1);
|
||||
SetLocalInt(o, "IN_USE", 1);
|
||||
|
||||
//Prevent permanent lock...
|
||||
DelayCommand(600.0, SetLocalInt(o, "IN_USE", 0));
|
||||
|
||||
oTarget = oPC;
|
||||
|
||||
lTarget = GetLocation(oTarget);
|
||||
|
||||
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "d_scribe", lTarget);
|
||||
|
||||
oTarget = oSpawn;
|
||||
|
||||
DelayCommand(0.5, AssignCommand(oTarget, ActionStartConversation(oPC, "")));
|
||||
|
||||
int nInt;
|
||||
nInt = GetObjectType(oTarget);
|
||||
|
||||
if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_GOOD_HELP), oTarget));
|
||||
else DelayCommand(0.4, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_GOOD_HELP), GetLocation(oTarget)));
|
||||
}
|
||||
}
|
||||
//If the box is not empty, and the box is in use..
|
||||
//Obviously the user has errored, so let's start over!
|
||||
else
|
||||
{
|
||||
//Kill the scribe if she exist!
|
||||
if(oS !=OBJECT_INVALID)
|
||||
{
|
||||
SetPlotFlag(oS, FALSE);
|
||||
DestroyObject(oS, 0.0f);
|
||||
}
|
||||
|
||||
object oO = GetFirstObjectInArea(GetArea(OBJECT_SELF));
|
||||
while(GetIsObjectValid(oO))
|
||||
{
|
||||
if(GetLocalInt(oO, "DESC_USER")==1)
|
||||
{
|
||||
AssignCommand(o, ActionSpeakString("You must start over!", TALKVOLUME_TALK));
|
||||
ReturnAll(oO);
|
||||
//Reset the chest and the PC.
|
||||
SetLocalInt(oPC, "DESC_USER", 0);
|
||||
SetLocalInt(o, "IN_USE", 0);
|
||||
return;
|
||||
}
|
||||
oO = GetNextObjectInArea(GetArea(OBJECT_SELF));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//If the box is empty!
|
||||
else
|
||||
{
|
||||
//If it's the original user closing it...
|
||||
if(c==1)
|
||||
{
|
||||
//If there are no more items in the container!
|
||||
if(i==0)
|
||||
{
|
||||
//clear all variables & remove them as the user..
|
||||
SetLocalInt(oPC, "DESC_USER", 0);
|
||||
SetLocalInt(o, "IN_USE", 0);
|
||||
|
||||
//Kill the scribe if she exist!
|
||||
if(oS !=OBJECT_INVALID)
|
||||
{
|
||||
SetPlotFlag(oS, FALSE);
|
||||
DestroyObject(oS, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
//If it's not the original user, then tell them how to use it!
|
||||
else
|
||||
{
|
||||
//If there are no items in the box (dbl check)
|
||||
if(i==0)
|
||||
{
|
||||
AssignCommand(o, ActionSpeakString("You must place at least 1 item inside to use this device!", TALKVOLUME_TALK));
|
||||
}
|
||||
|
||||
//Kill the scribe if she exist!
|
||||
if(oS !=OBJECT_INVALID)
|
||||
{
|
||||
SetPlotFlag(oS, FALSE);
|
||||
DestroyObject(oS, 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReturnAll(object oTarget)
|
||||
{
|
||||
object o = GetFirstItemInInventory(OBJECT_SELF);
|
||||
while(GetIsObjectValid(o))
|
||||
{
|
||||
AssignCommand(OBJECT_SELF, ActionGiveItem(o, oTarget));
|
||||
|
||||
o = GetNextItemInInventory(o);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user