Please Help - 'waking up' script

This is the situation: At the end of a scene, the PC is knocked unconscious. They are then transported to an new location/waypoint where they wake up. There is a trigger at the waypoint with a script that is meant to simulate the PC waking up. First the screen is black, then that clears, and the PC is prone from sleeping, and then they get up.

At least that is how it is supposed to work. Except when the PC switches to the new location, they keep standing, and neither effect happens. The PC is an ordinary human. So there is no elf immunity to sleep or anything like that.

Any help would be appreciated. Here is the script:

void main()
{
object oPC = GetEnteringObject();
if ( GetIsPC(oPC) )
{
ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectBlindness(), oPC, 5.5));
ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectSleep(), oPC, 6.5));
DestroyObject( OBJECT_SELF );
}

}

Try without the “Action” part. You are putting things in the trigger’s action queue and then destroying the trigger so any queued actions are gone. As I type this it occurs to me that triggers might not even have action queues anyway…

Agreed. Probably the best solution in this case.

Triggers do have action queues, but dead / destroyed objects don’t do actions.

Other solutions include delaying DestroyObject for, say, 0.5 seconds, or (better) assigning the commands to the module. That would be appropriate if actions had to be queued for some reason.

Dead creatures still do some actions. ActionDoCommand and ActionSpeakString work on them when assigned. They also drink potions when given by a PC.

The thing is that ActionDoCommand and DelayCommand(0.0, ...) schedule execution of their code after current script terminates. So does DestroyObject, but it is faster and the object is wiped out before it starts to do the actions.

If you do ActionDoCommand(DestroyObject(... it will work (appends to the end of action queue), but as guys already said here, it is superfluous.

void main()
{
    object oPC = GetEnteringObject();

    if(!GetIsPC(oPC)) return;

    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectBlindness(), oPC, 5.5);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectSleep(), oPC, 6.5);
    
    DestroyObject(OBJECT_SELF);
}

Because of its engine-enforced delay, DestroyObject could be placed before effect application and it will work, but don’t do it except for experimentation.

Removing the ActionDoCommand worked.

Thanks for all the help.

Thanks Proleric, I couldn’t remember off-hand and there’s no list in the lexicon I could find in a quick look. There’s just a mention that ActionDoCommand won’t work on objects that don’t have an action queue, and I wasn’t going to spend the time testing for it… :slight_smile: