Aller au contenu

Photo

Changing a Door's Appearance via a VFX


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

#1
rjshae

rjshae
  • Members
  • 4 485 messages

I wanted to explore a suggestion to change a door's visual appearance through the application of a visual effect, and here is what I came up with. In short, it works. Here's my demo script:

// Area OnClientEnter
/*
    This is an Area OnClientEnter event handler.
    
    This script demonstrates the application of a spell effect
    to a door in order to change its appearance. The script is
    placed in the 'On Client Enter Script' property of the area
    with the door, and the door itself is given an integer
    variable with the ID of the VFX. For example:
    
        visual_effect_ID = 669
    
    Here are some visual effect identifiers:
    
        643 -- VFX_DUR_SPELL_BARKSKIN
        661 -- VFX_DUR_SPELL_SPIDERSKIN
        669 -- VFX_DUR_SPELL_STONESKIN
        688 -- VFX_DUR_SPELL_IRON_BODY
        918 -- VFX_SPELL_DUR_TORT_SHELL
*/
// rjshae 4/19/14

const string VISUAL_EFFECT_ID = "visual_effect_ID";
const int VISUAL_EFFECT_SPELL_ID = 6949; // Must be unique

/*    This script looks for any doors, then checks whether
    they have a "visual_effect_ID" set. If so, it applies
    the matching visual effect to the door.
*/
void ApplyVisualEffectToDoors()
{
    object oTarget = GetFirstObjectInArea( OBJECT_SELF );
    while( GetIsObjectValid( oTarget ) ) {
        // Check for a door
        int nType = GetObjectType( oTarget );
        if ( nType == OBJECT_TYPE_DOOR ) {
            // Temporary
            object oPC = GetFirstPC();
            SendMessageToPC( oPC, "Found door" );
            
            int nVisualEffectID = GetLocalInt( oTarget, VISUAL_EFFECT_ID );
            if ( nVisualEffectID != 0 ) {
                // Remove a previous visual effect, if any
                effect eEffect = GetFirstEffect( oTarget );
                while ( GetIsEffectValid( eEffect ) ) {
                    // Compare the spell ID to VISUAL_EFFECT_SPELL_ID
                    int nEffectSpellId = GetEffectSpellId( eEffect );
                    if ( nEffectSpellId == VISUAL_EFFECT_SPELL_ID ) {
                        // Remove the visual effect and exit the loop
                        RemoveEffect( oTarget, eEffect );
                        break;
                    }
                    eEffect = GetNextEffect( oTarget );
                }
                RemoveEffect( oTarget, eEffect );
                
                // Apply the permanent effect to the door
                effect eDoorVisualEffect = EffectVisualEffect( nVisualEffectID );
                eDoorVisualEffect = SupernaturalEffect( eDoorVisualEffect );
                eDoorVisualEffect = SetEffectSpellId( eDoorVisualEffect, VISUAL_EFFECT_SPELL_ID );
                ApplyEffectToObject( DURATION_TYPE_PERMANENT, eDoorVisualEffect, oTarget );
            }
        }
        oTarget = GetNextObjectInArea( OBJECT_SELF );
    }
}

int StartingConditional()
{
    // Event fired via non-party transition (Load Game, Client Join, etc.)
//    if ( FiredFromPartyTransition() == FALSE )
//    {
//        return ( FALSE );
//    }
    
    // Get party leader, force control of owned PC
    object oPC = GetFirstEnteringPC();
    object oLeader = GetFactionLeader( oPC );
    oPC = SetOwnersControlledCompanion( oLeader );
    
    object oSpeaker;
    string sDialog;
    
    // Look up the doors in the area
    ApplyVisualEffectToDoors();
    
    // Revert control to original character
    SetOwnersControlledCompanion( oPC, oLeader );
    return ( FALSE );
}

Of course, one could apply a named effect file rather than a spell visual effect as was used here. Below is a demonstration of a door after applying the appropriate local variable and adding the above script to the On Client Enter for the area:

 

ve_door_open_zps1a2efe86.png

 

You can see the covering maps across the surface, regardless of the position of the door. Here are several more variants. I particularly like the iron skin covering.

 

ve_door_cover_zpsdb9ec125.png

 

So there you go: a way to change a door's appearance without creating a new door placeable.


  • Morbane, kamal_, Rolo Kipp et 3 autres aiment ceci

#2
andysks

andysks
  • Members
  • 1 645 messages

Good job Bob. I am certain that I will find use of this when I move to creating the planes and some dream sequences, in order to make the entrance to the next room otherworldly lets say.



#3
rjshae

rjshae
  • Members
  • 4 485 messages

The one drawback is that it makes the spell manifestation noise when the visual appearance is applied. It would probably make sense to create a set of door covering effects that don't do the sound. Maybe generate a variety of different door types and see if a pattern texture can be precisely mapped.



#4
andysks

andysks
  • Members
  • 1 645 messages

Well, the things you said are too complicated for me. So I'll use it with or without the "drawback" :). I like it as it is no problem.



#5
rjshae

rjshae
  • Members
  • 4 485 messages

Well, the things you said are too complicated for me. So I'll use it with or without the "drawback" :). I like it as it is no problem.

 

I don't have much experience with the visual effects editor either.  :)  But perhaps it isn't too hard to open an existing visual effect file in the toolset editor and just trim out the sound part? Changing the graphic might just be a matter of modifying a file name. Shrug.

 

IIRC, there are some visual effect sets posted to the vault. It might be worth looking through those for more examples and build a set of door coverings.



#6
kamal_

kamal_
  • Members
  • 5 240 messages

I don't have much experience with the visual effects editor either. But perhaps it isn't too hard to open an existing visual effect file in the toolset editor and just trim out the sound part? Changing the graphic might just be a matter of modifying a file name. Shrug.

It's easy. The vfx are made up of combinations of components parts, and you can add/remove them individually. The hardest part would be finding the vfx in the nwn2 directory. You'd just gave to give the soundless version a different vfx name.



#7
rjshae

rjshae
  • Members
  • 4 485 messages

Ta-da! A golden door.

 

You're right, it was pretty easy. I just modified the stoneskin fx, removed the particle emitters, then set my own texture files and slapped it in a hak.

 

gold_door_zpse4df4247.png

 

Here's the modified script I used:

 

// Area OnClientEnter
/*
    This is an Area OnClientEnter event handler.
    
    This script demonstrates the application of a spell effect
    to a door in order to change its appearance. The script is
    placed in the 'On Client Enter Script' property of the area
    with the door, and the door itself is given a string
    variable with the name of a .sef file.
*/
// rjshae 4/19/14

const string VISUAL_EFFECT_FILE = "vfx_file";
const int VISUAL_EFFECT_SPELL_ID = 6949; // Must be unique

/*    This script looks for any doors, then checks whether
    they have a "visual_effect_ID" set. If so, it applies
    the matching visual effect to the door.
*/
void ApplyVisualEffectToDoors()
{
    object oTarget = GetFirstObjectInArea( OBJECT_SELF );
    while( GetIsObjectValid( oTarget ) ) {
        // Check for a door
        int nType = GetObjectType( oTarget );
        if ( nType == OBJECT_TYPE_DOOR ) {
            string sVfxFileName = GetLocalString( oTarget, VISUAL_EFFECT_FILE );
            if ( GetStringLength( sVfxFileName ) > 0 ) {
                // Remove a previous visual effect, if any
                effect eEffect = GetFirstEffect( oTarget );
                while ( GetIsEffectValid( eEffect ) ) {
                    // Compare the spell ID to VISUAL_EFFECT_SPELL_ID
                    int nEffectSpellId = GetEffectSpellId( eEffect );
                    if ( nEffectSpellId == VISUAL_EFFECT_SPELL_ID ) {
                        // Remove the visual effect and exit the loop
                        RemoveEffect( oTarget, eEffect );
                        break;
                    }
                    eEffect = GetNextEffect( oTarget );
                }
                RemoveEffect( oTarget, eEffect );
                
                // Apply a permanent effect to the door
                effect eDoorVisualEffect =     EffectNWN2SpecialEffectFile( sVfxFileName );
                eDoorVisualEffect = SupernaturalEffect( eDoorVisualEffect );
                eDoorVisualEffect = SetEffectSpellId( eDoorVisualEffect, VISUAL_EFFECT_SPELL_ID );
                ApplyEffectToObject( DURATION_TYPE_PERMANENT, eDoorVisualEffect, oTarget );
            }
        }
        oTarget = GetNextObjectInArea( OBJECT_SELF );
    }
}

int StartingConditional()
{
    // Event fired via non-party transition (Load Game, Client Join, etc.)
//    if ( FiredFromPartyTransition() == FALSE )
//    {
//        return ( FALSE );
//    }
    
    // Get party leader, force control of owned PC
    object oPC = GetFirstEnteringPC();
    object oLeader = GetFactionLeader( oPC );
    oPC = SetOwnersControlledCompanion( oLeader );
    
    object oSpeaker;
    string sDialog;
    
    // Look up the doors in the area
    ApplyVisualEffectToDoors();
    
    // Revert control to original character
    SetOwnersControlledCompanion( oPC, oLeader );
    return ( FALSE );
}

 

We could have a lot of fun with this... :)


  • Rolo Kipp aime ceci

#8
Tchos

Tchos
  • Members
  • 5 042 messages

I'll see about using this technique to apply a texture that's specifically made for a door, to replace the texture with a fitted one.  I have dozens of door textures, but I dread the thought of having to make new doors for each one.


  • Rolo Kipp aime ceci

#9
rjshae

rjshae
  • Members
  • 4 485 messages

It seems to be UV mapped and there is no warping of the texture, so hopefully it'll use the same map on the fx as it does on the door texture.

 

I'm hoping to use this to generate a couple of dwarven stone doors.


  • Rolo Kipp aime ceci

#10
rjshae

rjshae
  • Members
  • 4 485 messages

Yes, it works...

 

overlay_zps07fb5015.png

 

Ed.: Note that I used a 512x512 texture for the effect, rather than the 256x256 used for the door. So it scales nicely.


  • kamal_ et Rolo Kipp aiment ceci

#11
kamal_

kamal_
  • Members
  • 5 240 messages

kamal likes this  ;)



#12
rjshae

rjshae
  • Members
  • 4 485 messages

Here's an experiment in using the NWN metal door texture for a fx reskin of std. door #5. It's, mmm... decent.

 

metal_door_zps13d7d7d0.png


  • PJ156, Rolo Kipp et Loki_999 aiment ceci

#13
PJ156

PJ156
  • Members
  • 2 982 messages
That works good :)

PJ

#14
Claudius33

Claudius33
  • Members
  • 256 messages

Nice.  :)



#15
rjshae

rjshae
  • Members
  • 4 485 messages

The light and dark areas are burnt into the NWN door texture, so you could end up with some odd-looking shadow arrangements. Oh well. It looks like the standard doors don't have a common layout, so an fx skin like this probably only works well with the specific door it is mapped to; otherwise it ends up mapped oddly, such as the door grip being along the edge and so forth. I'm going to reflect that in the fx name: e.g. fx_stdr5_nwn_metal.

 

There's only a few NWN door types, so I'll put some fx skins together and make them available for download. Maybe a short tut as well so some future reader can repeat it. :)


  • Rolo Kipp aime ceci

#16
4760

4760
  • Members
  • 1 204 messages

This opens a lot of possibilities! Nice work!



#17
Dann-J

Dann-J
  • Members
  • 3 161 messages

I wonder if you can make a door translucent by applying a VFX (like 'camouflage')? Then you could make glass or ice doors. Although if the door is blocking the minimap you'll see nothing but black behind it.


  • rjshae aime ceci

#18
rjshae

rjshae
  • Members
  • 4 485 messages

I wonder if you can make a door translucent by applying a VFX (like 'camouflage')? Then you could make glass or ice doors. Although if the door is blocking the minimap you'll see nothing but black behind it.

 

I haven't experimented with the VFX tool much, but perhaps if a semi-transparent second layer were added as a box around the door with a solid icy texture on the door surface, that could be used to give the illusion of transluscence. I've no idea if that is possible.

 

Ed.: If we could add a model surface to a door like this via a vfx, we could also build more secret door shapes. Maybe even ones that don't highlight on a mouse-over? :ph34r:



#19
rjshae

rjshae
  • Members
  • 4 485 messages

It looks like there is a way to attach a model as part of a vfx. So, for the back face of the semi-transparent door, I could just use the door model, reverse the normal maps (so it is viewable from the opposite direction), attach an opaque icy texture, then perhaps modify the model slightly to give it more depth. Hopefully the result is that the outer door surface is see-through but the inner surface is not, giving the illusion of an ice block. It might also help to add an illumination texture to the inner surface.



#20
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
How bizarre,

I was going to post a similar discovery when I found this post! Must be synchronicity at work.

I had been playing around with VFX on doors to imply magic was on it and discovered the same appearance changes with some effects. I even designed a lever to play around changing the VFX on the door to check them all out. There were obviously quite a few VFX that don't "attach" correctly, but there were others (like you show above) that worked well. I did also find ones like glowing effects worked and another gave a surreal black and white effect.
 
I simply added the effect from the doors HB effect (single check), but that was because I don't have many doors to consider at this point:-

iEffectVar is attached to the door as a variable at build time. (Relates to visualeffects.2da reference. i.e. The same number references as used in the above examples. E.g. If EFFECTVAR = 643 you would get the barkskin effect attached to the door.)

EXAMPLE FROM MY CODE:-
 
        // DOES THIS OBJECT EMIT AN AURA?
	int AURACHECK = GetLocalInt(OBJECT_SELF, "CHECKAURA");	
	
	if(AURACHECK == 0)
	{
		SetLocalInt(OBJECT_SELF, "CHECKAURA", 1);				
		int iEffectVar = GetLocalInt(OBJECT_SELF, "EFFECTVAR");
		if(iEffectVar > 0)
                {
                     effect eVFXAPPLY = EffectVisualEffect(iEffectVar);
                     ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVFXAPPLY, OBJECT_SELF);
                }
	}

Lance.
  • rjshae aime ceci

#21
rjshae

rjshae
  • Members
  • 4 485 messages

I've made a few NWN door vfx and a tutorial available here:

Please give it a try and see what you think. Thanks.



#22
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

I've made a few NWN door vfx and a tutorial available here:

Please give it a try and see what you think. Thanks.


New textures! Excellent!

Will download them, but may b a while before I get chance to test.

EDIT: Thanks for the informative info about how you got the textures into sefs.

EDIT: I will be adding these extra door VFXs to the visualeffects.2da (if that works), which makes adding them a bit easier. (As an alternative method of application. See my code example in last post.)

Thanks for these,
Lance.
  • rjshae aime ceci

#23
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

Hi Again,

For those interested, adding the new "door texture sefs" as lines to the visualeffects.2da works fine. Furthermore, as these can be added as visual effects using the following kind of code, then they can easily be removed with code that removes visual effects:-

 

See full example of code in a previous post on the previous page.

effect eVFXAPPLY = EffectVisualEffect(iEffectVar);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVFXAPPLY, OBJECT_SELF);

Also, I have made sure I have not accidentally added any "spell" like sounds and VFXs that are applied when the VFX is applied, so the effect is added silently. i.e. The effect alone is added and no spell sounds, etc.

Below is a clip from my own visualeffects.2da to show where the sef lines were added. NB: The sef file reference has to be entered all lower case, or else the effect will not be fired.

Lastly, I was unaware with any problems adding these effects to the standard door 1, but that might be because I did not know what I was looking for with respect to any issues mentioned in other posts.

My thanks again to rhshae for providing them.

Lance.

vfx2da.jpg



#24
rjshae

rjshae
  • Members
  • 4 485 messages

I'm probably being overly cautious in combining the visual effect with the SupernaturalEffect and SetEffectSpellId calls, but it helps avoid some type of dispel magic script from accidentally stripping off the visual effect and makes it easy to remove this effect without disturbing any others.

 

BTW, that last door in the posted set is using an ice texture with a slight alpha. However, I'm not sure I can really see it due to the amount of variance in the texture. It looks nice though, I think.

 

I had a thought that this method could also be used to create more secret doors by applying the texture of the tile walls. (It might be nice to have some door tile variants that are designed specifically for secret doors. I.e. no door frames.) I was wondering though: if we create a sef that has an attached model, will that model highlight with a mouse-over? I.e. could we use it to avoid the highlight?

 

Another thought I had is that we could create custom skins that are styled for some of the more popular tile set mods.



#25
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

<SNIP> 
I had a thought that this method could also be used to create more secret doors by applying the texture of the tile walls. (It might be nice to have some door tile variants that are designed specifically for secret doors. I.e. no door frames.) I was wondering though: if we create a sef that has an attached model, will that model highlight with a mouse-over? I.e. could we use it to avoid the highlight?
 
Another thought I had is that we could create custom skins that are styled for some of the more popular tile set mods.


Hi rjshae,

Just a quick note about secret doors. I managed to get real secret doors (with no hover clue) and posted a bit more about it in this blog entry of mine:-

http://worldofalthea...cret-doors.html

Just a thought for you ....

Cheers,
Lance.