Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Advice on reliably jumping a PC/NPC to a location/object

TerrorbleTerrorble Member Posts: 108
I am having trouble getting PC/NPC to reliably jump to object/location - sometimes nothing happens. There's a couple places that if it doesn't work it can break the whole module. So, I must be doing something wrong. Let me share a few examples and maybe someone can point out my error.

This one is on a placeable that I use to jump me to the next segment within the same area. Sometimes I have to use the placeable several times before it works, but the VFX fires every time:
    object oPC = GetLastUsedBy();
    string s = GetLocalString(OBJECT_SELF,"Next");
    if( GetLocalInt(Getdbobj(oPC),"BWSPIRIT"+s) == TRUE )
    {
        AssignCommand(oPC,ClearAllActions());
        ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_IMP_DIVINE_STRIKE_HOLY),oPC);
        DelayCommand(0.2,AssignCommand(oPC,ActionJumpToLocation(GetLocation(GetWaypointByTag("BWTP"+s)))));
    }


This snippet is from a trigger that jumps you to a waypoint within the area to view a cutscene:
    location lScene = GetLocation(GetWaypointByTag("VIEWING_WP"));

    AssignCommand(oPC,ClearAllActions());
    AssignCommand(oPC,ActionJumpToLocation(lScene));



This one is at the end of a conversation that should send you to another area:
    DelayCommand(5.0,AssignCommand(GetPCSpeaker(),ClearAllActions()));
    DelayCommand(5.0,AssignCommand(GetPCSpeaker(),ActionJumpToLocation(GetLocation(GetWaypointByTag("FORDETU")))));

I've tried delaying the jump 0.1seconds after ClearAllActions(). I've tried no ClearAllActions() at all. I've used JumptoObject() and ActionJumpToObject/Location() as well.

I find ClearAllActions() sorta has to be in there or else it rarely works at all.

Comments

  • KamirynKamiryn Member Posts: 45
    Keep in mind that DelayCommand() delays everything not just the ActionJumpToLocation(), it also delays GetPCSpeaker() for example. So I would replace the last one with
    object oPC = GetPCSpeaker();
    DelayCommand(5.0, AssignCommand(oPC,ClearAllActions()));
    DelayCommand(5.0, AssignCommand(oPC,ActionJumpToLocation(GetLocation(GetWaypointByTag("FORDETU")))));
    
    because GetPCSpeaker() makes sense only within a conversation, but 5 seconds after the end of a conversation there's no conversation anymore and GetPCSpeaker() should return INVALID_OBJECT only.

    Not sure about the first one... perhaps you should also delay the AssignCommand(oPC,ClearAllActions()):
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_IMP_DIVINE_STRIKE_HOLY),oPC);
    DelayCommand(0.2, AssignCommand(oPC,ClearAllActions()));
    DelayCommand(0.2, AssignCommand(oPC,ActionJumpToLocation(GetLocation(GetWaypointByTag("BWTP"+s)))));
    

    Terrorble
  • ProlericProleric Member Posts: 875
    If the PC is free to carry on clicking after the script fires, it might be cancelled accidentally.

    A method for preventing this is given in Note 3 on SetCommandable in the Lexicon.

    Where a delay is required, you would need to make the PC commandable again after the delay (otherwise the delayed action won't be queued) then uncommandable once more.

    P.S. Delayed commands may not work if the object running the script gets deleted or killed first - not sure whether that applies here.

    TerrorblemeaglynGrymlorde
  • TerrorbleTerrorble Member Posts: 108
    Thanks for the suggestions - great stuff to think about. I've worked it in and have my fingers crossed it'll work every time now.

    I chuckled a bit when I saw this because it appears I'm not the only one who has had trouble getting things to Jump the first time :/

    I found this in x3_inc_horse
    void HorseForceJump(object oJumper,object oDestination,float fRange=2.0,int nTimeOut=10)
    { // PURPOSE: Make sure jump
        //SendMessageToPC(oJumper,"nw_g0_transition:ForceJump("+IntToString(nTimeOut)+")");
        if (nTimeOut>0&&(GetArea(oJumper)!=GetArea(oDestination)||GetDistanceBetween(oJumper,oDestination)>fRange))
        { // jump
            AssignCommand(oJumper,ClearAllActions(TRUE));
            AssignCommand(oJumper,ActionJumpToObject(oDestination));
            DelayCommand(1.0,HorseForceJump(oJumper,oDestination,fRange,nTimeOut-1));
        } // jump
    } // HorseForceJump()
    

Sign In or Register to comment.