Rune_PRC8/_module/nss/opw_lock_unlock.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

59 lines
1.4 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// Lock and Unlock City Gates
// opw_lock_unlock
// By Don Anderson
// dandersonru@msn.com
//
// Place this script in the Switch OnUsed Event
//
////////////////////////////////////////////////////////////////////////////////
void ActivateSwitch()
{
DelayCommand(0.1, PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
DelayCommand(2.0, PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE));
}
void main()
{
object oMech = OBJECT_SELF;
location lLoc = GetLocation(oMech);
string sGate; object oGate;
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 10.0, lLoc, TRUE, OBJECT_TYPE_DOOR);
while (GetIsObjectValid(oTarget))
{
sGate = GetName(oTarget);
if(sGate == "ORS_CityGate")
{
oGate = oTarget;
break;
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 10.0, lLoc, TRUE, OBJECT_TYPE_DOOR);
}
float fDist = GetDistanceBetween(oMech,oGate);
if(fDist <= 10.0)
{
ActivateSwitch();
string sLink = GetLocalString(oGate,"LINKED");
object oLinkedGate = GetObjectByTag(sLink);
int nLocked = GetLocked(oGate);
if(nLocked == FALSE)
{
SetLocked(oGate,TRUE);
SetLocked(oLinkedGate,TRUE);
SpeakString("City Gate is Locked!");
}
if(nLocked == TRUE)
{
SetLocked(oGate,FALSE);
SetLocked(oLinkedGate,FALSE);
SpeakString("City Gate is Unlocked!");
}
}
}