Aller au contenu

Photo

FYI: Area on HB fires even when PC is not in area


  • Veuillez vous connecter pour répondre
16 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Just FYI.  I wasn't sure and just ran a test.  It does.

#2
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Yup it sure does. Actually NPC heatbeats do as well as long as they are spawned, its just the first lines there lower the NPC AI level and end the script if no PCs are in there.

#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
I've found (from bitter experience) that HBs on placeables (like Ipoints) certainly don't run if there are no PCs in the area. I'm not even entirely sure they run unless there is a PC within a given distance (although that's something I've yet to experiment with).

Some consistency in this game would be nice! Or perhaps ways of overriding the default HB behaviour to make it work the way YOU want it to.

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

DannJ wrote...

I've found (from bitter experience) that HBs on placeables (like Ipoints) certainly don't run if there are no PCs in the area. I'm not even entirely sure they run unless there is a PC within a given distance (although that's something I've yet to experiment with).

Some consistency in this game would be nice! Or perhaps ways of overriding the default HB behaviour to make it work the way YOU want it to.



So on placeables, the event itsself doesn't even fire.  Hmmm.... interesting, and good to know.

#5
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

DannJ wrote...

I've found (from bitter experience) that HBs on placeables (like Ipoints) certainly don't run if there are no PCs in the area. I'm not even entirely sure they run unless there is a PC within a given distance (although that's something I've yet to experiment with).

Some consistency in this game would be nice! Or perhaps ways of overriding the default HB behaviour to make it work the way YOU want it to.


Heartbeat scripts on an IPoint do work even when there is no PC in the same area. I use them to control things in other areas when needed in special cases.

Triggers are the only thing that I know of that do not fire their heartbeat no matter if a PC is there or not and that is because they only fire them when some creature/PC is within the trigger area.

Modifié par _Knightmare_, 20 juin 2011 - 12:13 .


#6
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
This is why whenever I make a custom HB script I do a check to see if the PC is in the area or not. If they aren't, then no reason to run the script.

Also, of course, it's helpful to only spawn creatures when the PC enters the area.

#7
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Chaos Wielder wrote...

Also, of course, it's helpful to only spawn creatures when the PC enters the area.


Yup agreed. Having creatures spawn in is better than placing them in down in the toolset. Also another reason why it is advisable to turn as many placeables into Environmental Objects as you can (EOs have no HB or other scripts).

#8
Dann-J

Dann-J
  • Members
  • 3 161 messages

_Knightmare_ wrote...
Heartbeat scripts on an IPoint do work even when there is no PC in the same area. I use them to control things in other areas when needed in special cases.


That's weird - I have HB scripts running off Ipoints that check whether it is day or night, and spawns or kills a group of appropriate creatures. I have the HB script reading local variables off the Ipoint (time of day, encounter tag, is it active or not), and trigger the encounter whenever its specified time of day starts (I just use a course 'day' or 'night' value). It does nothing while the encounter is active during it's specified time, then kills the encounter group when it is no longer their time (so nocturnal creatures appear when GetIsNight is true, and disappear when GetIsNight is false).

It all works fine when there are players in the area, but I'll often arrive into that particular area and not find the nightshift or dayshift. Yet if I sleep in that area, and advance the time by several hours, then the scripts fire properly and the encounter groups either appear or disappear on queue (although usually only if the players are reasonably close).

I was blaming the Ipoint, but perhaps something else isn't playing nice?

#9
Shallina

Shallina
  • Members
  • 1 011 messages
I think only the area hearbat and the module heartbat run all the time.

Creature and placeable in an area are "frozen" if there is no PC in it.

An easy test is to make a script that send message to the PC and run it in the heartbat of something that is in an other area.

#10
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

DannJ wrote...

It all works fine when there are players in the area, but I'll often arrive into that particular area and not find the nightshift or dayshift. Yet if I sleep in that area, and advance the time by several hours, then the scripts fire properly and the encounter groups either appear or disappear on queue (although usually only if the players are reasonably close).

I was blaming the Ipoint, but perhaps something else isn't playing nice?


How are you triggering the encounters? Did you use the TriggerEncounter() function? If so, it is that function that requires a PC in the area in order for it to work correctly.

To do something like you are, I would use the script OnClientEnter of the area so that the creatures are only spawned/existing when there is a PC in the area, otherwise you are using some needless resources (not much but still some).

Shallina wrote...

I think only the area hearbat and the module heartbat run all the time.

Creature and placeable in an area are "frozen" if there is no PC in it.

An easy test is to make a script that send message to the PC and run it in the heartbat of something that is in an other area.


This is exactly what I did way back when to test if the IPoint fires its HB. I just had a short script that did nothing but sent a feedback message to the PC that says "Heartbeat."  No matter what area I trasitioned to, the float string still went off so the IPoint HB does fire when you are not in the area. Since it is a placeable, I assume any placeable HB will still fire off (though I have never personally tested other placeables).

I also know for sure that NPC HBs work as I have them doing things in other areas where there is no player, including having them walk waypoints and even having them fight battles while there is no player in the area. For this to work, you need to force their AI level above VERY_LOW or else the default HB script will immediately return out and end their script.

Modifié par _Knightmare_, 20 juin 2011 - 12:24 .


#11
Shallina

Shallina
  • Members
  • 1 011 messages
My NPC aren't doing anithing if I am not in the area. But I'll check this in detail since I got 4 major area in one module.

Modifié par Shallina, 20 juin 2011 - 01:50 .


#12
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Shallina wrote...

My NPC aren't doing anithing if I am not in the area. But I'll check this in detail since I got 4 major area in one module.


The default NPC HB script (nw_c2_default1) has the following on line 21: if (GetAILevel() == AI_LEVEL_VERY_LOW) return; Any time the area is empty of PCs, it sets NPCs AI level to the VERY_LOW so in effect it makes the HB not fire since it immediately returns out (though it does in fact fire the HB script). You will need to alter that line to say:

if (GetAILevel() == AI_LEVEL_VERY_LOW) 
  {
  SetAILevel(oSelf, AI_LEVEL_LOW);
  }


Then they will do very basic things like walk waypoints. If you want them to do something more complex (like fight a battle as I have them doing), you need to set it to: SetAILevel(oSelf, AI_LEVEL_NORMAL);

#13
Shallina

Shallina
  • Members
  • 1 011 messages
I want them to do nothing in order to avoid strain on the player computer :) So the default setting seem good to me.

#14
Morbane

Morbane
  • Members
  • 1 883 messages
One time I had a NPC with a SpeakString on their HB and set to TalkVolumeShout - the Shouts could be heard in any area at any given time. I fixed it by changing the TalkVolume to standard or whisper I think.

#15
Dann-J

Dann-J
  • Members
  • 3 161 messages

_Knightmare_ wrote...

DannJ wrote...
I was blaming the Ipoint, but perhaps something else isn't playing nice?


How are you triggering the encounters? Did you use the TriggerEncounter() function? If so, it is that function that requires a PC in the area in order for it to work correctly.


I used two instances in Dragonglade where encounters were triggered in different areas than the PC was in, and they worked fine. They were all waiting when you got there. They were triggered by scripts running in the same area as the PC was though, so perhaps that made the difference.

Here's my time-based encounter spawning script:

#include "ginc_group"
void SpawnEncounter(object oEncounter, string sTime)
  {
  SetLocalInt(OBJECT_SELF,"Active",1);
  SetEncounterActive(TRUE,oEncounter);
  TriggerEncounter(oEncounter,GetFirstPC(),ENCOUNTER_CALC_FROM_FACTION, -1.0);
  ResetGroup("e"+sTime);
  EncounterToGroup("e"+sTime,1);
  DelayCommand(0.1, SetEncounterActive(FALSE,oEncounter));
  }
 
void KillEncounter(string sTime)
{
  SetLocalInt(OBJECT_SELF,"Active",0);
  DestroyObjectsInGroup("e"+sTime,0.0);
  ResetGroup("e"+sTime);
}
void main()
{
string sTag = GetTag(OBJECT_SELF);
string sTime = GetLocalString(OBJECT_SELF,"Time");
int iActive = GetLocalInt(OBJECT_SELF,"Active");
object oEncounter = GetObjectByTag("e"+sTag);
if (iActive == 0 && sTime == "day" && GetIsDay())
  {
  SpawnEncounter(oEncounter, sTime);
  }
if (iActive == 0 && sTime == "night" && GetIsNight())
  {
  SpawnEncounter(oEncounter, sTime);
  }
if (iActive == 1 && sTime == "day" && !GetIsDay())
  {
  KillEncounter(sTime);
  }
if (iActive == 1 && sTime == "night" && !GetIsNight())
  {
  KillEncounter(sTime);
  } 
}

_Knightmare_ wrote...

To do something like you are, I would use the script OnClientEnter of the area so that the creatures are only spawned/existing when there is a PC in the area, otherwise you are using some needless resources (not much but still some).


I'd have to use both a placeable HB and an OnClientEnter script. The OnClientEnter would have to be very different though; it would have to cycle through all the Ipoints in the area and check their status. Whereas each Ipoint currently has its own HB script to make sure things spawn/despawned when their time comes around, while the PC was already in the area.

Modifié par DannJ, 20 juin 2011 - 11:16 .


#16
Dann-J

Dann-J
  • Members
  • 3 161 messages

_Knightmare_ wrote...
Triggers are the only thing that I know of that do not fire their heartbeat no matter if a PC is there or not and that is because they only fire them when some creature/PC is within the trigger area.


I had an HB script running off a trigger in Dragonglade. It spawned a portal at a given time of day, and removed it again at another time. The player didn't need to be in the trigger for the portal to spawn.

#17
Dann-J

Dann-J
  • Members
  • 3 161 messages
I think you're right Knightmare - it's probably the encounter that is failing to work, rather than the HB script not firing. Otherwise the creatures would simply spawn within 6 seconds of the PC entering the area.

It looks like the HB is firing, and setting the local variable on the Ipoint saying that the encounter was spawned, even though the encounter didn't actually work. I've spawned encounters from other areas before, but the script that spawns them was always running in the same area as the PC. In this instance, the Ipoint HB is not always running in the same area the PC is in. That seems to be the crucial difference.

Just two extra lines at the top of my main() should fix the problem:

if (GetArea(GetFirstPC()) != GetArea(OBJECT_SELF):
return;

That way the local variable doesn't get set on the Ipoint during a failed encounter spawn, so within six seconds of the PC entering the area, anything that needs to spawn or despawn at that time should happen.

As usual, I've looked for an overly complex answer when just two lines of code would have done the trick...