Page 1 of 1

Function stuff.

Posted: 03 Jan 2011, 21:57
by Iluvalar
Hello all, as you know I have a fork in wich we can easily change parameters in a text file and change the feel of the game. But Per really killed my enthousiasm with this question : « Why don't you use the original function code ? » XD . Well I must confesse he is right, I should but it's an hell of a nightmare code to change. And while my tweak stuff is really easy and fun to manipulate it's not enought robust to support all the engine from scratch. So we would just end up with 2 competitive code.

So I thinked during christmas on the "perfect" function.cpp and research.cpp system. Of course it's just ideas right now and it will be too much work for myself alone (but not that much). But we can talk about it. At start, it won't change anything in game experience. But as I look at it closer, it will totally improve the ease of maintenance of the code and new changes (new research, new structure, new whatever body, range, AI upgrade) in such a way it can be easily understandable by everyone.

So right now we have function objects looking like this :

psWhatAffected[ playernum ]->SomeParamName

all theses objects come with there own "load" and "upgrade" function that basically all do the same fu**** stuff. The only thing that change is the number of SomeParamNames that each psWhat_affected possess. But as it's all hardcoded at the other end, we really don't care how many object there is. So I suggest :

psFunction[ playernum ][ WhatAffected_Specify_SomeParamName ]

That name : WhatAffected_Specify_SomeParamName would be listed in a enum (like I did in tweak.c). This way we'll get a single "load" and a single "upgrade" function that goes with all parameters. All lines in function.txt will look the same :

Trigger, WhatAffected_Specify_SomeParamName, mode, value, player_no

exemples:

Code: Select all

init, Research__power, set, 32,64
init, Droid__armor, set, 100, 64
Research_DroidVtolArmour_Mk3,  Droid_Vtol_KineticArmour, multiply, 105 (1.05),32
Of course the upgrade function would be smart enought to understand all this by itself.

there would be more then one of theses "function.txt" (init > mod > map > faction) each of which running on the same versatile syntax.

I don't know if all of this is very clear. I might forget something important. That's why we talk first ;) . What do you think about all this ?

Re: Function stuff.

Posted: 08 Jan 2011, 04:26
by Safety0ff
I am not familiar with this system, so I cannot comment at the moment.

Re: Function stuff.

Posted: 14 Jan 2011, 18:52
by Iluvalar
Open function.cpp, you will see just a big bunch of "load" and "upgrade". That's is why you are not familiar with it. This is just redundant code. I suggest we all put those parameters in a single array. Because this way we will have a single way to describe and use all of them.

I think my idea permit cumulative mods, map specific behavior and whole new "faction" bonus all in the same move. But we have to think about it because it's some serious change, we'll have to change the name of those parameters code wide (switch many objects by a single array). I don't want to be in the middle off it and realise I forgot something and have the code between 2 chairs. If you know what i mean... that's why I'm asking you first about you impression.