Author Topic: Questions about NPCs and PWs.  (Read 374 times)

Legacy_QlippothVI

  • Full Member
  • ***
  • Posts: 197
  • Karma: +0/-0
Questions about NPCs and PWs.
« on: June 04, 2012, 12:33:08 am »


                I'm looking at incorporating NPC Activities 6.2, basically Peak's additions and corrections
 (Pathways and professions)  to Deva's NPC Activities 6.1. The issues I"m finding, and this is probably no news to you, is that NPCs don't operate very well when no PC is in the area, or not in the module at all.

Is there any workaround for this? I'd like to make a PW where the NPCs continue to move and perform their actions while no PC is present. How can I keep them performing as if a PC is present? I see come complex workarounds in Deva's Harvest of Souls, but there are other issues. Like when you save a game and reload it, the NPCs seem to continue to perform as if no PC is present.

The other possible option, if it is possible, is to basically freeze the module when the last PC logs out. Sort of like a module-wide Timestop. Any joining PC would be put in a holding area where Timestop has no influence until things are started moving again.

Any ideas? I"m moving on for now to an SP story where I don't have to worry about these things, but in the end would like to find a way to keep creatures moving when no PCs are on the server.

 - Qlippoth
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #1 on: June 04, 2012, 12:52:20 am »


               Well I have no Idea what any of the systems you named are.   Without links you might as well not even listed them.  I have no time to look at them at the moment, if any one did want to look at them however I guess the will have to go searching for them.

The only suggestion I can make without looking at the scripts is to make sure the NPC's AI level is set to either AI_LEVEL_NORMAL or AI_LEVEL_HIGH.  You may find that you just end up creating more lag then needed though.
               
               

               
            

Legacy_QlippothVI

  • Full Member
  • ***
  • Posts: 197
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #2 on: June 04, 2012, 10:01:58 pm »


               Thanks, I just didn't know what to look for and that gave me a place to start. '<img'>

Any ideas for "freezing" a PW when no PCs are logged in? I know it sounds weird, just wondering.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #3 on: June 04, 2012, 10:21:43 pm »


               

QlippothVI wrote...

Thanks, I just didn't know what to look for and that gave me a place to start. '<img'>

Any ideas for "freezing" a PW when no PCs are logged in? I know it sounds weird, just wondering.

just place timestop effect on any placeable and remove it when its over, im using this long time ago and the server wont run any script at all

there is a little issue if you are using mysql though
               
               

               
            

Legacy_QlippothVI

  • Full Member
  • ***
  • Posts: 197
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #4 on: June 05, 2012, 12:02:47 am »


               I don't currently have plans for NWNX, but I have run the Universe of Arlandia, which is a random layout of template areas used over and over from a MySQL database. That was cool, technicaly speaking, but didn't have a story. It's a build cities and dominate the planet while fighting off monsters kinda sandbox.

What issues does this Timestop method cause such a module?

I'll have to figure out how to run Timestop when the last PC exits in every area but the Holding/Start area. I'm glad to know that this is possible, I have plans for a "Build an outpost" with wandering groups "entering and exiting" the module. I just have to work out the kinks when a PC isn't present and things get wonky... Mainly this is my lack of experience with scripting.

EDIT: Ooops, I was thinking of adding Timestop (area specific) to every area but one (start/re-enter). Are you talking about the module-wide timestop? So I could have a placable cast Timestop, halt everything in the module, then dismiss or expire the Timestop when a PC enters?
               
               

               


                     Modifié par QlippothVI, 04 juin 2012 - 11:26 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #5 on: June 05, 2012, 12:59:32 am »


               Does this module wide time stop actually stop the game clock?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #6 on: June 05, 2012, 08:06:29 am »


               

QlippothVI wrote...

EDIT: Ooops, I was thinking of adding Timestop (area specific) to every area but one (start/re-enter). Are you talking about the module-wide timestop? So I could have a placable cast Timestop, halt everything in the module, then dismiss or expire the Timestop when a PC enters?

yes this is module wide timestop, the issue with MySQL is that MySQL tent to shutdown when not used in specific ammount of time - to workaround it you must call some query each X hours.

If your PW is very populated then this isn't option for you anyway. Solution could be to despawn/spawn all NPCs when area is empty or kill them (with setdestroyable so they won't disappear) and resurect them after or to remove all scripts from them via NWNX.

henesua

well no delaycommands run, so time should be stopped as well but I never checked out actually so can't tell for sure
               
               

               
            

Legacy_QlippothVI

  • Full Member
  • ***
  • Posts: 197
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #7 on: June 11, 2012, 02:40:07 am »


               ShaDoOoW, any chance you could share your TimeStop script? I'm actually thinking of using this as a workaround for a bug I see in Harvest of Souls and might help me immensely. I would also use it in the project I mention earlier, obviously. Are you willing to share it? You could put it on the Vault and maybe Nexus as well. Or just share it here, just wondering. I think it might be useful to others.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #8 on: June 11, 2012, 02:54:59 am »


               You talking about Deva Winblood's module? I hear that is good fun. He was telling me about it recently.
               
               

               
            

Legacy_QlippothVI

  • Full Member
  • ***
  • Posts: 197
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #9 on: June 11, 2012, 03:39:49 am »


               Yeah, there is an issue, that "appears" solvable, but is beyond my limited scripting knowledge.

I suspect that the scripts that detect the lack of a PC for special NPC creature handling are not detecting a PC when a save game is loaded. Some pretty interesting handling of AI when little AI resources are availanble, I think he assigned them to the module? Loading a save game will display creatures that jump around the screen, even during combat with a PC present in the area/server. This doesn't occur at any other time. And if this is occuring with your own NPC followers you can tell them to stay put and then ask them to follow you again and things are fine, but only for them. You can't exactly do the same thing with hostil creatures that want to kill you.

I'm not sure a PC exists during the save game loading phase. I might be totally wrong, but it severely hampers the game (that can span HOURS/DAYS/ETC). Currently I run an XP virtual machine witha NWServer in VMWare Workstation, then suspend the VM for resuming it later. VERY handy, but not everyone have a beefy machine with a ton of RAM to throw at this issue like myself. I'd like to solve it in the module.

Otherwise I'm just knocking out some easy bugs, a typo here in a waypoint name, an additional script fix in a dialog, some pathing issues in the Drow Tileset, etc. ':wizard:'

I have a few ideas for additional features, but want the bugfix release as a base for the feature expansion.

The next big issue is figuring out why the LootCorpse script doesn't work when no PC is present on a running server... The little fixes are still all worthy of an update to my unofficial bugfix release. I've had so much fun with it, and RTS/RPG/etc game with battling creatures running about the living module.

The two big issue are the save game gameplay sabotage and the fact that too many lootbags after a a day of playing start to bring the server to a halt, then an untimely demise... I was hoping Lootcorpse would work as well when no PC was present. PC ingame, it's all working. Log out and return and loot bags are all over... <>

Anyway, the Timestop solution could allow the PC to exit the server, Timestop kicks in, then you save the game in stasis to resume later. Load save, log in, and the world resumes... Hopefully with all of the creatures never knowing the PC is missing and causing the bug (as is my theory anyway).
               
               

               


                     Modifié par QlippothVI, 11 juin 2012 - 02:48 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #10 on: June 11, 2012, 01:11:04 pm »


               its very simple:

Call this in OnClientEnter:

void UnpauseModule()
{
object o = GetObjectByTag("SYSTEM_NPC");
 if(GetIsObjectValid(o))
 {
 effect e = GetFirstEffect(o);
  while(GetIsEffectValid(e))
  {
   if(GetEffectType(e) == EFFECT_TYPE_TIMESTOP)
   {
   PrintString(">> A player just logged in, exiting sleep mode. <<");
   RemoveEffect(o,e);
   }
  e = GetNextEffect(o);
  }
 }
}


 
And call this in both OnModuleLoad and OnClientExit

void SleepMode()
{
 if(GetFirstPC() == OBJECT_INVALID)
 {
 SetPersistentString(GetModule(),"PERSISTENT_TIME",GetTimeStamp());
 PrintString(">> Last player exited game, entering sleep mode. <<");
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectTimeStop(),GetObjectByTag("SYSTEM_NPC"),14400.0);
 DelayCommand(0.1,SleepMode());
 }
}


The SetPersistentString line is very important (at least if you using NWNX2), it doesnt matter what you will store, it might be any MySQL call afterall even 1+1. The purpose is to keep MySQL running - there is a known issue, when MySQL will shutdown if there are no calls within certain ammount of time. To compile it you need "aps_include", if you dont have it in your module than you can safely comment the line out.

Also you need system npc to create the timestop effect.
               
               

               


                     Modifié par ShaDoOoW, 11 juin 2012 - 12:13 .
                     
                  


            

Legacy_QlippothVI

  • Full Member
  • ***
  • Posts: 197
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #11 on: June 12, 2012, 04:44:34 pm »


               Sweet, thanks! I'll try it out soon and let y'all know.
               
               

               
            

Legacy_QlippothVI

  • Full Member
  • ***
  • Posts: 197
  • Karma: +0/-0
Questions about NPCs and PWs.
« Reply #12 on: June 18, 2012, 05:09:06 pm »


               Drat! It works great, and I'll be using it in a PW idea i have, but it doesnt solve the AI issue in Harvest of Souls. I think it's due to a script being run on load that ma not react well to loading a save game, simce i hear the PC is not detected right away by scripts onLoad