Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

46 minutes ago, MirceaKitsune said:

Yeah this is a bit confusing. And indeed I should be able to simply print what .getButtons() says while holding down different buttons, that should give me the necessary result. 76 seems wrong though as it's not a power of two, IIRC that's how bits work.

In this particular case they don't follow power of two rules, they just get a basic integer value automatically by c++, because is a enum like the first in the examples bellow:

// this is the enum used in TDM source, is a C type unnamed enum and gets set to a int automatically.  
enum {  
value0,   // this is  0
value1,  // this is 1
value2,  // this is 2
value3,  // this is 3
...    // etc
};

// this is a C type unnamed enum based on power of two unsigned int values (hex values)
enum {
value0,  // this is automatically a 0
value1 = 0x1,
value2 = 0x2,
value3 = 0x4,
value4 = 0x8, 
...    // etc
};

 

Link to comment
Share on other sites

1 hour ago, grayman said:

You an use this to help understand decimal to binary (bits) equivalence.

Power of 2 has nothing to do with it.

I see. My understanding was this is a system used to store flags in a single integer as information that could be extracted from that number. Like if your number is 5, you'd know that with powers of two it could only be 4 + 1, thus it must contain bit 1 and 4 but not 2 or 8 or 16. My understanding may not be complete though.

Link to comment
Share on other sites

getButtons returns a specific part of the user input, but not the impulses.

class usercmd_t {
public:
	int			gameFrame;						// frame number
	int			gameTime;						// game time
	int			duplicateCount;					// duplication count for networking
	byte		buttons;						// buttons						<< that's what gets returned
	signed char	forwardmove;					// forward/backward movement
	signed char	rightmove;						// left/right movement
	signed char	upmove;							// up/down movement
	short		angles[3];						// view angles
	short		mx;								// mouse delta x
	short		my;								// mouse delta y
	signed char impulse;						// impulse command				<< that's what you are looking for
	byte		flags;							// additional flags
	int			sequence;						// just for debugging

public:
	void		ByteSwap();						// on big endian systems, byte swap the shorts and ints
	bool		operator==( const usercmd_t &rhs ) const;
};

The values it can hold are

const int BUTTON_ATTACK			= BIT(0);
const int BUTTON_RUN			= BIT(1);
const int BUTTON_ZOOM			= BIT(2);
const int BUTTON_SCORES			= BIT(3);
const int BUTTON_MLOOK			= BIT(4);
const int BUTTON_5				= BIT(5);
const int BUTTON_6				= BIT(6);
const int BUTTON_7				= BIT(7);

I've already stumbled upon this in the past as I've came with the same expectation as you did when discovering the function getButtons(). But it is indeed very restricted. Forwardmove/Rightmove/upmove is also accessible via getMove(), but that's it. Impulse are not accessible.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Yes that is right, those are the only buttons you can access, just like the original idtech 4. 

Yes is very limited but you need too realize that Doom3, was not made to be entirely changed/modded by script alone, you need to get your hands dirty into the c++ code (and IMO is not as hard as you may think).

TDM made it way more easy to script more stuff but still, many important functionality is done in c++ and in many cases, is not easy to make it changeable by script, not to talk that DoomScript is way slower than c++. 

So even thou I don't know if this is the case for MirceaKitsune work, anyone wanting to change how TDM works, in a more deep way, should really think creating a full mod, one that requires its own .dll like d3xp did for Doom3. This does mean coding in c++ and compiling the code. 

Saying that, it is not hard to make impulses available to the script engine, just like .getButtons, gets the value of usercmd.buttons, TDM engine team can just define a script function returning the value of usercmd.impulse.  Perhaps making a TDM feature request, in the bugtracker, will make the team more aware of this. 

Edited by HMart
Link to comment
Share on other sites

When I wrote I've stumbled upon it either I've meant five years ago or so, and stating its restrictiveness wasn't a complaint, just a determination.

 

On another note Mircea is requesting feedback on a very specific key. @MirceaKitsuneAs you want to know whether the use key is pressed or not, can I assume that you intent to utilize it for something else then its default usage and/or want to replace the current inventory (as otherwise you may get into conflict with the use response of the currently selected inventory item)?

  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

23 minutes ago, Obsttorte said:

When I wrote I've stumbled upon it either I've meant five years ago or so, and stating its restrictiveness wasn't a complaint, just a determination.

 

On another note Mircea is requesting feedback on a very specific key. @MirceaKitsuneAs you want to know whether the use key is pressed or not, can I assume that you intent to utilize it for something else then its default usage and/or want to replace the current inventory (as otherwise you may get into conflict with the use response of the currently selected inventory item)?

In my case I plan to use it for a plugin I'm making. Not disclosing too much about it at the moment... only thing I decided to say is I'm planning to include a skill system that lets you upgrade the player to enhance abilities, by which I mean the few abilities I can use the script system to modify. I need a way to let the player issue a command for upgrading various skills, and I'm not fond of making a full GUI for it just yet nor adding new keybinds which would have to be placed in the main menu as well.

Link to comment
Share on other sites

12 hours ago, MirceaKitsune said:

and I'm not fond of making a full GUI for it just yet

How do you plan to do it in the future, as using a gui for such a thing appears to be the natural decision?

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

4 hours ago, Obsttorte said:

How do you plan to do it in the future, as using a gui for such a thing appears to be the natural decision?

Maybe I will use one? I was ultimately planning to have the player inject himself with different arrows to randomly enhance a skill in that arrow's category... the selected weapon would be checked when the use key was pressed, given no item is also selected and nothing in-world is being frobbed. This idea kind of sucks though. Still leaning toward using loot as skill points instead.

But even if I use a GUI I need a button to open it up! And like I said a custom key bind won't work as I also have to give it a default value and add it to the main menu which would require hacking into the existing code. At the moment I remain kind of stuck here for this reason... suggestions would be much appreciated.

Also stuck on figuring out how on Earth to implement most skills, due to the scripting system only letting me influence the player in a handful of ways. I figured out how to do the basic ones thank goodness, but sadly there's going to be very few components since I can't change stuff like the firing rate or accuracy of the bow for every arrow.

Link to comment
Share on other sites

In the case were the player has no inventory item selected he has one selected, just none with a visible symbol and with no effect when "used". Can't remember the name of the entity def right now but its behaviour could be changed so it performs the desired action instead, so perfectly doable.

 

In regards to the GUI I would suggest to alter the inventory grid gui, so that it opens up a menu with several ingame menus instead as usual in other games. So the player presses the key for the inventory grid/map/objectives and a menu opens that allows him to choose between checking his inventory, taking a look at the map, check objectives or to spend skill points. This way you wouldn't need a specific key for the "skill tree page" but instead the player could use the menu of said gui to get there. Maybe even the best idea in that case to stick to only one key or replace one of the existing ones if you don't need them (for example if you merge objectives and map screen) if you don't want such a menu. Altering the main menu gui wouldn't be much of an issue as you only need to rename one of the strings there. So you wouldn't even have to touch the associated gui files.

 

In regards to the skills that affect weapon behaviour (firing rate, precision et al.): those are mostly handleable via the weapons scriptobjects. Making those attributes changeable shouldn't be much of a deal in most cases. If there are more skills you think of and don't know how to implement I would need to know more to tell you whether (and probably how) to implement those.

 

In regards to modding TDM via dll's. I don't know much about those specific aspects of programming to exactly tell you on how easely it is to create custom dll's to alter the behaviour of the source code or to add features to TDM without having to rely on or wait for future updates. It sounds like a promising approach. @HMart or any of the other more skilled coders might be able to tell you more on this matter.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Oh hell, sorry but forget about the dll, I was assuming TDM engine compilation was similar to original idtech4, but is not, for Doom3 the engine code was compiled into the .exe and the game code into a gamex86.dll, this separated the game, from the engine core and made it very easy to make your won mod and was how TDM was originally made, but on the conversion to standalone, it looks like the TDM team changed how the engine and game is compiled, now everything is compiled into the .exe, game code and all, there's no separate .dll anymore.

This means, anyone modding TDM game source code, will need to essentially compile the entire engine and release their own custom executable, instead of just using the original one that comes with the game.:(  

  • Sad 1
Link to comment
Share on other sites

I didn't think of forking the inventory menu to add my functionality, but now that I think twice I might just do that. Especially since one of my other dreams was adding a DeusEx type grid inventory thingie... prolly too complex for me but it would resonate with making my own copy. Thanks, will keep in mind and consider that option.

5 hours ago, HMart said:

This means, anyone modding TDM game source code, will need to essentially compile the entire engine and release their own custom executable, instead of just using the original one that comes with the game.:(  

I'm afraid so, would have been surprised if it worked any other way. That's why the engine can ideally leave as much as possible up to the scripting system, though of course basic functionalities must remain hard coded. I wish weapons were removed from the engine for instance, and reimplemented entirely as inventory items... this would also get rid of that pesky 16 weapons limit, or having to define them as properties of the player in the first place (except for the 1st person view models).

Link to comment
Share on other sites

I comprehend the desire to make everything with the script engine, I was in that position before but this was before I realized how slow DoomScript is, compared to C/C++, how hard it is to debug compared to C/C++ (there's only print debug available), even thou the later languages are "harder" than DoomScript just the fact that you have a debugger, imo make them way easier to work with. And as you are now realizing, how limited DoomScript is and was, for many things, so IMO it would be pretty much impossible (and imo crazy) for the TDM team, to decided to do almost the entire game using the script language, believe me, it would pretty much make the game unplayable for many people, specially for those that have a relatively slow PC but enough to play the game how it is code now.

Btw I'm not against TDM team making more deep access available for script, is for them to decided if is worth the trouble. 

Edited by HMart
Link to comment
Share on other sites

I'm stuck on a little math problem in my script: I need a way to detect which AI the player is looking at within a certain distance. By looking at I mean which AI is touched by the virtual crosshair at the center of the screen.

Unfortunately I'm not seeing a function to translate a 2D position to the 3D environment and see which point on the screen is over an object in the world. Let me know if there is any way and I missed it! But if there isn't then my only option appears to be sys.tracePoint(). As the trace must be done EACH FRAME I worry about potential performance implications, though hopefully filtering by CONTENTS_BODY means only AI bounding boxes are scanned so it's relatively cheap.

The part I'm stuck on is calculating the end point of my trace; The start is obviously player.getEyePos() which HOPEFULLY translates to the center of the screen in the 2D view. Unfortunately the function doesn't let me use an angle vector and wants another point to trace toward; This means I need to get the virtual point at the center of the player's screen but away a certain distance, in my case 1000 units away from their face. Using getViewAngles() and andToForward() should provide what is needed, the question is how exactly I would use them:. What math must they be piped through to accomplish this please?

Here's the unfinished function I'm currently using. Under a test against origin '0 0 0' the trace is confirmed to be working just fine, a sys.println(traced.getKey("name")) shows the correct entity in the console. The endpoint is my only problem.

player ent = $player1;
vector ang = ent.getViewAngles();
vector ang_fwd = sys.angToForward(ang);
vector pos_start = ent.getEyePos();
vector pos_end = '0 0 0';
sys.tracePoint(pos_start, pos_end, CONTENTS_BODY, ent);
entity traced = sys.getTraceEntity();

 

Link to comment
Share on other sites

angToForward should already give you the desired vector, only normed (so of length one). So pos_end should be calculated like this:

pos_end = pos_start + 1000.0*ang_fwd;

 

  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

6 hours ago, Obsttorte said:

angToForward should already give you the desired vector, only normed (so of length one). So pos_end should be calculated like this:


pos_end = pos_start + 1000.0*ang_fwd;

 

Cheers, will give it a try! I thought that might be the case after posting this but those more complicated maths are always a problem for me to understand :D

Once more I assume tracing is the only solution I have for my use case? There isn't any function to tell if a position on the 2D screen touches a 3D model from the player's POV? It should work perfectly of course... I'm mainly concerned for performance, though tracing each frame doesn't seem to noticeable reduce it in the slightest for me.

Link to comment
Share on other sites

13 minutes ago, Dragofer said:

Can just do the trace every 0.1 or even 0.2s, rather than every single frame.

I guess. I don't need so much responsiveness for everything... this is for a HUD component so the effects will be instant. Some things do need to respond each frame though, and since each thread can only contain one while(1) loop I'd need to thread multiple checks independently. Or I can use a timer check which is easier, but it becomes messy to keep track of what needs to be updated instantly and what can be delayed.

Since I'm using CONTENTS_BODY as the mask I assume the trace automatically excludes all entities except for AI, thus there shouldn't be a lot of bounding boxes to calculate. For starters I'm going to see if there actually is a performance drop, and once this system is out testing would be appreciated. You can follow the progress of the addon I'm working on here:

 

Link to comment
Share on other sites

Note that "A New Job" iirc uses a modification of my "player looks at something script" that does more or less what you seem to be aiming for. In regards to traces I wouldn't bother too much as long as you only perform one trace per frame. The game also needs to check whether something frobable is in front of the player and it doesn't cause much issues either.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Regarding the sound file, I'd like to know that too. It is possible to create a video that either precedes or takes the place of the text briefing. While I suppose the visuals in such a vid could be just a static shot of the text, the user interaction would be different and so probably just confusing. And, for me at least, creating a video is a heavier lift than an audio file.

There is a hook in a gui file to add your own audio file during the mission end screen, but I'm not aware of one for the briefing screen.

You could probably override the audio file used for the briefing screen (suggestive of deep wind chimes) with your own with the same name. But that track is used not just for the briefing, but also for the objectives, the shop, etc...  So overriding it probably won't give you what you want.

Link to comment
Share on other sites

An important question for the mod I'm working on, as I need to ensure it works with campaigns especially since I plan to make some myself: In a script, how do you make a value persist between campaign levels? So if a float was set to given value during the previous map, how do I make it get the same value once the next map has started? There's already inter-level persistence for a few things so it's doable, I just don't know how to do it for custom script variables.

Link to comment
Share on other sites

How do I read the current light gem level of the player in a script, to know how visible and exposed to light the player is at that moment? getLightLevel() seems to be a property of light entities rather than players / AI... a search through the default scripts doesn't help much either.

Link to comment
Share on other sites

Here's a weird one.
I can make a brush into a standard mover door and it works. But if I try to make a brush into a funcstatic door that translates, it shoots off (literally at high speeds) towards +x+y and sometimes also +z. 
I'm baffled. I followed the tutorials on Wiki just in case I'm missing something, but it's so simple, it appears I'm not.
Has anyone else ever seen this?

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...