Author Topic: Question about area building...  (Read 1257 times)

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« on: March 19, 2015, 03:53:10 pm »


               

I have an old PW mod that has a number of city areas with many shops. Currently each shop is its own area. I'm wondering if it wouldn't be more efficient to condense those little internal shop areas into one not overly large area. Are there any pros and cons to doing this that I should be aware of?



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Question about area building...
« Reply #1 on: March 19, 2015, 04:04:55 pm »


               

AFAIK Its best to locate all of the actual stores in an area that players do not visit. By the actual store i mean the waypoint looking object rather than the NPC who provides access to the store.


 


If you do this, then combining those areas into one should work fine.



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« Reply #2 on: March 19, 2015, 04:07:59 pm »


               


AFAIK Its best to locate all of the actual stores in an area that players do not visit. By the actual store i mean the waypoint looking object rather than the NPC who provides access to the store.


 


If you do this, then combining those areas into one should work fine.




 


Why exactly is that better? As I mentioned before this mod is older (was last updated in 1.68) but it currently has the stores spawn in, much like npcs spawn in, with an on enter script. If the area is empty of players then npcs/shops/items left on the ground are cleaned up and removed. I'm all for improvements though. I'd just like to understand the benefits of doing the shops that way. The way I currently do it allows for shop inventories to be periodically reset so they never get overburdened with too many things being sold to the vendors yet still gives players an opportunity to buy the vendored items of others if a market area is particularly busy with players.



               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Question about area building...
« Reply #3 on: March 19, 2015, 04:45:42 pm »


               

I recommend condensing things like generic shops and generic buildings into one physical area per city or general location. Then use the OnEnter script to hide the area every time someone enters so that if they've already visited other shops in that physical area, they don't show on the minimap.


 


Not only does this make it a little easier to manage these locations in the toolset, but it helps reduce the number of resources in the module since there is the known limitation of ~16K resources (.are, .git, .uti, .nss, etc, etc, etc) files that can be in the module before you start running into problems.



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« Reply #4 on: March 19, 2015, 05:11:06 pm »


               


I recommend condensing things like generic shops and generic buildings into one physical area per city or general location. Then use the OnEnter script to hide the area every time someone enters so that if they've already visited other shops in that physical area, they don't show on the minimap.


 


Not only does this make it a little easier to manage these locations in the toolset, but it helps reduce the number of resources in the module since there is the known limitation of ~16K resources (.are, .git, .uti, .nss, etc, etc, etc) files that can be in the module before you start running into problems.




Oooh I like that "hide the map" on enter tip! That was a minor concern of mine that the map would look a bit silly. Do you happen to know the specific script command to do that?



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Question about area building...
« Reply #5 on: March 19, 2015, 05:41:38 pm »


               

I could be wrong but my understanding was that all the inventory of a store was cycled through when a player enters an area. Perhaps this is only on the first entry. In anycase, I have observed some delays on area entry when lots of stores are in the same area, and saw the problem go away when I located the stores elsewhere.



               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Question about area building...
« Reply #6 on: March 19, 2015, 06:20:10 pm »


               

The ExploreAreaForPlayer function is where the magic happens. Something like this should do the trick if you put it in your Area OnEnter script, so long as the right-hand side of the name of any generic shops area is 'Shops':


 


object oPC = GetEnteringObject();


if (GetStringRight(GetName(OBJECT_SELF), 5) == "Shops")  ExploreAreaForPlayer(OBJECT_SELF, oPC, FALSE);



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« Reply #7 on: March 19, 2015, 07:14:05 pm »


               


The ExploreAreaForPlayer function is where the magic happens. Something like this should do the trick if you put it in your Area OnEnter script, so long as the right-hand side of the name of any generic shops area is 'Shops':


 


object oPC = GetEnteringObject();


if (GetStringRight(GetName(OBJECT_SELF), 5) == "Shops")  ExploreAreaForPlayer(OBJECT_SELF, oPC, FALSE);




Much obliged!


               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« Reply #8 on: March 19, 2015, 07:18:23 pm »


               


I could be wrong but my understanding was that all the inventory of a store was cycled through when a player enters an area. Perhaps this is only on the first entry. In anycase, I have observed some delays on area entry when lots of stores are in the same area, and saw the problem go away when I located the stores elsewhere.




My consolidated area would have about 8 shops in it... I may give your suggestion a try!


               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Question about area building...
« Reply #9 on: March 20, 2015, 01:43:44 am »


               

Henesua is correct, inventories of placeables and the inventories of merchants waypoints get loaded when a PC enters the map they are found on. This can add to an areas loading times. If this made stores load faster when you accessed them, any extra load time would likely be moot. It doesn't though. When you open a store, all the inventory info is resent anyhow. So in the end, having stores on a single map that is inaccessible to players works just fine and can help optimize a module when combined with other lag reducing practices.


 


To enable merchant waypoints to work anyplace in your module, just change


 


object oStore = GetNearestObjectByTag("Store_"+sStore);


 


to


 


object oStore = GetObjectByTag("Store_"+sStore);


 


in your open store scripts.



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« Reply #10 on: March 20, 2015, 04:31:47 am »


               


Henesua is correct, inventories of placeables and the inventories of merchants waypoints get loaded when a PC enters the map they are found on. This can add to an areas loading times. If this made stores load faster when you accessed them, any extra load time would likely be moot. It doesn't though. When you open a store, all the inventory info is resent anyhow. So in the end, having stores on a single map that is inaccessible to players works just fine and can help optimize a module when combined with other lag reducing practices.


 


To enable merchant waypoints to work anyplace in your module, just change


 


object oStore = GetNearestObjectByTag("Store_"+sStore);


 


to


 


object oStore = GetObjectByTag("Store_"+sStore);


 


in your open store scripts.




 


Thanks for that I'll give it a shot!


 


Also Thayan thank you! I put a bit of my own spin on the script but the fog of war works absolutely perfectly on my interior map! Only the shop the player is in has its map shown and the others remain black no matter where you enter from or how often!



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« Reply #11 on: March 21, 2015, 05:40:45 am »


               

Would either of you guys know of a good way to reset the merchants in that inaccessible area to periodically clean them out of any sold goods so they don't get bogged down?



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Question about area building...
« Reply #12 on: March 22, 2015, 04:34:24 am »


               

I clean my own stores instantly, using the module "OnUnAcquireItem" event. Here's what I use for it:



#include "x2_inc_switches"
void main()
{
     object oItem = GetModuleItemLost();
     if (GetObjectType(GetItemPossessor(oItem)) == OBJECT_TYPE_STORE) DestroyObject(oItem, 0.1f);
     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_UNACQUIRE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }

     }

}

This cleans sold items as each is sold. Some might consider it a drawback as that means something "accidentally" sold is lost, but with my economy, the sell value rarely comes close to the buying price and most couldn't .. or wouldn't repurchase at the time anyhow. My players just take a screenie .. send me a PM .. then suffer a lecture .. before I replace the item. '<img'>


 



               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Question about area building...
« Reply #13 on: March 22, 2015, 12:43:31 pm »


               

Basic advice - script CLEANLY, efficiently and you need not worry about 'too many areas'.


 


My server is stable, does not lag, does not crash, is repleat with smooth-running features, and boasts 1337+ Areas. Emphasis on the "+". NWN is a robust game, well built and stable. More, it was built for machines we were running 14 years ago... today's machines are far superior. The bottom line is this, unless the user does something really not-well-thought-out, NWN will  run fine. If you start to see lag or running crash issues, look to the systems used first (rather than too many areas).


               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Question about area building...
« Reply #14 on: March 23, 2015, 06:42:43 am »


               


I clean my own stores instantly, using the module "OnUnAcquireItem" event. Here's what I use for it:



#include "x2_inc_switches"
void main()
{
     object oItem = GetModuleItemLost();
     if (GetObjectType(GetItemPossessor(oItem)) == OBJECT_TYPE_STORE) DestroyObject(oItem, 0.1f);
     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_UNACQUIRE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }

     }

}

This cleans sold items as each is sold. Some might consider it a drawback as that means something "accidentally" sold is lost, but with my economy, the sell value rarely comes close to the buying price and most couldn't .. or wouldn't repurchase at the time anyhow. My players just take a screenie .. send me a PM .. then suffer a lecture .. before I replace the item. '<img'>




 


 


I'd prefer not to go this route. Ideally items would be "cleaned" out from vendors every few hours. I don't actually have any lag issues but I'm looking to optimize my mod and make things more efficient without giving up too much (I'd like the ability to buy back items if sold accidentally or to have other players have a chance to buy something sold to a vendor at least for a 2 hours).