Initial commit
Adding all of the current content for Anphillia Unlimited.
This commit is contained in:
73
_module/nss/hc_cat_tt_disarm.nss
Normal file
73
_module/nss/hc_cat_tt_disarm.nss
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "hc_text_traps"
|
||||
#include "prc_inc_spells"
|
||||
|
||||
void triggerTrap(object oTrap, object oVictim);
|
||||
|
||||
void main()
|
||||
{
|
||||
object oPC = GetPCSpeaker();
|
||||
SendMessageToPC(oPC, DISARMING);
|
||||
|
||||
if (oPC != OBJECT_INVALID)
|
||||
{
|
||||
int nRogueLevel = GetLevelByClass(CLASS_TYPE_ROGUE, oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_SCOUT, oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_NINJA, oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_FACTOTUM, oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_BEGUILER, oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_PSYCHIC_ROGUE, oPC);
|
||||
|
||||
int nSkillMod = GetLocalInt(oPC, "nSkillMod");
|
||||
object oTrappedItem = GetLocalObject(oPC, "oToolTarget");
|
||||
int iTrapDC = GetTrapDisarmDC(oTrappedItem) - 100;
|
||||
int bCanDisarmTrap = FALSE; // Assume that the person cannot spot a trap.
|
||||
// Determine spotting capability
|
||||
if ((iTrapDC <= 20) || ((iTrapDC > 20) && (nRogueLevel >= 1)))
|
||||
bCanDisarmTrap = TRUE;
|
||||
// Only check to see if detected if not previously detected
|
||||
// and the PC has the ability to do detect it.
|
||||
if (bCanDisarmTrap)
|
||||
{
|
||||
int nDisarm = GetSkillRank(SKILL_DISABLE_TRAP, oPC);
|
||||
int nDCCheck = d20() + nDisarm + nSkillMod;
|
||||
if (nDCCheck >= iTrapDC && nDisarm >= 1) // Trap disarmed
|
||||
{
|
||||
SetTrapDisabled(oTrappedItem);
|
||||
SendMessageToPC(oPC, DISARMED);
|
||||
}
|
||||
else if ((nDCCheck - iTrapDC) < -4)
|
||||
{
|
||||
SendMessageToPC(oPC, TRAPTRIGGERED);
|
||||
triggerTrap(oTrappedItem, oPC);
|
||||
}
|
||||
else
|
||||
SendMessageToPC(oPC, FAILDISARM);
|
||||
}
|
||||
else
|
||||
{
|
||||
triggerTrap(oTrappedItem, oPC);
|
||||
}
|
||||
|
||||
DeleteLocalObject(oPC, "oToolTarget");
|
||||
DeleteLocalInt(oPC, "nSkillMod");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void triggerTrap(object oTrappedObject, object oVictim)
|
||||
{
|
||||
switch (GetObjectType(oTrappedObject))
|
||||
{
|
||||
case OBJECT_TYPE_DOOR:
|
||||
AssignCommand(oVictim, ActionDoCommand(SetLocked(oTrappedObject, FALSE)));
|
||||
AssignCommand(oVictim, ActionOpenDoor(oTrappedObject));
|
||||
AssignCommand(oVictim, ActionDoCommand(SetLocked(oTrappedObject, TRUE)));
|
||||
break;
|
||||
case OBJECT_TYPE_PLACEABLE:
|
||||
AssignCommand(oVictim, ActionInteractObject(oTrappedObject));
|
||||
break;
|
||||
case OBJECT_TYPE_TRIGGER:
|
||||
AssignCommand(oVictim, ActionForceMoveToLocation(GetLocation(oTrappedObject)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user