Ironworks Gaming Forum

Ironworks Gaming Forum (http://www.ironworksforum.com/forum/index.php)
-   Neverwinter Nights 1 & 2 Also SoU & HotU Forum (http://www.ironworksforum.com/forum/forumdisplay.php?f=16)
-   -   [scripts] Delaying events (http://www.ironworksforum.com/forum/showthread.php?t=35481)

Legolas 06-09-2003 10:40 AM

Now I have a question.
I am finally nearing the stage where the first village of my module is completed; I have only one quest left to add before I can move on to new areas. This one gives me some trouble though.

The problem is that I can't figure out how to delay things in a script. Actions I can do, of course, and I can make creatures and conversations pause.
But I've no idea how to delay an object's creation, a creature's spawning or a journal entry update.

So far, I've been working around the problem by only updating the journal through conversations, keeping creatures in a waiting room and simply delaying the action of their jumping to a waypoint, and creating items in other people's inventories and delaying the action of giving the item to the PC. Although it works, it is not what I want to see, and it takes far more time than it should.

So my question, how do I make a simple script like this work:
Quote:

void main()
{
if(GetLocalInt(GetFirstPC(), "GVXvartspawn") == 1)
{
location lGVXvart1 = GetLocation(GetWaypointByTag("GVXvart1"));
<font color=red>DelayCommand(9.0, CreateObject(OBJECT_TYPE_CREATURE, "xvart1", lGVXvart1));</font>
location lGVXvart2 = GetLocation(GetWaypointByTag("GVXvart2"));
<font color=red>DelayCommand(9.5, CreateObject(OBJECT_TYPE_CREATURE, "xvart2", lGVXvart2));</font>

DelayCommand(9.6, AssignCommand(GetObjectByTag("xvart1"), ActionForceMoveToLocation(GetLocation(GetWaypointB yTag("GVXvart1D")), TRUE)));
DelayCommand(9.8, AssignCommand(GetObjectByTag("xvart2"), ActionForceMoveToLocation(GetLocation(GetWaypointB yTag("GVXvart2D")), TRUE)));

SetLocalInt(GetFirstPC(), "GVXvartspawn", 2);
}
}
Obviously it cannot be done using a DelayCommand, and an ActionWait would have nothing to do with it either.
It's annoying, even the far more limited WC3 editor has a command that pauses the execution of the script for a while.

philip 06-09-2003 12:10 PM

Quote:

Originally posted by Legolas:
Obviously it cannot be done using a DelayCommand, and an ActionWait would have nothing to do with it either.

Have you tested those functions or do you just assume they don't have anything to do with it (it might be that ActionWait() on OBJECT_SELF (if it's possible you didn't say that) works)? Otherwise you could try to DelayCommand() an ExecuteScript(), IIRC I had a way to this kind of things and I never used other functions than DelayCommand() and ActionWait(). If it's an object you could try the ActionWait() and change the DelayCommand() that assign actions to the xvarts to ActionWait() and change the floating numbers so it fits in what you want. If it's not an object you could try it with executing this script on an invisible object.

I don't think there's a function to delay the script from moving further but a work-around is possible

SpiritWarrior 06-09-2003 01:31 PM

Never actually tried this specifically and I would have done it like you have, using DelayCommand...obviously it does not work here.

I'm not near the toolset right now but I can mess around with it later and see what I can find. I am sure there is a workaround to this and if I don't stumble upon it I can ask around and find someone who has...I'll let ya know.

Chewbacca 06-09-2003 03:07 PM

Try ActionCreate

See NWN Lexicon for more info:
http://www.reapers.org/nwn/reference/

DelayCommand only works for Action* functions.

You can also call user-defined events to fire, but thats a level of scripting I'm not at yet. [img]smile.gif[/img]

Chewbacca 06-10-2003 01:39 AM

Quote:

Originally posted by Chewbacca:
Try ActionCreate

See NWN Lexicon for more info:
http://www.reapers.org/nwn/reference/

DelayCommand only works for Action* functions.

You can also call user-defined events to fire, but thats a level of scripting I'm not at yet. [img]smile.gif[/img]

Oops, I mis-typed ActionWait only works for Action* functions, that is it wont "pause" the execution of a script. It will pause character actions like animations.

DelayCommand will work to conjure up a creature, here is an example from the NWN lexicon that is used to make skeletons out of a pile of bones in the OC. It is a heartbeat script, but if used with an invisble object that fires a destroy object on itself after it spawns its mob you can make it spawn once and the heartbeat script disappears with the invisble object.
Quote:

string sCreature = "NW_SKELWARR01";
location lLoc = GetLocation(OBJECT_SELF);
DelayCommand(0.3, ActionCreate(sCreature, lLoc));
/* ***
** The DelayCommand message above could be replaced with
** ActionDoCommand(ActionCreate(sCreature, lLoc));
*** */

Legolas 06-10-2003 12:03 PM

It would appear that delaying the execution of another script does indeed work. Yay :D
Unfortunately, that means I'll have even more miniscripts lying about. But it's small price, I guess. Thanks everyone [img]smile.gif[/img]

SpiritWarrior 06-10-2003 09:37 PM

Well I see you seem to have it sorted but I did talk to a friend of mine and his advice read as follows :

Quote:

I think you have to define a custom function, which might look like CreateObjectAction( -parameters- )
{
CreateObject( -same parameters- )
}

and have the rest of the script down here...
BTW, I think there's already something along the lines of CreateObjectAction, hmm, here it is: CreateObjectVoid. That one you can use in a DelayCommand, I'm pretty sure.

[ 06-10-2003, 09:39 PM: Message edited by: SpiritWarrior ]

Legolas 06-11-2003 05:15 AM

It's not just about creating objects, but doing other things like adding journal entries and the like as well. In any case, I'm happy with the delayed execute script. I've found an easy way to add all the small scripts into a larger one using LocalInts and if/else lines so there's very little standing in the way of my finishing the Greensville area (for now).
I'll have to upload the new version someday soon.

Chewbacca 06-11-2003 05:45 AM

The OC uses the OnAquireItem event handler to trigger journal entries when the character recieves an item.

AddJournalQuestEntry is the function that, well, adds a journal quest entry. Using this a journal entry can be fired by just about any script, like by a trigger or a monster dying, but I dont know if it can be delayed.

Hope this helps...good luck! [img]smile.gif[/img]

[ 06-11-2003, 05:46 AM: Message edited by: Chewbacca ]


All times are GMT -4. The time now is 04:36 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved