In my test area I have a single npc running my heartbeat. The first thing I do in the heartbeat is print a debug message indicating it's run. I never see the debug message, much less those built in to the other functions getting called by the heartbeat.
#include "sh_npc_activinc"
#include "sh_npc_include"
#include "sh_npc_determine_activity"
void main()
{
object oPC = GetFirstPC();
SendMessageToPC(oPC, "Debug: Heartbeat running" );
object oNpc = OBJECT_SELF;
object oMod = GetModule();
GlobalSet (oMod);
AreaTransition(oNpc);
HeartbeatCheck (oNpc);
int nUd = GetLocalInt(oNpc, "ud");
if (nUd == 1) {return;}
if (IsInConversation(oNpc) == TRUE){return;}
int nSpeak = (0);
//int nReset = 0;
int nReset = GetLocalInt (oNpc, "reset");
object oWp1 = GetCurrentWp (oNpc);
//object oWp1 = GetObjectByTag("ip_wake1l");
VariableSwitcher (oNpc, oWp1, nReset);
int nCurrentActivity = CurrentActivity();
//int nSwitch = GetTimeActivity (oNpc);
{switch (nCurrentActivity)
{
SendMessageToPC(oPC, "Debug: heartbeat case switch");
case 0: NpcHidden (oNpc, oWp1, nSpeak); break;
//removed cases for post brevity.
default: NpcDisarm (oNpc); NpcMeditate (oNpc, oWp1, nSpeak); break;
}
}
How can a heartbeat not run
Débuté par
kamal_
, juil. 05 2011 12:09
#1
Posté 05 juillet 2011 - 12:09
#2
Posté 05 juillet 2011 - 02:17
Can't say I have ever had a HB not fire at all. I'm sure you did, but you made sure that things like the HB compiled correctly, that the NPC instance has the script assigned (with no spelling errors in script name), etc?
#3
Posté 05 juillet 2011 - 02:54
HB scripts sometimes don't seem to fire if the creature is busy doing something specific. Is your NPC otherwise occupied?
Do HB scripts fire if a creature is walking waypoints, for instance?
Do HB scripts fire if a creature is walking waypoints, for instance?
#4
Posté 05 juillet 2011 - 04:01
If the PC is out of the area, NPC heartbeat scripts will stop after a few rounds, regardless of the AI setting.
To be sure thought, check for the usual suspects: typos, override/hak scripts, or some kind of syntax error. One possibility is that the HB script has some sort of infinite loop or other weird problem, which throws a too-many-functions error. The script runs once, before your PC is loaded and can display messages, and then gets stuck.
To be sure thought, check for the usual suspects: typos, override/hak scripts, or some kind of syntax error. One possibility is that the HB script has some sort of infinite loop or other weird problem, which throws a too-many-functions error. The script runs once, before your PC is loaded and can display messages, and then gets stuck.
#5
Posté 05 juillet 2011 - 05:25
I had the same problem. As Lugaid said, it turns out that the HB scripts run at a much slower rate (once per 60 seconds vs once per 6 seconds IIRC) when there are no PCs in the area. From my brief investigation, it looked like this could be overridden but I never tried - the timing was fine once I understood what was happening. Check out the default heartbeat scripts. If you trace them far enough, you'll see the logic unfold.
Modifié par ç i p h é r, 05 juillet 2011 - 05:26 .
#6
Posté 05 juillet 2011 - 12:15
If you can't get the regular HB script to start working, you could consider using a Fake Heartbeat script. Below is the thread where Pain describes it.
Fake Heartbeat Scripting
Fake Heartbeat Scripting
#7
Posté 05 juillet 2011 - 01:09
Based on the thing suggested, lugaid is most likely right about some exotic reason such as an infinite loop somewhere. This is a straightforward single area module, with no placeables other than what I need to test the ai (ipoints and waypoints) there are two npcs. One running this ai to test it, and another I can talk with to advance time. There are no onenter scripts on the area, triggers, or anything like that.
The heartbeat itself is basically the same oneused in the Uncle FB ai, only with more cases and a few changed function parameters. The heartbeat itself is sound (it was previously running). So some change I made in one of the functions that gets called must have caused this. Just didn't understand how I could not see the initial debug line, and the fact it runs before the player enters can explain it if there's a problem in one of the functions.
The heartbeat itself is basically the same oneused in the Uncle FB ai, only with more cases and a few changed function parameters. The heartbeat itself is sound (it was previously running). So some change I made in one of the functions that gets called must have caused this. Just didn't understand how I could not see the initial debug line, and the fact it runs before the player enters can explain it if there's a problem in one of the functions.
#8
Posté 05 juillet 2011 - 08:19
If you are in the same area, try having the NPC speak a string instead as a debug.
I actually just ran into a problem myself where SendMessageToPC(GetFirstPC(), "<Message>"); didn't seem to be working when it ought - in this case it was being called from a script fired from the levelup_class GUI, and I still haven't gotten to the bottom of it (the script was definately running). Seeing this, I only wonder if it might be some issue with that function; if you tried a speak string it would lend weight to whether the script is being executed or not.
I actually just ran into a problem myself where SendMessageToPC(GetFirstPC(), "<Message>"); didn't seem to be working when it ought - in this case it was being called from a script fired from the levelup_class GUI, and I still haven't gotten to the bottom of it (the script was definately running). Seeing this, I only wonder if it might be some issue with that function; if you tried a speak string it would lend weight to whether the script is being executed or not.
#9
Posté 05 juillet 2011 - 08:25
Pain's advice here is good. Recursive functions are meant to be notorious performance hogs (apparently something to do with the DelayCommand makes it worse, I can't remember what but someone who apparently knew what was going on "under the hood" (though I wouldn't call it a "hood" so I don't know why I used that saying...) was explaining this somewhere... anyway, I digress) but if they only fire a few times, as the ones used in spellscripts etc. will do, they're fine. The issue is that if a recursive function never stopped, and could be called more than once, it could quickly bog down the game (imagine Melf's Acid Arrow permanently taking up processing power).M. Rieder wrote...
If you can't get the regular HB script to start working, you could consider using a Fake Heartbeat script. Below is the thread where Pain describes it.
Fake Heartbeat Scripting
#10
Posté 05 juillet 2011 - 08:40
There is always the hit point issue with placeables
#11
Posté 05 juillet 2011 - 10:30
I was able to get the heartbeat to run again. I removed all my code from one of the scripts that gets called and just returned a hardcoded value. Lugaid's suggestion of infinite loop or other weird problem appears to be correct. Now comes finding the logical error causing the problem.
edit: the problem was caused because not all paths of the function being called returned a value. What's odd is the compiler didn't see that yesterday, but did today. There are still bugs to be worked out in the code, but at least I can now look for them properly.
edit: the problem was caused because not all paths of the function being called returned a value. What's odd is the compiler didn't see that yesterday, but did today. There are still bugs to be worked out in the code, but at least I can now look for them properly.
Modifié par kamal_, 05 juillet 2011 - 11:05 .





Retour en haut







