Skip to content

Villain Monologue Gets Interrupted

What I'm trying to do is this:
1- Villain percieves the player.
2- Villain walks up and starts conversation.
3- If the player cancels or ends the conversation then the villain turns hostile and begins attacking
The problem I have is that sometimes the conversation ends immediately and then starts again. But when that happens the villain turns hostile.

The villain's onPercieved script
void main()
{
    ExecuteScript("nw_c2_default2", OBJECT_SELF);

    object oPercep =  GetLastPerceived();

    if(GetIsPC(oPercep) && GetLocalInt(OBJECT_SELF, "FinalTalk") != 1 && !IsInConversation(OBJECT_SELF))
    {
        ClearAllActions(FALSE);
        AssignCommand(OBJECT_SELF, ActionStartConversation(oPercep, "", TRUE));
    }
}

The villain's conversation has this script in both the Normal and Aborted part of the conversation file.
#include "nw_i0_generic"

void main()
{

        AdjustReputation(GetFirstPC(),OBJECT_SELF,-100);
        SetLocalInt(OBJECT_SELF, "FinalTalk",1);
        AssignCommand(OBJECT_SELF, DetermineCombatRound());

}

Comments

  • MelkiorMelkior Member Posts: 205
    I've discovered by experience that OnPerception is not a singular event. It seems to occur every 6 seconds, just like a heartbeat. That may be interfering with the conversation by starting a new conversation, which aborts the previous conversation which then activates the turn-hostile script.
    What I'd suggest is that you try putting a do-once into the onperception script so that it can only be activated the one time and skips trying to start the conversation on following perception events.
    Just after ClearAllActions put in the line: SetLocalInt(OBJECT_SELF,"PERCEPTION_ONCE",TRUE);
    Right after the ExecuteScript, insert: if(GetLocalInt(OBJECT_SELF,"PERCEPTION_ONCE")) return;

    It may be possible to add an event which erases the do-once if you need the conversation to ever retrigger, but if you don't need that, then what I've said should do the job.
  • ForSeriousForSerious Member Posts: 467
    That's what I was going to suggest.
    It does look like you tried to account for that with IsInConversation(OBJECT_SELF)
    Maybe try a SendMessageToPC(GetFirstPC()) with the results of all those checks. I'd also move ExecuteScript("nw_c2_default2", OBJECT_SELF); to the end—but maybe that doesn't matter.
Sign In or Register to comment.