95 lines
2.8 KiB
Plaintext
95 lines
2.8 KiB
Plaintext
|
// script for detecting hidden objects (not doors)
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
|
||
|
object oPC=GetEnteringObject();
|
||
|
|
||
|
/// if I have been triggered or somehow the PC is not valid, return
|
||
|
if ((GetLocalInt(OBJECT_SELF,"triggered")==TRUE)||(!GetIsObjectValid(oPC)))
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// if the entering object is not a PC and neither is its master, return. NB this
|
||
|
// does allow familiars to find things
|
||
|
if ((!GetIsPC(oPC))&&(!GetIsPC(GetMaster(oPC))))
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// We get the search skill of the entering object
|
||
|
int nSkill=GetSkillRank(SKILL_SEARCH,oPC);
|
||
|
|
||
|
//if the skill is untrained, just return
|
||
|
if (nSkill==-1)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// sMyTag refers to the CODE which tells us what secret door to use
|
||
|
// sTag refers to the resref of the object we want to make
|
||
|
// sWayTag is the tag of the waypoint it should appear at. It is the tag
|
||
|
// of the hidden object with _appear_wp after it.
|
||
|
|
||
|
string sMyTag = GetTag(OBJECT_SELF);
|
||
|
|
||
|
// get how long the tag of the trigger is
|
||
|
int nLength = GetStringLength(sMyTag);
|
||
|
|
||
|
// the tag must begin secrdr_ which is 7 letters. Then we want to get the next two
|
||
|
// this should give us the tag of the object we are trying to make
|
||
|
string sCode=GetSubString(sMyTag,7,2);
|
||
|
|
||
|
// sCode currently gives us our code. sTag will give us the res ref of the hidden door
|
||
|
string sTag="jw_secret_"+sCode+"_dr";
|
||
|
|
||
|
// This gives us the tag of the waypoint it should appear at
|
||
|
string sWayTag=sMyTag+"_apr_wp";
|
||
|
// DEBUG
|
||
|
//SpeakString (sWayTag);
|
||
|
|
||
|
// This is the location of the waypoint
|
||
|
location locLoc = GetLocation (GetWaypointByTag(sWayTag));
|
||
|
|
||
|
// This gives us the tag of the waypoint the door leads to
|
||
|
string sLeadsTo=sMyTag+"_DST";
|
||
|
|
||
|
// the DC is put into the key tag field in the trigger.
|
||
|
string sDC=GetTrapKeyTag(OBJECT_SELF);
|
||
|
int nDC=StringToInt(sDC);
|
||
|
// DEBUG
|
||
|
//SpeakString (sDC);
|
||
|
|
||
|
// we have a D20 dice roll which is added to the search skill
|
||
|
int nMod = d20();
|
||
|
|
||
|
int nTotalSkill=nSkill+nMod;
|
||
|
|
||
|
// did we find it.
|
||
|
if (nTotalSkill>=nDC)
|
||
|
{
|
||
|
|
||
|
object oItem;
|
||
|
// yes we found it, now create the object itself.
|
||
|
oItem = CreateObject(OBJECT_TYPE_PLACEABLE,sTag,locLoc,TRUE);
|
||
|
|
||
|
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_IMP_KNOCK),locLoc);
|
||
|
FloatingTextStringOnCreature("You spot a hidden door",oPC);
|
||
|
|
||
|
// set a local int on the object for clean up purposes
|
||
|
SetLocalInt(oItem,"jw_hidden_int",TRUE);
|
||
|
|
||
|
// Set a local location onto the hidden door so it knows where it leads to
|
||
|
SetLocalString(oItem, "sLeadsTo", sLeadsTo);
|
||
|
|
||
|
// Register that the hidden object has been found and cannot be found again
|
||
|
SetLocalInt(OBJECT_SELF,"triggered",TRUE);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|