Initial upload
Initial upload. PRC8 has been added. Module compiles, PRC's default AI & treasure scripts have been integrated. Started work on top hak for SLA / Ability / Scripting modifications.
This commit is contained in:
247
_module/nss/jw_trap_trig_hb.nss
Normal file
247
_module/nss/jw_trap_trig_hb.nss
Normal file
@@ -0,0 +1,247 @@
|
||||
|
||||
|
||||
int getdifficulty (string sDiff)
|
||||
|
||||
{
|
||||
|
||||
// works out the modified for xp, based on the difference between the player or average party level and
|
||||
// the cr of the mob.
|
||||
|
||||
int nDC;
|
||||
|
||||
if (sDiff=="1")
|
||||
{
|
||||
nDC=15;
|
||||
}
|
||||
|
||||
if (sDiff=="2")
|
||||
{
|
||||
nDC=20;
|
||||
}
|
||||
|
||||
if (sDiff=="3")
|
||||
{
|
||||
nDC=25;
|
||||
}
|
||||
|
||||
if (sDiff=="4")
|
||||
{
|
||||
nDC=30;
|
||||
}
|
||||
|
||||
if (sDiff=="5")
|
||||
{
|
||||
nDC=35;
|
||||
}
|
||||
|
||||
return nDC;
|
||||
}
|
||||
|
||||
//::///////////////////////////////////////////////
|
||||
//:: Creates a trap effect
|
||||
//:: V 1.2
|
||||
//:: Copyright (c) 2003 Jonathan Walker.
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
This Invisable object will do a check and see
|
||||
if any pc comes within a radius of this object.
|
||||
|
||||
If the PC has the search skill or is a elf then
|
||||
a search check will be made.
|
||||
|
||||
It will create a trapped trapdoor at its own location
|
||||
|
||||
The radius is 10
|
||||
The DC to detect and disarm is determined by the tag given to this trigger
|
||||
it creates a trapdoor with the first nine letters of its own tag + _plate
|
||||
So it would be jw_trap_1_plate, jw_trap_2_plate etc
|
||||
If this trigger has local int "triggered" set to true, then it returns;
|
||||
The difficulty of spotting the trap is determined by the ninth letter in the tag.
|
||||
Eg jw_trap_1 is the easiest jw_trap_5 is the hardest
|
||||
The trap that is created has three local variables given to it
|
||||
"creator", a string that refers to this trigger.
|
||||
"diff", a string that refers to the difficulty, from 1 to 5
|
||||
This will determine the DC to disarm the trap, the DC to detect it, and the amount of damage done
|
||||
"type", a sting that tells it what type of trap it is
|
||||
The type is determined by the tenth letter of the tag of this trigger
|
||||
eg jw_trap_1_f - f is the 11th letter and means that this is a fire trap
|
||||
f=fire
|
||||
s=spikes
|
||||
a=acid
|
||||
e=elec
|
||||
n=negative
|
||||
c=cold
|
||||
o=sonic
|
||||
|
||||
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Created By: Robert Babiak
|
||||
//:: Created On: June 25, 2002
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
// what is the tag of this object used in setting the destination
|
||||
string sMyTag = GetTag(OBJECT_SELF);
|
||||
string sTag=GetStringLeft(sMyTag,9);
|
||||
string sDiff=GetSubString(sMyTag,8,1);
|
||||
string sType=GetSubString(sMyTag,10,1);
|
||||
int nMod;
|
||||
location locLoc = GetLocation (GetNearestObjectByTag("jw_traplocation_wp"));
|
||||
float fFacing;
|
||||
vector vVector;
|
||||
vector vTestVec=GetPositionFromLocation(locLoc);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if the trap is supposed to be rest because nReset==1, then remove the trapdoor is it exists
|
||||
|
||||
int nDone = GetLocalInt(OBJECT_SELF,"done");
|
||||
int nReset = GetLocalInt(OBJECT_SELF,"Reset");
|
||||
|
||||
// ok reset the trapdoor is destroyed, and the done and reset flas are made 0 again
|
||||
if (nReset == 1)
|
||||
{
|
||||
nDone = 0;
|
||||
nReset = 0;
|
||||
|
||||
SetLocalInt(OBJECT_SELF,"done",nDone);
|
||||
SetLocalInt(OBJECT_SELF,"Reset",nReset);
|
||||
SetLocalInt(OBJECT_SELF,"triggered",FALSE);
|
||||
|
||||
object oidDoor= GetLocalObject(OBJECT_SELF,"Door");
|
||||
if (oidDoor != OBJECT_INVALID)
|
||||
{
|
||||
SetPlotFlag(oidDoor,0);
|
||||
DestroyObject(oidDoor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if the trap has been triggered already, just return
|
||||
|
||||
|
||||
if (GetLocalInt(OBJECT_SELF,"triggered")==TRUE)
|
||||
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the trap has been found already then there is nothing more for this trigger to do so return
|
||||
|
||||
if (nDone==1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// check if there are any PCs around that ought to be seeing it
|
||||
|
||||
//get the radius and DC of the secret door.
|
||||
|
||||
// DEBUG
|
||||
//SpeakString("starting to check PCs");
|
||||
|
||||
float fSearchDist = 10.0;
|
||||
int nDiffaculty = getdifficulty ( sDiff );
|
||||
|
||||
|
||||
int nBestSkill = -50;
|
||||
object oidBestSearcher = OBJECT_INVALID;
|
||||
int nCount = 1;
|
||||
|
||||
// Find the best searcher within the search radius.
|
||||
object oidNearestCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
|
||||
|
||||
while ( ( nDone == 0 ) &&
|
||||
( oidNearestCreature != OBJECT_INVALID )
|
||||
)
|
||||
{
|
||||
// what is the distance of the PC to the door location
|
||||
float fDist = GetDistanceBetween(OBJECT_SELF,oidNearestCreature);
|
||||
|
||||
if ( fDist > fSearchDist )
|
||||
|
||||
{
|
||||
nDone = 1;
|
||||
}
|
||||
|
||||
if ( fDist <= fSearchDist )
|
||||
{
|
||||
int nSkill = GetSkillRank(SKILL_SEARCH,oidNearestCreature);
|
||||
|
||||
// ok we have a searcher who is within range - now check if they found it
|
||||
if ( ( nDone == 0 ) &&
|
||||
( GetIsObjectValid( oidNearestCreature ) )
|
||||
)
|
||||
{
|
||||
nMod = d20();
|
||||
|
||||
// DEBUG
|
||||
// SendMessageToPC(oidNearestCreature,"checking you");
|
||||
|
||||
|
||||
// did we find it.
|
||||
if ((nSkill +nMod > nDiffaculty))
|
||||
{
|
||||
// DEBUG
|
||||
//SendMessageToPC(oidNearestCreature,"you found it");
|
||||
|
||||
|
||||
object oidDoor;
|
||||
// yes we found it, now create a trap door for us to use. it.
|
||||
|
||||
//vVector=GetPosition(oidNearestCreature);
|
||||
|
||||
oidDoor = CreateObject(OBJECT_TYPE_PLACEABLE,sTag+"_plate",locLoc);
|
||||
|
||||
vVector=GetPosition(oidNearestCreature);
|
||||
vVector=vTestVec+(vTestVec-vVector);
|
||||
//vVector=vTestVec-vVector;
|
||||
|
||||
AssignCommand(oidDoor,SetFacingPoint(vVector));
|
||||
|
||||
|
||||
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_IMP_KNOCK),GetLocation(oidDoor));
|
||||
FloatingTextStringOnCreature("Discovered a trap on the ground",oidNearestCreature);
|
||||
|
||||
// DEBUG
|
||||
//SendMessageToPC(oidNearestCreature,"trying to create "+sTag+"_plate");
|
||||
|
||||
/// instantly tell the finder that it is trapped.
|
||||
SetTrapDetectedBy(oidDoor,oidNearestCreature);
|
||||
|
||||
|
||||
// make this door as found.
|
||||
SetLocalInt(OBJECT_SELF,"done",1);
|
||||
SetPlotFlag(oidDoor,1);
|
||||
SetLocalObject(OBJECT_SELF,"Door",oidDoor);
|
||||
|
||||
// give the trap door its variables
|
||||
SetLocalObject(oidDoor,"creator",OBJECT_SELF);
|
||||
SetLocalString(oidDoor,"diff",sDiff);
|
||||
SetLocalString(oidDoor,"type",sType);
|
||||
|
||||
// make the trapdoor turn around
|
||||
//turnaround (oidDoor);
|
||||
|
||||
nDone=1;
|
||||
|
||||
} // if skill search found
|
||||
|
||||
|
||||
|
||||
}
|
||||
nCount = nCount +1;
|
||||
oidNearestCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF ,nCount);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user