Looping Scripts
#1
Posté 18 janvier 2010 - 11:47
#2
Posté 19 janvier 2010 - 12:08
#3
Posté 19 janvier 2010 - 01:33
For the creatures, here http://social.biowar...Creature_events , you can find some events that engine sends to creature script. There is the HEART_BEAT event too.
Modifié par Nattfodd, 19 janvier 2010 - 01:34 .
#4
Posté 19 janvier 2010 - 03:59
Here is the script so far:
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
void main()
{
object oPerson = GetObjectByTag("dgman");
object oWay1 = GetObjectByTag("per_way_1");
object oWay2 = GetObjectByTag("per_way_2");
object oWay3 = GetObjectByTag("per_way_3");
object oWay4 = GetObjectByTag("per_way_4");
object oWay5 = GetObjectByTag("per_way_5");
object oWay6 = GetObjectByTag("per_way_6");
object oWay7 = GetObjectByTag("per_way_7");
object oWay8 = GetObjectByTag("per_way_8");
location lPoint1 = GetLocation(oWay1);
location lPoint2 = GetLocation(oWay2);
location lPoint3 = GetLocation(oWay3);
location lPoint4 = GetLocation(oWay4);
location lPoint5 = GetLocation(oWay5);
location lPoint6 = GetLocation(oWay6);
location lPoint7 = GetLocation(oWay7);
location lPoint8 = GetLocation(oWay8);
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
string sDebug;
object oPC = GetHero();
object oParty = GetParty(oPC);
int nEventHandled = FALSE;
object[] aoObject1 = GetNearestObject(oPerson, OBJECT_TYPE_PLACEABLE);
command cUseObject = CommandUseObject(aoObject1[0], PLACEABLE_ACTION_OPEN);
switch(nEventType)
{
case EVENT_TYPE_SPAWN:
{
AddCommand (oPerson, CommandMoveToLocation (lPoint1, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
AddCommand (oPerson, CommandMoveToLocation (lPoint2, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
AddCommand (oPerson, CommandMoveToLocation (lPoint3, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
AddCommand (oPerson, CommandMoveToLocation (lPoint4, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
AddCommand (oPerson, CommandMoveToLocation (lPoint5, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
AddCommand (oPerson, CommandMoveToLocation (lPoint6, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
AddCommand (oPerson, CommandMoveToLocation (lPoint7, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
AddCommand (oPerson, CommandMoveToLocation (lPoint8, FALSE, FALSE), FALSE,
FALSE, COMMAND_ADDBEHAVIOR_DONTCLEAR);
break;
}
}
if (!nEventHandled)
{
HandleEvent(ev, R"test.ncs");
}
}
#5
Posté 19 janvier 2010 - 05:22
#6
Posté 19 janvier 2010 - 06:04
Thank you for all the help so far though Craig. I really do appreciate it
#7
Posté 19 janvier 2010 - 10:09
Craig Graff wrote...
DelayEvent is the function you want. You can look at pre410cr_genlock_emissary.nss for an example of this (though maybe not the most straightforward one).
What would it take to add a function "command CommandSignalEvent(event)" into the toolset. For an example in this particular case you need to know how long it takes to run the script in order to use DelayEvent(). Adding a SignalEvent() in a command queue would be more handy. I have used CommandUseAbility() to trigger EVENT_CUSTOM_COMMAND_COMPLETE but it isn't very intuitive approach.
#8
Posté 19 janvier 2010 - 02:58
Doc Valentine wrote...
The Ambient system does indeed seem to be the best way of making this work. However, it is very confusing to me. I took a look through the Wiki and it did a brief explanation of how to loop walking and how to set animation overrides for the character. But it did not really detail how I might have scripts that activate upon reaching a certain waypont, though I have seen a few functions for that when dealing with MovetoMultiLocation. So I guess if anyone knows the specific way in which I might do this, or knows of a tutorial I may have missed that will explain how to do this through the ambient system.
Thank you for all the help so far though Craig. I really do appreciate it
The lack of documentation in Toolset wiki is a known issue
Both Ambient behaviour system or scripts, let you handle ambient animations of NPC creatures. You can choose according to your abilities. But both of them must follow some restricted rules.
The hardest of these rules is how to identify the animations that fulfill a custom sequence you want to do.
If you are lucky and not much exigent, you can find predefined ambient sequences into ambient_ai 2DA file with a little description. In that case you only need to set in the toolset area editor, two local variables of the creature: the AMBIENT_SYSTEM_STATE and the AMBIENT_ANIM_PATTERN with optionally AMBIENT_ANIM_FREQ (this is explained at http://social.biowar...bient_behaviour).
If you want, you can create a custom ambient_anim_patterns M2DA file (ambient_ai.xls into the source directory) to add a personalized sequence, choosing animations listed into ANIM_base, ANIM_combat or ANIM_placeables 2DAs. The previous link also explains how to set the fields of ambient_ai columns.
If you want more customization you can ask me and i can teach you how to identify the animations listed into ANIM_* 2DAs into the toolset (you will notice that the ANIM_* 2DA column called AnimName does not contain the name of the .ANI file) to let you see a preview of the animation.
#9
Posté 19 janvier 2010 - 06:11
#10
Posté 19 janvier 2010 - 08:43
I have a question: the low level functions are into script.ldf? There is a way to explore it without using the DAToolChest? I can't use it because it crash everytime.
#11
Posté 19 janvier 2010 - 09:07
Ciao, muh!
#12
Posté 19 janvier 2010 - 09:22
#13
Posté 19 janvier 2010 - 10:41
#14
Posté 20 janvier 2010 - 03:47
void InitHeartbeat(
object oCreature, // object is self explanatory, the object to start the heartbeat for
float fInterval // the amount of time between heart beats
);
Now, the next part is also tricky because there are two heartbeat events, there is EVENT_TYPE_HEARTBEAT and EVENT_TYPE_HEARTBEAT2. EVENT_TYPE_HEARTBEAT2 is the one that will work with the script set above. Now, for the interval, I set it to the default NWN/Kotor heartbeat which is 6.0 seconds. Some situations may call for more or less, but I feel that's a pretty good start.
I'm hoping that by having the heartbeat set, the door issue will no longer be a problem. Before, I had a looping spawn script that got messed up when it was interrupted when the NPC opened a door that was blocking him. Since the heartbeat script activates every 6 seconds, interruptions shouldn't cause too much of an issue.
Either way, that's how it worked out for me.





Retour en haut






