You are here

Town Portal

2 posts / 0 new
Last post
Knight_Shield
Town Portal

I have scripts originally  created by driller.

 

It is a town portal system. I have it completely working in a test mod but when I put it to the player world the name and place are not displaying on the portal in town.

I'm not a scripter but I think it not pulling the area nmae or player name.

 

Any help cleaning my onativate script might help.

 



////onactivate ////////


object oMod = GetModule();

int GetFreePortal()
{
if(GetLocalInt(oMod,"WP_Portal1") != 1)
return 1;
if(GetLocalInt(oMod,"WP_Portal2") != 1)
return 2;
if(GetLocalInt(oMod,"WP_Portal3") != 1)
return 3;
if(GetLocalInt(oMod,"WP_Portal4") != 1)
return 4;
if(GetLocalInt(oMod,"WP_Portal5") != 1)
return 5;
if(GetLocalInt(oMod,"WP_Portal6") != 1)
return 6;
if(GetLocalInt(oMod,"WP_Portal7") != 1)
return 7;
if(GetLocalInt(oMod,"WP_Portal8") != 1)
return 8;
else
return 0;
}

void DestroyPortal(object oPC)
{
string sUniquePCID = GetPCPublicCDKey(oPC);
SetLocalInt(oPC,"ActivePortal",0);
object oPortalE = GetObjectByTag("PE"+sUniquePCID);
object oPortalX = GetObjectByTag("PX"+sUniquePCID);
int i = GetLocalInt(oPortalX,"WP");
SetLocalInt(oMod,"WP_Portal"+IntToString(i),0);
SetPlotFlag(oPortalE,FALSE);
DestroyObject(oPortalE);
SetPlotFlag(oPortalX,FALSE);
DestroyObject(oPortalX);
}

void CreateTownPortal(object oPC,location lLoc)
{
string sUniquePCID = GetPCPublicCDKey(oPC);

int i = GetFreePortal();

if(i != 0)
{
SetLocalInt(oMod,"WP_Portal"+IntToString(i),1);
if(GetLocalInt(oPC,"ActivePortal") == 1)
DestroyPortal(oPC);
object oWP = GetObjectByTag("WP_Portal"+IntToString(i));
location lExit = GetLocation(oWP);
object oPortalEnter = OBJECT_INVALID;
object oPortalExit = OBJECT_INVALID;
oPortalEnter = CreateObject(OBJECT_TYPE_PLACEABLE,"bk_townportal",lLoc,TRUE,"PE"+sUniquePCID);
oPortalExit = CreateObject(OBJECT_TYPE_PLACEABLE,"townportal00"+IntToString(i),lExit,TRUE,"PX"+sUniquePCID);
SetCustomToken(560+i,GetName(oPC)+"'s Portal to "+GetName(GetArea(oPC)));
SetLocalInt(oPortalExit,"WP",i);
effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,lLoc);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,lExit);
SetLocalInt(oPC,"ActivePortal",1);
return;
}
else
{
SendMessageToPC(oPC,"Your portal spell fizzles out.");
effect eVis = EffectVisualEffect(VFX_IMP_DISPEL, FALSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oPC);
return;
}
}

#include "x3_inc_horse"
#include "x2_inc_switches"
#include "rope_inc"
#include "nw_i0_generic"
void main()
{

    object oItem = GetItemActivated();
    object oWand=GetItemActivated();
    object oUser=GetItemActivator();
    string sWandTag=GetTag(oWand);
    object oPlayer = GetItemActivator();
    object oActivator = GetItemActivator();
    object oPC = GetItemActivator();
    object oTarget = GetItemActivatedTarget();
    string sTag = GetTag(oTarget);
    string sItem = GetTag(oItem);
    object oArea = GetArea(oTarget);
    location lActivator = GetLocation(oActivator);
    location lLoc = GetItemActivatedTargetLocation();
    string sItemTag = GetTag(oItem);
    location lTarget = GetItemActivatedTargetLocation();



                if(sItemTag == "PortalScroll")
                 CreateTownPortal(oPC,lLoc);









      //Enchant Rod script
    if (sWandTag == "EnchantRod")
    {
        ExecuteScript("ench_start", GetItemActivator());
        return;
    }//End of Enchant Rod script.

    //Soul Stone script
    if (sWandTag == "SoulStone")
    {
        SetLocalObject(oUser, "SoulStone", oWand);
        AssignCommand(oUser, ActionStartConversation(OBJECT_SELF, "SoulStoneConv", TRUE, FALSE));
        return;
    }
    //End of Soul Stone script


     if (sRope == "HeavyRope")
        {
        if (fDist < 15.0)//<--- can use FloatingText below, to figure what this
                         //-----float value needs to be.--//
        {
            if (iHasRope != 1)
            {
                object oRope = CreateObject(OBJECT_TYPE_PLACEABLE, "swing_rope", lClick);
                DestroyObject(GetItemPossessedBy(oActivator, sRope));
                SetLocalInt(oActivator, "HasRope", 1);
                SetLocalObject(oRope, "Owner", oActivator);
                FloatingTextStringOnCreature(sName+" secures a rope.", oActivator, FALSE);

                //----- used for setting distance float ----//
                //FloatingTextStringOnCreature("Distance to Landing is "+FloatToString(fDist), oActivator, FALSE);
            }
            else
            {
                FloatingTextStringOnCreature("You already have a rope.", oActivator, FALSE);
            }
          }
        else
        {
            FloatingTextStringOnCreature("You fail to secure a rope.", oActivator, FALSE);

            //----- used for setting distance float ----//
            //FloatingTextStringOnCreature("Distance to Landing is "+FloatToString(fDist), oActivator, FALSE);

        }
        // * Generic Item Script Execution Code
     // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
     // * it will execute a script that has the same name as the item's tag
     // * inside this script you can manage scripts for all events by checking against
     // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }

     }

}

}

  • up
    50%
  • down
    50%
Mannast

I see where you create the Custom Token in the CreateTownPortal function:
SetCustomToken(560+i,GetName(oPC)+"'s Portal to "+GetName(GetArea(oPC)));
But then what do you do with it? You would need to "bake" whatever is displaying this token. If it is the name of an object, you would need to rename it. If it is in a conversation, those "bake" when fired, so the token would be displayed correctly, but only if this Custom Token isn't redefined before you run the conversation. Hope that helps...

Portable Hole System, Scry and Teleport System, Throwing Objects, Prodding Traps, Portable Placeables and a Vanilla Basemodule, among other things

  • up
    50%
  • down
    50%