You are here

Editing Area Props In-Game

33 posts / 0 new
Last post
jestemwlodzimierz
Editing Area Props In-Game

I'm working on a module that revolves around procedure-generated areas. I failed to find a way to do 2 things with an in-game script:

- edit map notes text

- edit the displayed name of an area

Is it possible?

  • up
    50%
  • down
    50%
kevL's

probly no setter functions ...

  • - edit map notes text

delete and re-create the mapnote (if possible). Or try <custom-tokens>...

  • - edit the displayed name of an area

uh..

  • up
    100%
  • down
    0%
jestemwlodzimierz

Hmm... but can I edit the text of a map note with a scritpt? - even if it's a brand new one from CreateObject function.

As for Map Name I thought about editing the map GUI, but i don't know enough about .xmls...

  • up
    50%
  • down
    50%
kevL's

Unfortunately I tried SetCustomToken() on
- area name
- mapnote text
- placeable name
- dialog line

it worked only for the dialog line. at least as i understand it: "<CUSTOM3001>" eg.

And it seems t'me I tried changing an area-name in the past and didn't see a straightforward way to do it, and still don't ... but yes it should be possible to modify 'minimap.xml', "AREA_NAME_TEXT" using a gui-local string var, but i don't know how to do that offhand either.

as to mapnotes, I guess you'd have to have multiple pre-defined waypoints ready with the notes required, and choose which one to create or destroy/create on the fly.*


So, all i'm seeing are workarounds,

 

*or, if you know what text(s) will be needed, a bunch of pins (with different notes) could be set at the same place and then use SetMapPinEnabled() to decide which one currently shows.

edit: I'd think this should work to change the areaname

// Brock H. - OEI 03/29/06
// If StrRef is -1, then sText is used instead
// Passing in -1 and "" will clear the text
void SetGUIObjectText( object oPlayer, string sScreenName, string sUIObjectName, int nStrRef, string sText );

one way or another.

  • up
    50%
  • down
    50%
jestemwlodzimierz

I'll try to take on the minimap.xml and see what i can do. The waypoint workaround won't do unfortunately... What I wanted is have a generated name for each place so the player wouldn't enter a "shop" all the time, but instead "Jerry's Shop" one time "Asmodeus' Emporium" the other time "LeBron's Nike Store" other time, etc.

Thank for the help anyway, I appreciate it ;-)

  • up
    50%
  • down
    50%
jestemwlodzimierz

HOLY SHIT I DID IT XD I got it to work exactly the way I want :D

  • up
    50%
  • down
    50%
jestemwlodzimierz

Here's the trick: in minimap.xml replace all "OnUpdate=UIText_OnUpdate_DisplayAreaName()  with "OnUpdate=UIText_OnUpdate_DisplayLocalVar(local:1) "

Then you can edit the area name with this: SetLocalGUIVariable(GetFirstPC(), "SCREEN_MINIMAP", 1, "you area name");

  • up
    100%
  • down
    0%
kevL's

sweet :)_~

- may i suggest looping GetFirstPC() -> GetNextPC() to ensure all players get updated?

  • up
    50%
  • down
    50%
jestemwlodzimierz

As I tested it - switching players doesn't affect anything, so I think it's not required for sigle player mods.

The next step is modifying the AreaMap, which has to be done little differently:

In areamap.xml replace the OnUpdate commands for text just like previously. Then add OnAdd=UIObject_MISC_ExecuteServerScript("gui_script") to UIScene. After that create a gui_sctipt that edits the area name with SetLocalGUIVariable(GetFirstPC(), "SCREEN_AREAMAP", 1, GetLocalString(GetFirstPC(), "your area name"));

This way anytime the big map pops up it has the appropriate name :-)

  • up
    50%
  • down
    50%
4760

Nice trick!

  • up
    50%
  • down
    50%
Lance Botelle

Hi,

EDIT: Fixed a map-pin bug (where some pins duplicated) in v1.10: (26) Map Pins: Fixed duplication of a manually set pin.

I may be late to the post here, but I have edited map names, map pins (to a degree) and other map functions in my module, The Scroll. You could download and check out the functions/scripts/xml files in that. NOTE: I am also updating the module, and so I recommend waiting until v 1.10 for anything "final". That said, all those map references work in the current version.

https://neverwintervault.org/forums/neverwinter-nights-2/nwn2-modules/module-scroll-first-day-currently-updating-v110-coming-soon

IMAGE SHOWING MAP: http://worldofalthea.blogspot.co.uk/2017/08/the-scroll-updated-and-improved-version.html

Cheers, Lance.

MapWork.jpg

  • up
    50%
  • down
    50%
andysks

Sweet! This is one of these things, man. NWN2 never stops to amaze with new discoveries :D.

  • up
    50%
  • down
    50%
jestemwlodzimierz

OK, now part 2 - can I edit the challenge rating on a creature? Or do I have to screw with the .xml again?

  • up
    50%
  • down
    50%
kevL's

can't see a setter function ...

changing .Xml won't change a creature's CR (i doubt it.) I'd say CR can be set only in the toolset, whether for a blueprint or a pre-placed instance of the creature.

  • up
    50%
  • down
    50%
jestemwlodzimierz

I refuse to believe that XD I'll dig into the .xml

  • up
    50%
  • down
    50%
jestemwlodzimierz

And to be perfectly clear - I don't care about the xp award based on the CR. I can deal with that easily with OnDeah scripts. I just want to have the examine screen display the appropriate challenge rating.

  • up
    50%
  • down
    50%
jestemwlodzimierz

I got it - all it needs is 2 simple edits in examine.xml. In the UIScene you add OnAdd1=UIObject_MISC_ExecuteServerScript("gui_examine") and to EXAMINE_DESCRIPTION_TEXT you add update=true OnUpdate=UIText_OnUpdate_DisplayLocalVar(local:1).

Then you can use gui_examine to alter the description in any way you seem fit :-) Just use SetLocalGUIVariable(GetFirstPC(), "SCREEN_EXAMINE", 1, sText); where sText is the description box text.

  • up
    50%
  • down
    50%
kevL's

oh, ...

ofc that doesn't change the CR (which is a float value on each creature).

  • up
    50%
  • down
    50%
jestemwlodzimierz

Update - the soluion above will affect all the examine screens including the ones for spell, feats, abilities etc.

i have an idea for a workaround but I can't get the essential function to work... GetPlayerCreatureExamineTarget()...

  • up
    50%
  • down
    50%
Shallina

SetName(GetArea(objectInArea),"New Name") on the area object should work.

 

When you want to change a value on an object see for functions prefixed by set in the the script helper.

if you want to access a value look for get. Most of the time if you have a get for something, a set exist as well for it.

 

  • up
    50%
  • down
    50%
Lance Botelle

Again,

I may be late to the post here, but my module uses its own "CR Rating" system, with customized references and own "XP system". I don't know exactly what part you refer to, but I also have edited examine GUI, etc to make it so the CR does not show original, but my own system. Check out v1.10 of The Scroll upon release.

And as KevL says, edited the examine just allows you to alter what is shown. You need to alter other code/scripts to ensure your own CR rating is used.

Cheers, Lance.

  • up
    50%
  • down
    50%
jestemwlodzimierz

Late post is better than no post XD I only need to have the examine screen show the examined creature's "fake" CR based on its local int instead of the actual CR.

  • up
    50%
  • down
    50%
jestemwlodzimierz

Here's what I attempted: I added an OnAdd fuction to the examine screen to fire up a script. In the script I tried to use a function 

SetGUIObjectText(oPC, "SCREEN_EXAMINE", "EXAMINE_DESCRIPTION_TEXT", 0, sString);

where sString is a procedurally generated description (containing fake CR) that I get from a local int that the examined creature has. Problem is - I can't get the examined creature with the script.

I tried GetPlayerCreatureExamineTarget(oPC);, but it return OBJECT_INVALID every time. GetPlayerCurrentTarget(oPC); works fine, but with that function every time I examine something that is not a creature (item or spell) the screen shows the description for the creature... which I don't like.

pls halp

  • up
    50%
  • down
    50%
kevL's

note: GetPlayerCreatureExamineTarget() is the big (secondary/alternate) character sheet, for example when controlling the PC and examining a Companion.


Can you do something like this in your script:

object oTarget = GetPlayerCurrentTarget(oPC);
if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
{
    SetGUIObjectText(oPC, "SCREEN_EXAMINE", "EXAMINE_DESCRIPTION_TEXT", 0, sString);
}
else
    SetGUIObjectText(oPC, "SCREEN_EXAMINE", "EXAMINE_DESCRIPTION_TEXT", 0, "");


that is, simply clear the gui-text if current target is not a creature*. But this still won't help if switching to a spell description ....

 

*may have to use OnUpdate instead of OnAdd

  • up
    50%
  • down
    50%
jestemwlodzimierz

I already found a work around - it's stupid, but it works, so I guess it's not stupid XD

I used OnUpdate to fire up a script with a local string variable - the description.

All creatures' descriptions start with the health status, so I figured that if I check if the first 4 letters with "Unin", "Inju", "Badl", etc. (for "Uninjured, "Injured", "Badly Injured" etc...). it would mean a creature got examined.

I tested it and it works like a charm XD

  • up
    50%
  • down
    50%
jestemwlodzimierz

Another obstacle, though - the examine screen .xml in Overland Map mode is different than examine.xml. I can't indentify which one it is. I thought it's creatureexamine.xml, but it's not...

  • up
    50%
  • down
    50%
kevL's

creatureexamine.xml is for GetPlayerCreatureExamineTarget() -- the alternate/secondary character sheet (for non-controlled party members)

my examine screen in SoZ uses Examine.xml ... (i might have switched it at some pt. but don't think so)

  • up
    50%
  • down
    50%
jestemwlodzimierz

You're right - sorry, my bad. But it seems that examining a creature in a overland map doesn't automatically target that creature... GetPlayerCurrentTarget() returns invalid...

  • up
    50%
  • down
    50%
kevL's

hm yeh, i noticed that on the OL, right-click resulted in an automatic examine. there was no dropdown-> examine target option

My guess is that the Examine screen pops for the player before the data about the target has been gathered. So, in your 'gui_examine' script, try wrapping a subfunction, and put a delay between 0.f to say 0.2f

eg -
void main()
{
    DelayCommand(0.1f, ShowExamine());
}

void ShowExamine()
{
    object oTarget = GetPlayerCurrentTarget();
    // etc
    SetGUIObjectText(...);
}

  • up
    50%
  • down
    50%
jestemwlodzimierz

Didn't work :-/ I gave it a full second delay and it didn't work :-(

  • up
    50%
  • down
    50%
jestemwlodzimierz

I did find a lame work-around: I send the NAME from xml to the script and use FindSubString() to check for some characteristic words in the creature name and than edit the examination description based on that. I don't have that many creatures on the overland map anyway so it's fine with me. I won'r be able to procedurally generate he CR, but I'll live with it.

  • up
    50%
  • down
    50%
kevL's

yeah i'm up against the same obstacle:

have an OnUpdate script that runs when the Examine screen is up (shows extra information about the current target - which is not necessarily the examined object) and am consistently getting OBJECT_INVALID on the OL. I suspect we're up against a hardcoded issue, as soon as an area is flagged as overland. I don't know of any function that gets an overland-map target ....

ps. so i use GetIsOverlandMap() to bypass my script, if true.

  • up
    50%
  • down
    50%
Lance Botelle

Hi,

I have not done much coding with the overland map yet (that comes in the next mod), however, from what I have done, I have found that the "examine" call can sometimes be made from the contextmenu.xml.

I have also come up against difficulties in finding the subject when examine is used.

  • up
    50%
  • down
    50%