Author Topic: Script Request for CEP Door Placable  (Read 780 times)

Legacy_Shiek2005

  • Full Member
  • ***
  • Posts: 179
  • Karma: +0/-0
Script Request for CEP Door Placable
« Reply #15 on: September 08, 2011, 05:36:02 pm »


               Thanks '<img'>
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
Script Request for CEP Door Placable
« Reply #16 on: September 08, 2011, 06:47:34 pm »


               Haven't used CEP in some time but this is what I used to use with it:
[nwscript]
//:://////////////////////////////////////
// void AutoCloseDoor( object oDoor, int bAutoLock. float fDelay = 12.50f)
//         Automatically closes the specified door and optionally lock it after the given
//         number of seconds. The door can be either a standard toolset door or a CEP style
//         placeable door. Doors with no locks on them will not be locked even if the auto-lock
//         option is used. The default is to wait 12.5 seconds before closing and the door is
//         left unlocked.
//:://////////////////////////////////////
// Parameters: object oDoor  - the door to be closed.
//             int bAutoLock - if TRUE the door will also lock if it has a lock on it.
//                             if FALSE the door will remain unlocked even if it has a lock on it.
//                             default = FALSE.
//             float  fDelay - how long to wait before closing the door. default = 12.5 seconds.
//
// Returns:  None.
//:://////////////////////////////////////
void AutoCloseDoor( object oDoor, int bAutoLock = FALSE, float fDelay = 12.50f);
void AutoCloseDoor( object oDoor, int bAutoLock = FALSE, float fDelay = 12.50f)
{ if( fDelay <= 0.0f)   fDelay = 12.5f;
  if( !GetIsObjectValid( oDoor)) return;
  if( GetObjectType( oDoor) == OBJECT_TYPE_DOOR)
  { // Standard toolset door
    if( GetIsOpen( oDoor))       AssignCommand( oDoor, DelayCommand( fDelay, ActionCloseDoor( oDoor)));
    if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.1f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
  }
  else if( GetObjectType( oDoor) == OBJECT_TYPE_PLACEABLE)
  { string sGateBlock = GetLocalString( oDoor, "CEP_L_GATEBLOCK");
    if( sGateBlock != "")
    { // CEP placeable door
      if( GetIsOpen( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay, PlayAnimation( ANIMATION_PLACEABLE_CLOSE)));
      if( !GetIsObjectValid( GetLocalObject( oDoor, "GateBlock")))
      { object oGateBlock = CreateObject( OBJECT_TYPE_PLACEABLE, sGateBlock, GetLocation( oDoor));
        if( GetIsObjectValid( oGateBlock)) AssignCommand( oDoor, DelayCommand( fDelay +0.1f, SetLocalObject( oDoor, "GateBlock", oGateBlock)));
        else                               AssignCommand( oDoor, DelayCommand( fDelay +0.1f, DeleteLocalObject( oDoor, "GateBlock")));
      }
      if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.2f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
    }
    else
    { // Standard toolset placeable door.
      if( GetLocalInt( oDoor, "IsOpen"))
      { AssignCommand( oDoor, DelayCommand( fDelay, PlayAnimation( ANIMATION_PLACEABLE_CLOSE)));
        AssignCommand( oDoor, DelayCommand( fDelay +0.1f, DeleteLocalInt( oDoor, "IsOpen")));
      }
      if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.2f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
    }
  }
}
[/nwscript]
               
               

               


                     Modifié par Axe_Murderer, 08 septembre 2011 - 05:48 .
                     
                  


            

Legacy_Shiek2005

  • Full Member
  • ***
  • Posts: 179
  • Karma: +0/-0
Script Request for CEP Door Placable
« Reply #17 on: September 09, 2011, 03:17:53 am »


               

Axe_Murderer wrote...

Haven't used CEP in some time but this is what I used to use with it:
[nwscript]
//:://////////////////////////////////////
// void AutoCloseDoor( object oDoor, int bAutoLock. float fDelay = 12.50f)
//         Automatically closes the specified door and optionally lock it after the given
//         number of seconds. The door can be either a standard toolset door or a CEP style
//         placeable door. Doors with no locks on them will not be locked even if the auto-lock
//         option is used. The default is to wait 12.5 seconds before closing and the door is
//         left unlocked.
//:://////////////////////////////////////
// Parameters: object oDoor  - the door to be closed.
//             int bAutoLock - if TRUE the door will also lock if it has a lock on it.
//                             if FALSE the door will remain unlocked even if it has a lock on it.
//                             default = FALSE.
//             float  fDelay - how long to wait before closing the door. default = 12.5 seconds.
//
// Returns:  None.
//:://////////////////////////////////////
void AutoCloseDoor( object oDoor, int bAutoLock = FALSE, float fDelay = 12.50f);
void AutoCloseDoor( object oDoor, int bAutoLock = FALSE, float fDelay = 12.50f)
{ if( fDelay <= 0.0f)   fDelay = 12.5f;
  if( !GetIsObjectValid( oDoor)) return;
  if( GetObjectType( oDoor) == OBJECT_TYPE_DOOR)
  { // Standard toolset door
    if( GetIsOpen( oDoor))       AssignCommand( oDoor, DelayCommand( fDelay, ActionCloseDoor( oDoor)));
    if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.1f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
  }
  else if( GetObjectType( oDoor) == OBJECT_TYPE_PLACEABLE)
  { string sGateBlock = GetLocalString( oDoor, "CEP_L_GATEBLOCK");
    if( sGateBlock != "")
    { // CEP placeable door
      if( GetIsOpen( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay, PlayAnimation( ANIMATION_PLACEABLE_CLOSE)));
      if( !GetIsObjectValid( GetLocalObject( oDoor, "GateBlock")))
      { object oGateBlock = CreateObject( OBJECT_TYPE_PLACEABLE, sGateBlock, GetLocation( oDoor));
        if( GetIsObjectValid( oGateBlock)) AssignCommand( oDoor, DelayCommand( fDelay +0.1f, SetLocalObject( oDoor, "GateBlock", oGateBlock)));
        else                               AssignCommand( oDoor, DelayCommand( fDelay +0.1f, DeleteLocalObject( oDoor, "GateBlock")));
      }
      if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.2f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
    }
    else
    { // Standard toolset placeable door.
      if( GetLocalInt( oDoor, "IsOpen"))
      { AssignCommand( oDoor, DelayCommand( fDelay, PlayAnimation( ANIMATION_PLACEABLE_CLOSE)));
        AssignCommand( oDoor, DelayCommand( fDelay +0.1f, DeleteLocalInt( oDoor, "IsOpen")));
      }
      if( GetLockLockable( oDoor)) AssignCommand( oDoor, DelayCommand( fDelay +0.2f, ActionDoCommand( SetLocked( oDoor, bAutoLock))));
    }
  }
}
[/nwscript]


Excuse the noob question, but how do you use that script?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Script Request for CEP Door Placable
« Reply #18 on: September 09, 2011, 06:19:06 am »


               First off, did you decide if you are going to use one of the CEP doors that has an open/close animation or are you going to use one of the NWN2 appearances to go with your building that does not have open/close animations.

If you use Axe's script I believe it replaces the OnUsed zep script. It includes autoclose and lock functionality, but it also includes animation and gate block info for use with the CEP doors that support them.
               
               

               
            

Legacy_Shiek2005

  • Full Member
  • ***
  • Posts: 179
  • Karma: +0/-0
Script Request for CEP Door Placable
« Reply #19 on: September 09, 2011, 07:03:06 pm »


               Right now using the CEP NWN2 Door placeables, i had missed them i guess, but seeing as they fit the the buildings just right, we want to use those instead of the default doors.

We plan on setting them up so that they teleport the PC when they use them, but if they could work like real doors, that would be great.
               
               

               


                     Modifié par Shiek2005, 09 septembre 2011 - 06:04 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Script Request for CEP Door Placable
« Reply #20 on: September 09, 2011, 09:39:01 pm »


               You could try something like this in the OnUsed. Don't need any HB or spawn scripts or anything. The fake animation doesn't look that great but it's the best I could do. If you add more delays with SetFacing it doesn't work correctly. It requires that you set a string variable on the door (named "MY_DEST") for the destination waypoint tag.
For example:  MY_DEST | string | DOORDEST_WP22
So the tag of the waypoint you would travel to would be "DOORDEST_WP22".
You can change the "AUTOCLOSE_DELAY" to whatever you want at the top.
If the door is open and someone clicks the door they will just be teleported without any door opening or closing since the autoclose delay is still in effect.


const float AUTOCLOSE_DELAY = 10.0;

void AutoClose()
{
    if (GetLocalInt(OBJECT_SELF, "OPEN") == TRUE)
    {
        SetFacing(GetFacing(OBJECT_SELF) + 45.0);
        DelayCommand(0.3, SetFacing(GetFacing(OBJECT_SELF) + 45.0));
        PlaySound("as_dr_woodmedcl1");
        SetLocalInt(OBJECT_SELF, "OPEN", FALSE);
    }
}
void main()
{
    object oPC = GetLastUsedBy();
    int iOpen = GetLocalInt(OBJECT_SELF, "OPEN");
    float fFace = GetFacing(OBJECT_SELF);
    if (GetLocked(OBJECT_SELF) == TRUE)
    {
        PlaySound("as_dr_locked1");
        FloatingTextStringOnCreature("*locked*", oPC, TRUE);
        return;
    }
    if (iOpen != TRUE)
    {
        SetLocalInt(OBJECT_SELF, "OPEN", TRUE);
        PlaySound("as_dr_woodmedop1");
        SetFacing(GetFacing(OBJECT_SELF) - 45.0);
        DelayCommand(0.3, SetFacing(GetFacing(OBJECT_SELF) - 45.0));
        DelayCommand(AUTOCLOSE_DELAY, AutoClose());
    }

    string sDest = GetLocalString(OBJECT_SELF, "MY_DEST");
    object oDest = GetWaypointByTag(sDest);
    if (GetIsObjectValid(oDest))
    DelayCommand(1.5, AssignCommand(oPC, ActionJumpToObject(oDest)));
}


Hope it helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 09 septembre 2011 - 08:49 .
                     
                  


            

Legacy_Shiek2005

  • Full Member
  • ***
  • Posts: 179
  • Karma: +0/-0
Script Request for CEP Door Placable
« Reply #21 on: September 09, 2011, 11:28:39 pm »


               It's great, thanks a lot '^_^'

There's one last thing that maybe someone can suggest a work-around for. The door with that script works perfectly, sure, the animation might be a little rough, but it's not all that noticable. The problem is on the inside. On the outside, when the door is opened we see a black/dark interior...regardless, it's an opening leading somewhere. But inside, when the door opens, all you would see is a solid wall...not very realistic. A default tile doorway could work, but since the NWN2 Placable Doors are smaller then the default size of the tile Doorways....thats where the problem lies.

Is there any way to simulate an "opening" where there is none?