Author Topic: Help with Door Script  (Read 365 times)

Legacy_Tonden_Ockay

  • Hero Member
  • *****
  • Posts: 891
  • Karma: +0/-0
Help with Door Script
« on: July 19, 2015, 04:45:55 am »


               

I'm using this script on a CEP placeable door and it works, but it stays open. So I would like for it to have a 15.0 second delay then close. However I'm having no luck. So I could use some help with this.



/* Use a placeable wall door. This allows for locks and traps to be
 * placed on the door and plays an animation of the user opening
 * the door.
 *
 * Works for both standard and secret doors. For standard, the tag
 * of the waypoint destination must be set to LOC_<tag of door>.
 * For secret, the waypoint should be set to LOC_<tag of detect trigger>.
 *
 * This goes in the OnUsed event handler of the actual
 * placeable door object.
 */

#include "x0_i0_secret"

void main()
{
    object oUser = GetLastUsedBy();

    // Allow for traps and locks
    if (GetIsTrapped(OBJECT_SELF)) {return;}

    if (GetLocked(OBJECT_SELF)) {
        // See if we have the key and unlock if so
        string sKey = GetTrapKeyTag(OBJECT_SELF);
        object oKey = GetItemPossessedBy(oUser, sKey);
        if (sKey != "" && GetIsObjectValid(oKey)) {
            SendMessageToPC(oUser, GetStringByStrRef(7945));
            SetLocked(OBJECT_SELF, FALSE);
        } else {
            // Print '*locked*' message and play sound
            DelayCommand(0.1, PlaySound("as_dr_locked2"));
            FloatingTextStringOnCreature("*"
                                         + GetStringByStrRef(8307)
                                         + "*",
                                         oUser);
            SendMessageToPC(oUser, GetStringByStrRef(8296));
            return;
        }
    }

    // Handle opening/closing
    if (!GetIsSecretItemOpen(OBJECT_SELF)) {
        // play animation of user opening it
        AssignCommand(oUser, ActionPlayAnimation(ANIMATION_LOOPING_GET_MID));
        DelayCommand(1.0, ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN));
        SetIsSecretItemOpen(OBJECT_SELF, TRUE);
    } else {
        // it's open -- go through and then close
        UseSecretTransport(GetLastUsedBy());
        ActionPlayAnimation(ANIMATION_PLACEABLE_CLOSE);
        SetIsSecretItemOpen(OBJECT_SELF, FALSE);

 }
}


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Help with Door Script
« Reply #1 on: July 19, 2015, 10:04:38 am »


               

The last two lines could read


 


DelayCommand(15.0, ActionPlayAnimation(ANIMATION_PLACEABLE_CLOSE));
DelayCommand(15.0, SetIsSecretItemOpen(OBJECT_SELF, FALSE));

 


Better still, put the two commands in a function, then use DelayCommand on the function.



               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Help with Door Script
« Reply #2 on: July 19, 2015, 10:12:18 am »


               


The last two lines could read



DelayCommand(15.0, ActionPlayAnimation(ANIMATION_PLACEABLE_CLOSE));
DelayCommand(15.0, SetIsSecretItemOpen(OBJECT_SELF, FALSE));

Better still, put the two commands in a function, then use DelayCommand on the function.




Kinda strange that it's staying open though. The script as is looks like it should be closing as soon as the player gos through. I wonder if something else is going on?



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Help with Door Script
« Reply #3 on: July 19, 2015, 11:10:13 am »


               

In a bit larger modules placeable and door animations gets bugged, takes forever to start etc. Might be whats going on there or perhaps not.