These two scripts can be used for making
secret trapdoors or other hidden objects. When a PC comes near the secret
trap door a search check is made. If the check results in success a trapdoor
will appear. When clicked the trapdoor calls an area transfer.
First, use the Placeable Wiz to make a trapdoor. Don't place it in your
area. Edit the trapdoor (it will be somewhere in your custom palette) to run
this script 'OnUsed'.
NWScript: void main()
{
object oPC = GetLastUsedBy();
object oTarget = GetWaypointByTag( "wp_basement1");
AssignCommand( oPC, JumpToObject( oTarget));
}
Now when a player clicks the trapdoor they'll do an area transfer. Next drop
a waypoint in your area where you want the hidden trapdoor to be. Now set up
a general trigger that stakes out the detection radius for the trapdoor.
Drop this script in 'OnEnter'.
NWScript: int MyAutoDC(int DC, int nSkill, object oTarget)
{
int nLevel = GetHitDice( oTarget);
int nTest = 0;
switch (DC)
{
case 0: nTest = nLevel / 4 + 1; break;
case 1: nTest = (3 / nLevel + nLevel) - abs( (nLevel/2) -2); break;
case 2: nTest = FloatToInt( nLevel * 1.5 + 6) - abs( ( FloatToInt( nLevel/1.5) -2)); break;
}
if (GetSkillRank( nSkill, oTarget) + d20() >= nTest + 10)
return TRUE;
return FALSE;
}
int DoOnce()
{
int bResult = FALSE;
if ( GetLocalInt( OBJECT_SELF, "NW_L_DOONCE999") == 0)
{
SetLocalInt( OBJECT_SELF, "NW_L_DOONCE999", 1);
bResult = TRUE;
}
return bResult;
}
void main()
{
object oPC = GetEnteringObject();
location loc = GetLocation( GetNearestObjectByTag( "wp_trapdoor", oPC));
int nDC = 2;
if( GetIsPC( oPC) && MyAutoDC( nDC, SKILL_SEARCH, oPC))
{
while( DoOnce())
{
SendMessageToPC( oPC, "You've found something...");
CreateObject( OBJECT_TYPE_PLACEABLE, "cotrapdoor", loc, TRUE);
}
}
}
Both scripts compile and work as described for me. I hope others find the
same. I'm not sure about the AutoDC skill check function. Medium seems way
too easy and Easy is just a joke. I think I'll have it check PC level or
some other number instead of hit dice.
I think I put comments in at the couple of places where you'll want to
change tags to fit your modules. You'll want to change the way points and
the trapdoor template name for sure. Hope I didn't leave anything out. It's
5am here and the Coffee isn't cutting it anymore.
-Seek
.
EDIT: UPDATED
I had the skill check determining DC based on the level of the player that
was searching. This is obviously not the way to do it, so I made some (more)
changes to AutoDC().
This new script will check based on challenge level (int nDC: 0-easy,
1-medium, 2-hard) specified in main(). Also it takes into account the level
of the hidden object or the level of the hider if you want to think of it in
those terms (int nHiddenObjLevel).
NWScript:
int MyAutoDC( int DC, int nLevel, int nSkill, object oTarget)
{
int nTest = 0;
switch (DC)
{
case 0: nTest = nLevel / 4 + 1; break;
case 1: nTest = (3 / nLevel + nLevel) - abs( (nLevel/2) -2); break;
case 2: nTest = FloatToInt( nLevel * 1.5 + 6) - abs( ( FloatToInt( nLevel/1.5) -2)); break;
}
if (GetSkillRank( nSkill, oTarget) + d20() >= nTest + 10)
return TRUE;
return FALSE;
}
int DoOnce()
{
int bResult = FALSE;
if (GetLocalInt( OBJECT_SELF, "NW_L_DOONCE999") == 0)
{
SetLocalInt( OBJECT_SELF, "NW_L_DOONCE999", 1);
bResult = TRUE;
}
return bResult;
}
void main()
{
object oPC = GetEnteringObject();
location loc = GetLocation( GetNearestObjectByTag( "wp_trapdoor", oPC));
int nDC = 1;
int nHiddenObjLevel = 3;
if( GetIsPC( oPC) && MyAutoDC( nDC, nHiddenObjLevel, SKILL_SEARCH, oPC))
{
while( DoOnce())
{
SendMessageToPC( oPC, "You've found something...");
CreateObject( OBJECT_TYPE_PLACEABLE, "cotrapdoor", loc, TRUE);
}
}
}
Enjoy.
-Seek
|