Author Topic: changing BANK_WHEN_TURN macro to a command line flag  (Read 5270 times)

0 Members and 1 Guest are viewing this topic.

Offline arisian

  • 23
changing BANK_WHEN_TURN macro to a command line flag
Hi guys,

So first off, let me apologize for doing this on the forum rather than through Mantis, but I seem to be having the same difficulty that several others have, in that my attempts to register with Mantis do not result in me being sent a confirmation e-mail (I've tried several different usernames and e-mail accounts at this point).

To make up for this,  rather than simply requesting the feature I want, I've gone ahead and added it.  I've attached the output of 'svn diff' (run in the code/ directory), so it should be easy to use 'patch' to apply it.  It needs further testing, however; it seems to do what I expect on my system (x86_64, Gentoo Linux, nVidia openGL drivers, 3-axis joystick), but I haven't had a chance to test it on other platforms.  

The feature is essentially a migration of a #defined macro to a run-time option by using a command line flag.  The macro in question is defined (or commented out) on line 499 of code/physics/physics.cpp, and is called BANK_WHEN_TURN.  This macro controls whether applying yaw controls induces roll.  The default behavior is that a small roll is induced by yaw.  Back in the day, I didn't mind this "feature" in, eg. the early Wing Commander games, when I only had a 2 axis joystick.  Now, however, I have a 3 axis joystick, and it was annoying to me that pitch and roll controls were "pure" controls, but yaw was not.  It's possible to alter this behavior by changing the #define mentioned above, but that's a compile-time change, which is really not ideal.  Moving it to a command line flag is much friendlier, and shouldn't really affect performance at all, since it effectively just adds one extra multiply operation to an already complex algebraic formula.

This is my first time working with this codebase, but the command line parameter handling seems to be implemented in a way which makes the introduction of new flags pretty simple; I've added the new flag "-no_bank_when_turn" as a "Gameplay" modification, given it a description, and provided a link to a (currently non-extant) part of the command line reference on the wiki.  If anyone has any questions about what I've done or why, please feel free to reply to this post, or PM me.  


[attachment deleted by Tolwyn]

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: changing BANK_WHEN_TURN macro to a command line flag
Should be an AI profiles flag, not command line. But good idea!

 

Offline arisian

  • 23
Re: changing BANK_WHEN_TURN macro to a command line flag
It's possible I'm misunderstanding what the AI Profiles flags are, since this is my first time mucking around in the SCP codebase, but my intent was to add a feature that changed the handling of *player* ships, not AI ships, which is why I made it a command line flag.  The default behavior is still what it always was, but this flag makes 3-axis joystick control more natural, particularly when yaw is mapped to the Z axis.  If I'm missing something, please let me know, and I'll try to move my fix to a more appropriate location within the code.

 

Offline Sushi

  • Art Critic
  • 211
Re: changing BANK_WHEN_TURN macro to a command line flag
First off, I applaud the attitude of "I'll fix this myself!".  :yes: Welcome to HLP! Expect a beam soon from someone soon...

The only problem I see with your patch is that it affects AI behavior as well. I like the idea of making it so that the player ship NEVER banks when turning, but the AI should still do so. In fact, you can already control the amount of bank in the turn on a per-ship basis:
http://hard-light.net/wiki/index.php/Ships.tbl#.24Banking_Constant:

So, there's really two things at play here:

1. Bank-when-turn applying to all ships (player and AI). This is already handlable via ships.tbl.

2. The option to not bank when turning for player ships only. This is, I think, what you're after, and IMO a command-line option for this makes a lot of sense (it's a player preference sort of thing). The only disadvantage I see is that some modders may want to control how much banking goes into a turn differently for different ships, to give them a unique feel. A flag like this would override that behavior, and possibly upset some modders. Maybe. :) Personally, I think it's a great idea, but you need to modify it to only affect the player ship. Fix that and the patch gets a :yes: from me. :D


EDIT: I just read your last post, making me feel pretty silly. :) Clearly your intention is player-only, but I was reading the patch and it doesn't seem to have that restriction... I'll look again more closely.

EDIT2: OK, this looks like it WILL apply to all ships (it's NOT exclusive to the player). physics_read_flying_controls is called by AI as well. So just fix it so that it only turns off bank when dealing with the player ship.
« Last Edit: August 06, 2009, 01:00:25 pm by Sushi »

 

Offline arisian

  • 23
Re: changing BANK_WHEN_TURN macro to a command line flag
It looks like you're right, the way I've done it will apply to all ships.  Again, I'm not that familiar with the codebase; I'll take another crack at it later this evening.  If anyone has pointers about easy ways to distinguish player ships from non-player ships, or other ideas about where the best place to implement this change would be, I'd be happy to hear about it; otherwise, I'll just poke around until I find something.

 

Offline Sushi

  • Art Critic
  • 211
Re: changing BANK_WHEN_TURN macro to a command line flag
It looks like you're right, the way I've done it will apply to all ships.  Again, I'm not that familiar with the codebase; I'll take another crack at it later this evening.  If anyone has pointers about easy ways to distinguish player ships from non-player ships, or other ideas about where the best place to implement this change would be, I'd be happy to hear about it; otherwise, I'll just poke around until I find something.

OF_PLAYER_SHIP is probably the flag you're looking for. Search through the codebase to see how it's used, I'm sure you can figure it out. :D

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: changing BANK_WHEN_TURN macro to a command line flag
If it were done via ai_profiles then a simple mod could be set up to work essentially with retail or any other mod.  Then it wouldn't be usable during validated multi matches without breaking validation, which should be the case, since it changes the playing ground for some players.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline arisian

  • 23
Re: changing BANK_WHEN_TURN macro to a command line flag
Okay, I've made another patch that moves the changes into playercontrol.cpp, where it should only affect player ships not under AI control.  As before, it seems to work for me, though I make no claim to have tested extensively yet.  I'm still not sure I understand the ai_profiles thing people are talking about; ai_profiles.cpp doesn't seem to have any references to the banking constant.  Any further feedback would be welcome.

[attachment deleted by Tolwyn]

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: changing BANK_WHEN_TURN macro to a command line flag
It has nothing to do with it _yet_, we're trying to say it shouldn't be a command line option, but a new flag enabled in the ai_profiles table.  That table controls various changes in the engine to the retail behavior.  Really it would be ideal if a mod could allow it to be one or the other or force it to be set a certain way.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: changing BANK_WHEN_TURN macro to a command line flag
Exactly.

 

Offline arisian

  • 23
Re: changing BANK_WHEN_TURN macro to a command line flag
Ahh, I see what you're saying now.  What I've done so far satisfies my personal desires (as a casual single-player gamer), but if you think it'll be a problem for multiplayer or for modding, I'll just hold onto the patches for my personal use.

I think I now understand what you mean about ai_profiles.  I guess I need to learn more about actual mods; I'm perfectly comfortable with C++ code, but I've never actually looked at a FSO mod, I'm just a casual player.  Where would I look for the .tbl files with AI parameters in them?  I assume they're hidden inside the .vp archives or something, since there don't seem to be any standard files with that extension.  Are there tools for opening those things under Linux?  All the modding tools I've found so seem to be Win32 only...

I was able to make the changes I wanted with a small number of relatively minor changes by opting for "simple and not likely to break everything" over "best possible way of doing it if I was starting from scratch".  If you think that the "right" way of doing this is a more major project, I should probably step back and let someone who's more familiar with the codebase handle it.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: changing BANK_WHEN_TURN macro to a command line flag
To open .vps under Linux, there's maja, which is Java based. Any of the other tools should work under wine. Get them here: http://www.freespacemods.net/download.php?list.51
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: changing BANK_WHEN_TURN macro to a command line flag
:welcome:

Also, your username looks similar to someone I know, and the fact that you're apparently also on linux has piqued my curiosity... you wouldn't happen to be Patrick Drummond, would you?

 

Offline Sushi

  • Art Critic
  • 211
Re: changing BANK_WHEN_TURN macro to a command line flag
I think I now understand what you mean about ai_profiles.  I guess I need to learn more about actual mods; I'm perfectly comfortable with C++ code, but I've never actually looked at a FSO mod, I'm just a casual player.  Where would I look for the .tbl files with AI parameters in them? 

Correct, they're in VP files under data/tables. Check out mods like Blue Planet: I'm pretty sure they have a custom AI_Profiles tbl file (and it's an awesome mod totally worth playing anyway).

If you do decide to make this work as an AI_Profiles flag (which isn't too hard) then there are ways to make a minimod that you can use alone or in combination with any other mod. Basically, you would make the code change so that it is triggered via AI_Profiles, then create something like arisian-aip.tbm with the change, stick it in a custom mod folder, then add that mod to the secondarylist (in mod.ini) of any other mods you happen to play. If you're interested, I & others will be happy to walk you through it.

I was able to make the changes I wanted with a small number of relatively minor changes by opting for "simple and not likely to break everything" over "best possible way of doing it if I was starting from scratch".  If you think that the "right" way of doing this is a more major project, I should probably step back and let someone who's more familiar with the codebase handle it.

No, your attitude is fine. :) Simple and nonbreaking is good, and this is a minor change that IMO doesn't need a huge project. Don't be shy about suggesting/contributing ideas and code, though! It's a good idea, and IMO still worth doing. Just learn how AI_Profiles work and move the option from the command-line to AI Profiles, and I think we're probably good.

Also, feel free to hang out on the SCP's IRC channel: #scp on irc.esper.net. Faster feedback! :)

 

Offline arisian

  • 23
Re: changing BANK_WHEN_TURN macro to a command line flag
Okay, thanks for the advice.  I'll open up the .vp files and take a crack at implementing this in ai_profiles, though it may take me a few days to get back around to this project.  I'll post a patch for ai_profiles when I'm done.

 

Offline arisian

  • 23
Re: changing BANK_WHEN_TURN macro to a command line flag
So, I've added some code that I *think* should work in ai_profiles, but I don't have any examples of a mod that actually uses an ai_profiles.tbl (blue planet doesn't seem to).  Anyone know of any mods that actually use ai_profiles.tbl so I can make sure I didn't break things?

Oh, and @Aardwolf, no, my name is Ben Mitchell (www.cs.jhu.edu/~ben).  The name 'arisian' is a reference to a classic space opera (http://en.wikipedia.org/wiki/Lensman_series).

 

Offline Sushi

  • Art Critic
  • 211
Re: changing BANK_WHEN_TURN macro to a command line flag
So, I've added some code that I *think* should work in ai_profiles, but I don't have any examples of a mod that actually uses an ai_profiles.tbl (blue planet doesn't seem to).  Anyone know of any mods that actually use ai_profiles.tbl so I can make sure I didn't break things?

Oh, and @Aardwolf, no, my name is Ben Mitchell (www.cs.jhu.edu/~ben).  The name 'arisian' is a reference to a classic space opera (http://en.wikipedia.org/wiki/Lensman_series).

Blue Planet does in fact use ai_profiles.tbl, but it's hidden inside the VP. :) You'll need one of the various tools for opening VP files to get to it (I use qvp). I probably should have mentioned that sooner. :D Once you find it and extract it, just put it in freespace2/blueplanet/data/tables and edit away. This works because any files NOT in a VP archive will override the ones that are.

 

Offline arisian

  • 23
Re: changing BANK_WHEN_TURN macro to a command line flag
Hmm, it doesn't seem to be in the copy of the blueplanet.vp that I have; I had figured out where it should be, it's just not there in the version of the .vp file that I have.  Maybe I need to find a newer version of the mod...if you have a link to the version you're using, I'd appreciate it.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: changing BANK_WHEN_TURN macro to a command line flag
Blue Planet forum.
BP 3.6.10 thread.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Sushi

  • Art Critic
  • 211
Re: changing BANK_WHEN_TURN macro to a command line flag
Link (this IS the internet :p)