Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

While what HMart says is true, I don't think the performance of objects versus scripts should be top of mind. Use whichever works well for you. If I have a complicated series of actions I need to choreograph, scripting gives me the overview and control I need. Whereas if I do it with objects, I end up with a Jenga of colored blocks whose purposes and dependencies are not obvious at a glance, and so hard to debug. That said, for relatively simple stuff, objects (as you become familiar with them) are easier.

  • Like 1
Link to comment
Share on other sites

What's the entity type for having a model that sways back and forth? I've seen swinging signs above taverns in some FM's but couldn't find the entity for making my own. I believe for constant rotation it's func_rotating but not sure for bobbing.

Edited by MirceaKitsune
Link to comment
Share on other sites

1 hour ago, MirceaKitsune said:

What's the entity type for having a model that sways back and forth? I've seen swinging signs above taverns in some FM's but couldn't find the entity for making my own. I believe for constant rotation it's func_rotating but not sure for bobbing.

func_pendulum IIRC (I don’t have my computer in front of me). Set it up and bind the visible object to it. There’s one in my mission Now and Then

  • Thanks 1
Link to comment
Share on other sites

10 hours ago, joebarnin said:

func_pendulum IIRC (I don’t have my computer in front of me). Set it up and bind the visible object to it. There’s one in my mission Now and Then

Thanks, that was it. Set the model to it directly as that's easier and seems better than creating a fake brush.

One problem then however: Some signs swing in the wrong direction. Seemingly there's no way to override the angle... the entity suggests an "angles" spawnarg, I tried setting it to either "90" or "90 0 0" but neither affect it. Any thoughts?

178083947_wolf(2022-11-3017-51-38)(250.86-306.53182.09).thumb.jpg.d8467baeb7ba21461d8e2b5d47e3ca50.jpg

Edited by MirceaKitsune
Link to comment
Share on other sites

56 minutes ago, MirceaKitsune said:

Thanks, that was it. Set the model to it directly as that's easier and seems better than creating a fake brush.

One problem then however: Some signs swing in the wrong direction. Seemingly there's no way to override the angle... the entity suggests an "angles" spawnarg, I tried setting it to either "90" or "90 0 0" but neither affect it. Any thoughts?

178083947_wolf(2022-11-3017-51-38)(250.86-306.53182.09).thumb.jpg.d8467baeb7ba21461d8e2b5d47e3ca50.jpg

Looking at the func_pendulum c++ class, shows that it doesn't care or use angles var for anything. So the only thing I can think right now, to solve this, is to bind the visible entity, to a invisible pendulum mover, moving in the direction you want the visible one to follow, its own axis doesn't matter (visually but do matter to the pendulum movement), you can even make it a brush box. Hope you get what I mean.

Also here is a old Doom 3 pendulum tutorial that I found, I didn't bother to search in TDM wiki, so perhaps there's one there as well, but just in case see if this helps. 

https://web.archive.org/web/20100522163241/http://www.doom3world.org/phpbb2/viewtopic.php?p=84076#84076

Edited by HMart
  • Like 1
Link to comment
Share on other sites

There's a chain model to lengthen signs: I'll make that the func_pendulum then just bind the func_static sign to it, I can then use at any rotation I need. The swing direction follows the rotation of the pendulum entity so I can work with that.

While here I figured I'd ask another little question for a fun idea. I noticed there are some head entities in AI/ Ambient/atdm:ambient_head* which can be used to place a generic AI head. Is it possible to also make it idly chatter? Would be fun to have some scary Frankenstein stuff like heads in a jar or on a pole that can greet each other or yell at the player when seeing them (maybe even alert other AI) with the according lipsync :)

  • Like 1
Link to comment
Share on other sites

21 minutes ago, MirceaKitsune said:

While here I figured I'd ask another little question for a fun idea. I noticed there are some head entities in AI/ Ambient/atdm:ambient_head* which can be used to place a generic AI head. Is it possible to also make it idly chatter? Would be fun to have some scary Frankenstein stuff like heads in a jar or on a pole that can greet each other or yell at the player when seeing them (maybe even alert other AI) with the according lipsync :)

Yes, just create it as a func_animate entity. I believe you can make them play a specified animation when triggered, otherwise take a look at animation script events in the TDM script reference.

  • Like 2
Link to comment
Share on other sites

2 hours ago, Dragofer said:

Yes, just create it as a func_animate entity. I believe you can make them play a specified animation when triggered, otherwise take a look at animation script events in the TDM script reference.

Both func_animate and atdm:ambient_head_base seem to work when given a proper model (eg: head_01) as in you can have them play or loop one of the head animations. For voices you can put any voice line (like tdm_ai_jack_flee) on a speaker entity and have a random one played when that speaker is triggered (wonder if subtitles will work this way). Only issue is having the head lipsync to the audio being played... I see no way the speaker can communicate that to the entity, whereas if I add an s_shader directly to the head entity it doesn't appear to have all the features of a speaker and work either.

Edited by MirceaKitsune
Link to comment
Share on other sites

Hi, another noob question:

The wiki says this about ambient_world:

Quote

Create A light and then name it ambient_world

So the classname = light and the name = ambient_world .

But there is also a classname = ambient_world . Is that the same?

Edit: I think this is sort of a preset so you don't have to manually do the configuration and make mistakes. Correct?

Edited by datiswous
Link to comment
Share on other sites

2 hours ago, datiswous said:

Edit: I think this is sort of a preset so you don't have to manually do the configuration and make mistakes. Correct?

Yes, that's most likely it. I've always just created a large light, named it ambient_world and gave it the ambientlightnfo texture but you could also create the ambient_world light entity.

Link to comment
Share on other sites

On 11/30/2022 at 3:45 PM, MirceaKitsune said:

Only issue is having the head lipsync to the audio being played

A trick that might work for you is to use a regular AI, but disassociate the head from the body by using a large distance for the spawnarg offsetHeadModel <x y z>, described in https://wiki.thedarkmod.com/index.php?title=Female_AIs_-_Faces_%26_Heads#More_about_Pairing_a_Head_with_a_Body

So, you could have the body in an isolated "basement" room, maybe motionless or doing a path loop, and the head on the floor above, making similar traversals and speaking its lines by any of the normal methods. (If the sound emission turns out to be associated with the body instead of the head, you might need to cut some vents in the floor to allow sound propagation.)

 

Link to comment
Share on other sites

My mind's been on a plan for yet another FM which I haven't yet started, I'm still thinking of what I'd need for it. As a relevant reminder, please let me know if there's any developer knowledge or known workarounds on the gravity bug as low gravity is a feature I'd want to use. For now regarding the immediate questions:

I'd like to know if there is a way to make a model transition to a given rotation based on the switch that triggers it, useful for things like complex indicators or puzzles. Like let's say you have four buttons and an arrow: You want the arrow to point up when you press the center button, -45* when pressing the left button, +45* when pressing the right button, or down (180*) when you use the down button. How can each button make it go to its intended rotation? Many FM's have elevators that go to different floors so this exists for movement, haven't yet checked how it's done but I wonder if it's the same way for rotation.

A similar question for lights; Normally a light will instantly turn on and off when triggered. What if I want a light that instead changes its color to a new value based on the button pressed? Smooth transition would be nice though instant works too. I can use multiple lights and turn one on with the other off, but if possible it would be ideal to fade the color on one light entity.

Edited by MirceaKitsune
Link to comment
Share on other sites

I haven't tried this myself yet, but I found some script code in another project that fades a light from one color to another:

		// Transition
		vector delta = col2 - col;
		float starttime = sys.getTime();
		float endtime = starttime + fadeSeconds;
		float nowtime = sys.getTime();
		while ( nowtime < endtime )
		{
			float frac = ( nowtime - starttime ) / fadeSeconds;
			theLight.setLightParm(0, col_x + (frac * delta_x) );
			theLight.setLightParm(1, col_y + (frac * delta_y) );
			theLight.setLightParm(2, col_z + (frac * delta_z) );

			sys.waitFrame();
			nowtime = sys.getTime();
		}
		// Finalize colour
		theLight.setLightParm(0, col2_x );
		theLight.setLightParm(1, col2_y );
		theLight.setLightParm(2, col2_z );

'col2' is the new color, 'col1' is the old one. 'fadeSeconds' is how fast to fade. Give this a try?

  • Like 1
Link to comment
Share on other sites

Thanks. No way without a custom script then and having to use your own timer function? If that's needed I might go for this option then. What about making a func_static go to different rotations, can that be done without a map script?

Link to comment
Share on other sites

There are various ways of calling scripts that are able to pass one or more variables. Most commonly they can pass the entity that called the script. This is handy because you can set various custom spawnargs on that entity and let the script look them up.

The best way is to let each button target a callscriptfunction entity with the spawnargs “foreach” “1”, “call” “move_target” and targetting the desired mover, which can pass up to 3 different entities. Each button should have a custom spawnarg storing the desired new color and angles. Need the 1st entity (target) and 2nd entity (button that triggers the callscriptfunction entity) in this case:

void move_target(entity ent_target, entity ent_button, entity ent_callscriptfunction)
{
	//fade the color
	float colorFadeTime = 1;
	vector newColor = ent_button.getVectorKey(“_color_new”);
	thread crossFadeEnt( ent_target, ent_target.getColor(), newColor, colorFadeTime );

	//move the target, if needed
	float moveSpeed = 30;
	vector newAngles = button.getVectorKey(“angles_new”);
	vector delta = newAngles – ent_target.getAngles();
	float moveTime = sys.vecLength( delta ) / moveSpeed;

	if( moveTime > 0 )
	{
		ent_target.time( moveTime );
		ent_target.rotateOnce( delta );
	}
}

tdm_util.script contains various pre-made utility scripts including crossFadeEnt, which I used above to perform the colour fade.

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, MirceaKitsune said:

What about making a func_static go to different rotations, can that be done without a map script?

I think you want to use a func_rotating. Not sure how. Check out @JackFarmer's 'Hidden Hands: The Lost Citadel' mission - there are objects that rotate when you push a button.

  • Thanks 1
Link to comment
Share on other sites

Thanks! Sounds good, will look at it when I try the base concept. I take it multi-floor elevators also used a script or Stim / Response all along then? Didn't think about it before.

Another gimmick I wanted to attempt... this is something I always wanted to try out in TDM, now that I'm working on a small FM with just a few ambient songs I figured it would be a good time. I like how in similar games the music changes when a guard is attacking you which also helps you know you're being attacked: How would I do this? If scripting is needed as will surely be the case, how do I check the highest alert level of an AI then stop whichever song is playing and play a fixed one instead, afterward when the AI calms down go back to the ambience defined in that zone?

I noticed that in my first FM (and somehow still the only one I finished and posted to this day) I'd use $atdm_location_settings_1.setKey("snd_myarea","nosound") to clear or change the music in a place. I could do this whenever a guard changes alert level I guess, but I think the ambient music is only applied when the player enters or exits an area so I'd also need a way to refresh it. What are your thoughts?

Edited by MirceaKitsune
Link to comment
Share on other sites

5 hours ago, MirceaKitsune said:

If scripting is needed as will surely be the case, how do I check the highest alert level of an AI then stop whichever song is playing and play a fixed one instead, afterward when the AI calms down go back to the ambience defined in that zone?

1) Cycle through all entities that use the AI scriptobject. Wiki

2) For each entity, access the AI scriptobject variables to check alert state. Wiki

3) Use the override system to temporarily override the ambient. Wiki

  • Thanks 1
Link to comment
Share on other sites

5 hours ago, MirceaKitsune said:

Thanks! Sounds good, will look at it when I try the base concept. I take it multi-floor elevators also used a script or Stim / Response all along then? Didn't think about it before.

The elevator is implemented in the source code as a multi_state_mover spawnclass, allowing AIs to interact with it.

In any case, in one of my previous posts I detailed how to setup button-specific orientations & colour fades via scripts alone.

  • Thanks 1
Link to comment
Share on other sites

On 12/4/2022 at 2:25 PM, MirceaKitsune said:

making a func_static go to different rotations

Func_statics are the wrong entity for that, those are optimized and used for static objects, meaning objects that don't move at all. 

What you want is to use a func_mover, these don't move unless you script them to move but they are specially handled by the engine and have dedicated script code that func_statics don't have, for example func_movers have special rotating functions called RotateDownTo, RotateUpTo, RotateOnce, etc and special moving functions as well, those should be defined in TDM_events.script.

Btw don't confuse with func_movable that is for rigid body physics objects only.

Link to comment
Share on other sites

That is correct, func_static typically shouldn't be used for the purpose. I'm looking at func_mover but can't quite tell what I'd need to script myself or will work automatically: If I have it targeting multiple positions specified by another func_* (target0, target1, target2, etc) can each button call it to go to that specific target like the Wiki indicates, accounting for both position and rotation? multistate doesn't seem to support different rotations so might not be what I'm looking for in this case.

Link to comment
Share on other sites

I started putting together the basis of the project where I'll need my rotating / elevator stuff, still yet to get to that part. Hopefully without spoiling too much of my surprises, I'm toying with a dynamic daytime cycle of sorts. I'm easily able to obtain what I want using a light texture material... already have a working prototype which respects the lightgem and all, the skybox will use a fog light with a similar algorithm for the atmosphere. Only issue is I can't quite line up the color cycle to get the proper colors, seems I always get stuck when it comes to complex mathematics.

red 		(sintable[(time * 1) / Parm4]) * Parm0
green 		(sintable[(time * 1) / Parm4]) * Parm1
blue 		(sintable[(time * 2) / Parm4]) * Parm2

ShaderParm4 is the length of a day. I'm using 5 for a test... it will be much larger in practice of course, a day will probably last somewhere between 5 and 10 real life minutes.

The colors are off though... using a sintable / costable mixture works but I need the proper offsets: I want the sun to start / end at a full red, get yellowish just before / after the sunset / sunrise, and during the day just slightly increase its brightness toward noon... for the moon at night it should stay white just at very low intensity (0.1 should do). If anyone figures out a good formula please let me know, thanks!

Edited by MirceaKitsune
Link to comment
Share on other sites

@MirceaKitsune, instead of relying on sintable and an algorithm, you might consider just creating your own table of settings, which you could manually massage until you're happy. For instance, in tdm_ai_steambots.mtr, Baddcog defined a table manually:

table lanternbot_flicker_high { { 0.9, 0.8, 1, 1, 1, 1, 1, 1, 1, 0.8, 1, 0.9, 0.8, 1, 0.9, 0.9, 0.85, 0.9 } }

which was then invoked in that file as "lanternbot_flicker_high[time]" in combination with other parms to set red, green, blue.

For your case, if it was me doing it, I'd define separate tables for R, G, B, maybe with a change every half hour of simulated time (e.g., 48 values per table). You'd still have to do some calculation to normalize the time before indexing the table.

  • Like 2
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

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...