Aller au contenu

Photo

Script Request for CEP Door Placable


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

#1
Shiek2005

Shiek2005
  • Members
  • 104 messages
Is there any way to make the CEP doors, for example the Doorway under Custom > Civilization Exterior > Buildings > Doors have an open/close animation like a normal door?

If so, i'm looking for a script that when the door opens, the player is teleported to a waypoint (this, should obviously, be delayed by a second or two so that the door is seen opening :) ) and then the door closes again.

Could anyone help out here? :)

Thanks! 

#2
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Try looking at the scripts for a regular door and add the same script in the same slot to your cep door.It might work.

Modifié par Builder_Anthony, 07 septembre 2011 - 04:51 .


#3
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
PlayAnimation( ANIMATION_DOOR_OPEN1 );
or maybe
DoDoorAction( oCEPDoor, DOOR_ACTION_OPEN );
should make the animation go if there is one.

#4
Shadooow

Shadooow
  • Members
  • 4 470 messages
Try this: http://pastebin.com/YXJ3NMiT

Its the script I wrote for handling placeable doors with additional features:

1) since this script is required in OnUsed even it allows to use UserDefined event for custom scripting, it fires UserDefined when used, opened, closed, teleported, or failed to open
2) it allows traps/locks to behave properly, if doors are trapped you cant open them, if they are locked, you cant open them unless you have right key
3) it has automatical closing mechanism and it also open (nearest) opposite door when you open them
4) its able to automatically lock door (note value 7 wont work as its dependant on custom OnExit script for each area)
5) if the target WP is in same area it teleports all your associates to that target as well

#5
Shiek2005

Shiek2005
  • Members
  • 104 messages
@Builder_Anthony: Doors, by default, only have an OnDeath script from what i can gather.

@Axe_Murderer: Neither method seems to work, i tried both and they did not give the placable door an animation.

@ShaDoOoW: Thanks, but that does not work either.

#6
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
The 3 default CEP door scripts are:

OnDeath: zep_doorkill
OnHearbeat: zep_doorspawn
OnUsed: zep_openclose

You will have to alter the OnUsed most likely if you want it to act as a transition. The top of the zep_openclose script explains how the doors work as far as opening and closing them gos.

#7
Shadooow

Shadooow
  • Members
  • 4 470 messages

Shiek2005 wrote...

@ShaDoOoW: Thanks, but that does not work either.


What do you mean doesnt work? I dont want to have a stupid questions but do you know what to do with it? How to add it into module/where to set this script/how to set up variables. Im using this script and it does work. Truth I have changed it a bit (removed my includes added my functions into script) but it should work.

#8
Shiek2005

Shiek2005
  • Members
  • 104 messages

GhostOfGod wrote...

The 3 default CEP door scripts are:

OnDeath: zep_doorkill
OnHearbeat: zep_doorspawn
OnUsed: zep_openclose

You will have to alter the OnUsed most likely if you want it to act as a transition. The top of the zep_openclose script explains how the doors work as far as opening and closing them gos.


Stupid question, but this is my first time doing this, so i'm not familiar with it.

I'am using the door called "Doorway", how do i know which Gateblock is the appropriate one for this particular door?

@ShaDoOoW: I mean it doesn't work, as in it doesn't give my door an open/close animation, if it doesn't do that, for my needs, it does not work

I didn't mess with the variables, but from you mentioned, it goes on OnOpen with capabilities to support the use of OnUserDefined scripts.

#9
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
I don't think that particular door is supported by this system. It probably does not have an animation for it. All the ones that are supported and have animations, already have the scripts set up on them and have a variable on them to determine which gate block to use.

What you could do though is change its appearance to "Door: Basic 1(-5) (NWN2)".  These doors were made so that when rotated they turn on the side of the door, not in the middle. So you can fake an animation by making a script that rotates the door (SetFacing) and plays a sound.

I used something like this (found in my test mod but didn't retest) but I can't remember if it works or not. Been a long time since I messed with this but I had the same problem you are having.  Hopefully it helps. It could always be altered or streamlined or what not. You would need to make a waypoint to travel to that has the same tag as the door itself.


void AutoClose()
{
    if (GetLocalInt(OBJECT_SELF, "OPEN") == TRUE)
    {
        SetFacing(GetFacing(OBJECT_SELF) + 90.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)
    {
        PlaySound("as_dr_woodmedop1");
        SetFacing(fFace - 90.0);
        SetLocalInt(OBJECT_SELF, "OPEN", TRUE);
    }
    else
    {
        string sSelf = GetTag(OBJECT_SELF);
        object oDest = GetWaypointByTag(sSelf);
        AssignCommand(oPC, ActionJumpToObject(oDest));
        PlaySound("as_dr_woodmedcl1");
        SetFacing(fFace + 90.0);
        SetLocalInt(OBJECT_SELF, "OPEN", FALSE);
    }
    DelayCommand(10.0, AutoClose());
}

Modifié par GhostOfGod, 07 septembre 2011 - 10:11 .


#10
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<delicately painting...>

GhostOfGod wrote...

I don't think that particular door is supported by this system. It probably does not have an animation for it. All the ones that are supported and have animations, already have the scripts set up on them and have a variable on them to determine which gate block to use.


What about using a default door and changing the appearance?
(I haven't fooled around much with doors, yet :-P Too many other pots to stir :-)

<...his signature on some else's masterpiece>

#11
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

Rolo Kipp wrote...

<delicately painting...>

GhostOfGod wrote...

I don't think that particular door is supported by this system. It probably does not have an animation for it. All the ones that are supported and have animations, already have the scripts set up on them and have a variable on them to determine which gate block to use.


What about using a default door and changing the appearance?
(I haven't fooled around much with doors, yet :-P Too many other pots to stir :-)

<...his signature on some else's masterpiece>


Well the thing with the CEP doors that are supported by this system is that you can walk through the doors themselves and each one has it's own matching "gateblock" that is basically just an invisible object that matches the width of the door. When the door is closed the invisible object is spawned to prevent people from walking through the door. So if you alter the appearance you might have a mismatched width for the gateblock and I'm not entirely sure how the animations will react by changing appearances either.

#12
Shiek2005

Shiek2005
  • Members
  • 104 messages

Rolo Kipp wrote...

<delicately painting...>

GhostOfGod wrote...

I don't think that particular door is supported by this system. It probably does not have an animation for it. All the ones that are supported and have animations, already have the scripts set up on them and have a variable on them to determine which gate block to use.


What about using a default door and changing the appearance?
(I haven't fooled around much with doors, yet :-P Too many other pots to stir :-)

<...his signature on some else's masterpiece>


The problem is that i'm trying to place a door in an exact position as oppossed to a doorway tile opening.

Can anyone point me towards where the CEP doors are? Under "doors" i can't find anything suitable so far o.O

#13
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<reaching in to a tall hat...>

Shiek2005 wrote...
The problem is that i'm trying to place a door in an exact position as oppossed to a doorway tile opening.

Have you tried the trick of putting in a door tile, adding the door, using "Adjust Location" to move the door to the precise place/orientation you want and deleting the doorway tile?

There was a tutorial somewhere... (Toolset Guide?) titled "How to make a free-standing door"

Or something like that..

I've used it to embed a vertical area transition in the side of an old tree...

<...and squealing in fright at whatever it was that licked his fingers>

#14
Shiek2005

Shiek2005
  • Members
  • 104 messages
That works quite nicely Rolo, thanks.

One more question, are there any appropriate doors for the [NWN2] Building - Market 01 - 05 which can be found in Civilization Exterior > Buildings > Market? I tried browsing through the door models, but so far all of them are too big <_<

#15
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

GhostOfGod wrote...

What you could do though is change its appearance to "Door: Basic 1(-5)
(NWN2)".  These doors were made so that when rotated they turn on the
side of the door, not in the middle. So you can fake an animation by
making a script that rotates the door (SetFacing) and plays a sound.


If you're not sure how to change a door appearance. Just grab that "Doorway" that you were using and place one in the toolset. Open up it's properties. Now in the first tab you see (Basic) you will see a line for Appearance Type with a drop down menu. Click the arrow and scroll to the doors. Change it to whatever appearance you want and then place the door wherever you want.

However, again, not all doors come with open and close animations. The only CEP doors that have pre-made animations are the ones in your blueprints/placeables with scripts and varaibles already attached to them. If you want to use a different door appearance you will have to make your own script to fake the animation.

Modifié par GhostOfGod, 08 septembre 2011 - 01:20 .


#16
Shiek2005

Shiek2005
  • Members
  • 104 messages
Thanks :)

#17
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
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 .


#18
Shiek2005

Shiek2005
  • Members
  • 104 messages

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?

#19
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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.

#20
Shiek2005

Shiek2005
  • Members
  • 104 messages
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 .


#21
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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 .


#22
Shiek2005

Shiek2005
  • Members
  • 104 messages
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?