ActionJumpToLocation doesn't seem to work


#1

So ActionJumpToLocation (via assigncommand) doesn’t work, I know the OnEnter trigger works because the creature speaks the line I assigned it to speak: AssignCommand(oBeetle, SpeakString(“Yahoo!”));
I also know the object I want the creature to jump to exists because I used GetTag on the object and then used the SpeakString command again and the creature verified that the object exists (I currently removed it from the script).

I did exactly as ActionJumpToLocation told me to do, what could I possibly be missing?

Oh and please note I have improved my scripting habits :slight_smile:

 void main()
    {
        // Get the creature who triggered this event.
        object oBeetle = GetEnteringObject();

        // Only fire for creatures.
        if (!GetIsPC(oBeetle))
          {
           // Only fire for creatures tagged 'Beetle'.
            if (GetTag(oBeetle) == "Beetle")
             {
             //Speak Yahoo as a debugging method
               AssignCommand(oBeetle, SpeakString("Yahoo!"));
             //Get Object to teleport to
             object oHole = GetNearestObjectByTag("Hole");
             //Teleports Beetle to 'Hole' object
            AssignCommand(oBeetle, ActionJumpToObject(oHole));
             }
    }
}

#2

See Lexicon.

By omitting the second parameter, you’re telling the PC to walk to the hole, which is presumably impossible, as the path appears to be blocked by barriers.

Try using ActionJumpToLocation(GetLocation(oHole)) or ActionJumpToObject(oHole, FALSE).


#3

And since the beetle is already moving, add:

AssignCommand(oBeetle, ClearAllActions());

before to put the jump at the top of now-empty action queue.


#4

Excellent point… and if the beetle’s movement was previously driven by AI (e.g. walkwaypoints) you probably need to prevent AI interruptions temporarily (see SetCommandable Example Note 3).


#5

First off thanks for the feedback, ClearAllActions did the trick. Without it, nothing worked. I removed the barriers, no change. I added FALSE is the second parameter, no change. Also ActionJumpToLocation didn’t work. But yea, ClearAllActions before the jump did the trick. Thank you!

I read the SetCommandable but not exactly sure how it’s related to this specific situation, it was also confusing in the example where it’s written

assigns them an animation to play.
then, to insure that they do not just
click to move away and cancel the animation,

I imagine the person who wrote the example made a mistake there as NPC’s don’t click to move away under normal circumstances. Sorry to nitpick but it got me confused.


#6

What you need to do, as shown in the example, is to SetCommandable(FALSE) to prevent AI from cancelling your actions until they’re finished. The final action has to be a command to SetCommandable(TRUE), which enables AI again.


#7

So the creature actually cancels my action as opposed to putting it on queue? :astonished: Hah, I would never have thought that! You’re a fountain of knowledge Proleric.


#8

SetCommandable() controls whether action queue of a creature can be modified, either by itself or by scripts (which - in my opinion - should have a separate argument).

This is good advice, but I think it is worth mentioning that SetCommandable(TRUE) has to be scheduled as a final action right before a non-action call to SetCommandable(FALSE), which should go last:

AssignCommand(oBeetle, ClearAllActions());  // not an action
AssignCommand(oBeetle, ActionJumpToLocation(GetLocation(oHole)));
AssignCommand(oBettle, ActionDoCommand(SetCommandable(TRUE)));
AssignCommand(oBettle, SetCommandable(FALSE)); // not an action

Otherwise the creature will deadlock.

I also think that while @Proleric is on point about use of SetCommandable, making a non-patrolling creature jump to a point usually shouldn’t require it (since it’s instant). It’s definitely useful for complex actions where it can be used to prevent the PC from breaking the chain by talking to the creature or when there are nearby enemies.

It doesn’t really cancel your action, but it may make another call to ClearAllActions(), which cancels all actions (hence the name). This function is used whenever something has stop what it was doing and do something else now, i.e. spotted an enemy -> ClearAllActions() (cancel movement, etc) -> DetermineCombatRound().

Not using ClearAllActions() in your beetle script schedules the jump after what it was doing, but in the meantime many things many happen to disturb the action queue.