UFO:Alien Invasion

Development => Newbie Coding => Topic started by: Malick on February 16, 2011, 08:29:47 pm

Title: First coding attempts : pilots
Post by: Malick on February 16, 2011, 08:29:47 pm
Hi all,

This is my first coding attempt, so I started with something which I thought could be easy to implement.

My goals are :
1 - learn the coding basics and get used to the project structure.
2 - improve the implementation of the pilots ingame, in order to make them as refined as soldiers.

For this, I will start with simple mods and patches, just to see if I catch the principle.
First step : number of spawned pilots during campaign (starting and monthly)

See next posts for more details.

Malick
Title: Re: First coding attempts : pilots
Post by: Malick on February 16, 2011, 08:32:40 pm
STEP 1 :
Make initial / starting number of pilots depend on campaign difficulty setting (in campaign.ufo)
Make number of pilots generated each month depend on Nations satisfaction (in nation.ufo)

It 'seems' to work...
I'm trying to create a patch with GIT and then I'll post it here for you to test.
I'll be back :)

Malick

EDIT : I think I found the way to make a patch... Can you try it and tell me if it works ?
OK, the filename is not the one I expected, but anyway, you can still try ^^
Title: Re: First coding attempts : pilots
Post by: geever on February 16, 2011, 10:55:35 pm
Hey!

Welcome on board, and Grat for your first patch!

However as I remember available pilot count was "unlimited" by design so you can always fly your aircraft. But I think your patch is needed (I wanted to do that, thanks!) and this design must be dropped soon. The problem is if we implement pilot stats and have 512 pilots on start, players will just select the best of best of best and leave (or remove) the others. Pilot counts should be probably higher though, but it's fine.

Briefly read your patch, it seems to be fine but have no time to playtest now.
But:
* you should fix the comments in it. As you see the diff (patch) knows which lines exactly you added there is no need to sign your name everywhere, we don't do it either.
* doxygen comments with double asterisk on the start or *< have special meaning you should use this form only in those special cases (in the middle of the code we usually don't use it) Check Coding guidelines (http://ufoai.ninex.info/wiki/index.php/Coding_guidelines) for more on our syntax rules

And at last: You can/should post patches to our Tracker (http://sourceforge.net/tracker/?group_id=157793) so it isn't lost.

-geever
Title: Re: First coding attempts : pilots
Post by: Malick on February 16, 2011, 11:18:08 pm
Hi geever,

Thanks for the feedback. It's rather simple anyway : generate x pilots at game start and y each month. I ruthlessly copied code from the soldiers lines :)
Regarding comments with my name in it, it's just to make it easier for me : I get often lost in the hundreds of files and thousands of lines... I'll remove them when i submit an official patch on the tracker, thanks.

I have made a simple roadmap for improvement of the pilots. If there is something already done by the team, I'll be glad to follow it, otherwise, here are my ideas :
1 - make pilots generated at the campaign start and each month depending on difficulty and nations [done]
2 - save the number of missions and shot down ufos, show it on screen [open]
3 - create a set of ranks, link them to the missions / kills for promotion [open]
4 - create a set of skills and attributes [open]
5 - create rules so that the skills have an impact on aircraft speed, range, targeting, missile evasion, crash survival etc.. [open]

If you have any comment or proposal, feel free to jump in !
I've been on these forums for sooooo long without contributing, it's time I do something ;)

Malick

EDIT : sent on tracker as 'pilots generated in campaign'. Please tell me if everything works fine, as I may have messed with the patching process  ::)
Title: Re: First coding attempts : pilots
Post by: bayo on February 17, 2011, 09:04:51 am
Quote
Regarding comments with my name in it, it's just to make it easier for me : I get often lost in the hundreds of files and thousands of lines... I'll remove them when i submit an official patch on the tracker, thanks.
git status and git diff answer u the thing u change
Title: Re: First coding attempts : pilots
Post by: geever on February 17, 2011, 11:06:41 am
1 - make pilots generated at the campaign start and each month depending on difficulty and nations [done]
2 - save the number of missions and shot down ufos, show it on screen [open]
3 - create a set of ranks, link them to the missions / kills for promotion [open]
4 - create a set of skills and attributes [open]
5 - create rules so that the skills have an impact on aircraft speed, range, targeting, missile evasion, crash survival etc.. [open]

We should discuss it with BTAxis. We have plans for pilots. Join to our IRC channel (in the evening, CET).

-geever
Title: Re: First coding attempts : pilots
Post by: MCR on February 17, 2011, 11:07:59 am
Great to see your motivation, Malick  8)
Title: Re: First coding attempts : pilots
Post by: Malick on February 18, 2011, 12:03:05 am
Hi there,

Thanks for the warm welcome.

I gave a look on the proposal for pilots and I think this is rather close. We can discuss this, I'll try to join the IRC in the next few days.

In the mean time, did you find any issue with the patch (the test one here or the one on the tracker) ?

On my side, I'm trying to implement simple attributes/skills.
I'm looking for the definition of character templates (soldier_heavy, soldier_assault etc..)... Where can I find them ?
Anyway, it's too late to code anything right now, so I'll test this maybe on sunday.

Malick

Title: Re: First coding attempts : pilots
Post by: geever on February 18, 2011, 08:00:35 am
I gave a look on the proposal for pilots and I think this is rather close. We can discuss this, I'll try to join the IRC in the next few days.

The proposal you probably found on wiki is a bit outdated - I mentioned it to BTAxis already. What I know is that pilots will have one stat, not three, but other details should be discussed.

In the mean time, did you find any issue with the patch (the test one here or the one on the tracker) ?

No, sorry.

On my side, I'm trying to implement simple attributes/skills.
I'm looking for the definition of character templates (soldier_heavy, soldier_assault etc..)... Where can I find them ?

did you ceck the ufo-scripts?

-geever
Title: Re: First coding attempts : pilots
Post by: Malick on February 18, 2011, 07:41:07 pm
Quote
did you ceck the ufo-scripts?

For some reason, team_templates didn't show up in codeblocks. Or I was falling asleep.  ;D
I got them now.

I'll be glad to have a chat with BTAxis and anyone who wants to join.
The attributes and skills I expected to implement were :
Code: [Select]
Attributes : Speed / Health / Mind
Skills : Piloting / Targeting / Evasion / Survival

Each governing particular parts of the interception, normal flight and air combat.

See you later...

Malick
Title: Re: First coding attempts : pilots
Post by: BTAxis on February 19, 2011, 10:56:27 am
Hi Malick, good show on working on the pilots so far. Let's talk about the design for pilots and air combat a bit.

Firstly, as you will probably already know, there's the proposal for UFO interceptions (http://ufoai.ninex.info/wiki/index.php/Gameplay_Proposals/UFO_Interceptions), which still counts as what we want to end up with eventually. Therefore, the pilot design should be done in this context.

Secondly, there's the old pilots proposal (http://ufoai.ninex.info/wiki/index.php/Proposals/Pilots) that stevenjackson did. This is old and no longer considered in line with our wishes, so this is the part we're looking to redesign here.

Now, my idea so far was just to use one stat for pilots that governed everything, but I see you've got something more complex in mind. So the questions I think we should answer are:
1) What exactly does each attribute do? Do the attributes only translate to a bonus to skills? If so, why do we need them?
2) What do each of the skills do exactly, in the context of the interception proposal?
3) By what mechanic do each of the attributes and skills improve?

From what I can see, 1) seems easy to answer: we don't need attributes. Pilots play a much smaller role in the game than soldiers, so they don't need to be modeled in too much detail. A pilot's performance can be adequately expressed in his skills alone, I feel.
As for 2), I think targeting, evasion and survival have obvious applications. Targeting gives a bonus to weapon accuracy, causing more shots to hit the target, evasion reduces enemy accuracy, and survival increases the chance of a rescue mission appearing if the pilot is shot down. I'm not sure about piloting, though. A plane doesn't fly any faster just because it has a good pilot. Not sure what this skill would do.
Finally 3), this depends on how far you want to go. But there seem to be only limited ways in which the various stats can increase independently from each other, since a pilot basically always does the same thing (shoot at the UFOs, and get shot at in turn). I think you'll end up with stats uniformly increasing most of the time, which is why they might as well be a single stat. But this is a point of further discussion.
Title: Re: First coding attempts : pilots
Post by: Malick on February 20, 2011, 12:58:23 pm
Hi BTAxis,

Thanks for your reply. Here are some of my thoughts :

1 - I agree in fact pilots do not really need 'attributes'. Everything can be expressed ingame by a skill, as they play in real time (no TU), do not take shots (no health) etc... So, I'll remove this.
2 - The piloting skill is like a 'driving' skill. A friend has exactly the same car as mine. However, he is always able to drive faster and use slightly less gas than me. How does he do that ? Well, he probably knows better than me. Furthermore, this is an all-around skill that could apply to both interceptors and dropships. However, coding its influence in game will be another story...
3 - Skill improving in mission : that's a trickier one. When a pilot uses his/her skills, then they will improve. How much ? To be defined, tested and debugged.

As a summary, I'll start with the 4 following skills : Piloting, Targeting, Evasion, Survival.
It seems reasonable enough, and covers the events in the life of a PHALANX pilot.

To geever : I uploaded a corrected patch on sourceforge. Can you tell me if it works ? I'm sorry, I messed with the patch file, so I think I have corrupted it.

Malick
Title: Re: First coding attempts : pilots
Post by: BTAxis on February 20, 2011, 01:47:28 pm
3 - Skill improving in mission : that's a trickier one. When a pilot uses his/her skills, then they will improve. How much ? To be defined, tested and debugged.

I think you'll run into a number of issues with that. If a pilot's skills when they get used, then wouldn't that encourage getting shot down, in order to train the survival skill? And wouldn't it encourage sending pilots out on flights all the time, even when there are no actual UFOs to intercept or missions to go to? And in combat, how would evasion and accuracy NOT improve equally quickly? Remember, the only way having multiple stats is meaningful at all is if they're used individually and independently from each other. Otherwise they're just a gimmick.
Title: Re: First coding attempts : pilots
Post by: Malick on February 20, 2011, 02:17:01 pm
Well, for the survival skill, there will be a good chance of loosing the pilot each time he's shot down. If the player is willing to take the risk.
And, having the pilots flying all the time just to improve their 'piloting' skill doesn't sound foolish to me : our respective air forces do it all the time ! The only limiting factor would be price of fuel and availibility for scramble / interception.
For targeting, if the pilots hits something, then his skill improves.
For evasion, it may be used as an additional check in the calculation in 'AIRFIGHT_ProbabilityToHit'. If succesful, then, the skill improves.

Right now, I'm struggling with the amount of code to be created just for the pilots.
Please correct me if I'm wrong :
Pilots can not use the same structure as the soldiers character_s.
As for the UGV, I need to create dedicated structures with attached functions :
- characterPilot_s
- CHRSH_CharGenPilotSkills to assign the skills
- chrPilotScoreGlobal_s to store them (and allow an evolution over time).

After this,  I'll modify the chrtemplates to take chrPilotTemplate, with parsing of the info from the template.ufo file.

I'm in for some serious coding !

Malick

EDIT: Alternatively, I may also modify the existing structure to take into account the new skills...
1 - I add new skills, all characters have them, but pilots have 0 skill in ground combat and soldiers 0 skill in flying. However, the savegames won't work.
2 - I re-use existing skills, will be less clean, but slightly easier. (for ex, ASSAULT - > PILOTING, HEAVY -> TARGETING, SNIPER-> EVASION...

What's your preferred solution ?
Title: Re: First coding attempts : pilots
Post by: H-Hour on February 20, 2011, 02:49:36 pm
And, having the pilots flying all the time just to improve their 'piloting' skill doesn't sound foolish to me : our respective air forces do it all the time ! The only limiting factor would be price of fuel and availibility for scramble / interception.

THe problem is not that it's unrealistic, but that it's not very fun. Scheduling air time for pilots would make for some tedious micro-management.
Title: Re: First coding attempts : pilots
Post by: Malick on February 20, 2011, 02:59:52 pm
Of course, but no one forces the player to do so...
It's up to him : if he wants to improve his pilots, he will manage the time it takes and cost to train them. Otherwise, just keep them warm in the hangar.
It may be used as an exploit (if the bonus of flying is too high), but it remains a tedious and dangerous one, if the player is caught with his interceptors anavailable or out of fuel.

Malick
Title: Re: First coding attempts : pilots
Post by: BTAxis on February 20, 2011, 03:04:49 pm
Well, for the survival skill, there will be a good chance of loosing the pilot each time he's shot down. If the player is willing to take the risk.

There is no risk. A player will simply load his game when he loses a pilot, you're going to have to assume so. UFO:AI is very save/load friendly in this respect, to the point that it offers the player that awful, awful retry button at the end of a tactical mission, for no other apparent reason than to save him the trouble of loading his game.

The point I'm making here is, if the skill is trainable by purposefully getting shot down, then players WILL do it, and load their game if it fails. Therefore, it's bad design.

Quote
And, having the pilots flying all the time just to improve their 'piloting' skill doesn't sound foolish to me : our respective air forces do it all the time ! The only limiting factor would be price of fuel and availibility for scramble / interception.

What H-Hour said. If it's possible to do this, then the player will feel forced to, because NOT doing it would be foolish. So it only adds tedium, I'm afraid.

Quote
For targeting, if the pilots hits something, then his skill improves.
For evasion, it may be used as an additional check in the calculation in 'AIRFIGHT_ProbabilityToHit'. If succesful, then, the skill improves.

Then you get a self-reinforcing effect. Good pilots will improve quicker than bad pilots, because they successfully hit/evade more often. This is counter to the principle of diminishing returns, which is what generally underlies training progress, and which is also what's used for soldier improvement.

I really don't mean to make your life difficult, but I know bad design when I see it, and I'm seeing it now.
Title: Re: First coding attempts : pilots
Post by: Malick on February 20, 2011, 03:38:56 pm
BTAxis,

OK, point taken. I'm not really a game designer myself.

However, your point applies to the entire game : if I loose a soldier, I just hit reload. If my base gets attacked because I was looking elsewhere, I just hit reload. So on...
What can prevent the player from doing so ? Does this mean this is bad design ? I don't think so.
Just because the players WILL try to exploit the game to a point where no attributes and skills are meaningful, does not mean necessarily we should not add features.

In my opinion, the solution is not to downgrade, but to have safeguards : flying a jet costs an awful lot of money. Losing a jet, costs also money. Currently, a dropship costs 30 000 credit, or just about 30 assault rifles.
Make this a realistic amount : an aircraft should cost at least 100 000 credits. But, this is just a method of preventing abuse.

Regarding the progress of the pilots, I believe this is the same principle applied to the soldiers : hit something with a gun and your skills improves. Bad soldiers can not hit a barn, they don't progress.

So, BTAxis, I get your point, but respectfuly disagree.
Plus, you make my life difficult ;)

Malick
Title: Re: First coding attempts : pilots
Post by: Malick on February 20, 2011, 03:50:20 pm
Gents,

I've been coding a little bit.
For the moment, I added 3 skills to all characters : piloting, targeting and evading. The crash survival is just a reuse of the HP value.
Soldiers will have 0 piloting/targeting/evading skills and pilots, 0 combat skills.
Here is a screenshot for example.
Skills have currently no applications, it will come at a later stage.

I'll progress a bit more and will generate a patch file.

Malick

EDIT : patch attached. I will post it on the tracker as well.
Title: Re: First coding attempts : pilots
Post by: BTAxis on February 20, 2011, 03:50:27 pm
However, your point applies to the entire game : if I loose a soldier, I just hit reload. If my base gets attacked because I was looking elsewhere, I just hit reload. So on...
What can prevent the player from doing so ? Does this mean this is bad design ? I don't think so.
Just because the players WILL try to exploit the game to a point where no attributes and skills are meaningful, does not mean necessarily we should not add features.

You're right about this, players can load their game, and will do so. There's no real way to prevent this, nor is it really desirable to. I mean, that would just make the game annoying for a lot of people, and we wouldn't want that. But we can at least try to make the system as exploit-free as we can. Don't rely on the player to make the choice you expect him to make, and don't expect mitigating circumstances to have the effect on the player you think they will. Instead, make the system robust, leaving no incentives for abuse.


So, in that light, and back on topic, I see only two decent ways we can do the pilot design.

Option 1:
Give pilots a number of skills, and make each skill govern a certain part of what the pilot does, like we discussed previously. However, these skills are fixed, never improving over their initial rolled values. The effect will be that the player is going to want to review his pilot roster from time to time, and maybe replace his current pilots with ones he likes better.

Option 2:
Give pilots one single skill, called simply "piloting", which governs ALL aspects of what the pilot does. This skill improves as the pilot participates in missions (exact mechanism to be determined later), or if he stands by at the base (on the assumption that he will spend this time training in a flight simulator).


Either way works for me, so take your pick.
Title: Re: First coding attempts : pilots
Post by: freegamer on February 23, 2011, 05:30:46 pm
Option 3:
Give a pilot base skills that are fixed and have another stat for experience that starts at 0.  Modifiers use a combination of the two.
Title: Re: First coding attempts : pilots
Post by: Malick on February 27, 2011, 04:49:49 pm
Gents,

STEP 3 :
Pilots now have skills, which have an effect in game.
Their skills are shown in the 'hire' menu and on the 'aircraft-pilots' menu.
Number of missions and number of shot down ufos are shown also.

Check the patches below for more details.

Malick

EDIT : gasp, there is an error in patch 003-Pilots-effects-and-skills... Redownload the updated version (there was a CLIENT_DEBUG instead of DEBUG_CLIENT...)
Title: Re: First coding attempts : pilots
Post by: gl0w on March 11, 2011, 07:49:33 pm
Brilliant Malick.
I think this makes sense and fits with the aforementioned Interception model (http://ufoai.ninex.info/wiki/index.php/Gameplay_Proposals/UFO_Interceptions). It just gives you data to calculate that 'to-hit' chance.  Could be applied to both the current interception system, and the planned system above.

I think its a relatively simple system that allows for some tactical choices to be made in regards to interceptors, which, IMHO, are much needed.
Title: Re: First coding attempts : pilots
Post by: Malick on March 12, 2011, 10:07:40 am
Thanks gl0w.

I've been away last week, so didn't find the time to develop any further.
I obviously need to put more work into this in order to make it fully functional.

Currently, I'm trying to understand how to make this a single patch ?
GIT seems to create serial patches for each and every code commit I do.. Is it possible to regroup everything into one global patch ?

Thanks

Malick