Advice on reliably jumping a PC/NPC to a location/object
Terrorble
Member Posts: 179
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:
This snippet is from a trigger that jumps you to a waypoint within the area to view a cutscene:
This one is at the end of a conversation that should send you to another area:
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.
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.
0
Comments
Not sure about the first one... perhaps you should also delay the AssignCommand(oPC,ClearAllActions()):
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.
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