PDA

View Full Version : Coding-Tutorials


way
11-11-2003, 08:05 PM
Hi,
sry, if I'm the second or third who asks this Question,
but I want to know, if you know any Coding-Tutorials for JKA or JK-2 (I think it's almost equally)?

I do not know anything about Coding, and just want to ask what for things with coding goes?
like can I add new weapons?

thx for answers:)

razorace
11-11-2003, 10:33 PM
There's a minor tutorial included with the JK2 SDK, but it's not very good. You'll have to basically learn everything yourself and ask specific questions in the JKO coding forum.

Wudan
11-12-2003, 01:24 PM
Well, we've seen enough folk interested in coding come around to know a thing or two about your question.

Are you serious about coding? It's just C, except without pretty much any of the standard library available. Read a few C tutorials, bone up on the syntax and structure, and go from there.

The hardest part, I'd say, for a beginner, is to get started coding. We don't know precisely what JA's setup will be, but it seems you'll need to be able to compile DLLs (which you can do in Windows, Mac, or Linux), as qvms don't seem to play a part in JA (for shame ... or joy?)

If there isn't any wacky-ness (and I don't think there will be), you can compile in Dev-C++, which uses MingW to compile.

It's free, so I'll write a tutorial for setting it up, as I think you'll need free tools in your conquest. A few people put up money to purchase big software packages to make software, and models, but I'd say free is my favorite f-word.

Tchouky
11-12-2003, 06:42 PM
you should consider reading these tutorials:

www.planetquake.com/code3arena

they're not designed for jk2 or jka but for quake 3.
but since jka and jk2 are based upon quake 3 's code they can still be followed.


good luck.

way
11-12-2003, 07:08 PM
Thank you for the answers:)

@Tchouky: I will read it, thx

@Wudan: Can you give me a URL, please? I would be thankfull, if you would write a Tutorial

@Razorace: I knew it would be difficult, but everything on my own?
I will try, but can't do more than that.

I think first I'm gonna buy a book about C (just C, not C++ ?) and learn the basic-things.

PS: thanks again. Nice Users, nice forum:)

Wudan
11-12-2003, 08:36 PM
Perhaps the best place to start is with a tutorial I didn't find until later, but it's free, concise, and ... free!

http://cslibrary.stanford.edu/101/

The CS library at Stanford is free and open to the public - and it's good! This is the essential C one, but they have quite a few more.

I'd recommend getting Dev-C++, as it's free also, and you can start coding right away! :D

Nith Sahor
11-14-2003, 03:03 AM
Here are some functions that you might find useful once you learn some C and when the SDK comes out (I'm gambling that the functions and the source file names will be unchanged, since JKA and JO are similar)

in g_active.c:
ClientThink_real() - this function is called every client frame (a frame is a unit of time - so basically you can do things to clients every x seconds or x minutes, like poison)

in g_client.c:
ClientSpawn() - this function is called when the client spawns for the first time on the level/map. You can use this to change the client's state (e.g. make them faster, give them more health, give them different weapons etc.) or do other things.

ClientUserinfoChanged() - this function is called every time the userinfo of a player/client changes. For instance, if the player changes their model or changes their force powers. You can use this to set the player's model to a particular model you might want (e.g. if you're making a class based mod).

in g_missile.c:
CreateMissile() - creates a "missile" object, basically an entity that is the missile entity type and has a linear trajectory (travels in a straight line until it hits something, or until it reaches the end of its life variable). This function is used in the firing functions of some of the weapons - so when somebody fires, a "missile" is created that travels forward (unless the programmer changes some of its options).

in g_combat.c:
G_Damage() - handles damage, so you can put code in here that allows you to handle damage from different weapons differently (like adding knockback, or doing some other complicated thing), using the "mod" (Means/Method of Death) integer and checking it against the different MOD_ enums of different weapons.

I admit that it's been a while since I've coded for JK2 and some of this info might not apply to JKA, but I think most of it's correct. You will most probably want to check out some of the stuff in the cgame and ui modules and the other functions in the game module.

Hope this helps,
Nith

Tchouky
11-18-2003, 01:09 AM
Originally posted by way

I think first I'm gonna buy a book about C (just C, not C++ ?) and learn the basic-things.


it might be a good thing to start with C.
It will be a little easier and since quake 3 and jk2 are coded in plain C it's not necessary to code in c++.


but i suspect jka will be coded in c++ though :)
the dll only thingy and no qvm might be a sign =)

edit :
Nith Sahor im 100% sure that what you said will remain true in jka .

RenegadeOfPhunk
11-18-2003, 09:23 AM
but i suspect jka will be coded in c++ though



Nith Sahor im 100% sure that what you said will remain true in jka


Arent these two statements a bit contradictory? If they have indeed moved to C++ for JKA (which I seriously doubt btw), they will undoubtedly have re-arranged a significant chunk of the code base.
(...if they didn't, there would be no benefit from moving from C - would there...?)

...and so the filenames will almost certainly change. THe function names may not change in some cases, but the way they work will undoubedly change.

one quick example:

ClientSpawn() -> g_client.c

might become something like

CClient::Spawn() -> g_client.cpp


...but anyway, highly unlikely the JKA source code will turn out to be C++ imo.

...but we'll see I guess...

Vile
11-19-2003, 11:47 AM
I am also intrested in modding JK:JA, I have a firm background in the C programming language so if it is in C I can read it just fine :), but what I want to know, where to I get what .cpp files to mod the game? or is it not in .c or some other format? Just would like to know on that information so I can start familarizing myself with the functions and how stuff is set up.

razorace
11-19-2003, 12:17 PM
The MP source for JKA isn't out yet.

Vile
11-19-2003, 12:24 PM
ok cool that is good to know :p, so basically no one can mod JA coe wise as of now? But we can still add new models? and skins?

Wudan
11-19-2003, 04:18 PM
Yes, new models, skins and maps. No code, just yet.

Tchouky
11-19-2003, 10:54 PM
Originally posted by RenegadeOfPhunk

one quick example:

ClientSpawn() -> g_client.c

might become something like

CClient::Spawn() -> g_client.cpp




if they turn to c++ it's obvious that it will change a bit, and i agree with your example, but such a change is nothing.

the function will still be there and have the same role so it doesn't really change anything (except a small bit of syntax..) .

RenegadeOfPhunk
11-19-2003, 11:10 PM
the function will still be there and have the same role so it doesn't really change anything (except a small bit of syntax..) .


If the only difference between C and C++ was syntax, then there wouldn't be that much difference between them.

C is a procedural language
C++ is an Object-Orientated langiage

there is a world of difference not only in the syntax, but in the whole structure of the code. C++ allows far more organised, flexible and maintainable code.

I assure you - if it has been moved from C to C++, the structure of the code - in many if not most places -will be significantly different - enough that you will have to look in a different place to find the function you were looking for. In fact, in many cases, you will find many big functions split into various segments and split up between different classes.

One huge example would be the saber system. If the saber system had a nice OOP design this time round ... :drool:

...but anyway -I think this is all theoretical anyway. I'll put a 95% probability on the JKA source code still being in C. (Heh -how stupid am I going to look if I'm wrong...!)

Emon
11-20-2003, 12:41 AM
It's probably more likely than 5%. Raven did EF in C++, and they switched to straight DLLs, so you never know.

Nith Sahor
11-20-2003, 12:46 AM
Well, Quake 3 and JK2 were coded in a very object-oriented sort of way so the differences should not be too big...

Emon
11-20-2003, 12:52 AM
Er, they were in C, so they couldn't be object oriented.

Nith Sahor
11-20-2003, 01:05 AM
I said in an object oriented way, not actually object oriented.... like the way the gentity_t type could be a missile, a client or a bot. Obviously things like inheritance and encapsulation are missing, but it has that sort of style.

Wudan
11-20-2003, 01:53 AM
In the much broader spectrum that the term 'object oriented' deserves, C is an object oriented language. If you say not, please explain what an 'object' is, and how 'C' is not oriented around the handling of them.

Emon
11-20-2003, 03:28 AM
Objects are instances of classes, which are groups of data and functions. But that's only a part of it. Object-oriented programming is about encapsulation, polymorphism and inheritence.

This page (http://www.desy.de/gna/html/cc/Tutorial/tutorial.html) can explain it better than I can.

Edit: Wudan, does that answer what you're asking? If I recall, you started programming not too long ago in C, and haven't done much C++, so I assumed you were being serious and all, so I don't mean to insult your intelligence if you weren't.

RenegadeOfPhunk
11-20-2003, 09:01 AM
OOP isn't a few specific keywords or collection of syntax - it's a design philosophy.

As such, any language can be approached in an object-orientated way. i.e. you CAN use OOP techniques when programming in C. And conversely, you can write in a procedural fashion in C++. (i.e. bad class structure design!)

The difference being that C++ gives you the specific syntax to handle OOP development in much more effecient and effective manner.

The whole point of OOP is that the resulting code is easier to work with. Because C doesn't have the OOP specific syntax, you would end up having to specifically code in the OOP structure yourself, making the code more complex and therefore defeating the point of using OOP in the first place.



Well, Quake 3 and JK2 were coded in a very object-oriented sort of way so the differences should not be too big...


QIII and JK2 were written SOMEWHAT in an object-orientated way - in certain areas. It's not COMPLETELY object orientated -and will never be if it's written in C...


It's probably more likely than 5%. Raven did EF in C++, and they switched to straight DLLs, so you never know.


...really? wasn't aware of that. OK, I guess there's more of a chance than I think then.
...if the JKA code IS indeed in C++, I'm gonna be a happy man - modding the code will become a far quicker and easier task...

Although I have a sneaking suspision that they possibly may have rushed the C -> C++ conversion process (just judging by all the other stuff they had to do in the same time as well...), which would mean the class structure may not be as good as it could be. But we'll see...

Emon
11-20-2003, 08:08 PM
OOP's also for reliability, too.

RenegadeOfPhunk
11-20-2003, 08:35 PM
True. Modularity is also a plus.

...there are a whole load of advantages to using an OOP approach. The bottom line is, since I've gotten to grips with OOP design, I would never willingly take on a large software project without doing it OOP all the way -including using a proper OOP language like C++...

alexx860
11-25-2003, 05:23 PM
where can i found the JA SDK ??

way
11-25-2003, 05:45 PM
not released yet

RenegadeOfPhunk
11-28-2003, 09:39 AM
Well - looks like the JKA code is a mixed bag, but maybe not as mixed as first impressions would give.

There is a new project called botlib (which seems to handle the MP ICARUS implimentation), alongside the normal game, cgame and ui projects (which are still in C, just as in JO).
The botlib project has 'technically' been written in C++. The source files have a .cpp extension, and there is at least one class - CInterpereter.

However, these is one small detail - that's the only class!! CInterpereter! That's it!

So really, in balance, the C++ part of the JKA code doesn't really add much OOP to the mix - if any at all. I'd say it's pretty much the same as JO as far as depth of OOP design - at least from what I've seen so far...

Wudan
11-28-2003, 01:53 PM
It looks like I expected - a nasty bag of ... stuff.

But hey, dev time was really just about a year - could've been worse.

RenegadeOfPhunk
11-28-2003, 02:33 PM
But hey, dev time was really just about a year - could've been worse.


True :)

razorace
11-28-2003, 07:34 PM
Well, at least they came up with an interesting solution to dynamic blade sizes and improved collisions.

legameboy
12-01-2003, 01:27 AM
I'm also interested in coding JA. There are two major problems, though.

1. I have no background in coding (just a little HTML here and there).

2. The only modding I have done is a map for Jedi Outcast, a couple of houses in Morrowind, and some beginner skinning for Jedi Academy.

I know it's really sad, and if I should just forget about it feel free to say so, I'm very interested in this though, if that counts for me at all. Anyways, I'd appreciate tips, comments, or flames and the like. Heh.

legameboy
12-05-2003, 03:00 AM
Anyone? :p

Wudan
12-05-2003, 01:53 PM
The tutorials and links listed above should help out significantly - if you have specific questions, you could ask those, or if you just want to quiz some folks about C syntax, go to the jkacoding channel on IRC (listed in my sig).