60 lines
2.1 KiB
Plaintext
60 lines
2.1 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
//:: scrolloftownport.nss
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void main()
|
|
{
|
|
object oPC = GetItemActivator();
|
|
object oTownPortal;
|
|
|
|
if (GetIsObjectValid(oPC))
|
|
{
|
|
string sAreaTag = GetTag(GetArea(oPC));
|
|
|
|
if (sAreaTag != "area4_999" && sAreaTag != "NOTOWNPORTAL")
|
|
{
|
|
// if player already has a town portal destroy it
|
|
oTownPortal = GetLocalObject(oPC, "TownPortal");
|
|
|
|
if (GetIsObjectValid(oTownPortal)) DestroyObject(oTownPortal);
|
|
|
|
// create new town portal at player location
|
|
oTownPortal = CreateObject(OBJECT_TYPE_PLACEABLE, "townportal", GetLocation(oPC));
|
|
SetLocalObject(oPC, "TownPortal", oTownPortal);
|
|
|
|
switch (d6())
|
|
{
|
|
case 1: AssignCommand(oTownPortal, PlaySound("sco_lgrinholy01")); break;
|
|
case 2: AssignCommand(oTownPortal, PlaySound("sco_lgsprholy01")); break;
|
|
case 3: AssignCommand(oTownPortal, PlaySound("sco_lgupholy01")); break;
|
|
case 4: AssignCommand(oTownPortal, PlaySound("sco_lgrinodd01")); break;
|
|
case 5: AssignCommand(oTownPortal, PlaySound("sco_lgsprodd01")); break;
|
|
case 6: AssignCommand(oTownPortal, PlaySound("sco_mehanodd03")); break;
|
|
}
|
|
|
|
DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), oTownPortal));
|
|
DelayCommand(0.5, SignalEvent(oTownPortal, EventUserDefined(9000)));
|
|
|
|
// if there is no town portal in Valeford create one
|
|
oTownPortal = GetLocalObject(OBJECT_SELF, "TownPortal");
|
|
|
|
if (!GetIsObjectValid(oTownPortal))
|
|
{
|
|
oTownPortal = CreateObject(OBJECT_TYPE_PLACEABLE, "townportal", GetLocation(GetObjectByTag("WP_TownPortal")));
|
|
SetLocalObject(OBJECT_SELF, "TownPortal", oTownPortal);
|
|
DelayCommand(0.6, SignalEvent(oTownPortal, EventUserDefined(9000)));
|
|
}
|
|
}
|
|
|
|
else if (sAreaTag == "NOTOWNPORTAL")
|
|
{
|
|
FloatingTextStringOnCreature("The spell fizzles! The town portal does not work here!", oPC);
|
|
}
|
|
else
|
|
{
|
|
FloatingTextStringOnCreature("The spell fizzles! You're already in town!", oPC);
|
|
}
|
|
}
|
|
|
|
ExecuteScript(GetTag(GetItemActivated()), OBJECT_SELF);
|
|
} |