Aller au contenu

Photo

How to make the Object Busy?


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I would like to do some actions to NPC (move to, open door, unlock door) and it can not be stopped (talking or object in front).

 

Example: you talked to the NPC and he has already started to do some actions, but he can not be stopped because the actions are canceled (he must finish all).

 

other bad is if someone is in front, the action is canceled, can not have anyone else in their way (even an object)

 

the NPC has 4 waypoints to walk random so whatever script action will be canceled to walk to this waypoints, so we need remove the AI (artificial inteligence) for a time (temporary)

 

I made a script, but is still in trouble

 

/////////////////////////////////////////////////////////////////////////

void main()
{
        if(GetArea(OBJECT_SELF) == GetArea(GetObjectByTag("WP_CarmemWalk_006")))
   {
    object oDoor1 = GetObjectByTag("Door_TavdaEstr_Out");
    object oDoor2 = GetObjectByTag("Door_ArredNefTum_In");
    if (GetObjectType(oDoor1) == OBJECT_TYPE_DOOR && GetObjectType(oDoor2) == OBJECT_TYPE_DOOR && GetLocked(oDoor2))
    {
    SetAILevel(OBJECT_SELF, AI_LEVEL_VERY_LOW);
    DelayCommand(85.0, SetAILevel(OBJECT_SELF, AI_LEVEL_DEFAULT));
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_000"), TRUE);
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_0001"), TRUE);
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_001"), TRUE);
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_002"), TRUE);
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_003"), TRUE);
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_004"), TRUE);
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_005"), TRUE);
    ActionUnlockObject(oDoor2);
    ActionOpenDoor(oDoor2);
    ActionWait(10.0);
    ActionMoveToObject(GetObjectByTag("WP_CarmemWalk_006"), TRUE);
    return;
    }
 
    FloatingTextStringOnCreature ("Door already opened", GetPCSpeaker());
    return;
}
 
 
    FloatingTextStringOnCreature ("Carmem invalid area", GetPCSpeaker());
    return;
 
}
 
/////////////////////////////////////////////////////////////////////////


#2
Proleric

Proleric
  • Members
  • 2 356 messages
If you want to ensure the NPC actions happen without interruption, don't change the AI level, just close the action queue, as follows:

Action..
Action..
Action..
ActionDoCommand(SetCommandable(TRUE));
SetCommandable(FALSE);
ActionDoCommand is preferable to DelayCommand, because it happens at precisely the right time, when all the other actions are complete.

To work around blocking, I use ActionForceMoveToObject.
  • WhiteTiger aime ceci

#3
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

This is what Proleric is talking about...

void DoStuff(object oDoor2)
{
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_000"), TRUE);
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_0001"), TRUE);
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_001"), TRUE);
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_002"), TRUE);
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_003"), TRUE);
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_004"), TRUE);
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_005"), TRUE);
    ActionUnlockObject(oDoor2);
    ActionOpenDoor(oDoor2);
    ActionWait(10.0);
    ActionForceMoveToObject(GetObjectByTag("WP_CarmemWalk_006"), TRUE);
    ActionDoCommand(SetCommandable(TRUE));
    SetCommandable(FALSE);
}
 
void main()
{
    if(GetArea(OBJECT_SELF) == GetArea(GetObjectByTag("WP_CarmemWalk_006")))
    {
        object oDoor1 = GetObjectByTag("Door_TavdaEstr_Out");
        object oDoor2 = GetObjectByTag("Door_ArredNefTum_In");
        if (GetObjectType(oDoor1) == OBJECT_TYPE_DOOR && GetObjectType(oDoor2) == OBJECT_TYPE_DOOR && GetLocked(oDoor2))
        {
            AssignCommand(GetPCSpeaker(),DoStuff(oDoor2));
        }
        else FloatingTextStringOnCreature ("Door already opened", GetPCSpeaker());
    }
    else FloatingTextStringOnCreature ("Carmem invalid area", GetPCSpeaker());
}

  • WhiteTiger aime ceci

#4
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Thank you very much