"Change" the "OnHeartBeat" timing
#1
Posté 11 juillet 2013 - 12:39
is there a trick in Neverwinter Nights 2 scripting (or other) to change the timing of the "OnHeartbeat" of an Area (that is about 6 seconds) ??
If i have to do an operation in my script about 4 times per second how can i do it ??
Maybe a "while cicle" in the script assigned to the "OnHeartbeat" event of the Area ??
thanks for answers !!
#2
Posté 11 juillet 2013 - 12:59
#3
Posté 11 juillet 2013 - 01:08
I will try it, obviously are welcome even other solutions or tricks :-)
#4
Posté 11 juillet 2013 - 02:11
object oArea = GetObjectByTag("your_area_tag");
SetCustomHeartbeat(oArea, 4000);
Edit:
Ah, you want 4 times per second, not every 4 seconds. In that case,
SetCustomHeartbeat(oArea, 250);
Modifié par Tchos, 11 juillet 2013 - 02:13 .
#5
Posté 11 juillet 2013 - 08:21
#6
Posté 11 juillet 2013 - 10:55
#7
Posté 12 juillet 2013 - 05:33
#8
Posté 12 juillet 2013 - 06:18
I went and tested this, and I think you'll be happy to find that it does. I have a heartbeat script on the two placeables in this video (a wine crate, and an ipoint), and I've used SetCustomHeartbeat(OBJECT_SELF, 1000) to give them 1-second heartbeats. In the video, you can see that their SpeakString() calls are being executed every 1 second.DannJ wrote...
SetCustomHeartbeat() [...] certainly doesn't work on placeables (including iPoints).
Demo
Modifié par Tchos, 12 juillet 2013 - 06:20 .
#9
Posté 12 juillet 2013 - 12:53
adding the following to the area oncliententer:
void MyOperation(object oObject)
{
//something to make sure this only runs while the player is in the area
//change this or remove it depending on what you want done... could also use a
// GetIsObjectValid(oObject) to make sure you're not running it when object is gone
// too many heartbeat functions in a module will ruin other things, like Kaedrin's
if(GetTag(GetArea(GetFirstPC()))==GetTag(GetArea(oObject)))
{
//***insert whatever you want done here***
// a delay of 0.25 s to run this again...
DelayCommand(0.25,MyOperation(oObject))
}
}
#10
Posté 12 juillet 2013 - 02:16
Must i put the two lines of code in a script assigned to the "OnHeartbeat" of the area ??
#11
Posté 12 juillet 2013 - 04:19
In Crimmor, the item Evercarpet relies on ipoints with very short custom heartbeats to produce it's effect when used.Tchos wrote...
I went and tested this, and I think you'll be happy to find that it does. I have a heartbeat script on the two placeables in this video (a wine crate, and an ipoint), and I've used SetCustomHeartbeat(OBJECT_SELF, 1000) to give them 1-second heartbeats. In the video, you can see that their SpeakString() calls are being executed every 1 second.DannJ wrote...
SetCustomHeartbeat() [...] certainly doesn't work on placeables (including iPoints).
Demo
#12
Posté 12 juillet 2013 - 04:29
You could do that, but I wouldn't recommend it. It would be more efficient to put the lines in some place where they'd only be run once (or at least only once per visit), because you don't need to set the heartbeat over and over. You could put it in your area's On Client Enter slot, for instance.Fabb_u wrote...
Excuse me Tchos but exactly how should i use your trick ?
Must i put the two lines of code in a script assigned to the "OnHeartbeat" of the area ??
If you do put it in the actual area's script set, then you don't need the first line. You could use "OBJECT_SELF" to refer to the area.
I'll have to check that out.kamal_ wrote...
In Crimmor, the item Evercarpet relies on ipoints with very short custom heartbeats to produce it's effect when used.
Modifié par Tchos, 12 juillet 2013 - 04:30 .
#13
Posté 13 juillet 2013 - 10:46
1- I have an area whose Tag is "area1"
2- I assign a script to the "On clientEnter" event of this area; the script is the follow:
void main()
{
object oArea = GetObjectByTag("OBJECT_SELF");
SetCustomHeartbeat(oArea, 250);
}
3- I assign a script to the "On HeartBeat" event of the area; the script is the follow:
void main()
{
int h = GetCustomHeartbeat(GetObjectByTag("OBJECT_SELF"));
SendMessageToPC(GetFirstPC(), "message ! " + IntToString© + " heart= " + IntToString(h));
}
The value of "h" is always "0" and the message appears every 6 seconds, so the new definition of the heartbeat doesn't work !!!
#14
Posté 13 juillet 2013 - 11:01
void main()
{
object oArea = OBJECT_SELF;
SetCustomHeartbeat(oArea, 250);
}Or, you can skip the first line entirely, and write:
void main()
{
SetCustomHeartbeat(OBJECT_SELF, 250);
}Or, you could also write it like this, since your area's tag is "area1":
void main()
{
object oArea = GetObjectByTag("area1");
SetCustomHeartbeat(oArea, 250);
}
Modifié par Tchos, 13 juillet 2013 - 11:07 .
#15
Posté 13 juillet 2013 - 11:53
Maybe the SetCustomHeartbeat doesn't work with an area?
Could you send me the module which you used to do yours "Demo" video ???
#16
Posté 13 juillet 2013 - 12:04
#17
Posté 13 juillet 2013 - 01:22
From this point, though, if you still want to use the custom heartbeat, could you put your script (whatever you want to do with this heartbeat) on an ipoint in the area instead of on the area itself?
Modifié par Tchos, 13 juillet 2013 - 01:23 .
#18
Posté 13 juillet 2013 - 02:01
#19
Posté 13 juillet 2013 - 03:28
#20
Posté 13 juillet 2013 - 04:08
I think to use this creature like an "observer" to take this info about 4 times per second: this creature has to be "invisible", not a member of the party ... it must not enjoy battles, not interact with enemies or npc ecc.
#21
Posté 13 juillet 2013 - 04:49
#22
Posté 14 juillet 2013 - 11:16
I wanted fading footsteps to appear behind the player as they moved across the overland map, and once every six seconds wasn't nearly frequent enough (unless the player was a kangaroo). 'Track Rat' does his job brilliantly though. He even offsets the tracks slightly to either side in alternate directions to make them look like actual foot or hoof prints.
#23
Posté 15 juillet 2013 - 01:57
#24
Posté 15 juillet 2013 - 11:46
#25
Posté 15 juillet 2013 - 01:10
Regardless, even if you use a creature, it doesn't have to follow the player around.
Modifié par Tchos, 15 juillet 2013 - 01:20 .





Retour en haut






