Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Polpolion on October 15, 2008, 12:43:31 pm

Title: Starting off Coding FS2...
Post by: Polpolion on October 15, 2008, 12:43:31 pm
...and I need some help (big suprise).

I've gotten a bit tired of not doing anything during programing class. None of the assignments have ever taken me more than about 15 minutes to do, and I get new assignments at most once a week, so I've decided that I'd actually do something useful on my own. I've taken a semester of true BASIC (not actual programming), a semester of c/c++ (oh wow, I know the syntax and understand the extreme basics of the language), and I'm currently taking a year-long AP Java course (I've taught myself more Java in about a half a day back in august than what's been taught in the class so far).

I don't need help learning more of the language itself, I'll be taking care of that myself if I have any issues (after all, I'll have an hour a day where I wouldn't be able to do anything else other than randomly browsing the intraweb). What I would like help with in general, is actually learning my way around the FSO code. Is there any good way to become fluent in the way everything works? Is there any types of things I could try and code that would help me better learn how the game functions? My overall goal is to eventually be able to actually help code for the SCP, but that's not possible yet.

I downloaded the code itself for 3.6.9 a while ago, and that's just what I'll be using until I know that I could do more than just tinker and fool around.

Also, I need a real IDE. For some reason, I don't think Dev-C++ will quite cut it, and last time I checked, I couldn't access the ones in the stickied threads. Any suggestions?

And once I figure that out, what I think that I'll be doing first is trying to add in an optional effect for beam weapons to have exponential damage. Depending on how long the beam is held on its target, the amount of damage the beam does would keep increasing.

So where exactly is the weapons.tbl parased in the code, and where is the damage calculations done? At first I assumed in the weapons and math sub folders respectivly, but I still can't quite find anything.

 :)

I really appreciate any help.
Title: Re: Starting off Coding FS2...
Post by: Flipside on October 15, 2008, 01:02:17 pm
I have the same problem with languages, they seem to want me to do everything in Java which is annoying as hell.

I agree with them that once you know one language, it's possible to learn them all, but possible doesn't get the job done.
Title: Re: Starting off Coding FS2...
Post by: Wanderer on October 15, 2008, 01:10:22 pm
If you are using windozer then you can probably get the MS Visual Studio Express Edition.

http://www.hard-light.net/forums/index.php/topic,52845.0.html
http://www.microsoft.com/express/download/

As for table parsing (where the functions are located)... see for example this.. the box on the right side of the screen..
http://www.hard-light.net/wiki/index.php/Tables

Damage calculations... well... shiphit.cpp would probably be the best bet to find them. However - for example - if you search for the references in to code to for example weapon_info struct's damage variable you can see where it is used.

Title: Re: Starting off Coding FS2...
Post by: chief1983 on October 15, 2008, 05:04:10 pm
You should check to see if you have access to the MSDN Academic Alliance program through your school as well, they may be able to get you a legit copy of VS2008 Pro for cheap, or free.  I would suggest getting the up to date code base and tinkering with that, just doing an SVN checkout isn't going to affect anything and you'll have up to date project files and bugfixes to boot.  You can easily use TortoiseSVN to get the SCP code (http://www.hard-light.net/forums/index.php/topic,52845.0.html).  Then it's just a matter of rightclick->update to get the latest code.

Code::Blocks might be another IDE to look at eventually but we don't currently have a project file specifically for it.

I think VSExpress comes with the debugger.  If so you can compile your own builds, and analyze any crashes that happen in realtime.  I've figured more stuff out looking at what's led up to a crash than I have most any other way.  It's still a bit daunting to me though.
Title: Re: Starting off Coding FS2...
Post by: Polpolion on October 18, 2008, 08:29:43 pm
Well, I've gotten MSVC++ 2008 up and running with 3.6.9 right now. I've been looking through the code for this and it looks like what I'll have to do is add in an optional table entry for damage exponent, a weapons_info value for it, and factor it into the damage attenuation (Somehow). Hopefully I won't run into too many complications...
Title: Re: Starting off Coding FS2...
Post by: Wanderer on October 19, 2008, 03:53:14 am
Umh... http://www.hard-light.net/wiki/index.php/Armor.tbl
Title: Re: Starting off Coding FS2...
Post by: Polpolion on October 19, 2008, 04:57:36 pm
Well, I'm doing this more to try and learn my way around the code, not purely just to have it done. On top of that, I don't quite think it's what I had in mind.

And it seems like theres a million billion different kind of weapon info structs scattered throughout the code. Really confusing.
Title: Re: Starting off Coding FS2...
Post by: Polpolion on October 24, 2008, 01:06:43 pm
I'm almost done. All I need to do is figure out where you plug in data into the beam struct. Anyone know where?
Title: Re: Starting off Coding FS2...
Post by: Wanderer on October 24, 2008, 01:17:16 pm
Well.. there is actually just one single weapon info structure that is just referenced all throughout the code... As for where is data is plugged to beam struct... You could try first finding the said struct (or actually the variable within the struct you want to fill) then right-clicking it and selecting 'Find All References' (using MSVC++ 2008).
Title: Re: Starting off Coding FS2...
Post by: Polpolion on October 27, 2008, 12:48:24 pm
Okay, I think I've got it done. Now how to I go about compiling this, or even just having it check for errors?
Title: Re: Starting off Coding FS2...
Post by: Wanderer on October 27, 2008, 01:06:34 pm
First select the solution configuration (probably debug for starters). Then go to menu item 'Build' and select 'Build Solution'.
Title: Re: Starting off Coding FS2...
Post by: Polpolion on November 24, 2008, 01:05:31 pm
What does Assert(); do?
Title: Re: Starting off Coding FS2...
Post by: phreak on November 24, 2008, 01:41:57 pm
I'll test the indicated expression and cause an assertion failure if the expression evaluates to 'false'.  They are only triggered in debug builds.
Title: Re: Starting off Coding FS2...
Post by: Jeff Vader on November 24, 2008, 01:50:06 pm
I'll test the indicated expression and cause an assertion failure if the expression evaluates to 'false'.
:lol: Sounds funny when it's missing a "t".

Sorry. I'll be quiet now.
Title: Re: Starting off Coding FS2...
Post by: karajorma on November 24, 2008, 03:43:33 pm
What does Assert(); do?

Basically it's a method of catching coding errors. If I'm writing a new function which uses a variable called x and I'm sure that x is never going to be zero (and it would screw things up if x was 0) I'll Assert (x != 0). Now if the debug build is running and x is zero at that point in the code then the debug build will basically go "Aha! You were wrong! x can be zero!"

This gives the coder the chance to fix their mistake. Int3() works in a similar way. Except Int3() is placed in a part of the code that should never be reached while Assert is a statement that should never be true.