WoR_PRC8/_module/nss/keymaker.nss
Jaysyn904 b5e28e52f4 Initial commit
Initial commit [1.18]
2025-04-03 11:49:34 -04:00

38 lines
1.2 KiB
Plaintext

void main()
{
object oUser= GetItemActivator();
object oAct= GetItemActivated();
object oTarget= GetItemActivatedTarget();
location lTar= GetItemActivatedTargetLocation();
string sItem= GetTag(oAct);
location lUser= GetLocation(oUser);
//Somehow mesh this into your activate item system
if(sItem == "keymaker")
{
//there must be a safe instance of the base item somewhere in the module
//to copy from.
if((GetObjectType(oTarget)!=OBJECT_TYPE_DOOR)&&(GetObjectType(oTarget)!=OBJECT_TYPE_PLACEABLE))
{
FloatingTextStringOnCreature("The target is not an object with a lock", oUser, FALSE);
return;
}
if((GetLockLockable(oTarget)==FALSE))
{
FloatingTextStringOnCreature("The target cannot be locked", oUser, FALSE);
return;
}
if((GetLockKeyTag(oTarget)==""))
{
FloatingTextStringOnCreature("A key cannot be created for the target", oUser, FALSE);
return;
}
string sTag= GetLockKeyTag(oTarget);
object oSource= GetObjectByTag("MAGIC_KEY");
object oCreated= CopyObject(oSource, GetLocation(oUser), oUser, sTag);
FloatingTextStringOnCreature("A key has been created", oUser, FALSE);
}
}