Calling an object created mid-cutscene
gpeddino
Member Posts: 51
I'm working on a complex cutscene which involves a character appearing and disappearing (and doing other actions in-between). For that, I'm using GestaltCreate and then DestroyObject.
The thing is, after I create the creature, I can't refer to it with GetObjectByTag, but that works inside the function. Here's what I mean:
From my understanding, the problem is the DelayCommand, which makes GetObjectByTag try to refer to an object that doesn't exist yet.
Is there any workaround for this? Like, is there any way of calling an object with a delayed response?
The thing is, after I create the creature, I can't refer to it with GetObjectByTag, but that works inside the function. Here's what I mean:
WORKS: GestaltCreate(17.0, wHayford, OBJECT_TYPE_CREATURE, "hayford"); DelayCommand(22.0, AssignCommand(GetObjectByTag("Hayford"), SpeakString(HAYFORD_THREAT_1, TALKVOLUME_SHOUT))); DelayCommand(26.0, AssignCommand(GetObjectByTag("Hayford"), SpeakString(HAYFORD_THREAT_2, TALKVOLUME_SHOUT))); DelayCommand(30.0, AssignCommand(GetObjectByTag("Hayford"), SpeakString(HAYFORD_THREAT_3, TALKVOLUME_SHOUT))); DOES NOT WORK: GestaltCreate(17.0, wHayford, OBJECT_TYPE_CREATURE, "hayford"); oHayford = GetObjectByTag("Hayford"); DelayCommand(22.0, AssignCommand(oHayford, SpeakString(HAYFORD_THREAT_1, TALKVOLUME_SHOUT))); DelayCommand(26.0, AssignCommand(oHayford, SpeakString(HAYFORD_THREAT_2, TALKVOLUME_SHOUT))); DelayCommand(30.0, AssignCommand(oHayford, SpeakString(HAYFORD_THREAT_3, TALKVOLUME_SHOUT)));
From my understanding, the problem is the DelayCommand, which makes GetObjectByTag try to refer to an object that doesn't exist yet.
Is there any workaround for this? Like, is there any way of calling an object with a delayed response?
0
Comments
void hayfordSpeak(object oHayford=OBJECT_INVALID)
{
oHayford=GetObjectByTag("Hayford");
AssignCommand(oHayford,SpeakString(etc...));
DelayCommand(4.0,AssignCommand(oHayford,etc...);
DelayCommand(8.0,AssignCommand(oHayford,etc...);
}
And then add that after the gestalt command, like:
GestaltCreate(etc...);
DelayCommand(22.0,hayfordSpeak());
I decided to stick to the GetObjectByTag for now. The script I'm working on already has several different functions and adding more would make things a bit too cluttered. I just wanted to find out if there was a workaround I wasn't aware of.