PDA

View Full Version : Delaying a script execution


GeorgNihilus
01-23-2008, 01:08 PM
Hi people :) this 'should' be pretty simple but it's not working for me :( ... well I'm trying to insert a delay of 15 seconds before firing a script but I'm not succeeding even though the script I'm using is compiling good.
Here's the script I'm dealing with:

//:: k_def_death01
/*
Default On Death Script
*/
//:: Created By: Preston Watamaniuk
//:: Copyright (c) 2002 Bioware Corp.

#include "k_inc_switch"
#include "k_inc_debug"

void main()
{
DelayCommand (15.0, ExecuteScript("k_spn_selk", OBJECT_SELF));
ExecuteScript("k_spn_selk", OBJECT_SELF);
ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_DEATH);
/*
if(!GN_GetSpawnInCondition(SW_FLAG_AI_OFF))
{
SpeakString("GEN_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
//Shout Attack my target, only works with the On Spawn In setup
SpeakString("GEN_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
}
if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_DEATH))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
}
*/
}

I just added the red marked line, nothing more, but they delay is completely ignored when running the script from the .utc I'm using (OnDeath field). Maybe 'ExecuteScript' is not an action command ... is it? Any ideas? :confused:

thanks on advance guys! :waive1:

stoffe
01-24-2008, 08:15 AM
Hi people :) this 'should' be pretty simple but it's not working for me :( ... well I'm trying to insert a delay of 15 seconds before firing a script but I'm not succeeding even though the script I'm using is compiling good.


The problem is most likely that you are trying to run the delayed command off a dead character. Dead characters (except party members) will be removed from the game world after a few seconds, and as such will not be able to run your script.

Try assigning the execute command to some other object that will stick around after the character's death instead. For example:


#include "k_inc_switch"

void main() {
AssignCommand(GetModule(), DelayCommand (15.0, ExecuteScript("k_spn_selk", OBJECT_SELF)));
ExecuteScript("k_spn_selk", OBJECT_SELF);
ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_DEATH);
}

GeorgNihilus
01-25-2008, 09:07 AM
Thanks Stoffe :) didn't know ... finally I manage to insert the delay in the OnSpawn script of the .utc and worked ...

Good modding! ;)