Oy, capital letters. Never a good idea in nwn. But okay. Here’s a replacement script for your spell script. Add this and fire off the spell and see if it all works. No other setup required, assuming the spellscript is assigned in your spells.2da
.
Again, I have not tested this, so keep a copy of your old script just in case. There’s a bunch of debugging statements just in case. If it doesn’t work, let me know what the statements say. If it does work, set DEBUG_ME
to FALSE
and recompile.
string THIS = "CS_S1_RopeTrik";
int DEBUG_ME = TRUE;
void debug(object o, string s)
{
if (DEBUG_ME) SendMessageToPC(o, s);
}
void _JumpToExterior(object oPC)
{
object oTarget = GetLocalObject(oPC, "ROPE_SOURCE");
if (!GetIsObjectValid(oTarget))
{
debug(oPC, "Could not find source rope");
return;
}
debug(oPC, "Jumping PC back to original location");
AssignCommand(oPC, DelayCommand(1.0, JumpToObject(oTarget)));
DestroyObject(oTarget);
}
void _JumpToInterior(object oPC)
{
object oTarget = GetWaypointByTag("rpetrk");
if (!GetIsObjectValid(oTarget))
{
debug(oPC, "Could not find valid destination with tag `rpetrk`");
return;
}
debug(oPC, "Jumping PC back to interior location");
AssignCommand(oPC, DelayCommand(1.0, JumpToObject(oTarget)));
}
void _CastSpell()
{
object oPC = GetLastSpellCaster();
if (!GetIsPC(oPC) || !GetIsObjectValid(oPC))
{
debug(GetFirstPC(), "Unable to find valid PC for ropetrick");
return;
}
object oRope = CreateObject(OBJECT_TYPE_PLACEABLE, "rpetrick", GetSpellTargetLocation(), TRUE, "ropetrick_source");
object oTarget = GetObjectByTag("ropeback");
if (!GetIsObjectValid(oRope)) debug(oPC, "Unable to create rope placeable");
if (!GetIsObjectValid(oTarget)) debug(oPC, "Unable to find destination placeable");
DelayCommand(0.5f, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), oRope));
SetEventScript(oRope, EVENT_SCRIPT_PLACEABLE_ON_USED, THIS);
SetEventScript(oTarget, EVENT_SCRIPT_PLACEABLE_ON_USED, THIS);
SetLocalObject(oPC, "ROPE_SOURCE", oRope);
SendMessageToPC(OBJECT_SELF, "You have cast the Rope Trick spell.");
SendMessageToAllDMs(GetName(OBJECT_SELF) + " has cast the Rope Trick Spell.");
}
void main()
{
int n = GetCurrentlyRunningEvent();
if (n == 0) n = GetCurrentlyRunningEvent(FALSE);
if (n == EVENT_SCRIPT_PLACEABLE_ON_USED)
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC) || !GetIsObjectValid(oPC))
{
debug(GetFirstPC(), "Unable to find valid PC for ropetrick");
return;
}
string sTag = GetTag(OBJECT_SELF);
if (sTag == "ropetrick_source")
_JumpToInterior(oPC);
else if (sTag == "ropeback")
_JumpToExterior(oPC);
else
debug(oPC, "CS_S1_RopeTrik called without valid placeable");
}
else
_CastSpell();
}