Author Topic: Regarding NWNX_Areas & NWNX_Dynres  (Read 3375 times)

Legacy_Neverwinter Owl

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« on: July 22, 2016, 09:59:49 pm »


               

I've just finished the -painfully long- surgical process of converting all my module's areas to load as needed using Dynres and nwnx_areas. Everything works great, I'm a huge fan of the plugin cleaning player TURDS so you don't have people logging into maps that no longer exist.


 


However, I'm having a strange issue which occurs only sometimes. When I enter certain types of areas, the area is completely black, but if I move my character around the blackness fades and I can see everything on the map like normal. Even in the darkness, if I move my camera around I can see placeables and map features etc, so it doesn't seem like the case of loading into an unloaded map, though I could be wrong. It has only happened so far in interiors.


 


Any ideas of what could be causing this? I would ask on the nwnx forums, but the place seems pretty slow and I timeout every single time I try to log in :S



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #1 on: July 23, 2016, 09:37:27 pm »


               


 


This issue?


 


It was resolved on Windows nwnx_areas in Maxrocks version of it.


I am unsure about the linux.



               
               

               
            

Legacy_Neverwinter Owl

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #2 on: July 24, 2016, 02:05:31 am »


               

Similar, but the "darkness" fades after taking a few steps with WASD and then you can see the map like normal. It also only happens when loading interior areas, hasn't seemed to have happened from logging back into the server. If I log out of the area when its black and log back in, the area is loaded as normal - so this is definitely just a visual effect. I've also stood beside people who were effected, when I wasn't.


 


I haven't been able to locate Maxrocks version, though I've seen people talking about it.


 


Is it a completely out of date version compared to the one I got from Terra here http://www.nwnx.org/...opic.php?t=2116



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #3 on: July 24, 2016, 01:11:03 pm »


               

I thought at first Terra's one might be derived from Maxrocks - but just looking at the source code I can see it is missing the Turd Management code 


and the 'ReAdd' areas to DungeonMaster list etc


These were functionalities that were present in Maxrocks one.


 


This one:


https://github.com/N...rock/nwnx_areas


 


Appears to be more substantial in terms of code presence - I used this one for about 4 years + and had no issues with it.


I initially got the dark universe bug years ago, and reported it to Maxrock and he patches the issue.


               
               

               
            

Legacy_Neverwinter Owl

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #4 on: July 24, 2016, 05:23:00 pm »


               

Awesome, thanks so much for the help Baaleos. One final question, how do I go about building this? Lol! I've never compiled a DLL before.



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #5 on: July 26, 2016, 04:09:36 pm »


               

Yeesh


Well...


First - download the sources to your pc.


Then make sure you have visual studio express installed (or something better - Visual Studio premium etc if you have it)


Make sure you have the VC++ mode installed


(So it can work with c++ code instead of c#)


 


So - first step - try building it.


It will likely complain - I've never had an instance where something from GIT built immediately with no debugging.


 


Go try that and if you have any issues - let me know.


There might be some posts on the Windows Development forum over at nwnx.org  that discuss the numerous issues with building.



               
               

               
            

Legacy_Neverwinter Owl

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #6 on: July 26, 2016, 10:15:42 pm »


               

I managed to get it built, and then shortly after that found a pre-built on the same Git. I'm totally not familiar with their layout so I was a total noob at finding that.


 


Anyways, I managed to switch over from Terra's version, and this plugin has the same issue. I'm almost positive it has to do with the ceilings of the particular maps it happens on, and the entry waypoints might be too close to the wall. Since the outcome was the same, I've decided to switch back to Terra's as it has some extra functionality to it and it's apparently based off of Max's edits. Don't fix what isn't broken I guess is the saying.


 


 


However, there is another issue I've run into.


 


This has only happened twice according to one of my top players, so it is very very rare, but on this rare occasion my custom area transition trigger will take someone to a completely wrong area entirely, and in one instance it sent someone to the proper area, but it didn't send them to the proper waypoint - it didn't even send them to a waypoint at all! They appeared on the top of a random inaccessible cliff.


 


I've scoured the maps to make sure the WPs and transitions align, and made sure there were no little simple mistakes, and I know the areas plugin isn't responsible for transitions so it shouldn't be that... I'm at a loss.


 


I don't know what you guys use for area triggers, but does anything in this look particularily troublesome?


 


How it works: If you wanted to connect to an area named House, you would make a trigger with the tag "house" (resref of the area you want to connect to), and this particular trigger would take you to the waypoint "House1" (area tag +1).



#include "nwnx_areas"
#include "dotransition"
void main()
{
object oPC = GetEnteringObject();
if(!GetIsPC(oPC)) return;

string sRes = GetTag(OBJECT_SELF);
string sWP = sRes+"1";

DoTransition(oPC, sRes, sWP);

}


#include "nwnx_areas"

void DoTransition(object oPC, string sRes, string sWP)
{

object oDest = GetObjectByTag(sWP);
location lWP = GetLocation(oDest);

object oArea = GetLocalObject(GetModule(), sRes);

// If the area arleady exists, and the waypoint exists, take us there.
if(GetIsObjectValid(oArea) && GetIsObjectValid(oDest)){
    AssignCommand(oPC, ClearAllActions(TRUE));
    AssignCommand(oPC, ActionJumpToLocation(lWP));
    return;
    }

// Otherwise create the area, set the local object on the module and then take us there.
else if(!GetIsObjectValid(oArea)){
    oArea = AREAS_CreateArea(sRes);
    SetLocalObject(GetModule(), sRes, oArea);
    FloatingTextStringOnCreature("Loading...", oPC, TRUE);

    oDest = GetObjectByTag(sWP);
    lWP = GetLocation(oDest);

    if(GetIsObjectValid(oDest)){
        AssignCommand(oPC, ClearAllActions(TRUE));
        AssignCommand(oPC, ActionJumpToLocation(lWP));
        }

}
}


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #7 on: July 27, 2016, 03:54:29 pm »


               

Ok, I suspect with regards to your script you are doing it the difficult way.


The easier way is to store an object reference to the door on the destination door, and have the destination door store a reference to the origin door.


 


 


Then onTransition/Click - have it port the player to the destination door.


Don't worry about tags at all.


 


 


This is my 'OnDoorOpen' script


Note - this will be when the area is generated and the door you use is linked to the destination door.



#include "areas_inc"
#include "nwnx_funcs"
#include "nos_area_gen_inc"
 
 
 
void main()
{
int iInitialized = GetLocalInt(OBJECT_SELF,"INIT");
if(iInitialized)
    {
        //Find the target door, and open
        object oDoor = GetLocalObject(OBJECT_SELF,"TARGET_DOOR");
        int iOpen = GetIsOpen(oDoor);
        if(!iOpen)
            {
                AssignCommand(oDoor,ActionOpenDoor(oDoor));
                DelayCommand(15.00,AssignCommand(oDoor,ActionCloseDoor(oDoor)));//Close Interior Door after 15 Seconds
            }
        DelayCommand(15.00,ActionCloseDoor(OBJECT_SELF));
        return;
    }
object oCurrentArea = GetArea(OBJECT_SELF);
string sResSpecific = GetLocalString(OBJECT_SELF,"AREA_TYPE_SPECIFIC");
string sResRef;
if(sResSpecific == ""){
 sResRef = TypeToRes(GetLocalString(OBJECT_SELF,"AREA_TYPE"));
}else
{
sResRef = GetStringLowerCase(sResSpecific);
}
string sTagPrefix = GetResRef(oCurrentArea);
int iDoorProcessed = GetLocalInt(oCurrentArea,"DOORS_DONE");
string sNewTag = sTagPrefix+"_"+IntToString(iDoorProcessed);
string sDestTag = sNewTag+"_INT";
 
iDoorProcessed++;
SetLocalInt(oCurrentArea,"DOORS_DONE",iDoorProcessed); //Increments the Door Number, to ensure other doors get a tag of +1 than this one.
NWNXFuncs_SetTag(OBJECT_SELF,sNewTag);  //Set our tag, to unique tag
 
string sScript = GetLocalString(OBJECT_SELF,"SCRIPT_TO_RUN_ON_AREA");
// _hallsofthedivin
 
object oArea;
//Create the New Area
while(oArea == OBJECT_INVALID)
    {
        oArea = CreateArea(sResRef);
    }
RestoreAreaSettings(oArea);
SetLocalInt(oArea,"GENERATED_AREA",1);
 
//Set Music etc
 
 
 
//The Area Should be created
object oDoor = GetFirstObjectInArea(oArea);
while(oDoor != OBJECT_INVALID)
    {
     if(GetObjectType(oDoor) == OBJECT_TYPE_DOOR && GetLocalInt(oDoor,"EXIT")==1)
        {
            NWNXFuncs_SetTag(oDoor,sDestTag); // Give it the destination Tag
            SetLocalObject(OBJECT_SELF,"TARGET_DOOR",oDoor);
            SetLocalObject(oDoor,"TARGET_DOOR",OBJECT_SELF);
            SetLocalInt(oDoor,"INIT",1);
        }
     oDoor = GetNextObjectInArea(oArea);
    }
if(sScript != "")
{
    ExecuteScript(sScript,oArea);
}
 
SetLocalInt(OBJECT_SELF,"INIT",1);
}


 

Note - The way I did this was to either put a waypoint 'near' to the destination door I wanted to link to (with a tag of DEST) or something like that.

Or you can give your intended destination door a tag or variable to mark it as the proper destination door.

If you are looping through all doors in the area, trying to find the door you want to link to - you just need to mark the door as the right door so the script can find it.

 

 

The onUsedScript

This is what ports the player to the destination

Notice the lack of tag use.

Unique tags are required on the door - which is why I do a little bit of tag changing in the onOpen script.

I think internally - if the area and door have duplicate tags as other doors and areas in the module, then even door transitions can get banjaxed.



void main()
{
object oPC = GetClickingObject();
object oDest = GetLocalObject(OBJECT_SELF,"TARGET_DOOR");
AssignCommand(oPC, JumpToObject(oDest));
if(GetObjectType(oDest)==OBJECT_TYPE_DOOR)
    {
     if(!GetIsOpen(oDest))
        {
            AssignCommand(oDest,ActionOpenDoor(oDest));
        }
    }
string sExtra = GetLocalString(OBJECT_SELF,"EXTRA_SCRIPT");
if(sExtra != "")
    {
        DelayCommand(2.00,ExecuteScript(GetStringLowerCase(sExtra),OBJECT_SELF));
    }
}


 

The close door script.

This is so closing on door, will close the door it is linked to.

Simulating the internal behavior from nwn vanilla.


void main()
{
object oDest = GetLocalObject(OBJECT_SELF,"TARGET_DOOR");
if(GetObjectType(oDest)==OBJECT_TYPE_DOOR)
    {
     if(GetIsOpen(oDest))
        {
            AssignCommand(oDest,ActionCloseDoor(oDest));
        }
    }
 
}


               
               

               
            

Legacy_Neverwinter Owl

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Regarding NWNX_Areas & NWNX_Dynres
« Reply #8 on: July 30, 2016, 06:24:00 am »


               

You're right about using tags being a rough idea. It works 99% of the time, but the internal engine or something can definitely get confused once in awhile and some wonky things happen.


 


I myself have had weird things happen, like being teleported one area back, while I was just standing in a field doing nothing. I still have no idea how that logically makes sense. Is it possible someone could have used a different trigger with the same tag as the last trigger I used, and it ran the script on me instead?


 


Either way, time to crack open some brews and convert my transitions/doors over to unique tags and use variable targets instead.