Jump to content
The Dark Mod Forums

Skin that toggles with button?


Springheel

Recommended Posts

I have a model light with a separate light attached. I'd like the model to switch skins to an unlit version when a button is pressed but I want the light and model separate, and not part of the same entity. Is there an easy way to do this?

 

I tried making the model into a light entity with no light spawnarg, but it seems a light gets spawned with it anyway (though I can't find where it comes from).

 

 

Link to comment
Share on other sites

Do you mean as part of a light entity or just on the regular model? I've tried the former, which works fine, but then the entity spawns an additional light somehow. I didn't think the latter would work.

Link to comment
Share on other sites

Yeah, if your talking about the new 4 way ceiling light your making, just have a look at "atdm:antique_chandelier_4_globes" as that switches between lit and unlit skin for on and off etc.

 

Def

entityDef atdm:antique_chandelier_4_globes
{
	"inherit"				"atdm:static_electric_light_lit_quiet_base"
	"model"								"models/darkmod/lights/non-extinguishable/chandelier_gas4.lwo"
	"editor_setKeyValue model"			"models/darkmod/lights/non-extinguishable/chandelier_gas4.lwo"
	"editor_displayFolder"				"Lights/Model Lights, Static/Switchable/Electric/Indoor"
	
	"skin"								"lights/chandelier_gas4"
	"skin_lit"							"lights/chandelier_gas4"
	"skin_unlit"						"lights/chandelier_gas4_unlit"
	
	// need a better light sound texture - removed per Springheel, no buzzing indoor lights
	//"texture"							"lights/biground1_squarelamp_snd"
	"editor_usage"						"A lit wall-mounted electric lamp with a fancy design. Can be switched on/off."
	"light_center"						"0 0 -54"
	"editor_setKeyValue light_center"	"0 0 -54"
	"noshadows"							"0"
	"noshadows_lit"						"1" // grayman #2943 - no shadows from the model when lit
}

Skin

skin lights/chandelier_gas4_unlit
{
    model "models/darkmod/lights/non-extinguishable/chandelier_gas4.lwo"
    model "models/darkmod/lights/non-extinguishable/wall_gas4.lwo"

    tdm_chandelier_gas4 tdm_chandelier_gas4_unlit
}

skin lights/chandelier_gas4
{
    model models/darkmod/lights/non-extinguishable/chandelier_gas4.lwo
    model models/darkmod/lights/non-extinguishable/wall_gas4.lwo

    //placeholder to swap skins
}

Material

tdm_chandelier_gas4 //author: Tricko
{
    qer_editorimage	models/darkmod/props/textures/chandelier_bronze_001_ed
	metal
    noshadows

    diffusemap  models/darkmod/props/textures/chandelier_bronze_001
    bumpmap     models/darkmod/props/textures/chandelier_bronze_001_local
    specularmap	models/darkmod/props/textures/chandelier_bronze_001_s
    
    {blend add
    map   models/darkmod/props/textures/chandelier_bronze_lit001   }


   {
	        if ( parm11 > 0 )
	        blend       gl_dst_color, gl_one
	        map         _white
	        rgb         0.40 * parm11
	    }
	    {
	        if ( parm11 > 0 )
	        blend       add
	        map         models/darkmod/props/textures/chandelier_bronze_001
	        rgb         0.15 * parm11
    }

	// TDM Ambient Method Related 
	{							
		if (global5 == 1)		
		blend add				
		map				models/darkmod/props/textures/chandelier_bronze_001		
		scale			1, 1		
		red				global2	
		green			global3	
		blue			global4	
	}							
}

tdm_chandelier_gas4_unlit //author: Tricko/Baddcog
{
    qer_editorimage    models/darkmod/props/textures/chandelier_bronze_001_ed
    metal
    noshadows

    diffusemap  models/darkmod/props/textures/chandelier_bronze_001
    bumpmap     models/darkmod/props/textures/chandelier_bronze_001_local
    specularmap    models/darkmod/props/textures/chandelier_bronze_001_s
    
   {
            if ( parm11 > 0 )
            blend       gl_dst_color, gl_one
            map         _white
            rgb         0.40 * parm11
        }
        {
            if ( parm11 > 0 )
            blend       add
            map         models/darkmod/props/textures/chandelier_bronze_001
            rgb         0.15 * parm11
    }

    // TDM Ambient Method Related
    {                            
        if (global5 == 1)        
        blend add                
        map                models/darkmod/props/textures/chandelier_bronze_001        
        scale            1, 1        
        red                global2    
        green            global3    
        blue            global4    
    }                            
}
Link to comment
Share on other sites

Sounds like one of your skin defs is including a light attachment (either directly or inherited) unless there's something hard-coded happening there?

 

Post your def code and I'll peek around the SVN when I get home.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

But that entity comes with an attached light, which I want to avoid.

Than I would think its just a a case of removing the light entity from the def -

 

- "inherit" "atdm:static_electric_light_lit_quiet_base"

 

If not, nbhor should be able to figure it out for you.

Link to comment
Share on other sites

I've made an entity that looks like this:

 

entityDef atdm:electric_ornate_chandelier01
{
"inherit" "atdm:light_base"
"editor_usage" "ornate_chandelier01 that can be switched on and off. Entity does not include actual lights; just switches skins. Lights must be added separately."

"AIUse" "AIUSE_LIGHTSOURCE"
"lightType" "AIUSE_LIGHTTYPE_ELECTRIC" // grayman #2603


"editor_displayFolder" "Lights/Model Lights, Static/Switchable/Electric/"
"model" "models/darkmod/lights/non-extinguishable/chandelier_ornate01.lwo"

"extinguished" "0"




"skin_lit" "chandelier_ornate01_lit"
"skin_unlit" "chandelier_ornate01_unlit"


// so we can use LightOn(), LightOff().
// Switching skin does not work when triggered by a button:
"scriptobject" "tdm_light_holder"

// grayman #2603 - This stim can be turned on to have AI notice the light is off
"sr_class_1" "S"
"sr_type_1" "STIM_VISUAL"
"sr_state_1" "1"
"sr_radius_1" "500"
"sr_time_interval_1" "977" // every second or so

"noshadows" "0"
"noshadows_lit" "1"
}

 

It only inherits from light_base, which doesn't have any attached lights that I can see. Yet a light is spawned anyway. Maybe it's because of "spawnclass" "idLight"?

 

(the comment about skins not switching with a button is evidently false, because that part works)

Link to comment
Share on other sites

Its getting a light entity from the line -

 

 

How?

 

There's nothing in "light_base" that indicates an attached light. "light_base" inherits from "light", which has the spawnclass line I mentioned above, but I see nothing else in the inheritance tree that could attach a light.

Link to comment
Share on other sites

I think you are onto something with spawnclass idLight but I'll take a look at:

 

"scriptobject" "tdm_light_holder"

 

to see if this is spawning it's own light too.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I think you are onto something with spawnclass idLight but I'll take a look at:

 

"scriptobject" "tdm_light_holder"

 

 

 

Commenting that out doesn't remove the light, but does stop the skin swapping from working.

Link to comment
Share on other sites

Is there any other option for toggling a skin on and off with a button?

Answering that question on its own, you can use stim response on the lamp to change the skin when triggered.

Link to comment
Share on other sites

If the spawnclass is idLight, you'll get a light at spawn time. That is the spawnclass, after all.

 

 

Does that mean all our light entities that def_attach a light actually have two lights?

  • Like 1
Link to comment
Share on other sites

Interesting point. I was just thinking that the tdm_light_holder script itself has a light spawn in it

similar to how scripted fog lights work. That would be a nice boost if we could get rid of duplicate

lights.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

 

Does that mean all our light entities that def_attach a light actually have two lights?

 

No, because the spawnclass of those lights is something other than idLight. Typically they're an idStaticEntity.

 

If you can find an example of a light that uses a model and attaches a light (or an entity that eventually leads to attaching a light, like a candle holder with a candle in it), and its spawnclass is idLight, then it's probably creating one more light than needed, but I haven't found an instance of that, after looking at a half dozen examples.

Link to comment
Share on other sites

Interesting point. I was just thinking that the tdm_light_holder script itself has a light spawn in it

similar to how scripted fog lights work. That would be a nice boost if we could get rid of duplicate

lights.

 

I don't see where the tdm_light_holder script spawns lights.

Link to comment
Share on other sites

If you can find an example of a light that uses a model and attaches a light (or an entity that eventually leads to attaching a light, like a candle holder with a candle in it), and its spawnclass is idLight, then it's probably creating one more light than needed, but I haven't found an instance of that, after looking at a half dozen examples.

 

 

I was thinking of examples like this, which def_attachs a "light_lamp_desk_03" entity.

 

entityDef atdm:lamp_desk_03_with_switch

{

"inherit" "atdm:static_light_lit_base"

"model" "models/darkmod/lights/non-extinguishable/lamp_desk_03.ase"

 

"extinguished" "0"

"noshadows_lit" "1" // turn off shadow when lit

// Let the lamp not obscure the light:

"noshadows" "1" // lit, so has no shadows

 

"editor_usage" "A small desk lamp with a switch that the player can toggle to turn the lamp on/off."

"editor_displayFolder" "Lights/Model Lights, Static/Switchable/Electric/Indoor"

 

// the lamp itself is unfrobable

"frobable" "0"

 

"def_attach" "light_lamp_desk_03"

"pos_attach" "flame" // At the attach point called "flame"...

"attach_pos_name_1" "flame" // ... which is defined here.

"name_attach" "flame" // Give it a name to pass along spawnargs

"attach_pos_origin_1" "0 0 37.6" // Offset the light a bit

"attach_pos_angles_1" "0 0 0" // rotate the light

 

"skin" "desklampshade_03"

"skin_lit" "desklampshade_03"

"skin_unlit" "desklampshade_03_unlit"

 

// attach the switch

"def_attach_2" "atdm:lamp_desk_switch"

"pos_attach_2" "switch" // At the attach point called "switch"...

"attach_pos_name_2" "switch" // ... which is defined here.

"name_attach_2" "switch" // Give it a name to pass along spawnargs

"attach_pos_origin_2" "-2 0 4.125" // Offset the switch a bit

"attach_pos_angles_2" "0 0 0" // rotate the switch

 

// add a link from the switch to the flame (self here refers to the newly spawned base lamp entity)

"add_link" "self:attached:switch to self:attached:flame"

}

Link to comment
Share on other sites

Ok, to answer my own question for future reference, there are two ways to do this:

 

1. Keep the attached light but set the radius to 1,1,1.

 

2. Set the entity to inherit from "atdm:static_light_lit_base". This inherits from func_static and isn't an idLight, but still has the script that allows for skin changes. Most of our lights that attach open flames do this.

  • Like 1
Link to comment
Share on other sites

Nope. It's still possible that those desk lamps might be spawning more than one light, but I don't think that's a big issue even if it is so.

Link to comment
Share on other sites

Nope. It's still possible that those desk lamps might be spawning more than one light, but I don't think that's a big issue even if it is so.

 

They won't be using more than one light. I remember discussing it last year when we were working out why the def_attach variety of entity light didn't used to respond to activation by a switch. Simple lights like desk maps can be an idLight themselves because they only need one model, the lamp. Entities like torches need two models because they have a particle effect too, so they use def attach to spawn a separate entity light which carries the particle model. The script object doesn't spawn a light either way.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 5 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
×
×
  • Create New...