I was looking into the World Map system and reading through Sunjammer's Tutorial it all seems to be easy enough to setup, but I wanted to add a new functionality to the system that I think will require a custom script to launch the world map UI.
Currently, this script is used to launch the world map UI from a world map transition trigger. I wanted to launch the UI, not from a trigger, but from an item in the player's inventory. This custom map item would be used by the player and then launch the world map UI after some checks.
The checks that I'm thinking of would first check a varible on the current area (MapTravel) to see if map traveling is allowed from that location. 1 for yes, 0 for no.
Then it would check if the party is in combat, and if yes, not allow the map UI to open.
The basic idea here is that the player can open their inventory, and use a map item to open the world map UI. I'm also assuming that tag based scripting is being used, so the script in question would be named the same as the map item.
Help on this would be greatly appreciated as I know Slowdivefan and the IWD guys would be interested in this as well.
Getting a custom World Map Item to open the World Map UI - Script Request
Débuté par
MokahTGS
, févr. 27 2012 10:21
#1
Posté 27 février 2012 - 10:21
#2
Posté 27 février 2012 - 10:54
It should just be a matter of using GetItemActivator in a tag-based script instead of GetClickingObject.
I imagine the name of the map (sMap) will always be the same, so that really only leaves calculating the origin (sOrigin) based on the area you are in. You could name the origin points by putting a prefix in front of the corresponding area tags ('origin_area1' for an area with a tag of 'area1', for example).
I imagine the name of the map (sMap) will always be the same, so that really only leaves calculating the origin (sOrigin) based on the area you are in. You could name the origin points by putting a prefix in front of the corresponding area tags ('origin_area1' for an area with a tag of 'area1', for example).
Modifié par DannJ, 27 février 2012 - 10:57 .
#3
Posté 28 février 2012 - 12:12
Well, I'm no scripter so I'll have to wait for someone to write this thing up...
#4
Posté 28 février 2012 - 01:01
Something like this perhaps (written in notepad at work, so untested):
void main()
{
object oClicker = GetItemActivator();
string sMap = "insert map name here";
object oArea = GetArea(oClicker);
string sOrigin = "origin_"+GetTag(oArea);
// open the world map gui
ShowWorldMap(sMap, oClicker, sOrigin);
}
void main()
{
object oClicker = GetItemActivator();
string sMap = "insert map name here";
object oArea = GetArea(oClicker);
string sOrigin = "origin_"+GetTag(oArea);
// open the world map gui
ShowWorldMap(sMap, oClicker, sOrigin);
}
#5
Posté 28 février 2012 - 02:04
except that doesn't do the checks that I was asking for in the OP.
#6
Posté 28 février 2012 - 03:08
No - you'd have to add the specific details yourself (or find someone more magnanimous than I to do so).
The other option would be to learn some basic scripting. I hear that the ladyfolk are doing all sorts of things for themselves these days (voting, changing tyres, singing old Eurythmics/Aretha Franklin songs...).
The other option would be to learn some basic scripting. I hear that the ladyfolk are doing all sorts of things for themselves these days (voting, changing tyres, singing old Eurythmics/Aretha Franklin songs...).
#7
Posté 28 février 2012 - 03:24
[Duplicado Deleto]
Modifié par DannJ, 28 février 2012 - 03:28 .
#8
Posté 28 février 2012 - 03:35
sigh...
#9
Posté 28 février 2012 - 04:28
Are you serious or am I misinterpreting your comment? Mokah is asking for a scripter to volunteer and write the script for us. If you can't do it, no problem, but to make a horrible comment like that is absolutely uncalled for. You owe her an apology. As a NWN2 community, we have different areas of skills and interests. We can't do it all and that is why we help each other out where we can. For instance, since I learned some basic 3d modelling, I have made placeables for others when asked and I had the time. Since I am not the best at scripting, I have had many people write scripts for me. We help and support each other, that is why the community has lasted this long. Sorry for my rant, but I find your comment offensive.
#10
Posté 28 février 2012 - 04:40
Encouraging the empowerment of women is horrible these days? Political correctness has indeed gone mad!
I for one greatly disapprove of direct ichthian transfer, due to it's inevitably short-term gains. 'Tis far better to encourage the development of self-actualised ichthian trapping skills in order to foster self-improvement and decrease reliance on others.
Or am I the only one to feel that way?
I for one greatly disapprove of direct ichthian transfer, due to it's inevitably short-term gains. 'Tis far better to encourage the development of self-actualised ichthian trapping skills in order to foster self-improvement and decrease reliance on others.
Or am I the only one to feel that way?
Modifié par DannJ, 28 février 2012 - 04:45 .
#11
Posté 28 février 2012 - 05:01
Generally I have written scripts for folks when it solves some kind of interesting or common problem. If the script's requirements are so unique that it would only be of value in the requester's project, then I am more inclined to recommend that they look at some scripts and try to write it and then ask for assistance.
In this case I would suggest looking at the standard conversation gc_ script that checks if the party is in combat. That combined with checking a area local variable to see if travel is allowed and another to specify the origin point, should be enough to make a start of it.
Regards
In this case I would suggest looking at the standard conversation gc_ script that checks if the party is in combat. That combined with checking a area local variable to see if travel is allowed and another to specify the origin point, should be enough to make a start of it.
Regards
#12
Posté 28 février 2012 - 05:08
Kaldor Silverwand wrote...
Generally I have written scripts for folks when it solves some kind of interesting or common problem.
// 'i_map_item_ac'
//
// was 'sj_tr_show_world_map_en'
// Displays the World Map GUI specified by the sMap local variable and selects the Map Point
// specified by the (optional) sOrigin local variable.
//--------------------------------------------------------------------------------------------------
/*
World Map Transition Trigger OnClick event script the World Map Demo Starter Script Set to
display the World Map GUI to the clicking player.
The trigger has two local variables:
- sMap: the file name (with or without the .wmp exention) of the World Map to display
- sOrigin the name (tag) of the Map Point representing the player's current location
NOTE: this is a very simple version, designed to be built upon as requirements grow.
*/
//--------------------------------------------------------------------------------------------------
/*
22 Jan 2007 – Sunjammer
- created
2012 feb 27 - DannJ, kevL's
- add functional checks for tag-based activation.
*/
//--------------------------------------------------------------------------------------------------
void main()
{
object oActor = GetItemActivator();
object oArea = GetArea(oActor);
// set variable 'MapTravel' ( 0/1 ) on Area, to disallow/allow travel from that area
int bMapTravel = GetLocalInt(oArea, "MapTravel");
if (bMapTravel && !GetIsInCombat(oActor))
{
object oActivated = GetItemActivated();
// set variable 'Map' ( string ) on map_item, to state the .Wmp to open
string sMap = GetLocalString(oActivated, "Map");
// this assumes, that the Name of the points on the worldmap are same as areaTags:
// (alter accordingly)
string sOrigin = GetTag(oArea);
// open the world map gui
ShowWorldMap(sMap, oActor, sOrigin);
}
}edit, always a mistake, always a mistake ........
Modifié par kevL, 28 février 2012 - 05:18 .
#13
Posté 28 février 2012 - 05:30
// i_YOURITEMTAG_AC
void main()
{
object oMisogynist = GetItemActivator();
object oArea = GetArea(oMisogynist);
int bAllowXport = GetLocalInt(oArea,"bAllowXport");
string sMap = "sYourMap"; // in all practicality, this is going to be a specific string for your application
string sOrigin = GetTag(oArea); // this is a guess, you'll want to use a named origin from your map
// we only allow players to use the World Map
if( GetIsObjectValid(oMisogynist) && GetIsPC(oMisogynist) )
{
if (bAllowXport)
{
// open the world map gui
ShowWorldMap(sMap,oMisogynist, sOrigin);
}
else
{
SendMessageToPC(oMisogynist,"Sorry Misogynist, you can't use that item here.");
}
}
}
Modifié par DM Wired, 28 février 2012 - 05:38 .
#14
Posté 28 février 2012 - 08:02
I suggest that in order to have one script work for multiple areas with some flexibility in original point naming that if you use KevL's script, instead of using
string sOrigin = GetTag(oArea);
you instead use the lines:
string sOrigin = GetLocalString(oArea, "sOrigin");
if (sOrigin == "") sOrigin = GetTag(oArea);
This way the default is the area tag, but you can specify a string variable sOrigin on the area if you want to have a differently named origin.
Feedback to the user if it is not allowed can be added after the first } with the lines:
else
{
SendMessageToPC(oActor,"The map cannot be used while in combat and may not work in this area.");
}
I'm not sure if it will work if someone besides a PC (a companion or cohort) tries to activate the map. You might need a check to prevent that.
Regards
string sOrigin = GetTag(oArea);
you instead use the lines:
string sOrigin = GetLocalString(oArea, "sOrigin");
if (sOrigin == "") sOrigin = GetTag(oArea);
This way the default is the area tag, but you can specify a string variable sOrigin on the area if you want to have a differently named origin.
Feedback to the user if it is not allowed can be added after the first } with the lines:
else
{
SendMessageToPC(oActor,"The map cannot be used while in combat and may not work in this area.");
}
I'm not sure if it will work if someone besides a PC (a companion or cohort) tries to activate the map. You might need a check to prevent that.
Regards
Modifié par Kaldor Silverwand, 28 février 2012 - 08:03 .
#15
Posté 29 février 2012 - 05:26
// 'i_map_item_ac'
//
// script to activate the worldMap from an item (item must be tagged "map_item"
// per name of script, [see 'x2_inc_switches'] and have the "Cast Spell: Unique
// Power Self Only" itemproperty)
//
// search "nwn2 tag-based scripting" for more info.
void main()
{
object oActor = GetItemActivator();
if (GetIsInCombat(oActor))
{
// Feedback to the user if it is not allowed:
SendMessageToPC(oActor,
"<c=pink>The map_item cannot be used while in combat.</c>");
return;
}
// set var 'bMapTravel' ( int, 1 ) on Area, to allow travel from that area
object oArea = GetArea(oActor);
int bMapTravel = GetLocalInt(oArea, "bMapTravel");
if (!bMapTravel)
{
// Feedback to the user if it is not allowed:
SendMessageToPC(oActor,
"<c=pink>The map_item cannot be used in this area.</c>");
}
else
{
object oActivated = GetItemActivated();
// set var 'sMap' ( string ) on map_item, to state the .Wmp to open
string sMap = GetLocalString(oActivated, "sMap");
// set var 'sOrigin' ( string ) on Area
// defaults to areaTag, if not specified
string sOrigin = GetLocalString(oArea, "sOrigin");
if (sOrigin == "") sOrigin = GetTag(oArea);
// open the world map gui
ShowWorldMap(sMap, oActor, sOrigin);
}
}Ps. i Doubt any checks are needed for GetIsPC( ) & GetIsObjectValid( ) ... you might want to switch control to the player's main character before porting, but that would depends on how the rest of the campaign is set up as to whether any conflicts arise by porting a secondary character (not sure if familiars can even activate an item ..).
Nb. don't forget that bMapTravel can be turned into !bMapTravel easily enough; if you don't want to go through all your areas adding a var_int, and you want travel disallowed only in very few areas, make changes from "bMapTravel" to its opposite: bNoMapTravel, as proper through the script
- scripts have to make sense, they really are little stories ....





Retour en haut







