84 lines
1.9 KiB
Plaintext
84 lines
1.9 KiB
Plaintext
|
void main()
|
||
|
{
|
||
|
|
||
|
object oObject;
|
||
|
effect eEffect;
|
||
|
int nReflex;
|
||
|
int nDexbonus;
|
||
|
int nD20;
|
||
|
object oDog;
|
||
|
int nCounter;
|
||
|
int nDone=0;
|
||
|
|
||
|
|
||
|
// get the radius and DC of the trap.
|
||
|
float fSearchDist = 22.0;
|
||
|
int nDiffaculty = 32;
|
||
|
|
||
|
|
||
|
|
||
|
// Find the best creature within the trap radius
|
||
|
int nCount = 1;
|
||
|
object oidNearestCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
|
||
|
|
||
|
while ( ( nDone == 0 ) &&
|
||
|
( oidNearestCreature != OBJECT_INVALID )
|
||
|
)
|
||
|
|
||
|
// start the while loop
|
||
|
{
|
||
|
// what is the distance of the PC to the trap location
|
||
|
float fDist = GetDistanceBetween(OBJECT_SELF,oidNearestCreature);
|
||
|
|
||
|
|
||
|
|
||
|
// if the player is in range, then make the saving throw
|
||
|
|
||
|
if ( fDist <= fSearchDist )
|
||
|
{
|
||
|
int nReflex = WillSave(oidNearestCreature,nDiffaculty,SAVING_THROW_TYPE_POSITIVE);
|
||
|
// false if failed, true if succeeded
|
||
|
|
||
|
// If succeeded:
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectBeam(VFX_BEAM_MIND,oidNearestCreature,BODY_NODE_CHEST),OBJECT_SELF,5.0);
|
||
|
|
||
|
if (nReflex)
|
||
|
|
||
|
{
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
//but if fail:
|
||
|
|
||
|
else
|
||
|
|
||
|
{
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_IMP_PULSE_NEGATIVE),oidNearestCreature,5.0);
|
||
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectNegativeLevel(2),oidNearestCreature);
|
||
|
|
||
|
}
|
||
|
|
||
|
//end the if the player is in range sequence
|
||
|
}
|
||
|
|
||
|
//if the player was too far way, stop everything now
|
||
|
|
||
|
if ( fDist > fSearchDist )
|
||
|
|
||
|
{
|
||
|
nDone = 1;
|
||
|
}
|
||
|
|
||
|
nCount++;
|
||
|
oidNearestCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF ,nCount);
|
||
|
|
||
|
//end the while loop
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
// end the whole thing
|
||
|
}
|