Jump to content
The Dark Mod Forums

Help understanding codebase


jaredmitchell

Recommended Posts

Hey guys! Sorry if this isn't in the appropriate place, but I don't see a coding-specific forum here (is it hidden?).

 

So after my not terribly great first FM, I was interested in making a level centered around a couple of new systems the player could use, so that I could get more level design experience, as well as some experience working in a game engine with C++.

 

My idea was to make a new type of arrow, so I started looking around TDM's codebase to find an "arrow" class or something similar that I could extend off of. Looking around the project, though, I started to realize that this class definition might not exist, or that arrows are implemented in some way I didn't anticipate.

 

Would someone be able to point me in the right direction, please? Thank you very much!

Edited by jaredmitchell
Link to comment
Share on other sites

I am not sure what you want to achieve, but for new weapons you do not need any new code in most cases. You can find all the weapons definitions in the file tdm_defs01.pk4 in the subfolder "def" with the names tdm_weapon_*.def (or if you have already unpacked the pk4 file(s) in the def-folder in TDM). There you can find all the arrows, as well as the sword and the blackjack.

Link to comment
Share on other sites

Coders typically post to the "I want to help" section:

 

http://forums.thedarkmod.com/forum/11-i-want-to-help/

 

however, that is usually after some familiarization with our code standards.

 

To begin, have you reviewed the materials in our Wiki:

 

http://wiki.thedarkmod.com/index.php?title=Coding

 

http://www.thedarkmod.com/downloads/

 

Scripting:

 

http://wiki.thedarkmod.com/index.php?title=Scripting_basics

 

along with the Doom 3 \ Id Tech 4 resources:

 

http://fabiensanglard.net/doom3/

 

https://modwiki.xnet.fi/Doom_3

 

?

 

As an aside, I had our 2.03 SVN cloned to Git awhile back (SVN2Git doesn't auto-update anymore) but it may be easier to search

the codebase online using Git search rather than downloading the SVN files and searching\grepping them locally.

 

https://github.com/svn2github/TheDarkMod_SVN_Unofficial

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

As said by Destined, weapons are defined and customized via entity definition. Furthermore there are some scripts to get them to work as desired. If you check the entity definitions, you can see which scripts are used (scriptobject) as well as the class in the code handling the basic behaviour (spawnclass).

 

As pointed out, most changes do not require fiddling with the source code. Also changing the code specifically for a FM might be a bit over the top, as players would have to replace their binaries with your to play your fm, and would have to undo the changes if the would like to play an "ordinary" FM after that.

 

But if you really want to start working with the source code, I suggest you take a look at the bugtracker.

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

I guess I should've been more transparent about what I'm trying to do here in the initial post: I'm interested in creating a "tether arrow", i.e. a rope arrow whose rope doesn't necessarily need to be vertical. To make this work, I think I'd need another entity (an "anchor point") for the player to tie the end of the rope onto, both for it to make sense in the world as well as to restrict the player from using it anywhere. Does this seem like it could be accomplished via scripting and .def files?

 

 

I am not sure what you want to achieve, but for new weapons you do not need any new code in most cases. You can find all the weapons definitions in the file tdm_defs01.pk4 in the subfolder "def" with the names tdm_weapon_*.def (or if you have already unpacked the pk4 file(s) in the def-folder in TDM). There you can find all the arrows, as well as the sword and the blackjack.

 

Ah, I was not aware that the .def files contained some logic (as I haven't worked with them before). I'll try to familiarize myself with them- even if I ended up in C++, I'm guessing I'd need to write a .def file to get the arrow into the editor.

 

Coders typically post to the "I want to help" section:

 

http://forums.thedarkmod.com/forum/11-i-want-to-help/

 

Thought that might be the case. I'll keep that in mind in the future.

 

To begin, have you reviewed the materials in our Wiki:

 

Somewhat. I'm familiar with scripting for missions, and looked at some of the articles for coding when I first tried to figure out where to start. The general coding articles seemed like basic knowledge I had already encountered elsewhere ("Coding in the SDK", re: performance and debugging), and the other articles seemed too specific to help me get acclimated ("Adding new Cvars", "Adding Script Events to sys").

 

I didn't look at Doom 3-specific articles, either, because I figured that hypothetical "arrow" class I was looking for would be unique to TDM.

 

As pointed out, most changes do not require fiddling with the source code. Also changing the code specifically for a FM might be a bit over the top, as players would have to replace their binaries with your to play your fm, and would have to undo the changes if the would like to play an "ordinary" FM after that.

 

Ah, I see. The logistics of that make it seem like more trouble than it's worth. :/

Link to comment
Share on other sites

If you have a feature idea that's compatible with our intended playstyle, feel free to offer an example implementation and let the community discuss it's inclusion.

Particularly, if the feature is optional then like-minded mission authors can offer it too without causing problems for the core.

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 bet you could pull that off with a clever script, along with some new objects & animations. The way I think about it, you'd create a new horizontal rope object with an unreeling animation during its deployment that stays put as an object if the arrow successfully hits (else, it falls & is deleted). And then it has a collision surface that allows the player to walk on it.

 

It'd be a good amount of work. There's a reason why you don't see it. The physical simulation involved is more complex than a vertical rope arrow. But it's not impossible either. It might be tricky to get it to look good, but getting it functional shouldn't take too much. At least, it's in the ball park of do-able by a committed fan, as opposed to something like multiplayer or a physics rehaul, which are massive challenges.

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

Ah, I was not aware that the .def files contained some logic (as I haven't worked with them before). I'll try to familiarize myself with them- even if I ended up in C++, I'm guessing I'd need to write a .def file to get the arrow into the editor.

The def files are not too difficult to understand (I myself have no C/C++ experience and still can work with them). Think of them as a collection of spawnargs that you would see in DR. One of the things that first took a while for me was to find the files where the inherited spawnargs are found, so you can actually see every spawnarg that the object has. SteveL gave me a python script that searches all pk4 files (without extracting them) that helped very much, whenever I was looking for a spawnarg. You can find the script in these two threads:

http://forums.thedarkmod.com/topic/17852-pk4-directory-search/

http://forums.thedarkmod.com/topic/17676-ai-stats-wiki-page/

I think for your project you should take a look at the rope arrow as this is the most similar arrow type to the one you want.

Link to comment
Share on other sites

I thought about such an arrow before (played the Batman games ;) ) and it is doable via scripting me thinks, although I never tried to implement it.

 

Having an animated rope for it to look good as suggested by demagogue is a way to get a good looking result, but for that purpose you would need to create the specific animation in a modeling program (which would be beyond my capabilities, but you might be able to do it, or you could ask someone else for help here). But it might be possible to get it to work without that.

 

The implementation depends on how exactly you want the arrow to work. Assuming you are aiming for an Batman like approach the behaviour would be like this:

  • with the arrow equipped, the game would inform the player whether the arrow would yield the desired result at the point the player is currently aiming at
  • if the arow gets shot, once it hits the wall or whatever, a rope or similar gets shot backwards and hits the wall there, creating a connection for the player to use

From this approach on, an implementation needs to have the following features:

  • when the player cocks the bow, an invisible projectile is shot at the point the arrow would hit; from there, a projectile is shot backwards; now you have to points where the projectiles hit, and the script can check whether the distant is small enough for the arrow to deploy; if so, an gui overlay at the first impact point is created to inform the player that he can use the arrow there, otherwise the same gui would inform the player that the distance is too high (the gui is optional, but might be worthwhile as this is a feature unknown to the players)
  • in case the distance is fine if the arrow is shot at the opposing wall, you have either an animated rope as mentioned above or some other setup that creates the backwards shooting rope
  • the rope connecting the two opposing walls need a ladder texture in addition to its visual textures (ladder textures are invisible but needed so the player can climb something)

Note that this sort of code will require quiet some math to get it to work properly. Also note that the implementation must account for different distances between the walls the rope is deployed. Code changes are unneccessary.

 

My advice is to try to create a basic setup as a proof of concept to see whether the implementation works. Once you've done this you can work on the other parts to get it to look right.

 

If this is something you want to add to your own FM, than you don't have to discuss this with the team. You can do whatever you want in your own FM's. If you want this to get added to the core mod, you will have to discuss this with the team. In the latter case, you should provide a detailed description on how the new arrow should work.

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

I thought about such an arrow before (played the Batman games ;) ) and it is doable via scripting me thinks, although I never tried to implement it.

 

Having an animated rope for it to look good as suggested by demagogue is a way to get a good looking result, but for that purpose you would need to create the specific animation in a modeling program (which would be beyond my capabilities, but you might be able to do it, or you could ask someone else for help here). But it might be possible to get it to work without that.

 

The implementation depends on how exactly you want the arrow to work. Assuming you are aiming for an Batman like approach the behaviour would be like this:

  • with the arrow equipped, the game would inform the player whether the arrow would yield the desired result at the point the player is currently aiming at
  • if the arow gets shot, once it hits the wall or whatever, a rope or similar gets shot backwards and hits the wall there, creating a connection for the player to use

From this approach on, an implementation needs to have the following features:

  • when the player cocks the bow, an invisible projectile is shot at the point the arrow would hit; from there, a projectile is shot backwards; now you have to points where the projectiles hit, and the script can check whether the distant is small enough for the arrow to deploy; if so, an gui overlay at the first impact point is created to inform the player that he can use the arrow there, otherwise the same gui would inform the player that the distance is too high (the gui is optional, but might be worthwhile as this is a feature unknown to the players)
  • in case the distance is fine if the arrow is shot at the opposing wall, you have either an animated rope as mentioned above or some other setup that creates the backwards shooting rope
  • the rope connecting the two opposing walls need a ladder texture in addition to its visual textures (ladder textures are invisible but needed so the player can climb something)

Note that this sort of code will require quiet some math to get it to work properly. Also note that the implementation must account for different distances between the walls the rope is deployed. Code changes are unneccessary.

 

My advice is to try to create a basic setup as a proof of concept to see whether the implementation works. Once you've done this you can work on the other parts to get it to look right.

 

If this is something you want to add to your own FM, than you don't have to discuss this with the team. You can do whatever you want in your own FM's. If you want this to get added to the core mod, you will have to discuss this with the team. In the latter case, you should provide a detailed description on how the new arrow should work.

 

Hope i'm comprehend this well, being English not my main language.

 

Obs that looks like a setup that would work, but i would change some stuff, instead of using two invisible projectiles (looks to me like a more complicated setup) i would use a ray trace, using the trace script function, from the point of view of the player , in that way you can already put the max distance limitation into the trace path itself, then if the distance is right, detect the surface/point/object the ray collided with, create a rope ragdool some units in front of the player, where one side would travel to the point off collision and attach to the surface (or world) there, needs test to see if the physics system is stable enough for that, the other point of the rope would attach to a point some distance in front of the player view (like he was securing the rope with his hands), you could move the point around and so put it inside some other surface, then, or you automatically detect the surface where the player is trying to attach the other end of the rope (with a trace from the rope point to the surface) and if is a real surface and not the "air", remove the attachment from the player "hands" and transfer it to the surface, or you could hope the player to not try to attach the rope to the air and so just make it so if the player clicks a certain key that attaches the point to the "world", preferably inside some surface.

 

Btw i recommend reading the Doom 3 "map_alphalabs3_crane.script" is the script of the game, crane minigame, it explains very well how to use trace and how to attach and detach objects from traces.

Link to comment
Share on other sites

Hey, so a bit of an update on this!

 

I just started to play around with getting a new entity in a test level so that I can start figuring this out. I wrote an entity def file, "tdm_weapon_tetherarrow.def", which shows up in editor and appeared in my map prior to me writing a new script for it.

 

However, when I made a new script and tried to get my in-level tether arrow to connect to it via spawnargs, I started getting an error saying that the scriptobject couldn't be found, and the map wouldn't launch. I have a feeling this is related to the location of my "tdm_ammo_tetherarrow_small.script".

 

So, where's the appropriate location to put the weapon script file? Does it need to be within a .pk4 like the others?

 

Just in case, here's the entity with its spawnargs:

tetherarrowineditor.png?ssl=1&w=800

 

And here's the error I get when trying to run the map:

 

tetherarrowerror.png?ssl=1&w=800

 

Thank you!

Edited by jaredmitchell
Link to comment
Share on other sites

The script file belongs in <myfilename>/script/.

 

You also have to create a new file called <myfilename>/script/tdm_custom_scripts.script and put this line in it:

 

#include "script/tdm_ammo_tetherarrow_small.script"
Otherwise, TDM won't see the scriptobject for the new arrow.
Link to comment
Share on other sites

That should have been <mymissionname>, not <myfilename>.

 

How have you set up your project files?

 

I'm assuming they look like this:

 

<mymissionname>/maps

<mymissionname>/script

<mymissionname>/xdata

<mymissionname>/def

<mymissionname>/models

In the final pk4, your folders should look like this:

 

maps

script

xdata

def

models

 

and whatever else. These are the folders where you put your files.

Link to comment
Share on other sites

Sorry to prolong this now, but now I have an issue where the tether arrow won't be added to the player's inventory (on frobbing it, a message is generated in the console saying it "couldn't be added"). As far as I know, my entityDef and weapon script are basically the same as from when I copied them from the rope arrow files, with changes only made to the class names and text for the inventory.

 

Anyone know what's happening? Here's the .def file just in case:

 

 

As well as the .script:

 

EDIT: Removed the code snippets, since they were really long and ended up not being relevant

 

Thanks again!

Edited by jaredmitchell
Link to comment
Share on other sites

I think you have the problem here, that there are only 10 weapon slots available, which are already specified. This means, you will have to remove one weapon type and put your tether arrow in its stead. With a quick forum search I found this thread about adding weapons. Maybe it will help you (did not read all of it) or at least point you in the right direction.

Link to comment
Share on other sites

Ah ha! That got me pointed in the right direction. Thank you.

 

According to a post on the iddev site, the weapon slots were defined in the player.def file. Making a copy of it in my mission files and changing the rope arrow slot to the tether arrow slot now allows me to pick it up. Hopefully now I can try and figure out the logic of this arrow without bothering you guys too much. :P

  • Like 2
Link to comment
Share on other sites

Okay, sorry, more help plz:

 

I wanted to add a bool to the player script object (defined in tdm_player.script) to toggle when they come into/out of the range of a place where they can tie off their tether (defined by the entity tie_off which I've defined). I created a copy of this script and put it in the appropriate place with my mission files, included it in my tdm_custom_scripts file, and made the appropriate changes (adding the bool, as well as getter and setter functions).

 

Previously, I used a modified player_thief entityDef to get the player to be able to pick up my new tether arrow entity. However, it doesn't seem to be reading my version of the player script, with the map file crashing when I try to access my specific functions. I then changed the object name to "player_tether" and told the entityDef to use this as its script object. Now when I try to run my map it gives me this error, which seems to confirm that it can't/won't load my version of the player script object:

 

playerobjecterror.png?ssl=1&w=800

 

Does anyone know how to get around this? Thank you very much (again)!

Link to comment
Share on other sites

https://www.youtube.com/watch?v=JmWFMBY2oS0&list=PLrQt-qjh-krYU2kpnJJRHUO8P4xPG5I9X&index=5

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

Thank you, Obsttorte, but this doesn't address my question. I'm trying to add logic to the player entity by changing things in the tdm_player.script. The way my files are set up now, though, the game is not reading my version of the script object. How do I remedy this?

 

Are you just editing the player script? Or are you also making custom scripts? If you are making custom ones, have you added them to the main scrip? The main script runs first, You also need to be careful that any custom script needs to be included in the main script in the right order, any script that requires another script needs those to run first, for example the player script needs to be included after the ai_base script, because it inherits from ai_base, in the main script file that means top to bottom.

 

I also know that very rarely Doom script (TDM script) has problems with "if else" logic, sometimes you need to break a "if else" statement in more parts for it to work, it's rare but happened to me.

Link to comment
Share on other sites

 

Are you just editing the player script? Or are you also making custom scripts? If you are making custom ones, have you added them to the main scrip?

 

I made a copy of the player script to edit its logic and put it in the script folder of my mission files. It's included in the tdm_custom_scripts.script file that I used, which has been working with the other script objects that I've written.

 

 

You also need to be careful that any custom script needs to be included in the main script in the right order, any script that requires another script needs those to run first, for example the player script needs to be included after the ai_base script, because it inherits from ai_base, in the main script file that means top to bottom.

 

That was a good suggestion. I tried it, but alas, that did not solve my problem.

 

My problem is that I similarly made a copy of the player entityDef file, and told it to use my custom player script object. However, when the map loads, it doesn't seem to recognize my script, and just prints an error to the console.

Link to comment
Share on other sites

You could consider to make a backup of the files you change and leave them in their original folders. After you are done, you can simply rename the new fiels and restore the backups. This way there shoud be no way, that your changes get ignored.

 

Another thing I just remembered: How is your Dark Radiant set up under "File->Select Game..."? The setup is a bit confusing, and if it is done wrong, the files in your FM folder do not take precedence over the original files. This happens on a regular basis... Unfortunately, I am not sure myself, how the correct configuration has to look, so here someone else has to chime in, I fear. I am sure I saw this discussion just recently, but jsut can't remember where :-/

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  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • 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
×
×
  • Create New...