Skip to content

Perception Script Help

ZephiriusZephirius Member Posts: 419
edited April 2023 in Builders - Scripting
In my script I want the NPC (a golem) to play a few .wav files when he perceives the PC. I've really never tinkered around with the whole OnPerception thing, so I'm kinda of flailing around here. :#

Code:
void main()
{
    if ( !GetLastPerceptionSeen() )
        return;

    object oPC = GetLastPerceived();

    if (d20() > 5)
    {
        AssignCommand(oPC, PlaySound("computer_03"));
        DelayCommand(0.9, AssignCommand(oPC, PlaySound("six")));
        DelayCommand(0.9, AssignCommand(OBJECT_SELF, SpeakString("Six...?")));
    }
}


Edit: I removed the dice roll and it seems to work ok now.
void main()
{
    if ( !GetLastPerceptionSeen() )
        return;

    object oPC = GetLastPerceived();
   
   AssignCommand(oPC, PlaySound("computer_03"));
    DelayCommand(0.9, AssignCommand(oPC, PlaySound("six")));
    DelayCommand(0.9, AssignCommand(OBJECT_SELF, SpeakString("Six...?")));
 
}

Comments

  • MelkiorMelkior Member Posts: 204
    The probable reason why it seemed to not be working with the random roll is because it happened to select a number from 1-5 each time.
Sign In or Register to comment.