generated from Jaysyn/ModuleTemplate
107 lines
5.7 KiB
Plaintext
107 lines
5.7 KiB
Plaintext
void main()
|
|
{
|
|
object oUser = GetItemActivator();
|
|
object oTarget = GetItemActivatedTarget();
|
|
object oItem = GetItemActivated();
|
|
object oAlly = GetFirstObjectInShape(SHAPE_SPHERE, 4.0, GetLocation(oTarget), TRUE);
|
|
int nAllies = 0;
|
|
object oVictim = GetLocalObject(oItem, "oVictim");
|
|
float fRange = GetDistanceBetween(oUser, oTarget);
|
|
int nAttack;
|
|
int nDefense;
|
|
|
|
if (oVictim==OBJECT_INVALID)
|
|
{
|
|
// Rope is not in use; time to target
|
|
if (fRange < 3.0) // Check range
|
|
{
|
|
if (GetIsInCombat(oTarget)) // Opposed checks if in combat
|
|
{
|
|
while (GetIsObjectValid(oAlly)) // This loop counts allies near the target
|
|
{
|
|
if (GetIsFriend(oUser, oAlly))
|
|
nAllies ++;
|
|
oAlly = GetNextObjectInShape(SHAPE_SPHERE, 3.0, GetLocation(oTarget), TRUE);
|
|
}
|
|
|
|
nAttack = d20()+GetAbilityModifier(ABILITY_STRENGTH, oUser)+nAllies; // Attack roll
|
|
nDefense = d20()+GetAbilityModifier(ABILITY_STRENGTH, oTarget); // Defense roll
|
|
|
|
if (nAttack + 1 > nDefense) // Opposed check
|
|
{
|
|
nAttack = d20()+ GetAbilityModifier(ABILITY_DEXTERITY, oUser)+GetSkillRank(SKILL_PICK_POCKET, oUser)+nAllies;
|
|
nDefense = d20()+GetAbilityModifier(ABILITY_DEXTERITY, oTarget)+GetSkillRank(SKILL_PICK_POCKET, oTarget);
|
|
if (nAttack + 1 > nDefense)
|
|
{
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectCutsceneParalyze(), oTarget)); // Paralyze
|
|
SetLocalObject(oItem, "oVictim", oTarget); // Set victim variable
|
|
AssignCommand(oTarget, SpeakString(GetName(oTarget)+" is tied up.")); // Inform
|
|
}
|
|
else
|
|
{
|
|
float fTime = d6()*10.0;
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCutsceneParalyze(), oTarget, fTime)); // Paralyze
|
|
SetLocalObject(oItem, "oVictim", oTarget); // Set victim variable
|
|
AssignCommand(oTarget, SpeakString(GetName(oTarget)+" is tied up.")); // Inform
|
|
DelayCommand(fTime, DeleteLocalObject(oItem, "oVictim"));
|
|
DelayCommand(fTime, SendMessageToAllDMs(GetName(oTarget)+" works the ropes loose if still captured."));
|
|
}
|
|
}
|
|
else // Announce failure
|
|
{
|
|
if (nAllies > 0)
|
|
AssignCommand(oUser, SpeakString(GetName(oUser)+" tries to tie up "+GetName(oTarget)+" with "+IntToString(nAllies)+" allies, but fails."));
|
|
else
|
|
AssignCommand(oUser, SpeakString(GetName(oUser)+" tries to tie up "+GetName(oTarget)+", but fails."));
|
|
|
|
}
|
|
|
|
|
|
}
|
|
else // Autosuccess otherwise
|
|
{
|
|
nAttack = d20()+ GetAbilityModifier(ABILITY_DEXTERITY, oUser)+GetSkillRank(SKILL_PICK_POCKET, oUser)+4;
|
|
nDefense = d20()+GetAbilityModifier(ABILITY_DEXTERITY, oTarget)+GetSkillRank(SKILL_PICK_POCKET, oTarget);
|
|
if (nAttack + 1 > nDefense)
|
|
{
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectCutsceneParalyze(), oTarget)); // Paralyze
|
|
SetLocalObject(oItem, "oVictim", oTarget); // Set victim variable
|
|
AssignCommand(oTarget, SpeakString(GetName(oTarget)+" is tied up.")); // Inform
|
|
}
|
|
else
|
|
{
|
|
float fTime = d6()*10.0;
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCutsceneParalyze(), oTarget, fTime)); // Paralyze
|
|
SetLocalObject(oItem, "oVictim", oTarget); // Set victim variable
|
|
AssignCommand(oTarget, SpeakString(GetName(oTarget)+" is tied up.")); // Inform
|
|
DelayCommand(fTime, DeleteLocalObject(oItem, "oVictim"));
|
|
DelayCommand(fTime, AssignCommand(oTarget, SpeakString(GetName(oTarget)+" works the ropes loose.")));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
SendMessageToPC(oUser, "Target is out of range; you must be within ten feet.");
|
|
}
|
|
else
|
|
{
|
|
// Allow target to be untied IF close enough
|
|
fRange = GetDistanceBetween(oUser, oVictim);
|
|
if (fRange < 3.0 && fRange > 0.0) // Check range
|
|
{
|
|
effect eRem = GetFirstEffect(oVictim);
|
|
while (GetIsEffectValid(eRem))
|
|
{
|
|
if (GetEffectCreator(eRem)==oItem)
|
|
RemoveEffect(oVictim, eRem); // Remove that effect
|
|
eRem = GetNextEffect(oVictim);
|
|
}
|
|
DeleteLocalObject(oItem, "oVictim"); // Clear the victim variable
|
|
AssignCommand(oVictim, SpeakString(GetName(oVictim)+" is set free."));
|
|
}
|
|
else // Out of range
|
|
SendMessageToPC(oUser, "The target tied up with this rope, "+GetName(oVictim)+", is out of range. Get within ten feet.");
|
|
|
|
|
|
}
|
|
}
|