ActionForceMoveToObject in this script won't work no matter what
Shandareth
Member Posts: 6
Hello to everyone. I'm making a cutscene where pc and henchmen get attacked by a group of monsters and helped by two guards. At the end of the script the PC and henchmen are supposed to run away at a waypoint but they don't. I tried to change the target from waypoint to object and to location, but nothing happens. In addition, sometimes people speak the strings they supposed to speak but sometimes not. My brain is melting. This is the actual script. Please help.
void main()
{
object oSpawn = GetWaypointByTag("brutespawn");
location oLocation = GetLocation(oSpawn);
object adelari1 = GetNearestObjectByTag("adelari1");
object adelari2 = GetNearestObjectByTag("adelari2");
object adelari3 = GetNearestObjectByTag("adelari3");
object oPC = GetFirstPC();
object nilde = GetNearestObjectByTag("nilde_npc");
object shandareth = GetNearestObjectByTag("shandareth_npc");
object girolamone = GetNearestObjectByTag("girolamone_npc");
object pdor = GetNearestObjectByTag("pdor_npc");
object rigel = GetNearestObjectByTag("rigel_npc");
object huginn = GetNearestObjectByTag("huginn_npc");
object nessuno = GetNearestObjectByTag("nessuno_npc");
object guardia1 = GetNearestObjectByTag("Sentinella3");
object guardia2 = GetNearestObjectByTag("Sentinella4");
object oTargetto = GetWaypointByTag("WP_movehere");
// cutscene mode per i pc
ExecuteScript("cutscene_in2", oPC);
while (GetIsObjectValid(oPC))
{ oPC = GetNextPC();
ExecuteScript("cutscene_in2", oPC);}
oPC = GetFirstFactionMember(nilde, TRUE);
// spawnano i Bruti, e attaccano le guardie
SoundObjectPlay(GetObjectByTag("brutescream1"));
CreateObject(OBJECT_TYPE_CREATURE, "brutoadelari", oLocation, FALSE, "brutoadelari1");
CreateObject(OBJECT_TYPE_CREATURE, "brutoadelari", oLocation, FALSE, "brutoadelari2");
object bruto1 = GetObjectByTag("brutoadelari1");
object bruto2 = GetObjectByTag("brutoadelari2");
SetObjectVisualTransform(bruto1, OBJECT_VISUAL_TRANSFORM_SCALE, 1.3);
SetObjectVisualTransform(bruto2, OBJECT_VISUAL_TRANSFORM_SCALE, 1.4);
AssignCommand(bruto1, ActionAttack(guardia1, FALSE));
AssignCommand(bruto2, ActionAttack(guardia2, FALSE));
AssignCommand(adelari1, ActionAttack(guardia1, FALSE));
AssignCommand(adelari2, ActionAttack(guardia2, FALSE));
AssignCommand(adelari3, ActionAttack(guardia1, FALSE));
AssignCommand(oPC, ClearAllActions(TRUE));
object NearestAdelari = GetNearestCreature(CREATURE_TYPE_RACIAL_TYPE, RACIAL_TYPE_ABERRATION);
DelayCommand(4.0, AssignCommand(oPC, ActionAttack(NearestAdelari, FALSE)));
DelayCommand(4.0, AssignCommand(guardia1, SpeakString("Oh dio santo! BRUTI!")));
DelayCommand(7.0, AssignCommand(guardia2, SpeakString("Compagnia! SCAPPATE! li teniamo a bada noi!")));
DelayCommand(10.0, AssignCommand(nilde, SpeakString("Non vi lasceremo qui a morire!")));
DelayCommand(14.0, AssignCommand(guardia1, SpeakString("La vostra missione è più importante, ORA CORRETE! li terremo a bada finché riusciamo!")));
DelayCommand(17.0, AssignCommand(nessuno, ActionForceMoveToObject(oPC, TRUE)));
DelayCommand(17.0, AssignCommand(nessuno, SpeakString("Allora eroi, andiamo o volete rimanere qui?")));
DelayCommand(22.0, AssignCommand(oPC, ClearAllActions(TRUE)));
DelayCommand(22.0, AssignCommand(oPC, SpeakString("E va bene, CORRIAMO!")));
// tutti scappano verso la foresta, le guardie rimangono a combattere
DelayCommand(23.0, AssignCommand(oPC, ClearAllActions(TRUE)));
DelayCommand(23.0, AssignCommand(oPC, ActionForceMoveToObject(oTargetto)));
DelayCommand(24.0, AssignCommand(nilde, ClearAllActions(TRUE)));
DelayCommand(24.0, AssignCommand(nilde, ActionForceMoveToObject(oTargetto, TRUE)));
DelayCommand(24.0, AssignCommand(huginn, ClearAllActions(TRUE)));
DelayCommand(24.0, AssignCommand(huginn, ActionForceMoveToObject(oTargetto, TRUE)));
DelayCommand(24.0, AssignCommand(shandareth, ClearAllActions(TRUE)));
DelayCommand(24.0, AssignCommand(shandareth, ActionForceMoveToObject(oTargetto, TRUE)));
DelayCommand(24.0, AssignCommand(rigel, ClearAllActions(TRUE)));
DelayCommand(24.0, AssignCommand(rigel, ActionForceMoveToObject(oTargetto, TRUE)));
DelayCommand(24.0, AssignCommand(nessuno, ClearAllActions(TRUE)));
DelayCommand(24.0, AssignCommand(nessuno, ActionForceMoveToObject(oTargetto, TRUE)));
DelayCommand(24.0, AssignCommand(girolamone, ClearAllActions(TRUE)));
DelayCommand(24.0, AssignCommand(girolamone, ActionForceMoveToObject(oTargetto, TRUE)));
DelayCommand(24.0, AssignCommand(pdor, ClearAllActions(TRUE)));
DelayCommand(24.0, AssignCommand(pdor, ActionForceMoveToObject(oTargetto, TRUE)));
while (GetIsObjectValid(oPC))
{ oPC = GetNextPC();
DelayCommand(22.0, AssignCommand(oPC, ClearAllActions(TRUE)));
DelayCommand(22.0, AssignCommand(oPC, ActionForceMoveToObject(oTargetto)));}
}
0
Comments
Adding even a 0.1 second gap between clearing actions and assigning commands helps to ensure there's no overlap. For example:
could be rewritten as
Also, I just noticed that you're trying to get each PC to move to oTargetto, but you're actually skipping over the first PC, meaning this wouldn't work in single player.
The line oPC = GetNextPC(); should be placed at the end of the loop. As it stands now, you're immediately finding the next PC and assigning those actions.