Point by point. Trying to develop the start of a portal system. Where the player can’t use a portal to jump to another portal they have never been too. Somewhat like diablo’s waypoint system but not requiring use of the portal to unlock location, instead coming within proximity of it (via area trigger).
I don’t have a full count of the portals I will end up with. I was hoping once this starts working I could copy/paste and make minor changes - if even needed - for additional city/location portals in the future. Even going so far as allowing the player to set three points anywhere that they can portal too… <— that step is not important right now.
In total right now there are 3 “portals”.
City 1 (player starts here and this is always visible in the portal conversation)
City 2 (player needs to visit the portal at City 2 before it’s available to select in portal conversation.
Worldstone (when a player dies, they return to the worldstone - which is just a portal that uses the same conversation as the other two portals. Allowing the PC to jump back to a city near their death location.
So the idea is the player obtains a shard of the worldstone and that allows them to use the portals. And only where the portal has been visited (visiting City 2 portal), is where the player can teleport too. I wanted to use local variables on the worldstoneshard item in the PC inventory because I may have the PC lose the stone in the future or during certain events/quests - requiring them to obtain a new one, and revisit locations to be able to travel to them again. So plugging the VARs into the PCs undroppable worldstoneshard item seemed to be the right directions in my mind.
Step 1:
Create worldstoneshard in PC inventory:
This comes from a One Time conversation the player has with a NPC that sends them into the world.
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625 */
//Put this on action taken in the conversation editor
void main()
{
object oPC = GetPCSpeaker();
CreateItemOnObject("worldstoneshard", oPC);
SetLocalInt(oPC, "virgin", 1);
}
Now the PC has the item and is teleported to City1.
PC talks to a unrelated NPC that charges 800gp to sail them to City2.
PC pays the gold and arrives at City2 docks, makes way into city2 and comes within proximity of the portal. There is a Area Trigger surrounding the portal area that the PC would need to enter before clicking on the portal.
Upon entering the trigger area around the undiscovered portal in City2, the PC’s worldstoneshard item’s local variable called ‘bwwp’ is updated to 1, meaning the portal is discovered.
Trigger Area OnEnter script:
void main()
{
object oPC;
object oItem;
oPC = GetEnteringObject();
if(!GetIsPC(oPC))
{
return;
}
oItem = GetItemPossessedBy(oPC, "worldstoneshard");
if(GetIsObjectValid(oItem))
{
SetLocalInt(oItem, "bwwp", 1);
}
else
{
SendMessageToPC(oPC, "You are missing something.");
}
}
This script kicks off the conversation when PC uses the portal:
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625 */
//Put this script OnUsed
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = GetObjectByTag("bwwp");
AssignCommand(oTarget, ActionStartConversation(oPC, "wordlstone"));
}
I’m aware of the spelling mistake with ‘Wordlstone’ above.
On the portals conversation “text appears when…” check the City2 option should now be visible and the PC teleported when clicking it.
Conversation Script:
int StartingConditional()
{
object oPC = GetPCSpeaker();
object oItem = GetItemPossessedBy(oPC, "worldstoneshard");
int iReturnMe = FALSE;
if(GetIsObjectValid(oItem))
iReturnMe = (GetLocalInt(oItem, "bwwp") != 1);
return iReturnMe;
}
That’s all I’m trying to do. I’m probably making it far more complicated than it should be.
City1 Portal Script:
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625 */
//Put this on action taken in the conversation editor
void main()
{
object oPC = GetPCSpeaker();
object oTarget;
location lTarget;
oTarget = GetWaypointByTag("BeleghostPortal");
lTarget = GetLocation(oTarget);
//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
AssignCommand(oPC, ClearAllActions());
DelayCommand(3.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));
oTarget = oPC;
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oTarget));
}
City2 Portal Script:
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625 */
//Put this on action taken in the conversation editor
void main()
{
object oPC = GetPCSpeaker();
object oTarget;
location lTarget;
oTarget = GetWaypointByTag("bwwp");
lTarget = GetLocation(oTarget);
//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
AssignCommand(oPC, ClearAllActions());
DelayCommand(3.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));
oTarget = oPC;
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oTarget));
}
Hopefully this is in a decent order.
-missed the trigger onenter script, added.